@Test public void getFromNonExistingNameSpace() { assertEquals(0, store.sizeOfNamespace(NAMESPACE1)); Serializable retrievedValue = store.get(NAMESPACE1, KEY1); assertNull(retrievedValue); }
@Test public void deleteFromNonExistingNamespace() { assertEquals(0, store.countNamespaces()); assertEquals(0, store.sizeOfNamespace(NAMESPACE1)); store.delete(NAMESPACE1, KEY1); assertEquals(0, store.countNamespaces()); assertEquals(0, store.sizeOfNamespace(NAMESPACE1)); }
@Test public void putNull() { Serializable value = null; assertEquals(0, store.countNamespaces()); store.put(NAMESPACE1, KEY1, value); assertEquals(1, store.countNamespaces()); assertEquals(1, store.sizeOfNamespace(NAMESPACE1)); }
@Test public void putToEmptyStoreCreatesNamespace() { Serializable value = "value"; assertEquals(0, store.countNamespaces()); store.put(NAMESPACE1, KEY1, value); assertEquals(1, store.countNamespaces()); assertEquals(1, store.sizeOfNamespace(NAMESPACE1)); }
@Test public void deleteExistingKey() { Serializable value = "value"; store.put(NAMESPACE1, KEY1, value); assertEquals(1, store.sizeOfNamespace(NAMESPACE1)); store.delete(NAMESPACE1, KEY1); assertEquals(0, store.sizeOfNamespace(NAMESPACE1)); }
@Test public void getNonExistingKey() { Serializable value = "value"; store.put(NAMESPACE1, KEY1, value); assertEquals(1, store.sizeOfNamespace(NAMESPACE1)); Serializable retrievedValue = store.get(NAMESPACE1, KEY2); assertNull(retrievedValue); }
@Test public void getReturnsCopyOfOriginalValue() { Serializable value = "value"; store.put(NAMESPACE1, KEY1, value); Serializable retrievedValue = store.get(NAMESPACE1, KEY1); assertEquals(value, retrievedValue); assertNotSame(value, retrievedValue); }
@Test public void getExistingKey() { Serializable value = "value"; store.put(NAMESPACE1, KEY1, value); Serializable retrievedValue = store.get(NAMESPACE1, KEY1); assertNotNull(retrievedValue); assertEquals(value, retrievedValue); }
@Test public void ensurePutStoresCopyOfValue() { ArrayList<Integer> value = new ArrayList<>(); store.put(NAMESPACE1, KEY1, value); value.add(42); assertFalse(value.isEmpty()); ArrayList storedValue = (ArrayList) store.get(NAMESPACE1, KEY1); assertTrue(storedValue.isEmpty()); }
@Test public void putDifferentKeysToSameNamespace() { Serializable value = "value"; assertEquals(0, store.countNamespaces()); store.put(NAMESPACE1, KEY1, value); store.put(NAMESPACE1, KEY2, value); assertEquals(1, store.countNamespaces()); assertEquals(2, store.sizeOfNamespace(NAMESPACE1)); }