Java Code Examples for com.helger.commons.mock.CommonsTestHelper#testGetClone()
The following examples show how to use
com.helger.commons.mock.CommonsTestHelper#testGetClone() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MutableBooleanTest.java From ph-commons with Apache License 2.0 | 6 votes |
@Test public void testMutableBoolean () { final MutableBoolean x = new MutableBoolean (false); assertFalse (x.booleanValue ()); assertSame (Boolean.FALSE, x.getAsBoolean ()); assertTrue (x.set (true).isChanged ()); assertTrue (x.booleanValue ()); assertSame (Boolean.TRUE, x.getAsBoolean ()); assertFalse (x.set (true).isChanged ()); assertTrue (x.booleanValue ()); assertSame (Boolean.TRUE, x.getAsBoolean ()); CommonsTestHelper.testDefaultImplementationWithEqualContentObject (new MutableBoolean (true), new MutableBoolean (true)); CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (new MutableBoolean (true), new MutableBoolean (false)); CommonsTestHelper.testGetClone (new MutableBoolean (true)); }
Example 2
Source File: CommonsWeakHashMapTest.java From ph-commons with Apache License 2.0 | 6 votes |
@Test public void testBasic () { final ICommonsMap <String, String> aTest = new CommonsWeakHashMap <> (); aTest.put ("aaa", "bla"); aTest.put ("bbb", "blb"); aTest.put ("ccc", "blc"); final ICommonsOrderedSet <String> aSortedKeys = aTest.getSortedByKey (Comparator.naturalOrder ()).copyOfKeySet (); assertEquals ("aaa", aSortedKeys.getAtIndex (0)); assertEquals ("bbb", aSortedKeys.getAtIndex (1)); assertEquals ("ccc", aSortedKeys.getAtIndex (2)); if (false) CommonsTestHelper.testDefaultSerialization (aTest); CommonsTestHelper.testGetClone (aTest); }
Example 3
Source File: CommonsHashMapTest.java From ph-commons with Apache License 2.0 | 6 votes |
@Test public void testBasic () { final ICommonsMap <String, String> aTest = new CommonsHashMap <> (); aTest.put ("aaa", "bla"); aTest.put ("bbb", "blb"); aTest.put ("ccc", "blc"); final ICommonsOrderedSet <String> aSortedKeys = aTest.getSortedByKey (Comparator.naturalOrder ()).copyOfKeySet (); assertEquals ("aaa", aSortedKeys.getAtIndex (0)); assertEquals ("bbb", aSortedKeys.getAtIndex (1)); assertEquals ("ccc", aSortedKeys.getAtIndex (2)); CommonsTestHelper.testDefaultSerialization (aTest); CommonsTestHelper.testGetClone (aTest); assertEquals (3, aTest.size ()); aTest.removeIf (e -> !e.getKey ().startsWith ("c")); assertEquals (1, aTest.size ()); }
Example 4
Source File: HttpHeaderMapTest.java From ph-commons with Apache License 2.0 | 6 votes |
@Test public void testSetAllHeadersPrefilled () { final HttpHeaderMap h = new HttpHeaderMap (); h.addHeader ("key1", "val1"); h.addHeader ("key1", "val2"); h.addHeader ("KEY1", "val3"); final HttpHeaderMap h2 = new HttpHeaderMap (); h2.addIntHeader ("key2", 42); h2.setAllHeaders (h); CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (h2, h); assertEquals (4, h2.getAllHeaderLines (true).size ()); assertEquals ("key2: 42", h2.getAllHeaderLines (true).get (0)); assertEquals ("key1: val1", h2.getAllHeaderLines (true).get (1)); assertEquals ("key1: val2", h2.getAllHeaderLines (true).get (2)); assertEquals ("key1: val3", h2.getAllHeaderLines (true).get (3)); CommonsTestHelper.testGetClone (h); CommonsTestHelper.testDefaultSerialization (h); CommonsTestHelper.testGetClone (h2); CommonsTestHelper.testDefaultSerialization (h2); }
Example 5
Source File: CommonsLinkedHashSetTest.java From ph-commons with Apache License 2.0 | 6 votes |
@Test public void testBasic () { final ICommonsSet <String> aTest = new CommonsLinkedHashSet <> (); aTest.add ("aaa"); aTest.add ("bbb"); aTest.add ("ccc"); final ICommonsList <String> aSortedKeys = aTest.getSorted (Comparator.naturalOrder ()); assertEquals ("aaa", aSortedKeys.getAtIndex (0)); assertEquals ("bbb", aSortedKeys.getAtIndex (1)); assertEquals ("ccc", aSortedKeys.getAtIndex (2)); CommonsTestHelper.testDefaultSerialization (aTest); CommonsTestHelper.testGetClone (aTest); }
Example 6
Source File: CommonsTreeMapTest.java From ph-commons with Apache License 2.0 | 6 votes |
@Test public void testBasic () { final ICommonsMap <String, String> aTest = new CommonsTreeMap <> (); aTest.put ("aaa", "bla"); aTest.put ("bbb", "blb"); aTest.put ("ccc", "blc"); final ICommonsOrderedSet <String> aSortedKeys = aTest.getSortedByKey (Comparator.naturalOrder ()).copyOfKeySet (); assertEquals ("aaa", aSortedKeys.getAtIndex (0)); assertEquals ("bbb", aSortedKeys.getAtIndex (1)); assertEquals ("ccc", aSortedKeys.getAtIndex (2)); CommonsTestHelper.testDefaultSerialization (aTest); CommonsTestHelper.testGetClone (aTest); }
Example 7
Source File: CommonsConcurrentHashMapTest.java From ph-commons with Apache License 2.0 | 6 votes |
@Test public void testBasic () { final ICommonsMap <String, String> aTest = new CommonsConcurrentHashMap <> (); aTest.put ("aaa", "bla"); aTest.put ("bbb", "blb"); aTest.put ("ccc", "blc"); final ICommonsSet <String> aSortedKeys = aTest.getSortedByKey (Comparator.naturalOrder ()).copyOfKeySet (); assertEquals ("aaa", aSortedKeys.getAtIndex (0)); assertEquals ("bbb", aSortedKeys.getAtIndex (1)); assertEquals ("ccc", aSortedKeys.getAtIndex (2)); CommonsTestHelper.testDefaultSerialization (aTest); CommonsTestHelper.testGetClone (aTest); }
Example 8
Source File: SoftLinkedHashMapTest.java From ph-commons with Apache License 2.0 | 5 votes |
@Test public void testEntrySetToArray () { final SoftLinkedHashMap <Integer, BigDecimal> aMap = new SoftLinkedHashMap <> (17); aMap.put (Integer.valueOf (1), BigDecimal.TEN); assertEquals (1, aMap.entrySet ().size ()); assertEquals (1, aMap.entrySet ().toArray ().length); assertEquals (1, aMap.entrySet ().toArray (new Map.Entry [0]).length); assertEquals (1, aMap.entrySet ().toArray (new Map.Entry [5]).length); assertEquals (5, aMap.entrySet ().toArray (new MapEntry [5]).length); CommonsTestHelper.testGetClone (aMap); }
Example 9
Source File: CommonsArrayListTest.java From ph-commons with Apache License 2.0 | 5 votes |
@Test public void testBasic () { final ICommonsList <String> aTest = new CommonsArrayList <> (); assertTrue (aTest.isEmpty ()); aTest.add ("aaa"); aTest.add ("bbb"); aTest.add ("ccc"); CommonsTestHelper.testDefaultSerialization (aTest); CommonsTestHelper.testGetClone (aTest); }
Example 10
Source File: CommonsVectorTest.java From ph-commons with Apache License 2.0 | 5 votes |
@Test public void testBasic () { final ICommonsList <String> aTest = new CommonsVector <> (); assertTrue (aTest.isEmpty ()); aTest.add ("aaa"); aTest.add ("bbb"); aTest.add ("ccc"); CommonsTestHelper.testDefaultSerialization (aTest); CommonsTestHelper.testGetClone (aTest); }
Example 11
Source File: HttpHeaderMapTest.java From ph-commons with Apache License 2.0 | 5 votes |
@Test public void testAddAllHeadersPrefilledDifferentCasing () { final HttpHeaderMap h = new HttpHeaderMap (); // First header defines the casing! h.addHeader ("Key1", "val1"); h.addHeader ("KEY1", "val2"); h.addHeader ("KEY1", "val3"); final HttpHeaderMap h2 = new HttpHeaderMap (); h2.addIntHeader ("key2", 42); h2.addAllHeaders (h); CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (h2, h); assertEquals (4, h2.getAllHeaderLines (true).size ()); assertEquals ("key2: 42", h2.getAllHeaderLines (true).get (0)); assertEquals ("Key1: val1", h2.getAllHeaderLines (true).get (1)); assertEquals ("Key1: val2", h2.getAllHeaderLines (true).get (2)); assertEquals ("Key1: val3", h2.getAllHeaderLines (true).get (3)); assertEquals (4, h2.getAllHeaderLines (false).size ()); assertEquals ("key2: 42", h2.getAllHeaderLines (false).get (0)); assertEquals ("Key1: val1", h2.getAllHeaderLines (false).get (1)); assertEquals ("Key1: val2", h2.getAllHeaderLines (false).get (2)); assertEquals ("Key1: val3", h2.getAllHeaderLines (false).get (3)); CommonsTestHelper.testGetClone (h); CommonsTestHelper.testDefaultSerialization (h); CommonsTestHelper.testGetClone (h2); CommonsTestHelper.testDefaultSerialization (h2); }
Example 12
Source File: HttpHeaderMapTest.java From ph-commons with Apache License 2.0 | 5 votes |
@Test public void testAddAllHeadersPrefilled () { final HttpHeaderMap h = new HttpHeaderMap (); h.addHeader ("key1", "val1"); h.addHeader ("KEY1", "val2"); h.addHeader ("KEY1", "val3"); final HttpHeaderMap h2 = new HttpHeaderMap (); h2.addIntHeader ("key2", 42); h2.addAllHeaders (h); CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (h2, h); assertEquals (4, h2.getAllHeaderLines (true).size ()); assertEquals ("key2: 42", h2.getAllHeaderLines (true).get (0)); assertEquals ("key1: val1", h2.getAllHeaderLines (true).get (1)); assertEquals ("key1: val2", h2.getAllHeaderLines (true).get (2)); assertEquals ("key1: val3", h2.getAllHeaderLines (true).get (3)); assertEquals (4, h2.getAllHeaderLines (false).size ()); assertEquals ("key2: 42", h2.getAllHeaderLines (false).get (0)); assertEquals ("key1: val1", h2.getAllHeaderLines (false).get (1)); assertEquals ("key1: val2", h2.getAllHeaderLines (false).get (2)); assertEquals ("key1: val3", h2.getAllHeaderLines (false).get (3)); CommonsTestHelper.testGetClone (h); CommonsTestHelper.testDefaultSerialization (h); CommonsTestHelper.testGetClone (h2); CommonsTestHelper.testDefaultSerialization (h2); }
Example 13
Source File: CommonsCopyOnWriteArrayListTest.java From ph-commons with Apache License 2.0 | 5 votes |
@Test public void testBasic () { final ICommonsList <String> aTest = new CommonsCopyOnWriteArrayList <> (); assertTrue (aTest.isEmpty ()); aTest.add ("aaa"); aTest.add ("bbb"); aTest.add ("ccc"); CommonsTestHelper.testDefaultSerialization (aTest); CommonsTestHelper.testGetClone (aTest); }
Example 14
Source File: HttpHeaderMapTest.java From ph-commons with Apache License 2.0 | 5 votes |
@Test public void testSimpleValue () { final HttpHeaderMap h = new HttpHeaderMap (); h.addHeader ("key1", "val1"); assertFalse (h.isEmpty ()); assertTrue (h.isNotEmpty ()); assertEquals (1, h.size ()); assertNotNull (h.getAllHeaderLines (true)); assertEquals (1, h.getAllHeaderLines (true).size ()); assertEquals ("key1: val1", h.getAllHeaderLines (true).getFirst ()); assertNotNull (h.getAllHeaderLines (false)); assertEquals (1, h.getAllHeaderLines (false).size ()); assertEquals ("key1: val1", h.getAllHeaderLines (false).getFirst ()); assertNotNull (h.getAllHeaderNames ()); assertEquals (1, h.getAllHeaderNames ().size ()); assertEquals ("key1", h.getAllHeaderNames ().getFirst ()); assertNotNull (h.getAllHeaders ()); assertEquals (1, h.getAllHeaders ().size ()); assertEquals ("key1", h.getAllHeaders ().getFirstKey ()); assertNotNull (h.getAllHeaderValues ("key1")); assertEquals (1, h.getAllHeaderValues ("key1").size ()); assertEquals ("val1", h.getAllHeaderValues ("key1").getFirst ()); CommonsTestHelper.testGetClone (h); CommonsTestHelper.testDefaultSerialization (h); }
Example 15
Source File: CommonsLinkedListTest.java From ph-commons with Apache License 2.0 | 5 votes |
@Test public void testBasic () { final ICommonsList <String> aTest = new CommonsLinkedList <> (); assertTrue (aTest.isEmpty ()); aTest.add ("aaa"); aTest.add ("bbb"); aTest.add ("ccc"); CommonsTestHelper.testDefaultSerialization (aTest); CommonsTestHelper.testGetClone (aTest); }
Example 16
Source File: CommonsEnumMapTest.java From ph-commons with Apache License 2.0 | 5 votes |
@Test public void testBasic () { final ICommonsMap <EChange, String> aTest = new CommonsEnumMap <> (EChange.class); aTest.put (EChange.UNCHANGED, "blb"); aTest.put (EChange.CHANGED, "bla"); final ICommonsOrderedSet <EChange> aSortedKeys = aTest.getSortedByKey (Comparator.naturalOrder ()).copyOfKeySet (); assertEquals (EChange.CHANGED, aSortedKeys.getAtIndex (0)); assertEquals (EChange.UNCHANGED, aSortedKeys.getAtIndex (1)); CommonsTestHelper.testDefaultSerialization (aTest); CommonsTestHelper.testGetClone (aTest); }
Example 17
Source File: HttpHeaderMapTest.java From ph-commons with Apache License 2.0 | 4 votes |
@Test public void testMultipleSimpleValues () { final HttpHeaderMap h = new HttpHeaderMap (); h.addHeader ("key1", "val1"); h.addHeader ("key2", "val2"); h.addHeader ("key3", "val3"); assertFalse (h.isEmpty ()); assertTrue (h.isNotEmpty ()); assertEquals (3, h.size ()); assertNotNull (h.getAllHeaderLines (true)); assertEquals (3, h.getAllHeaderLines (true).size ()); assertEquals ("key1: val1", h.getAllHeaderLines (true).getFirst ()); assertEquals ("key2: val2", h.getAllHeaderLines (true).get (1)); assertEquals ("key3: val3", h.getAllHeaderLines (true).get (2)); assertNotNull (h.getAllHeaderLines (false)); assertEquals (3, h.getAllHeaderLines (false).size ()); assertEquals ("key1: val1", h.getAllHeaderLines (false).getFirst ()); assertEquals ("key2: val2", h.getAllHeaderLines (false).get (1)); assertEquals ("key3: val3", h.getAllHeaderLines (false).get (2)); assertNotNull (h.getAllHeaderNames ()); assertEquals (3, h.getAllHeaderNames ().size ()); assertTrue (h.getAllHeaderNames ().contains ("key1")); assertTrue (h.getAllHeaderNames ().contains ("key2")); assertTrue (h.getAllHeaderNames ().contains ("key3")); assertNotNull (h.getAllHeaders ()); assertEquals (3, h.getAllHeaders ().size ()); assertTrue (h.getAllHeaders ().containsKey ("key1")); assertTrue (h.getAllHeaders ().containsKey ("key2")); assertTrue (h.getAllHeaders ().containsKey ("key3")); assertNotNull (h.getAllHeaderValues ("key1")); assertEquals (1, h.getAllHeaderValues ("key1").size ()); assertEquals ("val1", h.getAllHeaderValues ("key1").getFirst ()); assertNotNull (h.getAllHeaderValues ("key2")); assertEquals (1, h.getAllHeaderValues ("key2").size ()); assertEquals ("val2", h.getAllHeaderValues ("key2").getFirst ()); assertNotNull (h.getAllHeaderValues ("key3")); assertEquals (1, h.getAllHeaderValues ("key3").size ()); assertEquals ("val3", h.getAllHeaderValues ("key3").getFirst ()); assertNotNull (h.getAllHeaderValues ("KEY1")); assertEquals (1, h.getAllHeaderValues ("kEy1").size ()); assertEquals ("val1", h.getAllHeaderValues ("keY1").getFirst ()); CommonsTestHelper.testGetClone (h); CommonsTestHelper.testDefaultSerialization (h); }
Example 18
Source File: MutableLongTest.java From ph-commons with Apache License 2.0 | 4 votes |
@Test public void testMutableLong () { final MutableLong x = new MutableLong (0); assertEquals (0, x.longValue ()); assertEquals (Long.valueOf (0), x.getAsLong ()); assertFalse (x.isNot0 ()); assertTrue (x.is0 ()); x.inc (); assertEquals (1, x.longValue ()); assertNotEquals (x.hashCode (), x.longValue ()); x.inc (5); assertEquals (6, x.longValue ()); assertNotEquals (x.hashCode (), x.longValue ()); x.inc (-2); assertEquals (4, x.longValue ()); assertNotEquals (x.hashCode (), x.longValue ()); x.dec (); assertEquals (3, x.longValue ()); assertFalse (x.isEven ()); assertNotEquals (x.hashCode (), x.longValue ()); x.dec (5); assertEquals (-2, x.longValue ()); assertTrue (x.isNot0 ()); assertFalse (x.is0 ()); assertTrue (x.isEven ()); assertNotEquals (x.hashCode (), x.longValue ()); assertTrue (x.set (4711).isChanged ()); assertFalse (x.set (4711).isChanged ()); assertFalse (x.isEven ()); assertEquals (4711, x.longValue ()); assertEquals (-1, new MutableLong (4).compareTo (new MutableLong (5))); assertEquals (0, new MutableLong (5).compareTo (new MutableLong (5))); assertEquals (+1, new MutableLong (6).compareTo (new MutableLong (5))); assertNotNull (x.toString ()); assertTrue (x.toString ().contains (Long.toString (x.longValue ()))); x.set (-1); assertFalse (x.isGT0 ()); x.set (0); assertFalse (x.isGT0 ()); x.set (1); assertTrue (x.isGT0 ()); CommonsTestHelper.testDefaultImplementationWithEqualContentObject (new MutableLong (-7000), new MutableLong (-7000)); CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (new MutableLong (600), new MutableLong (700)); CommonsTestHelper.testGetClone (new MutableLong (Long.MIN_VALUE)); }
Example 19
Source File: MutableDoubleTest.java From ph-commons with Apache License 2.0 | 4 votes |
@Test public void testMutableDouble () { final MutableDouble x = new MutableDouble (0); assertEquals (0, x.doubleValue (), DELTA); assertEquals (Double.valueOf (0), x.getAsDouble ()); assertFalse (x.isNot0 ()); assertTrue (x.is0 ()); x.inc (); assertEquals (1, x.doubleValue (), DELTA); assertNotEquals (x.hashCode (), x.doubleValue (), DELTA); x.inc (5); assertEquals (6, x.doubleValue (), DELTA); assertNotEquals (x.hashCode (), x.doubleValue (), DELTA); x.inc (-2); assertEquals (4, x.doubleValue (), DELTA); assertNotEquals (x.hashCode (), x.doubleValue (), DELTA); x.dec (); assertEquals (3, x.doubleValue (), DELTA); assertNotEquals (x.hashCode (), x.doubleValue (), DELTA); x.dec (5); assertEquals (-2, x.doubleValue (), DELTA); assertTrue (x.isNot0 ()); assertFalse (x.is0 ()); assertNotEquals (x.hashCode (), x.doubleValue (), DELTA); assertTrue (x.set (4711).isChanged ()); assertFalse (x.set (4711).isChanged ()); assertEquals (4711, x.doubleValue (), DELTA); assertEquals (-1, new MutableDouble (4).compareTo (new MutableDouble (5))); assertEquals (0, new MutableDouble (5).compareTo (new MutableDouble (5))); assertEquals (+1, new MutableDouble (6).compareTo (new MutableDouble (5))); assertNotNull (x.toString ()); assertTrue (x.toString ().contains (Double.toString (x.doubleValue ()))); x.set (-1); assertFalse (x.isGT0 ()); x.set (0); assertFalse (x.isGT0 ()); x.set (1); assertTrue (x.isGT0 ()); CommonsTestHelper.testDefaultImplementationWithEqualContentObject (new MutableDouble (3.1234), new MutableDouble (3.1234)); CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (new MutableDouble (3.1234), new MutableDouble (3.123)); CommonsTestHelper.testGetClone (new MutableDouble (47.11)); }
Example 20
Source File: MutableByteTest.java From ph-commons with Apache License 2.0 | 4 votes |
@Test public void testMutableByte () { final MutableByte x = new MutableByte (0); assertEquals (0, x.byteValue ()); assertEquals (Byte.valueOf ((byte) 0), x.getAsByte ()); assertFalse (x.isNot0 ()); assertTrue (x.is0 ()); x.inc (); assertEquals (1, x.byteValue ()); assertNotEquals (x.hashCode (), x.byteValue ()); x.inc (5); assertEquals (6, x.byteValue ()); assertNotEquals (x.hashCode (), x.byteValue ()); x.inc (-2); assertEquals (4, x.byteValue ()); assertNotEquals (x.hashCode (), x.byteValue ()); x.dec (); assertEquals (3, x.byteValue ()); assertFalse (x.isEven ()); assertNotEquals (x.hashCode (), x.byteValue ()); x.dec (5); assertEquals (-2, x.byteValue ()); assertTrue (x.isNot0 ()); assertFalse (x.is0 ()); assertTrue (x.isEven ()); assertNotEquals (x.hashCode (), x.byteValue ()); assertTrue (x.set (255).isChanged ()); assertFalse (x.set (255).isChanged ()); assertFalse (x.isEven ()); assertEquals (-1, x.byteValue ()); assertTrue (x.set (0).isChanged ()); assertEquals (0, x.byteValue ()); assertTrue (x.set (127).isChanged ()); assertEquals (127, x.byteValue ()); assertTrue (x.set (128).isChanged ()); assertEquals (-128, x.byteValue ()); assertTrue (x.set (255).isChanged ()); assertEquals (-1, x.byteValue ()); assertTrue (x.set (256).isChanged ()); assertEquals (0, x.byteValue ()); assertTrue (x.set (257).isChanged ()); assertEquals (1, x.byteValue ()); assertEquals (-1, new MutableByte (4).compareTo (new MutableByte (5))); assertEquals (0, new MutableByte (5).compareTo (new MutableByte (5))); assertEquals (+1, new MutableByte (6).compareTo (new MutableByte (5))); assertNotNull (x.toString ()); assertTrue (x.toString ().contains (Integer.toString (x.byteValue ()))); x.set (-1); assertFalse (x.isGT0 ()); x.set (0); assertFalse (x.isGT0 ()); x.set (1); assertTrue (x.isGT0 ()); CommonsTestHelper.testDefaultImplementationWithEqualContentObject (new MutableByte (-7), new MutableByte (-7)); CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (new MutableByte (6), new MutableByte (7)); CommonsTestHelper.testGetClone (new MutableByte (Integer.MAX_VALUE)); }