use of org.apache.ibatis.reflection.factory.DefaultObjectFactory in project mybatis-3 by mybatis.
the class CglibProxyTest method shouldCreateAProxyForAPartiallyLoadedBean.
@Test
public void shouldCreateAProxyForAPartiallyLoadedBean() throws Exception {
ResultLoaderMap loader = new ResultLoaderMap();
loader.addLoader("id", null, null);
Object proxy = proxyFactory.createProxy(author, loader, new Configuration(), new DefaultObjectFactory(), new ArrayList<Class<?>>(), new ArrayList<Object>());
Author author2 = (Author) deserialize(serialize((Serializable) proxy));
assertTrue(author2 instanceof Factory);
}
use of org.apache.ibatis.reflection.factory.DefaultObjectFactory in project mybatis-3 by mybatis.
the class CglibProxyTest method shouldLetCallALoadedProperty.
@Test
public void shouldLetCallALoadedProperty() throws Exception {
Author author2 = (Author) ((CglibProxyFactory) proxyFactory).createDeserializationProxy(author, new HashMap<String, ResultLoaderMap.LoadPair>(), new DefaultObjectFactory(), new ArrayList<Class<?>>(), new ArrayList<Object>());
assertEquals(999, author2.getId());
}
use of org.apache.ibatis.reflection.factory.DefaultObjectFactory in project mybatis-3 by mybatis.
the class CglibProxyTest method shouldFailCallingAnUnloadedProperty.
@Test(expected = ExecutorException.class)
public void shouldFailCallingAnUnloadedProperty() throws Exception {
// yes, it must go in uppercase
HashMap<String, ResultLoaderMap.LoadPair> unloadedProperties = new HashMap<String, ResultLoaderMap.LoadPair>();
unloadedProperties.put("ID", null);
Author author2 = (Author) ((CglibProxyFactory) proxyFactory).createDeserializationProxy(author, unloadedProperties, new DefaultObjectFactory(), new ArrayList<Class<?>>(), new ArrayList<Object>());
author2.getId();
}
use of org.apache.ibatis.reflection.factory.DefaultObjectFactory in project mybatis-3 by mybatis.
the class JavassistProxyTest method shouldLetCallALoadedProperty.
@Test
public void shouldLetCallALoadedProperty() throws Exception {
Author author2 = (Author) ((JavassistProxyFactory) proxyFactory).createDeserializationProxy(author, new HashMap<String, ResultLoaderMap.LoadPair>(), new DefaultObjectFactory(), new ArrayList<Class<?>>(), new ArrayList<Object>());
assertEquals(999, author2.getId());
}
use of org.apache.ibatis.reflection.factory.DefaultObjectFactory in project mybatis-3 by mybatis.
the class JavassistProxyTest method shouldCreateAProxyForAPartiallyLoadedBean.
@Test
public void shouldCreateAProxyForAPartiallyLoadedBean() throws Exception {
ResultLoaderMap loader = new ResultLoaderMap();
loader.addLoader("id", null, null);
Object proxy = proxyFactory.createProxy(author, loader, new Configuration(), new DefaultObjectFactory(), new ArrayList<Class<?>>(), new ArrayList<Object>());
Author author2 = (Author) deserialize(serialize((Serializable) proxy));
assertTrue(author2 instanceof Proxy);
}
Aggregations