JdkSerializerDeserializer implements SerializerDeserializer { @Override public Object deserialize(byte[] data) { if (data == null) { return null; } ClassLoader classLoader = sessionManager.getSessionClassLoader(); if (classLoader == null) { classLoader = Thread.currentThread().getContextClassLoader(); } try (ByteArrayInputStream in = new ByteArrayInputStream(data); ObjectInputStream is = new ClassLoaderObjectInputStream(classLoader, in)) { Object obj = is.readObject(); deserializedData.inc(data.length); deserializedHistogram.update(data.length); return obj; } catch (IOException | ClassNotFoundException e) { throw new IllegalStateException("Unable to deserialize object. See stacktrace for more information.", e); } }  @Override byte[] serialize(Object value); @Override Object deserialize(byte[] data); @Override void setSessionManager(SessionManager sessionManager);  }
@Test public void testDeserialize() { assertEquals(null, serializer.deserialize(null)); assertEquals("String", serializer.deserialize(serializedString)); }
@Test(expected=IllegalStateException.class) public void testDeserializeWithClassNotFoundException() throws ClassNotFoundException { ClassLoader cl = mock(ClassLoader.class); when(sessionManager.getSessionClassLoader()).thenReturn(cl); assertEquals(now, serializer.deserialize(serializedDate)); }