From: Robert Varga Date: Thu, 29 Dec 2016 12:25:51 +0000 (+0100) Subject: BUG-7464: Update pom.xml X-Git-Tag: release/carbon~178 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=ddb098da2d1f8607e1cf073c05e0d8e187eb1ab4;p=yangtools.git BUG-7464: Update pom.xml Update pom.xml and move source to yangtools-specific package. Also add triemap as a third-party module, attaching it to default compilation. Change-Id: I0554be2c99a6aa42ca1e25bf290693117a5b8920 Signed-off-by: Robert Varga --- diff --git a/third-party/pom.xml b/third-party/pom.xml index 44a9f48931..deeb4a7d24 100644 --- a/third-party/pom.xml +++ b/third-party/pom.xml @@ -22,6 +22,7 @@ pom + triemap xsd-regex diff --git a/third-party/triemap/pom.xml b/third-party/triemap/pom.xml index 10d77a92a6..cdec858a9f 100644 --- a/third-party/triemap/pom.xml +++ b/third-party/triemap/pom.xml @@ -1,90 +1,77 @@ + + + - 4.0.0 - - org.sonatype.oss - oss-parent - 7 - - com.github.romix - java-concurrent-hash-trie-map - 0.2.23-ODL - TrieMap - Java implementation of a concurrent trie hash map from Scala collections library - bundle - https://github.com/romix/java-concurrent-hash-trie-map - - - The Apache Software License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - repo - - - - https://github.com/romix/java-concurrent-hash-trie-map - scm:git:https://github.com/romix/java-concurrent-hash-trie-map.git - scm:git:https://github.com/romix/java-concurrent-hash-trie-map.git - java-concurrent-hash-trie-map-0.2.23 - - - - romix - Roman Levenstein - romixlev@gmail.com - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3.2 - - 1.6 - 1.6 - iso8859-1 - - - - org.apache.maven.plugins - maven-release-plugin - 2.5 - - - pom.xml - - - - - org.apache.felix - maven-bundle-plugin - 2.4.0 - true - - - ${project.groupId}.${project.artifactId} - - - - - - - - junit - junit - 4.9 - test - - - - - sonatype-nexus-staging - Nexus Staging Repository - https://oss.sonatype.org/service/local/staging/deploy/maven2/ - - - sonatype-nexus-snapshots - Nexus Snapshots Repository - https://oss.sonatype.org/content/repositories/snapshots/ - - + + + org.opendaylight.odlparent + bundle-parent + 1.8.0-SNAPSHOT + + + + 4.0.0 + org.opendaylight.yangtools + triemap + 0.9.0-SNAPSHOT + bundle + + Java implementation of a concurrent trie hash map from Scala collections library + + + + junit + junit + + + + + + + + maven-checkstyle-plugin + + true + + + + + + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + + ${odl.site.url}/${project.groupId}/${stream}/${project.artifactId}/ + + + + opendaylight-site + ${nexus.site.url}/${project.artifactId}/ + + diff --git a/third-party/triemap/src/main/java/com/romix/scala/collection/concurrent/BasicNode.java b/third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/BasicNode.java similarity index 92% rename from third-party/triemap/src/main/java/com/romix/scala/collection/concurrent/BasicNode.java rename to third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/BasicNode.java index ed5cdbe25e..82b99193cd 100644 --- a/third-party/triemap/src/main/java/com/romix/scala/collection/concurrent/BasicNode.java +++ b/third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/BasicNode.java @@ -6,7 +6,7 @@ ** |/ ** \* */ -package com.romix.scala.collection.concurrent; +package org.opendaylight.yangtools.triemap; diff --git a/third-party/triemap/src/main/java/com/romix/scala/collection/concurrent/CNodeBase.java b/third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/CNodeBase.java similarity index 95% rename from third-party/triemap/src/main/java/com/romix/scala/collection/concurrent/CNodeBase.java rename to third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/CNodeBase.java index 33b21c5804..2a12749b4d 100644 --- a/third-party/triemap/src/main/java/com/romix/scala/collection/concurrent/CNodeBase.java +++ b/third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/CNodeBase.java @@ -6,7 +6,7 @@ ** |/ ** \* */ -package com.romix.scala.collection.concurrent; +package org.opendaylight.yangtools.triemap; diff --git a/third-party/triemap/src/main/java/com/romix/scala/collection/concurrent/Gen.java b/third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/Gen.java similarity index 91% rename from third-party/triemap/src/main/java/com/romix/scala/collection/concurrent/Gen.java rename to third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/Gen.java index 15aba43cd4..357c9c4c17 100644 --- a/third-party/triemap/src/main/java/com/romix/scala/collection/concurrent/Gen.java +++ b/third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/Gen.java @@ -6,7 +6,7 @@ ** |/ ** \* */ -package com.romix.scala.collection.concurrent; +package org.opendaylight.yangtools.triemap; diff --git a/third-party/triemap/src/main/java/com/romix/scala/collection/concurrent/INodeBase.java b/third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/INodeBase.java similarity index 95% rename from third-party/triemap/src/main/java/com/romix/scala/collection/concurrent/INodeBase.java rename to third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/INodeBase.java index 11a3b3404f..f09dc838d7 100644 --- a/third-party/triemap/src/main/java/com/romix/scala/collection/concurrent/INodeBase.java +++ b/third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/INodeBase.java @@ -6,7 +6,7 @@ ** |/ ** \* */ -package com.romix.scala.collection.concurrent; +package org.opendaylight.yangtools.triemap; diff --git a/third-party/triemap/src/main/java/com/romix/scala/collection/concurrent/ListMap.java b/third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/ListMap.java similarity index 98% rename from third-party/triemap/src/main/java/com/romix/scala/collection/concurrent/ListMap.java rename to third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/ListMap.java index bef25f7cb3..fd3da93de7 100644 --- a/third-party/triemap/src/main/java/com/romix/scala/collection/concurrent/ListMap.java +++ b/third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/ListMap.java @@ -1,11 +1,9 @@ -package com.romix.scala.collection.concurrent; +package org.opendaylight.yangtools.triemap; import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; -import com.romix.scala.Option; - /** * Mimic immutable ListMap in Scala * diff --git a/third-party/triemap/src/main/java/com/romix/scala/collection/concurrent/MainNode.java b/third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/MainNode.java similarity index 96% rename from third-party/triemap/src/main/java/com/romix/scala/collection/concurrent/MainNode.java rename to third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/MainNode.java index 82387252d2..9ee09a04ad 100644 --- a/third-party/triemap/src/main/java/com/romix/scala/collection/concurrent/MainNode.java +++ b/third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/MainNode.java @@ -6,7 +6,7 @@ ** |/ ** \* */ -package com.romix.scala.collection.concurrent; +package org.opendaylight.yangtools.triemap; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; diff --git a/third-party/triemap/src/main/java/com/romix/scala/None.java b/third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/None.java similarity index 57% rename from third-party/triemap/src/main/java/com/romix/scala/None.java rename to third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/None.java index ba7d648b2d..6c1190c5b3 100644 --- a/third-party/triemap/src/main/java/com/romix/scala/None.java +++ b/third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/None.java @@ -1,4 +1,4 @@ -package com.romix.scala; +package org.opendaylight.yangtools.triemap; /** * Mimic None in Scala @@ -7,6 +7,6 @@ package com.romix.scala; * * @param */ -public class None extends Option{ +class None extends Option{ } diff --git a/third-party/triemap/src/main/java/com/romix/scala/Option.java b/third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/Option.java similarity index 88% rename from third-party/triemap/src/main/java/com/romix/scala/Option.java rename to third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/Option.java index 833ef5fbe2..431a375fbc 100644 --- a/third-party/triemap/src/main/java/com/romix/scala/Option.java +++ b/third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/Option.java @@ -1,4 +1,4 @@ -package com.romix.scala; +package org.opendaylight.yangtools.triemap; /** * Mimic Option in Scala @@ -8,7 +8,7 @@ package com.romix.scala; * @param */ @SuppressWarnings({"rawtypes", "unchecked"}) -public class Option { +class Option { static None none = new None(); public static Option makeOption(V o){ if(o!=null) diff --git a/third-party/triemap/src/main/java/com/romix/scala/collection/concurrent/Pair.java b/third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/Pair.java similarity index 85% rename from third-party/triemap/src/main/java/com/romix/scala/collection/concurrent/Pair.java rename to third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/Pair.java index 18c262d33f..2bb73f92e3 100644 --- a/third-party/triemap/src/main/java/com/romix/scala/collection/concurrent/Pair.java +++ b/third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/Pair.java @@ -1,4 +1,4 @@ -package com.romix.scala.collection.concurrent; +package org.opendaylight.yangtools.triemap; import java.util.Map; @@ -10,7 +10,7 @@ import java.util.Map; * @param * @param */ -public class Pair implements Map.Entry { +class Pair implements Map.Entry { final K k; final V v; diff --git a/third-party/triemap/src/main/java/com/romix/scala/Some.java b/third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/Some.java similarity index 79% rename from third-party/triemap/src/main/java/com/romix/scala/Some.java rename to third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/Some.java index 6268600319..114ac650c0 100644 --- a/third-party/triemap/src/main/java/com/romix/scala/Some.java +++ b/third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/Some.java @@ -1,4 +1,4 @@ -package com.romix.scala; +package org.opendaylight.yangtools.triemap; /** * Mimic Some in Scala @@ -7,7 +7,7 @@ package com.romix.scala; * * @param */ -public class Some extends Option{ +class Some extends Option{ final V value; public Some(V v) { value = v; diff --git a/third-party/triemap/src/main/java/com/romix/scala/collection/concurrent/TrieMap.java b/third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/TrieMap.java similarity index 99% rename from third-party/triemap/src/main/java/com/romix/scala/collection/concurrent/TrieMap.java rename to third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/TrieMap.java index 8f92922da5..f727f0eddc 100644 --- a/third-party/triemap/src/main/java/com/romix/scala/collection/concurrent/TrieMap.java +++ b/third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/TrieMap.java @@ -1,4 +1,4 @@ -package com.romix.scala.collection.concurrent; +package org.opendaylight.yangtools.triemap; import java.io.IOException; import java.io.ObjectInputStream; @@ -17,14 +17,11 @@ import java.util.NoSuchElementException; import java.util.Set; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; -import com.romix.scala.None; -import com.romix.scala.Option; -import com.romix.scala.Some; /*** * This is a port of Scala's TrieMap class from the Scala Collections library. * - * @author Roman Levenstein + * @author Roman Levenstein <romixlev@gmail.com> * * @param * @param diff --git a/third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestCNodeFlagCollision.java b/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestCNodeFlagCollision.java similarity index 93% rename from third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestCNodeFlagCollision.java rename to third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestCNodeFlagCollision.java index a08a685380..f0fbb55901 100644 --- a/third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestCNodeFlagCollision.java +++ b/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestCNodeFlagCollision.java @@ -1,35 +1,35 @@ -package com.romix.scala.collection.concurrent; - -import java.util.Map; - -import org.junit.Test; - -public class TestCNodeFlagCollision { - @Test - public void testCNodeFlagCollision () { - final Map map = new TrieMap (); - final Integer z15169 = Integer.valueOf (15169); - final Integer z28336 = Integer.valueOf (28336); - - TestHelper.assertTrue (null == map.get (z15169)); - TestHelper.assertTrue (null == map.get (z28336)); - - map.put (z15169, z15169); - TestHelper.assertTrue (null != map.get (z15169)); - TestHelper.assertTrue (null == map.get (z28336)); - - map.put (z28336, z28336); - TestHelper.assertTrue (null != map.get (z15169)); - TestHelper.assertTrue (null != map.get (z28336)); - - map.remove (z15169); - - TestHelper.assertTrue (null == map.get (z15169)); - TestHelper.assertTrue (null != map.get (z28336)); - - map.remove (z28336); - - TestHelper.assertTrue (null == map.get (z15169)); - TestHelper.assertTrue (null == map.get (z28336)); - } -} +package org.opendaylight.yangtools.triemap; + +import java.util.Map; + +import org.junit.Test; + +public class TestCNodeFlagCollision { + @Test + public void testCNodeFlagCollision () { + final Map map = new TrieMap (); + final Integer z15169 = Integer.valueOf (15169); + final Integer z28336 = Integer.valueOf (28336); + + TestHelper.assertTrue (null == map.get (z15169)); + TestHelper.assertTrue (null == map.get (z28336)); + + map.put (z15169, z15169); + TestHelper.assertTrue (null != map.get (z15169)); + TestHelper.assertTrue (null == map.get (z28336)); + + map.put (z28336, z28336); + TestHelper.assertTrue (null != map.get (z15169)); + TestHelper.assertTrue (null != map.get (z28336)); + + map.remove (z15169); + + TestHelper.assertTrue (null == map.get (z15169)); + TestHelper.assertTrue (null != map.get (z28336)); + + map.remove (z28336); + + TestHelper.assertTrue (null == map.get (z15169)); + TestHelper.assertTrue (null == map.get (z28336)); + } +} diff --git a/third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestCNodeInsertionIncorrectOrder.java b/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestCNodeInsertionIncorrectOrder.java similarity index 89% rename from third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestCNodeInsertionIncorrectOrder.java rename to third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestCNodeInsertionIncorrectOrder.java index 9d36de336b..b8ab573f8b 100644 --- a/third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestCNodeInsertionIncorrectOrder.java +++ b/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestCNodeInsertionIncorrectOrder.java @@ -1,21 +1,21 @@ -package com.romix.scala.collection.concurrent; - -import java.util.Map; - -import org.junit.Test; - -public class TestCNodeInsertionIncorrectOrder { - - @Test - public void testCNodeInsertionIncorrectOrder () { - final Map map = new TrieMap (); - final Integer z3884 = Integer.valueOf (3884); - final Integer z4266 = Integer.valueOf (4266); - map.put (z3884, z3884); - TestHelper.assertTrue (null != map.get (z3884)); - - map.put (z4266, z4266); - TestHelper.assertTrue (null != map.get (z3884)); - TestHelper.assertTrue (null != map.get (z4266)); - } -} +package org.opendaylight.yangtools.triemap; + +import java.util.Map; + +import org.junit.Test; + +public class TestCNodeInsertionIncorrectOrder { + + @Test + public void testCNodeInsertionIncorrectOrder () { + final Map map = new TrieMap (); + final Integer z3884 = Integer.valueOf (3884); + final Integer z4266 = Integer.valueOf (4266); + map.put (z3884, z3884); + TestHelper.assertTrue (null != map.get (z3884)); + + map.put (z4266, z4266); + TestHelper.assertTrue (null != map.get (z3884)); + TestHelper.assertTrue (null != map.get (z4266)); + } +} diff --git a/third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestConcurrentMapPutIfAbsent.java b/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestConcurrentMapPutIfAbsent.java similarity index 88% rename from third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestConcurrentMapPutIfAbsent.java rename to third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestConcurrentMapPutIfAbsent.java index afdadcd8cb..9c29836174 100644 --- a/third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestConcurrentMapPutIfAbsent.java +++ b/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestConcurrentMapPutIfAbsent.java @@ -1,19 +1,19 @@ -package com.romix.scala.collection.concurrent; - -import java.util.concurrent.ConcurrentMap; - -import org.junit.Test; - -public class TestConcurrentMapPutIfAbsent { - private static final int COUNT = 50*1000; - - @Test - public void testConcurrentMapPutIfAbsent () { - final ConcurrentMap map = new TrieMap (); - - for (int i = 0; i < COUNT; i++) { - TestHelper.assertTrue (null == map.putIfAbsent (i, i)); - TestHelper.assertTrue (Integer.valueOf (i).equals (map.putIfAbsent (i, i))); - } - } -} +package org.opendaylight.yangtools.triemap; + +import java.util.concurrent.ConcurrentMap; + +import org.junit.Test; + +public class TestConcurrentMapPutIfAbsent { + private static final int COUNT = 50*1000; + + @Test + public void testConcurrentMapPutIfAbsent () { + final ConcurrentMap map = new TrieMap (); + + for (int i = 0; i < COUNT; i++) { + TestHelper.assertTrue (null == map.putIfAbsent (i, i)); + TestHelper.assertTrue (Integer.valueOf (i).equals (map.putIfAbsent (i, i))); + } + } +} diff --git a/third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestConcurrentMapRemove.java b/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestConcurrentMapRemove.java similarity index 91% rename from third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestConcurrentMapRemove.java rename to third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestConcurrentMapRemove.java index 6796784cc0..980322d9df 100644 --- a/third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestConcurrentMapRemove.java +++ b/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestConcurrentMapRemove.java @@ -1,24 +1,24 @@ -package com.romix.scala.collection.concurrent; - -import java.util.concurrent.ConcurrentMap; - -import org.junit.Test; - -public class TestConcurrentMapRemove { - private static final int COUNT = 50*1000; - - @Test - public void testConcurrentMapRemove () { - final ConcurrentMap map = new TrieMap (); - - for (int i = 128; i < COUNT; i++) { - TestHelper.assertFalse (map.remove (i, i)); - TestHelper.assertTrue (null == map.put (i, i)); - TestHelper.assertFalse (map.remove (i, "lol")); - TestHelper.assertTrue (map.containsKey (i)); - TestHelper.assertTrue (map.remove (i, i)); - TestHelper.assertFalse (map.containsKey (i)); - TestHelper.assertTrue (null == map.put (i, i)); - } - } -} +package org.opendaylight.yangtools.triemap; + +import java.util.concurrent.ConcurrentMap; + +import org.junit.Test; + +public class TestConcurrentMapRemove { + private static final int COUNT = 50*1000; + + @Test + public void testConcurrentMapRemove () { + final ConcurrentMap map = new TrieMap (); + + for (int i = 128; i < COUNT; i++) { + TestHelper.assertFalse (map.remove (i, i)); + TestHelper.assertTrue (null == map.put (i, i)); + TestHelper.assertFalse (map.remove (i, "lol")); + TestHelper.assertTrue (map.containsKey (i)); + TestHelper.assertTrue (map.remove (i, i)); + TestHelper.assertFalse (map.containsKey (i)); + TestHelper.assertTrue (null == map.put (i, i)); + } + } +} diff --git a/third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestConcurrentMapReplace.java b/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestConcurrentMapReplace.java similarity index 91% rename from third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestConcurrentMapReplace.java rename to third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestConcurrentMapReplace.java index d941aca675..6e10ecae10 100644 --- a/third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestConcurrentMapReplace.java +++ b/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestConcurrentMapReplace.java @@ -1,23 +1,23 @@ -package com.romix.scala.collection.concurrent; - -import java.util.concurrent.ConcurrentMap; - -import org.junit.Test; - -public class TestConcurrentMapReplace { - private static final int COUNT = 50*1000; - - @Test - public void testConcurrentMapReplace () { - final ConcurrentMap map = new TrieMap (); - - for (int i = 0; i < COUNT; i++) { - TestHelper.assertTrue (null == map.replace (i, "lol")); - TestHelper.assertFalse (map.replace (i, i, "lol2")); - TestHelper.assertTrue (null == map.put (i, i)); - TestHelper.assertTrue (Integer.valueOf (i).equals (map.replace (i, "lol"))); - TestHelper.assertFalse (map.replace (i, i, "lol2")); - TestHelper.assertTrue (map.replace (i, "lol", i)); - } - } -} +package org.opendaylight.yangtools.triemap; + +import java.util.concurrent.ConcurrentMap; + +import org.junit.Test; + +public class TestConcurrentMapReplace { + private static final int COUNT = 50*1000; + + @Test + public void testConcurrentMapReplace () { + final ConcurrentMap map = new TrieMap (); + + for (int i = 0; i < COUNT; i++) { + TestHelper.assertTrue (null == map.replace (i, "lol")); + TestHelper.assertFalse (map.replace (i, i, "lol2")); + TestHelper.assertTrue (null == map.put (i, i)); + TestHelper.assertTrue (Integer.valueOf (i).equals (map.replace (i, "lol"))); + TestHelper.assertFalse (map.replace (i, i, "lol2")); + TestHelper.assertTrue (map.replace (i, "lol", i)); + } + } +} diff --git a/third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestDelete.java b/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestDelete.java similarity index 94% rename from third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestDelete.java rename to third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestDelete.java index c374174add..8cd1b39d32 100644 --- a/third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestDelete.java +++ b/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestDelete.java @@ -1,43 +1,42 @@ -package com.romix.scala.collection.concurrent; - -import org.junit.Test; - - -public class TestDelete { - @Test - public void testDelete () { - final TrieMap bt = new TrieMap (); - - for (int i = 0; i < 10000; i++) { - TestHelper.assertEquals (null, bt.put (Integer.valueOf (i), Integer.valueOf (i))); - final Object lookup = bt.lookup (Integer.valueOf (i)); - TestHelper.assertEquals (Integer.valueOf (i), lookup); - } - - checkAddInsert (bt, 536); - checkAddInsert (bt, 4341); - checkAddInsert (bt, 8437); - - for (int i = 0; i < 10000; i++) { - boolean removed = null != bt.remove(Integer.valueOf (i)); - TestHelper.assertEquals (Boolean.TRUE, Boolean.valueOf (removed)); - final Object lookup = bt.lookup (Integer.valueOf (i)); - TestHelper.assertEquals (null, lookup); - } - - bt.toString (); - } - - private static void checkAddInsert (final TrieMap bt, int k) { - final Integer v = Integer.valueOf (k); - bt.remove (v); - Object foundV = bt.lookup (v); - TestHelper.assertEquals (null, foundV); - TestHelper.assertEquals (null, bt.put (v, v)); - foundV = bt.lookup (v); - TestHelper.assertEquals (v, foundV); - - TestHelper.assertEquals (v, bt.put (v, Integer.valueOf (-1))); - TestHelper.assertEquals (Integer.valueOf (-1), bt.put (v, v)); - } -} +package org.opendaylight.yangtools.triemap; + +import org.junit.Test; + +public class TestDelete { + @Test + public void testDelete () { + final TrieMap bt = new TrieMap (); + + for (int i = 0; i < 10000; i++) { + TestHelper.assertEquals (null, bt.put (Integer.valueOf (i), Integer.valueOf (i))); + final Object lookup = bt.lookup (Integer.valueOf (i)); + TestHelper.assertEquals (Integer.valueOf (i), lookup); + } + + checkAddInsert (bt, 536); + checkAddInsert (bt, 4341); + checkAddInsert (bt, 8437); + + for (int i = 0; i < 10000; i++) { + boolean removed = null != bt.remove(Integer.valueOf (i)); + TestHelper.assertEquals (Boolean.TRUE, Boolean.valueOf (removed)); + final Object lookup = bt.lookup (Integer.valueOf (i)); + TestHelper.assertEquals (null, lookup); + } + + bt.toString (); + } + + private static void checkAddInsert (final TrieMap bt, int k) { + final Integer v = Integer.valueOf (k); + bt.remove (v); + Object foundV = bt.lookup (v); + TestHelper.assertEquals (null, foundV); + TestHelper.assertEquals (null, bt.put (v, v)); + foundV = bt.lookup (v); + TestHelper.assertEquals (v, foundV); + + TestHelper.assertEquals (v, bt.put (v, Integer.valueOf (-1))); + TestHelper.assertEquals (Integer.valueOf (-1), bt.put (v, v)); + } +} diff --git a/third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestHashCollisions.java b/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestHashCollisions.java similarity index 96% rename from third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestHashCollisions.java rename to third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestHashCollisions.java index ce89f17ae0..963953718b 100644 --- a/third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestHashCollisions.java +++ b/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestHashCollisions.java @@ -1,179 +1,179 @@ -package com.romix.scala.collection.concurrent; - - -import org.junit.Test; - -public class TestHashCollisions { - @Test - public void testHashCollisions () { - final TrieMap bt = new TrieMap (); - - insertStrings (bt); - insertChars (bt); - insertInts (bt); - insertBytes (bt); - - removeStrings (bt); - removeChars (bt); - removeInts (bt); - removeBytes (bt); - - insertStrings (bt); - insertInts (bt); - insertBytes (bt); - insertChars (bt); - - removeBytes (bt); - removeStrings (bt); - removeChars (bt); - removeInts (bt); - - insertStrings (bt); - insertInts (bt); - insertBytes (bt); - insertChars (bt); - - removeStrings (bt); - removeChars (bt); - removeInts (bt); - removeBytes (bt); - - insertStrings (bt); - insertInts (bt); - insertBytes (bt); - insertChars (bt); - - removeChars (bt); - removeInts (bt); - removeBytes (bt); - removeStrings (bt); - - insertStrings (bt); - insertInts (bt); - insertBytes (bt); - insertChars (bt); - - removeInts (bt); - removeBytes (bt); - removeStrings (bt); - removeChars (bt); - - System.out.println (bt); - } - - private static void insertChars (final TrieMap bt) { - TestHelper.assertEquals (null, bt.put ('a', 'a')); - TestHelper.assertEquals (null, bt.put ('b', 'b')); - TestHelper.assertEquals (null, bt.put ('c', 'c')); - TestHelper.assertEquals (null, bt.put ('d', 'd')); - TestHelper.assertEquals (null, bt.put ('e', 'e')); - - TestHelper.assertEquals ('a', bt.put ('a', 'a')); - TestHelper.assertEquals ('b', bt.put ('b', 'b')); - TestHelper.assertEquals ('c', bt.put ('c', 'c')); - TestHelper.assertEquals ('d', bt.put ('d', 'd')); - TestHelper.assertEquals ('e', bt.put ('e', 'e')); - } - - private static void insertStrings (final TrieMap bt) { - TestHelper.assertEquals (null, bt.put ("a", "a")); - TestHelper.assertEquals (null, bt.put ("b", "b")); - TestHelper.assertEquals (null, bt.put ("c", "c")); - TestHelper.assertEquals (null, bt.put ("d", "d")); - TestHelper.assertEquals (null, bt.put ("e", "e")); - - TestHelper.assertEquals ("a", bt.put ("a", "a")); - TestHelper.assertEquals ("b", bt.put ("b", "b")); - TestHelper.assertEquals ("c", bt.put ("c", "c")); - TestHelper.assertEquals ("d", bt.put ("d", "d")); - TestHelper.assertEquals ("e", bt.put ("e", "e")); - } - - private static void insertBytes (final TrieMap bt) { - for (byte i = 0; i < 128 && i >= 0; i++) { - final Byte bigB = Byte.valueOf (i); - TestHelper.assertEquals (null, bt.put (bigB, bigB)); - TestHelper.assertEquals (bigB, bt.put (bigB, bigB)); - } - } - - private static void insertInts (final TrieMap bt) { - for (int i = 0; i < 128; i++) { - final Integer bigI = Integer.valueOf (i); - TestHelper.assertEquals (null, bt.put (bigI, bigI)); - TestHelper.assertEquals (bigI, bt.put (bigI, bigI)); - } - } - - private static void removeChars (final TrieMap bt) { - TestHelper.assertTrue (null != bt.lookup ('a')); - TestHelper.assertTrue (null != bt.lookup ('b')); - TestHelper.assertTrue (null != bt.lookup ('c')); - TestHelper.assertTrue (null != bt.lookup ('d')); - TestHelper.assertTrue (null != bt.lookup ('e')); - - TestHelper.assertTrue (null != bt.remove ('a')); - TestHelper.assertTrue (null != bt.remove ('b')); - TestHelper.assertTrue (null != bt.remove ('c')); - TestHelper.assertTrue (null != bt.remove ('d')); - TestHelper.assertTrue (null != bt.remove ('e')); - - TestHelper.assertFalse (null != bt.remove ('a')); - TestHelper.assertFalse (null != bt.remove ('b')); - TestHelper.assertFalse (null != bt.remove ('c')); - TestHelper.assertFalse (null != bt.remove ('d')); - TestHelper.assertFalse (null != bt.remove ('e')); - - TestHelper.assertTrue (null == bt.lookup ('a')); - TestHelper.assertTrue (null == bt.lookup ('b')); - TestHelper.assertTrue (null == bt.lookup ('c')); - TestHelper.assertTrue (null == bt.lookup ('d')); - TestHelper.assertTrue (null == bt.lookup ('e')); - } - - private static void removeStrings (final TrieMap bt) { - TestHelper.assertTrue (null != bt.lookup ("a")); - TestHelper.assertTrue (null != bt.lookup ("b")); - TestHelper.assertTrue (null != bt.lookup ("c")); - TestHelper.assertTrue (null != bt.lookup ("d")); - TestHelper.assertTrue (null != bt.lookup ("e")); - - TestHelper.assertTrue (null != bt.remove ("a")); - TestHelper.assertTrue (null != bt.remove ("b")); - TestHelper.assertTrue (null != bt.remove ("c")); - TestHelper.assertTrue (null != bt.remove ("d")); - TestHelper.assertTrue (null != bt.remove ("e")); - - TestHelper.assertFalse (null != bt.remove ("a")); - TestHelper.assertFalse (null != bt.remove ("b")); - TestHelper.assertFalse (null != bt.remove ("c")); - TestHelper.assertFalse (null != bt.remove ("d")); - TestHelper.assertFalse (null != bt.remove ("e")); - - TestHelper.assertTrue (null == bt.lookup ("a")); - TestHelper.assertTrue (null == bt.lookup ("b")); - TestHelper.assertTrue (null == bt.lookup ("c")); - TestHelper.assertTrue (null == bt.lookup ("d")); - TestHelper.assertTrue (null == bt.lookup ("e")); - } - - private static void removeInts (final TrieMap bt) { - for (int i = 0; i < 128; i++) { - final Integer bigI = Integer.valueOf (i); - TestHelper.assertTrue (null != bt.lookup (bigI)); - TestHelper.assertTrue (null != bt.remove (bigI)); - TestHelper.assertFalse (null != bt.remove (bigI)); - TestHelper.assertTrue (null == bt.lookup (bigI)); - } - } - - private static void removeBytes (final TrieMap bt) { - for (byte i = 0; i < 128 && i >= 0; i++) { - final Byte bigB = Byte.valueOf (i); - TestHelper.assertTrue (null != bt.lookup (bigB)); - TestHelper.assertTrue (null != bt.remove (bigB)); - TestHelper.assertFalse (null != bt.remove (bigB)); - TestHelper.assertTrue (null == bt.lookup (bigB)); - } - } -} +package org.opendaylight.yangtools.triemap; + + +import org.junit.Test; + +public class TestHashCollisions { + @Test + public void testHashCollisions () { + final TrieMap bt = new TrieMap (); + + insertStrings (bt); + insertChars (bt); + insertInts (bt); + insertBytes (bt); + + removeStrings (bt); + removeChars (bt); + removeInts (bt); + removeBytes (bt); + + insertStrings (bt); + insertInts (bt); + insertBytes (bt); + insertChars (bt); + + removeBytes (bt); + removeStrings (bt); + removeChars (bt); + removeInts (bt); + + insertStrings (bt); + insertInts (bt); + insertBytes (bt); + insertChars (bt); + + removeStrings (bt); + removeChars (bt); + removeInts (bt); + removeBytes (bt); + + insertStrings (bt); + insertInts (bt); + insertBytes (bt); + insertChars (bt); + + removeChars (bt); + removeInts (bt); + removeBytes (bt); + removeStrings (bt); + + insertStrings (bt); + insertInts (bt); + insertBytes (bt); + insertChars (bt); + + removeInts (bt); + removeBytes (bt); + removeStrings (bt); + removeChars (bt); + + System.out.println (bt); + } + + private static void insertChars (final TrieMap bt) { + TestHelper.assertEquals (null, bt.put ('a', 'a')); + TestHelper.assertEquals (null, bt.put ('b', 'b')); + TestHelper.assertEquals (null, bt.put ('c', 'c')); + TestHelper.assertEquals (null, bt.put ('d', 'd')); + TestHelper.assertEquals (null, bt.put ('e', 'e')); + + TestHelper.assertEquals ('a', bt.put ('a', 'a')); + TestHelper.assertEquals ('b', bt.put ('b', 'b')); + TestHelper.assertEquals ('c', bt.put ('c', 'c')); + TestHelper.assertEquals ('d', bt.put ('d', 'd')); + TestHelper.assertEquals ('e', bt.put ('e', 'e')); + } + + private static void insertStrings (final TrieMap bt) { + TestHelper.assertEquals (null, bt.put ("a", "a")); + TestHelper.assertEquals (null, bt.put ("b", "b")); + TestHelper.assertEquals (null, bt.put ("c", "c")); + TestHelper.assertEquals (null, bt.put ("d", "d")); + TestHelper.assertEquals (null, bt.put ("e", "e")); + + TestHelper.assertEquals ("a", bt.put ("a", "a")); + TestHelper.assertEquals ("b", bt.put ("b", "b")); + TestHelper.assertEquals ("c", bt.put ("c", "c")); + TestHelper.assertEquals ("d", bt.put ("d", "d")); + TestHelper.assertEquals ("e", bt.put ("e", "e")); + } + + private static void insertBytes (final TrieMap bt) { + for (byte i = 0; i < 128 && i >= 0; i++) { + final Byte bigB = Byte.valueOf (i); + TestHelper.assertEquals (null, bt.put (bigB, bigB)); + TestHelper.assertEquals (bigB, bt.put (bigB, bigB)); + } + } + + private static void insertInts (final TrieMap bt) { + for (int i = 0; i < 128; i++) { + final Integer bigI = Integer.valueOf (i); + TestHelper.assertEquals (null, bt.put (bigI, bigI)); + TestHelper.assertEquals (bigI, bt.put (bigI, bigI)); + } + } + + private static void removeChars (final TrieMap bt) { + TestHelper.assertTrue (null != bt.lookup ('a')); + TestHelper.assertTrue (null != bt.lookup ('b')); + TestHelper.assertTrue (null != bt.lookup ('c')); + TestHelper.assertTrue (null != bt.lookup ('d')); + TestHelper.assertTrue (null != bt.lookup ('e')); + + TestHelper.assertTrue (null != bt.remove ('a')); + TestHelper.assertTrue (null != bt.remove ('b')); + TestHelper.assertTrue (null != bt.remove ('c')); + TestHelper.assertTrue (null != bt.remove ('d')); + TestHelper.assertTrue (null != bt.remove ('e')); + + TestHelper.assertFalse (null != bt.remove ('a')); + TestHelper.assertFalse (null != bt.remove ('b')); + TestHelper.assertFalse (null != bt.remove ('c')); + TestHelper.assertFalse (null != bt.remove ('d')); + TestHelper.assertFalse (null != bt.remove ('e')); + + TestHelper.assertTrue (null == bt.lookup ('a')); + TestHelper.assertTrue (null == bt.lookup ('b')); + TestHelper.assertTrue (null == bt.lookup ('c')); + TestHelper.assertTrue (null == bt.lookup ('d')); + TestHelper.assertTrue (null == bt.lookup ('e')); + } + + private static void removeStrings (final TrieMap bt) { + TestHelper.assertTrue (null != bt.lookup ("a")); + TestHelper.assertTrue (null != bt.lookup ("b")); + TestHelper.assertTrue (null != bt.lookup ("c")); + TestHelper.assertTrue (null != bt.lookup ("d")); + TestHelper.assertTrue (null != bt.lookup ("e")); + + TestHelper.assertTrue (null != bt.remove ("a")); + TestHelper.assertTrue (null != bt.remove ("b")); + TestHelper.assertTrue (null != bt.remove ("c")); + TestHelper.assertTrue (null != bt.remove ("d")); + TestHelper.assertTrue (null != bt.remove ("e")); + + TestHelper.assertFalse (null != bt.remove ("a")); + TestHelper.assertFalse (null != bt.remove ("b")); + TestHelper.assertFalse (null != bt.remove ("c")); + TestHelper.assertFalse (null != bt.remove ("d")); + TestHelper.assertFalse (null != bt.remove ("e")); + + TestHelper.assertTrue (null == bt.lookup ("a")); + TestHelper.assertTrue (null == bt.lookup ("b")); + TestHelper.assertTrue (null == bt.lookup ("c")); + TestHelper.assertTrue (null == bt.lookup ("d")); + TestHelper.assertTrue (null == bt.lookup ("e")); + } + + private static void removeInts (final TrieMap bt) { + for (int i = 0; i < 128; i++) { + final Integer bigI = Integer.valueOf (i); + TestHelper.assertTrue (null != bt.lookup (bigI)); + TestHelper.assertTrue (null != bt.remove (bigI)); + TestHelper.assertFalse (null != bt.remove (bigI)); + TestHelper.assertTrue (null == bt.lookup (bigI)); + } + } + + private static void removeBytes (final TrieMap bt) { + for (byte i = 0; i < 128 && i >= 0; i++) { + final Byte bigB = Byte.valueOf (i); + TestHelper.assertTrue (null != bt.lookup (bigB)); + TestHelper.assertTrue (null != bt.remove (bigB)); + TestHelper.assertFalse (null != bt.remove (bigB)); + TestHelper.assertTrue (null == bt.lookup (bigB)); + } + } +} diff --git a/third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestHashCollisionsRemove.java b/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestHashCollisionsRemove.java similarity index 91% rename from third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestHashCollisionsRemove.java rename to third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestHashCollisionsRemove.java index a991eb0b4c..5cdcce6ec4 100644 --- a/third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestHashCollisionsRemove.java +++ b/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestHashCollisionsRemove.java @@ -1,29 +1,29 @@ -package com.romix.scala.collection.concurrent; - -import java.util.Map; - -import org.junit.Test; - -public class TestHashCollisionsRemove { - @Test - public void testHashCollisionsRemove() { - final Map bt = new TrieMap (); - int count = 50000; - for (int j = 0; j < count; j++) { - final Object[] objects = TestMultiThreadMapIterator.getObjects (j); - for (final Object o : objects) { - bt.put (o, o); - } - } - - for (int j = 0; j < count; j++) { - final Object[] objects = TestMultiThreadMapIterator.getObjects (j); - for (final Object o : objects) { - bt.remove (o); - } - } - - TestHelper.assertEquals (0, bt.size ()); - TestHelper.assertTrue (bt.isEmpty ()); - } -} +package org.opendaylight.yangtools.triemap; + +import java.util.Map; + +import org.junit.Test; + +public class TestHashCollisionsRemove { + @Test + public void testHashCollisionsRemove() { + final Map bt = new TrieMap (); + int count = 50000; + for (int j = 0; j < count; j++) { + final Object[] objects = TestMultiThreadMapIterator.getObjects (j); + for (final Object o : objects) { + bt.put (o, o); + } + } + + for (int j = 0; j < count; j++) { + final Object[] objects = TestMultiThreadMapIterator.getObjects (j); + for (final Object o : objects) { + bt.remove (o); + } + } + + TestHelper.assertEquals (0, bt.size ()); + TestHelper.assertTrue (bt.isEmpty ()); + } +} diff --git a/third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestHashCollisionsRemoveIterator.java b/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestHashCollisionsRemoveIterator.java similarity index 92% rename from third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestHashCollisionsRemoveIterator.java rename to third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestHashCollisionsRemoveIterator.java index 91783d6c56..2f67c7834f 100644 --- a/third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestHashCollisionsRemoveIterator.java +++ b/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestHashCollisionsRemoveIterator.java @@ -1,31 +1,31 @@ -package com.romix.scala.collection.concurrent; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; - -import org.junit.Test; - -public class TestHashCollisionsRemoveIterator { - @Test - public void testHashCollisionsRemoveIterator () { - final Map bt = new TrieMap (); - int count = 50000; - for (int j = 0; j < count; j++) { - bt.put (Integer.valueOf (j), Integer.valueOf (j)); - } - - final Collection list = new ArrayList (); - for (final Iterator> i = bt.entrySet ().iterator (); i.hasNext ();) { - final Entry e = i.next (); - final Object key = e.getKey (); - list.add (key); - i.remove (); - } - - TestHelper.assertEquals (0, bt.size ()); - TestHelper.assertTrue (bt.isEmpty ()); - } -} +package org.opendaylight.yangtools.triemap; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; + +import org.junit.Test; + +public class TestHashCollisionsRemoveIterator { + @Test + public void testHashCollisionsRemoveIterator () { + final Map bt = new TrieMap (); + int count = 50000; + for (int j = 0; j < count; j++) { + bt.put (Integer.valueOf (j), Integer.valueOf (j)); + } + + final Collection list = new ArrayList (); + for (final Iterator> i = bt.entrySet ().iterator (); i.hasNext ();) { + final Entry e = i.next (); + final Object key = e.getKey (); + list.add (key); + i.remove (); + } + + TestHelper.assertEquals (0, bt.size ()); + TestHelper.assertTrue (bt.isEmpty ()); + } +} diff --git a/third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestHelper.java b/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestHelper.java similarity index 89% rename from third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestHelper.java rename to third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestHelper.java index 26331bb249..80846eaa7a 100644 --- a/third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestHelper.java +++ b/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestHelper.java @@ -1,27 +1,27 @@ -package com.romix.scala.collection.concurrent; - -import org.junit.Assert; - -public class TestHelper { - - public static void assertEquals (long expected, long found) { - Assert.assertEquals (expected, found); - } - - public static void assertEquals (int expected, int found) { - Assert.assertEquals (expected, found); - } - - public static void assertEquals (Object expected, Object found) { - Assert.assertEquals (expected, found); - } - - public static void assertTrue (boolean found) { - Assert.assertTrue (found); - } - - public static void assertFalse (boolean found) { - Assert.assertFalse (found); - } - -} +package org.opendaylight.yangtools.triemap; + +import org.junit.Assert; + +public class TestHelper { + + public static void assertEquals (long expected, long found) { + Assert.assertEquals (expected, found); + } + + public static void assertEquals (int expected, int found) { + Assert.assertEquals (expected, found); + } + + public static void assertEquals (Object expected, Object found) { + Assert.assertEquals (expected, found); + } + + public static void assertTrue (boolean found) { + Assert.assertTrue (found); + } + + public static void assertFalse (boolean found) { + Assert.assertFalse (found); + } + +} diff --git a/third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestInsert.java b/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestInsert.java similarity index 91% rename from third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestInsert.java rename to third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestInsert.java index 69e0b689d1..ee8db2d437 100644 --- a/third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestInsert.java +++ b/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestInsert.java @@ -1,23 +1,23 @@ -package com.romix.scala.collection.concurrent; - -import org.junit.Test; - -public class TestInsert { - @Test - public void testInsert () { - final TrieMap bt = new TrieMap (); - TestHelper.assertEquals (null, bt.put ("a", "a")); - TestHelper.assertEquals (null, bt.put ("b", "b")); - TestHelper.assertEquals (null, bt.put ("c", "b")); - TestHelper.assertEquals (null, bt.put ("d", "b")); - TestHelper.assertEquals (null, bt.put ("e", "b")); - - for (int i = 0; i < 10000; i++) { - TestHelper.assertEquals (null, bt.put (Integer.valueOf (i), Integer.valueOf (i))); - final Object lookup = bt.lookup (Integer.valueOf (i)); - TestHelper.assertEquals (Integer.valueOf (i), lookup); - } - - bt.toString (); - } -} +package org.opendaylight.yangtools.triemap; + +import org.junit.Test; + +public class TestInsert { + @Test + public void testInsert () { + final TrieMap bt = new TrieMap (); + TestHelper.assertEquals (null, bt.put ("a", "a")); + TestHelper.assertEquals (null, bt.put ("b", "b")); + TestHelper.assertEquals (null, bt.put ("c", "b")); + TestHelper.assertEquals (null, bt.put ("d", "b")); + TestHelper.assertEquals (null, bt.put ("e", "b")); + + for (int i = 0; i < 10000; i++) { + TestHelper.assertEquals (null, bt.put (Integer.valueOf (i), Integer.valueOf (i))); + final Object lookup = bt.lookup (Integer.valueOf (i)); + TestHelper.assertEquals (Integer.valueOf (i), lookup); + } + + bt.toString (); + } +} diff --git a/third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestInstantiationSpeed.java b/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestInstantiationSpeed.java similarity index 95% rename from third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestInstantiationSpeed.java rename to third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestInstantiationSpeed.java index 1318a37de7..794867df2a 100644 --- a/third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestInstantiationSpeed.java +++ b/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestInstantiationSpeed.java @@ -1,4 +1,4 @@ -package com.romix.scala.collection.concurrent; +package org.opendaylight.yangtools.triemap; import org.junit.Test; diff --git a/third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestMapIterator.java b/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestMapIterator.java similarity index 95% rename from third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestMapIterator.java rename to third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestMapIterator.java index 4815911522..43abcc18ba 100644 --- a/third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestMapIterator.java +++ b/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestMapIterator.java @@ -1,57 +1,57 @@ -package com.romix.scala.collection.concurrent; - -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Random; -import java.util.Set; - -import org.junit.Test; - -public class TestMapIterator { - @Test - public void testMapIterator () { - for (int i = 0; i < 60 * 1000; i+= 400 + new Random ().nextInt (400)) { - System.out.println (i); - final Map bt = new TrieMap (); - for (int j = 0; j < i; j++) { - TestHelper.assertEquals (null, bt.put (Integer.valueOf (j), Integer.valueOf (j))); - } - int count = 0; - final Set set = new HashSet (); - for (final Map.Entry e : bt.entrySet ()) { - set.add (e.getKey ()); - count++; - } - for (final Integer j : set) { - TestHelper.assertTrue (bt.containsKey (j)); - } - for (final Integer j : bt.keySet ()) { - TestHelper.assertTrue (set.contains (j)); - } - - TestHelper.assertEquals (i, count); - TestHelper.assertEquals (i, bt.size ()); - - for (final Iterator> iter = bt.entrySet ().iterator (); iter.hasNext ();) { - final Entry e = iter.next (); - TestHelper.assertTrue (e.getValue () == bt.get (e.getKey ())); - e.setValue (e.getValue () + 1); - TestHelper.assertTrue (e.getValue () == e.getKey () + 1); - TestHelper.assertTrue (e.getValue () == bt.get (e.getKey ())); - e.setValue (e.getValue () - 1); - } - - for (final Iterator iter = bt.keySet ().iterator (); iter.hasNext ();) { - final Integer k = iter.next (); - TestHelper.assertTrue (bt.containsKey (k)); - iter.remove (); - TestHelper.assertFalse (bt.containsKey (k)); - } - - TestHelper.assertEquals (0, bt.size ()); - TestHelper.assertTrue (bt.isEmpty ()); - } - } -} +package org.opendaylight.yangtools.triemap; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Random; +import java.util.Set; + +import org.junit.Test; + +public class TestMapIterator { + @Test + public void testMapIterator () { + for (int i = 0; i < 60 * 1000; i+= 400 + new Random ().nextInt (400)) { + System.out.println (i); + final Map bt = new TrieMap (); + for (int j = 0; j < i; j++) { + TestHelper.assertEquals (null, bt.put (Integer.valueOf (j), Integer.valueOf (j))); + } + int count = 0; + final Set set = new HashSet (); + for (final Map.Entry e : bt.entrySet ()) { + set.add (e.getKey ()); + count++; + } + for (final Integer j : set) { + TestHelper.assertTrue (bt.containsKey (j)); + } + for (final Integer j : bt.keySet ()) { + TestHelper.assertTrue (set.contains (j)); + } + + TestHelper.assertEquals (i, count); + TestHelper.assertEquals (i, bt.size ()); + + for (final Iterator> iter = bt.entrySet ().iterator (); iter.hasNext ();) { + final Entry e = iter.next (); + TestHelper.assertTrue (e.getValue () == bt.get (e.getKey ())); + e.setValue (e.getValue () + 1); + TestHelper.assertTrue (e.getValue () == e.getKey () + 1); + TestHelper.assertTrue (e.getValue () == bt.get (e.getKey ())); + e.setValue (e.getValue () - 1); + } + + for (final Iterator iter = bt.keySet ().iterator (); iter.hasNext ();) { + final Integer k = iter.next (); + TestHelper.assertTrue (bt.containsKey (k)); + iter.remove (); + TestHelper.assertFalse (bt.containsKey (k)); + } + + TestHelper.assertEquals (0, bt.size ()); + TestHelper.assertTrue (bt.isEmpty ()); + } + } +} diff --git a/third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestMultiThreadAddDelete.java b/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestMultiThreadAddDelete.java similarity index 96% rename from third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestMultiThreadAddDelete.java rename to third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestMultiThreadAddDelete.java index 99280c208f..efcb846a9b 100644 --- a/third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestMultiThreadAddDelete.java +++ b/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestMultiThreadAddDelete.java @@ -1,114 +1,114 @@ -package com.romix.scala.collection.concurrent; - -import java.util.Map; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; - -import org.junit.Test; - -public class TestMultiThreadAddDelete { - private static final int RETRIES = 1; - private static final int N_THREADS = 7; - private static final int COUNT = 50 * 1000; - - @Test - public void testMultiThreadAddDelete () { - for (int j = 0; j < RETRIES; j++) { - final Map bt = new TrieMap (); - - { - final ExecutorService es = Executors.newFixedThreadPool (N_THREADS); - for (int i = 0; i < N_THREADS; i++) { - final int threadNo = i; - es.execute (new Runnable () { - @Override - public void run () { - for (int j = 0; j < COUNT; j++) { - if (j % N_THREADS == threadNo) { - bt.put (Integer.valueOf (j), Integer.valueOf (j)); - } - } - } - }); - } - es.shutdown (); - try { - es.awaitTermination (3600L, TimeUnit.SECONDS); - } catch (final InterruptedException e) { - e.printStackTrace (); - } - } - - TestHelper.assertEquals (COUNT, bt.size ()); - TestHelper.assertFalse (bt.isEmpty ()); - - { - final ExecutorService es = Executors.newFixedThreadPool (N_THREADS); - for (int i = 0; i < N_THREADS; i++) { - final int threadNo = i; - es.execute (new Runnable () { - @Override - public void run () { - for (int j = 0; j < COUNT; j++) { - if (j % N_THREADS == threadNo) { - bt.remove (Integer.valueOf (j)); - } - } - } - }); - } - es.shutdown (); - try { - es.awaitTermination (3600L, TimeUnit.SECONDS); - } catch (final InterruptedException e) { - e.printStackTrace (); - } - } - - - TestHelper.assertEquals (0, bt.size ()); - TestHelper.assertTrue (bt.isEmpty ()); - - { - final ExecutorService es = Executors.newFixedThreadPool (N_THREADS); - for (int i = 0; i < N_THREADS; i++) { - final int threadNo = i; - es.execute (new Runnable () { - @Override - public void run () { - for (int j = 0; j < COUNT; j++) { - if (j % N_THREADS == threadNo) { - try { - bt.put (Integer.valueOf (j), Integer.valueOf (j)); - if (!bt.containsKey (Integer.valueOf (j))) { - System.out.println (j); - } - bt.remove (Integer.valueOf (j)); - if (bt.containsKey (Integer.valueOf (j))) { - System.out.println (-j); - } - } catch (Throwable t) { - t.printStackTrace (); - } - } - } - } - }); - } - es.shutdown (); - try { - es.awaitTermination (3600L, TimeUnit.SECONDS); - } catch (final InterruptedException e) { - e.printStackTrace (); - } - } - - TestHelper.assertEquals (0, bt.size ()); - if (!bt.isEmpty ()) { - System.out.println (); - } - TestHelper.assertTrue (bt.isEmpty ()); - } - } -} +package org.opendaylight.yangtools.triemap; + +import java.util.Map; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; + +import org.junit.Test; + +public class TestMultiThreadAddDelete { + private static final int RETRIES = 1; + private static final int N_THREADS = 7; + private static final int COUNT = 50 * 1000; + + @Test + public void testMultiThreadAddDelete () { + for (int j = 0; j < RETRIES; j++) { + final Map bt = new TrieMap (); + + { + final ExecutorService es = Executors.newFixedThreadPool (N_THREADS); + for (int i = 0; i < N_THREADS; i++) { + final int threadNo = i; + es.execute (new Runnable () { + @Override + public void run () { + for (int j = 0; j < COUNT; j++) { + if (j % N_THREADS == threadNo) { + bt.put (Integer.valueOf (j), Integer.valueOf (j)); + } + } + } + }); + } + es.shutdown (); + try { + es.awaitTermination (3600L, TimeUnit.SECONDS); + } catch (final InterruptedException e) { + e.printStackTrace (); + } + } + + TestHelper.assertEquals (COUNT, bt.size ()); + TestHelper.assertFalse (bt.isEmpty ()); + + { + final ExecutorService es = Executors.newFixedThreadPool (N_THREADS); + for (int i = 0; i < N_THREADS; i++) { + final int threadNo = i; + es.execute (new Runnable () { + @Override + public void run () { + for (int j = 0; j < COUNT; j++) { + if (j % N_THREADS == threadNo) { + bt.remove (Integer.valueOf (j)); + } + } + } + }); + } + es.shutdown (); + try { + es.awaitTermination (3600L, TimeUnit.SECONDS); + } catch (final InterruptedException e) { + e.printStackTrace (); + } + } + + + TestHelper.assertEquals (0, bt.size ()); + TestHelper.assertTrue (bt.isEmpty ()); + + { + final ExecutorService es = Executors.newFixedThreadPool (N_THREADS); + for (int i = 0; i < N_THREADS; i++) { + final int threadNo = i; + es.execute (new Runnable () { + @Override + public void run () { + for (int j = 0; j < COUNT; j++) { + if (j % N_THREADS == threadNo) { + try { + bt.put (Integer.valueOf (j), Integer.valueOf (j)); + if (!bt.containsKey (Integer.valueOf (j))) { + System.out.println (j); + } + bt.remove (Integer.valueOf (j)); + if (bt.containsKey (Integer.valueOf (j))) { + System.out.println (-j); + } + } catch (Throwable t) { + t.printStackTrace (); + } + } + } + } + }); + } + es.shutdown (); + try { + es.awaitTermination (3600L, TimeUnit.SECONDS); + } catch (final InterruptedException e) { + e.printStackTrace (); + } + } + + TestHelper.assertEquals (0, bt.size ()); + if (!bt.isEmpty ()) { + System.out.println (); + } + TestHelper.assertTrue (bt.isEmpty ()); + } + } +} diff --git a/third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestMultiThreadInserts.java b/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestMultiThreadInserts.java similarity index 93% rename from third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestMultiThreadInserts.java rename to third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestMultiThreadInserts.java index 2062a1c519..6ad60fd41f 100644 --- a/third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestMultiThreadInserts.java +++ b/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestMultiThreadInserts.java @@ -1,41 +1,41 @@ -package com.romix.scala.collection.concurrent; - -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; - -import org.junit.Test; - -public class TestMultiThreadInserts { - @Test - public void testMultiThreadInserts () { - final int nThreads = 2; - final ExecutorService es = Executors.newFixedThreadPool (nThreads); - final TrieMap bt = new TrieMap (); - for (int i = 0; i < nThreads; i++) { - final int threadNo = i; - es.execute (new Runnable () { - @Override - public void run () { - for (int j = 0; j < 500 * 1000; j++) { - if (j % nThreads == threadNo) { - bt.put (Integer.valueOf (j), Integer.valueOf (j)); - } - } - } - }); - } - - es.shutdown (); - try { - es.awaitTermination (3600L, TimeUnit.SECONDS); - } catch (final InterruptedException e) { - e.printStackTrace (); - } - - for (int j = 0; j < 500 * 1000; j++) { - final Object lookup = bt.lookup (Integer.valueOf (j)); - TestHelper.assertEquals (Integer.valueOf (j), lookup); - } - } -} +package org.opendaylight.yangtools.triemap; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; + +import org.junit.Test; + +public class TestMultiThreadInserts { + @Test + public void testMultiThreadInserts () { + final int nThreads = 2; + final ExecutorService es = Executors.newFixedThreadPool (nThreads); + final TrieMap bt = new TrieMap (); + for (int i = 0; i < nThreads; i++) { + final int threadNo = i; + es.execute (new Runnable () { + @Override + public void run () { + for (int j = 0; j < 500 * 1000; j++) { + if (j % nThreads == threadNo) { + bt.put (Integer.valueOf (j), Integer.valueOf (j)); + } + } + } + }); + } + + es.shutdown (); + try { + es.awaitTermination (3600L, TimeUnit.SECONDS); + } catch (final InterruptedException e) { + e.printStackTrace (); + } + + for (int j = 0; j < 500 * 1000; j++) { + final Object lookup = bt.lookup (Integer.valueOf (j)); + TestHelper.assertEquals (Integer.valueOf (j), lookup); + } + } +} diff --git a/third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestMultiThreadMapIterator.java b/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestMultiThreadMapIterator.java similarity index 96% rename from third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestMultiThreadMapIterator.java rename to third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestMultiThreadMapIterator.java index 91e7b068b1..fc4128a552 100644 --- a/third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestMultiThreadMapIterator.java +++ b/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestMultiThreadMapIterator.java @@ -1,155 +1,155 @@ -package com.romix.scala.collection.concurrent; - -import java.util.Collection; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; - -import org.junit.Test; - -public class TestMultiThreadMapIterator { - private static final int NTHREADS = 7; - - @Test - public void testMultiThreadMapIterator () { - final Map bt = new TrieMap (); - for (int j = 0; j < 50 * 1000; j++) { - final Object[] objects = getObjects (j); - for (final Object o : objects) { - bt.put (o, o); - } - } - - System.out.println ("Size of initialized map is " + bt.size ()); - int count = 0; - { - final ExecutorService es = Executors.newFixedThreadPool (NTHREADS); - for (int i = 0; i < NTHREADS; i++) { - final int threadNo = i; - es.execute (new Runnable () { - @Override - public void run () { - for (final Iterator> i = bt.entrySet ().iterator (); i.hasNext ();) { - final Entry e = i.next (); - if (accepts (threadNo, NTHREADS, e.getKey ())) { - String newValue = "TEST:" + threadNo; - e.setValue (newValue); - } - } - } - }); - } - - es.shutdown (); - try { - es.awaitTermination (3600L, TimeUnit.SECONDS); - } catch (final InterruptedException e) { - e.printStackTrace (); - } - } - - count = 0; - for (final Map.Entry kv : bt.entrySet ()) { - Object value = kv.getValue (); - TestHelper.assertTrue (value instanceof String); - count++; - } - TestHelper.assertEquals (50000 + 2000 + 1000 + 100, count); - - final ConcurrentHashMap removed = new ConcurrentHashMap (); - - { - final ExecutorService es = Executors.newFixedThreadPool (NTHREADS); - for (int i = 0; i < NTHREADS; i++) { - final int threadNo = i; - es.execute (new Runnable () { - @Override - public void run () { - for (final Iterator> i = bt.entrySet ().iterator (); i.hasNext ();) { - final Entry e = i.next (); - Object key = e.getKey (); - if (accepts (threadNo, NTHREADS, key)) { - if (null == bt.get (key)) { - System.out.println (key); - } - i.remove (); - if (null != bt.get (key)) { - System.out.println (key); - } - removed.put (key, key); - } - } - } - }); - } - - es.shutdown (); - try { - es.awaitTermination (3600L, TimeUnit.SECONDS); - } catch (final InterruptedException e) { - e.printStackTrace (); - } - } - - count = 0; - for (final Object value : bt.keySet ()) { - value.toString (); - count++; - } - for (final Object o : bt.keySet ()) { - if (!removed.contains (bt.get (o))) { - System.out.println ("Not removed: " + o); - } - } - TestHelper.assertEquals (0, count); - TestHelper.assertEquals (0, bt.size ()); - TestHelper.assertTrue (bt.isEmpty ()); - } - - protected static boolean accepts (final int threadNo, final int nThreads, final Object key) { - int val = getKeyValue (key); - if(val>=0) - return val % nThreads == threadNo; - else - return false; - } - - private static int getKeyValue (final Object key) { - int val = 0; - if (key instanceof Integer) { - val = ((Integer) key).intValue (); - } - else if (key instanceof Character) { - val = Math.abs (Character.getNumericValue ((Character) key) + 1); - } - else if (key instanceof Short) { - val = ((Short) key).intValue () + 2; - } - else if (key instanceof Byte) { - val = ((Byte) key).intValue () + 3; - } else - return -1; - return val; - } - - static Object[] getObjects (final int j) { - final Collection results = new LinkedList (); - results.add (Integer.valueOf (j)); - if (j < 2000) { - results.add (Character.valueOf ((char) j)); - } - if (j < 1000) { - results.add (Short.valueOf ((short) j)); - } - if (j < 100) { - results.add (Byte.valueOf ((byte) j)); - } - - return results.toArray (); - } -} +package org.opendaylight.yangtools.triemap; + +import java.util.Collection; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.Map; +import java.util.Map.Entry; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; + +import org.junit.Test; + +public class TestMultiThreadMapIterator { + private static final int NTHREADS = 7; + + @Test + public void testMultiThreadMapIterator () { + final Map bt = new TrieMap (); + for (int j = 0; j < 50 * 1000; j++) { + final Object[] objects = getObjects (j); + for (final Object o : objects) { + bt.put (o, o); + } + } + + System.out.println ("Size of initialized map is " + bt.size ()); + int count = 0; + { + final ExecutorService es = Executors.newFixedThreadPool (NTHREADS); + for (int i = 0; i < NTHREADS; i++) { + final int threadNo = i; + es.execute (new Runnable () { + @Override + public void run () { + for (final Iterator> i = bt.entrySet ().iterator (); i.hasNext ();) { + final Entry e = i.next (); + if (accepts (threadNo, NTHREADS, e.getKey ())) { + String newValue = "TEST:" + threadNo; + e.setValue (newValue); + } + } + } + }); + } + + es.shutdown (); + try { + es.awaitTermination (3600L, TimeUnit.SECONDS); + } catch (final InterruptedException e) { + e.printStackTrace (); + } + } + + count = 0; + for (final Map.Entry kv : bt.entrySet ()) { + Object value = kv.getValue (); + TestHelper.assertTrue (value instanceof String); + count++; + } + TestHelper.assertEquals (50000 + 2000 + 1000 + 100, count); + + final ConcurrentHashMap removed = new ConcurrentHashMap (); + + { + final ExecutorService es = Executors.newFixedThreadPool (NTHREADS); + for (int i = 0; i < NTHREADS; i++) { + final int threadNo = i; + es.execute (new Runnable () { + @Override + public void run () { + for (final Iterator> i = bt.entrySet ().iterator (); i.hasNext ();) { + final Entry e = i.next (); + Object key = e.getKey (); + if (accepts (threadNo, NTHREADS, key)) { + if (null == bt.get (key)) { + System.out.println (key); + } + i.remove (); + if (null != bt.get (key)) { + System.out.println (key); + } + removed.put (key, key); + } + } + } + }); + } + + es.shutdown (); + try { + es.awaitTermination (3600L, TimeUnit.SECONDS); + } catch (final InterruptedException e) { + e.printStackTrace (); + } + } + + count = 0; + for (final Object value : bt.keySet ()) { + value.toString (); + count++; + } + for (final Object o : bt.keySet ()) { + if (!removed.contains (bt.get (o))) { + System.out.println ("Not removed: " + o); + } + } + TestHelper.assertEquals (0, count); + TestHelper.assertEquals (0, bt.size ()); + TestHelper.assertTrue (bt.isEmpty ()); + } + + protected static boolean accepts (final int threadNo, final int nThreads, final Object key) { + int val = getKeyValue (key); + if(val>=0) + return val % nThreads == threadNo; + else + return false; + } + + private static int getKeyValue (final Object key) { + int val = 0; + if (key instanceof Integer) { + val = ((Integer) key).intValue (); + } + else if (key instanceof Character) { + val = Math.abs (Character.getNumericValue ((Character) key) + 1); + } + else if (key instanceof Short) { + val = ((Short) key).intValue () + 2; + } + else if (key instanceof Byte) { + val = ((Byte) key).intValue () + 3; + } else + return -1; + return val; + } + + static Object[] getObjects (final int j) { + final Collection results = new LinkedList (); + results.add (Integer.valueOf (j)); + if (j < 2000) { + results.add (Character.valueOf ((char) j)); + } + if (j < 1000) { + results.add (Short.valueOf ((short) j)); + } + if (j < 100) { + results.add (Byte.valueOf ((byte) j)); + } + + return results.toArray (); + } +} diff --git a/third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestReadOnlyAndUpdatableIterators.java b/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestReadOnlyAndUpdatableIterators.java similarity index 96% rename from third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestReadOnlyAndUpdatableIterators.java rename to third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestReadOnlyAndUpdatableIterators.java index 7ff5b5d54d..878aa769d8 100644 --- a/third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestReadOnlyAndUpdatableIterators.java +++ b/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestReadOnlyAndUpdatableIterators.java @@ -1,130 +1,130 @@ -package com.romix.scala.collection.concurrent; - -import java.util.Iterator; -import java.util.Map.Entry; - -import org.junit.Before; -import org.junit.Test; - -/*** - * - * Test that read-only iterators do not allow for any updates. - * Test that non read-only iterators allow for updates. - * - */ -public class TestReadOnlyAndUpdatableIterators { - TrieMap bt; - private static final int MAP_SIZE = 200; - - @Before - public void setUp() { - bt = new TrieMap (); - for (int j = 0; j < MAP_SIZE; j++) { - TestHelper.assertEquals (null, bt.put (Integer.valueOf (j), Integer.valueOf (j))); - } - } - - @Test - public void testReadOnlyIterator () { - Iterator> it = bt.readOnlyIterator (); - try { - it.next().setValue (0); - // It should have generated an exception, because it is a read-only iterator - TestHelper.assertFalse (true); - } catch (Exception e) { - - } - try { - it.remove (); - // It should have generated an exception, because it is a read-only iterator - TestHelper.assertFalse (true); - } catch (Exception e) { - - } - } - - @Test - public void testReadOnlySnapshotReadOnlyIterator () { - TrieMap roSnapshot = bt.readOnlySnapshot (); - Iterator> it = roSnapshot.readOnlyIterator (); - try { - it.next().setValue (0); - // It should have generated an exception, because it is a read-only iterator - TestHelper.assertFalse (true); - } catch (Exception e) { - - } - try { - it.remove (); - // It should have generated an exception, because it is a read-only iterator - TestHelper.assertFalse (true); - } catch (Exception e) { - - } - } - - @Test - public void testReadOnlySnapshotIterator () { - TrieMap roSnapshot = bt.readOnlySnapshot (); - Iterator> it = roSnapshot.iterator (); - try { - it.next().setValue (0); - // It should have generated an exception, because it is a read-only iterator - TestHelper.assertFalse (true); - } catch (Exception e) { - - } - try { - it.remove (); - // It should have generated an exception, because it is a read-only iterator - TestHelper.assertFalse (true); - } catch (Exception e) { - - } - } - - @Test - public void testIterator () { - Iterator> it = bt.iterator (); - try { - it.next().setValue (0); - } catch (Exception e) { - // It should not have generated an exception, because it is a non read-only iterator - TestHelper.assertFalse (true); - } - - try { - it.remove (); - } catch (Exception e) { - // It should not have generated an exception, because it is a non read-only iterator - TestHelper.assertFalse (true); - } - - // All changes are done on the original map - TestHelper.assertEquals (MAP_SIZE - 1, bt.size ()); - } - - @Test - public void testSnapshotIterator () { - TrieMap snapshot = bt.snapshot (); - Iterator> it = snapshot.iterator (); - try { - it.next().setValue (0); - } catch (Exception e) { - // It should not have generated an exception, because it is a non read-only iterator - TestHelper.assertFalse (true); - } - try { - it.remove (); - } catch (Exception e) { - // It should not have generated an exception, because it is a non read-only iterator - TestHelper.assertFalse (true); - } - - // All changes are done on the snapshot, not on the original map - // Map size should remain unchanged - TestHelper.assertEquals (MAP_SIZE, bt.size ()); - // snapshot size was changed - TestHelper.assertEquals (MAP_SIZE-1, snapshot.size ()); - } -} +package org.opendaylight.yangtools.triemap; + +import java.util.Iterator; +import java.util.Map.Entry; + +import org.junit.Before; +import org.junit.Test; + +/*** + * + * Test that read-only iterators do not allow for any updates. + * Test that non read-only iterators allow for updates. + * + */ +public class TestReadOnlyAndUpdatableIterators { + TrieMap bt; + private static final int MAP_SIZE = 200; + + @Before + public void setUp() { + bt = new TrieMap (); + for (int j = 0; j < MAP_SIZE; j++) { + TestHelper.assertEquals (null, bt.put (Integer.valueOf (j), Integer.valueOf (j))); + } + } + + @Test + public void testReadOnlyIterator () { + Iterator> it = bt.readOnlyIterator (); + try { + it.next().setValue (0); + // It should have generated an exception, because it is a read-only iterator + TestHelper.assertFalse (true); + } catch (Exception e) { + + } + try { + it.remove (); + // It should have generated an exception, because it is a read-only iterator + TestHelper.assertFalse (true); + } catch (Exception e) { + + } + } + + @Test + public void testReadOnlySnapshotReadOnlyIterator () { + TrieMap roSnapshot = bt.readOnlySnapshot (); + Iterator> it = roSnapshot.readOnlyIterator (); + try { + it.next().setValue (0); + // It should have generated an exception, because it is a read-only iterator + TestHelper.assertFalse (true); + } catch (Exception e) { + + } + try { + it.remove (); + // It should have generated an exception, because it is a read-only iterator + TestHelper.assertFalse (true); + } catch (Exception e) { + + } + } + + @Test + public void testReadOnlySnapshotIterator () { + TrieMap roSnapshot = bt.readOnlySnapshot (); + Iterator> it = roSnapshot.iterator (); + try { + it.next().setValue (0); + // It should have generated an exception, because it is a read-only iterator + TestHelper.assertFalse (true); + } catch (Exception e) { + + } + try { + it.remove (); + // It should have generated an exception, because it is a read-only iterator + TestHelper.assertFalse (true); + } catch (Exception e) { + + } + } + + @Test + public void testIterator () { + Iterator> it = bt.iterator (); + try { + it.next().setValue (0); + } catch (Exception e) { + // It should not have generated an exception, because it is a non read-only iterator + TestHelper.assertFalse (true); + } + + try { + it.remove (); + } catch (Exception e) { + // It should not have generated an exception, because it is a non read-only iterator + TestHelper.assertFalse (true); + } + + // All changes are done on the original map + TestHelper.assertEquals (MAP_SIZE - 1, bt.size ()); + } + + @Test + public void testSnapshotIterator () { + TrieMap snapshot = bt.snapshot (); + Iterator> it = snapshot.iterator (); + try { + it.next().setValue (0); + } catch (Exception e) { + // It should not have generated an exception, because it is a non read-only iterator + TestHelper.assertFalse (true); + } + try { + it.remove (); + } catch (Exception e) { + // It should not have generated an exception, because it is a non read-only iterator + TestHelper.assertFalse (true); + } + + // All changes are done on the snapshot, not on the original map + // Map size should remain unchanged + TestHelper.assertEquals (MAP_SIZE, bt.size ()); + // snapshot size was changed + TestHelper.assertEquals (MAP_SIZE-1, snapshot.size ()); + } +} diff --git a/third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestSerialization.java b/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestSerialization.java similarity index 96% rename from third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestSerialization.java rename to third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestSerialization.java index 04a4a2c7fb..aaf3bfea09 100644 --- a/third-party/triemap/src/test/java/com/romix/scala/collection/concurrent/TestSerialization.java +++ b/third-party/triemap/src/test/java/org/opendaylight/yangtools/triemap/TestSerialization.java @@ -1,4 +1,4 @@ -package com.romix.scala.collection.concurrent; +package org.opendaylight.yangtools.triemap; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream;