X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=common%2Futil%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Futil%2FSharedSingletonMapTest.java;h=58064e87bc9369a2997040aa8a3f306ff194d4e1;hb=24d06767f3a0ead8152a745fb05eda1d4a37ba77;hp=3e0bb753dfbead2d027e3808f964faa0695d1628;hpb=136f1755f17cfe70dfe854e9d886ac0eedf97c19;p=yangtools.git diff --git a/common/util/src/test/java/org/opendaylight/yangtools/util/SharedSingletonMapTest.java b/common/util/src/test/java/org/opendaylight/yangtools/util/SharedSingletonMapTest.java index 3e0bb753df..58064e87bc 100644 --- a/common/util/src/test/java/org/opendaylight/yangtools/util/SharedSingletonMapTest.java +++ b/common/util/src/test/java/org/opendaylight/yangtools/util/SharedSingletonMapTest.java @@ -11,6 +11,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; +import com.google.common.collect.ImmutableMap; import java.util.Collections; import java.util.Map; import java.util.Set; @@ -18,7 +19,7 @@ import org.junit.Test; public class SharedSingletonMapTest { private static UnmodifiableMapPhase create() { - return SharedSingletonMap.of("k1", "v1"); + return SharedSingletonMap.orderedOf("k1", "v1"); } @Test @@ -59,12 +60,39 @@ public class SharedSingletonMapTest { assertFalse(m.equals(Collections.singletonMap("k1", null))); assertFalse(m.equals(Collections.singletonMap(null, "v1"))); assertFalse(m.equals(Collections.singletonMap("k1", "v2"))); + assertFalse(m.equals(ImmutableMap.of("k1", "v1", "k2", "v2"))); final Set set = m.keySet(); assertTrue(set instanceof SingletonSet); assertTrue(set.contains("k1")); } + @Test + public void testOrderedCopyOf() { + final Map t = Collections.singletonMap("k1", "v1"); + final Map m = SharedSingletonMap.orderedCopyOf(t); + assertTrue(t.equals(m)); + assertTrue(m.equals(t)); + } + + @Test + public void testUnorderedCopyOf() { + final Map t = Collections.singletonMap("k1", "v1"); + final Map m = SharedSingletonMap.unorderedCopyOf(t); + assertTrue(t.equals(m)); + assertTrue(m.equals(t)); + } + + @Test(expected=IllegalArgumentException.class) + public void testEmptyOrderedCopyOf() { + SharedSingletonMap.orderedCopyOf(ImmutableMap.of()); + } + + @Test(expected=IllegalArgumentException.class) + public void testEmptyUnorderedCopyOf() { + SharedSingletonMap.unorderedCopyOf(ImmutableMap.of()); + } + @Test(expected=UnsupportedOperationException.class) public void testClear() { create().clear();