diff options
Diffstat (limited to 'src/junit/com/jogamp/common/util')
36 files changed, 836 insertions, 840 deletions
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 a4518f0..934fb5e 100644 --- a/src/junit/com/jogamp/common/util/TestTempJarCache.java +++ b/src/junit/com/jogamp/common/util/TestTempJarCache.java @@ -59,15 +59,15 @@ public class TestTempJarCache extends JunitTracer { static TempFileCache fileCache; static class TestClassLoader extends URLClassLoader { - public TestClassLoader(URL[] urls) { + public TestClassLoader(final URL[] urls) { super(urls); } - public TestClassLoader(URL[] urls, ClassLoader parent) { + public TestClassLoader(final URL[] urls, final ClassLoader parent) { super(urls, parent); } } - static void assertTempFileCachesIndividualInstances(boolean shallBeSame, TempFileCache fileCache2, TempFileCache fileCache3) { + static void assertTempFileCachesIndividualInstances(final boolean shallBeSame, final TempFileCache fileCache2, final TempFileCache fileCache3) { Assert.assertTrue(fileCache2.getTempDir().exists()); Assert.assertTrue(fileCache2.getTempDir().isDirectory()); Assert.assertTrue(fileCache3.getTempDir().exists()); @@ -83,30 +83,30 @@ public class TestTempJarCache extends JunitTracer { } // also verify with diff classloader/reflection method, // to proof that methodology is valid! - ClassLoader cl = fileCache2.getClass().getClassLoader(); + final ClassLoader cl = fileCache2.getClass().getClassLoader(); assertTempFileCachesIndividualInstances(shallBeSame, fileCache2, cl, fileCache3, cl); } - static void assertTempFileCachesIndividualInstances(boolean shallBeSame, Object fileCache2, ClassLoader cl2, Object fileCache3, ClassLoader cl3) { - Class<?> fileCacheClazz2 = ReflectionUtil.getClass(TempFileCache.class.getName(), false, cl2); - Class<?> fileCacheClazz3 = ReflectionUtil.getClass(TempFileCache.class.getName(), false, cl3); + static void assertTempFileCachesIndividualInstances(final boolean shallBeSame, final Object fileCache2, final ClassLoader cl2, final Object fileCache3, final ClassLoader cl3) { + final Class<?> fileCacheClazz2 = ReflectionUtil.getClass(TempFileCache.class.getName(), false, cl2); + final Class<?> fileCacheClazz3 = ReflectionUtil.getClass(TempFileCache.class.getName(), false, cl3); - Method fc2GetBaseDir = ReflectionUtil.getMethod(fileCacheClazz2 , "getBaseDir"); - Method fc3GetBaseDir = ReflectionUtil.getMethod(fileCacheClazz3 , "getBaseDir"); - Object baseDir2 = ReflectionUtil.callMethod(fileCache2, fc2GetBaseDir); - Object baseDir3 = ReflectionUtil.callMethod(fileCache3, fc3GetBaseDir); + final Method fc2GetBaseDir = ReflectionUtil.getMethod(fileCacheClazz2 , "getBaseDir"); + final Method fc3GetBaseDir = ReflectionUtil.getMethod(fileCacheClazz3 , "getBaseDir"); + final Object baseDir2 = ReflectionUtil.callMethod(fileCache2, fc2GetBaseDir); + final Object baseDir3 = ReflectionUtil.callMethod(fileCache3, fc3GetBaseDir); Assert.assertEquals(baseDir2, baseDir3); - Method fc2GetRootDir = ReflectionUtil.getMethod(fileCacheClazz2 , "getRootDir"); - Method fc3GetRootDir = ReflectionUtil.getMethod(fileCacheClazz3 , "getRootDir"); - Object rootDir2 = ReflectionUtil.callMethod(fileCache2, fc2GetRootDir); - Object rootDir3 = ReflectionUtil.callMethod(fileCache3, fc3GetRootDir); + final Method fc2GetRootDir = ReflectionUtil.getMethod(fileCacheClazz2 , "getRootDir"); + final Method fc3GetRootDir = ReflectionUtil.getMethod(fileCacheClazz3 , "getRootDir"); + final Object rootDir2 = ReflectionUtil.callMethod(fileCache2, fc2GetRootDir); + final Object rootDir3 = ReflectionUtil.callMethod(fileCache3, fc3GetRootDir); Assert.assertEquals(rootDir2, rootDir3); - Method fc2GetTempDir = ReflectionUtil.getMethod(fileCacheClazz2 , "getTempDir"); - Method fc3GetTempDir = ReflectionUtil.getMethod(fileCacheClazz3 , "getTempDir"); - Object tempDir2 = ReflectionUtil.callMethod(fileCache2, fc2GetTempDir); - Object tempDir3 = ReflectionUtil.callMethod(fileCache3, fc3GetTempDir); + final Method fc2GetTempDir = ReflectionUtil.getMethod(fileCacheClazz2 , "getTempDir"); + final Method fc3GetTempDir = ReflectionUtil.getMethod(fileCacheClazz3 , "getTempDir"); + final Object tempDir2 = ReflectionUtil.callMethod(fileCache2, fc2GetTempDir); + final Object tempDir3 = ReflectionUtil.callMethod(fileCache3, fc3GetTempDir); if(shallBeSame) { Assert.assertTrue("file caches are not equal", tempDir2.equals(tempDir3)); @@ -135,8 +135,8 @@ public class TestTempJarCache extends JunitTracer { @Test public void testTempFileCache02Instances() throws IOException { - TempFileCache fileCache2 = new TempFileCache(); - TempFileCache fileCache3 = new TempFileCache(); + final TempFileCache fileCache2 = new TempFileCache(); + final TempFileCache fileCache3 = new TempFileCache(); assertTempFileCachesIndividualInstances(false, fileCache2, fileCache3); } @@ -144,7 +144,7 @@ public class TestTempJarCache extends JunitTracer { @Test public void testJarUtil01a() throws IOException, IllegalArgumentException, URISyntaxException { if(AndroidVersion.isAvailable) { System.err.println("n/a on Android"); return; } - JarFile jarFile = JarUtil.getJarFile(GlueGenVersion.class.getName(), this.getClass().getClassLoader()); + final JarFile jarFile = JarUtil.getJarFile(GlueGenVersion.class.getName(), this.getClass().getClassLoader()); Assert.assertNotNull(jarFile); JarUtil.extract(fileCache.getTempDir(), null, jarFile, null, false, true, true); File f = new File(fileCache.getTempDir(), "META-INF/MANIFEST.MF"); @@ -204,13 +204,13 @@ public class TestTempJarCache extends JunitTracer { URI jarUriRoot = JarUtil.getJarSubURI(TempJarCache.class.getName(), cl); jarUriRoot = IOUtil.getURIDirname(jarUriRoot); - URI nativeJarURI = JarUtil.getJarFileURI(jarUriRoot, nativeJarName); + final URI nativeJarURI = JarUtil.getJarFileURI(jarUriRoot, nativeJarName); TempJarCache.addNativeLibs(TempJarCache.class, nativeJarURI, null /* nativeLibraryPath */); - String libFullPath = TempJarCache.findLibrary(libBaseName); + final String libFullPath = TempJarCache.findLibrary(libBaseName); Assert.assertNotNull(libFullPath); Assert.assertEquals(libBaseName, NativeLibrary.isValidNativeLibraryName(libFullPath, true)); - File f = new File(libFullPath); + final File f = new File(libFullPath); Assert.assertTrue(f.exists()); } @@ -222,10 +222,10 @@ public class TestTempJarCache extends JunitTracer { JNILibLoaderBase.addNativeJarLibs(TempJarCache.class, libBaseName); Assert.assertTrue(JNILibLoaderBase.isLoaded(libBaseName)); - String libFullPath = TempJarCache.findLibrary(libBaseName); + final String libFullPath = TempJarCache.findLibrary(libBaseName); Assert.assertNotNull(libFullPath); Assert.assertEquals(libBaseName, NativeLibrary.isValidNativeLibraryName(libFullPath, true)); - File f = new File(libFullPath); + final File f = new File(libFullPath); Assert.assertTrue(f.exists()); } @@ -233,19 +233,19 @@ public class TestTempJarCache extends JunitTracer { public void testTempJarCache04aSameClassLoader() throws IOException { assertTempFileCachesIndividualInstances(true, TempJarCache.getTempFileCache(), TempJarCache.getTempFileCache()); - ClassLoader cl = getClass().getClassLoader(); - TempFileCache fileCache2 = (TempFileCache) ReflectionUtil.callStaticMethod(TempJarCache.class.getName(), "getTempFileCache", null, null, cl); - TempFileCache fileCache3 = (TempFileCache) ReflectionUtil.callStaticMethod(TempJarCache.class.getName(), "getTempFileCache", null, null, cl); + final ClassLoader cl = getClass().getClassLoader(); + final TempFileCache fileCache2 = (TempFileCache) ReflectionUtil.callStaticMethod(TempJarCache.class.getName(), "getTempFileCache", null, null, cl); + final TempFileCache fileCache3 = (TempFileCache) ReflectionUtil.callStaticMethod(TempJarCache.class.getName(), "getTempFileCache", null, null, cl); assertTempFileCachesIndividualInstances(true, fileCache2, fileCache3); } @Test public void testTempJarCache04bDiffClassLoader() throws IOException, IllegalArgumentException, URISyntaxException { if(AndroidVersion.isAvailable) { System.err.println("n/a on Android"); return; } - URL[] urls = new URL[] { JarUtil.getJarFileURI(TempJarCache.class.getName(), getClass().getClassLoader()).toURL() }; + final URL[] urls = new URL[] { JarUtil.getJarFileURI(TempJarCache.class.getName(), getClass().getClassLoader()).toURL() }; System.err.println("url: "+urls[0]); - ClassLoader cl2 = new TestClassLoader(urls, null); - ClassLoader cl3 = new TestClassLoader(urls, null); + final ClassLoader cl2 = new TestClassLoader(urls, null); + final ClassLoader cl3 = new TestClassLoader(urls, null); Assert.assertFalse(( (Boolean) ReflectionUtil.callStaticMethod(TempJarCache.class.getName(), "isInitialized", null, null, cl2) ).booleanValue()); @@ -260,14 +260,14 @@ public class TestTempJarCache extends JunitTracer { Assert.assertTrue(( (Boolean) ReflectionUtil.callStaticMethod(TempJarCache.class.getName(), "isInitialized", null, null, cl3) ).booleanValue()); - Object fileCache2 = ReflectionUtil.callStaticMethod(TempJarCache.class.getName(), "getTempFileCache", null, null, cl2); - Object fileCache3 = ReflectionUtil.callStaticMethod(TempJarCache.class.getName(), "getTempFileCache", null, null, cl3); + final Object fileCache2 = ReflectionUtil.callStaticMethod(TempJarCache.class.getName(), "getTempFileCache", null, null, cl2); + final Object fileCache3 = ReflectionUtil.callStaticMethod(TempJarCache.class.getName(), "getTempFileCache", null, null, cl3); assertTempFileCachesIndividualInstances(false, fileCache2, cl2, fileCache3, cl3); } - public static void main(String args[]) throws IOException { - String tstname = TestTempJarCache.class.getName(); + public static void main(final String args[]) throws IOException { + final String tstname = TestTempJarCache.class.getName(); org.junit.runner.JUnitCore.main(tstname); } diff --git a/src/junit/com/jogamp/common/util/TestValueConversion.java b/src/junit/com/jogamp/common/util/TestValueConversion.java index 13cd0cd..6c86803 100644 --- a/src/junit/com/jogamp/common/util/TestValueConversion.java +++ b/src/junit/com/jogamp/common/util/TestValueConversion.java @@ -99,15 +99,15 @@ public class TestValueConversion { @Test public void testConversion() { - byte sb0 = 127; - byte sb1 = -128; + final byte sb0 = 127; + final byte sb1 = -128; - float sf0 = byte_to_float(sb0, true); - float sf1 = byte_to_float(sb1, true); - short ss0 = byte_to_short(sb0, true, true); - short ss1 = byte_to_short(sb1, true, true); - int si0 = byte_to_int(sb0, true, true); - int si1 = byte_to_int(sb1, true, true); + final float sf0 = byte_to_float(sb0, true); + final float sf1 = byte_to_float(sb1, true); + final short ss0 = byte_to_short(sb0, true, true); + final short ss1 = byte_to_short(sb1, true, true); + final int si0 = byte_to_int(sb0, true, true); + final int si1 = byte_to_int(sb1, true, true); Assert.assertEquals(1.0f, sf0, 0.0); Assert.assertEquals(-1.0f, sf1, 0.0); @@ -121,10 +121,10 @@ public class TestValueConversion { Assert.assertEquals(sb0, int_to_byte(si0, true, true)); Assert.assertEquals(sb1, int_to_byte(si1, true, true)); - byte ub0 = (byte) 0xff; - float uf0 = byte_to_float(ub0, false); - short us0 = byte_to_short(ub0, false, false); - int ui0 = byte_to_int(ub0, false, false); + final byte ub0 = (byte) 0xff; + final float uf0 = byte_to_float(ub0, false); + final short us0 = byte_to_short(ub0, false, false); + final int ui0 = byte_to_int(ub0, false, false); Assert.assertEquals(1.0f, uf0, 0.0); Assert.assertEquals((short)0xffff, us0); @@ -134,7 +134,7 @@ public class TestValueConversion { Assert.assertEquals(us0, int_to_short(ui0, false, false)); } - public static void main(String args[]) { + public static void main(final String args[]) { org.junit.runner.JUnitCore.main(TestValueConversion.class.getName()); } diff --git a/src/junit/com/jogamp/common/util/TestVersionInfo.java b/src/junit/com/jogamp/common/util/TestVersionInfo.java index 46bd1d2..7466d0d 100644 --- a/src/junit/com/jogamp/common/util/TestVersionInfo.java +++ b/src/junit/com/jogamp/common/util/TestVersionInfo.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.common.util; import java.io.IOException; @@ -50,8 +50,8 @@ public class TestVersionInfo extends JunitTracer { } - public static void main(String args[]) throws IOException { - String tstname = TestVersionInfo.class.getName(); + public static void main(final String args[]) throws IOException { + final String tstname = TestVersionInfo.class.getName(); org.junit.runner.JUnitCore.main(tstname); } diff --git a/src/junit/com/jogamp/common/util/TestVersionNumber.java b/src/junit/com/jogamp/common/util/TestVersionNumber.java index b3d1cfd..2b4f6d2 100644 --- a/src/junit/com/jogamp/common/util/TestVersionNumber.java +++ b/src/junit/com/jogamp/common/util/TestVersionNumber.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.common.util; import java.io.IOException; @@ -50,21 +50,21 @@ public class TestVersionNumber extends JunitTracer { Assert.assertTrue(vn0.hasMajor()); Assert.assertTrue(vn0.hasMinor()); Assert.assertTrue(vn0.hasSub()); - + VersionNumber vn; - + vn = new VersionNumber(vs00); Assert.assertTrue(vn.hasMajor()); Assert.assertTrue(vn.hasMinor()); Assert.assertTrue(vn.hasSub()); Assert.assertEquals(vn0, vn); - + vn = new VersionNumber(vs01); Assert.assertTrue(vn.hasMajor()); Assert.assertTrue(vn.hasMinor()); Assert.assertTrue(vn.hasSub()); Assert.assertEquals(vn0, vn); - + vn = new VersionNumber(vs02); Assert.assertTrue(vn.hasMajor()); Assert.assertTrue(vn.hasMinor()); @@ -74,7 +74,7 @@ public class TestVersionNumber extends JunitTracer { @Test public void test01b() { final String delim = ","; - + final String vs00 = "1,0,16"; final String vs01 = "OpenGL ES GLSL ES 1,0,16"; final String vs02 = "1,0,16 OpenGL ES GLSL ES"; @@ -82,26 +82,26 @@ public class TestVersionNumber extends JunitTracer { Assert.assertTrue(vn0.hasMajor()); Assert.assertTrue(vn0.hasMinor()); Assert.assertTrue(vn0.hasSub()); - + VersionNumber vn; - + vn = new VersionNumber(vs00, delim); Assert.assertTrue(vn.hasMajor()); Assert.assertTrue(vn.hasMinor()); Assert.assertTrue(vn.hasSub()); Assert.assertEquals(vn0, vn); - + vn = new VersionNumber(vs01, delim); Assert.assertTrue(vn.hasMajor()); Assert.assertTrue(vn.hasMinor()); Assert.assertTrue(vn.hasSub()); Assert.assertEquals(vn0, vn); - + vn = new VersionNumber(vs02, delim); Assert.assertTrue(vn.hasMajor()); Assert.assertTrue(vn.hasMinor()); Assert.assertTrue(vn.hasSub()); - Assert.assertEquals(vn0, vn); + Assert.assertEquals(vn0, vn); } @Test @@ -113,32 +113,32 @@ public class TestVersionNumber extends JunitTracer { Assert.assertTrue(vn0.hasMajor()); Assert.assertTrue(vn0.hasMinor()); Assert.assertTrue(vn0.hasSub()); - + VersionNumber vn; - + vn = new VersionNumber(vs00); Assert.assertTrue(vn.hasMajor()); Assert.assertTrue(vn.hasMinor()); Assert.assertTrue(!vn.hasSub()); Assert.assertEquals(vn0, vn); - + vn = new VersionNumber(vs01); Assert.assertTrue(vn.hasMajor()); Assert.assertTrue(vn.hasMinor()); Assert.assertTrue(!vn.hasSub()); Assert.assertEquals(vn0, vn); - + vn = new VersionNumber(vs02); Assert.assertTrue(vn.hasMajor()); Assert.assertTrue(vn.hasMinor()); Assert.assertTrue(!vn.hasSub()); Assert.assertEquals(vn0, vn); } - + @Test public void test02b() { final String delim = ","; - + final String vs00 = "4,20"; final String vs01 = "COMPANY via Stupid tool 4,20"; final String vs02 = "4,20 COMPANY via Stupid tool"; @@ -146,21 +146,21 @@ public class TestVersionNumber extends JunitTracer { Assert.assertTrue(vn0.hasMajor()); Assert.assertTrue(vn0.hasMinor()); Assert.assertTrue(vn0.hasSub()); - + VersionNumber vn; - + vn = new VersionNumber(vs00, delim); Assert.assertTrue(vn.hasMajor()); Assert.assertTrue(vn.hasMinor()); Assert.assertTrue(!vn.hasSub()); Assert.assertEquals(vn0, vn); - + vn = new VersionNumber(vs01, delim); Assert.assertTrue(vn.hasMajor()); Assert.assertTrue(vn.hasMinor()); Assert.assertTrue(!vn.hasSub()); Assert.assertEquals(vn0, vn); - + vn = new VersionNumber(vs02, delim); Assert.assertTrue(vn.hasMajor()); Assert.assertTrue(vn.hasMinor()); @@ -177,32 +177,32 @@ public class TestVersionNumber extends JunitTracer { Assert.assertTrue(vn0.hasMajor()); Assert.assertTrue(vn0.hasMinor()); Assert.assertTrue(vn0.hasSub()); - + VersionNumber vn; - + vn = new VersionNumber(vs00); Assert.assertTrue(vn.hasMajor()); Assert.assertTrue(vn.hasMinor()); Assert.assertTrue(vn.hasSub()); Assert.assertEquals(vn0, vn); - + vn = new VersionNumber(vs01); Assert.assertTrue(vn.hasMajor()); Assert.assertTrue(vn.hasMinor()); Assert.assertTrue(vn.hasSub()); Assert.assertEquals(vn0, vn); - + vn = new VersionNumber(vs02); Assert.assertTrue(vn.hasMajor()); Assert.assertTrue(vn.hasMinor()); Assert.assertTrue(vn.hasSub()); Assert.assertEquals(vn0, vn); } - + @Test public void test03b() { final String delim = ","; - + final String vs00 = "A10,11,12b"; final String vs01 = "Prelim Text 10,Funny11,Weird12 Something is odd"; final String vs02 = "Prelim Text 10,Funny11l1,Weird12 2 Something is odd"; @@ -210,28 +210,28 @@ public class TestVersionNumber extends JunitTracer { Assert.assertTrue(vn0.hasMajor()); Assert.assertTrue(vn0.hasMinor()); Assert.assertTrue(vn0.hasSub()); - + VersionNumber vn; - + vn = new VersionNumber(vs00, delim); Assert.assertTrue(vn.hasMajor()); Assert.assertTrue(vn.hasMinor()); Assert.assertTrue(vn.hasSub()); Assert.assertEquals(vn0, vn); - + vn = new VersionNumber(vs01, delim); Assert.assertTrue(vn.hasMajor()); Assert.assertTrue(vn.hasMinor()); Assert.assertTrue(vn.hasSub()); Assert.assertEquals(vn0, vn); - + vn = new VersionNumber(vs02, delim); Assert.assertTrue(vn.hasMajor()); Assert.assertTrue(vn.hasMinor()); Assert.assertTrue(vn.hasSub()); Assert.assertEquals(vn0, vn); } - + @Test public void test04() { final String vs00 = "A10.11.12b (git-d6c318e)"; @@ -241,21 +241,21 @@ public class TestVersionNumber extends JunitTracer { Assert.assertTrue(vn0.hasMajor()); Assert.assertTrue(vn0.hasMinor()); Assert.assertTrue(vn0.hasSub()); - + VersionNumber vn; - + vn = new VersionNumber(vs00); Assert.assertTrue(vn.hasMajor()); Assert.assertTrue(vn.hasMinor()); Assert.assertTrue(vn.hasSub()); Assert.assertEquals(vn0, vn); - + vn = new VersionNumber(vs01); Assert.assertTrue(vn.hasMajor()); Assert.assertTrue(vn.hasMinor()); Assert.assertTrue(vn.hasSub()); Assert.assertEquals(vn0, vn); - + vn = new VersionNumber(vs02); Assert.assertTrue(vn.hasMajor()); Assert.assertTrue(vn.hasMinor()); @@ -265,7 +265,7 @@ public class TestVersionNumber extends JunitTracer { @Test public void test04b() { final String delim = ","; - + final String vs00 = "A10,11,12b (git-d6c318e)"; final String vs01 = "Prelim Text 10,Funny11,Weird12 Something is odd (git-d6c318e)"; final String vs02 = "Prelim Text 10,Funny11l1,Weird12 2 Something is odd (git-d6c318e)"; @@ -273,30 +273,30 @@ public class TestVersionNumber extends JunitTracer { Assert.assertTrue(vn0.hasMajor()); Assert.assertTrue(vn0.hasMinor()); Assert.assertTrue(vn0.hasSub()); - + VersionNumber vn; - + vn = new VersionNumber(vs00, delim); Assert.assertTrue(vn.hasMajor()); Assert.assertTrue(vn.hasMinor()); Assert.assertTrue(vn.hasSub()); Assert.assertEquals(vn0, vn); - + vn = new VersionNumber(vs01, delim); Assert.assertTrue(vn.hasMajor()); Assert.assertTrue(vn.hasMinor()); Assert.assertTrue(vn.hasSub()); Assert.assertEquals(vn0, vn); - + vn = new VersionNumber(vs02, delim); Assert.assertTrue(vn.hasMajor()); Assert.assertTrue(vn.hasMinor()); Assert.assertTrue(vn.hasSub()); Assert.assertEquals(vn0, vn); } - - public static void main(String args[]) throws IOException { - String tstname = TestVersionNumber.class.getName(); + + public static void main(final String args[]) throws IOException { + final String tstname = TestVersionNumber.class.getName(); org.junit.runner.JUnitCore.main(tstname); } diff --git a/src/junit/com/jogamp/common/util/TestVersionSemantics.java b/src/junit/com/jogamp/common/util/TestVersionSemantics.java index 5e8b899..b70cdd7 100644 --- a/src/junit/com/jogamp/common/util/TestVersionSemantics.java +++ b/src/junit/com/jogamp/common/util/TestVersionSemantics.java @@ -93,8 +93,8 @@ public class TestVersionSemantics extends JunitTracer { curVersion.getClass(), currentCL, curVersionNumber, excludes); } - public static void main(String args[]) throws IOException { - String tstname = TestVersionSemantics.class.getName(); + public static void main(final String args[]) throws IOException { + final String tstname = TestVersionSemantics.class.getName(); org.junit.runner.JUnitCore.main(tstname); } } diff --git a/src/junit/com/jogamp/common/util/locks/TestRecursiveLock01.java b/src/junit/com/jogamp/common/util/locks/TestRecursiveLock01.java index df5f3ba..26677c0 100644 --- a/src/junit/com/jogamp/common/util/locks/TestRecursiveLock01.java +++ b/src/junit/com/jogamp/common/util/locks/TestRecursiveLock01.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.common.util.locks; import java.io.IOException; @@ -47,16 +47,16 @@ import org.junit.runners.MethodSorters; public class TestRecursiveLock01 extends JunitTracer { public enum YieldMode { - NONE(0), YIELD(1), SLEEP(2); - + NONE(0), YIELD(1), SLEEP(2); + public final int id; - YieldMode(int id){ + YieldMode(final int id){ this.id = id; } - } - - static void yield(YieldMode mode) { + } + + static void yield(final YieldMode mode) { switch(mode) { case YIELD: Thread.yield(); @@ -64,7 +64,7 @@ public class TestRecursiveLock01 extends JunitTracer { case SLEEP: try { Thread.sleep(10); - } catch (InterruptedException ie) { + } catch (final InterruptedException ie) { ie.printStackTrace(); } break; @@ -76,7 +76,7 @@ public class TestRecursiveLock01 extends JunitTracer { static class LockedObject { static final boolean DEBUG = false; - + static class ThreadStat { ThreadStat() { total = 0; @@ -85,16 +85,16 @@ public class TestRecursiveLock01 extends JunitTracer { long total; // ns int counter; } - - private RecursiveLock locker; // post + + private final RecursiveLock locker; // post private int deferredThreadCount = 0; // synced - private Map<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); } } |