public void testDeserializationError() {
// Create a class with one simple field:
final ClassLoader loaderForCustomClassInVersion1 = ClassGenerationUtil.makeClassLoaderForCustomClass( this.getClass().getClassLoader(), TEST_TYPE_CLASS_NAME, "field1" );
final Object value = makeValueInstance( loaderForCustomClassInVersion1 );
final SessionAttributesTranscoder transcoder = new KryoTranscoderFactory().createTranscoder( loaderForCustomClassInVersion1 );
// serialize one instance
final MemcachedBackupSession memcachedBackupSession = new MemcachedBackupSession();
final Map<String, Object> attributes = new HashMap<String, Object>();
attributes.put( "test", value );
byte[] data = transcoder.serializeAttributes( memcachedBackupSession, attributes );
final Map<String, Object> deserializeAttributes = transcoder.deserializeAttributes( data );
final Object actual = deserializeAttributes.get( "test" );
assertNotNull(actual);
assertDeepEquals(actual, value);
// create same class with second field
final ClassLoader loaderForCustomClassInVersion2 = ClassGenerationUtil.makeClassLoaderForCustomClass( this.getClass().getClassLoader(), TEST_TYPE_CLASS_NAME, "field1", "field2" );
final SessionAttributesTranscoder secondTranscoder = new KryoTranscoderFactory().createTranscoder( loaderForCustomClassInVersion2 );
// this should lead to an exception
secondTranscoder.deserializeAttributes( data );
}