diff options
author | Sven Gothel <[email protected]> | 2014-10-03 05:49:57 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-10-03 05:49:57 +0200 |
commit | 773d96584b4edc13eb6ff689eaf891aab09aa5a4 (patch) | |
tree | b670122688f8c6f327664f600fc13d2f54f906f7 /src/junit/com/jogamp/common/util | |
parent | db12572b4f674884c3f7ad8f7e15ba9e97cf865a (diff) |
SingletonTestCase -> SingletonJunitCase: Accomodate ClassLoader lifecycle of static fields; Change name to avoid testing itself.
Diffstat (limited to 'src/junit/com/jogamp/common/util')
25 files changed, 64 insertions, 83 deletions
diff --git a/src/junit/com/jogamp/common/util/IntIntHashMapTest.java b/src/junit/com/jogamp/common/util/IntIntHashMapTest.java index 2de0c38..466e321 100644 --- a/src/junit/com/jogamp/common/util/IntIntHashMapTest.java +++ b/src/junit/com/jogamp/common/util/IntIntHashMapTest.java @@ -40,7 +40,7 @@ import org.junit.BeforeClass; import org.junit.Test; import com.jogamp.common.os.Platform; -import com.jogamp.junit.util.SingletonTestCase; +import com.jogamp.junit.util.SingletonJunitCase; import static org.junit.Assert.*; import static java.lang.System.*; @@ -54,7 +54,7 @@ import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class IntIntHashMapTest extends SingletonTestCase { +public class IntIntHashMapTest extends SingletonJunitCase { private static int iterations; private static IntIntUniqueRndValues pairs; diff --git a/src/junit/com/jogamp/common/util/IntObjectHashMapTest.java b/src/junit/com/jogamp/common/util/IntObjectHashMapTest.java index 9e5618b..091a159 100644 --- a/src/junit/com/jogamp/common/util/IntObjectHashMapTest.java +++ b/src/junit/com/jogamp/common/util/IntObjectHashMapTest.java @@ -40,7 +40,7 @@ import org.junit.BeforeClass; import org.junit.Test; import com.jogamp.common.os.Platform; -import com.jogamp.junit.util.SingletonTestCase; +import com.jogamp.junit.util.SingletonJunitCase; import static org.junit.Assert.*; @@ -53,7 +53,7 @@ import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class IntObjectHashMapTest extends SingletonTestCase { +public class IntObjectHashMapTest extends SingletonJunitCase { private static int iterations; private static IntIntObjUniqueRndValues pairs; diff --git a/src/junit/com/jogamp/common/util/LongIntHashMapTest.java b/src/junit/com/jogamp/common/util/LongIntHashMapTest.java index 9f868ba..9ea4206 100644 --- a/src/junit/com/jogamp/common/util/LongIntHashMapTest.java +++ b/src/junit/com/jogamp/common/util/LongIntHashMapTest.java @@ -40,7 +40,7 @@ import org.junit.BeforeClass; import org.junit.Test; import com.jogamp.common.os.Platform; -import com.jogamp.junit.util.SingletonTestCase; +import com.jogamp.junit.util.SingletonJunitCase; import static org.junit.Assert.*; import static java.lang.System.*; @@ -54,7 +54,7 @@ import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class LongIntHashMapTest extends SingletonTestCase { +public class LongIntHashMapTest extends SingletonJunitCase { private static int iterations; private static LongIntUniqueRndValues pairs; diff --git a/src/junit/com/jogamp/common/util/TestArrayHashSet01.java b/src/junit/com/jogamp/common/util/TestArrayHashSet01.java index f8e2c22..51db2c7 100644 --- a/src/junit/com/jogamp/common/util/TestArrayHashSet01.java +++ b/src/junit/com/jogamp/common/util/TestArrayHashSet01.java @@ -34,13 +34,13 @@ import java.io.IOException; import org.junit.Assert; import org.junit.Test; -import com.jogamp.junit.util.SingletonTestCase; +import com.jogamp.junit.util.SingletonJunitCase; import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class TestArrayHashSet01 extends SingletonTestCase { +public class TestArrayHashSet01 extends SingletonJunitCase { public static class Dummy { int i1, i2, i3; diff --git a/src/junit/com/jogamp/common/util/TestBitstream00.java b/src/junit/com/jogamp/common/util/TestBitstream00.java index 02d8c78..fa9c75d 100644 --- a/src/junit/com/jogamp/common/util/TestBitstream00.java +++ b/src/junit/com/jogamp/common/util/TestBitstream00.java @@ -42,7 +42,7 @@ import com.jogamp.common.os.Platform; import static com.jogamp.common.util.BitstreamData.*; -import com.jogamp.junit.util.SingletonTestCase; +import com.jogamp.junit.util.SingletonJunitCase; import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; @@ -51,7 +51,7 @@ import org.junit.runners.MethodSorters; * Test basic bit operations for {@link Bitstream} */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class TestBitstream00 extends SingletonTestCase { +public class TestBitstream00 extends SingletonJunitCase { @Test public void test00ShowByteOrder() { diff --git a/src/junit/com/jogamp/common/util/TestBitstream01.java b/src/junit/com/jogamp/common/util/TestBitstream01.java index bd8f563..99116e6 100644 --- a/src/junit/com/jogamp/common/util/TestBitstream01.java +++ b/src/junit/com/jogamp/common/util/TestBitstream01.java @@ -34,7 +34,7 @@ import java.nio.ByteBuffer; import org.junit.Assert; import org.junit.Test; -import com.jogamp.junit.util.SingletonTestCase; +import com.jogamp.junit.util.SingletonJunitCase; import static com.jogamp.common.util.BitstreamData.*; import org.junit.FixMethodOrder; @@ -53,7 +53,7 @@ import org.junit.runners.MethodSorters; * </ul> */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class TestBitstream01 extends SingletonTestCase { +public class TestBitstream01 extends SingletonJunitCase { Bitstream<ByteBuffer> getTestStream(final boolean msbFirst, final int preBits, final int skipBits, final int postBits) throws IOException { final int byteCount = ( preBits + skipBits + postBits + 7 ) / 8; diff --git a/src/junit/com/jogamp/common/util/TestBitstream02.java b/src/junit/com/jogamp/common/util/TestBitstream02.java index e5789e7..3fb4cce 100644 --- a/src/junit/com/jogamp/common/util/TestBitstream02.java +++ b/src/junit/com/jogamp/common/util/TestBitstream02.java @@ -35,7 +35,7 @@ import org.junit.Assert; import org.junit.Test; import com.jogamp.common.nio.Buffers; -import com.jogamp.junit.util.SingletonTestCase; +import com.jogamp.junit.util.SingletonJunitCase; import static com.jogamp.common.util.BitstreamData.*; @@ -51,7 +51,7 @@ import org.junit.runners.MethodSorters; * </ul> */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class TestBitstream02 extends SingletonTestCase { +public class TestBitstream02 extends SingletonJunitCase { @Test public void test01Int8BitsAligned() throws IOException { diff --git a/src/junit/com/jogamp/common/util/TestBitstream03.java b/src/junit/com/jogamp/common/util/TestBitstream03.java index 02555a5..4dfb3d7 100644 --- a/src/junit/com/jogamp/common/util/TestBitstream03.java +++ b/src/junit/com/jogamp/common/util/TestBitstream03.java @@ -36,7 +36,7 @@ import org.junit.Assert; import org.junit.Test; import com.jogamp.common.nio.Buffers; -import com.jogamp.junit.util.SingletonTestCase; +import com.jogamp.junit.util.SingletonJunitCase; import static com.jogamp.common.util.BitstreamData.*; @@ -52,7 +52,7 @@ import org.junit.runners.MethodSorters; * </ul> */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class TestBitstream03 extends SingletonTestCase { +public class TestBitstream03 extends SingletonJunitCase { @Test public void test01Int16BitsAligned() throws IOException { diff --git a/src/junit/com/jogamp/common/util/TestBitstream04.java b/src/junit/com/jogamp/common/util/TestBitstream04.java index b05f0ff..277510e 100644 --- a/src/junit/com/jogamp/common/util/TestBitstream04.java +++ b/src/junit/com/jogamp/common/util/TestBitstream04.java @@ -36,7 +36,7 @@ import org.junit.Assert; import org.junit.Test; import com.jogamp.common.nio.Buffers; -import com.jogamp.junit.util.SingletonTestCase; +import com.jogamp.junit.util.SingletonJunitCase; import static com.jogamp.common.util.BitstreamData.*; @@ -52,7 +52,7 @@ import org.junit.runners.MethodSorters; * </ul> */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class TestBitstream04 extends SingletonTestCase { +public class TestBitstream04 extends SingletonJunitCase { @Test public void test01Int32BitsAligned() throws IOException { diff --git a/src/junit/com/jogamp/common/util/TestFloatStack01.java b/src/junit/com/jogamp/common/util/TestFloatStack01.java index 409236e..7a22a44 100644 --- a/src/junit/com/jogamp/common/util/TestFloatStack01.java +++ b/src/junit/com/jogamp/common/util/TestFloatStack01.java @@ -35,13 +35,13 @@ import java.util.Arrays; import org.junit.Assert; import org.junit.Test; -import com.jogamp.junit.util.SingletonTestCase; +import com.jogamp.junit.util.SingletonJunitCase; import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class /*testname*/TestFloatStack01/*testname*/ extends SingletonTestCase { +public class /*testname*/TestFloatStack01/*testname*/ extends SingletonJunitCase { static final boolean equals(final /*value*/float/*value*/[] b, final int bOffset, final /*value*/float/*value*/[] stack, final int stackOffset, final int length) { diff --git a/src/junit/com/jogamp/common/util/TestIOUtil01.java b/src/junit/com/jogamp/common/util/TestIOUtil01.java index bbe0d64..539f883 100644 --- a/src/junit/com/jogamp/common/util/TestIOUtil01.java +++ b/src/junit/com/jogamp/common/util/TestIOUtil01.java @@ -45,13 +45,13 @@ import org.junit.Test; import com.jogamp.common.os.MachineDescription; import com.jogamp.common.os.Platform; -import com.jogamp.junit.util.SingletonTestCase; +import com.jogamp.junit.util.SingletonJunitCase; import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class TestIOUtil01 extends SingletonTestCase { +public class TestIOUtil01 extends SingletonJunitCase { static final MachineDescription machine = Platform.getMachineDescription(); static final int tsz = machine.pageSizeInBytes() + machine.pageSizeInBytes() / 2 ; diff --git a/src/junit/com/jogamp/common/util/TestIteratorIndexCORE.java b/src/junit/com/jogamp/common/util/TestIteratorIndexCORE.java index 9ade783..8289587 100644 --- a/src/junit/com/jogamp/common/util/TestIteratorIndexCORE.java +++ b/src/junit/com/jogamp/common/util/TestIteratorIndexCORE.java @@ -34,13 +34,13 @@ import java.io.IOException; import org.junit.Test; import com.jogamp.common.os.Platform; -import com.jogamp.junit.util.SingletonTestCase; +import com.jogamp.junit.util.SingletonJunitCase; import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class TestIteratorIndexCORE extends SingletonTestCase { +public class TestIteratorIndexCORE extends SingletonJunitCase { static int elems = 10; static int loop = ( Platform.getCPUFamily() == Platform.CPUFamily.ARM ) ? 20 : 9999999; diff --git a/src/junit/com/jogamp/common/util/TestJarUtil.java b/src/junit/com/jogamp/common/util/TestJarUtil.java index 42aa707..747da8f 100644 --- a/src/junit/com/jogamp/common/util/TestJarUtil.java +++ b/src/junit/com/jogamp/common/util/TestJarUtil.java @@ -51,13 +51,13 @@ import com.jogamp.common.os.AndroidVersion; import com.jogamp.common.util.cache.TempCacheReg; import com.jogamp.common.util.cache.TempFileCache; import com.jogamp.common.util.cache.TempJarCache; -import com.jogamp.junit.util.SingletonTestCase; +import com.jogamp.junit.util.SingletonJunitCase; import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class TestJarUtil extends SingletonTestCase { +public class TestJarUtil extends SingletonJunitCase { static TempFileCache fileCache; @BeforeClass diff --git a/src/junit/com/jogamp/common/util/TestPlatform01.java b/src/junit/com/jogamp/common/util/TestPlatform01.java index acdced3..fc88067 100644 --- a/src/junit/com/jogamp/common/util/TestPlatform01.java +++ b/src/junit/com/jogamp/common/util/TestPlatform01.java @@ -33,13 +33,13 @@ import org.junit.Test; import com.jogamp.common.os.MachineDescription; import com.jogamp.common.os.Platform; -import com.jogamp.junit.util.SingletonTestCase; +import com.jogamp.junit.util.SingletonJunitCase; import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class TestPlatform01 extends SingletonTestCase { +public class TestPlatform01 extends SingletonJunitCase { @Test public void testInfo00() { diff --git a/src/junit/com/jogamp/common/util/TestRunnableTask01.java b/src/junit/com/jogamp/common/util/TestRunnableTask01.java index 7c2f27a..76c2d2a 100644 --- a/src/junit/com/jogamp/common/util/TestRunnableTask01.java +++ b/src/junit/com/jogamp/common/util/TestRunnableTask01.java @@ -34,13 +34,13 @@ import java.lang.reflect.InvocationTargetException; import org.junit.Assert; import org.junit.Test; -import com.jogamp.junit.util.SingletonTestCase; +import com.jogamp.junit.util.SingletonJunitCase; import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class TestRunnableTask01 extends SingletonTestCase { +public class TestRunnableTask01 extends SingletonJunitCase { @Test public void testInvokeAndWait00() throws IOException, InterruptedException, InvocationTargetException { diff --git a/src/junit/com/jogamp/common/util/TestSystemPropsAndEnvs.java b/src/junit/com/jogamp/common/util/TestSystemPropsAndEnvs.java index 44eea42..ec71494 100644 --- a/src/junit/com/jogamp/common/util/TestSystemPropsAndEnvs.java +++ b/src/junit/com/jogamp/common/util/TestSystemPropsAndEnvs.java @@ -35,13 +35,13 @@ import java.util.Properties; import org.junit.Test; -import com.jogamp.junit.util.SingletonTestCase; +import com.jogamp.junit.util.SingletonJunitCase; import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class TestSystemPropsAndEnvs extends SingletonTestCase { +public class TestSystemPropsAndEnvs extends SingletonJunitCase { @Test public void dumpProperties() { diff --git a/src/junit/com/jogamp/common/util/TestTempJarCache.java b/src/junit/com/jogamp/common/util/TestTempJarCache.java index 20b14fb..9cc855f 100644 --- a/src/junit/com/jogamp/common/util/TestTempJarCache.java +++ b/src/junit/com/jogamp/common/util/TestTempJarCache.java @@ -51,10 +51,10 @@ import com.jogamp.common.os.Platform; import com.jogamp.common.util.cache.TempCacheReg; import com.jogamp.common.util.cache.TempFileCache; import com.jogamp.common.util.cache.TempJarCache; -import com.jogamp.junit.util.SingletonTestCase; +import com.jogamp.junit.util.SingletonJunitCase; @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class TestTempJarCache extends SingletonTestCase { +public class TestTempJarCache extends SingletonJunitCase { static TempFileCache fileCache; static class TestClassLoader extends URLClassLoader { diff --git a/src/junit/com/jogamp/common/util/TestVersionInfo.java b/src/junit/com/jogamp/common/util/TestVersionInfo.java index f548e39..2a9dfa1 100644 --- a/src/junit/com/jogamp/common/util/TestVersionInfo.java +++ b/src/junit/com/jogamp/common/util/TestVersionInfo.java @@ -32,13 +32,13 @@ import java.io.IOException; import org.junit.Test; import com.jogamp.common.GlueGenVersion; -import com.jogamp.junit.util.SingletonTestCase; +import com.jogamp.junit.util.SingletonJunitCase; import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class TestVersionInfo extends SingletonTestCase { +public class TestVersionInfo extends SingletonJunitCase { @Test public void testInfo01() { diff --git a/src/junit/com/jogamp/common/util/TestVersionNumber.java b/src/junit/com/jogamp/common/util/TestVersionNumber.java index 2959d18..9b86376 100644 --- a/src/junit/com/jogamp/common/util/TestVersionNumber.java +++ b/src/junit/com/jogamp/common/util/TestVersionNumber.java @@ -33,13 +33,13 @@ import java.io.IOException; import org.junit.Assert; import org.junit.Test; -import com.jogamp.junit.util.SingletonTestCase; +import com.jogamp.junit.util.SingletonJunitCase; import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class TestVersionNumber extends SingletonTestCase { +public class TestVersionNumber extends SingletonJunitCase { @Test public void test01() { diff --git a/src/junit/com/jogamp/common/util/TestVersionSemantics.java b/src/junit/com/jogamp/common/util/TestVersionSemantics.java index 8163ffb..6faa9a6 100644 --- a/src/junit/com/jogamp/common/util/TestVersionSemantics.java +++ b/src/junit/com/jogamp/common/util/TestVersionSemantics.java @@ -42,7 +42,7 @@ import org.semver.Delta; import com.jogamp.common.GlueGenVersion; import com.jogamp.common.util.VersionNumberString; -import com.jogamp.junit.util.SingletonTestCase; +import com.jogamp.junit.util.SingletonJunitCase; import com.jogamp.junit.util.VersionSemanticsUtil; /** @@ -64,7 +64,7 @@ import com.jogamp.junit.util.VersionSemanticsUtil; * @throws URISyntaxException */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class TestVersionSemantics extends SingletonTestCase { +public class TestVersionSemantics extends SingletonJunitCase { static final String jarFile = "gluegen-rt.jar"; static final VersionNumberString preVersionNumber = new VersionNumberString("2.2.0"); static final Delta.CompatibilityType expectedCompatibilityType = Delta.CompatibilityType.NON_BACKWARD_COMPATIBLE; diff --git a/src/junit/com/jogamp/common/util/locks/TestRecursiveLock01.java b/src/junit/com/jogamp/common/util/locks/TestRecursiveLock01.java index 09d96f2..4508f94 100644 --- a/src/junit/com/jogamp/common/util/locks/TestRecursiveLock01.java +++ b/src/junit/com/jogamp/common/util/locks/TestRecursiveLock01.java @@ -38,13 +38,13 @@ import org.junit.Assert; import org.junit.Test; import com.jogamp.common.os.Platform; -import com.jogamp.junit.util.SingletonTestCase; +import com.jogamp.junit.util.SingletonJunitCase; import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class TestRecursiveLock01 extends SingletonTestCase { +public class TestRecursiveLock01 extends SingletonJunitCase { public enum YieldMode { NONE(0), YIELD(1), SLEEP(2); diff --git a/src/junit/com/jogamp/common/util/locks/TestRecursiveThreadGroupLock01.java b/src/junit/com/jogamp/common/util/locks/TestRecursiveThreadGroupLock01.java index b338abe..e35d146 100644 --- a/src/junit/com/jogamp/common/util/locks/TestRecursiveThreadGroupLock01.java +++ b/src/junit/com/jogamp/common/util/locks/TestRecursiveThreadGroupLock01.java @@ -34,13 +34,13 @@ import org.junit.Assert; import org.junit.Test; import com.jogamp.common.os.Platform; -import com.jogamp.junit.util.SingletonTestCase; +import com.jogamp.junit.util.SingletonJunitCase; import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class TestRecursiveThreadGroupLock01 extends SingletonTestCase { +public class TestRecursiveThreadGroupLock01 extends SingletonJunitCase { public enum YieldMode { NONE(0), YIELD(1), SLEEP(2); diff --git a/src/junit/com/jogamp/common/util/locks/TestSingletonServerSocket00.java b/src/junit/com/jogamp/common/util/locks/TestSingletonServerSocket00.java index 775d46f..b018a79 100644 --- a/src/junit/com/jogamp/common/util/locks/TestSingletonServerSocket00.java +++ b/src/junit/com/jogamp/common/util/locks/TestSingletonServerSocket00.java @@ -32,35 +32,37 @@ import java.io.IOException; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; - import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; +import com.jogamp.junit.util.SingletonJunitCase; + @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestSingletonServerSocket00 { - // public static final String SINGLE_INSTANCE_LOCK_FILE = "UITestCase.lock"; - public static final int SINGLE_INSTANCE_LOCK_PORT = 59999; - public static final long SINGLE_INSTANCE_LOCK_TO = 3*60*1000; // wait up to 3 min - public static final long SINGLE_INSTANCE_LOCK_POLL = 100; // poll every 100ms + public static final long SINGLE_INSTANCE_LOCK_TO = SingletonJunitCase.SINGLE_INSTANCE_LOCK_TO; + + public static final long SINGLE_INSTANCE_LOCK_POLL = 100; // poll every 100ms + private static volatile SingletonInstance singletonInstance; @BeforeClass public static void oneTimeSetUp() { // one-time initialization code - singletonInstance = SingletonInstance.createServerSocket(SINGLE_INSTANCE_LOCK_POLL, SINGLE_INSTANCE_LOCK_PORT); + singletonInstance = SingletonInstance.createServerSocket(SINGLE_INSTANCE_LOCK_POLL, + SingletonJunitCase.SINGLE_INSTANCE_LOCK_PORT); } @Test - public void testLockUnlock() { + public void test01_LockUnlock() { Assert.assertTrue("Could not lock single instance: "+singletonInstance.getName(), singletonInstance.tryLock(SINGLE_INSTANCE_LOCK_TO)); System.gc(); // force cleanup singletonInstance.unlock(); } @Test - public void test2ndInstanceLockTimeout() { + public void test02_2ndInstanceLockTimeout() { Assert.assertTrue("Could not lock single instance: "+singletonInstance.getName(), singletonInstance.tryLock(SINGLE_INSTANCE_LOCK_TO)); - final SingletonInstance instanceTwo = SingletonInstance.createServerSocket(SINGLE_INSTANCE_LOCK_POLL, SINGLE_INSTANCE_LOCK_PORT); + final SingletonInstance instanceTwo = SingletonInstance.createServerSocket(SINGLE_INSTANCE_LOCK_POLL, SingletonJunitCase.SINGLE_INSTANCE_LOCK_PORT); Assert.assertFalse("Could lock 2nd instance: "+instanceTwo.getName(), instanceTwo.tryLock(1000)); // 10x System.gc(); // force cleanup singletonInstance.unlock(); @@ -69,7 +71,7 @@ public class TestSingletonServerSocket00 { private Thread startLockUnlockOffThread(final int i) { final Thread t = new Thread(new Runnable() { public void run() { - final SingletonInstance myLock = SingletonInstance.createServerSocket(10, SINGLE_INSTANCE_LOCK_PORT); + final SingletonInstance myLock = SingletonInstance.createServerSocket(10, SingletonJunitCase.SINGLE_INSTANCE_LOCK_PORT); System.err.println(Thread.currentThread().getName()+" LOCK try .."); Assert.assertTrue(Thread.currentThread().getName()+" - Could not lock instance: "+myLock.getName(), myLock.tryLock(1000)); System.err.println(Thread.currentThread().getName()+" LOCK ON"); diff --git a/src/junit/com/jogamp/common/util/locks/TestSingletonServerSocket01.java b/src/junit/com/jogamp/common/util/locks/TestSingletonServerSocket01.java index 82ca89b..b37e600 100644 --- a/src/junit/com/jogamp/common/util/locks/TestSingletonServerSocket01.java +++ b/src/junit/com/jogamp/common/util/locks/TestSingletonServerSocket01.java @@ -32,27 +32,24 @@ import java.io.IOException; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; - import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; +import com.jogamp.junit.util.SingletonJunitCase; + @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestSingletonServerSocket01 { - // public static final String SINGLE_INSTANCE_LOCK_FILE = "UITestCase.lock"; - public static final int SINGLE_INSTANCE_LOCK_PORT = 59999; - public static final long SINGLE_INSTANCE_LOCK_TO = 3*60*1000; // wait up to 3 min - public static final long SINGLE_INSTANCE_LOCK_POLL = 1000; // poll every 1s private static volatile SingletonInstance singletonInstance; @BeforeClass public static void oneTimeSetUp() { // one-time initialization code - singletonInstance = SingletonInstance.createServerSocket(SINGLE_INSTANCE_LOCK_POLL, SINGLE_INSTANCE_LOCK_PORT); + singletonInstance = SingletonInstance.createServerSocket(SingletonJunitCase.SINGLE_INSTANCE_LOCK_POLL, SingletonJunitCase.SINGLE_INSTANCE_LOCK_PORT); } @Test public void testJVMShutdown() { - Assert.assertTrue("Could not lock single instance: "+singletonInstance.getName(), singletonInstance.tryLock(SINGLE_INSTANCE_LOCK_TO)); + Assert.assertTrue("Could not lock single instance: "+singletonInstance.getName(), singletonInstance.tryLock(SingletonJunitCase.SINGLE_INSTANCE_LOCK_TO)); singletonInstance.unlock(); } diff --git a/src/junit/com/jogamp/common/util/locks/TestSingletonServerSocket02.java b/src/junit/com/jogamp/common/util/locks/TestSingletonServerSocket02.java index 50eebd6..d29abf0 100644 --- a/src/junit/com/jogamp/common/util/locks/TestSingletonServerSocket02.java +++ b/src/junit/com/jogamp/common/util/locks/TestSingletonServerSocket02.java @@ -33,31 +33,13 @@ import org.junit.Assert; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; - import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class TestSingletonServerSocket02 { - // public static final String SINGLE_INSTANCE_LOCK_FILE = "UITestCase.lock"; - public static final int SINGLE_INSTANCE_LOCK_PORT = 59999; - public static final long SINGLE_INSTANCE_LOCK_TO = 3*60*1000; // wait up to 3 min - public static final long SINGLE_INSTANCE_LOCK_POLL = 1000; // poll every 1s - private static volatile SingletonInstance singletonInstance; - - @BeforeClass - public static void oneTimeSetUp() { - // one-time initialization code - singletonInstance = SingletonInstance.createServerSocket(SINGLE_INSTANCE_LOCK_POLL, SINGLE_INSTANCE_LOCK_PORT); - Assert.assertTrue("Could not lock single instance: "+singletonInstance.getName(), singletonInstance.tryLock(SINGLE_INSTANCE_LOCK_TO)); - } - - @AfterClass - public static void oneTimeTearDown() { - System.gc(); // force cleanup - singletonInstance.unlock(); - } +import com.jogamp.junit.util.SingletonJunitCase; +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestSingletonServerSocket02 extends SingletonJunitCase { @Test public void dummy() throws InterruptedException { // make junit happy @@ -65,7 +47,7 @@ public class TestSingletonServerSocket02 { // @Test(timeout=10) // Only enable manually to test timeout behavior public void testTimeout() throws InterruptedException { - Thread.sleep(3000); + Thread.sleep(SingletonJunitCase.SINGLE_INSTANCE_LOCK_TO+3000); } public static void main(final String args[]) throws IOException, InterruptedException { |