From 18ceb207ddd8e9065a8e0bd4a64163a3a2a0a0ce Mon Sep 17 00:00:00 2001 From: Robert Antoni Buj i Gelonch Date: Thu, 2 Oct 2014 11:19:12 +0200 Subject: javaunohelper: More robust way to wait for finalization Change-Id: I09fa2462d8131381f380574b8a9aeaf080211b2b Reviewed-on: https://gerrit.libreoffice.org/11759 Reviewed-by: Noel Grandin Tested-by: Noel Grandin --- .../test/com/sun/star/lib/uno/helper/WeakBase_Test.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'javaunohelper/test/com/sun') diff --git a/javaunohelper/test/com/sun/star/lib/uno/helper/WeakBase_Test.java b/javaunohelper/test/com/sun/star/lib/uno/helper/WeakBase_Test.java index ef9fdbf8e0bd..07200b6b0fb5 100644 --- a/javaunohelper/test/com/sun/star/lib/uno/helper/WeakBase_Test.java +++ b/javaunohelper/test/com/sun/star/lib/uno/helper/WeakBase_Test.java @@ -34,6 +34,7 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import org.junit.Test; +import util.WaitUnreachable; public class WeakBase_Test { @@ -81,12 +82,9 @@ public class WeakBase_Test adapter.addReference(aRef2); assertSame(adapter.queryAdapted(), comp); + WaitUnreachable u = new WaitUnreachable(comp); comp= null; - logger.log(Level.FINE, "Wait 51ms (-XX:MaxGCPauseMillis=50)"); - System.gc(); - System.runFinalization(); - Thread.sleep(51); - + u.waitUnreachable(); assertEquals(aRef1.nDisposeCalled, 1); assertEquals(aRef2.nDisposeCalled, 1); assertNull(adapter.queryAdapted()); @@ -102,11 +100,9 @@ public class WeakBase_Test adapter.addReference(aRef2); adapter.removeReference(aRef1); - logger.log(Level.FINE, "Wait 51ms (-XX:MaxGCPauseMillis=50)"); + u = new WaitUnreachable(comp); comp= null; - System.gc(); - System.runFinalization(); - Thread.sleep(51); + u.waitUnreachable(); assertEquals(aRef1.nDisposeCalled, 0); assertEquals(aRef2.nDisposeCalled, 1); } -- cgit