@Test(enabled = true) public void testDeserializeHibernateCollection() { final MemcachedBackupSessionManager manager = createManager(); final Set<Animal> animals = new HashSet<Animal>(Arrays.asList(new Animal("cat"))); final Person person = new Person("foo bar", animals); final Long personId = createPerson(person); final Person foundPerson = findPerson(personId); LOG.info("person: " + person.toString()); LOG.info("found: " + foundPerson.toString()); TestUtils.assertDeepEquals(person, foundPerson); final TranscoderService transcoderService = new TranscoderService(createTranscoder(manager)); final MemcachedBackupSession session = createSession(manager, "123456789"); session.setAttribute("person", foundPerson); final byte[] data = transcoderService.serialize(session); final MemcachedBackupSession deserialized = transcoderService.deserialize(data, null, manager); final Person deserializedPerson = (Person) deserialized.getAttribute("person"); TestUtils.assertDeepEquals(foundPerson, deserializedPerson); }
private static MemcachedBackupSession createSession( final MemcachedBackupSessionManager manager, final String id) { final MemcachedBackupSession session = manager.createEmptySession(); session.setId(id); session.setValid(true); return session; }