Package org.neo4j.smack.serialization

Source Code of org.neo4j.smack.serialization.TestDeserializationStrategy

package org.neo4j.smack.serialization;

import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertThat;

import java.io.ByteArrayInputStream;
import java.io.InputStream;

import org.codehaus.jackson.JsonFactory;
import org.codehaus.jackson.map.ObjectMapper;
import org.junit.Test;

public class TestDeserializationStrategy {

    @Test
    public void testSimpleDeserializationStrategy() throws Exception
    {
        InputStream in = new ByteArrayInputStream("{\"firstkey\":1,\"secondkey\":2}".getBytes("UTF-8"));
        JsonDeserializer d = new JsonDeserializer(new JsonFactory(new ObjectMapper()), in);
       
        DeserializationStrategy<Object> objectStrategy = new DeserializationStrategy<Object>() {
            @Override
            public Object deserialize(Deserializer in)
                    throws DeserializationException
            {
                return in.readObject();
            }
        };
       
        assertThat(objectStrategy.deserialize(d),not(nullValue()));
    }
   
}
TOP

Related Classes of org.neo4j.smack.serialization.TestDeserializationStrategy

TOP
Copyright © 2018 www.massapi.com. 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.