Description
Conduct a test case [1] on RI and HARMONY.
RI works well while HARMONY fails on both of them.
As to the 1st test, HARMONY uses "equals" method during destroying while RI doesn't.
I think this may be the root cause for the second test.
[1]
public void test_destroy_OverrideEquals() {
class MockThreadGroup extends ThreadGroup {
private boolean isCalled = false;
public void reset()
{ isCalled = false; }public boolean isCallEqauls()
{ return isCalled; }public MockThreadGroup(String name)
{ super(name); reset(); }public MockThreadGroup(ThreadGroup parent, String name)
{ super(parent, name); reset(); }public boolean equals(Object obj)
{ isCalled = true; return false; }}
MockThreadGroup ptg = new MockThreadGroup("Parent");
MockThreadGroup ctg = new MockThreadGroup(ptg, "Child");
MockThreadGroup dtg = new MockThreadGroup(ptg, "Daemon");
dtg.setDaemon(true);
assertEquals(2, ptg.activeGroupCount());
ptg.destroy();
assertFalse(ptg.isCallEqauls());
assertFalse(ctg.isCallEqauls());
assertFalse(dtg.isCallEqauls());
assertEquals(0, ptg.activeGroupCount());
}
public void test_setDaemonZ_Destory() throws InterruptedException {
ThreadGroup daemonGroup = new ThreadGroup("daemon");
Thread myThread = new Thread(daemonGroup, new Runnable() {
public void run() {
}
});
ThreadGroup childGroup = new ThreadGroup(daemonGroup, "child");
daemonGroup.setDaemon(true);
assertEquals(0, daemonGroup.activeCount());
childGroup.destroy();
assertTrue(childGroup.isDestroyed());
assertFalse(daemonGroup.isDestroyed());
myThread.start();
myThread.join();
assertTrue(daemonGroup.isDestroyed());
}