Package de.javakaffee.web.msm

Examples of de.javakaffee.web.msm.SessionAttributesTranscoder


    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 );
    }
View Full Code Here

TOP

Related Classes of de.javakaffee.web.msm.SessionAttributesTranscoder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.