@Test public void canBeReconstitutedFromByteArray() throws Exception { String key = impl.getStorageKey(); HttpCacheEntry entry = impl.getHttpCacheEntry(); byte[] bytes = impl.toByteArray(); impl = new MemcachedCacheEntryImpl(); impl.set(bytes); assertEquals(key, impl.getStorageKey()); assertEquivalent(entry, impl.getHttpCacheEntry()); }
@Test(expected = MemcachedSerializationException.class) public void cannotReconstituteFromGarbage() { impl = new MemcachedCacheEntryImpl(); byte[] bytes = HttpTestUtils.getRandomBytes(128); impl.set(bytes); }