From df9ff7f340a5ab4e07efc613f5f264eeae63d4c7 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 3 Jul 2014 16:06:47 +0200 Subject: Code Clean-Up based on our Recommended Settings (jogamp-scripting c47bc86ae2ee268a1f38c5580d11f93d7f8d6e74) Code Clean-Up based on our Recommended Settings (jogamp-scripting c47bc86ae2ee268a1f38c5580d11f93d7f8d6e74) - Change non static accesses to static members using declaring type - Change indirect accesses to static members to direct accesses (accesses through subtypes) - Add final modifier to private fields - Add final modifier to method parameters - Add final modifier to local variables - Remove unnecessary casts - Remove unnecessary '$NON-NLS$' tags - Remove trailing white spaces on all lines --- .../jogamp/common/net/AssetURLConnectionBase.java | 10 +- .../net/AssetURLConnectionRegisteredTest.java | 44 +-- .../net/AssetURLConnectionUnregisteredTest.java | 34 +- .../com/jogamp/common/net/TestURIQueryProps.java | 22 +- .../common/net/TestUrisWithAssetHandler.java | 6 +- src/junit/com/jogamp/common/net/URIDumpUtil.java | 6 +- src/junit/com/jogamp/common/nio/BuffersTest.java | 34 +- .../jogamp/common/nio/CachedBufferFactoryTest.java | 136 ++++---- .../nio/TestBuffersFloatDoubleConversion.java | 40 +-- .../jogamp/common/nio/TestPointerBufferEndian.java | 28 +- .../common/nio/TestStructAccessorEndian.java | 28 +- .../com/jogamp/common/os/TestElfReader01.java | 50 +-- .../com/jogamp/common/util/BitstreamData.java | 18 +- src/junit/com/jogamp/common/util/IntCloneable.java | 28 +- .../com/jogamp/common/util/IntIntHashMapTest.java | 90 +++--- .../common/util/IntIntObjUniqueRndValues.java | 20 +- .../jogamp/common/util/IntIntUniqueRndValues.java | 20 +- .../jogamp/common/util/IntObjectHashMapTest.java | 44 +-- .../com/jogamp/common/util/LongIntHashMapTest.java | 36 +-- .../jogamp/common/util/LongIntUniqueRndValues.java | 20 +- .../com/jogamp/common/util/RingBuffer01Base.java | 154 ++++----- .../com/jogamp/common/util/TestArrayHashSet01.java | 32 +- .../com/jogamp/common/util/TestBitstream00.java | 10 +- .../com/jogamp/common/util/TestBitstream01.java | 16 +- .../com/jogamp/common/util/TestBitstream02.java | 8 +- .../com/jogamp/common/util/TestBitstream03.java | 14 +- .../com/jogamp/common/util/TestBitstream04.java | 14 +- .../com/jogamp/common/util/TestFloatStack01.java | 142 ++++---- src/junit/com/jogamp/common/util/TestIOUtil01.java | 50 +-- .../jogamp/common/util/TestIOUtilURICompose.java | 14 +- .../jogamp/common/util/TestIOUtilURIHandling.java | 20 +- .../jogamp/common/util/TestIteratorIndexCORE.java | 40 ++- src/junit/com/jogamp/common/util/TestJarUtil.java | 44 +-- .../com/jogamp/common/util/TestLFRingBuffer01.java | 18 +- .../com/jogamp/common/util/TestPlatform01.java | 30 +- .../com/jogamp/common/util/TestRunnableTask01.java | 38 +-- .../jogamp/common/util/TestSyncRingBuffer01.java | 18 +- .../jogamp/common/util/TestSystemPropsAndEnvs.java | 38 +-- .../com/jogamp/common/util/TestTempJarCache.java | 74 ++--- .../jogamp/common/util/TestValueConversion.java | 26 +- .../com/jogamp/common/util/TestVersionInfo.java | 14 +- .../com/jogamp/common/util/TestVersionNumber.java | 96 +++--- .../jogamp/common/util/TestVersionSemantics.java | 4 +- .../common/util/locks/TestRecursiveLock01.java | 356 ++++++++++----------- .../util/locks/TestRecursiveThreadGroupLock01.java | 106 +++--- .../util/locks/TestSingletonServerSocket00.java | 16 +- .../util/locks/TestSingletonServerSocket01.java | 4 +- .../util/locks/TestSingletonServerSocket02.java | 4 +- .../gluegen/test/junit/generation/BaseClass.java | 184 +++++------ .../test/junit/generation/BindingJNILibLoader.java | 10 +- .../test/junit/generation/BuildEnvironment.java | 21 +- .../gluegen/test/junit/generation/PCPPTest.java | 30 +- .../test/junit/generation/Test1p1JavaEmitter.java | 4 +- .../junit/generation/Test1p2LoadJNIAndImplLib.java | 6 +- .../generation/Test1p2ProcAddressEmitter.java | 4 +- .../test/junit/structgen/TestStructGen01.java | 16 +- .../test/junit/structgen/TestStructGen02.java | 6 +- src/junit/com/jogamp/junit/sec/Applet01.java | 84 ++--- .../com/jogamp/junit/sec/TestSecIOUtil01.java | 24 +- src/junit/com/jogamp/junit/util/JunitTracer.java | 28 +- 60 files changed, 1264 insertions(+), 1267 deletions(-) (limited to 'src/junit/com/jogamp') diff --git a/src/junit/com/jogamp/common/net/AssetURLConnectionBase.java b/src/junit/com/jogamp/common/net/AssetURLConnectionBase.java index cb3fe14..e16003f 100644 --- a/src/junit/com/jogamp/common/net/AssetURLConnectionBase.java +++ b/src/junit/com/jogamp/common/net/AssetURLConnectionBase.java @@ -17,9 +17,9 @@ public abstract class AssetURLConnectionBase extends JunitTracer { /** In gluegen-rt.jar */ protected static final String test_asset_rt_url = "asset:gluegen/info.txt"; protected static final String test_asset_rt_entry = "gluegen/info.txt"; - + protected static final String test_asset_rt2_url = "asset:/gluegen/info.txt"; - + /** In gluegen.test.jar */ protected static final String test_asset_test1_url = "asset:gluegen-test/info.txt"; protected static final String test_asset_test1_entry = "gluegen-test/info.txt"; @@ -36,7 +36,7 @@ public abstract class AssetURLConnectionBase extends JunitTracer { protected static final String test_asset_test4b_url = "asset:/com/jogamp/common/net/data2/RelativeData2.txt"; protected static final String test_asset_test4_entry = "com/jogamp/common/net/data2/RelativeData2.txt"; - protected static void testAssetConnection(URLConnection c, String entry_name) throws IOException { + protected static void testAssetConnection(final URLConnection c, final String entry_name) throws IOException { Assert.assertNotNull(c); if(c instanceof AssetURLConnection) { final AssetURLConnection ac = (AssetURLConnection) c; @@ -49,7 +49,7 @@ public abstract class AssetURLConnectionBase extends JunitTracer { Assert.assertEquals(entry_name, jc.getEntryName()); } } - + final BufferedReader reader = new BufferedReader(new InputStreamReader(c.getInputStream())); try { String line = null; @@ -61,5 +61,5 @@ public abstract class AssetURLConnectionBase extends JunitTracer { } finally { IOUtil.close(reader, false); } - } + } } \ No newline at end of file diff --git a/src/junit/com/jogamp/common/net/AssetURLConnectionRegisteredTest.java b/src/junit/com/jogamp/common/net/AssetURLConnectionRegisteredTest.java index 2a3df41..7648990 100644 --- a/src/junit/com/jogamp/common/net/AssetURLConnectionRegisteredTest.java +++ b/src/junit/com/jogamp/common/net/AssetURLConnectionRegisteredTest.java @@ -17,7 +17,7 @@ import org.junit.runners.MethodSorters; @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class AssetURLConnectionRegisteredTest extends AssetURLConnectionBase { - + @BeforeClass public static void assetRegistration() throws Exception { try { @@ -25,68 +25,68 @@ public class AssetURLConnectionRegisteredTest extends AssetURLConnectionBase { Assert.assertTrue("GenericURLStreamHandlerFactory.register() failed", AssetURLContext.registerHandler(AssetURLConnectionRegisteredTest.class.getClassLoader())); Assert.assertNotNull(AssetURLContext.getRegisteredHandler()); System.err.println("******* Asset URL Stream Handler Registration: POST"); - } catch (Exception e) { + } catch (final Exception e) { setTestSupported(false); throw e; - } + } } - + @Test public void assetRegisteredURLConnection_RT() throws IOException { testAssetConnection(createAssetURLConnection(test_asset_rt_url), test_asset_rt_entry); } - + @Test public void assetRegisteredURLConnection_Test() throws IOException { testAssetConnection(createAssetURLConnection(test_asset_test1_url), test_asset_test1_entry); } - + @Test public void assetRegisteredIOUtilGetResourceRel1_RT() throws IOException, URISyntaxException { final URLConnection urlConn0 = IOUtil.getResource(test_asset_test2a_url, this.getClass().getClassLoader()); Assert.assertNotNull(urlConn0); Assert.assertEquals(test_asset_test2a_url, urlConn0.getURL().toExternalForm()); testAssetConnection(urlConn0, test_asset_test2_entry); - + final URI uri1 = IOUtil.getRelativeOf(urlConn0.getURL().toURI(), test_asset_test3_rel); Assert.assertNotNull(uri1); Assert.assertEquals(test_asset_test3a_url, uri1.toString()); testAssetConnection(uri1.toURL().openConnection(), test_asset_test3_entry); - + final URI uri2 = IOUtil.getRelativeOf(urlConn0.getURL().toURI(), test_asset_test4_rel); Assert.assertNotNull(uri2); Assert.assertEquals(test_asset_test4a_url, uri2.toString()); testAssetConnection(uri2.toURL().openConnection(), test_asset_test4_entry); } - + @Test public void assetRegisteredIOUtilGetResourceRel2_RT() throws IOException, URISyntaxException { final URLConnection urlConn0 = IOUtil.getResource(test_asset_test2b_url, this.getClass().getClassLoader()); Assert.assertNotNull(urlConn0); Assert.assertEquals(test_asset_test2b_url, urlConn0.getURL().toExternalForm()); testAssetConnection(urlConn0, test_asset_test2_entry); - + final URI uri1 = IOUtil.getRelativeOf(urlConn0.getURL().toURI(), test_asset_test3_rel); Assert.assertNotNull(uri1); Assert.assertEquals(test_asset_test3b_url, uri1.toString()); testAssetConnection(uri1.toURL().openConnection(), test_asset_test3_entry); - + final URI uri2 = IOUtil.getRelativeOf(urlConn0.getURL().toURI(), test_asset_test4_rel); Assert.assertNotNull(uri2); Assert.assertEquals(test_asset_test4b_url, uri2.toString()); - testAssetConnection(uri2.toURL().openConnection(), test_asset_test4_entry); + testAssetConnection(uri2.toURL().openConnection(), test_asset_test4_entry); } - - URLConnection createAssetURLConnection(String path) throws IOException { - URL url = AssetURLContext.createURL(path); - URLConnection c = url.openConnection(); + + URLConnection createAssetURLConnection(final String path) throws IOException { + final URL url = AssetURLContext.createURL(path); + final URLConnection c = url.openConnection(); System.err.println("createAssetURL: "+path+" -> url: "+url+" -> conn: "+c+" / connURL "+(null!=c?c.getURL():null)); - return c; - + return c; + } - - public static void main(String args[]) throws IOException { - String tstname = AssetURLConnectionRegisteredTest.class.getName(); + + public static void main(final String args[]) throws IOException { + final String tstname = AssetURLConnectionRegisteredTest.class.getName(); org.junit.runner.JUnitCore.main(tstname); - } + } } diff --git a/src/junit/com/jogamp/common/net/AssetURLConnectionUnregisteredTest.java b/src/junit/com/jogamp/common/net/AssetURLConnectionUnregisteredTest.java index 29b698e..5fbde49 100644 --- a/src/junit/com/jogamp/common/net/AssetURLConnectionUnregisteredTest.java +++ b/src/junit/com/jogamp/common/net/AssetURLConnectionUnregisteredTest.java @@ -20,46 +20,46 @@ public class AssetURLConnectionUnregisteredTest extends AssetURLConnectionBase { public void assetUnregisteredURLConnection_RT2() throws IOException { testAssetConnection(createAssetURLConnection(test_asset_rt2_url, this.getClass().getClassLoader()), test_asset_rt_entry); } - + @Test public void assetUnregisteredURLConnection_RT() throws IOException { testAssetConnection(createAssetURLConnection(test_asset_rt_url, this.getClass().getClassLoader()), test_asset_rt_entry); } - + @Test public void assetUnregisteredURLConnection_Test() throws IOException { testAssetConnection(createAssetURLConnection(test_asset_test1_url, this.getClass().getClassLoader()), test_asset_test1_entry); } - + @Test public void assetUnregisteredIOUtilGetResourceAbs_RT() throws IOException { - URLConnection c = IOUtil.getResource(test_asset_rt_entry, this.getClass().getClassLoader()); + final URLConnection c = IOUtil.getResource(test_asset_rt_entry, this.getClass().getClassLoader()); testAssetConnection(c, test_asset_rt_entry); } - + @Test public void assetUnregisteredIOUtilGetResourceRel0_RT() throws IOException, URISyntaxException { final URLConnection urlConn0 = IOUtil.getResource(this.getClass(), test_asset_test2_rel); testAssetConnection(urlConn0, test_asset_test2_entry); - + final URI uri1 = IOUtil.getRelativeOf(urlConn0.getURL().toURI(), test_asset_test3_rel); Assert.assertNotNull(uri1); // JARFile URL .. testAssetConnection(uri1.toURL().openConnection(), test_asset_test3_entry); - + final URI uri2 = IOUtil.getRelativeOf(urlConn0.getURL().toURI(), test_asset_test4_rel); Assert.assertNotNull(uri2); - testAssetConnection(uri2.toURL().openConnection(), test_asset_test4_entry); + testAssetConnection(uri2.toURL().openConnection(), test_asset_test4_entry); } - - protected static URLConnection createAssetURLConnection(String path, ClassLoader cl) throws IOException { - URL url = AssetURLContext.createURL(path, cl); - URLConnection c = url.openConnection(); + + protected static URLConnection createAssetURLConnection(final String path, final ClassLoader cl) throws IOException { + final URL url = AssetURLContext.createURL(path, cl); + final URLConnection c = url.openConnection(); System.err.println("createAssetURL: "+path+" -> url: "+url+" -> conn: "+c+" / connURL "+(null!=c?c.getURL():null)); - return c; + return c; } - - public static void main(String args[]) throws IOException { - String tstname = AssetURLConnectionUnregisteredTest.class.getName(); + + public static void main(final String args[]) throws IOException { + final String tstname = AssetURLConnectionUnregisteredTest.class.getName(); org.junit.runner.JUnitCore.main(tstname); - } + } } diff --git a/src/junit/com/jogamp/common/net/TestURIQueryProps.java b/src/junit/com/jogamp/common/net/TestURIQueryProps.java index 09cef61..4f4435a 100644 --- a/src/junit/com/jogamp/common/net/TestURIQueryProps.java +++ b/src/junit/com/jogamp/common/net/TestURIQueryProps.java @@ -16,35 +16,35 @@ import org.junit.runners.MethodSorters; @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestURIQueryProps extends JunitTracer { - + @Test public void test() throws IOException, URISyntaxException { final String SCHEME = "camera"; final String HOST = "somewhere"; final String PATH = "0"; - String[] args = new String[] { + final String[] args = new String[] { SCHEME+"://"+HOST+"/"+PATH, SCHEME+"://"+HOST+"/"+PATH+"?p1=1", }; for(int i=0; i -> "+uri1+" -> NULL"); } else { - URI uri1T = data.appendQuery(uri0); + final URI uri1T = data.appendQuery(uri0); showURI(uri1T); Assert.assertEquals(uri1, uri1T); } } } - public static void main(String args[]) throws IOException { - String tstname = TestURIQueryProps.class.getName(); + public static void main(final String args[]) throws IOException { + final String tstname = TestURIQueryProps.class.getName(); org.junit.runner.JUnitCore.main(tstname); - } + } } diff --git a/src/junit/com/jogamp/common/net/TestUrisWithAssetHandler.java b/src/junit/com/jogamp/common/net/TestUrisWithAssetHandler.java index 6e244eb..d2bfaf7 100644 --- a/src/junit/com/jogamp/common/net/TestUrisWithAssetHandler.java +++ b/src/junit/com/jogamp/common/net/TestUrisWithAssetHandler.java @@ -23,7 +23,7 @@ public class TestUrisWithAssetHandler extends JunitTracer { Assert.assertTrue("GenericURLStreamHandlerFactory.register() failed", AssetURLContext.registerHandler(TestUrisWithAssetHandler.class.getClassLoader())); Assert.assertNotNull(AssetURLContext.getRegisteredHandler()); System.err.println("******* Asset URL Stream Handler Registration: POST"); - } catch (Exception e) { + } catch (final Exception e) { setTestSupported(false); throw e; } @@ -43,8 +43,8 @@ public class TestUrisWithAssetHandler extends JunitTracer { showURX("asset:jar:file:/web1/file1.jar!/rootDir/dummyParent/../file1.txt"); } - public static void main(String args[]) throws IOException { - String tstname = TestUrisWithAssetHandler.class.getName(); + public static void main(final String args[]) throws IOException { + final String tstname = TestUrisWithAssetHandler.class.getName(); org.junit.runner.JUnitCore.main(tstname); } } diff --git a/src/junit/com/jogamp/common/net/URIDumpUtil.java b/src/junit/com/jogamp/common/net/URIDumpUtil.java index 132a19c..8d94b6d 100644 --- a/src/junit/com/jogamp/common/net/URIDumpUtil.java +++ b/src/junit/com/jogamp/common/net/URIDumpUtil.java @@ -6,14 +6,14 @@ import java.net.URISyntaxException; import java.net.URL; public class URIDumpUtil { - public static void showURX(String urx) throws MalformedURLException, URISyntaxException { + public static void showURX(final String urx) throws MalformedURLException, URISyntaxException { System.err.println("XXXXXX "+urx); showURL(new URL(urx)); showURI(new URI(urx)); System.err.println("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } - public static void showURL(URL url) { + public static void showURL(final URL url) { System.err.println("YYYYYY URL "+url); System.err.println("protocol: "+url.getProtocol()); System.err.println("auth: "+url.getAuthority()); @@ -22,7 +22,7 @@ public class URIDumpUtil { System.err.println("file: "+url.getFile() + " ( path " + url.getPath() + ", query " + url.getQuery() + " ) " ); System.err.println("ref: "+url.getRef()); } - public static void showURI(URI uri) { + public static void showURI(final URI uri) { System.err.println("ZZZZZZ URI "+uri); // 1 [scheme:]scheme-specific-part[#fragment] System.err.println("1 scheme: "+uri.getScheme()); diff --git a/src/junit/com/jogamp/common/nio/BuffersTest.java b/src/junit/com/jogamp/common/nio/BuffersTest.java index 9ad7823..68bd71f 100644 --- a/src/junit/com/jogamp/common/nio/BuffersTest.java +++ b/src/junit/com/jogamp/common/nio/BuffersTest.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + /* * Created on Sunday, July 04 2010 20:00 */ @@ -49,45 +49,45 @@ public class BuffersTest extends JunitTracer { @Test public void slice() { - - IntBuffer buffer = Buffers.newDirectIntBuffer(6); + + final IntBuffer buffer = Buffers.newDirectIntBuffer(6); buffer.put(new int[]{1,2,3,4,5,6}).rewind(); - IntBuffer threefour = Buffers.slice(buffer, 2, 2); + final IntBuffer threefour = Buffers.slice(buffer, 2, 2); assertEquals(3, threefour.get(0)); assertEquals(4, threefour.get(1)); assertEquals(2, threefour.capacity()); - + assertEquals(0, buffer.position()); assertEquals(6, buffer.limit()); - IntBuffer fourfivesix = Buffers.slice(buffer, 3, 3); + final IntBuffer fourfivesix = Buffers.slice(buffer, 3, 3); assertEquals(4, fourfivesix.get(0)); assertEquals(5, fourfivesix.get(1)); assertEquals(6, fourfivesix.get(2)); assertEquals(3, fourfivesix.capacity()); - + assertEquals(0, buffer.position()); assertEquals(6, buffer.limit()); - - IntBuffer onetwothree = Buffers.slice(buffer, 0, 3); + + final IntBuffer onetwothree = Buffers.slice(buffer, 0, 3); assertEquals(1, onetwothree.get(0)); assertEquals(2, onetwothree.get(1)); assertEquals(3, onetwothree.get(2)); assertEquals(3, onetwothree.capacity()); - + assertEquals(0, buffer.position()); assertEquals(6, buffer.limit()); - + // is it really sliced? buffer.put(2, 42); - + assertEquals(42, buffer.get(2)); assertEquals(42, onetwothree.get(2)); - + } diff --git a/src/junit/com/jogamp/common/nio/CachedBufferFactoryTest.java b/src/junit/com/jogamp/common/nio/CachedBufferFactoryTest.java index b0cd49e..b0f3cfb 100644 --- a/src/junit/com/jogamp/common/nio/CachedBufferFactoryTest.java +++ b/src/junit/com/jogamp/common/nio/CachedBufferFactoryTest.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -56,30 +56,30 @@ import org.junit.runners.MethodSorters; @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class CachedBufferFactoryTest extends JunitTracer { - + private final int BUFFERCOUNT = 120; - + private static int[] sizes; private static int[] values; private static IntBuffer[] buffers; - + @Before public void setup() { - + sizes = new int[BUFFERCOUNT]; values = new int[sizes.length]; buffers = new IntBuffer[sizes.length]; - - Random rnd = new Random(7); - + + final Random rnd = new Random(7); + // setup for (int i = 0; i < sizes.length; i++) { sizes[i] = rnd.nextInt(80)+1; values[i] = rnd.nextInt(); } - + } - + @After public void teardown() { sizes = null; @@ -89,34 +89,34 @@ public class CachedBufferFactoryTest extends JunitTracer { @Test public void dynamicTest() { - - CachedBufferFactory factory = CachedBufferFactory.create(64); - + + final CachedBufferFactory factory = CachedBufferFactory.create(64); + // create for (int i = 0; i < sizes.length; i++) { buffers[i] = factory.newDirectIntBuffer(sizes[i]); assertEquals(ByteOrder.nativeOrder(), buffers[i].order()); fill(buffers[i], values[i]); } - + // check checkBuffers(buffers, sizes, values); - + } - + @Test public void dynamicConcurrentTest() throws InterruptedException, ExecutionException { - + final CachedBufferFactory factory = CachedBufferFactory.createSynchronized(24); - - List> callables = new ArrayList>(); - + + final List> callables = new ArrayList>(); + final CountDownLatch latch = new CountDownLatch(10); - + // create for (int i = 0; i < sizes.length; i++) { final int n = i; - Callable c = new Callable() { + final Callable c = new Callable() { public Object call() throws Exception { latch.countDown(); latch.await(); @@ -127,52 +127,52 @@ public class CachedBufferFactoryTest extends JunitTracer { }; callables.add(c); } - - ExecutorService dathVader = Executors.newFixedThreadPool(10); + + final ExecutorService dathVader = Executors.newFixedThreadPool(10); dathVader.invokeAll(callables); - + dathVader.shutdown(); - + // check checkBuffers(buffers, sizes, values); - + } - private void checkBuffers(IntBuffer[] buffers, int[] sizes, int[] values) { + private void checkBuffers(final IntBuffer[] buffers, final int[] sizes, final int[] values) { for (int i = 0; i < buffers.length; i++) { - IntBuffer buffer = buffers[i]; + final IntBuffer buffer = buffers[i]; assertEquals(sizes[i], buffer.capacity()); assertEquals(0, buffer.position()); assertTrue(equals(buffer, values[i])); } } - + @Test public void staticTest() { - - CachedBufferFactory factory = CachedBufferFactory.create(10, true); - + + final CachedBufferFactory factory = CachedBufferFactory.create(10, true); + for (int i = 0; i < 5; i++) { factory.newDirectByteBuffer(2); } - + try{ factory.newDirectByteBuffer(1); fail(); - }catch (RuntimeException ex) { + }catch (final RuntimeException ex) { // expected } - + } - - private void fill(IntBuffer buffer, int value) { + + private void fill(final IntBuffer buffer, final int value) { while(buffer.remaining() != 0) buffer.put(value); buffer.rewind(); } - - private boolean equals(IntBuffer buffer, int value) { + + private boolean equals(final IntBuffer buffer, final int value) { while(buffer.remaining() != 0) { if(value != buffer.get()) return false; @@ -181,37 +181,37 @@ public class CachedBufferFactoryTest extends JunitTracer { buffer.rewind(); return true; } - - + + /* load testing */ - + private int size = 4; - private int iterations = 10000; - + private final int iterations = 10000; + // @Test public Object loadTest() { - CachedBufferFactory factory = CachedBufferFactory.create(); - ByteBuffer[] buffer = new ByteBuffer[iterations]; + final CachedBufferFactory factory = CachedBufferFactory.create(); + final ByteBuffer[] buffer = new ByteBuffer[iterations]; for (int i = 0; i < buffer.length; i++) { buffer[i] = factory.newDirectByteBuffer(size); } return buffer; } - + // @Test public Object referenceTest() { - ByteBuffer[] buffer = new ByteBuffer[iterations]; + final ByteBuffer[] buffer = new ByteBuffer[iterations]; for (int i = 0; i < buffer.length; i++) { buffer[i] = Buffers.newDirectByteBuffer(size); } return buffer; } - - - public static void main(String[] args) { - + + + public static void main(final String[] args) { + CachedBufferFactoryTest test = new CachedBufferFactoryTest(); - + out.print("warmup..."); Object obj = null; for (int i = 0; i < 100; i++) { @@ -220,33 +220,33 @@ public class CachedBufferFactoryTest extends JunitTracer { gc(); } out.println("done"); - + test = new CachedBufferFactoryTest(); gc(); - + for (int i = 0; i < 10; i++) { - + out.println("allocation size: "+test.size); - + long time = System.currentTimeMillis(); obj = test.referenceTest(); if(obj == null) return; // ref lock - + out.println("reference: "+ (System.currentTimeMillis()-time)); gc(); - + time = currentTimeMillis(); obj = test.loadTest(); if(obj == null) return; // ref lock - + out.println("factory: "+ (System.currentTimeMillis()-time)); - + gc(); - + test.size*=2; } - + } - + } diff --git a/src/junit/com/jogamp/common/nio/TestBuffersFloatDoubleConversion.java b/src/junit/com/jogamp/common/nio/TestBuffersFloatDoubleConversion.java index 192a49e..61bbafa 100644 --- a/src/junit/com/jogamp/common/nio/TestBuffersFloatDoubleConversion.java +++ b/src/junit/com/jogamp/common/nio/TestBuffersFloatDoubleConversion.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.common.nio; import java.io.IOException; @@ -41,7 +41,7 @@ import org.junit.runners.MethodSorters; @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestBuffersFloatDoubleConversion extends JunitTracer { - public static boolean cmpFloatArray(float[] d1, int d1_offset, float[] d2, int d2_offset, int len) { + public static boolean cmpFloatArray(final float[] d1, final int d1_offset, final float[] d2, final int d2_offset, final int len) { if( d1.length - d1_offset < len) { throw new RuntimeException("d1 too small len "+len+" > "+d1.length+" - "+d1_offset); } @@ -55,7 +55,7 @@ public class TestBuffersFloatDoubleConversion extends JunitTracer { return ok; } - public static boolean cmpDoubleArray(double[] d1, int d1_offset, double[] d2, int d2_offset, int len) { + public static boolean cmpDoubleArray(final double[] d1, final int d1_offset, final double[] d2, final int d2_offset, final int len) { if( d1.length - d1_offset < len) { throw new RuntimeException("d1 too small len "+len+" > "+d1.length+" - "+d1_offset); } @@ -69,7 +69,7 @@ public class TestBuffersFloatDoubleConversion extends JunitTracer { return ok; } - public static void incrFloatArray(float[] data, int offset, int len) { + public static void incrFloatArray(final float[] data, final int offset, final int len) { if( data.length - offset < len) { throw new RuntimeException("data too small len "+len+" > "+data.length+" - "+offset); } @@ -78,7 +78,7 @@ public class TestBuffersFloatDoubleConversion extends JunitTracer { } } - public static void incrDoubleArray(double[] data, int offset, int len) { + public static void incrDoubleArray(final double[] data, final int offset, final int len) { if( data.length - offset < len) { throw new RuntimeException("data too small len "+len+" > "+data.length+" - "+offset); } @@ -87,7 +87,7 @@ public class TestBuffersFloatDoubleConversion extends JunitTracer { } } - public static void setFloatArray(float[] data, int offset, int len) { + public static void setFloatArray(final float[] data, final int offset, final int len) { if( data.length - offset < len) { throw new RuntimeException("data too small len "+len+" > "+data.length+" - "+offset); } @@ -96,7 +96,7 @@ public class TestBuffersFloatDoubleConversion extends JunitTracer { } } - public static void setDoubleArray(double[] data, int offset, int len) { + public static void setDoubleArray(final double[] data, final int offset, final int len) { if( data.length - offset < len) { throw new RuntimeException("data too small len "+len+" > "+data.length+" - "+offset); } @@ -105,8 +105,8 @@ public class TestBuffersFloatDoubleConversion extends JunitTracer { } } - public static void doItDoubleArray01(double[] data, int offset, int len) { - float[] f_data = Buffers.getFloatArray(data, offset, null, 0, len); + public static void doItDoubleArray01(final double[] data, final int offset, final int len) { + final float[] f_data = Buffers.getFloatArray(data, offset, null, 0, len); incrFloatArray(f_data, 0, len); Buffers.getDoubleArray(f_data, 0, data, offset, len); } @@ -117,23 +117,23 @@ public class TestBuffersFloatDoubleConversion extends JunitTracer { final int len = 20; // reference 1 - float[] fa_ref = new float[100]; + final float[] fa_ref = new float[100]; setFloatArray(fa_ref, offset, len); incrFloatArray(fa_ref, offset, len); // reference 2 - double[] da_ref = new double[100]; + final double[] da_ref = new double[100]; setDoubleArray(da_ref, offset, len); incrDoubleArray(da_ref, offset, len); // test 1: forth and back .. double -> float -> double { - double[] da1 = new double[100]; + final double[] da1 = new double[100]; setDoubleArray(da1, offset, len); incrDoubleArray(da1, offset, len); // conv_forth: double[offset..len] -> float[0..len] - float[] f_da1 = Buffers.getFloatArray(da1, offset, null, 0, len); + final float[] f_da1 = Buffers.getFloatArray(da1, offset, null, 0, len); Assert.assertTrue(cmpFloatArray(fa_ref, offset, f_da1, 0, len)); // conv_back: float[0..len] -> double[offset..len] @@ -143,7 +143,7 @@ public class TestBuffersFloatDoubleConversion extends JunitTracer { // test 2: forth, incr, back .. double -> float -> incr -> double { - double[] da1 = new double[100]; + final double[] da1 = new double[100]; setDoubleArray(da1, offset, len); doItDoubleArray01(da1, offset, len); @@ -151,8 +151,8 @@ public class TestBuffersFloatDoubleConversion extends JunitTracer { } } - public static void main(String args[]) throws IOException { - String tstname = TestBuffersFloatDoubleConversion.class.getName(); + public static void main(final String args[]) throws IOException { + final String tstname = TestBuffersFloatDoubleConversion.class.getName(); org.junit.runner.JUnitCore.main(tstname); } diff --git a/src/junit/com/jogamp/common/nio/TestPointerBufferEndian.java b/src/junit/com/jogamp/common/nio/TestPointerBufferEndian.java index 3a1c584..49a470f 100644 --- a/src/junit/com/jogamp/common/nio/TestPointerBufferEndian.java +++ b/src/junit/com/jogamp/common/nio/TestPointerBufferEndian.java @@ -3,6 +3,8 @@ package com.jogamp.common.nio; import java.io.IOException; +import jogamp.common.os.PlatformPropsImpl; + import com.jogamp.common.os.*; import com.jogamp.junit.util.JunitTracer; @@ -17,24 +19,24 @@ import org.junit.runners.MethodSorters; @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestPointerBufferEndian extends JunitTracer { - protected void testImpl (boolean direct) { + protected void testImpl (final boolean direct) { final MachineDescription machine = Platform.getMachineDescription(); - int bitsPtr = machine.pointerSizeInBytes() * 8; - String bitsProp = System.getProperty("sun.arch.data.model"); - out.println("OS: <"+Platform.OS+"> CPU: <"+Platform.ARCH+"> Bits: <"+bitsPtr+"/"+bitsProp+">"); + final int bitsPtr = machine.pointerSizeInBytes() * 8; + final String bitsProp = System.getProperty("sun.arch.data.model"); + out.println("OS: <"+PlatformPropsImpl.OS+"> CPU: <"+PlatformPropsImpl.ARCH+"> Bits: <"+bitsPtr+"/"+bitsProp+">"); out.println(machine.toString()); - long[] valuesSource = { 0x0123456789ABCDEFL, 0x8877665544332211L, 0xAFFEDEADBEEFAFFEL }; - long[] values32Bit = { 0x0000000089ABCDEFL, 0x0000000044332211L, 0x00000000BEEFAFFEL }; + final long[] valuesSource = { 0x0123456789ABCDEFL, 0x8877665544332211L, 0xAFFEDEADBEEFAFFEL }; + final long[] values32Bit = { 0x0000000089ABCDEFL, 0x0000000044332211L, 0x00000000BEEFAFFEL }; - PointerBuffer ptr = direct ? PointerBuffer.allocateDirect(3) : PointerBuffer.allocate(valuesSource.length); + final PointerBuffer ptr = direct ? PointerBuffer.allocateDirect(3) : PointerBuffer.allocate(valuesSource.length); ptr.put(valuesSource, 0, valuesSource.length); ptr.rewind(); int i=0; while(ptr.hasRemaining()) { - long v = ptr.get() ; - long t = Platform.is32Bit() ? values32Bit[i] : valuesSource[i]; + final long v = ptr.get() ; + final long t = Platform.is32Bit() ? values32Bit[i] : valuesSource[i]; Assert.assertTrue("Value["+i+"] shall be 0x"+Long.toHexString(t)+", is: 0x"+Long.toHexString(v), t == v); i++; } @@ -50,9 +52,9 @@ public class TestPointerBufferEndian extends JunitTracer { public void testIndirect () { testImpl (false); } - - public static void main(String args[]) throws IOException { - String tstname = TestPointerBufferEndian.class.getName(); + + public static void main(final String args[]) throws IOException { + final String tstname = TestPointerBufferEndian.class.getName(); org.junit.runner.JUnitCore.main(tstname); - } + } } diff --git a/src/junit/com/jogamp/common/nio/TestStructAccessorEndian.java b/src/junit/com/jogamp/common/nio/TestStructAccessorEndian.java index 62eccf0..967122e 100644 --- a/src/junit/com/jogamp/common/nio/TestStructAccessorEndian.java +++ b/src/junit/com/jogamp/common/nio/TestStructAccessorEndian.java @@ -5,6 +5,8 @@ import static java.lang.System.out; import java.io.IOException; import java.nio.ByteBuffer; +import jogamp.common.os.PlatformPropsImpl; + import org.junit.Assert; import org.junit.Test; @@ -20,16 +22,16 @@ public class TestStructAccessorEndian extends JunitTracer { @Test public void testStructAccessorEndian1 () { - final MachineDescription machine = Platform.getMachineDescription(); - int bitsPtr = machine.pointerSizeInBytes() * 8; - String bitsProp = System.getProperty("sun.arch.data.model"); - out.println("OS: <"+Platform.OS+"> CPU: <"+Platform.ARCH+"> Bits: <"+bitsPtr+"/"+bitsProp+">"); + final MachineDescription machine = Platform.getMachineDescription(); + final int bitsPtr = machine.pointerSizeInBytes() * 8; + final String bitsProp = System.getProperty("sun.arch.data.model"); + out.println("OS: <"+PlatformPropsImpl.OS+"> CPU: <"+PlatformPropsImpl.ARCH+"> Bits: <"+bitsPtr+"/"+bitsProp+">"); out.println("CPU is: "+ (Platform.is32Bit()?"32":"64") + " bit"); out.println(machine.toString()); - long[] valuesSource = { 0x0123456789ABCDEFL, 0x8877665544332211L, 0xAFFEDEADBEEFAFFEL }; - ByteBuffer tst = Buffers.newDirectByteBuffer(Buffers.SIZEOF_LONG * valuesSource.length); - StructAccessor acc = new StructAccessor(tst); + final long[] valuesSource = { 0x0123456789ABCDEFL, 0x8877665544332211L, 0xAFFEDEADBEEFAFFEL }; + final ByteBuffer tst = Buffers.newDirectByteBuffer(Buffers.SIZEOF_LONG * valuesSource.length); + final StructAccessor acc = new StructAccessor(tst); int i; @@ -38,15 +40,15 @@ public class TestStructAccessorEndian extends JunitTracer { } for(i=0; i possibleLibPaths = NativeLibrary.enumerateLibraryPaths(libName, libName, libName, true, cl); for(int i=0; i entry : map.entrySet()) { + for (final Entry entry : map.entrySet()) { assertTrue(intmap.containsKey(entry.getKey())); assertTrue(intmap.containsValue(entry.getValue())); } int i = 0; - for (Entry entry : map.entrySet()) { + for (final Entry entry : map.entrySet()) { assertEquals((int)entry.getValue(), intmap.remove(entry.getKey())); assertEquals(map.size() - i - 1, intmap.size()); i++; } } - + @Test public void iteratorTest() { @@ -108,14 +108,14 @@ public class IntIntHashMapTest { for (int i = 0; i < iterations; i++) { intmap.put(pairs.keys[i], pairs.values[i]); } - - Iterator iterator = intmap.iterator(); + + final Iterator iterator = intmap.iterator(); assertNotNull(iterator); assertTrue(iterator.hasNext()); int n = 0; while (iterator.hasNext()) { - IntIntHashMap.Entry entry = iterator.next(); + final IntIntHashMap.Entry entry = iterator.next(); assertNotNull(entry); n++; } @@ -129,33 +129,33 @@ public class IntIntHashMapTest { public void cloneTest() { final int smallSize = iterations / 4 ; - + final IntIntHashMap intmap = new IntIntHashMap( smallSize + smallSize / 4, 0.75f); intmap.setKeyNotFoundValue(-1); - + for (int i = 0; i < smallSize; i++) { intmap.put(pairs.keys[i], pairs.values[i]); } assertEquals(intmap.size(), smallSize); - + final IntIntHashMap intmapCopy = (IntIntHashMap) intmap.clone(); - + assertEquals(intmap.size(), intmapCopy.size()); assertEquals(intmap.getKeyNotFoundValue(), intmapCopy.getKeyNotFoundValue()); - - Iterator iterator = intmap.iterator(); + + final Iterator iterator = intmap.iterator(); assertNotNull(iterator); assertTrue(iterator.hasNext()); - Iterator iteratorCopy = intmapCopy.iterator(); + final Iterator iteratorCopy = intmapCopy.iterator(); assertNotNull(iteratorCopy); assertTrue(iteratorCopy.hasNext()); - + int n = 0; while (iterator.hasNext()) { assertTrue(iteratorCopy.hasNext()); - IntIntHashMap.Entry entry = iterator.next(); - IntIntHashMap.Entry entryCopy = iteratorCopy.next(); + final IntIntHashMap.Entry entry = iterator.next(); + final IntIntHashMap.Entry entryCopy = iteratorCopy.next(); assertNotNull(entry); assertNotNull(entryCopy); assertEquals(entry.key, entryCopy.key); @@ -173,45 +173,45 @@ public class IntIntHashMapTest { assertTrue(intmapCopy.containsValue(pairs.values[i])); assertTrue(intmapCopy.containsKey(pairs.keys[i])); } - + // out.println(intmap); } @Test public void capacityTest() { - final int fixedSize = 16; - final int capacity = 32; - + final int fixedSize = 16; + final int capacity = 32; + final IntIntHashMap intmap = new IntIntHashMap( capacity, 0.75f); intmap.setKeyNotFoundValue(-1); - - assertEquals(intmap.capacity(), capacity); + + assertEquals(intmap.capacity(), capacity); for (int i = 0; i < fixedSize; i++) { intmap.put(pairs.keys[i], pairs.values[i]); } assertEquals(intmap.size(), fixedSize); assertEquals(intmap.capacity(), capacity); - + final IntIntHashMap intmapCopy = (IntIntHashMap) intmap.clone(); - + assertEquals(intmap.size(), intmapCopy.size()); assertEquals(intmap.capacity(), intmapCopy.capacity()); assertEquals(intmap.getKeyNotFoundValue(), intmapCopy.getKeyNotFoundValue()); - - Iterator iterator = intmap.iterator(); + + final Iterator iterator = intmap.iterator(); assertNotNull(iterator); assertTrue(iterator.hasNext()); - Iterator iteratorCopy = intmapCopy.iterator(); + final Iterator iteratorCopy = intmapCopy.iterator(); assertNotNull(iteratorCopy); assertTrue(iteratorCopy.hasNext()); - + int n = 0; while (iterator.hasNext()) { assertTrue(iteratorCopy.hasNext()); - IntIntHashMap.Entry entry = iterator.next(); - IntIntHashMap.Entry entryCopy = iteratorCopy.next(); + final IntIntHashMap.Entry entry = iterator.next(); + final IntIntHashMap.Entry entryCopy = iteratorCopy.next(); assertNotNull(entry); assertNotNull(entryCopy); assertEquals(entry.key, entryCopy.key); @@ -231,7 +231,7 @@ public class IntIntHashMapTest { assertTrue(intmapCopy.containsValue(pairs.values[i])); assertTrue(intmapCopy.containsKey(pairs.keys[i])); } - + // out.println(intmap); } @@ -242,7 +242,7 @@ public class IntIntHashMapTest { benchmark(false); } - void benchmark(boolean warmup) { + void benchmark(final boolean warmup) { // simple benchmark final IntIntHashMap intmap = new IntIntHashMap(1024); @@ -256,14 +256,14 @@ public class IntIntHashMapTest { for (int i = 0; i < iterations; i++) { intmap.put(pairs.keys[i], pairs.values[i]); } - long intmapPutTime = (nanoTime() - time); + final long intmapPutTime = (nanoTime() - time); out.println(" iimap: " + intmapPutTime/1000000.0f+"ms"); time = nanoTime(); for (int i = 0; i < iterations; i++) { map.put(pairs.keys[i], pairs.values[i]); } - long mapPutTime = (nanoTime() - time); + final long mapPutTime = (nanoTime() - time); out.println(" map: " + mapPutTime/1000000.0f+"ms"); @@ -273,14 +273,14 @@ public class IntIntHashMapTest { for (int i = 0; i < iterations; i++) { intmap.get(pairs.keys[i]); } - long intmapGetTime = (nanoTime() - time); + final long intmapGetTime = (nanoTime() - time); out.println(" iimap: " + intmapGetTime/1000000.0f+"ms"); time = nanoTime(); for (int i = 0; i < iterations; i++) { map.get(pairs.keys[i]); } - long mapGetTime = (nanoTime() - time); + final long mapGetTime = (nanoTime() - time); out.println(" map: " + mapGetTime/1000000.0f+"ms"); @@ -291,7 +291,7 @@ public class IntIntHashMapTest { intmap.remove(pairs.keys[i]); } assertEquals(0, intmap.size()); - long intmapRemoveTime = (nanoTime() - time); + final long intmapRemoveTime = (nanoTime() - time); out.println(" iimap: " + intmapRemoveTime/1000000.0f+"ms"); time = nanoTime(); @@ -299,7 +299,7 @@ public class IntIntHashMapTest { map.remove(pairs.keys[i]); } assertEquals(0, map.size()); - long mapRemoveTime = (nanoTime() - time); + final long mapRemoveTime = (nanoTime() - time); out.println(" map: " + mapRemoveTime/1000000.0f+"ms"); if(!warmup) { @@ -312,7 +312,7 @@ public class IntIntHashMapTest { } } - public static void main(String args[]) throws IOException { + public static void main(final String args[]) throws IOException { org.junit.runner.JUnitCore.main(IntIntHashMapTest.class.getName()); } diff --git a/src/junit/com/jogamp/common/util/IntIntObjUniqueRndValues.java b/src/junit/com/jogamp/common/util/IntIntObjUniqueRndValues.java index 38ba352..82c4da7 100644 --- a/src/junit/com/jogamp/common/util/IntIntObjUniqueRndValues.java +++ b/src/junit/com/jogamp/common/util/IntIntObjUniqueRndValues.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + /** * Created on Sunday, March 28 2010 21:01 */ @@ -39,17 +39,17 @@ public class IntIntObjUniqueRndValues { public int[] keys; public IntCloneable[] values; - public IntIntObjUniqueRndValues(int size) { + public IntIntObjUniqueRndValues(final int size) { // final int keySeed = 42; // final int valueSeed = 23; - Random keyRnd = new Random(/*keySeed*/); - Random valueRnd = new Random(/*valueSeed*/); + final Random keyRnd = new Random(/*keySeed*/); + final Random valueRnd = new Random(/*valueSeed*/); - HashSet uniqueKeys = new HashSet(size); + final HashSet uniqueKeys = new HashSet(size); keys = new int[size]; values = new IntCloneable[size]; while (uniqueKeys.size() < size) { - int k = keyRnd.nextInt(); + final int k = keyRnd.nextInt(); if( uniqueKeys.add( new Integer(k) ) ) { final int i = uniqueKeys.size()-1; keys[i] = k; diff --git a/src/junit/com/jogamp/common/util/IntIntUniqueRndValues.java b/src/junit/com/jogamp/common/util/IntIntUniqueRndValues.java index 07b222b..800fb14 100644 --- a/src/junit/com/jogamp/common/util/IntIntUniqueRndValues.java +++ b/src/junit/com/jogamp/common/util/IntIntUniqueRndValues.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + /** * Created on Sunday, March 28 2010 21:01 */ @@ -39,17 +39,17 @@ public class IntIntUniqueRndValues { public int[] keys; public int[] values; - public IntIntUniqueRndValues(int size) { + public IntIntUniqueRndValues(final int size) { // final int keySeed = 42; // final int valueSeed = 23; - Random keyRnd = new Random(/*keySeed*/); - Random valueRnd = new Random(/*valueSeed*/); + final Random keyRnd = new Random(/*keySeed*/); + final Random valueRnd = new Random(/*valueSeed*/); - HashSet uniqueKeys = new HashSet(size); + final HashSet uniqueKeys = new HashSet(size); keys = new int[size]; values = new int[size]; while (uniqueKeys.size() < size) { - int k = keyRnd.nextInt(); + final int k = keyRnd.nextInt(); if( uniqueKeys.add( new Integer(k) ) ) { final int i = uniqueKeys.size()-1; keys[i] = k; diff --git a/src/junit/com/jogamp/common/util/IntObjectHashMapTest.java b/src/junit/com/jogamp/common/util/IntObjectHashMapTest.java index 18cdf6c..11bf765 100644 --- a/src/junit/com/jogamp/common/util/IntObjectHashMapTest.java +++ b/src/junit/com/jogamp/common/util/IntObjectHashMapTest.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + /** * Created on Sunday, March 28 2010 21:01 */ @@ -45,7 +45,7 @@ import static org.junit.Assert.*; /** * * @author Michael Bien - * @author Sven Gothel + * @author Sven Gothel */ import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; @@ -85,20 +85,20 @@ public class IntObjectHashMapTest { assertEquals(map.size(), intmap.size()); - for (Entry entry : map.entrySet()) { + for (final Entry entry : map.entrySet()) { assertTrue(intmap.containsKey(entry.getKey())); assertTrue(intmap.containsValue(entry.getValue())); } int i = 0; - for (Entry entry : map.entrySet()) { + for (final Entry entry : map.entrySet()) { assertEquals(entry.getValue(), intmap.remove(entry.getKey())); assertEquals(map.size() - i - 1, intmap.size()); i++; } } - + @Test public void iteratorTest() { @@ -107,14 +107,14 @@ public class IntObjectHashMapTest { for (int i = 0; i < iterations; i++) { intmap.put(pairs.keys[i], pairs.values[i]); } - - Iterator iterator = intmap.iterator(); + + final Iterator iterator = intmap.iterator(); assertNotNull(iterator); assertTrue(iterator.hasNext()); int n = 0; while (iterator.hasNext()) { - IntObjectHashMap.Entry entry = iterator.next(); + final IntObjectHashMap.Entry entry = iterator.next(); assertNotNull(entry); n++; } @@ -132,25 +132,25 @@ public class IntObjectHashMapTest { for (int i = 0; i < iterations; i++) { intmap.put(pairs.keys[i], pairs.values[i]); } - + final IntObjectHashMap intmapCopy = (IntObjectHashMap) intmap.clone(); - + assertEquals(intmap.size(), intmapCopy.size()); assertEquals(intmap.getKeyNotFoundValue(), intmapCopy.getKeyNotFoundValue()); - - Iterator iterator = intmap.iterator(); + + final Iterator iterator = intmap.iterator(); assertNotNull(iterator); assertTrue(iterator.hasNext()); - Iterator iteratorCopy = intmapCopy.iterator(); + final Iterator iteratorCopy = intmapCopy.iterator(); assertNotNull(iteratorCopy); assertTrue(iteratorCopy.hasNext()); - + int n = 0; while (iterator.hasNext()) { assertTrue(iteratorCopy.hasNext()); - IntObjectHashMap.Entry entry = iterator.next(); - IntObjectHashMap.Entry entryCopy = iteratorCopy.next(); + final IntObjectHashMap.Entry entry = iterator.next(); + final IntObjectHashMap.Entry entryCopy = iteratorCopy.next(); assertNotNull(entry); assertNotNull(entryCopy); assertEquals(entry.key, entryCopy.key); @@ -168,12 +168,12 @@ public class IntObjectHashMapTest { assertTrue(intmapCopy.containsValue(pairs.values[i])); assertTrue(intmapCopy.containsKey(pairs.keys[i])); } - + // out.println(intmap); } - public static void main(String args[]) throws IOException { + public static void main(final String args[]) throws IOException { org.junit.runner.JUnitCore.main(IntObjectHashMapTest.class.getName()); } diff --git a/src/junit/com/jogamp/common/util/LongIntHashMapTest.java b/src/junit/com/jogamp/common/util/LongIntHashMapTest.java index ac1f7c4..f6ec4bc 100644 --- a/src/junit/com/jogamp/common/util/LongIntHashMapTest.java +++ b/src/junit/com/jogamp/common/util/LongIntHashMapTest.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + /** * Created on Sunday, March 28 2010 21:01 */ @@ -62,7 +62,7 @@ public class LongIntHashMapTest { iterations = ( Platform.getCPUFamily() == Platform.CPUFamily.ARM ) ? 20 : 10000; pairs = new LongIntUniqueRndValues(iterations); } - + /** * Test of put method, of class LongIntHashMap. */ @@ -86,13 +86,13 @@ public class LongIntHashMapTest { assertEquals(map.size(), intmap.size()); - for (Entry entry : map.entrySet()) { + for (final Entry entry : map.entrySet()) { assertTrue(intmap.containsKey(entry.getKey())); assertTrue(intmap.containsValue(entry.getValue())); } int i = 0; - for (Entry entry : map.entrySet()) { + for (final Entry entry : map.entrySet()) { assertEquals((int)entry.getValue(), intmap.remove(entry.getKey())); assertEquals(map.size() - i - 1, intmap.size()); i++; @@ -109,13 +109,13 @@ public class LongIntHashMapTest { map.put(pairs.keys[i], pairs.values[i]); } - Iterator iterator = map.iterator(); + final Iterator iterator = map.iterator(); assertNotNull(iterator); assertTrue(iterator.hasNext()); int n = 0; while (iterator.hasNext()) { - LongIntHashMap.Entry entry = (LongIntHashMap.Entry)iterator.next(); + final LongIntHashMap.Entry entry = iterator.next(); assertNotNull(entry); n++; } @@ -131,7 +131,7 @@ public class LongIntHashMapTest { benchmark(false); } - void benchmark(boolean warmup) { + void benchmark(final boolean warmup) { // simple benchmark final LongIntHashMap intmap = new LongIntHashMap(1024); @@ -145,7 +145,7 @@ public class LongIntHashMapTest { for (int i = 0; i < iterations; i++) { intmap.put(pairs.keys[i], pairs.values[i]); } - long intmapPutTime = (nanoTime() - time); + final long intmapPutTime = (nanoTime() - time); out.println(" iimap: " + intmapPutTime/1000000.0f+"ms"); @@ -153,7 +153,7 @@ public class LongIntHashMapTest { for (int i = 0; i < iterations; i++) { map.put(pairs.keys[i], pairs.values[i]); } - long mapPutTime = (nanoTime() - time); + final long mapPutTime = (nanoTime() - time); out.println(" map: " + mapPutTime/1000000.0f+"ms"); @@ -163,14 +163,14 @@ public class LongIntHashMapTest { for (int i = 0; i < iterations; i++) { intmap.get(pairs.keys[i]); } - long intmapGetTime = (nanoTime() - time); + final long intmapGetTime = (nanoTime() - time); out.println(" iimap: " + intmapGetTime/1000000.0f+"ms"); time = nanoTime(); for (int i = 0; i < iterations; i++) { map.get(pairs.keys[i]); } - long mapGetTime = (nanoTime() - time); + final long mapGetTime = (nanoTime() - time); out.println(" map: " + mapGetTime/1000000.0f+"ms"); @@ -181,7 +181,7 @@ public class LongIntHashMapTest { intmap.remove(pairs.keys[i]); } assertEquals(0, intmap.size()); - long intmapRemoveTime = (nanoTime() - time); + final long intmapRemoveTime = (nanoTime() - time); out.println(" iimap: " + intmapRemoveTime/1000000.0f+"ms"); time = nanoTime(); @@ -189,7 +189,7 @@ public class LongIntHashMapTest { map.remove(pairs.keys[i]); } assertEquals(0, map.size()); - long mapRemoveTime = (nanoTime() - time); + final long mapRemoveTime = (nanoTime() - time); out.println(" map: " + mapRemoveTime/1000000.0f+"ms"); if(!warmup) { @@ -202,7 +202,7 @@ public class LongIntHashMapTest { } } - public static void main(String args[]) throws IOException { + public static void main(final String args[]) throws IOException { org.junit.runner.JUnitCore.main(LongIntHashMapTest.class.getName()); } diff --git a/src/junit/com/jogamp/common/util/LongIntUniqueRndValues.java b/src/junit/com/jogamp/common/util/LongIntUniqueRndValues.java index 6ead167..616e8e4 100644 --- a/src/junit/com/jogamp/common/util/LongIntUniqueRndValues.java +++ b/src/junit/com/jogamp/common/util/LongIntUniqueRndValues.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + /** * Created on Sunday, March 28 2010 21:01 */ @@ -39,17 +39,17 @@ public class LongIntUniqueRndValues { public long[] keys; public int[] values; - public LongIntUniqueRndValues(int size) { + public LongIntUniqueRndValues(final int size) { // final int keySeed = 42; // final int valueSeed = 23; - Random keyRnd = new Random(/*keySeed*/); - Random valueRnd = new Random(/*valueSeed*/); + final Random keyRnd = new Random(/*keySeed*/); + final Random valueRnd = new Random(/*valueSeed*/); - HashSet uniqueKeys = new HashSet(size); + final HashSet uniqueKeys = new HashSet(size); keys = new long[size]; values = new int[size]; while (uniqueKeys.size() < size) { - long k = keyRnd.nextLong(); + final long k = keyRnd.nextLong(); if( uniqueKeys.add( new Long(k) ) ) { final int i = uniqueKeys.size()-1; keys[i] = k; diff --git a/src/junit/com/jogamp/common/util/RingBuffer01Base.java b/src/junit/com/jogamp/common/util/RingBuffer01Base.java index f7e8fcf..ced94dc 100644 --- a/src/junit/com/jogamp/common/util/RingBuffer01Base.java +++ b/src/junit/com/jogamp/common/util/RingBuffer01Base.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.common.util; @@ -36,154 +36,154 @@ import com.jogamp.common.util.Ringbuffer; public abstract class RingBuffer01Base { private static boolean DEBUG = false; - + public abstract Ringbuffer createEmpty(int initialCapacity); public abstract Ringbuffer createFull(Integer[] source); - - public Integer[] createIntArray(int capacity, int startValue) { + + public Integer[] createIntArray(final int capacity, final int startValue) { final Integer[] array = new Integer[capacity]; for(int i=0; i rb, boolean clearRef, int capacity, int len, int startValue) { + + private void readTestImpl(final Ringbuffer rb, final boolean clearRef, final int capacity, final int len, final int startValue) { final int preSize = rb.size(); Assert.assertEquals("Wrong capacity "+rb, capacity, rb.capacity()); Assert.assertTrue("Too low capacity to read "+len+" elems: "+rb, capacity-len >= 0); Assert.assertTrue("Too low size to read "+len+" elems: "+rb, preSize >= len); Assert.assertTrue("Is empty "+rb, !rb.isEmpty()); - + for(int i=0; i= len); Assert.assertTrue("Is full "+rb, !rb.isFull()); } - - private void writeTestImpl(Ringbuffer rb, int capacity, int len, int startValue) { + + private void writeTestImpl(final Ringbuffer rb, final int capacity, final int len, final int startValue) { final int preSize = rb.size(); Assert.assertEquals("Wrong capacity "+rb, capacity, rb.capacity()); Assert.assertTrue("Too low capacity to write "+len+" elems: "+rb, capacity-len >= 0); Assert.assertTrue("Too low size to write "+len+" elems: "+rb, preSize+len <= capacity); Assert.assertTrue("Is full "+rb, !rb.isFull()); - + for(int i=0; i rb, int pos) { + + private void moveGetPutImpl(final Ringbuffer rb, final int pos) { Assert.assertTrue("RB is empty "+rb, !rb.isEmpty()); for(int i=0; i rb, int pos) { + + private void movePutGetImpl(final Ringbuffer rb, final int pos) { Assert.assertTrue("RB is full "+rb, !rb.isFull()); for(int i=0; i rb = createFull(source); - Assert.assertEquals("Not full size "+rb, capacity, rb.size()); + final Ringbuffer rb = createFull(source); + Assert.assertEquals("Not full size "+rb, capacity, rb.size()); Assert.assertTrue("Not full "+rb, rb.isFull()); - + readTestImpl(rb, true, capacity, capacity, 0); Assert.assertTrue("Not empty "+rb, rb.isEmpty()); } - + @Test public void test02_EmptyWrite() { final int capacity = 11; - final Ringbuffer rb = createEmpty(capacity); + final Ringbuffer rb = createEmpty(capacity); Assert.assertEquals("Not zero size "+rb, 0, rb.size()); Assert.assertTrue("Not empty "+rb, rb.isEmpty()); - + writeTestImpl(rb, capacity, capacity, 0); Assert.assertEquals("Not full size "+rb, capacity, rb.size()); Assert.assertTrue("Not full "+rb, rb.isFull()); - + readTestImpl(rb, true, capacity, capacity, 0); Assert.assertTrue("Not empty "+rb, rb.isEmpty()); } - + @Test public void test03_FullReadReset() { final int capacity = 11; final Integer[] source = createIntArray(capacity, 0); - final Ringbuffer rb = createFull(source); + final Ringbuffer rb = createFull(source); Assert.assertTrue("Not full "+rb, rb.isFull()); - + rb.resetFull(source); Assert.assertTrue("Not full "+rb, rb.isFull()); - + readTestImpl(rb, false, capacity, capacity, 0); Assert.assertTrue("Not empty "+rb, rb.isEmpty()); - + rb.resetFull(source); Assert.assertTrue("Not full "+rb, rb.isFull()); - + readTestImpl(rb, false, capacity, capacity, 0); Assert.assertTrue("Not empty "+rb, rb.isEmpty()); } - + @Test public void test04_EmptyWriteClear() { final int capacity = 11; - final Ringbuffer rb = createEmpty(capacity); + final Ringbuffer rb = createEmpty(capacity); Assert.assertTrue("Not empty "+rb, rb.isEmpty()); - + rb.clear(); Assert.assertTrue("Not empty "+rb, rb.isEmpty()); - + writeTestImpl(rb, capacity, capacity, 0); Assert.assertTrue("Not full "+rb, rb.isFull()); - + readTestImpl(rb, false, capacity, capacity, 0); Assert.assertTrue("Not empty "+rb, rb.isEmpty()); - + rb.clear(); Assert.assertTrue("Not empty "+rb, rb.isEmpty()); - + writeTestImpl(rb, capacity, capacity, 0); Assert.assertTrue("Not full "+rb, rb.isFull()); - + readTestImpl(rb, false, capacity, capacity, 0); Assert.assertTrue("Not empty "+rb, rb.isEmpty()); } - + @Test public void test05_ReadResetMid01() { final int capacity = 11; final Integer[] source = createIntArray(capacity, 0); - final Ringbuffer rb = createFull(source); + final Ringbuffer rb = createFull(source); Assert.assertTrue("Not full "+rb, rb.isFull()); - + rb.resetFull(source); Assert.assertTrue("Not full "+rb, rb.isFull()); - + readTestImpl(rb, false, capacity, 5, 0); Assert.assertTrue("Is empty "+rb, !rb.isEmpty()); Assert.assertTrue("Is Full "+rb, !rb.isFull()); - + if( DEBUG ) { rb.dump(System.err, "ReadReset01["+5+"].pre0"); } @@ -192,26 +192,26 @@ public abstract class RingBuffer01Base { if( DEBUG ) { rb.dump(System.err, "ReadReset01["+5+"].post"); } - + readTestImpl(rb, false, capacity, capacity, 0); Assert.assertTrue("Not empty "+rb, rb.isEmpty()); } - + @Test public void test06_ReadResetMid02() { final int capacity = 11; final Integer[] source = createIntArray(capacity, 0); - final Ringbuffer rb = createFull(source); + final Ringbuffer rb = createFull(source); Assert.assertTrue("Not full "+rb, rb.isFull()); - + rb.resetFull(source); Assert.assertTrue("Not full "+rb, rb.isFull()); - + moveGetPutImpl(rb, 5); // readTestImpl(rb, false, capacity, 5, 0); // Assert.assertTrue("Is empty "+rb, !rb.isEmpty()); // Assert.assertTrue("Is Full "+rb, !rb.isFull()); - + if( DEBUG ) { rb.dump(System.err, "ReadReset02["+5+"].pre0"); } @@ -220,12 +220,12 @@ public abstract class RingBuffer01Base { if( DEBUG ) { rb.dump(System.err, "ReadReset02["+5+"].post"); } - + readTestImpl(rb, false, capacity, capacity, 0); Assert.assertTrue("Not empty "+rb, rb.isEmpty()); } - - private void test_GrowEmptyImpl(int initCapacity, int pos) { + + private void test_GrowEmptyImpl(final int initCapacity, final int pos) { final int growAmount = 5; final int grownCapacity = initCapacity+growAmount; final Integer[] growArray = new Integer[growAmount]; @@ -233,7 +233,7 @@ public abstract class RingBuffer01Base { growArray[i] = Integer.valueOf(100+i); } final Ringbuffer rb = createEmpty(initCapacity); - + if( DEBUG ) { rb.dump(System.err, "GrowEmpty["+pos+"].pre0"); } @@ -245,18 +245,18 @@ public abstract class RingBuffer01Base { if( DEBUG ) { rb.dump(System.err, "GrowEmpty["+pos+"].post"); } - + Assert.assertEquals("Wrong capacity "+rb, grownCapacity, rb.capacity()); Assert.assertEquals("Not growAmount size "+rb, growAmount, rb.size()); Assert.assertTrue("Is full "+rb, !rb.isFull()); Assert.assertTrue("Is empty "+rb, !rb.isEmpty()); - + for(int i=0; i rb = createFull(source); - + final Ringbuffer rb = createFull(source); + if( DEBUG || debug ) { rb.dump(System.err, "GrowFull["+pos+"].pre0"); } @@ -295,29 +295,29 @@ public abstract class RingBuffer01Base { if( DEBUG || debug ) { rb.dump(System.err, "GrowFull["+pos+"].post"); } - + Assert.assertEquals("Wrong capacity "+rb, grownCapacity, rb.capacity()); Assert.assertEquals("Not orig size "+rb, initCapacity, rb.size()); Assert.assertTrue("Is full "+rb, !rb.isFull()); Assert.assertTrue("Is empty "+rb, !rb.isEmpty()); - + for(int i=0; i l, int start, int len, int i2, int i3, int expectedPlusSize) { - int oldSize = l.size(); + public void populate(final List l, final int start, final int len, final int i2, final int i3, final int expectedPlusSize) { + final int oldSize = l.size(); int pos = start+len-1; while(pos>=start) { l.add(new Dummy(pos--, i2, i3)); @@ -85,15 +85,15 @@ public class TestArrayHashSet01 extends JunitTracer { @Test public void test01ArrayHashSet() { - ArrayHashSet l = new ArrayHashSet(); + final ArrayHashSet l = new ArrayHashSet(); populate(l, 10, 100, 22, 34, 100); // [10 .. 109] populate(l, 10, 100, 22, 34, 0); // [10 .. 109] populate(l, 6, 5, 22, 34, 4); // [ 6 .. 9], 10 already exists - Dummy p6_22_34 = new Dummy(6, 22, 34); + final Dummy p6_22_34 = new Dummy(6, 22, 34); // slow get on position .. - int i = l.indexOf(p6_22_34); + final int i = l.indexOf(p6_22_34); Dummy q = l.get(i); Assert.assertNotNull(q); Assert.assertEquals(p6_22_34, q); @@ -116,7 +116,7 @@ public class TestArrayHashSet01 extends JunitTracer { Assert.assertTrue(p6_22_34.hashCode() == q.hashCode()); Assert.assertTrue(p6_22_34 != q); // diff reference - Dummy p1_2_3 = new Dummy(1, 2, 3); // a new one .. + final Dummy p1_2_3 = new Dummy(1, 2, 3); // a new one .. q = l.getOrAdd(p1_2_3); // added test Assert.assertNotNull(q); Assert.assertEquals(p1_2_3, q); @@ -124,8 +124,8 @@ public class TestArrayHashSet01 extends JunitTracer { Assert.assertTrue(p1_2_3 == q); // _same_ reference, since getOrAdd added it } - public static void main(String args[]) throws IOException { - String tstname = TestArrayHashSet01.class.getName(); + public static void main(final String args[]) throws IOException { + final String tstname = TestArrayHashSet01.class.getName(); org.junit.runner.JUnitCore.main(tstname); } diff --git a/src/junit/com/jogamp/common/util/TestBitstream00.java b/src/junit/com/jogamp/common/util/TestBitstream00.java index d0c5613..7bf4167 100644 --- a/src/junit/com/jogamp/common/util/TestBitstream00.java +++ b/src/junit/com/jogamp/common/util/TestBitstream00.java @@ -55,8 +55,8 @@ public class TestBitstream00 extends JunitTracer { @Test public void test00ShowByteOrder() { - int i_ff = 0xff; - byte b_ff = (byte)i_ff; + final int i_ff = 0xff; + final byte b_ff = (byte)i_ff; System.err.println("i_ff "+i_ff+", "+toHexBinaryString(i_ff, 8)); System.err.println("b_ff "+b_ff+", "+toHexBinaryString(0xff & b_ff, 8)); @@ -69,7 +69,7 @@ public class TestBitstream00 extends JunitTracer { dumpData("tstLSB.pbyte", testBytesLSB_revByte, 0, testBytesLSB_revByte.length); dumpData("tstLSB.whole", testBytesLSB, 0, testBytesLSB.length); } - void showOrderImpl(ByteOrder byteOrder) { + void showOrderImpl(final ByteOrder byteOrder) { final ByteBuffer bb_long = ByteBuffer.allocate(Buffers.SIZEOF_LONG); if( null != byteOrder ) { bb_long.order(byteOrder); @@ -129,8 +129,8 @@ public class TestBitstream00 extends JunitTracer { } } - public static void main(String args[]) throws IOException { - String tstname = TestBitstream00.class.getName(); + public static void main(final String args[]) throws IOException { + final String tstname = TestBitstream00.class.getName(); org.junit.runner.JUnitCore.main(tstname); } diff --git a/src/junit/com/jogamp/common/util/TestBitstream01.java b/src/junit/com/jogamp/common/util/TestBitstream01.java index a8ae4a5..f0415bc 100644 --- a/src/junit/com/jogamp/common/util/TestBitstream01.java +++ b/src/junit/com/jogamp/common/util/TestBitstream01.java @@ -55,7 +55,7 @@ import org.junit.runners.MethodSorters; @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestBitstream01 extends JunitTracer { - Bitstream getTestStream(final boolean msbFirst, int preBits, final int skipBits, final int postBits) throws IOException { + Bitstream getTestStream(final boolean msbFirst, final int preBits, final int skipBits, final int postBits) throws IOException { final int byteCount = ( preBits + skipBits + postBits + 7 ) / 8; final ByteBuffer bbTest = ByteBuffer.allocate(byteCount); final Bitstream.ByteBufferStream bbsTest = new Bitstream.ByteBufferStream(bbTest); @@ -75,7 +75,7 @@ public class TestBitstream01 extends JunitTracer { return bsTest; } - String getTestStreamResultAsString(final boolean msbFirst, int preBits, final int skipBits, final int postBits) { + String getTestStreamResultAsString(final boolean msbFirst, final int preBits, final int skipBits, final int postBits) { final String pre, post; if( msbFirst ) { pre = testStringMSB.substring(0, preBits); @@ -149,7 +149,7 @@ public class TestBitstream01 extends JunitTracer { return sbRead.toString(); } - void testLinearBitsImpl(final boolean msbFirst, int preBits, int skipBits, final int postBits) throws IOException { + void testLinearBitsImpl(final boolean msbFirst, final int preBits, final int skipBits, final int postBits) throws IOException { final int totalBits = preBits+skipBits+postBits; System.err.println("XXX TestLinearBits: msbFirst "+msbFirst+", preBits "+preBits+", skipBits "+skipBits+", postBits "+postBits+", totalBits "+totalBits); @@ -254,7 +254,7 @@ public class TestBitstream01 extends JunitTracer { testBulkBitsImpl(msbFirst, 16, 11, 5); } - void testBulkBitsImpl(final boolean msbFirst, int preBits, final int skipBits, final int postBits) throws IOException { + void testBulkBitsImpl(final boolean msbFirst, final int preBits, final int skipBits, final int postBits) throws IOException { final int totalBits = preBits+skipBits+postBits; System.err.println("XXX TestBulkBits: msbFirst "+msbFirst+", preBits "+preBits+", skipBits "+skipBits+", postBits "+postBits+", totalBits "+totalBits); @@ -324,18 +324,18 @@ public class TestBitstream01 extends JunitTracer { try { bsTest.readBit(false); - } catch (Exception e) { + } catch (final Exception e) { Assert.assertNotNull(e); } try { bsTest.writeBit(false, 1); - } catch (Exception e) { + } catch (final Exception e) { Assert.assertNotNull(e); } } - public static void main(String args[]) throws IOException { - String tstname = TestBitstream01.class.getName(); + public static void main(final String args[]) throws IOException { + final String tstname = TestBitstream01.class.getName(); org.junit.runner.JUnitCore.main(tstname); } diff --git a/src/junit/com/jogamp/common/util/TestBitstream02.java b/src/junit/com/jogamp/common/util/TestBitstream02.java index b518df8..e1a9eb0 100644 --- a/src/junit/com/jogamp/common/util/TestBitstream02.java +++ b/src/junit/com/jogamp/common/util/TestBitstream02.java @@ -62,7 +62,7 @@ public class TestBitstream02 extends JunitTracer { test01Int8BitsAlignedImpl(Byte.MAX_VALUE); test01Int8BitsAlignedImpl((byte)0xff); } - void test01Int8BitsAlignedImpl(byte val8) throws IOException { + void test01Int8BitsAlignedImpl(final byte val8) throws IOException { // Test with buffer defined value final ByteBuffer bb = ByteBuffer.allocate(Buffers.SIZEOF_BYTE); System.err.println("XXX Test01Int8BitsAligned: value "+val8+", "+toHexBinaryString(val8, 8)); @@ -105,7 +105,7 @@ public class TestBitstream02 extends JunitTracer { test02Int8BitsUnalignedImpl(preBits, Byte.MAX_VALUE); test02Int8BitsUnalignedImpl(preBits, (byte)0xff); } - void test02Int8BitsUnalignedImpl(int preBits, byte val8) throws IOException { + void test02Int8BitsUnalignedImpl(final int preBits, final byte val8) throws IOException { final int preBytes = ( preBits + 7 ) >>> 3; final int byteCount = preBytes + Buffers.SIZEOF_BYTE; final ByteBuffer bb = ByteBuffer.allocate(byteCount); @@ -125,8 +125,8 @@ public class TestBitstream02 extends JunitTracer { Assert.assertEquals(val8, r8); } - public static void main(String args[]) throws IOException { - String tstname = TestBitstream02.class.getName(); + public static void main(final String args[]) throws IOException { + final String tstname = TestBitstream02.class.getName(); org.junit.runner.JUnitCore.main(tstname); } diff --git a/src/junit/com/jogamp/common/util/TestBitstream03.java b/src/junit/com/jogamp/common/util/TestBitstream03.java index 3647924..29debc8 100644 --- a/src/junit/com/jogamp/common/util/TestBitstream03.java +++ b/src/junit/com/jogamp/common/util/TestBitstream03.java @@ -60,7 +60,7 @@ public class TestBitstream03 extends JunitTracer { test01Int16BitsImpl(ByteOrder.BIG_ENDIAN); test01Int16BitsImpl(ByteOrder.LITTLE_ENDIAN); } - void test01Int16BitsImpl(ByteOrder byteOrder) throws IOException { + void test01Int16BitsImpl(final ByteOrder byteOrder) throws IOException { test01Int16BitsAlignedImpl(byteOrder, (short)0); test01Int16BitsAlignedImpl(byteOrder, (short)1); test01Int16BitsAlignedImpl(byteOrder, (short)7); @@ -69,7 +69,7 @@ public class TestBitstream03 extends JunitTracer { test01Int16BitsAlignedImpl(byteOrder, Short.MAX_VALUE); test01Int16BitsAlignedImpl(byteOrder, (short)0xffff); } - void test01Int16BitsAlignedImpl(ByteOrder byteOrder, short val16) throws IOException { + void test01Int16BitsAlignedImpl(final ByteOrder byteOrder, final short val16) throws IOException { // Test with buffer defined value final ByteBuffer bb = ByteBuffer.allocate(Buffers.SIZEOF_SHORT); if( null != byteOrder ) { @@ -104,7 +104,7 @@ public class TestBitstream03 extends JunitTracer { test02Int16BitsUnalignedImpl(ByteOrder.BIG_ENDIAN); test02Int16BitsUnalignedImpl(ByteOrder.LITTLE_ENDIAN); } - void test02Int16BitsUnalignedImpl(ByteOrder byteOrder) throws IOException { + void test02Int16BitsUnalignedImpl(final ByteOrder byteOrder) throws IOException { test02Int16BitsUnalignedImpl(byteOrder, 0); test02Int16BitsUnalignedImpl(byteOrder, 1); test02Int16BitsUnalignedImpl(byteOrder, 7); @@ -113,7 +113,7 @@ public class TestBitstream03 extends JunitTracer { test02Int16BitsUnalignedImpl(byteOrder, 24); test02Int16BitsUnalignedImpl(byteOrder, 25); } - void test02Int16BitsUnalignedImpl(ByteOrder byteOrder, final int preBits) throws IOException { + void test02Int16BitsUnalignedImpl(final ByteOrder byteOrder, final int preBits) throws IOException { test02Int16BitsUnalignedImpl(byteOrder, preBits, (short)0); test02Int16BitsUnalignedImpl(byteOrder, preBits, (short)1); test02Int16BitsUnalignedImpl(byteOrder, preBits, (short)7); @@ -122,7 +122,7 @@ public class TestBitstream03 extends JunitTracer { test02Int16BitsUnalignedImpl(byteOrder, preBits, Short.MAX_VALUE); test02Int16BitsUnalignedImpl(byteOrder, preBits, (short)0xffff); } - void test02Int16BitsUnalignedImpl(ByteOrder byteOrder, int preBits, short val16) throws IOException { + void test02Int16BitsUnalignedImpl(final ByteOrder byteOrder, final int preBits, final short val16) throws IOException { final int preBytes = ( preBits + 7 ) >>> 3; final int byteCount = preBytes + Buffers.SIZEOF_SHORT; final ByteBuffer bb = ByteBuffer.allocate(byteCount); @@ -146,8 +146,8 @@ public class TestBitstream03 extends JunitTracer { Assert.assertEquals(val16, r16); } - public static void main(String args[]) throws IOException { - String tstname = TestBitstream03.class.getName(); + public static void main(final String args[]) throws IOException { + final String tstname = TestBitstream03.class.getName(); org.junit.runner.JUnitCore.main(tstname); } diff --git a/src/junit/com/jogamp/common/util/TestBitstream04.java b/src/junit/com/jogamp/common/util/TestBitstream04.java index 196db71..f61ebea 100644 --- a/src/junit/com/jogamp/common/util/TestBitstream04.java +++ b/src/junit/com/jogamp/common/util/TestBitstream04.java @@ -60,7 +60,7 @@ public class TestBitstream04 extends JunitTracer { test01Int32BitsImpl(ByteOrder.BIG_ENDIAN); test01Int32BitsImpl(ByteOrder.LITTLE_ENDIAN); } - void test01Int32BitsImpl(ByteOrder byteOrder) throws IOException { + void test01Int32BitsImpl(final ByteOrder byteOrder) throws IOException { test01Int32BitsAlignedImpl(byteOrder, 0, 0); test01Int32BitsAlignedImpl(byteOrder, 1, 1); test01Int32BitsAlignedImpl(byteOrder, -1, -1); @@ -70,7 +70,7 @@ public class TestBitstream04 extends JunitTracer { test01Int32BitsAlignedImpl(byteOrder, Integer.MAX_VALUE, Integer.MAX_VALUE); test01Int32BitsAlignedImpl(byteOrder, 0xffffffff, -1); } - void test01Int32BitsAlignedImpl(ByteOrder byteOrder, int val32, int expUInt32Int) throws IOException { + void test01Int32BitsAlignedImpl(final ByteOrder byteOrder, final int val32, final int expUInt32Int) throws IOException { // Test with buffer defined value final ByteBuffer bb = ByteBuffer.allocate(Buffers.SIZEOF_INT); if( null != byteOrder ) { @@ -120,7 +120,7 @@ public class TestBitstream04 extends JunitTracer { test02Int32BitsUnalignedImpl(ByteOrder.BIG_ENDIAN); test02Int32BitsUnalignedImpl(ByteOrder.LITTLE_ENDIAN); } - void test02Int32BitsUnalignedImpl(ByteOrder byteOrder) throws IOException { + void test02Int32BitsUnalignedImpl(final ByteOrder byteOrder) throws IOException { test02Int32BitsUnalignedImpl(byteOrder, 0); test02Int32BitsUnalignedImpl(byteOrder, 1); test02Int32BitsUnalignedImpl(byteOrder, 7); @@ -129,7 +129,7 @@ public class TestBitstream04 extends JunitTracer { test02Int32BitsUnalignedImpl(byteOrder, 24); test02Int32BitsUnalignedImpl(byteOrder, 25); } - void test02Int32BitsUnalignedImpl(ByteOrder byteOrder, final int preBits) throws IOException { + void test02Int32BitsUnalignedImpl(final ByteOrder byteOrder, final int preBits) throws IOException { test02Int32BitsUnalignedImpl(byteOrder, preBits, 0, 0); test02Int32BitsUnalignedImpl(byteOrder, preBits, 1, 1); test02Int32BitsUnalignedImpl(byteOrder, preBits, -1, -1); @@ -139,7 +139,7 @@ public class TestBitstream04 extends JunitTracer { test02Int32BitsUnalignedImpl(byteOrder, preBits, Integer.MAX_VALUE, Integer.MAX_VALUE); test02Int32BitsUnalignedImpl(byteOrder, preBits, 0xffffffff, -1); } - void test02Int32BitsUnalignedImpl(ByteOrder byteOrder, int preBits, int val32, int expUInt32Int) throws IOException { + void test02Int32BitsUnalignedImpl(final ByteOrder byteOrder, final int preBits, final int val32, final int expUInt32Int) throws IOException { final int preBytes = ( preBits + 7 ) >>> 3; final int byteCount = preBytes + Buffers.SIZEOF_INT; final ByteBuffer bb = ByteBuffer.allocate(byteCount); @@ -171,8 +171,8 @@ public class TestBitstream04 extends JunitTracer { Assert.assertEquals(expUInt32Int, uint32_i); } - public static void main(String args[]) throws IOException { - String tstname = TestBitstream04.class.getName(); + public static void main(final String args[]) throws IOException { + final String tstname = TestBitstream04.class.getName(); org.junit.runner.JUnitCore.main(tstname); } diff --git a/src/junit/com/jogamp/common/util/TestFloatStack01.java b/src/junit/com/jogamp/common/util/TestFloatStack01.java index eab83aa..c0c1a2f 100644 --- a/src/junit/com/jogamp/common/util/TestFloatStack01.java +++ b/src/junit/com/jogamp/common/util/TestFloatStack01.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.common.util; import java.io.IOException; @@ -43,8 +43,8 @@ import org.junit.runners.MethodSorters; @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class /*testname*/TestFloatStack01/*testname*/ extends JunitTracer { - static final boolean equals(/*value*/float/*value*/[] b, int bOffset, - /*value*/float/*value*/[] stack, int stackOffset, int length) { + static final boolean equals(final /*value*/float/*value*/[] b, final int bOffset, + final /*value*/float/*value*/[] stack, final int stackOffset, final int length) { for(int i=0; i=0 && orig[i]==bb.get(i); i--) ; + for(i=tsz-1; i>=0 && orig[i]==bb.get(i); i--) ; Assert.assertTrue("Bytes not equal orig vs array", 0>i); } - + @Test public void testCopyStream03Buffer() throws IOException { final String tfilename2 = "./test2.bin" ; - URLConnection urlConn1 = IOUtil.getResource(this.getClass(), tfilename); + final URLConnection urlConn1 = IOUtil.getResource(this.getClass(), tfilename); Assert.assertNotNull(urlConn1); - - File file2 = new File(tfilename2); + + final File file2 = new File(tfilename2); IOUtil.copyURLConn2File(urlConn1, file2); - URLConnection urlConn2 = IOUtil.getResource(this.getClass(), tfilename2); + final URLConnection urlConn2 = IOUtil.getResource(this.getClass(), tfilename2); Assert.assertNotNull(urlConn2); final BufferedInputStream bis = new BufferedInputStream( urlConn2.getInputStream() ); final ByteBuffer bb; try { - bb = IOUtil.copyStream2ByteBuffer( bis ); + bb = IOUtil.copyStream2ByteBuffer( bis ); } finally { IOUtil.close(bis, false); } Assert.assertEquals("Byte number not equal orig vs buffer", orig.length, bb.limit()); int i; - for(i=tsz-1; i>=0 && orig[i]==bb.get(i); i--) ; + for(i=tsz-1; i>=0 && orig[i]==bb.get(i); i--) ; Assert.assertTrue("Bytes not equal orig vs array", 0>i); } - - public static void main(String args[]) throws IOException { - String tstname = TestIOUtil01.class.getName(); + + public static void main(final String args[]) throws IOException { + final String tstname = TestIOUtil01.class.getName(); org.junit.runner.JUnitCore.main(tstname); } diff --git a/src/junit/com/jogamp/common/util/TestIOUtilURICompose.java b/src/junit/com/jogamp/common/util/TestIOUtilURICompose.java index 0809599..3369afd 100644 --- a/src/junit/com/jogamp/common/util/TestIOUtilURICompose.java +++ b/src/junit/com/jogamp/common/util/TestIOUtilURICompose.java @@ -39,15 +39,15 @@ public class TestIOUtilURICompose extends JunitTracer { testURLCompositioning(file1URL, new URL("asset:jar:file:/web1/file1.jar!/rootDir/dummyParent/../file1.txt")); } - static void testURNCompositioning(String urn) throws MalformedURLException, URISyntaxException { + static void testURNCompositioning(final String urn) throws MalformedURLException, URISyntaxException { testURICompositioning( new URI(urn) ); testURLCompositioning( new URL(urn) ); } - static void testURICompositioning(URI uri) throws MalformedURLException, URISyntaxException { + static void testURICompositioning(final URI uri) throws MalformedURLException, URISyntaxException { testURICompositioning(uri, uri); } - static void testURICompositioning(URI refURI, URI uri1) throws MalformedURLException, URISyntaxException { + static void testURICompositioning(final URI refURI, final URI uri1) throws MalformedURLException, URISyntaxException { final String scheme = uri1.getScheme(); final String ssp = uri1.getRawSchemeSpecificPart(); final String fragment = uri1.getRawFragment(); @@ -62,10 +62,10 @@ public class TestIOUtilURICompose extends JunitTracer { Assert.assertEquals(refURI, uri2); } - static void testURLCompositioning(URL url) throws MalformedURLException, URISyntaxException { + static void testURLCompositioning(final URL url) throws MalformedURLException, URISyntaxException { testURLCompositioning(url, url); } - static void testURLCompositioning(URL refURL, URL url1) throws MalformedURLException, URISyntaxException { + static void testURLCompositioning(final URL refURL, final URL url1) throws MalformedURLException, URISyntaxException { final URI uri1 = url1.toURI(); final String scheme = uri1.getScheme(); final String ssp = uri1.getRawSchemeSpecificPart(); @@ -85,8 +85,8 @@ public class TestIOUtilURICompose extends JunitTracer { Assert.assertTrue(refURL.sameFile(uri2.toURL())); } - public static void main(String args[]) throws IOException { - String tstname = TestIOUtilURICompose.class.getName(); + public static void main(final String args[]) throws IOException { + final String tstname = TestIOUtilURICompose.class.getName(); org.junit.runner.JUnitCore.main(tstname); } } diff --git a/src/junit/com/jogamp/common/util/TestIOUtilURIHandling.java b/src/junit/com/jogamp/common/util/TestIOUtilURIHandling.java index efd7030..ca62ae9 100644 --- a/src/junit/com/jogamp/common/util/TestIOUtilURIHandling.java +++ b/src/junit/com/jogamp/common/util/TestIOUtilURIHandling.java @@ -186,8 +186,8 @@ public class TestIOUtilURIHandling extends JunitTracer { final String string = "Hallo Welt öä"; System.err.println("sp1 "+string); { - String sp2 = IOUtil.encodeToURI(string); - String sp3 = IOUtil.encodeToURI(sp2); + final String sp2 = IOUtil.encodeToURI(string); + final String sp3 = IOUtil.encodeToURI(sp2); System.err.println("sp2 "+sp2); System.err.println("sp3 "+sp3); } @@ -315,7 +315,7 @@ public class TestIOUtilURIHandling extends JunitTracer { } } - static void testURI2URL(String testname, String[][] uriSArray) throws IOException, URISyntaxException { + static void testURI2URL(final String testname, final String[][] uriSArray) throws IOException, URISyntaxException { boolean ok = true; for(int i=0; i0) { l.add(new Integer(len--)); } @@ -58,12 +54,12 @@ public class TestIteratorIndexCORE extends JunitTracer { @Test public void test01ArrayListIterator() { int sum=0; - ArrayList l = new ArrayList(); + final ArrayList l = new ArrayList(); populate(l, elems); for(int j=loop; j>0; j--) { - for(Iterator iter = l.iterator(); iter.hasNext(); ) { - Integer i = (Integer)iter.next(); + for(final Iterator iter = l.iterator(); iter.hasNext(); ) { + final Integer i = (Integer)iter.next(); sum+=i.intValue(); } } @@ -73,12 +69,12 @@ public class TestIteratorIndexCORE extends JunitTracer { @Test public void test0ArrayListIndex() { int sum=0; - ArrayList l = new ArrayList(); + final ArrayList l = new ArrayList(); populate(l, elems); for(int j=loop; j>0; j--) { for(int k = 0; k < l.size(); k++) { - Integer i = (Integer)l.get(k); + final Integer i = (Integer)l.get(k); sum+=i.intValue(); } } @@ -88,12 +84,12 @@ public class TestIteratorIndexCORE extends JunitTracer { @Test public void test01LinkedListListIterator() { int sum=0; - LinkedList l = new LinkedList(); + final LinkedList l = new LinkedList(); populate(l, elems); for(int j=loop; j>0; j--) { - for(Iterator iter = l.iterator(); iter.hasNext(); ) { - Integer i = (Integer)iter.next(); + for(final Iterator iter = l.iterator(); iter.hasNext(); ) { + final Integer i = (Integer)iter.next(); sum+=i.intValue(); } } @@ -103,20 +99,20 @@ public class TestIteratorIndexCORE extends JunitTracer { @Test public void test01LinkedListListIndex() { int sum=0; - LinkedList l = new LinkedList(); + final LinkedList l = new LinkedList(); populate(l, elems); for(int j=loop; j>0; j--) { for(int k = 0; k < l.size(); k++) { - Integer i = (Integer)l.get(k); + final Integer i = (Integer)l.get(k); sum+=i.intValue(); } } System.err.println("test01-linkedlist-index sum: "+sum); } - public static void main(String args[]) throws IOException { - String tstname = TestIteratorIndexCORE.class.getName(); + public static void main(final String args[]) throws IOException { + final String tstname = TestIteratorIndexCORE.class.getName(); org.junit.runner.JUnitCore.main(tstname); } diff --git a/src/junit/com/jogamp/common/util/TestJarUtil.java b/src/junit/com/jogamp/common/util/TestJarUtil.java index 6434469..07e33fc 100644 --- a/src/junit/com/jogamp/common/util/TestJarUtil.java +++ b/src/junit/com/jogamp/common/util/TestJarUtil.java @@ -77,18 +77,18 @@ public class TestJarUtil extends JunitTracer { } static class TestClassLoader extends URLClassLoader { - public TestClassLoader(URL[] urls) { + public TestClassLoader(final URL[] urls) { super(urls); } - public TestClassLoader(URL[] urls, ClassLoader parent) { + public TestClassLoader(final URL[] urls, final ClassLoader parent) { super(urls, parent); } } - void validateJarFile(JarFile jarFile) throws IllegalArgumentException, IOException { + void validateJarFile(final JarFile jarFile) throws IllegalArgumentException, IOException { Assert.assertNotNull(jarFile); Assert.assertTrue("jarFile has zero entries: "+jarFile, jarFile.size()>0); - Enumeration entries = jarFile.entries(); + final Enumeration entries = jarFile.entries(); System.err.println("Entries of "+jarFile.getName()+": "); int i = 0; while(entries.hasMoreElements()) { @@ -97,34 +97,34 @@ public class TestJarUtil extends JunitTracer { } } - void validateJarFileURL(URI jarFileURI) throws IllegalArgumentException, IOException, URISyntaxException { + void validateJarFileURL(final URI jarFileURI) throws IllegalArgumentException, IOException, URISyntaxException { Assert.assertNotNull(jarFileURI); final URL jarFileURL = IOUtil.toURL(jarFileURI); - URLConnection aURLc = jarFileURL.openConnection(); + final URLConnection aURLc = jarFileURL.openConnection(); Assert.assertTrue("jarFileURI/URL has zero content: "+jarFileURL, aURLc.getContentLength()>0); System.err.println("URLConnection: "+aURLc); Assert.assertTrue("Not a JarURLConnection: "+aURLc, (aURLc instanceof JarURLConnection) ); - JarURLConnection jURLc = (JarURLConnection) aURLc; - JarFile jarFile = jURLc.getJarFile(); + final JarURLConnection jURLc = (JarURLConnection) aURLc; + final JarFile jarFile = jURLc.getJarFile(); validateJarFile(jarFile); } - void validateJarUtil(String expJarName, String clazzBinName, ClassLoader cl) throws IllegalArgumentException, IOException, URISyntaxException { - String jarName= JarUtil.getJarBasename(clazzBinName, cl); + void validateJarUtil(final String expJarName, final String clazzBinName, final ClassLoader cl) throws IllegalArgumentException, IOException, URISyntaxException { + final String jarName= JarUtil.getJarBasename(clazzBinName, cl); Assert.assertNotNull(jarName); Assert.assertEquals(expJarName, jarName); - URI jarSubURI = JarUtil.getJarSubURI(clazzBinName, cl); + final URI jarSubURI = JarUtil.getJarSubURI(clazzBinName, cl); Assert.assertNotNull(jarSubURI); final URL jarSubURL= IOUtil.toURL(jarSubURI); - URLConnection urlConn = jarSubURL.openConnection(); + final URLConnection urlConn = jarSubURL.openConnection(); Assert.assertTrue("jarSubURL has zero content: "+jarSubURL, urlConn.getContentLength()>0); System.err.println("URLConnection of jarSubURL: "+urlConn); - URI jarFileURL = JarUtil.getJarFileURI(clazzBinName, cl); + final URI jarFileURL = JarUtil.getJarFileURI(clazzBinName, cl); validateJarFileURL(jarFileURL); - JarFile jarFile = JarUtil.getJarFile(clazzBinName, cl); + final JarFile jarFile = JarUtil.getJarFile(clazzBinName, cl); validateJarFile(jarFile); } @@ -202,8 +202,8 @@ public class TestJarUtil extends JunitTracer { } /** Override normal method to return un-resolvable URL. */ - public URL getResource(String name) { - URL url = super.getResource(name); + public URL getResource(final String name) { + final URL url = super.getResource(name); if(url == null) return(null); URL urlReturn = null; @@ -212,11 +212,11 @@ public class TestJarUtil extends JunitTracer { urlReturn = new URL("bundleresource", "4.fwk1990213994", 1, url.getFile(), new URLStreamHandler() { @Override - protected URLConnection openConnection(URL u) throws IOException { + protected URLConnection openConnection(final URL u) throws IOException { return null; } }); - } catch(MalformedURLException e) { + } catch(final MalformedURLException e) { // shouldn't happen, since I create the URL correctly above Assert.assertTrue(false); } @@ -228,11 +228,11 @@ public class TestJarUtil extends JunitTracer { * opaque bundle data inside its custom classloader to find the stored JAR path; we do it here * by simply retrieving the JAR name from where we left it at the end of the URL. */ JarUtil.setResolver( new JarUtil.Resolver() { - public URL resolve( URL url ) { + public URL resolve( final URL url ) { if( url.getProtocol().equals("bundleresource") ) { try { return new URL( IOUtil.JAR_SCHEME, "", url.getFile() ); - } catch(MalformedURLException e) { + } catch(final MalformedURLException e) { return url; } } else { @@ -254,8 +254,8 @@ public class TestJarUtil extends JunitTracer { System.err.println("XXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } - public static void main(String args[]) throws IOException { - String tstname = TestJarUtil.class.getName(); + public static void main(final String args[]) throws IOException { + final String tstname = TestJarUtil.class.getName(); org.junit.runner.JUnitCore.main(tstname); } diff --git a/src/junit/com/jogamp/common/util/TestLFRingBuffer01.java b/src/junit/com/jogamp/common/util/TestLFRingBuffer01.java index 1695b37..181af7c 100644 --- a/src/junit/com/jogamp/common/util/TestLFRingBuffer01.java +++ b/src/junit/com/jogamp/common/util/TestLFRingBuffer01.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.common.util; import com.jogamp.common.util.LFRingbuffer; @@ -36,14 +36,14 @@ import org.junit.runners.MethodSorters; @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestLFRingBuffer01 extends RingBuffer01Base { - public Ringbuffer createEmpty(int initialCapacity) { + public Ringbuffer createEmpty(final int initialCapacity) { return new LFRingbuffer(Integer[].class, initialCapacity); } - public Ringbuffer createFull(Integer[] source) { + public Ringbuffer createFull(final Integer[] source) { return new LFRingbuffer(source); } - - public static void main(String args[]) { + + public static void main(final String args[]) { org.junit.runner.JUnitCore.main(TestLFRingBuffer01.class.getName()); } diff --git a/src/junit/com/jogamp/common/util/TestPlatform01.java b/src/junit/com/jogamp/common/util/TestPlatform01.java index c2218da..ebdfe19 100644 --- a/src/junit/com/jogamp/common/util/TestPlatform01.java +++ b/src/junit/com/jogamp/common/util/TestPlatform01.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.common.util; import org.junit.Assert; @@ -59,37 +59,37 @@ public class TestPlatform01 extends JunitTracer { System.err.println(); System.err.println(); } - + @Test public void testPageSize01() { - final MachineDescription machine = Platform.getMachineDescription(); + final MachineDescription machine = Platform.getMachineDescription(); final int ps = machine.pageSizeInBytes(); System.err.println("PageSize: "+ps); Assert.assertTrue("PageSize is 0", 0 < ps ); - + final int ps_pages = machine.pageCount(ps); Assert.assertTrue("PageNumber of PageSize is not 1, but "+ps_pages, 1 == ps_pages); - + final int sz0 = ps - 10; final int sz0_pages = machine.pageCount(sz0); Assert.assertTrue("PageNumber of PageSize-10 is not 1, but "+sz0_pages, 1 == sz0_pages); - + final int sz1 = ps + 10; final int sz1_pages = machine.pageCount(sz1); Assert.assertTrue("PageNumber of PageSize+10 is not 2, but "+sz1_pages, 2 == sz1_pages); - + final int ps_psa = machine.pageAlignedSize(ps); Assert.assertTrue("PageAlignedSize of PageSize is not PageSize, but "+ps_psa, ps == ps_psa); - + final int sz0_psa = machine.pageAlignedSize(sz0); Assert.assertTrue("PageAlignedSize of PageSize-10 is not PageSize, but "+sz0_psa, ps == sz0_psa); - + final int sz1_psa = machine.pageAlignedSize(sz1); Assert.assertTrue("PageAlignedSize of PageSize+10 is not 2*PageSize, but "+sz1_psa, ps*2 == sz1_psa); } - public static void main(String args[]) { - String tstname = TestPlatform01.class.getName(); + public static void main(final String args[]) { + final String tstname = TestPlatform01.class.getName(); org.junit.runner.JUnitCore.main(tstname); } diff --git a/src/junit/com/jogamp/common/util/TestRunnableTask01.java b/src/junit/com/jogamp/common/util/TestRunnableTask01.java index 6051a9b..feb0468 100644 --- a/src/junit/com/jogamp/common/util/TestRunnableTask01.java +++ b/src/junit/com/jogamp/common/util/TestRunnableTask01.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.common.util; import java.io.IOException; @@ -56,23 +56,23 @@ public class TestRunnableTask01 extends JunitTracer { } } }; - + System.err.println("BB.0: "+syncObject); synchronized (syncObject) { System.err.println("BB.1: "+syncObject); new Thread(clientAction, Thread.currentThread().getName()+"-clientAction").start(); try { - System.err.println("BB.2"); + System.err.println("BB.2"); syncObject.wait(); System.err.println("BB.3"); - } catch (InterruptedException e) { + } catch (final InterruptedException e) { throw new RuntimeException(e); - } + } Assert.assertTrue(done[0]); - System.err.println("BB.X"); + System.err.println("BB.X"); } } - + @Test public void testInvokeAndWait01() throws IOException, InterruptedException, InvocationTargetException { final boolean[] done = {false}; @@ -83,26 +83,26 @@ public class TestRunnableTask01 extends JunitTracer { System.err.println("CA.X"); } }; - - final RunnableTask rTask = new RunnableTask(clientAction, new Object(), false, null); + + final RunnableTask rTask = new RunnableTask(clientAction, new Object(), false, null); System.err.println("BB.0: "+rTask.getSyncObject()); synchronized (rTask.getSyncObject()) { System.err.println("BB.1: "+rTask.getSyncObject()); - new Thread(rTask, Thread.currentThread().getName()+"-clientAction").start(); + new Thread(rTask, Thread.currentThread().getName()+"-clientAction").start(); try { System.err.println("BB.2"); rTask.getSyncObject().wait(); System.err.println("BB.3"); - } catch (InterruptedException e) { + } catch (final InterruptedException e) { throw new RuntimeException(e); - } + } Assert.assertTrue(done[0]); System.err.println("BB.X"); - } + } } - public static void main(String args[]) throws IOException { - String tstname = TestRunnableTask01.class.getName(); + public static void main(final String args[]) throws IOException { + final String tstname = TestRunnableTask01.class.getName(); org.junit.runner.JUnitCore.main(tstname); } diff --git a/src/junit/com/jogamp/common/util/TestSyncRingBuffer01.java b/src/junit/com/jogamp/common/util/TestSyncRingBuffer01.java index 0418d44..920231f 100644 --- a/src/junit/com/jogamp/common/util/TestSyncRingBuffer01.java +++ b/src/junit/com/jogamp/common/util/TestSyncRingBuffer01.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.common.util; import com.jogamp.common.util.Ringbuffer; @@ -36,14 +36,14 @@ import org.junit.runners.MethodSorters; @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestSyncRingBuffer01 extends RingBuffer01Base { - public Ringbuffer createEmpty(int initialCapacity) { + public Ringbuffer createEmpty(final int initialCapacity) { return new SyncedRingbuffer(Integer[].class, initialCapacity); } - public Ringbuffer createFull(Integer[] source) { + public Ringbuffer createFull(final Integer[] source) { return new SyncedRingbuffer(source); } - - public static void main(String args[]) { + + public static void main(final String args[]) { org.junit.runner.JUnitCore.main(TestSyncRingBuffer01.class.getName()); } diff --git a/src/junit/com/jogamp/common/util/TestSystemPropsAndEnvs.java b/src/junit/com/jogamp/common/util/TestSystemPropsAndEnvs.java index cb8acb1..a78957a 100644 --- a/src/junit/com/jogamp/common/util/TestSystemPropsAndEnvs.java +++ b/src/junit/com/jogamp/common/util/TestSystemPropsAndEnvs.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.common.util; import java.io.IOException; @@ -46,20 +46,20 @@ public class TestSystemPropsAndEnvs extends JunitTracer { @Test public void dumpProperties() { int i=0; - Properties props = System.getProperties(); - Iterator> iter = props.entrySet().iterator(); + final Properties props = System.getProperties(); + final Iterator> iter = props.entrySet().iterator(); while (iter.hasNext()) { i++; - Map.Entry entry = iter.next(); + final Map.Entry entry = iter.next(); System.out.format("%4d: %s = %s%n", i, entry.getKey(), entry.getValue()); } System.out.println("Property count: "+i); } - + private static String[] suppress_envs = new String[] { "COOKIE", "SSH", "GPG" }; - private static boolean contains(String data, String[] search) { - if(null != data && null != search) { + private static boolean contains(final String data, final String[] search) { + if(null != data && null != search) { for(int i=0; i= 0) { return true; @@ -67,25 +67,25 @@ public class TestSystemPropsAndEnvs extends JunitTracer { } } return false; - } - + } + @Test public void dumpEnvironment() { int i=0; - Map env = System.getenv(); - for (String envName : env.keySet()) { + final Map env = System.getenv(); + for (final String envName : env.keySet()) { if(!contains(envName, suppress_envs)) { i++; System.out.format("%4d: %s = %s%n", i, envName, env.get(envName)); } - } + } System.out.println("Environment count: "+i); } - - public static void main(String args[]) throws IOException { - String tstname = TestSystemPropsAndEnvs.class.getName(); + + public static void main(final String args[]) throws IOException { + final String tstname = TestSystemPropsAndEnvs.class.getName(); org.junit.runner.JUnitCore.main(tstname); } diff --git a/src/junit/com/jogamp/common/util/TestTempJarCache.java b/src/junit/com/jogamp/common/util/TestTempJarCache.java index a4518f0..934fb5e 100644 --- a/src/junit/com/jogamp/common/util/TestTempJarCache.java +++ b/src/junit/com/jogamp/common/util/TestTempJarCache.java @@ -59,15 +59,15 @@ public class TestTempJarCache extends JunitTracer { static TempFileCache fileCache; static class TestClassLoader extends URLClassLoader { - public TestClassLoader(URL[] urls) { + public TestClassLoader(final URL[] urls) { super(urls); } - public TestClassLoader(URL[] urls, ClassLoader parent) { + public TestClassLoader(final URL[] urls, final ClassLoader parent) { super(urls, parent); } } - static void assertTempFileCachesIndividualInstances(boolean shallBeSame, TempFileCache fileCache2, TempFileCache fileCache3) { + static void assertTempFileCachesIndividualInstances(final boolean shallBeSame, final TempFileCache fileCache2, final TempFileCache fileCache3) { Assert.assertTrue(fileCache2.getTempDir().exists()); Assert.assertTrue(fileCache2.getTempDir().isDirectory()); Assert.assertTrue(fileCache3.getTempDir().exists()); @@ -83,30 +83,30 @@ public class TestTempJarCache extends JunitTracer { } // also verify with diff classloader/reflection method, // to proof that methodology is valid! - ClassLoader cl = fileCache2.getClass().getClassLoader(); + final ClassLoader cl = fileCache2.getClass().getClassLoader(); assertTempFileCachesIndividualInstances(shallBeSame, fileCache2, cl, fileCache3, cl); } - static void assertTempFileCachesIndividualInstances(boolean shallBeSame, Object fileCache2, ClassLoader cl2, Object fileCache3, ClassLoader cl3) { - Class fileCacheClazz2 = ReflectionUtil.getClass(TempFileCache.class.getName(), false, cl2); - Class fileCacheClazz3 = ReflectionUtil.getClass(TempFileCache.class.getName(), false, cl3); + static void assertTempFileCachesIndividualInstances(final boolean shallBeSame, final Object fileCache2, final ClassLoader cl2, final Object fileCache3, final ClassLoader cl3) { + final Class fileCacheClazz2 = ReflectionUtil.getClass(TempFileCache.class.getName(), false, cl2); + final Class fileCacheClazz3 = ReflectionUtil.getClass(TempFileCache.class.getName(), false, cl3); - Method fc2GetBaseDir = ReflectionUtil.getMethod(fileCacheClazz2 , "getBaseDir"); - Method fc3GetBaseDir = ReflectionUtil.getMethod(fileCacheClazz3 , "getBaseDir"); - Object baseDir2 = ReflectionUtil.callMethod(fileCache2, fc2GetBaseDir); - Object baseDir3 = ReflectionUtil.callMethod(fileCache3, fc3GetBaseDir); + final Method fc2GetBaseDir = ReflectionUtil.getMethod(fileCacheClazz2 , "getBaseDir"); + final Method fc3GetBaseDir = ReflectionUtil.getMethod(fileCacheClazz3 , "getBaseDir"); + final Object baseDir2 = ReflectionUtil.callMethod(fileCache2, fc2GetBaseDir); + final Object baseDir3 = ReflectionUtil.callMethod(fileCache3, fc3GetBaseDir); Assert.assertEquals(baseDir2, baseDir3); - Method fc2GetRootDir = ReflectionUtil.getMethod(fileCacheClazz2 , "getRootDir"); - Method fc3GetRootDir = ReflectionUtil.getMethod(fileCacheClazz3 , "getRootDir"); - Object rootDir2 = ReflectionUtil.callMethod(fileCache2, fc2GetRootDir); - Object rootDir3 = ReflectionUtil.callMethod(fileCache3, fc3GetRootDir); + final Method fc2GetRootDir = ReflectionUtil.getMethod(fileCacheClazz2 , "getRootDir"); + final Method fc3GetRootDir = ReflectionUtil.getMethod(fileCacheClazz3 , "getRootDir"); + final Object rootDir2 = ReflectionUtil.callMethod(fileCache2, fc2GetRootDir); + final Object rootDir3 = ReflectionUtil.callMethod(fileCache3, fc3GetRootDir); Assert.assertEquals(rootDir2, rootDir3); - Method fc2GetTempDir = ReflectionUtil.getMethod(fileCacheClazz2 , "getTempDir"); - Method fc3GetTempDir = ReflectionUtil.getMethod(fileCacheClazz3 , "getTempDir"); - Object tempDir2 = ReflectionUtil.callMethod(fileCache2, fc2GetTempDir); - Object tempDir3 = ReflectionUtil.callMethod(fileCache3, fc3GetTempDir); + final Method fc2GetTempDir = ReflectionUtil.getMethod(fileCacheClazz2 , "getTempDir"); + final Method fc3GetTempDir = ReflectionUtil.getMethod(fileCacheClazz3 , "getTempDir"); + final Object tempDir2 = ReflectionUtil.callMethod(fileCache2, fc2GetTempDir); + final Object tempDir3 = ReflectionUtil.callMethod(fileCache3, fc3GetTempDir); if(shallBeSame) { Assert.assertTrue("file caches are not equal", tempDir2.equals(tempDir3)); @@ -135,8 +135,8 @@ public class TestTempJarCache extends JunitTracer { @Test public void testTempFileCache02Instances() throws IOException { - TempFileCache fileCache2 = new TempFileCache(); - TempFileCache fileCache3 = new TempFileCache(); + final TempFileCache fileCache2 = new TempFileCache(); + final TempFileCache fileCache3 = new TempFileCache(); assertTempFileCachesIndividualInstances(false, fileCache2, fileCache3); } @@ -144,7 +144,7 @@ public class TestTempJarCache extends JunitTracer { @Test public void testJarUtil01a() throws IOException, IllegalArgumentException, URISyntaxException { if(AndroidVersion.isAvailable) { System.err.println("n/a on Android"); return; } - JarFile jarFile = JarUtil.getJarFile(GlueGenVersion.class.getName(), this.getClass().getClassLoader()); + final JarFile jarFile = JarUtil.getJarFile(GlueGenVersion.class.getName(), this.getClass().getClassLoader()); Assert.assertNotNull(jarFile); JarUtil.extract(fileCache.getTempDir(), null, jarFile, null, false, true, true); File f = new File(fileCache.getTempDir(), "META-INF/MANIFEST.MF"); @@ -204,13 +204,13 @@ public class TestTempJarCache extends JunitTracer { URI jarUriRoot = JarUtil.getJarSubURI(TempJarCache.class.getName(), cl); jarUriRoot = IOUtil.getURIDirname(jarUriRoot); - URI nativeJarURI = JarUtil.getJarFileURI(jarUriRoot, nativeJarName); + final URI nativeJarURI = JarUtil.getJarFileURI(jarUriRoot, nativeJarName); TempJarCache.addNativeLibs(TempJarCache.class, nativeJarURI, null /* nativeLibraryPath */); - String libFullPath = TempJarCache.findLibrary(libBaseName); + final String libFullPath = TempJarCache.findLibrary(libBaseName); Assert.assertNotNull(libFullPath); Assert.assertEquals(libBaseName, NativeLibrary.isValidNativeLibraryName(libFullPath, true)); - File f = new File(libFullPath); + final File f = new File(libFullPath); Assert.assertTrue(f.exists()); } @@ -222,10 +222,10 @@ public class TestTempJarCache extends JunitTracer { JNILibLoaderBase.addNativeJarLibs(TempJarCache.class, libBaseName); Assert.assertTrue(JNILibLoaderBase.isLoaded(libBaseName)); - String libFullPath = TempJarCache.findLibrary(libBaseName); + final String libFullPath = TempJarCache.findLibrary(libBaseName); Assert.assertNotNull(libFullPath); Assert.assertEquals(libBaseName, NativeLibrary.isValidNativeLibraryName(libFullPath, true)); - File f = new File(libFullPath); + final File f = new File(libFullPath); Assert.assertTrue(f.exists()); } @@ -233,19 +233,19 @@ public class TestTempJarCache extends JunitTracer { public void testTempJarCache04aSameClassLoader() throws IOException { assertTempFileCachesIndividualInstances(true, TempJarCache.getTempFileCache(), TempJarCache.getTempFileCache()); - ClassLoader cl = getClass().getClassLoader(); - TempFileCache fileCache2 = (TempFileCache) ReflectionUtil.callStaticMethod(TempJarCache.class.getName(), "getTempFileCache", null, null, cl); - TempFileCache fileCache3 = (TempFileCache) ReflectionUtil.callStaticMethod(TempJarCache.class.getName(), "getTempFileCache", null, null, cl); + final ClassLoader cl = getClass().getClassLoader(); + final TempFileCache fileCache2 = (TempFileCache) ReflectionUtil.callStaticMethod(TempJarCache.class.getName(), "getTempFileCache", null, null, cl); + final TempFileCache fileCache3 = (TempFileCache) ReflectionUtil.callStaticMethod(TempJarCache.class.getName(), "getTempFileCache", null, null, cl); assertTempFileCachesIndividualInstances(true, fileCache2, fileCache3); } @Test public void testTempJarCache04bDiffClassLoader() throws IOException, IllegalArgumentException, URISyntaxException { if(AndroidVersion.isAvailable) { System.err.println("n/a on Android"); return; } - URL[] urls = new URL[] { JarUtil.getJarFileURI(TempJarCache.class.getName(), getClass().getClassLoader()).toURL() }; + final URL[] urls = new URL[] { JarUtil.getJarFileURI(TempJarCache.class.getName(), getClass().getClassLoader()).toURL() }; System.err.println("url: "+urls[0]); - ClassLoader cl2 = new TestClassLoader(urls, null); - ClassLoader cl3 = new TestClassLoader(urls, null); + final ClassLoader cl2 = new TestClassLoader(urls, null); + final ClassLoader cl3 = new TestClassLoader(urls, null); Assert.assertFalse(( (Boolean) ReflectionUtil.callStaticMethod(TempJarCache.class.getName(), "isInitialized", null, null, cl2) ).booleanValue()); @@ -260,14 +260,14 @@ public class TestTempJarCache extends JunitTracer { Assert.assertTrue(( (Boolean) ReflectionUtil.callStaticMethod(TempJarCache.class.getName(), "isInitialized", null, null, cl3) ).booleanValue()); - Object fileCache2 = ReflectionUtil.callStaticMethod(TempJarCache.class.getName(), "getTempFileCache", null, null, cl2); - Object fileCache3 = ReflectionUtil.callStaticMethod(TempJarCache.class.getName(), "getTempFileCache", null, null, cl3); + final Object fileCache2 = ReflectionUtil.callStaticMethod(TempJarCache.class.getName(), "getTempFileCache", null, null, cl2); + final Object fileCache3 = ReflectionUtil.callStaticMethod(TempJarCache.class.getName(), "getTempFileCache", null, null, cl3); assertTempFileCachesIndividualInstances(false, fileCache2, cl2, fileCache3, cl3); } - public static void main(String args[]) throws IOException { - String tstname = TestTempJarCache.class.getName(); + public static void main(final String args[]) throws IOException { + final String tstname = TestTempJarCache.class.getName(); org.junit.runner.JUnitCore.main(tstname); } diff --git a/src/junit/com/jogamp/common/util/TestValueConversion.java b/src/junit/com/jogamp/common/util/TestValueConversion.java index 13cd0cd..6c86803 100644 --- a/src/junit/com/jogamp/common/util/TestValueConversion.java +++ b/src/junit/com/jogamp/common/util/TestValueConversion.java @@ -99,15 +99,15 @@ public class TestValueConversion { @Test public void testConversion() { - byte sb0 = 127; - byte sb1 = -128; + final byte sb0 = 127; + final byte sb1 = -128; - float sf0 = byte_to_float(sb0, true); - float sf1 = byte_to_float(sb1, true); - short ss0 = byte_to_short(sb0, true, true); - short ss1 = byte_to_short(sb1, true, true); - int si0 = byte_to_int(sb0, true, true); - int si1 = byte_to_int(sb1, true, true); + final float sf0 = byte_to_float(sb0, true); + final float sf1 = byte_to_float(sb1, true); + final short ss0 = byte_to_short(sb0, true, true); + final short ss1 = byte_to_short(sb1, true, true); + final int si0 = byte_to_int(sb0, true, true); + final int si1 = byte_to_int(sb1, true, true); Assert.assertEquals(1.0f, sf0, 0.0); Assert.assertEquals(-1.0f, sf1, 0.0); @@ -121,10 +121,10 @@ public class TestValueConversion { Assert.assertEquals(sb0, int_to_byte(si0, true, true)); Assert.assertEquals(sb1, int_to_byte(si1, true, true)); - byte ub0 = (byte) 0xff; - float uf0 = byte_to_float(ub0, false); - short us0 = byte_to_short(ub0, false, false); - int ui0 = byte_to_int(ub0, false, false); + final byte ub0 = (byte) 0xff; + final float uf0 = byte_to_float(ub0, false); + final short us0 = byte_to_short(ub0, false, false); + final int ui0 = byte_to_int(ub0, false, false); Assert.assertEquals(1.0f, uf0, 0.0); Assert.assertEquals((short)0xffff, us0); @@ -134,7 +134,7 @@ public class TestValueConversion { Assert.assertEquals(us0, int_to_short(ui0, false, false)); } - public static void main(String args[]) { + public static void main(final String args[]) { org.junit.runner.JUnitCore.main(TestValueConversion.class.getName()); } diff --git a/src/junit/com/jogamp/common/util/TestVersionInfo.java b/src/junit/com/jogamp/common/util/TestVersionInfo.java index 46bd1d2..7466d0d 100644 --- a/src/junit/com/jogamp/common/util/TestVersionInfo.java +++ b/src/junit/com/jogamp/common/util/TestVersionInfo.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.common.util; import java.io.IOException; @@ -50,8 +50,8 @@ public class TestVersionInfo extends JunitTracer { } - public static void main(String args[]) throws IOException { - String tstname = TestVersionInfo.class.getName(); + public static void main(final String args[]) throws IOException { + final String tstname = TestVersionInfo.class.getName(); org.junit.runner.JUnitCore.main(tstname); } diff --git a/src/junit/com/jogamp/common/util/TestVersionNumber.java b/src/junit/com/jogamp/common/util/TestVersionNumber.java index b3d1cfd..2b4f6d2 100644 --- a/src/junit/com/jogamp/common/util/TestVersionNumber.java +++ b/src/junit/com/jogamp/common/util/TestVersionNumber.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.common.util; import java.io.IOException; @@ -50,21 +50,21 @@ public class TestVersionNumber extends JunitTracer { Assert.assertTrue(vn0.hasMajor()); Assert.assertTrue(vn0.hasMinor()); Assert.assertTrue(vn0.hasSub()); - + VersionNumber vn; - + vn = new VersionNumber(vs00); Assert.assertTrue(vn.hasMajor()); Assert.assertTrue(vn.hasMinor()); Assert.assertTrue(vn.hasSub()); Assert.assertEquals(vn0, vn); - + vn = new VersionNumber(vs01); Assert.assertTrue(vn.hasMajor()); Assert.assertTrue(vn.hasMinor()); Assert.assertTrue(vn.hasSub()); Assert.assertEquals(vn0, vn); - + vn = new VersionNumber(vs02); Assert.assertTrue(vn.hasMajor()); Assert.assertTrue(vn.hasMinor()); @@ -74,7 +74,7 @@ public class TestVersionNumber extends JunitTracer { @Test public void test01b() { final String delim = ","; - + final String vs00 = "1,0,16"; final String vs01 = "OpenGL ES GLSL ES 1,0,16"; final String vs02 = "1,0,16 OpenGL ES GLSL ES"; @@ -82,26 +82,26 @@ public class TestVersionNumber extends JunitTracer { Assert.assertTrue(vn0.hasMajor()); Assert.assertTrue(vn0.hasMinor()); Assert.assertTrue(vn0.hasSub()); - + VersionNumber vn; - + vn = new VersionNumber(vs00, delim); Assert.assertTrue(vn.hasMajor()); Assert.assertTrue(vn.hasMinor()); Assert.assertTrue(vn.hasSub()); Assert.assertEquals(vn0, vn); - + vn = new VersionNumber(vs01, delim); Assert.assertTrue(vn.hasMajor()); Assert.assertTrue(vn.hasMinor()); Assert.assertTrue(vn.hasSub()); Assert.assertEquals(vn0, vn); - + vn = new VersionNumber(vs02, delim); Assert.assertTrue(vn.hasMajor()); Assert.assertTrue(vn.hasMinor()); Assert.assertTrue(vn.hasSub()); - Assert.assertEquals(vn0, vn); + Assert.assertEquals(vn0, vn); } @Test @@ -113,32 +113,32 @@ public class TestVersionNumber extends JunitTracer { Assert.assertTrue(vn0.hasMajor()); Assert.assertTrue(vn0.hasMinor()); Assert.assertTrue(vn0.hasSub()); - + VersionNumber vn; - + vn = new VersionNumber(vs00); Assert.assertTrue(vn.hasMajor()); Assert.assertTrue(vn.hasMinor()); Assert.assertTrue(!vn.hasSub()); Assert.assertEquals(vn0, vn); - + vn = new VersionNumber(vs01); Assert.assertTrue(vn.hasMajor()); Assert.assertTrue(vn.hasMinor()); Assert.assertTrue(!vn.hasSub()); Assert.assertEquals(vn0, vn); - + vn = new VersionNumber(vs02); Assert.assertTrue(vn.hasMajor()); Assert.assertTrue(vn.hasMinor()); Assert.assertTrue(!vn.hasSub()); Assert.assertEquals(vn0, vn); } - + @Test public void test02b() { final String delim = ","; - + final String vs00 = "4,20"; final String vs01 = "COMPANY via Stupid tool 4,20"; final String vs02 = "4,20 COMPANY via Stupid tool"; @@ -146,21 +146,21 @@ public class TestVersionNumber extends JunitTracer { Assert.assertTrue(vn0.hasMajor()); Assert.assertTrue(vn0.hasMinor()); Assert.assertTrue(vn0.hasSub()); - + VersionNumber vn; - + vn = new VersionNumber(vs00, delim); Assert.assertTrue(vn.hasMajor()); Assert.assertTrue(vn.hasMinor()); Assert.assertTrue(!vn.hasSub()); Assert.assertEquals(vn0, vn); - + vn = new VersionNumber(vs01, delim); Assert.assertTrue(vn.hasMajor()); Assert.assertTrue(vn.hasMinor()); Assert.assertTrue(!vn.hasSub()); Assert.assertEquals(vn0, vn); - + vn = new VersionNumber(vs02, delim); Assert.assertTrue(vn.hasMajor()); Assert.assertTrue(vn.hasMinor()); @@ -177,32 +177,32 @@ public class TestVersionNumber extends JunitTracer { Assert.assertTrue(vn0.hasMajor()); Assert.assertTrue(vn0.hasMinor()); Assert.assertTrue(vn0.hasSub()); - + VersionNumber vn; - + vn = new VersionNumber(vs00); Assert.assertTrue(vn.hasMajor()); Assert.assertTrue(vn.hasMinor()); Assert.assertTrue(vn.hasSub()); Assert.assertEquals(vn0, vn); - + vn = new VersionNumber(vs01); Assert.assertTrue(vn.hasMajor()); Assert.assertTrue(vn.hasMinor()); Assert.assertTrue(vn.hasSub()); Assert.assertEquals(vn0, vn); - + vn = new VersionNumber(vs02); Assert.assertTrue(vn.hasMajor()); Assert.assertTrue(vn.hasMinor()); Assert.assertTrue(vn.hasSub()); Assert.assertEquals(vn0, vn); } - + @Test public void test03b() { final String delim = ","; - + final String vs00 = "A10,11,12b"; final String vs01 = "Prelim Text 10,Funny11,Weird12 Something is odd"; final String vs02 = "Prelim Text 10,Funny11l1,Weird12 2 Something is odd"; @@ -210,28 +210,28 @@ public class TestVersionNumber extends JunitTracer { Assert.assertTrue(vn0.hasMajor()); Assert.assertTrue(vn0.hasMinor()); Assert.assertTrue(vn0.hasSub()); - + VersionNumber vn; - + vn = new VersionNumber(vs00, delim); Assert.assertTrue(vn.hasMajor()); Assert.assertTrue(vn.hasMinor()); Assert.assertTrue(vn.hasSub()); Assert.assertEquals(vn0, vn); - + vn = new VersionNumber(vs01, delim); Assert.assertTrue(vn.hasMajor()); Assert.assertTrue(vn.hasMinor()); Assert.assertTrue(vn.hasSub()); Assert.assertEquals(vn0, vn); - + vn = new VersionNumber(vs02, delim); Assert.assertTrue(vn.hasMajor()); Assert.assertTrue(vn.hasMinor()); Assert.assertTrue(vn.hasSub()); Assert.assertEquals(vn0, vn); } - + @Test public void test04() { final String vs00 = "A10.11.12b (git-d6c318e)"; @@ -241,21 +241,21 @@ public class TestVersionNumber extends JunitTracer { Assert.assertTrue(vn0.hasMajor()); Assert.assertTrue(vn0.hasMinor()); Assert.assertTrue(vn0.hasSub()); - + VersionNumber vn; - + vn = new VersionNumber(vs00); Assert.assertTrue(vn.hasMajor()); Assert.assertTrue(vn.hasMinor()); Assert.assertTrue(vn.hasSub()); Assert.assertEquals(vn0, vn); - + vn = new VersionNumber(vs01); Assert.assertTrue(vn.hasMajor()); Assert.assertTrue(vn.hasMinor()); Assert.assertTrue(vn.hasSub()); Assert.assertEquals(vn0, vn); - + vn = new VersionNumber(vs02); Assert.assertTrue(vn.hasMajor()); Assert.assertTrue(vn.hasMinor()); @@ -265,7 +265,7 @@ public class TestVersionNumber extends JunitTracer { @Test public void test04b() { final String delim = ","; - + final String vs00 = "A10,11,12b (git-d6c318e)"; final String vs01 = "Prelim Text 10,Funny11,Weird12 Something is odd (git-d6c318e)"; final String vs02 = "Prelim Text 10,Funny11l1,Weird12 2 Something is odd (git-d6c318e)"; @@ -273,30 +273,30 @@ public class TestVersionNumber extends JunitTracer { Assert.assertTrue(vn0.hasMajor()); Assert.assertTrue(vn0.hasMinor()); Assert.assertTrue(vn0.hasSub()); - + VersionNumber vn; - + vn = new VersionNumber(vs00, delim); Assert.assertTrue(vn.hasMajor()); Assert.assertTrue(vn.hasMinor()); Assert.assertTrue(vn.hasSub()); Assert.assertEquals(vn0, vn); - + vn = new VersionNumber(vs01, delim); Assert.assertTrue(vn.hasMajor()); Assert.assertTrue(vn.hasMinor()); Assert.assertTrue(vn.hasSub()); Assert.assertEquals(vn0, vn); - + vn = new VersionNumber(vs02, delim); Assert.assertTrue(vn.hasMajor()); Assert.assertTrue(vn.hasMinor()); Assert.assertTrue(vn.hasSub()); Assert.assertEquals(vn0, vn); } - - public static void main(String args[]) throws IOException { - String tstname = TestVersionNumber.class.getName(); + + public static void main(final String args[]) throws IOException { + final String tstname = TestVersionNumber.class.getName(); org.junit.runner.JUnitCore.main(tstname); } diff --git a/src/junit/com/jogamp/common/util/TestVersionSemantics.java b/src/junit/com/jogamp/common/util/TestVersionSemantics.java index 5e8b899..b70cdd7 100644 --- a/src/junit/com/jogamp/common/util/TestVersionSemantics.java +++ b/src/junit/com/jogamp/common/util/TestVersionSemantics.java @@ -93,8 +93,8 @@ public class TestVersionSemantics extends JunitTracer { curVersion.getClass(), currentCL, curVersionNumber, excludes); } - public static void main(String args[]) throws IOException { - String tstname = TestVersionSemantics.class.getName(); + public static void main(final String args[]) throws IOException { + final String tstname = TestVersionSemantics.class.getName(); org.junit.runner.JUnitCore.main(tstname); } } diff --git a/src/junit/com/jogamp/common/util/locks/TestRecursiveLock01.java b/src/junit/com/jogamp/common/util/locks/TestRecursiveLock01.java index df5f3ba..26677c0 100644 --- a/src/junit/com/jogamp/common/util/locks/TestRecursiveLock01.java +++ b/src/junit/com/jogamp/common/util/locks/TestRecursiveLock01.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.common.util.locks; import java.io.IOException; @@ -47,16 +47,16 @@ import org.junit.runners.MethodSorters; public class TestRecursiveLock01 extends JunitTracer { public enum YieldMode { - NONE(0), YIELD(1), SLEEP(2); - + NONE(0), YIELD(1), SLEEP(2); + public final int id; - YieldMode(int id){ + YieldMode(final int id){ this.id = id; } - } - - static void yield(YieldMode mode) { + } + + static void yield(final YieldMode mode) { switch(mode) { case YIELD: Thread.yield(); @@ -64,7 +64,7 @@ public class TestRecursiveLock01 extends JunitTracer { case SLEEP: try { Thread.sleep(10); - } catch (InterruptedException ie) { + } catch (final InterruptedException ie) { ie.printStackTrace(); } break; @@ -76,7 +76,7 @@ public class TestRecursiveLock01 extends JunitTracer { static class LockedObject { static final boolean DEBUG = false; - + static class ThreadStat { ThreadStat() { total = 0; @@ -85,16 +85,16 @@ public class TestRecursiveLock01 extends JunitTracer { long total; // ns int counter; } - - private RecursiveLock locker; // post + + private final RecursiveLock locker; // post private int deferredThreadCount = 0; // synced - private Map threadWaitMap = Collections.synchronizedMap(new HashMap()); // locked - - long avrg; // ns, post + private final Map threadWaitMap = Collections.synchronizedMap(new HashMap()); // locked + + long avrg; // ns, post long max_deviation; // ns, post long min_deviation; // ns, post - public LockedObject(LockFactory.ImplType implType, boolean fair) { + public LockedObject(final LockFactory.ImplType implType, final boolean fair) { locker = LockFactory.createRecursiveLock(implType, fair); } @@ -107,8 +107,8 @@ public class TestRecursiveLock01 extends JunitTracer { public synchronized int getDeferredThreadCount() { return deferredThreadCount; } - - public final void action1Direct(int l, YieldMode yieldMode) { + + public final void action1Direct(int l, final YieldMode yieldMode) { if(DEBUG) { System.err.print("dc) { throw new InternalError("deferredThreads: "+dc); } - } + } } - public final void action2Deferred(int l, YieldMode yieldMode) { - Action2 action2 = new Action2(l, yieldMode); + public final void action2Deferred(final int l, final YieldMode yieldMode) { + final Action2 action2 = new Action2(l, yieldMode); new Thread(action2, Thread.currentThread().getName()+"-deferred").start(); } @@ -177,7 +177,7 @@ public class TestRecursiveLock01 extends JunitTracer { long td = System.nanoTime(); locker.lock(); td = System.nanoTime() - td; - + final String cur = Thread.currentThread().getName(); ThreadStat ts = threadWaitMap.get(cur); if(null == ts) { @@ -195,37 +195,37 @@ public class TestRecursiveLock01 extends JunitTracer { public final boolean isLocked() { return locker.isLocked(); } - - public void stats(boolean dump) { + + public void stats(final boolean dump) { long timeAllLocks=0; int numAllLocks=0; - for(Iterator i = threadWaitMap.keySet().iterator(); i.hasNext(); ) { - String name = i.next(); - ThreadStat ts = threadWaitMap.get(name); + for(final Iterator i = threadWaitMap.keySet().iterator(); i.hasNext(); ) { + final String name = i.next(); + final ThreadStat ts = threadWaitMap.get(name); timeAllLocks += ts.total; numAllLocks += ts.counter; - } + } max_deviation = Long.MIN_VALUE; min_deviation = Long.MAX_VALUE; avrg = timeAllLocks/numAllLocks; if(dump) { - System.err.printf("Average: %6d ms / %6d times = %8d ns", + System.err.printf("Average: %6d ms / %6d times = %8d ns", timeAllLocks/1000000, numAllLocks, avrg); System.err.println(); } - for(Iterator i = threadWaitMap.keySet().iterator(); i.hasNext(); numAllLocks++) { - String name = i.next(); + for(final Iterator i = threadWaitMap.keySet().iterator(); i.hasNext(); numAllLocks++) { + final String name = i.next(); final ThreadStat ts = threadWaitMap.get(name); final long a = ts.total/ts.counter; final long d = a - avrg; max_deviation = Math.max(max_deviation, d); min_deviation = Math.min(min_deviation, d); if(dump) { - System.err.printf("%-35s %12d ns / %6d times, a %8d ns, d %8d ns", + System.err.printf("%-35s %12d ns / %6d times, a %8d ns, d %8d ns", name, ts.total, ts.counter, a, d); System.err.println(); } - } + } if(dump) { System.err.printf("Deviation (min/max): [%8d ns - %8d ns]", min_deviation, max_deviation); System.err.println(); @@ -248,7 +248,7 @@ public class TestRecursiveLock01 extends JunitTracer { int iloops; YieldMode yieldMode; - public LockedObjectRunner1(LockedObject lo, int loops, int iloops, YieldMode yieldMode) { + public LockedObjectRunner1(final LockedObject lo, final int loops, final int iloops, final YieldMode yieldMode) { this.lo = lo; this.loops = loops; this.iloops = iloops; @@ -264,18 +264,18 @@ public class TestRecursiveLock01 extends JunitTracer { public final boolean isStopped() { return stopped; } - + public void waitUntilStopped() { synchronized(this) { while(!stopped) { try { this.wait(); - } catch (InterruptedException e) { + } catch (final InterruptedException e) { e.printStackTrace(); } } } - + } public void run() { @@ -291,18 +291,18 @@ public class TestRecursiveLock01 extends JunitTracer { } } - protected long testLockedObjectImpl(LockFactory.ImplType implType, boolean fair, - int threadNum, int loops, int iloops, YieldMode yieldMode) throws InterruptedException { + protected long testLockedObjectImpl(final LockFactory.ImplType implType, final boolean fair, + final int threadNum, final int loops, final int iloops, final YieldMode yieldMode) throws InterruptedException { final long t0 = System.currentTimeMillis(); - LockedObject lo = new LockedObject(implType, fair); - LockedObjectRunner[] runners = new LockedObjectRunner[threadNum]; - Thread[] threads = new Thread[threadNum]; + final LockedObject lo = new LockedObject(implType, fair); + final LockedObjectRunner[] runners = new LockedObjectRunner[threadNum]; + final Thread[] threads = new Thread[threadNum]; int i; for(i=0; i=mark) { if(DEBUG) { System.err.println(tab+"["+name+" c "+slaveCounter+" - NOP]"); } - return; + return; } locker.lock(); if(DEBUG) { @@ -141,7 +141,7 @@ public class TestRecursiveThreadGroupLock01 extends JunitTracer { public final boolean isLocked() { return locker.isLocked(); } - + } interface LockedObjectRunner extends Runnable { @@ -163,7 +163,7 @@ public class TestRecursiveThreadGroupLock01 extends JunitTracer { YieldMode yieldMode; /** master constructor */ - public LockedObjectRunner1(String tab, String name, LockedObject lo, Thread[] slaves, int loops, int mark, YieldMode yieldMode) { + public LockedObjectRunner1(final String tab, final String name, final LockedObject lo, final Thread[] slaves, final int loops, final int mark, final YieldMode yieldMode) { this.tab = tab; this.name = name; this.lo = lo; @@ -178,7 +178,7 @@ public class TestRecursiveThreadGroupLock01 extends JunitTracer { } /** slave constructor */ - public LockedObjectRunner1(String tab, String name, LockedObject lo, int loops, int mark, YieldMode yieldMode) { + public LockedObjectRunner1(final String tab, final String name, final LockedObject lo, final int loops, final int mark, final YieldMode yieldMode) { this.tab = tab; this.name = name; this.lo = lo; @@ -191,7 +191,7 @@ public class TestRecursiveThreadGroupLock01 extends JunitTracer { Assert.assertTrue(mark>loops); Assert.assertTrue(loops*loops>mark); } - + public final void stop() { shouldStop = true; } @@ -202,18 +202,18 @@ public class TestRecursiveThreadGroupLock01 extends JunitTracer { public final boolean isStopped() { return stopped; } - + public void waitUntilStopped() { synchronized(this) { while(!stopped) { try { this.wait(); - } catch (InterruptedException e) { + } catch (final InterruptedException e) { e.printStackTrace(); } } } - + } public void run() { @@ -232,28 +232,28 @@ public class TestRecursiveThreadGroupLock01 extends JunitTracer { } } - protected long testLockedObjectImpl(LockFactory.ImplType implType, boolean fair, - int slaveThreadNum, int concurrentThreadNum, - int loops, int mark, YieldMode yieldMode) throws InterruptedException { + protected long testLockedObjectImpl(final LockFactory.ImplType implType, final boolean fair, + final int slaveThreadNum, final int concurrentThreadNum, + final int loops, final int mark, final YieldMode yieldMode) throws InterruptedException { final long t0 = System.currentTimeMillis(); - LockedObject lo = new LockedObject(); - LockedObjectRunner[] concurrentRunners = new LockedObjectRunner[concurrentThreadNum]; - LockedObjectRunner[] slaveRunners = new LockedObjectRunner[slaveThreadNum]; - Thread[] concurrentThreads = new Thread[concurrentThreadNum]; - Thread[] slaveThreads = new Thread[slaveThreadNum]; - Thread[] noCoOwnerThreads = new Thread[0]; + final LockedObject lo = new LockedObject(); + final LockedObjectRunner[] concurrentRunners = new LockedObjectRunner[concurrentThreadNum]; + final LockedObjectRunner[] slaveRunners = new LockedObjectRunner[slaveThreadNum]; + final Thread[] concurrentThreads = new Thread[concurrentThreadNum]; + final Thread[] slaveThreads = new Thread[slaveThreadNum]; + final Thread[] noCoOwnerThreads = new Thread[0]; int i; for(i=0; i clazzIf = Class.forName(ifName); - Class clazzImpl = Class.forName(implName); + final Class clazzIf = Class.forName(ifName); + final Class clazzImpl = Class.forName(implName); Assert.assertNotNull(ifName+" does not exist", clazzIf); Assert.assertNotNull(implName+" does not exist", clazzImpl); Assert.assertEquals(1, clazzIf.getDeclaredField("CONSTANT_ONE").get(null)); - Object obj = clazzImpl.newInstance(); + final Object obj = clazzImpl.newInstance(); Assert.assertTrue("Not of type "+ifName, clazzIf.isAssignableFrom(obj.getClass())); Assert.assertTrue("Not of type com.jogamp.gluegen.test.junit.generation.Bindingtest1", (obj instanceof com.jogamp.gluegen.test.junit.generation.Bindingtest1)); } @@ -76,22 +76,22 @@ public class BaseClass extends JunitTracer { * Verifies if all generated method signatures are completed, * ie a compilation only coverage test without functional tests. */ - public void chapter__TestCoverageSignature(Bindingtest1 binding) throws Exception { + public void chapter__TestCoverageSignature(final Bindingtest1 binding) throws Exception { int i; - long context = 0; + final long context = 0; LongBuffer lb=null; - IntBuffer ib=null; - long[] larray = null; - int larray_offset = 0; + final IntBuffer ib=null; + final long[] larray = null; + final int larray_offset = 0; String str=null; - String[] strings = null; - int[] iarray = null; - int iarray_offset = 0; + final String[] strings = null; + final int[] iarray = null; + final int iarray_offset = 0; long result = 0; long l = result; { - ByteBuffer bb = binding.createAPtrBlob(); + final ByteBuffer bb = binding.createAPtrBlob(); PointerBuffer pb = safeByteBuffer2PointerBuffer(bb, 1); long bb2A = binding.getAPtrAddress(bb); bb2A = bb2A - 0; // avoid warning @@ -119,7 +119,7 @@ public class BaseClass extends JunitTracer { binding.releaseAPtrBlob(bb); } - ByteBuffer bb=null; + final ByteBuffer bb=null; PointerBuffer pb=null; result = binding.arrayTestInt32(context, ib); @@ -177,7 +177,7 @@ public class BaseClass extends JunitTracer { l = binding.typeTestUIntPtrT(l, l); } - ByteBuffer newByteBuffer(int size, boolean direct) { + ByteBuffer newByteBuffer(final int size, final boolean direct) { if(direct) { final ByteBuffer bb = Buffers.newDirectByteBuffer(size); Assert.assertTrue(bb.isDirect()); @@ -193,7 +193,7 @@ public class BaseClass extends JunitTracer { } } - IntBuffer newIntBuffer(int size, boolean direct) { + IntBuffer newIntBuffer(final int size, final boolean direct) { if(direct) { final IntBuffer ib = Buffers.newDirectIntBuffer(size); Assert.assertTrue(ib.isDirect()); @@ -206,7 +206,7 @@ public class BaseClass extends JunitTracer { } } - LongBuffer newLongBuffer(int size, boolean direct) { + LongBuffer newLongBuffer(final int size, final boolean direct) { if(direct) { final LongBuffer lb = Buffers.newDirectLongBuffer(size); Assert.assertTrue(lb.isDirect()); @@ -219,7 +219,7 @@ public class BaseClass extends JunitTracer { } } - PointerBuffer newPointerBuffer(int size, boolean direct) { + PointerBuffer newPointerBuffer(final int size, final boolean direct) { if(direct) { final PointerBuffer pb = PointerBuffer.allocateDirect(size); Assert.assertTrue(pb.isDirect()); @@ -233,7 +233,7 @@ public class BaseClass extends JunitTracer { } } - long cleanAddress(long a) { + long cleanAddress(final long a) { if (Platform.is32Bit()) { return a & 0x00000000FFFFFFFFL; } else { @@ -241,7 +241,7 @@ public class BaseClass extends JunitTracer { } } - PointerBuffer validatePointerBuffer(PointerBuffer pb, int elements) { + PointerBuffer validatePointerBuffer(final PointerBuffer pb, final int elements) { Assert.assertNotNull(pb); Assert.assertEquals("PointerBuffer capacity not "+elements, elements, pb.capacity()); Assert.assertEquals("PointerBuffer remaining not "+elements, elements, pb.remaining()); @@ -252,7 +252,7 @@ public class BaseClass extends JunitTracer { } return pb; } - PointerBuffer safeByteBuffer2PointerBuffer(ByteBuffer bb, int elements) { + PointerBuffer safeByteBuffer2PointerBuffer(final ByteBuffer bb, final int elements) { Assert.assertEquals("ByteBuffer capacity not PointerBuffer ELEMENT_SIZE * "+elements, elements * PointerBuffer.ELEMENT_SIZE, bb.capacity()); Assert.assertEquals("ByteBuffer remaining not PointerBuffer ELEMENT_SIZE * "+elements, elements * PointerBuffer.ELEMENT_SIZE, bb.remaining()); return validatePointerBuffer(PointerBuffer.wrap(bb), elements); @@ -264,46 +264,46 @@ public class BaseClass extends JunitTracer { * This is a compilation (coverage) and runtime time (semantic) test. * This covers indirect primitive arrays and direct NIO buffers. */ - public void chapter03TestCoverageFunctionalityNIOAndPrimitiveArray(Bindingtest1 binding, boolean direct) throws Exception { + public void chapter03TestCoverageFunctionalityNIOAndPrimitiveArray(final Bindingtest1 binding, final boolean direct) throws Exception { int i; long result; final long context = 1; - LongBuffer lb = newLongBuffer(1, direct); + final LongBuffer lb = newLongBuffer(1, direct); lb.put(0, 10); - ByteBuffer bb2 = newByteBuffer(Buffers.SIZEOF_LONG, direct); - LongBuffer bb2L = bb2.asLongBuffer(); + final ByteBuffer bb2 = newByteBuffer(Buffers.SIZEOF_LONG, direct); + final LongBuffer bb2L = bb2.asLongBuffer(); bb2L.put(0, 100); - IntBuffer ib1 = newIntBuffer(Bindingtest1.ARRAY_SIZE, direct); + final IntBuffer ib1 = newIntBuffer(Bindingtest1.ARRAY_SIZE, direct); for(i=0; i() { public Object run() { diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/BuildEnvironment.java b/src/junit/com/jogamp/gluegen/test/junit/generation/BuildEnvironment.java index a09d1a9..e8fb24d 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/BuildEnvironment.java +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/BuildEnvironment.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,16 +20,13 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - -package com.jogamp.gluegen.test.junit.generation; -import java.io.File; -import java.net.URISyntaxException; +package com.jogamp.gluegen.test.junit.generation; import com.jogamp.common.util.VersionUtil; @@ -44,7 +41,7 @@ public final class BuildEnvironment { public static final String gluegenRoot; public static final String testOutput; public static final String rootrel_build; - + static { out.println(" - - - System info - - - "); @@ -52,20 +49,20 @@ public final class BuildEnvironment { out.println("VM: " + System.getProperty("java.vm.name")); // setup paths - String rootrel_build_tmp = System.getProperty("rootrel.build"); + final String rootrel_build_tmp = System.getProperty("rootrel.build"); if(null==rootrel_build_tmp || rootrel_build_tmp.length()==0) { throw new RuntimeException("Pls specify property rootrel.build"); } rootrel_build = rootrel_build_tmp; out.println("rootrel.build: " + rootrel_build); - String gluegen_root_tmp = System.getProperty("gluegen.root"); + final String gluegen_root_tmp = System.getProperty("gluegen.root"); if(null==gluegen_root_tmp || gluegen_root_tmp.length()==0) { throw new RuntimeException("Pls specify property gluegen.root"); } gluegenRoot = gluegen_root_tmp; out.println("gluegen.root: " + gluegenRoot); - + testOutput = gluegenRoot + "/" + rootrel_build + "/test"; out.println("testOutput: "+testOutput); diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/PCPPTest.java b/src/junit/com/jogamp/gluegen/test/junit/generation/PCPPTest.java index eceef19..f45297f 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/PCPPTest.java +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/PCPPTest.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.gluegen.test.junit.generation; import com.jogamp.common.os.AndroidVersion; @@ -60,18 +60,18 @@ public class PCPPTest extends JunitTracer { setTestSupported(false); } } - + @Test public void pcppMacroDefinitionTest() throws FileNotFoundException, IOException { - PCPP pp = new PCPP(Collections.emptyList(), false, false); - ByteArrayOutputStream output = new ByteArrayOutputStream(); + final PCPP pp = new PCPP(Collections.emptyList(), false, false); + final ByteArrayOutputStream output = new ByteArrayOutputStream(); pp.setOut(output); - String filename = "pcpptest.h"; - String filepath = BuildEnvironment.gluegenRoot + "/src/junit/com/jogamp/gluegen/test/junit/generation/" + filename ; + final String filename = "pcpptest.h"; + final String filepath = BuildEnvironment.gluegenRoot + "/src/junit/com/jogamp/gluegen/test/junit/generation/" + filename ; pp.run(new BufferedReader(new FileReader(filepath)), filename); - String expected = "# 1 \"pcpptest.h\""+ + final String expected = "# 1 \"pcpptest.h\""+ "# define CL_SCHAR_MIN (-127-1)"+ "# define __YES__ 1"+ "# 16 \"pcpptest.h\""+ @@ -99,7 +99,7 @@ public class PCPPTest extends JunitTracer { output.flush(); - String result = output.toString(); + final String result = output.toString(); output.close(); System.err.println("Expected: "); @@ -117,12 +117,12 @@ public class PCPPTest extends JunitTracer { } - private String killWhitespace(String a) { + private String killWhitespace(final String a) { return a.replaceAll("\\p{javaWhitespace}+", ""); } - public static void main(String args[]) throws IOException { - String tstname = PCPPTest.class.getName(); + public static void main(final String args[]) throws IOException { + final String tstname = PCPPTest.class.getName(); org.junit.runner.JUnitCore.main(tstname); } } diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p1JavaEmitter.java b/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p1JavaEmitter.java index e3e3ca9..9e961cb 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p1JavaEmitter.java +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p1JavaEmitter.java @@ -148,8 +148,8 @@ public class Test1p1JavaEmitter extends BaseClass { chapter13TestStructArrayModelMutable(new Bindingtest1p1Impl()); } - public static void main(String args[]) throws IOException { - String tstname = Test1p1JavaEmitter.class.getName(); + public static void main(final String args[]) throws IOException { + final String tstname = Test1p1JavaEmitter.class.getName(); org.junit.runner.JUnitCore.main(tstname); } diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2LoadJNIAndImplLib.java b/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2LoadJNIAndImplLib.java index b16194e..b8adab0 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2LoadJNIAndImplLib.java +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2LoadJNIAndImplLib.java @@ -64,13 +64,13 @@ public class Test1p2LoadJNIAndImplLib extends BaseClass { @SuppressWarnings("unused") - public static void main(String args[]) throws Exception { + public static void main(final String args[]) throws Exception { if( true ) { chapter01TestLoadLibrary(); - Test1p2LoadJNIAndImplLib tst = new Test1p2LoadJNIAndImplLib(); + final Test1p2LoadJNIAndImplLib tst = new Test1p2LoadJNIAndImplLib(); tst.chapter02TestClassExist(); } else { - String tstname = Test1p2LoadJNIAndImplLib.class.getName(); + final String tstname = Test1p2LoadJNIAndImplLib.class.getName(); org.junit.runner.JUnitCore.main(tstname); } } diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2ProcAddressEmitter.java b/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2ProcAddressEmitter.java index 39e3948..49a1851 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2ProcAddressEmitter.java +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2ProcAddressEmitter.java @@ -166,8 +166,8 @@ public class Test1p2ProcAddressEmitter extends BaseClass { dynamicLookupHelper = null; } - public static void main(String args[]) throws IOException { - String tstname = Test1p2ProcAddressEmitter.class.getName(); + public static void main(final String args[]) throws IOException { + final String tstname = Test1p2ProcAddressEmitter.class.getName(); org.junit.runner.JUnitCore.main(tstname); } } diff --git a/src/junit/com/jogamp/gluegen/test/junit/structgen/TestStructGen01.java b/src/junit/com/jogamp/gluegen/test/junit/structgen/TestStructGen01.java index 74f0552..89a9a68 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/structgen/TestStructGen01.java +++ b/src/junit/com/jogamp/gluegen/test/junit/structgen/TestStructGen01.java @@ -20,12 +20,12 @@ public class TestStructGen01 extends JunitTracer { @Test public void test01() { - RenderingConfig config = RenderingConfig.create(); - Vec3f dir = config.getCamera().getDir(); + final RenderingConfig config = RenderingConfig.create(); + final Vec3f dir = config.getCamera().getDir(); dir.setX(0.5f); dir.setY(0.6f); dir.setZ(0.7f); - Vec3f dir2 = Vec3f.create(dir.getBuffer()); + final Vec3f dir2 = Vec3f.create(dir.getBuffer()); Assert.assertEquals(dir.getX(), dir2.getX(), 0.0001f); Assert.assertEquals(dir.getY(), dir2.getY(), 0.0001f); Assert.assertEquals(dir.getZ(), dir2.getZ(), 0.0001f); @@ -33,9 +33,9 @@ public class TestStructGen01 extends JunitTracer { @Test public void test02() { - Camera cam = Camera.create(); - Vec3f cam_dir = cam.getDir(); - Vec3f cam_orig = cam.getOrig(); + final Camera cam = Camera.create(); + final Vec3f cam_dir = cam.getDir(); + final Vec3f cam_orig = cam.getOrig(); cam_dir.setX(1); cam_dir.setY(2); cam_dir.setZ(3); @@ -44,8 +44,8 @@ public class TestStructGen01 extends JunitTracer { cam_orig.setZ(2); } - public static void main(String args[]) { - String tstname = TestStructGen01.class.getName(); + public static void main(final String args[]) { + final String tstname = TestStructGen01.class.getName(); org.junit.runner.JUnitCore.main(tstname); } diff --git a/src/junit/com/jogamp/gluegen/test/junit/structgen/TestStructGen02.java b/src/junit/com/jogamp/gluegen/test/junit/structgen/TestStructGen02.java index a8f0e52..cf0fadc 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/structgen/TestStructGen02.java +++ b/src/junit/com/jogamp/gluegen/test/junit/structgen/TestStructGen02.java @@ -31,7 +31,7 @@ public class TestStructGen02 extends JunitTracer { pos.setY(0.6f); pos.setZ(0.7f); - Pixel pixel2 = Pixel.create(pixel.getBuffer()); + final Pixel pixel2 = Pixel.create(pixel.getBuffer()); final Col4f color2 = pixel2.getColor(); Assert.assertEquals(color.getR(), color2.getR(), 0.0001f); Assert.assertEquals(color.getG(), color2.getG(), 0.0001f); @@ -43,8 +43,8 @@ public class TestStructGen02 extends JunitTracer { Assert.assertEquals(pos.getZ(), pos2.getZ(), 0.0001f); } - public static void main(String args[]) { - String tstname = TestStructGen02.class.getName(); + public static void main(final String args[]) { + final String tstname = TestStructGen02.class.getName(); org.junit.runner.JUnitCore.main(tstname); } diff --git a/src/junit/com/jogamp/junit/sec/Applet01.java b/src/junit/com/jogamp/junit/sec/Applet01.java index 12e8f48..a335efe 100644 --- a/src/junit/com/jogamp/junit/sec/Applet01.java +++ b/src/junit/com/jogamp/junit/sec/Applet01.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -44,38 +44,38 @@ import com.jogamp.common.util.IOUtil; import com.jogamp.common.util.JarUtil; /** - * Applet: Provoke AccessControlException while writing to file! + * Applet: Provoke AccessControlException while writing to file! */ @SuppressWarnings("serial") public class Applet01 extends Applet { static final String java_io_tmpdir_propkey = "java.io.tmpdir"; static final String java_home_propkey = "java.home"; static final String os_name_propkey = "os.name"; - + static final String tfilename = "test.bin" ; - static final MachineDescription machine = Platform.getMachineDescription(); + static final MachineDescription machine = Platform.getMachineDescription(); static final int tsz = machine.pageSizeInBytes(); - + static final boolean usesSecurityManager; - + static { if( null == System.getSecurityManager() ) { usesSecurityManager = false; System.err.println("No SecurityManager Installed"); } else { usesSecurityManager = true; - System.err.println("SecurityManager Already Installed"); + System.err.println("SecurityManager Already Installed"); } } - - static void testPropImpl(String propKey, boolean isSecure) { + + static void testPropImpl(final String propKey, boolean isSecure) { isSecure |= !usesSecurityManager; - + Exception se0 = null; try { - String p0 = System.getProperty(propKey); + final String p0 = System.getProperty(propKey); System.err.println(propKey+": "+p0); - } catch (AccessControlException e) { + } catch (final AccessControlException e) { se0 = e; if( !isSecure ) { System.err.println("Expected exception for insecure property <"+propKey+">"); @@ -95,15 +95,15 @@ public class Applet01 extends Applet { } } } - + static void testTempDirImpl(boolean isSecure) { isSecure |= !usesSecurityManager; - + Exception se0 = null; try { - File tmp = IOUtil.getTempDir(true); + final File tmp = IOUtil.getTempDir(true); System.err.println("Temp: "+tmp); - } catch (AccessControlException e) { + } catch (final AccessControlException e) { se0 = e; if( !isSecure ) { System.err.println("Expected exception for insecure temp dir"); @@ -124,12 +124,12 @@ public class Applet01 extends Applet { } } - private void testWriteFile() { + private void testWriteFile() { AccessControlException sec01 = null; try { - File tmp = IOUtil.getTempDir(true); + final File tmp = IOUtil.getTempDir(true); System.err.println("Temp: "+tmp); - byte[] orig = new byte[tsz]; + final byte[] orig = new byte[tsz]; final File tfile = new File(tmp, tfilename); final OutputStream tout = new BufferedOutputStream(new FileOutputStream(tfile)); for(int i=0; i clazz = this.getClass(); URL libURL = clazz.getResource("/libtest1.so"); @@ -172,19 +172,19 @@ public class Applet01 extends Applet { } } System.err.println("Untrusted Library (URL): "+libURL); - + String libDir1 = null; if( null != libURL ) { try { libDir1 = JarUtil.getJarSubURI(libURL.toURI()).getPath(); - } catch (Exception e) { + } catch (final Exception e) { e.printStackTrace(); } if( null != libDir1 ) { System.err.println("libDir1.1: "+libDir1); try { libDir1= IOUtil.getParentOf(libDir1); - } catch (URISyntaxException e) { + } catch (final URISyntaxException e) { e.printStackTrace(); } System.err.println("libDir1.2: "+libDir1); @@ -194,9 +194,9 @@ public class Applet01 extends Applet { final String absLib = libDir1 + "natives/" + libBaseName; Exception sec01 = null; try { - NativeLibrary nlib = NativeLibrary.open(absLib, cl); + final NativeLibrary nlib = NativeLibrary.open(absLib, cl); System.err.println("NativeLibrary: "+nlib); - } catch (SecurityException e) { + } catch (final SecurityException e) { sec01 = e; if( usesSecurityManager ) { System.err.println("Expected exception for loading native library"); @@ -204,7 +204,7 @@ public class Applet01 extends Applet { } else { System.err.println("Unexpected exception for loading native library"); sec01.printStackTrace(); - } + } } if( !usesSecurityManager ) { if( null != sec01 ) { @@ -216,14 +216,14 @@ public class Applet01 extends Applet { } } } - + public void init() { - + } public void start() { Platform.initSingleton(); - + { testPropImpl(os_name_propkey, true); } @@ -240,15 +240,15 @@ public class Applet01 extends Applet { testTempDirImpl(false); } System.err.println("temp0: OK"); - - testWriteFile(); + + testWriteFile(); System.err.println("writeFile: OK"); - + testOpenLibrary(true); System.err.println("lib0: OK"); } - + public void stop() { - + } } diff --git a/src/junit/com/jogamp/junit/sec/TestSecIOUtil01.java b/src/junit/com/jogamp/junit/sec/TestSecIOUtil01.java index 9ee735c..e4e1b34 100644 --- a/src/junit/com/jogamp/junit/sec/TestSecIOUtil01.java +++ b/src/junit/com/jogamp/junit/sec/TestSecIOUtil01.java @@ -69,14 +69,14 @@ public class TestSecIOUtil01 extends JunitTracer { Platform.initSingleton(); } - static void testPropImpl01(String propKey, boolean isSecure) { + static void testPropImpl01(final String propKey, boolean isSecure) { isSecure |= !usesSecurityManager; Exception se0 = null; try { - String p0 = System.getProperty(propKey); + final String p0 = System.getProperty(propKey); System.err.println(propKey+": "+p0); - } catch (AccessControlException e) { + } catch (final AccessControlException e) { se0 = e; if( !isSecure ) { System.err.println("Expected exception for insecure property <"+propKey+">"); @@ -113,9 +113,9 @@ public class TestSecIOUtil01 extends JunitTracer { Exception se0 = null; try { - File tmp = IOUtil.getTempDir(true); + final File tmp = IOUtil.getTempDir(true); System.err.println("Temp: "+tmp); - } catch (AccessControlException e) { + } catch (final AccessControlException e) { se0 = e; if( !isSecure ) { System.err.println("Expected exception for insecure temp dir"); @@ -137,7 +137,7 @@ public class TestSecIOUtil01 extends JunitTracer { testTempDirImpl(false); } - private NativeLibrary openLibraryImpl(boolean global) { + private NativeLibrary openLibraryImpl(final boolean global) { final ClassLoader cl = getClass().getClassLoader(); System.err.println("CL "+cl); @@ -158,14 +158,14 @@ public class TestSecIOUtil01 extends JunitTracer { if( null != libURL ) { try { libDir1 = JarUtil.getJarSubURI(libURL.toURI()).getPath(); - } catch (Exception e) { + } catch (final Exception e) { e.printStackTrace(); } if( null != libDir1 ) { System.err.println("libDir1.1: "+libDir1); try { libDir1= IOUtil.getParentOf(libDir1); - } catch (URISyntaxException e) { + } catch (final URISyntaxException e) { e.printStackTrace(); } System.err.println("libDir1.2: "+libDir1); @@ -178,7 +178,7 @@ public class TestSecIOUtil01 extends JunitTracer { try { nlib = NativeLibrary.open(absLib, cl); System.err.println("NativeLibrary: "+nlib); - } catch (SecurityException e) { + } catch (final SecurityException e) { se0 = e; if( usesSecurityManager ) { System.err.println("Expected exception for loading native library"); @@ -197,16 +197,16 @@ public class TestSecIOUtil01 extends JunitTracer { } public void testOpenLibrary() { - NativeLibrary nlib = openLibraryImpl(true); + final NativeLibrary nlib = openLibraryImpl(true); if( null != nlib ) { nlib.close(); } } - public static void main(String args[]) throws IOException { + public static void main(final String args[]) throws IOException { TestSecIOUtil01.setup(); - TestSecIOUtil01 aa = new TestSecIOUtil01(); + final TestSecIOUtil01 aa = new TestSecIOUtil01(); aa.testProp00_Temp(); aa.testProp01_Temp(); aa.testProp02_Temp(); diff --git a/src/junit/com/jogamp/junit/util/JunitTracer.java b/src/junit/com/jogamp/junit/util/JunitTracer.java index 555f27f..0575532 100644 --- a/src/junit/com/jogamp/junit/util/JunitTracer.java +++ b/src/junit/com/jogamp/junit/util/JunitTracer.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.junit.util; import org.junit.Assume; @@ -44,27 +44,27 @@ public abstract class JunitTracer { @Rule public TestName _unitTestName = new TestName(); static volatile boolean testSupported = true; - - public static void setTestSupported(boolean v) { + + public static void setTestSupported(final boolean v) { System.err.println("setTestSupported: "+v); testSupported = v; } - + public final String getTestMethodName() { return _unitTestName.getMethodName(); } - - public final String getSimpleTestName(String separator) { + + public final String getSimpleTestName(final String separator) { return getClass().getSimpleName()+separator+getTestMethodName(); } - public final String getFullTestName(String separator) { + public final String getFullTestName(final String separator) { return getClass().getName()+separator+getTestMethodName(); } - + @BeforeClass public static void oneTimeSetUp() { - // one-time initialization code + // one-time initialization code } @AfterClass @@ -80,7 +80,7 @@ public abstract class JunitTracer { System.err.println(" - "+unsupportedTestMsg); Assume.assumeTrue(testSupported); } - System.err.println(); + System.err.println(); } @After -- cgit v1.2.3