System.out.println("Testing WeakBase.queryAdapter, XAdapter tests");
boolean[] r= new boolean[50];
int i= 0;
SomeClass comp= new SomeClass();
XAdapter adapter= comp.queryAdapter();
MyRef aRef1= new MyRef();
MyRef aRef2= new MyRef();
adapter.addReference(aRef1);
adapter.addReference(aRef2);
r[i++]= adapter.queryAdapted() == comp;
comp= null;
System.out.println("Wait 5 sec");
for(int c= 0; c < 50; c++)
{
try
{
Thread.currentThread().sleep(100);
System.gc();
System.runFinalization();
}catch (InterruptedException ie)
{
}
}
r[i++]= aRef1.nDisposeCalled == 1;
r[i++]= aRef2.nDisposeCalled == 1;
r[i++]= adapter.queryAdapted() == null;
adapter.removeReference(aRef1); // should not do any harm
adapter.removeReference(aRef2);
comp= new SomeClass();
adapter= comp.queryAdapter();
aRef1.nDisposeCalled= 0;
aRef2.nDisposeCalled= 0;
adapter.addReference(aRef1);
adapter.addReference(aRef2);
adapter.removeReference(aRef1);
System.out.println("Wait 5 sec");
comp= null;
for(int c= 0; c < 50; c++)
{
try