diff options
Diffstat (limited to 'src/junit/com')
60 files changed, 1263 insertions, 1266 deletions
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<args.length-1; i+=2) { - String uri_s0 = args[i]; - String uri_s1 = args[i+1]; - URI uri0 = new URI(uri_s0); - URI uri1 = new URI(uri_s1); + final String uri_s0 = args[i]; + final String uri_s1 = args[i+1]; + final URI uri0 = new URI(uri_s0); + final URI uri1 = new URI(uri_s1); showURI(uri0); showURI(uri1); - URIQueryProps data = URIQueryProps.create(uri1, ';'); + final URIQueryProps data = URIQueryProps.create(uri1, ';'); if(null == data) { System.err.println("Error: NULL: <"+uri_s1+"> -> "+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<Callable<Object>> callables = new ArrayList<Callable<Object>>(); - + + final List<Callable<Object>> callables = new ArrayList<Callable<Object>>(); + final CountDownLatch latch = new CountDownLatch(10); - + // create for (int i = 0; i < sizes.length; i++) { final int n = i; - Callable<Object> c = new Callable<Object>() { + final Callable<Object> c = new Callable<Object>() { 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<valuesSource.length; i++) { - long v = acc.getLongAt(i*8); - long t = valuesSource[i]; + final long v = acc.getLongAt(i*8); + final long t = valuesSource[i]; Assert.assertTrue("Value["+i+"] shall be 0x"+Long.toHexString(t)+", is: 0x"+Long.toHexString(v), t == v); } } - - public static void main(String args[]) throws IOException { - String tstname = TestStructAccessorEndian.class.getName(); + + public static void main(final String args[]) throws IOException { + final String tstname = TestStructAccessorEndian.class.getName(); org.junit.runner.JUnitCore.main(tstname); } - + } diff --git a/src/junit/com/jogamp/common/os/TestElfReader01.java b/src/junit/com/jogamp/common/os/TestElfReader01.java index b058a0f..bc6aef1 100644 --- a/src/junit/com/jogamp/common/os/TestElfReader01.java +++ b/src/junit/com/jogamp/common/os/TestElfReader01.java @@ -26,15 +26,15 @@ public class TestElfReader01 extends JunitTracer { public static String GNU_LINUX_SELF_EXE = "/proc/self/exe"; public static String ARM_HF_EXE = "tst-exe-armhf"; public static String ARM_SF_EXE = "tst-exe-arm"; - - private static boolean checkFileReadAccess(File file) { + + private static boolean checkFileReadAccess(final File file) { try { return file.isFile() && file.canRead(); - } catch (Throwable t) { } + } catch (final Throwable t) { } return false; - } - static File findJVMLib(String libName) { - ClassLoader cl = TestElfReader01.class.getClassLoader(); + } + static File findJVMLib(final String libName) { + final ClassLoader cl = TestElfReader01.class.getClassLoader(); final List<String> possibleLibPaths = NativeLibrary.enumerateLibraryPaths(libName, libName, libName, true, cl); for(int i=0; i<possibleLibPaths.size(); i++) { final String libPath = possibleLibPaths.get(i); @@ -47,17 +47,17 @@ public class TestElfReader01 extends JunitTracer { } return null; } - + @Test public void testGNULinuxSelfExe () throws IOException { if( OSType.LINUX == Platform.getOSType() ) { - File f = new File(GNU_LINUX_SELF_EXE); + final File f = new File(GNU_LINUX_SELF_EXE); if( checkFileReadAccess(f) ) { testElfHeaderImpl(f, false); } } } - + @Test public void testJavaLib () throws IOException { File jvmLib = findJVMLib("java"); @@ -68,16 +68,16 @@ public class TestElfReader01 extends JunitTracer { testElfHeaderImpl(jvmLib, false); } } - - void testElfHeaderImpl(File file, boolean fileOutSections) throws IOException { + + void testElfHeaderImpl(final File file, final boolean fileOutSections) throws IOException { System.err.println("Test file "+file.getAbsolutePath()); - RandomAccessFile in = new RandomAccessFile(file, "r"); + final RandomAccessFile in = new RandomAccessFile(file, "r"); try { final ElfHeader eh; try { eh = ElfHeader.read(in); - } catch (Exception e) { - System.err.println("Probably not an ELF file - or not in current format: (catched) "+e.getMessage()); + } catch (final Exception e) { + System.err.println("Probably not an ELF file - or not in current format: (caught) "+e.getMessage()); e.printStackTrace(); return; } @@ -91,7 +91,7 @@ public class TestElfReader01 extends JunitTracer { System.err.println("SH size "+eh.sht[0].d.getBuffer().limit()); } { - SectionHeader sh = eh.getSectionHeader(SectionHeader.SHT_ARM_ATTRIBUTES); + final SectionHeader sh = eh.getSectionHeader(SectionHeader.SHT_ARM_ATTRIBUTES); boolean abiVFPArgsAcceptsVFPVariant = false; if( null != sh ) { final SectionArmAttributes sArmAttrs = (SectionArmAttributes) sh.readSection(in); @@ -116,12 +116,12 @@ public class TestElfReader01 extends JunitTracer { in.close(); } } - - static void dumpSection(RandomAccessFile in, SectionHeader sh, String name, boolean fileOut) throws IllegalArgumentException, IOException { + + static void dumpSection(final RandomAccessFile in, final SectionHeader sh, final String name, final boolean fileOut) throws IllegalArgumentException, IOException { final Section s = sh.readSection(in); if(fileOut) { - File outFile = new File("ElfSection-"+sh.getIndex()+"-"+name); - OutputStream out = new BufferedOutputStream(new FileOutputStream(outFile)); + final File outFile = new File("ElfSection-"+sh.getIndex()+"-"+name); + final OutputStream out = new BufferedOutputStream(new FileOutputStream(outFile)); try { out.write(s.data, s.offset, s.length); } finally { @@ -130,13 +130,13 @@ public class TestElfReader01 extends JunitTracer { } System.err.println(name+": read "+s.length+", "+s); } - - public static void main(String args[]) throws IOException { - String tstname = TestElfReader01.class.getName(); + + public static void main(final String args[]) throws IOException { + final String tstname = TestElfReader01.class.getName(); org.junit.runner.JUnitCore.main(tstname); } - - static String toHexString(int i) { return "0x"+Integer.toHexString(i); } - static String toHexString(long i) { return "0x"+Long.toHexString(i); } - + + static String toHexString(final int i) { return "0x"+Integer.toHexString(i); } + static String toHexString(final long i) { return "0x"+Long.toHexString(i); } + } diff --git a/src/junit/com/jogamp/common/util/BitstreamData.java b/src/junit/com/jogamp/common/util/BitstreamData.java index a434053..a5a0bd9 100644 --- a/src/junit/com/jogamp/common/util/BitstreamData.java +++ b/src/junit/com/jogamp/common/util/BitstreamData.java @@ -59,7 +59,7 @@ public class BitstreamData { public static final String[] testStringsLSB_revByte = new String[] { "01111011", "11110101", "01010011", "01111111" }; public static final String testStringLSB_revByte = testStringsLSB_revByte[0]+testStringsLSB_revByte[1]+testStringsLSB_revByte[2]+testStringsLSB_revByte[3]; - public static final void dumpData(String prefix, byte[] data, int offset, int len) { + public static final void dumpData(final String prefix, final byte[] data, final int offset, final int len) { for(int i=0; i<len; ) { System.err.printf("%s: %03d: ", prefix, i); for(int j=0; j<8 && i<len; j++, i++) { @@ -69,7 +69,7 @@ public class BitstreamData { System.err.println(""); } } - public static final void dumpData(String prefix, ByteBuffer data, int offset, int len) { + public static final void dumpData(final String prefix, final ByteBuffer data, final int offset, final int len) { for(int i=0; i<len; ) { System.err.printf("%s: %03d: ", prefix, i); for(int j=0; j<8 && i<len; j++, i++) { @@ -80,14 +80,14 @@ public class BitstreamData { } } - public static String toHexString(int v) { + public static String toHexString(final int v) { return "0x"+Integer.toHexString(v); } - public static String toHexString(long v) { + public static String toHexString(final long v) { return "0x"+Long.toHexString(v); } public static final String strZeroPadding= "0000000000000000000000000000000000000000000000000000000000000000"; // 64 - public static String toBinaryString(int v, int bitCount) { + public static String toBinaryString(final int v, final int bitCount) { if( 0 == bitCount ) { return ""; } @@ -95,7 +95,7 @@ public class BitstreamData { final String s0 = Integer.toBinaryString( mask & v ); return strZeroPadding.substring(0, bitCount-s0.length())+s0; } - public static String toBinaryString(long v, int bitCount) { + public static String toBinaryString(final long v, final int bitCount) { if( 0 == bitCount ) { return ""; } @@ -103,15 +103,15 @@ public class BitstreamData { final String s0 = Long.toBinaryString( mask & v ); return strZeroPadding.substring(0, bitCount-s0.length())+s0; } - public static String toHexBinaryString(long v, int bitCount) { + public static String toHexBinaryString(final long v, final int bitCount) { final int nibbles = 0 == bitCount ? 2 : ( bitCount + 3 ) / 4; return String.format("[%0"+nibbles+"X, %s]", v, toBinaryString(v, bitCount)); } - public static String toHexBinaryString(int v, int bitCount) { + public static String toHexBinaryString(final int v, final int bitCount) { final int nibbles = 0 == bitCount ? 2 : ( bitCount + 3 ) / 4; return String.format("[%0"+nibbles+"X, %s]", v, toBinaryString(v, bitCount)); } - public static String toHexBinaryString(short v, int bitCount) { + public static String toHexBinaryString(final short v, final int bitCount) { final int nibbles = 0 == bitCount ? 2 : ( bitCount + 3 ) / 4; return String.format("[%0"+nibbles+"X, %s]", v, toBinaryString(v, bitCount)); } diff --git a/src/junit/com/jogamp/common/util/IntCloneable.java b/src/junit/com/jogamp/common/util/IntCloneable.java index 461589b..b1db956 100644 --- a/src/junit/com/jogamp/common/util/IntCloneable.java +++ b/src/junit/com/jogamp/common/util/IntCloneable.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. @@ -28,24 +28,24 @@ package com.jogamp.common.util; public class IntCloneable implements Cloneable { - private int i; - - public IntCloneable(int i) { this.i = i; } - + private final int i; + + public IntCloneable(final int i) { this.i = i; } + public int intValue() { return i; } - + @Override public Object clone() { return new IntCloneable(i); - } - + } + @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if(this == obj) { return true; } if (obj instanceof IntCloneable) { - IntCloneable v = (IntCloneable)obj; + final IntCloneable v = (IntCloneable)obj; return i == v.i ; } - return false; + return false; } } diff --git a/src/junit/com/jogamp/common/util/IntIntHashMapTest.java b/src/junit/com/jogamp/common/util/IntIntHashMapTest.java index fa56d3d..ac009cb 100644 --- a/src/junit/com/jogamp/common/util/IntIntHashMapTest.java +++ b/src/junit/com/jogamp/common/util/IntIntHashMapTest.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 */ @@ -46,7 +46,7 @@ import static java.lang.System.*; /** * * @author Michael Bien - * @author Sven Gothel + * @author Sven Gothel */ import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; @@ -86,20 +86,20 @@ public class IntIntHashMapTest { assertEquals(map.size(), intmap.size()); - for (Entry<Integer, Integer> entry : map.entrySet()) { + for (final Entry<Integer, Integer> entry : map.entrySet()) { assertTrue(intmap.containsKey(entry.getKey())); assertTrue(intmap.containsValue(entry.getValue())); } int i = 0; - for (Entry<Integer, Integer> entry : map.entrySet()) { + for (final Entry<Integer, Integer> 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<IntIntHashMap.Entry> iterator = intmap.iterator(); + + final Iterator<IntIntHashMap.Entry> 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<IntIntHashMap.Entry> iterator = intmap.iterator(); + + final Iterator<IntIntHashMap.Entry> iterator = intmap.iterator(); assertNotNull(iterator); assertTrue(iterator.hasNext()); - Iterator<IntIntHashMap.Entry> iteratorCopy = intmapCopy.iterator(); + final Iterator<IntIntHashMap.Entry> 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<IntIntHashMap.Entry> iterator = intmap.iterator(); + + final Iterator<IntIntHashMap.Entry> iterator = intmap.iterator(); assertNotNull(iterator); assertTrue(iterator.hasNext()); - Iterator<IntIntHashMap.Entry> iteratorCopy = intmapCopy.iterator(); + final Iterator<IntIntHashMap.Entry> 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<Integer> uniqueKeys = new HashSet<Integer>(size); + final HashSet<Integer> uniqueKeys = new HashSet<Integer>(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<Integer> uniqueKeys = new HashSet<Integer>(size); + final HashSet<Integer> uniqueKeys = new HashSet<Integer>(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<Integer, IntCloneable> entry : map.entrySet()) { + for (final Entry<Integer, IntCloneable> entry : map.entrySet()) { assertTrue(intmap.containsKey(entry.getKey())); assertTrue(intmap.containsValue(entry.getValue())); } int i = 0; - for (Entry<Integer, IntCloneable> entry : map.entrySet()) { + for (final Entry<Integer, IntCloneable> 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<IntObjectHashMap.Entry> iterator = intmap.iterator(); + + final Iterator<IntObjectHashMap.Entry> 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<IntObjectHashMap.Entry> iterator = intmap.iterator(); + + final Iterator<IntObjectHashMap.Entry> iterator = intmap.iterator(); assertNotNull(iterator); assertTrue(iterator.hasNext()); - Iterator<IntObjectHashMap.Entry> iteratorCopy = intmapCopy.iterator(); + final Iterator<IntObjectHashMap.Entry> 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<Long, Integer> entry : map.entrySet()) { + for (final Entry<Long, Integer> entry : map.entrySet()) { assertTrue(intmap.containsKey(entry.getKey())); assertTrue(intmap.containsValue(entry.getValue())); } int i = 0; - for (Entry<Long, Integer> entry : map.entrySet()) { + for (final Entry<Long, Integer> 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<LongIntHashMap.Entry> iterator = map.iterator(); + final Iterator<LongIntHashMap.Entry> 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<Long> uniqueKeys = new HashSet<Long>(size); + final HashSet<Long> uniqueKeys = new HashSet<Long>(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<Integer> createEmpty(int initialCapacity); public abstract Ringbuffer<Integer> 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<capacity; i++) { array[i] = Integer.valueOf(startValue+i); } return array; } - - private void readTestImpl(Ringbuffer<Integer> rb, boolean clearRef, int capacity, int len, int startValue) { + + private void readTestImpl(final Ringbuffer<Integer> 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; i++) { - Integer vI = rb.get(); + final Integer vI = rb.get(); Assert.assertNotNull("Empty at read #"+(i+1)+": "+rb, vI); Assert.assertEquals("Wrong value at read #"+(i+1)+": "+rb, startValue+i, vI.intValue()); } - + Assert.assertEquals("Invalid size "+rb, preSize-len, rb.size()); Assert.assertTrue("Invalid free slots after reading "+len+": "+rb, rb.getFreeSlots()>= len); Assert.assertTrue("Is full "+rb, !rb.isFull()); } - - private void writeTestImpl(Ringbuffer<Integer> rb, int capacity, int len, int startValue) { + + private void writeTestImpl(final Ringbuffer<Integer> 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<len; i++) { Assert.assertTrue("Buffer is full at put #"+i+": "+rb, rb.put( Integer.valueOf(startValue+i) )); } - + Assert.assertEquals("Invalid size "+rb, preSize+len, rb.size()); Assert.assertTrue("Is empty "+rb, !rb.isEmpty()); } - - private void moveGetPutImpl(Ringbuffer<Integer> rb, int pos) { + + private void moveGetPutImpl(final Ringbuffer<Integer> rb, final int pos) { Assert.assertTrue("RB is empty "+rb, !rb.isEmpty()); for(int i=0; i<pos; i++) { Assert.assertEquals("MoveFull.get failed "+rb, i, rb.get().intValue()); Assert.assertTrue("MoveFull.put failed "+rb, rb.put(i)); } } - - private void movePutGetImpl(Ringbuffer<Integer> rb, int pos) { + + private void movePutGetImpl(final Ringbuffer<Integer> rb, final int pos) { Assert.assertTrue("RB is full "+rb, !rb.isFull()); for(int i=0; i<pos; i++) { Assert.assertTrue("MoveEmpty.put failed "+rb, rb.put(600+i)); Assert.assertEquals("MoveEmpty.get failed "+rb, 600+i, rb.get().intValue()); } } - + @Test public void test01_FullRead() { final int capacity = 11; final Integer[] source = createIntArray(capacity, 0); - final Ringbuffer<Integer> rb = createFull(source); - Assert.assertEquals("Not full size "+rb, capacity, rb.size()); + final Ringbuffer<Integer> 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<Integer> rb = createEmpty(capacity); + final Ringbuffer<Integer> 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<Integer> rb = createFull(source); + final Ringbuffer<Integer> 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<Integer> rb = createEmpty(capacity); + final Ringbuffer<Integer> 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<Integer> rb = createFull(source); + final Ringbuffer<Integer> 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<Integer> rb = createFull(source); + final Ringbuffer<Integer> 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<Integer> 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<growAmount; i++) { - Integer vI = rb.get(); + final Integer vI = rb.get(); Assert.assertNotNull("Empty at read #"+(i+1)+": "+rb, vI); Assert.assertEquals("Wrong value at read #"+(i+1)+": "+rb, 100+i, vI.intValue()); } - + Assert.assertEquals("Not zero size "+rb, 0, rb.size()); Assert.assertTrue("Not empty "+rb, rb.isEmpty()); Assert.assertTrue("Is full "+rb, !rb.isFull()); @@ -268,7 +268,7 @@ public abstract class RingBuffer01Base { @Test public void test11_GrowEmpty02_Begin2() { test_GrowEmptyImpl(11, 0+2); - } + } @Test public void test12_GrowEmpty03_End() { test_GrowEmptyImpl(11, 11-1); @@ -277,13 +277,13 @@ public abstract class RingBuffer01Base { public void test13_GrowEmpty04_End2() { test_GrowEmptyImpl(11, 11-1-2); } - - private void test_GrowFullImpl(int initCapacity, int pos, boolean debug) { + + private void test_GrowFullImpl(final int initCapacity, final int pos, final boolean debug) { final int growAmount = 5; final int grownCapacity = initCapacity+growAmount; final Integer[] source = createIntArray(initCapacity, 0); - final Ringbuffer<Integer> rb = createFull(source); - + final Ringbuffer<Integer> 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<growAmount; i++) { Assert.assertTrue("Buffer is full at put #"+i+": "+rb, rb.put( Integer.valueOf(100+i) )); } Assert.assertEquals("Not new size "+rb, grownCapacity, rb.size()); Assert.assertTrue("Not full "+rb, rb.isFull()); - + for(int i=0; i<initCapacity; i++) { - Integer vI = rb.get(); + final Integer vI = rb.get(); Assert.assertNotNull("Empty at read #"+(i+1)+": "+rb, vI); Assert.assertEquals("Wrong value at read #"+(i+1)+": "+rb, (pos+i)%initCapacity, vI.intValue()); } for(int i=0; i<growAmount; i++) { - Integer vI = rb.get(); + final Integer vI = rb.get(); Assert.assertNotNull("Empty at read #"+(i+1)+": "+rb, vI); Assert.assertEquals("Wrong value at read #"+(i+1)+": "+rb, 100+i, vI.intValue()); } - + Assert.assertEquals("Not zero size "+rb, 0, rb.size()); Assert.assertTrue("Not empty "+rb, rb.isEmpty()); Assert.assertTrue("Is full "+rb, !rb.isFull()); @@ -325,19 +325,19 @@ public abstract class RingBuffer01Base { @Test public void test20_GrowFull01_Begin() { test_GrowFullImpl(11, 0, false); - } + } @Test public void test21_GrowFull02_Begin1() { test_GrowFullImpl(11, 0+1, false); - } + } @Test public void test22_GrowFull03_Begin2() { test_GrowFullImpl(11, 0+2, false); - } + } @Test public void test23_GrowFull04_Begin3() { test_GrowFullImpl(11, 0+3, false); - } + } @Test public void test24_GrowFull05_End() { test_GrowFullImpl(11, 11-1, false); diff --git a/src/junit/com/jogamp/common/util/TestArrayHashSet01.java b/src/junit/com/jogamp/common/util/TestArrayHashSet01.java index 10a4bf1..4f63fbe 100644 --- a/src/junit/com/jogamp/common/util/TestArrayHashSet01.java +++ b/src/junit/com/jogamp/common/util/TestArrayHashSet01.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.util.*; @@ -45,15 +45,15 @@ public class TestArrayHashSet01 extends JunitTracer { public static class Dummy { int i1, i2, i3; - public Dummy(int i1, int i2, int i3) { + public Dummy(final int i1, final int i2, final int i3) { this.i1 = i1; this.i2 = i2; this.i3 = i3; } - public boolean equals(Object o) { + public boolean equals(final Object o) { if(o instanceof Dummy) { - Dummy d = (Dummy)o; + final Dummy d = (Dummy)o; return this.i1 == d.i1 && this.i2 == d.i2 && this.i3 == d.i3 ; @@ -74,8 +74,8 @@ public class TestArrayHashSet01 extends JunitTracer { } } - public void populate(List<Dummy> l, int start, int len, int i2, int i3, int expectedPlusSize) { - int oldSize = l.size(); + public void populate(final List<Dummy> 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<Dummy> l = new ArrayHashSet<Dummy>(); + final ArrayHashSet<Dummy> l = new ArrayHashSet<Dummy>(); 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<ByteBuffer> getTestStream(final boolean msbFirst, int preBits, final int skipBits, final int postBits) throws IOException { + Bitstream<ByteBuffer> getTestStream(final boolean msbFirst, final int preBits, final int skipBits, final int postBits) throws IOException { final int byteCount = ( preBits + skipBits + postBits + 7 ) / 8; 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<length; i++) { if( b[bOffset+i] != stack[stackOffset+i]) { return false; @@ -52,40 +52,40 @@ public class /*testname*/TestFloatStack01/*testname*/ extends JunitTracer { } return true; } - - + + @Test public void test01PrimitiveArray_I32_G02() { final int initialSizeElem = 32; final int growSizeElem = 2; testPrimitiveArrayImpl(initialSizeElem, growSizeElem); } - + @Test public void test02PrimitiveArray_I00_G32() { final int initialSizeElem = 0; final int growSizeElem = 32; testPrimitiveArrayImpl(initialSizeElem, growSizeElem); } - + static private final boolean VERBOSE = false; - - private void testPrimitiveArrayImpl(int initialSizeElem, int growSizeElem) { - final int compNum = 3; - /*value*/float/*value*/[] e0 = + + private void testPrimitiveArrayImpl(final int initialSizeElem, final int growSizeElem) { + final int compNum = 3; + final /*value*/float/*value*/[] e0 = new /*value*/float/*value*/[] { 0, 1, 2 }; - /*value*/float/*value*/[] e1 = + final /*value*/float/*value*/[] e1 = new /*value*/float/*value*/[] { 3, 4, 5 }; - + final int totalSizeElem = initialSizeElem+2*growSizeElem; - + final int initialSizeComp = initialSizeElem*compNum; final int growSizeComp = growSizeElem*compNum; final int totalSizeComp = totalSizeElem*compNum; - - final /*name*/FloatStack/*name*/ fs0 = + + final /*name*/FloatStack/*name*/ fs0 = new /*name*/FloatStack/*name*/(initialSizeComp, growSizeComp); - + // // PUT // @@ -99,9 +99,9 @@ public class /*testname*/TestFloatStack01/*testname*/ extends JunitTracer { final int j = ( i - initialSizeElem ) % growSizeElem ; final int k = ( 0 < j && j < growSizeElem ) ? growSizeElem - j : 0; Assert.assertTrue("Error #"+i+"("+j+", "+k+"), "+fs0, fs0.remaining() == k*compNum); - } + } Assert.assertTrue("Error "+fs0, fs0.position() == i*compNum); - + String s; if( 0 == i % 2) { if(VERBOSE) { @@ -123,47 +123,47 @@ public class /*testname*/TestFloatStack01/*testname*/ extends JunitTracer { } Assert.assertTrue("Error "+fs0, fs0.remaining() == 0); Assert.assertTrue("Error "+fs0, fs0.position() == totalSizeComp); - + fs0.setGrowSize(0); { Exception expectedException = null; try { fs0.putOnTop(e1, 0, compNum); - } catch (Exception e) { + } catch (final Exception e) { expectedException = e; } if(null == expectedException || !(expectedException instanceof IndexOutOfBoundsException) ) { Assert.assertTrue("Error "+fs0+", exception "+expectedException, false); } } - + // // GET // - + for(int i=0; i<totalSizeElem; i++) { Assert.assertTrue("Error "+fs0, fs0.remaining() == i*compNum); Assert.assertTrue("Error "+fs0, fs0.position() == (totalSizeElem-i)*compNum); - - final /*value*/float/*value*/[] buf = + + final /*value*/float/*value*/[] buf = new /*value*/float/*value*/[compNum]; fs0.getFromTop(buf, 0, compNum); if( 0 == i % 2) { - Assert.assertTrue("Error "+fs0+", #"+i+": "+Arrays.toString(e1)+" != "+Arrays.toString(buf), Arrays.equals(e1, buf)); + Assert.assertTrue("Error "+fs0+", #"+i+": "+Arrays.toString(e1)+" != "+Arrays.toString(buf), Arrays.equals(e1, buf)); } else { Assert.assertTrue("Error "+fs0+", #"+i+": "+Arrays.toString(e0)+" != "+Arrays.toString(buf), Arrays.equals(e0, buf)); } } Assert.assertTrue("Error "+fs0, fs0.remaining() == totalSizeComp); - Assert.assertTrue("Error "+fs0, fs0.position() == 0); - + Assert.assertTrue("Error "+fs0, fs0.position() == 0); + { - final /*value*/float/*value*/[] buf = + final /*value*/float/*value*/[] buf = new /*value*/float/*value*/[compNum]; Exception expectedException = null; try { fs0.getFromTop(buf, 0, compNum); - } catch (Exception e) { + } catch (final Exception e) { expectedException = e; } if(null == expectedException || !(expectedException instanceof IndexOutOfBoundsException) ) { @@ -178,43 +178,43 @@ public class /*testname*/TestFloatStack01/*testname*/ extends JunitTracer { final int growSizeElem = 2; testFloatBufferImpl(initialSizeElem, growSizeElem); } - + @Test public void test12FloatBuffer_I00_G32() { final int initialSizeElem = 0; final int growSizeElem = 32; testFloatBufferImpl(initialSizeElem, growSizeElem); } - - private void testFloatBufferImpl(int initialSizeElem, int growSizeElem) { - final int compNum = 3; - /*value2*/FloatBuffer/*value2*/ fb0 = + + private void testFloatBufferImpl(final int initialSizeElem, final int growSizeElem) { + final int compNum = 3; + final /*value2*/FloatBuffer/*value2*/ fb0 = /*value2*/FloatBuffer/*value2*/.allocate(3*compNum); - - /*value*/float/*value*/[] e0 = + + final /*value*/float/*value*/[] e0 = new /*value*/float/*value*/[] { 0, 1, 2 }; - /*value*/float/*value*/[] e1 = - new /*value*/float/*value*/[] { 3, 4, 5 }; - /*value*/float/*value*/[] e2 = - new /*value*/float/*value*/[] { 6, 7, 8 }; // not put on stack! + final /*value*/float/*value*/[] e1 = + new /*value*/float/*value*/[] { 3, 4, 5 }; + final /*value*/float/*value*/[] e2 = + new /*value*/float/*value*/[] { 6, 7, 8 }; // not put on stack! fb0.put(e0); fb0.put(e1); fb0.put(e2); fb0.position(0); - + final int totalSizeElem = initialSizeElem+2*growSizeElem; - + final int initialSizeComp = initialSizeElem*compNum; final int growSizeComp = growSizeElem*compNum; final int totalSizeComp = totalSizeElem*compNum; - - final /*name*/FloatStack/*name*/ fs0 = + + final /*name*/FloatStack/*name*/ fs0 = new /*name*/FloatStack/*name*/(initialSizeComp, growSizeComp); // // PUT // - + for(int i=0; i<totalSizeElem; i++) { if( 0 == i ) { Assert.assertTrue("Error #"+i+", "+fs0+", "+fb0, fb0.position() == 0); @@ -230,13 +230,13 @@ public class /*testname*/TestFloatStack01/*testname*/ extends JunitTracer { final int j = ( i - initialSizeElem ) % growSizeElem ; final int k = ( 0 < j && j < growSizeElem ) ? growSizeElem - j : 0; Assert.assertTrue("Error #"+i+"("+j+", "+k+"), "+fs0, fs0.remaining() == k*compNum); - } + } Assert.assertTrue("Error "+fs0, fs0.position() == i*compNum); - + final int fb0Pos0 = fb0.position(); fs0.putOnTop(fb0, compNum); Assert.assertTrue("Error "+fs0+", "+fb0, fb0.position() == fb0Pos0 + compNum); - } + } Assert.assertTrue("Error "+fs0, fs0.remaining() == 0); Assert.assertTrue("Error "+fs0, fs0.position() == totalSizeComp); @@ -246,31 +246,31 @@ public class /*testname*/TestFloatStack01/*testname*/ extends JunitTracer { Exception expectedException = null; try { fs0.putOnTop(fb0, compNum); - } catch (Exception e) { + } catch (final Exception e) { expectedException = e; } if(null == expectedException || !(expectedException instanceof IndexOutOfBoundsException) ) { Assert.assertTrue("Error "+fs0+", exception "+expectedException, false); - } + } fb0.position(0); } - + // // GET // - + for(int i=0; i<totalSizeElem; i++) { Assert.assertTrue("Error "+fs0, fs0.remaining() == i*compNum); Assert.assertTrue("Error "+fs0, fs0.position() == (totalSizeElem-i)*compNum); - - final /*value*/float/*value*/[] backing = + + final /*value*/float/*value*/[] backing = new /*value*/float/*value*/[compNum]; - /*value2*/FloatBuffer/*value2*/ buf = + final /*value2*/FloatBuffer/*value2*/ buf = /*value2*/FloatBuffer/*value2*/.wrap(backing); - + fs0.getFromTop(buf, compNum); if( 0 == i % 2) { - Assert.assertTrue("Error "+fs0+", #"+i+": "+Arrays.toString(e1)+" != "+Arrays.toString(backing), Arrays.equals(e1, backing)); + Assert.assertTrue("Error "+fs0+", #"+i+": "+Arrays.toString(e1)+" != "+Arrays.toString(backing), Arrays.equals(e1, backing)); } else { Assert.assertTrue("Error "+fs0+", #"+i+": "+Arrays.toString(e0)+" != "+Arrays.toString(backing), Arrays.equals(e0, backing)); } @@ -278,28 +278,28 @@ public class /*testname*/TestFloatStack01/*testname*/ extends JunitTracer { buf.position(0); } Assert.assertTrue("Error "+fs0, fs0.remaining() == totalSizeComp); - Assert.assertTrue("Error "+fs0, fs0.position() == 0); - + Assert.assertTrue("Error "+fs0, fs0.position() == 0); + { - final /*value*/float/*value*/[] backing = + final /*value*/float/*value*/[] backing = new /*value*/float/*value*/[compNum]; - /*value2*/FloatBuffer/*value2*/ buf + final /*value2*/FloatBuffer/*value2*/ buf = /*value2*/FloatBuffer/*value2*/.wrap(backing); Exception expectedException = null; try { fs0.getFromTop(buf, compNum); - } catch (Exception e) { + } catch (final Exception e) { expectedException = e; } if(null == expectedException || !(expectedException instanceof IndexOutOfBoundsException) ) { Assert.assertTrue("Error "+fs0+", exception "+expectedException, false); } } - + } - - public static void main(String args[]) throws IOException { - String tstname = /*testname*/TestFloatStack01/*testname*/.class.getName(); + + public static void main(final String args[]) throws IOException { + final String tstname = /*testname*/TestFloatStack01/*testname*/.class.getName(); org.junit.runner.JUnitCore.main(tstname); } diff --git a/src/junit/com/jogamp/common/util/TestIOUtil01.java b/src/junit/com/jogamp/common/util/TestIOUtil01.java index 6a53bb5..2a9c857 100644 --- a/src/junit/com/jogamp/common/util/TestIOUtil01.java +++ b/src/junit/com/jogamp/common/util/TestIOUtil01.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.util.*; @@ -52,15 +52,15 @@ import org.junit.runners.MethodSorters; @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestIOUtil01 extends JunitTracer { - static final MachineDescription machine = Platform.getMachineDescription(); + static final MachineDescription machine = Platform.getMachineDescription(); static final int tsz = machine.pageSizeInBytes() + machine.pageSizeInBytes() / 2 ; static final byte[] orig = new byte[tsz]; static final String tfilename = "./test.bin" ; - + @BeforeClass public static void setup() throws IOException { - final File tfile = new File(tfilename); - final OutputStream tout = new BufferedOutputStream(new FileOutputStream(tfile)); + final File tfile = new File(tfilename); + final OutputStream tout = new BufferedOutputStream(new FileOutputStream(tfile)); for(int i=0; i<tsz; i++) { final byte b = (byte) (i%256); orig[i] = b; @@ -68,10 +68,10 @@ public class TestIOUtil01 extends JunitTracer { } tout.close(); } - + @Test public void testCopyStream01Array() throws IOException { - URLConnection urlConn = IOUtil.getResource(this.getClass(), tfilename); + final URLConnection urlConn = IOUtil.getResource(this.getClass(), tfilename); Assert.assertNotNull(urlConn); final BufferedInputStream bis = new BufferedInputStream( urlConn.getInputStream() ); final byte[] bb; @@ -82,52 +82,52 @@ public class TestIOUtil01 extends JunitTracer { } Assert.assertEquals("Byte number not equal orig vs array", orig.length, bb.length); Assert.assertTrue("Bytes not equal orig vs array", Arrays.equals(orig, bb)); - + } @Test public void testCopyStream02Buffer() throws IOException { - URLConnection urlConn = IOUtil.getResource(this.getClass(), tfilename); + final URLConnection urlConn = IOUtil.getResource(this.getClass(), tfilename); Assert.assertNotNull(urlConn); final BufferedInputStream bis = new BufferedInputStream( urlConn.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); } - + @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; i<uriSArray.length; i++) { final String[] uriSPair = uriSArray[i]; @@ -328,7 +328,7 @@ public class TestIOUtilURIHandling extends JunitTracer { Assert.assertTrue("One or more errors occured see stderr above", ok); } - static boolean testURI2URL(String uriSource, String uriExpected) throws IOException, URISyntaxException { + static boolean testURI2URL(final String uriSource, final String uriExpected) throws IOException, URISyntaxException { showURX(uriSource); final URI uri0 = new URI(uriSource); System.err.println("uri.string: "+uri0.toString()); @@ -346,7 +346,7 @@ public class TestIOUtilURIHandling extends JunitTracer { URLConnection con = null; try { con = actualUrl.openConnection(); - } catch (Throwable _t) { + } catch (final Throwable _t) { t = _t; } if( null != t ) { @@ -359,7 +359,7 @@ public class TestIOUtilURIHandling extends JunitTracer { return ok; } - static void testFile2URI(String testname, String[][] uriSArray) throws IOException, URISyntaxException { + static void testFile2URI(final String testname, final String[][] uriSArray) throws IOException, URISyntaxException { boolean ok = true; for(int i=0; i<uriSArray.length; i++) { final String[] uriSPair = uriSArray[i]; @@ -374,7 +374,7 @@ public class TestIOUtilURIHandling extends JunitTracer { Assert.assertTrue("One or more errors occured see stderr above", ok); } - static boolean testFile2URI(String fileSource, String uriEncExpected, String uriDecExpected, String fileExpected) throws IOException, URISyntaxException { + static boolean testFile2URI(final String fileSource, final String uriEncExpected, final String uriDecExpected, final String fileExpected) throws IOException, URISyntaxException { final File file = new File(fileSource); { final URI uri0 = file.toURI(); @@ -405,7 +405,7 @@ public class TestIOUtilURIHandling extends JunitTracer { URLConnection con = null; try { con = actualUrl.openConnection(); - } catch (Throwable _t) { + } catch (final Throwable _t) { t = _t; } if( null != t ) { @@ -418,8 +418,8 @@ public class TestIOUtilURIHandling extends JunitTracer { return ok; } - public static void main(String args[]) throws IOException { - String tstname = TestIOUtilURIHandling.class.getName(); + public static void main(final String args[]) throws IOException { + final String tstname = TestIOUtilURIHandling.class.getName(); org.junit.runner.JUnitCore.main(tstname); } } diff --git a/src/junit/com/jogamp/common/util/TestIteratorIndexCORE.java b/src/junit/com/jogamp/common/util/TestIteratorIndexCORE.java index 0ffed92..110d1cd 100644 --- a/src/junit/com/jogamp/common/util/TestIteratorIndexCORE.java +++ b/src/junit/com/jogamp/common/util/TestIteratorIndexCORE.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,21 +20,17 @@ * 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.util.*; import java.io.IOException; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.AfterClass; import org.junit.Test; import com.jogamp.common.os.Platform; @@ -49,7 +45,7 @@ public class TestIteratorIndexCORE extends JunitTracer { static int elems = 10; static int loop = ( Platform.getCPUFamily() == Platform.CPUFamily.ARM ) ? 20 : 9999999; - public void populate(List l, int len) { + public void populate(final List l, int len) { while(len>0) { 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<JarEntry> entries = jarFile.entries(); + final Enumeration<JarEntry> 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<Integer> createEmpty(int initialCapacity) { + public Ringbuffer<Integer> createEmpty(final int initialCapacity) { return new LFRingbuffer<Integer>(Integer[].class, initialCapacity); } - public Ringbuffer<Integer> createFull(Integer[] source) { + public Ringbuffer<Integer> createFull(final Integer[] source) { return new LFRingbuffer<Integer>(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<Integer> createEmpty(int initialCapacity) { + public Ringbuffer<Integer> createEmpty(final int initialCapacity) { return new SyncedRingbuffer<Integer>(Integer[].class, initialCapacity); } - public Ringbuffer<Integer> createFull(Integer[] source) { + public Ringbuffer<Integer> createFull(final Integer[] source) { return new SyncedRingbuffer<Integer>(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<Map.Entry<Object,Object>> iter = props.entrySet().iterator(); + final Properties props = System.getProperties(); + final Iterator<Map.Entry<Object,Object>> iter = props.entrySet().iterator(); while (iter.hasNext()) { i++; - Map.Entry<Object, Object> entry = iter.next(); + final Map.Entry<Object, Object> 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<search.length; i++) { if(data.indexOf(search[i]) >= 0) { return true; @@ -67,25 +67,25 @@ public class TestSystemPropsAndEnvs extends JunitTracer { } } return false; - } - + } + @Test public void dumpEnvironment() { int i=0; - Map<String, String> env = System.getenv(); - for (String envName : env.keySet()) { + final Map<String, String> 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 cbc9735..ce06e9a 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()); } @@ -218,19 +218,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()); @@ -245,14 +245,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<String, ThreadStat> threadWaitMap = Collections.synchronizedMap(new HashMap<String, ThreadStat>()); // locked - - long avrg; // ns, post + private final Map<String, ThreadStat> threadWaitMap = Collections.synchronizedMap(new HashMap<String, ThreadStat>()); // 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("<a1"); } @@ -133,13 +133,13 @@ public class TestRecursiveLock01 extends JunitTracer { class Action2 implements Runnable { int l; YieldMode yieldMode; - - Action2(int l, YieldMode yieldMode) { + + Action2(final int l, final YieldMode yieldMode) { this.l=l; this.yieldMode=yieldMode; incrDeferredThreadCount(); } - + public void run() { if(DEBUG) { System.err.print("[a2"); @@ -165,11 +165,11 @@ public class TestRecursiveLock01 extends JunitTracer { if(0>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<String> i = threadWaitMap.keySet().iterator(); i.hasNext(); ) { - String name = i.next(); - ThreadStat ts = threadWaitMap.get(name); + for(final Iterator<String> 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<String> i = threadWaitMap.keySet().iterator(); i.hasNext(); numAllLocks++) { - String name = i.next(); + for(final Iterator<String> 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<threadNum; i++) { runners[i] = new LockedObjectRunner1(lo, loops, iloops, yieldMode); // String name = Thread.currentThread().getName()+"-ActionThread-"+i+"_of_"+threadNum; - String name = "ActionThread-"+i+"_of_"+threadNum; + final String name = "ActionThread-"+i+"_of_"+threadNum; threads[i] = new Thread( runners[i], name ); threads[i].start(); } @@ -312,17 +312,17 @@ public class TestRecursiveLock01 extends JunitTracer { } while( 0 < lo.getDeferredThreadCount() ) { Thread.sleep(100); - } + } Assert.assertEquals(0, lo.locker.getHoldCount()); Assert.assertEquals(false, lo.locker.isLocked()); Assert.assertEquals(0, lo.getDeferredThreadCount()); - + final long dt = System.currentTimeMillis()-t0; lo.stats(false); - + System.err.println(); final String fair_S = fair ? "fair " : "unfair" ; - System.err.printf("---- TestRecursiveLock01.testLockedObjectThreading: i %5s, %s, threads %2d, loops-outter %6d, loops-inner %6d, yield %5s - dt %6d ms, avrg %8d ns, deviation [ %8d .. %8d ] ns", + System.err.printf("---- TestRecursiveLock01.testLockedObjectThreading: i %5s, %s, threads %2d, loops-outter %6d, loops-inner %6d, yield %5s - dt %6d ms, avrg %8d ns, deviation [ %8d .. %8d ] ns", implType, fair_S, threadNum, loops, iloops, yieldMode, dt, lo.avrg, lo.min_deviation, lo.max_deviation); System.err.println(); return dt; @@ -330,247 +330,247 @@ public class TestRecursiveLock01 extends JunitTracer { @Test public void testLockedObjectThreading5x1000x10000N_Int01_Fair() throws InterruptedException { - LockFactory.ImplType t = LockFactory.ImplType.Int01; - boolean fair=true; - int threadNum=5; - int loops=1000; - int iloops=10000; - YieldMode yieldMode=YieldMode.NONE; - + final LockFactory.ImplType t = LockFactory.ImplType.Int01; + final boolean fair=true; + int threadNum=5; + int loops=1000; + int iloops=10000; + final YieldMode yieldMode=YieldMode.NONE; + if( Platform.getCPUFamily() == Platform.CPUFamily.ARM ) { threadNum=5; loops=5; iloops=10; } - + testLockedObjectImpl(t, fair, threadNum, loops, iloops, yieldMode); } @Test public void testLockedObjectThreading5x1000x10000N_Java5_Fair() throws InterruptedException { - LockFactory.ImplType t = LockFactory.ImplType.Java5; - boolean fair=true; - int threadNum=5; - int loops=1000; - int iloops=10000; - YieldMode yieldMode=YieldMode.NONE; - + final LockFactory.ImplType t = LockFactory.ImplType.Java5; + final boolean fair=true; + int threadNum=5; + int loops=1000; + int iloops=10000; + final YieldMode yieldMode=YieldMode.NONE; + if( Platform.getCPUFamily() == Platform.CPUFamily.ARM ) { threadNum=5; loops=5; iloops=10; } - + testLockedObjectImpl(t, fair, threadNum, loops, iloops, yieldMode); } - + @Test public void testLockedObjectThreading5x1000x10000N_Int01_Unfair() throws InterruptedException { - LockFactory.ImplType t = LockFactory.ImplType.Int01; - boolean fair=false; - int threadNum=5; - int loops=1000; - int iloops=10000; - YieldMode yieldMode=YieldMode.NONE; - + final LockFactory.ImplType t = LockFactory.ImplType.Int01; + final boolean fair=false; + int threadNum=5; + int loops=1000; + int iloops=10000; + final YieldMode yieldMode=YieldMode.NONE; + if( Platform.getCPUFamily() == Platform.CPUFamily.ARM ) { threadNum=5; loops=5; iloops=10; } - + testLockedObjectImpl(t, fair, threadNum, loops, iloops, yieldMode); } @Test public void testLockedObjectThreading5x1000x10000N_Java5_Unfair() throws InterruptedException { - LockFactory.ImplType t = LockFactory.ImplType.Java5; - boolean fair=false; - int threadNum=5; - int loops=1000; - int iloops=10000; - YieldMode yieldMode=YieldMode.NONE; - + final LockFactory.ImplType t = LockFactory.ImplType.Java5; + final boolean fair=false; + int threadNum=5; + int loops=1000; + int iloops=10000; + final YieldMode yieldMode=YieldMode.NONE; + if( Platform.getCPUFamily() == Platform.CPUFamily.ARM ) { threadNum=5; loops=5; iloops=10; } - + testLockedObjectImpl(t, fair, threadNum, loops, iloops, yieldMode); } - + @Test public void testLockedObjectThreading25x100x100Y_Int01_Fair() throws InterruptedException { - LockFactory.ImplType t = LockFactory.ImplType.Int01; - boolean fair=true; - int threadNum=25; - int loops=100; - int iloops=100; - YieldMode yieldMode=YieldMode.YIELD; - + final LockFactory.ImplType t = LockFactory.ImplType.Int01; + final boolean fair=true; + int threadNum=25; + int loops=100; + int iloops=100; + final YieldMode yieldMode=YieldMode.YIELD; + if( Platform.getCPUFamily() == Platform.CPUFamily.ARM ) { threadNum=5; loops=5; iloops=10; } - - testLockedObjectImpl(t, fair, threadNum, loops, iloops, yieldMode); + + testLockedObjectImpl(t, fair, threadNum, loops, iloops, yieldMode); } @Test public void testLockedObjectThreading25x100x100Y_Java5_Fair() throws InterruptedException { - LockFactory.ImplType t = LockFactory.ImplType.Java5; - boolean fair=true; - int threadNum=25; - int loops=100; - int iloops=100; - YieldMode yieldMode=YieldMode.YIELD; - + final LockFactory.ImplType t = LockFactory.ImplType.Java5; + final boolean fair=true; + int threadNum=25; + int loops=100; + int iloops=100; + final YieldMode yieldMode=YieldMode.YIELD; + if( Platform.getCPUFamily() == Platform.CPUFamily.ARM ) { threadNum=5; loops=5; iloops=10; } - - testLockedObjectImpl(t, fair, threadNum, loops, iloops, yieldMode); + + testLockedObjectImpl(t, fair, threadNum, loops, iloops, yieldMode); } @Test public void testLockedObjectThreading25x100x100Y_Int01_Unair() throws InterruptedException { - LockFactory.ImplType t = LockFactory.ImplType.Int01; - boolean fair=false; - int threadNum=25; - int loops=100; - int iloops=100; - YieldMode yieldMode=YieldMode.YIELD; - + final LockFactory.ImplType t = LockFactory.ImplType.Int01; + final boolean fair=false; + int threadNum=25; + int loops=100; + int iloops=100; + final YieldMode yieldMode=YieldMode.YIELD; + if( Platform.getCPUFamily() == Platform.CPUFamily.ARM ) { threadNum=5; loops=5; iloops=10; } - - testLockedObjectImpl(t, fair, threadNum, loops, iloops, yieldMode); + + testLockedObjectImpl(t, fair, threadNum, loops, iloops, yieldMode); } @Test public void testLockedObjectThreading25x100x100Y_Java5_Unfair() throws InterruptedException { - LockFactory.ImplType t = LockFactory.ImplType.Java5; - boolean fair=false; - int threadNum=25; - int loops=100; - int iloops=100; - YieldMode yieldMode=YieldMode.YIELD; - + final LockFactory.ImplType t = LockFactory.ImplType.Java5; + final boolean fair=false; + int threadNum=25; + int loops=100; + int iloops=100; + final YieldMode yieldMode=YieldMode.YIELD; + if( Platform.getCPUFamily() == Platform.CPUFamily.ARM ) { threadNum=5; loops=5; iloops=10; } - - testLockedObjectImpl(t, fair, threadNum, loops, iloops, yieldMode); + + testLockedObjectImpl(t, fair, threadNum, loops, iloops, yieldMode); } // @Test public void testLockedObjectThreading25x100x100S_Int01_Fair() throws InterruptedException { - LockFactory.ImplType t = LockFactory.ImplType.Int01; - boolean fair=true; - int threadNum=25; - int loops=100; - int iloops=100; - YieldMode yieldMode=YieldMode.SLEEP; - + final LockFactory.ImplType t = LockFactory.ImplType.Int01; + final boolean fair=true; + int threadNum=25; + int loops=100; + int iloops=100; + final YieldMode yieldMode=YieldMode.SLEEP; + if( Platform.getCPUFamily() == Platform.CPUFamily.ARM ) { threadNum=5; loops=5; iloops=10; } - + testLockedObjectImpl(t, fair, threadNum, loops, iloops, yieldMode); } // @Test public void testLockedObjectThreading25x100x100S_Java5() throws InterruptedException { - LockFactory.ImplType t = LockFactory.ImplType.Java5; - boolean fair=true; - int threadNum=25; - int loops=100; - int iloops=100; - YieldMode yieldMode=YieldMode.SLEEP; - + final LockFactory.ImplType t = LockFactory.ImplType.Java5; + final boolean fair=true; + int threadNum=25; + int loops=100; + int iloops=100; + final YieldMode yieldMode=YieldMode.SLEEP; + if( Platform.getCPUFamily() == Platform.CPUFamily.ARM ) { threadNum=5; loops=5; iloops=10; } - + testLockedObjectImpl(t, fair, threadNum, loops, iloops, yieldMode); } @Test public void testLockedObjectThreading25x100x100N_Int01_Fair() throws InterruptedException { - LockFactory.ImplType t = LockFactory.ImplType.Int01; - boolean fair=true; - int threadNum=25; - int loops=100; - int iloops=100; - YieldMode yieldMode=YieldMode.NONE; - + final LockFactory.ImplType t = LockFactory.ImplType.Int01; + final boolean fair=true; + int threadNum=25; + int loops=100; + int iloops=100; + final YieldMode yieldMode=YieldMode.NONE; + if( Platform.getCPUFamily() == Platform.CPUFamily.ARM ) { threadNum=5; loops=5; iloops=10; } - + testLockedObjectImpl(t, fair, threadNum, loops, iloops, yieldMode); } @Test public void testLockedObjectThreading25x100x100N_Java5_Fair() throws InterruptedException { - LockFactory.ImplType t = LockFactory.ImplType.Java5; - boolean fair=true; - int threadNum=25; - int loops=100; - int iloops=100; - YieldMode yieldMode=YieldMode.NONE; - + final LockFactory.ImplType t = LockFactory.ImplType.Java5; + final boolean fair=true; + int threadNum=25; + int loops=100; + int iloops=100; + final YieldMode yieldMode=YieldMode.NONE; + if( Platform.getCPUFamily() == Platform.CPUFamily.ARM ) { threadNum=5; loops=5; iloops=10; } - + testLockedObjectImpl(t, fair, threadNum, loops, iloops, yieldMode); } @Test public void testLockedObjectThreading25x100x100N_Int01_Unfair() throws InterruptedException { - LockFactory.ImplType t = LockFactory.ImplType.Int01; - boolean fair=false; - int threadNum=25; - int loops=100; - int iloops=100; - YieldMode yieldMode=YieldMode.NONE; - + final LockFactory.ImplType t = LockFactory.ImplType.Int01; + final boolean fair=false; + int threadNum=25; + int loops=100; + int iloops=100; + final YieldMode yieldMode=YieldMode.NONE; + if( Platform.getCPUFamily() == Platform.CPUFamily.ARM ) { threadNum=5; loops=5; iloops=10; } - + testLockedObjectImpl(t, fair, threadNum, loops, iloops, yieldMode); } @Test public void testLockedObjectThreading25x100x100N_Java5_Unfair() throws InterruptedException { - LockFactory.ImplType t = LockFactory.ImplType.Java5; - boolean fair=false; - int threadNum=25; - int loops=100; - int iloops=100; - YieldMode yieldMode=YieldMode.NONE; - + final LockFactory.ImplType t = LockFactory.ImplType.Java5; + final boolean fair=false; + int threadNum=25; + int loops=100; + int iloops=100; + final YieldMode yieldMode=YieldMode.NONE; + if( Platform.getCPUFamily() == Platform.CPUFamily.ARM ) { threadNum=5; loops=5; iloops=10; } - + testLockedObjectImpl(t, fair, threadNum, loops, iloops, yieldMode); } - static int atoi(String a) { + static int atoi(final String a) { int i=0; try { i = Integer.parseInt(a); - } catch (Exception ex) { ex.printStackTrace(); } + } catch (final Exception ex) { ex.printStackTrace(); } return i; } - public static void main(String args[]) throws IOException, InterruptedException { - String tstname = TestRecursiveLock01.class.getName(); + public static void main(final String args[]) throws IOException, InterruptedException { + final String tstname = TestRecursiveLock01.class.getName(); org.junit.runner.JUnitCore.main(tstname); - + /** BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); System.err.println("Press enter to continue"); - System.err.println(stdin.readLine()); + System.err.println(stdin.readLine()); TestRecursiveLock01 t = new TestRecursiveLock01(); t.testLockedObjectThreading5x1000x10000N_Int01_Unfair(); - + t.testLockedObjectThreading5x1000x10000N_Int01_Fair(); t.testLockedObjectThreading5x1000x10000N_Java5_Fair(); t.testLockedObjectThreading5x1000x10000N_Int01_Unfair(); diff --git a/src/junit/com/jogamp/common/util/locks/TestRecursiveThreadGroupLock01.java b/src/junit/com/jogamp/common/util/locks/TestRecursiveThreadGroupLock01.java index 51cc0ac..b361463 100644 --- a/src/junit/com/jogamp/common/util/locks/TestRecursiveThreadGroupLock01.java +++ b/src/junit/com/jogamp/common/util/locks/TestRecursiveThreadGroupLock01.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; @@ -43,16 +43,16 @@ import org.junit.runners.MethodSorters; public class TestRecursiveThreadGroupLock01 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(); @@ -60,7 +60,7 @@ public class TestRecursiveThreadGroupLock01 extends JunitTracer { case SLEEP: try { Thread.sleep(10); - } catch (InterruptedException ie) { + } catch (final InterruptedException ie) { ie.printStackTrace(); } break; @@ -72,8 +72,8 @@ public class TestRecursiveThreadGroupLock01 extends JunitTracer { static class LockedObject { static final boolean DEBUG = false; - - private RecursiveThreadGroupLock locker; // post + + private final RecursiveThreadGroupLock locker; // post private volatile int slaveCounter; public LockedObject() { @@ -81,7 +81,7 @@ public class TestRecursiveThreadGroupLock01 extends JunitTracer { slaveCounter = 0; } - public final void masterAction(String tab, String name, Thread[] slaves, int loops, int mark, final YieldMode yieldMode) { + public final void masterAction(final String tab, final String name, final Thread[] slaves, final int loops, final int mark, final YieldMode yieldMode) { locker.lock(); if(DEBUG) { System.err.println(tab+"<"+name+" c "+slaveCounter); @@ -107,12 +107,12 @@ public class TestRecursiveThreadGroupLock01 extends JunitTracer { } } - public final void slaveAction(String tab, String name, int loops, int mark, YieldMode yieldMode) { + public final void slaveAction(final String tab, final String name, int loops, final int mark, final YieldMode yieldMode) { if(slaveCounter>=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<slaveThreadNum; i++) { slaveRunners[i] = new LockedObjectRunner1(" ", "s"+i, lo, loops, mark, yieldMode); - String name = "ActionThread-Slaves-"+i+"_of_"+slaveThreadNum; + final String name = "ActionThread-Slaves-"+i+"_of_"+slaveThreadNum; slaveThreads[i] = new Thread( slaveRunners[i], name ); } for(i=0; i<concurrentThreadNum; i++) { String name; if(i==0) { concurrentRunners[i] = new LockedObjectRunner1("", "M0", lo, slaveThreads, loops, mark, yieldMode); - name = "ActionThread-Master-"+i+"_of_"+concurrentThreadNum; + name = "ActionThread-Master-"+i+"_of_"+concurrentThreadNum; } else { concurrentRunners[i] = new LockedObjectRunner1(" ", "O"+i, lo, noCoOwnerThreads, loops, mark, yieldMode); name = "ActionThread-Others-"+i+"_of_"+concurrentThreadNum; @@ -276,45 +276,45 @@ public class TestRecursiveThreadGroupLock01 extends JunitTracer { } Assert.assertEquals(0, lo.locker.getHoldCount()); Assert.assertEquals(false, lo.locker.isLocked()); - + final long dt = System.currentTimeMillis()-t0; - + System.err.println(); final String fair_S = fair ? "fair " : "unfair" ; - System.err.printf("---- TestRecursiveLock01.testLockedObjectThreading: i %5s, %s, threads %2d, loops-outter %6d, loops-inner %6d, yield %5s - dt %6d ms", + System.err.printf("---- TestRecursiveLock01.testLockedObjectThreading: i %5s, %s, threads %2d, loops-outter %6d, loops-inner %6d, yield %5s - dt %6d ms", implType, fair_S, concurrentThreadNum, loops, mark, yieldMode, dt); System.err.println(); return dt; } - + @Test public void testTwoThreadsInGroup() throws InterruptedException { - LockFactory.ImplType t = LockFactory.ImplType.Int02ThreadGroup; - boolean fair=true; - int coOwnerThreadNum=2; - int threadNum=5; - int loops=1000; - int mark=10000; - YieldMode yieldMode=YieldMode.YIELD; - + final LockFactory.ImplType t = LockFactory.ImplType.Int02ThreadGroup; + final boolean fair=true; + final int coOwnerThreadNum=2; + final int threadNum=5; + int loops=1000; + int mark=10000; + final YieldMode yieldMode=YieldMode.YIELD; + if( Platform.getCPUFamily() == Platform.CPUFamily.ARM ) { loops=5; mark=10; } - + testLockedObjectImpl(t, fair, coOwnerThreadNum, threadNum, loops, mark, yieldMode); } - public static void main(String args[]) throws IOException, InterruptedException { - String tstname = TestRecursiveThreadGroupLock01.class.getName(); + public static void main(final String args[]) throws IOException, InterruptedException { + final String tstname = TestRecursiveThreadGroupLock01.class.getName(); org.junit.runner.JUnitCore.main(tstname); - + /** BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); System.err.println("Press enter to continue"); - System.err.println(stdin.readLine()); + System.err.println(stdin.readLine()); TestRecursiveLock01 t = new TestRecursiveLock01(); t.testLockedObjectThreading5x1000x10000N_Int01_Unfair(); - + t.testLockedObjectThreading5x1000x10000N_Int01_Fair(); t.testLockedObjectThreading5x1000x10000N_Java5_Fair(); t.testLockedObjectThreading5x1000x10000N_Int01_Unfair(); diff --git a/src/junit/com/jogamp/common/util/locks/TestSingletonServerSocket00.java b/src/junit/com/jogamp/common/util/locks/TestSingletonServerSocket00.java index c699e2e..775d46f 100644 --- a/src/junit/com/jogamp/common/util/locks/TestSingletonServerSocket00.java +++ b/src/junit/com/jogamp/common/util/locks/TestSingletonServerSocket00.java @@ -60,22 +60,22 @@ public class TestSingletonServerSocket00 { @Test public void test2ndInstanceLockTimeout() { Assert.assertTrue("Could not lock single instance: "+singletonInstance.getName(), singletonInstance.tryLock(SINGLE_INSTANCE_LOCK_TO)); - SingletonInstance instanceTwo = SingletonInstance.createServerSocket(SINGLE_INSTANCE_LOCK_POLL, SINGLE_INSTANCE_LOCK_PORT); + final SingletonInstance instanceTwo = SingletonInstance.createServerSocket(SINGLE_INSTANCE_LOCK_POLL, SINGLE_INSTANCE_LOCK_PORT); Assert.assertFalse("Could lock 2nd instance: "+instanceTwo.getName(), instanceTwo.tryLock(1000)); // 10x System.gc(); // force cleanup singletonInstance.unlock(); } - private Thread startLockUnlockOffThread(int i) { + private Thread startLockUnlockOffThread(final int i) { final Thread t = new Thread(new Runnable() { public void run() { - SingletonInstance myLock = SingletonInstance.createServerSocket(10, SINGLE_INSTANCE_LOCK_PORT); + final SingletonInstance myLock = SingletonInstance.createServerSocket(10, SINGLE_INSTANCE_LOCK_PORT); System.err.println(Thread.currentThread().getName()+" LOCK try .."); Assert.assertTrue(Thread.currentThread().getName()+" - Could not lock instance: "+myLock.getName(), myLock.tryLock(1000)); System.err.println(Thread.currentThread().getName()+" LOCK ON"); try { Thread.sleep(300); - } catch (InterruptedException e) { } + } catch (final InterruptedException e) { } myLock.unlock(); System.err.println(Thread.currentThread().getName()+" LOCK OFF"); } @@ -87,8 +87,8 @@ public class TestSingletonServerSocket00 { @Test public void testOffthreadLockUnlock() throws InterruptedException { Assert.assertTrue("Could not lock single instance: "+singletonInstance.getName(), singletonInstance.tryLock(SINGLE_INSTANCE_LOCK_TO)); - Thread t1 = startLockUnlockOffThread(1); - Thread t2 = startLockUnlockOffThread(2); + final Thread t1 = startLockUnlockOffThread(1); + final Thread t2 = startLockUnlockOffThread(2); Thread.sleep(300); System.gc(); // force cleanup singletonInstance.unlock(); @@ -97,8 +97,8 @@ public class TestSingletonServerSocket00 { } } - public static void main(String args[]) throws IOException, InterruptedException { - String tstname = TestSingletonServerSocket00.class.getName(); + public static void main(final String args[]) throws IOException, InterruptedException { + final String tstname = TestSingletonServerSocket00.class.getName(); org.junit.runner.JUnitCore.main(tstname); } } diff --git a/src/junit/com/jogamp/common/util/locks/TestSingletonServerSocket01.java b/src/junit/com/jogamp/common/util/locks/TestSingletonServerSocket01.java index 4bdc9bf..82ca89b 100644 --- a/src/junit/com/jogamp/common/util/locks/TestSingletonServerSocket01.java +++ b/src/junit/com/jogamp/common/util/locks/TestSingletonServerSocket01.java @@ -56,8 +56,8 @@ public class TestSingletonServerSocket01 { singletonInstance.unlock(); } - public static void main(String args[]) throws IOException, InterruptedException { - String tstname = TestSingletonServerSocket01.class.getName(); + public static void main(final String args[]) throws IOException, InterruptedException { + final String tstname = TestSingletonServerSocket01.class.getName(); org.junit.runner.JUnitCore.main(tstname); } } diff --git a/src/junit/com/jogamp/common/util/locks/TestSingletonServerSocket02.java b/src/junit/com/jogamp/common/util/locks/TestSingletonServerSocket02.java index cb862ce..50eebd6 100644 --- a/src/junit/com/jogamp/common/util/locks/TestSingletonServerSocket02.java +++ b/src/junit/com/jogamp/common/util/locks/TestSingletonServerSocket02.java @@ -68,8 +68,8 @@ public class TestSingletonServerSocket02 { Thread.sleep(3000); } - public static void main(String args[]) throws IOException, InterruptedException { - String tstname = TestSingletonServerSocket02.class.getName(); + public static void main(final String args[]) throws IOException, InterruptedException { + final String tstname = TestSingletonServerSocket02.class.getName(); org.junit.runner.JUnitCore.main(tstname); } } diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java b/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java index fd64ba9..b90eeb0 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java @@ -55,19 +55,19 @@ public class BaseClass extends JunitTracer { /** * Verifies the existence and creation of the generated class. */ - public void testClassExist(String name) throws Exception { - String ifName = "com.jogamp.gluegen.test.junit.generation.Binding"+name; - String implName = "com.jogamp.gluegen.test.junit.generation.impl.Binding"+name+"Impl"; + public void testClassExist(final String name) throws Exception { + final String ifName = "com.jogamp.gluegen.test.junit.generation.Binding"+name; + final String implName = "com.jogamp.gluegen.test.junit.generation.impl.Binding"+name+"Impl"; - Class<?> 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<Bindingtest1.ARRAY_SIZE; i++) { ib1.put(i, 1000); } - LongBuffer lb1 = newLongBuffer(Bindingtest1.ARRAY_SIZE, direct); + final LongBuffer lb1 = newLongBuffer(Bindingtest1.ARRAY_SIZE, direct); for(i=0; i<Bindingtest1.ARRAY_SIZE; i++) { lb1.put(i, 1000); } - LongBuffer lb2 = newLongBuffer(Bindingtest1.ARRAY_SIZE, direct); + final LongBuffer lb2 = newLongBuffer(Bindingtest1.ARRAY_SIZE, direct); for(i=0; i<Bindingtest1.ARRAY_SIZE; i++) { lb2.put(i, 10000); } - int[] iarray1 = new int[Bindingtest1.ARRAY_SIZE]; - int iarray1_offset = 0; + final int[] iarray1 = new int[Bindingtest1.ARRAY_SIZE]; + final int iarray1_offset = 0; for(i=0; i<Bindingtest1.ARRAY_SIZE; i++) { iarray1[i]= 1000; } - long[] larray1 = new long[Bindingtest1.ARRAY_SIZE]; - int larray1_offset = 0; + final long[] larray1 = new long[Bindingtest1.ARRAY_SIZE]; + final int larray1_offset = 0; for(i=0; i<Bindingtest1.ARRAY_SIZE; i++) { larray1[i]= 1000; } - long[] larray2 = new long[Bindingtest1.ARRAY_SIZE]; - int larray2_offset = 0; + final long[] larray2 = new long[Bindingtest1.ARRAY_SIZE]; + final int larray2_offset = 0; for(i=0; i<Bindingtest1.ARRAY_SIZE; i++) { larray2[i]= 10000; } @@ -332,7 +332,7 @@ public class BaseClass extends JunitTracer { // LongBuffer arrayTestFoo2 ( LongBuffer ) - don't write-back array-arg { lb2.rewind(); - LongBuffer lb3 = newLongBuffer(Bindingtest1.ARRAY_SIZE, direct); + final LongBuffer lb3 = newLongBuffer(Bindingtest1.ARRAY_SIZE, direct); lb3.put(lb2); lb3.rewind(); lb2.rewind(); @@ -341,7 +341,7 @@ public class BaseClass extends JunitTracer { Assert.assertTrue("Wrong result: "+lb3.capacity(), Bindingtest1.ARRAY_SIZE == lb3.capacity()); Assert.assertTrue("Wrong result: "+lb3.remaining(), Bindingtest1.ARRAY_SIZE == lb3.remaining()); - LongBuffer lbR = binding.arrayTestFoo2(lb3); + final LongBuffer lbR = binding.arrayTestFoo2(lb3); // System.out.println("lbR: "+lbR); Assert.assertNotNull(lbR); @@ -358,12 +358,12 @@ public class BaseClass extends JunitTracer { // LongBuffer arrayTestFoo2 ( long[], int ) - don't write-back array-arg { - long[] larray3 = new long[Bindingtest1.ARRAY_SIZE]; + final long[] larray3 = new long[Bindingtest1.ARRAY_SIZE]; for(i=0; i<Bindingtest1.ARRAY_SIZE; i++) { larray3[i]= larray2[i]; } - LongBuffer lbR = binding.arrayTestFoo2(larray3, 0); + final LongBuffer lbR = binding.arrayTestFoo2(larray3, 0); Assert.assertNotNull(lbR); Assert.assertTrue("Wrong result: "+lbR.capacity(), Bindingtest1.ARRAY_SIZE == lbR.capacity()); @@ -378,7 +378,7 @@ public class BaseClass extends JunitTracer { // void arrayTestFoo3 ( LongBuffer ) - write-back array-arg { lb2.rewind(); - LongBuffer lb3 = newLongBuffer(Bindingtest1.ARRAY_SIZE, direct); + final LongBuffer lb3 = newLongBuffer(Bindingtest1.ARRAY_SIZE, direct); lb3.put(lb2); lb3.rewind(); lb2.rewind(); @@ -399,7 +399,7 @@ public class BaseClass extends JunitTracer { // void arrayTestFoo3 ( long[], int ) - write-back array-arg { - long[] larray3 = new long[Bindingtest1.ARRAY_SIZE]; + final long[] larray3 = new long[Bindingtest1.ARRAY_SIZE]; for(i=0; i<Bindingtest1.ARRAY_SIZE; i++) { larray3[i]= larray2[i]; } @@ -416,7 +416,7 @@ public class BaseClass extends JunitTracer { // PointerBuffer arrayTestFoo3PtrPtr(PointerBuffer) { lb2.rewind(); - LongBuffer lb3 = newLongBuffer(Bindingtest1.ARRAY_SIZE*Bindingtest1.ARRAY_SIZE, direct); + final LongBuffer lb3 = newLongBuffer(Bindingtest1.ARRAY_SIZE*Bindingtest1.ARRAY_SIZE, direct); int j; for(j=0; j<Bindingtest1.ARRAY_SIZE; j++) { lb3.put(lb2); @@ -428,10 +428,10 @@ public class BaseClass extends JunitTracer { Assert.assertTrue("Wrong result: "+lb3.capacity(), Bindingtest1.ARRAY_SIZE*Bindingtest1.ARRAY_SIZE == lb3.capacity()); Assert.assertTrue("Wrong result: "+lb3.remaining(), Bindingtest1.ARRAY_SIZE*Bindingtest1.ARRAY_SIZE == lb3.remaining()); - PointerBuffer pb = binding.arrayTestFoo3ArrayToPtrPtr(lb3); + final PointerBuffer pb = binding.arrayTestFoo3ArrayToPtrPtr(lb3); validatePointerBuffer(pb, Bindingtest1.ARRAY_SIZE); - PointerBuffer pb2 = binding.arrayTestFoo3PtrPtr(pb); + final PointerBuffer pb2 = binding.arrayTestFoo3PtrPtr(pb); validatePointerBuffer(pb2, Bindingtest1.ARRAY_SIZE); for(j=0; j<Bindingtest1.ARRAY_SIZE*Bindingtest1.ARRAY_SIZE; j++) { Assert.assertEquals("Wrong result: s:"+lb2.get(j%Bindingtest1.ARRAY_SIZE)+" d: "+lb3.get(j), @@ -445,11 +445,11 @@ public class BaseClass extends JunitTracer { // " " // PointerBuffer arrayTestFoo3PtrPtr(PointerBuffer) { - PointerBuffer pb = newPointerBuffer(Bindingtest1.ARRAY_SIZE, direct); + final PointerBuffer pb = newPointerBuffer(Bindingtest1.ARRAY_SIZE, direct); int j; for(j=0; j<Bindingtest1.ARRAY_SIZE; j++) { // the referenced buffer must be direct, non direct is not supported - LongBuffer lb3 = Buffers.newDirectLongBuffer(Bindingtest1.ARRAY_SIZE); + final LongBuffer lb3 = Buffers.newDirectLongBuffer(Bindingtest1.ARRAY_SIZE); lb3.put(lb2); lb2.rewind(); lb3.rewind(); @@ -463,10 +463,10 @@ public class BaseClass extends JunitTracer { Assert.assertNotNull(pb.getReferencedBuffer(0)); Assert.assertTrue("Wrong result: "+pb.getReferencedBuffer(0)+" != "+lb2, pb.getReferencedBuffer(0).equals(lb2)); - PointerBuffer pb2 = binding.arrayTestFoo3PtrPtr(pb); // pb2 is shallow + final PointerBuffer pb2 = binding.arrayTestFoo3PtrPtr(pb); // pb2 is shallow validatePointerBuffer(pb2, Bindingtest1.ARRAY_SIZE); for(j=0; j<Bindingtest1.ARRAY_SIZE; j++) { - LongBuffer i64b = (LongBuffer) pb.getReferencedBuffer(j); + final LongBuffer i64b = (LongBuffer) pb.getReferencedBuffer(j); for(i=0; i<Bindingtest1.ARRAY_SIZE; i++) { Assert.assertEquals("Wrong result: ["+j+"]["+i+"] s:"+lb2.get(i)+" d: "+i64b.get(i), 1+lb2.get(i), i64b.get(i)); @@ -480,11 +480,11 @@ public class BaseClass extends JunitTracer { // " " // PointerBuffer arrayTestFoo3PtrPtr(PointerBuffer) { - PointerBuffer pbS = newPointerBuffer(Bindingtest1.ARRAY_SIZE, direct); + final PointerBuffer pbS = newPointerBuffer(Bindingtest1.ARRAY_SIZE, direct); int j; for(j=0; j<Bindingtest1.ARRAY_SIZE; j++) { // the referenced buffer must be direct, non direct is not supported - LongBuffer lb3 = Buffers.newDirectLongBuffer(Bindingtest1.ARRAY_SIZE); + final LongBuffer lb3 = Buffers.newDirectLongBuffer(Bindingtest1.ARRAY_SIZE); lb3.put(lb2); lb2.rewind(); lb3.rewind(); @@ -496,13 +496,13 @@ public class BaseClass extends JunitTracer { Assert.assertNotNull(pbS.getReferencedBuffer(0)); Assert.assertTrue("Wrong result: "+pbS.getReferencedBuffer(0)+" != "+lb2, pbS.getReferencedBuffer(0).equals(lb2)); - PointerBuffer pbD = newPointerBuffer(Bindingtest1.ARRAY_SIZE, direct); + final PointerBuffer pbD = newPointerBuffer(Bindingtest1.ARRAY_SIZE, direct); // System.err.println("\n***pbS "+pbS); System.err.println("***pbD "+pbD); binding.arrayTestFoo3CopyPtrPtrA(pbD, pbS); // pbD is shallow validatePointerBuffer(pbD, Bindingtest1.ARRAY_SIZE); - PointerBuffer pbD2 = binding.arrayTestFoo3PtrPtr(pbD); // pbD2 is shallow + final PointerBuffer pbD2 = binding.arrayTestFoo3PtrPtr(pbD); // pbD2 is shallow Assert.assertEquals(0, binding.arrayTestFoo3PtrPtrValidation(pbD, 10000)); validatePointerBuffer(pbD2, Bindingtest1.ARRAY_SIZE); Assert.assertEquals(0, binding.arrayTestFoo3PtrPtrValidation(pbD2, 10000)); @@ -521,7 +521,7 @@ public class BaseClass extends JunitTracer { Exception e = null; try { binding.bufferTestNioDirectOnly(lb); - } catch (RuntimeException re) { + } catch (final RuntimeException re) { e = re; } Assert.assertNotNull(e); @@ -551,7 +551,7 @@ public class BaseClass extends JunitTracer { i = binding.strToInt("42"); Assert.assertTrue("Wrong result: "+i, 42==i); - String str = binding.intToStr(42); + final String str = binding.intToStr(42); Assert.assertTrue("Wrong result: "+str, str.equals("42")); i = binding.stringArrayRead(new String[] { "1234", "5678", "9a" }, 3); @@ -563,10 +563,10 @@ public class BaseClass extends JunitTracer { { // one 0xff in each byte array // the referenced buffer must be direct, non direct is not supported - ByteBuffer bbB = Buffers.newDirectByteBuffer(new byte [] {(byte)0xaa, (byte)0xff, (byte)0xba, (byte)0xbe}); + final ByteBuffer bbB = Buffers.newDirectByteBuffer(new byte [] {(byte)0xaa, (byte)0xff, (byte)0xba, (byte)0xbe}); bbB.rewind(); - PointerBuffer pbB = newPointerBuffer(Bindingtest1.ARRAY_SIZE, direct); - PointerBuffer pbL = newPointerBuffer(Bindingtest1.ARRAY_SIZE, direct); + final PointerBuffer pbB = newPointerBuffer(Bindingtest1.ARRAY_SIZE, direct); + final PointerBuffer pbL = newPointerBuffer(Bindingtest1.ARRAY_SIZE, direct); for(int j=0; j<Bindingtest1.ARRAY_SIZE; j++) { pbB.referenceBuffer(bbB); pbL.put(bbB.capacity()); @@ -577,19 +577,19 @@ public class BaseClass extends JunitTracer { Assert.assertNotNull(pbB.getReferencedBuffer(0)); Assert.assertTrue("Wrong result: "+pbB.getReferencedBuffer(0)+" != "+bbB, pbB.getReferencedBuffer(0).equals(bbB)); validatePointerBuffer(pbL, Bindingtest1.ARRAY_SIZE); - long temp = pbL.get(); + final long temp = pbL.get(); Assert.assertTrue("Wrong result: "+temp, temp==bbB.capacity()); pbL.rewind(); i = binding.binaryArrayRead(pbL, pbB, Bindingtest1.ARRAY_SIZE); Assert.assertTrue("Wrong result: "+i, Bindingtest1.ARRAY_SIZE==i); } - IntBuffer ib = newIntBuffer(3, direct); + final IntBuffer ib = newIntBuffer(3, direct); ib.put(0, 1); ib.put(1, 2); ib.put(2, 3); - int[] iarray = new int[] { 1, 2, 3 }; + final int[] iarray = new int[] { 1, 2, 3 }; i = binding.intArrayRead(ib, 3); Assert.assertTrue("Wrong result: "+i, 6==i); @@ -604,9 +604,9 @@ public class BaseClass extends JunitTracer { Assert.assertTrue("Wrong result: "+i, 0==i); { - long cfg_base = 0xAABBCCDD11223344L; + final long cfg_base = 0xAABBCCDD11223344L; - PointerBuffer pb = newPointerBuffer(Bindingtest1.ARRAY_SIZE, direct); + final PointerBuffer pb = newPointerBuffer(Bindingtest1.ARRAY_SIZE, direct); for(i=0; i<Bindingtest1.ARRAY_SIZE; i++) { long cfg_native; if(Platform.is32Bit()) { @@ -614,15 +614,15 @@ public class BaseClass extends JunitTracer { } else { cfg_native = (cfg_base+i); } - long cfg = binding.typeTestAnonSingle(cfg_base + i); + final long cfg = binding.typeTestAnonSingle(cfg_base + i); Assert.assertTrue("Wrong result: 0x"+Long.toHexString(cfg_native)+"+1 != 0x"+Long.toHexString(cfg), (cfg_native+1)==cfg); pb.put(i, cfg_base+i); - long t = pb.get(i); + final long t = pb.get(i); Assert.assertTrue("Wrong result: 0x"+Long.toHexString(cfg_native)+" != 0x"+Long.toHexString(t), cfg_native==t); } pb.rewind(); - PointerBuffer pb2 = binding.typeTestAnonPointer(pb); + final PointerBuffer pb2 = binding.typeTestAnonPointer(pb); Assert.assertTrue("Wrong result: "+pb2.capacity(), Bindingtest1.ARRAY_SIZE == pb2.capacity()); Assert.assertTrue("Wrong result: "+pb2.remaining(), Bindingtest1.ARRAY_SIZE == pb2.remaining()); for(i=0; i<Bindingtest1.ARRAY_SIZE; i++) { @@ -631,7 +631,7 @@ public class BaseClass extends JunitTracer { } } - public void chapter04TestPointerBuffer(Bindingtest1 binding) throws Exception { + public void chapter04TestPointerBuffer(final Bindingtest1 binding) throws Exception { final long DEADBEEF = 0x00000000DEADBEEFL; { @@ -738,15 +738,15 @@ public class BaseClass extends JunitTracer { /** * This covers indirect primitive arrays and indirect NIO buffers. */ - public void chapter05TestSomeFunctionsAllIndirect(Bindingtest1 binding) throws Exception { + public void chapter05TestSomeFunctionsAllIndirect(final Bindingtest1 binding) throws Exception { int i; - IntBuffer ib = IntBuffer.allocate(3); + final IntBuffer ib = IntBuffer.allocate(3); ib.put(0, 1); ib.put(1, 2); ib.put(2, 3); - int[] iarray = new int[] { 1, 2, 3 }; + final int[] iarray = new int[] { 1, 2, 3 }; i = binding.intArrayRead(ib, 3); Assert.assertTrue("Wrong result: "+i, 6==i); @@ -764,7 +764,7 @@ public class BaseClass extends JunitTracer { Assert.assertTrue(Arrays.equals(src, dst)); } { - IntBuffer dstB = IntBuffer.allocate(src.length); + final IntBuffer dstB = IntBuffer.allocate(src.length); i = binding.intArrayCopy(dstB, srcB, src.length); System.err.println("ArrayCopy.02: "+Arrays.toString(dstB.array())+", "+dstB); Assert.assertTrue("Wrong result: "+i, src.length==i); @@ -789,7 +789,7 @@ public class BaseClass extends JunitTracer { Assert.assertTrue(Arrays.equals(src2, dst)); } { - IntBuffer dstB = IntBuffer.allocate(src2.length); + final IntBuffer dstB = IntBuffer.allocate(src2.length); { dstB.position(3); srcB.position(3); @@ -822,10 +822,10 @@ public class BaseClass extends JunitTracer { } } - public void chapter09TestCompoundAlignment(Bindingtest1 binding) throws Exception { + public void chapter09TestCompoundAlignment(final Bindingtest1 binding) throws Exception { - MachineDescription.StaticConfig smd = MachineDescriptionRuntime.getStatic(); - MachineDescription md = MachineDescriptionRuntime.getRuntime(); + final MachineDescription.StaticConfig smd = MachineDescriptionRuntime.getStatic(); + final MachineDescription md = MachineDescriptionRuntime.getRuntime(); System.err.println("static md: "+smd); System.err.println("runtime md: "+md); @@ -833,10 +833,10 @@ public class BaseClass extends JunitTracer { // Test compound alignment read { - TK_ComplicatedSuperSet cs = binding.createComplicatedSuperSet(); + final TK_ComplicatedSuperSet cs = binding.createComplicatedSuperSet(); Assert.assertEquals((byte)0xA0, cs.getBits1()); - TK_ComplicatedSubSet sub1 = cs.getSub1(); + final TK_ComplicatedSubSet sub1 = cs.getSub1(); Assert.assertEquals((byte)0xA1, sub1.getBits1()); Assert.assertEquals(0x12345678, sub1.getId()); Assert.assertEquals((byte)0xA2, sub1.getBits2()); @@ -851,7 +851,7 @@ public class BaseClass extends JunitTracer { Assert.assertEquals((byte)0xB0, cs.getBits2()); - TK_ComplicatedSubSet sub2 = cs.getSub2(); + final TK_ComplicatedSubSet sub2 = cs.getSub2(); Assert.assertEquals((byte)0xB1, sub2.getBits1()); Assert.assertEquals(0x12345678, sub2.getId()); Assert.assertEquals((byte)0xB2, sub2.getBits2()); @@ -873,10 +873,10 @@ public class BaseClass extends JunitTracer { // Test compound alignment write { - TK_ComplicatedSuperSet cs = TK_ComplicatedSuperSet.create(); + final TK_ComplicatedSuperSet cs = TK_ComplicatedSuperSet.create(); cs.setBits1((byte)0xA0); - TK_ComplicatedSubSet sub1 = cs.getSub1(); + final TK_ComplicatedSubSet sub1 = cs.getSub1(); sub1.setBits1((byte)0xA1); sub1.setId(0x12345678); sub1.setBits2((byte)0xA2); @@ -891,7 +891,7 @@ public class BaseClass extends JunitTracer { cs.setBits2((byte)0xB0); - TK_ComplicatedSubSet sub2 = cs.getSub2(); + final TK_ComplicatedSubSet sub2 = cs.getSub2(); sub2.setBits1((byte)0xB1); sub2.setId(0x12345678); sub2.setBits2((byte)0xB2); @@ -936,18 +936,18 @@ public class BaseClass extends JunitTracer { } /** Test compound access call-by-reference */ - public void chapter10TestCompoundCallByReference(Bindingtest1 binding) throws Exception { + public void chapter10TestCompoundCallByReference(final Bindingtest1 binding) throws Exception { final TK_Surface surface = binding.createSurface(); final long surfaceContext = surface.getCtx(); assertAPTR(0x123456789abcdef0L, surfaceContext); - TK_ContextWrapper ctxWrapper = surface.getCtxWrapper(); + final TK_ContextWrapper ctxWrapper = surface.getCtxWrapper(); final long wrapperContext = ctxWrapper.getCtx(); assertAPTR(0xA23456781abcdef0L, wrapperContext); - TK_Engine engine = surface.getEngine(); + final TK_Engine engine = surface.getEngine(); final long engineContext = engine.getCtx(); assertAPTR(0xB23456782abcdef0L, engineContext); Assert.assertEquals(0x0111, engine.render(0x0100, 0x0010, 0x0001)); @@ -970,7 +970,7 @@ public class BaseClass extends JunitTracer { assertAPTR(engineContext, engine.getCtx()); Assert.assertEquals(0x0111, engine.render(0x0100, 0x0010, 0x0001)); - TK_Dimension dimension = surface.getBounds(); + final TK_Dimension dimension = surface.getBounds(); dumpDim("ch10: ref-dim ", dimension); Assert.assertEquals(0x11111111, dimension.getX()); Assert.assertEquals(0x22222222, dimension.getY()); @@ -979,16 +979,16 @@ public class BaseClass extends JunitTracer { Assert.assertEquals(2, surface.getClipSize()); - TK_Dimension[] allclips = surface.getClips(0, new TK_Dimension[surface.getClipSize()]); + final TK_Dimension[] allclips = surface.getClips(0, new TK_Dimension[surface.getClipSize()]); for(int i=0; i<surface.getClipSize(); i++) { - TK_Dimension clip0 = surface.getClip(i); + final TK_Dimension clip0 = surface.getClip(i); Assert.assertEquals(0x44444444 * (i+1) + 0x11111111, clip0.getX()); Assert.assertEquals(0x44444444 * (i+1) + 0x22222222, clip0.getY()); Assert.assertEquals(0x44444444 * (i+1) + 0x33333333, clip0.getWidth()); Assert.assertEquals(0x44444444 * (i+1) + 0x44444444, clip0.getHeight()); - TK_Dimension[] clip1 = new TK_Dimension[1]; + final TK_Dimension[] clip1 = new TK_Dimension[1]; surface.getClips(i, clip1); Assert.assertEquals(0x44444444 * (i+1) + 0x11111111, clip1[0].getX()); Assert.assertEquals(0x44444444 * (i+1) + 0x22222222, clip1[0].getY()); @@ -1005,7 +1005,7 @@ public class BaseClass extends JunitTracer { } /** Test compound access call-by-value */ - public void chapter11TestCompoundCallByValue(Bindingtest1 binding) throws Exception { + public void chapter11TestCompoundCallByValue(final Bindingtest1 binding) throws Exception { int sub = 0; { final TK_Surface surface = binding.createSurface(); @@ -1118,7 +1118,7 @@ public class BaseClass extends JunitTracer { public static final float EPSILON = 1.1920929E-7f; // Float.MIN_VALUE == 1.4e-45f ; double EPSILON 2.220446049250313E-16d /** Test array and pointer bindings of structs */ - public void chapter12TestStructArrayModelConst(Bindingtest1 binding) throws Exception { + public void chapter12TestStructArrayModelConst(final Bindingtest1 binding) throws Exception { final TK_ModelConst model = binding.createModelConst(); Assert.assertEquals(3, model.getIntxxPointerCustomLenVal()); @@ -1283,7 +1283,7 @@ public class BaseClass extends JunitTracer { binding.destroyModelConst(model); } - private void dumpStringChars(String prefix, String s) { + private void dumpStringChars(final String prefix, final String s) { final int len = s.length(); for(int i=0; i<len; i++) { final char c = s.charAt(i); @@ -1291,7 +1291,7 @@ public class BaseClass extends JunitTracer { } } - public void chapter13TestStructArrayModelMutable(Bindingtest1 binding) throws Exception { + public void chapter13TestStructArrayModelMutable(final Bindingtest1 binding) throws Exception { final TK_ModelMutable model = binding.createModelMutable(); Assert.assertEquals(3, model.getIntxxPointerCustomLenVal()); diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/BindingJNILibLoader.java b/src/junit/com/jogamp/gluegen/test/junit/generation/BindingJNILibLoader.java index 23daa6d..47e392a 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/BindingJNILibLoader.java +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/BindingJNILibLoader.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. @@ -32,7 +32,7 @@ import com.jogamp.common.jvm.JNILibLoaderBase; import java.security.*; public class BindingJNILibLoader extends JNILibLoaderBase { - + public static void loadBindingtest1p1() { AccessController.doPrivileged(new PrivilegedAction<Object>() { 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.<String>emptyList(), false, false); - ByteArrayOutputStream output = new ByteArrayOutputStream(); + final PCPP pp = new PCPP(Collections.<String>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<tsz; i++) { @@ -138,9 +138,9 @@ public class Applet01 extends Applet { tout.write(b); } tout.close(); - } catch (IOException ioe) { + } catch (final IOException ioe) { ioe.printStackTrace(); - } catch (AccessControlException ace) { + } catch (final AccessControlException ace) { // GOOD! sec01 = ace; System.err.println("Expected:"+ace.getMessage()); @@ -153,13 +153,13 @@ public class Applet01 extends Applet { if( null == sec01 ) { throw new Error("SecurityException not thrown on writing to temp"); } - } + } } - - private void testOpenLibrary(boolean global) { + + private void testOpenLibrary(final boolean global) { final ClassLoader cl = getClass().getClassLoader(); System.err.println("CL "+cl); - + String libBaseName = null; final Class<?> 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 |