use of org.apache.ibatis.reflection.factory.DefaultObjectFactory in project mybatis-3 by mybatis.
the class SerializableProxyTest method shouldSerializeAProxyForABeanWithoutDefaultConstructorAndUnloadedProperties.
@Test
public void shouldSerializeAProxyForABeanWithoutDefaultConstructorAndUnloadedProperties() throws Exception {
AuthorWithoutDefaultConstructor author = new AuthorWithoutDefaultConstructor(999, "someone", "!@#@!#!@#", "someone@somewhere.com", "blah", Section.NEWS);
ArrayList<Class<?>> argTypes = new ArrayList<Class<?>>();
argTypes.add(Integer.class);
argTypes.add(String.class);
argTypes.add(String.class);
argTypes.add(String.class);
argTypes.add(String.class);
argTypes.add(Section.class);
ArrayList<Object> argValues = new ArrayList<Object>();
argValues.add(999);
argValues.add("someone");
argValues.add("!@#@!#!@#");
argValues.add("someone@somewhere.com");
argValues.add("blah");
argValues.add(Section.NEWS);
ResultLoaderMap loader = new ResultLoaderMap();
loader.addLoader("id", null, null);
Object proxy = proxyFactory.createProxy(author, loader, new Configuration(), new DefaultObjectFactory(), argTypes, argValues);
Object proxy2 = deserialize(serialize((Serializable) proxy));
assertEquals(author, proxy2);
}
use of org.apache.ibatis.reflection.factory.DefaultObjectFactory in project mybatis-3 by mybatis.
the class SerializableProxyTest method shouldLetReadALoadedPropertyAfterSerialization.
@Test
public void shouldLetReadALoadedPropertyAfterSerialization() throws Exception {
Object proxy = proxyFactory.createProxy(author, new ResultLoaderMap(), new Configuration(), new DefaultObjectFactory(), new ArrayList<Class<?>>(), new ArrayList<Object>());
byte[] ser = serialize((Serializable) proxy);
Author author2 = (Author) deserialize(ser);
assertEquals(999, author2.getId());
}
use of org.apache.ibatis.reflection.factory.DefaultObjectFactory in project mybatis-3 by mybatis.
the class SerializableProxyTest method shouldSerializeAProxyForABeanWithoutDefaultConstructor.
@Test
public void shouldSerializeAProxyForABeanWithoutDefaultConstructor() throws Exception {
AuthorWithoutDefaultConstructor author = new AuthorWithoutDefaultConstructor(999, "someone", "!@#@!#!@#", "someone@somewhere.com", "blah", Section.NEWS);
ArrayList<Class<?>> argTypes = new ArrayList<Class<?>>();
argTypes.add(Integer.class);
argTypes.add(String.class);
argTypes.add(String.class);
argTypes.add(String.class);
argTypes.add(String.class);
argTypes.add(Section.class);
ArrayList<Object> argValues = new ArrayList<Object>();
argValues.add(999);
argValues.add("someone");
argValues.add("!@#@!#!@#");
argValues.add("someone@somewhere.com");
argValues.add("blah");
argValues.add(Section.NEWS);
Object proxy = proxyFactory.createProxy(author, new ResultLoaderMap(), new Configuration(), new DefaultObjectFactory(), argTypes, argValues);
Object proxy2 = deserialize(serialize((Serializable) proxy));
assertEquals(author, proxy2);
}
use of org.apache.ibatis.reflection.factory.DefaultObjectFactory in project mybatis-3 by mybatis.
the class SerializableProxyTest method shouldSerizaliceAFullLoadedObjectToOriginalClass.
@Test
public void shouldSerizaliceAFullLoadedObjectToOriginalClass() throws Exception {
Object proxy = proxyFactory.createProxy(author, new ResultLoaderMap(), new Configuration(), new DefaultObjectFactory(), new ArrayList<Class<?>>(), new ArrayList<Object>());
Object proxy2 = deserialize(serialize((Serializable) proxy));
assertEquals(author.getClass(), proxy2.getClass());
}
Aggregations