public void testSetup() { checkMaps(false); }
public void testMapKeySet() { map.keySet(); checkMaps(true); }
public void testMapEntrySet() { map.entrySet(); checkMaps(true); }
public void testMapPut() { map.put("ANOTHER", "VALUE"); checkMaps(true); }
public void testMapPutAll() { map.putAll(holyMap); checkMaps(true); }
@SuppressWarnings("unchecked") public void testSerializability() throws Exception { map.put("MORE", "STUFF"); checkMaps(true); ByteArrayOutputStream baos = new ByteArrayOutputStream(1024); ObjectOutputStream os = new ObjectOutputStream(baos); os.writeObject(map); os.close(); // Read it back in ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); ObjectInputStream ois = new ObjectInputStream(bais); ValueProtectingMap<String, Serializable> reloadedMap = (ValueProtectingMap<String, Serializable>) ois.readObject(); ois.close(); // Make sure it has the value assertEquals("Reloaded object not same.", "STUFF", reloadedMap.get("MORE")); } }
/** * Ensures that single, immutable values are given out as-is and * without affecting the backing storage */ public void testMapGetImmutable() { assertTrue("Immutable value instance incorrect", map.get("IMMUTABLE") == valueImmutable); checkMaps(false); }
public void testMapIsEmpty() { assertFalse(map.isEmpty()); checkMaps(false); }
public void testMapClear() { map.clear(); assertEquals("Map should be empty: ", 0, map.size()); checkMaps(true); }
public void testMapContainsValue() { assertTrue(map.containsValue(valueMutable)); assertFalse(map.containsValue("Dassie")); checkMaps(false); }
public void testMapContainsKey() { assertTrue(map.containsKey("LIST")); assertFalse(map.containsKey("LISTXXX")); checkMaps(false); }
/** * Ensures that single, immutable values are cloned before being given out * without affecting the backing storage */ public void testMapGetMutable() { TestMutable mutable = (TestMutable) map.get("MUTABLE"); assertFalse("Mutable value instance incorrect", mutable == valueMutable); checkMaps(false); // Modify the instance mutable.increment(); assertEquals("Backing mutable should not have changed: ", 0, valueMutable.i); }