Search in sources :

Example 1 with DefaultObjectFactory

use of org.apache.ibatis.reflection.factory.DefaultObjectFactory in project mybatis-3 by mybatis.

the class JavassistProxyTest method shouldSerizalizeADeserlizaliedProxy.

@Test
void shouldSerizalizeADeserlizaliedProxy() throws Exception {
    Object proxy = ((JavassistProxyFactory) proxyFactory).createDeserializationProxy(author, new HashMap<>(), new DefaultObjectFactory(), new ArrayList<>(), new ArrayList<>());
    Author author2 = (Author) deserialize(serialize((Serializable) proxy));
    assertEquals(author, author2);
    assertNotEquals(author.getClass(), author2.getClass());
}
Also used : JavassistProxyFactory(org.apache.ibatis.executor.loader.javassist.JavassistProxyFactory) DefaultObjectFactory(org.apache.ibatis.reflection.factory.DefaultObjectFactory) Author(org.apache.ibatis.domain.blog.Author) Test(org.junit.jupiter.api.Test)

Example 2 with DefaultObjectFactory

use of org.apache.ibatis.reflection.factory.DefaultObjectFactory in project mybatis-3 by mybatis.

the class CglibProxyTest method shouldSerizalizeADeserlizaliedProxy.

@Test
void shouldSerizalizeADeserlizaliedProxy() throws Exception {
    Object proxy = ((CglibProxyFactory) proxyFactory).createDeserializationProxy(author, new HashMap<>(), new DefaultObjectFactory(), new ArrayList<>(), new ArrayList<>());
    Author author2 = (Author) deserialize(serialize((Serializable) proxy));
    assertEquals(author, author2);
    assertNotEquals(author.getClass(), author2.getClass());
}
Also used : CglibProxyFactory(org.apache.ibatis.executor.loader.cglib.CglibProxyFactory) DefaultObjectFactory(org.apache.ibatis.reflection.factory.DefaultObjectFactory) Author(org.apache.ibatis.domain.blog.Author) Test(org.junit.jupiter.api.Test)

Example 3 with DefaultObjectFactory

use of org.apache.ibatis.reflection.factory.DefaultObjectFactory in project mybatis-3 by mybatis.

the class SerializableProxyTest method shouldSerializeAProxyForABeanWithDefaultConstructor.

@Test
void shouldSerializeAProxyForABeanWithDefaultConstructor() throws Exception {
    Object proxy = proxyFactory.createProxy(author, new ResultLoaderMap(), new Configuration(), new DefaultObjectFactory(), new ArrayList<>(), new ArrayList<>());
    Object proxy2 = deserialize(serialize((Serializable) proxy));
    assertEquals(author, proxy2);
}
Also used : Serializable(java.io.Serializable) Configuration(org.apache.ibatis.session.Configuration) DefaultObjectFactory(org.apache.ibatis.reflection.factory.DefaultObjectFactory) Test(org.junit.jupiter.api.Test)

Example 4 with DefaultObjectFactory

use of org.apache.ibatis.reflection.factory.DefaultObjectFactory in project mybatis-3 by mybatis.

the class SerializableProxyTest method shouldKeepGenericTypes.

@Test
void shouldKeepGenericTypes() {
    for (int i = 0; i < 10000; i++) {
        Author pc = new Author();
        Author proxy = (Author) proxyFactory.createProxy(pc, new ResultLoaderMap(), new Configuration(), new DefaultObjectFactory(), new ArrayList<>(), new ArrayList<>());
        proxy.getBio();
    }
}
Also used : Configuration(org.apache.ibatis.session.Configuration) DefaultObjectFactory(org.apache.ibatis.reflection.factory.DefaultObjectFactory) ArrayList(java.util.ArrayList) Author(org.apache.ibatis.domain.blog.Author) Test(org.junit.jupiter.api.Test)

Example 5 with DefaultObjectFactory

use of org.apache.ibatis.reflection.factory.DefaultObjectFactory in project mybatis-3 by mybatis.

the class SerializableProxyTest method shouldNotCreateAProxyForAFullyLoadedBean.

@Test
void shouldNotCreateAProxyForAFullyLoadedBean() throws Exception {
    Object proxy = proxyFactory.createProxy(author, new ResultLoaderMap(), new Configuration(), new DefaultObjectFactory(), new ArrayList<>(), new ArrayList<>());
    Author author2 = (Author) deserialize(serialize((Serializable) proxy));
    assertEquals(author.getClass(), author2.getClass());
}
Also used : Configuration(org.apache.ibatis.session.Configuration) DefaultObjectFactory(org.apache.ibatis.reflection.factory.DefaultObjectFactory) Author(org.apache.ibatis.domain.blog.Author) Test(org.junit.jupiter.api.Test)

Aggregations

DefaultObjectFactory (org.apache.ibatis.reflection.factory.DefaultObjectFactory)19 Test (org.junit.jupiter.api.Test)19 Author (org.apache.ibatis.domain.blog.Author)13 Configuration (org.apache.ibatis.session.Configuration)13 ArrayList (java.util.ArrayList)7 Serializable (java.io.Serializable)4 HashMap (java.util.HashMap)4 CglibProxyFactory (org.apache.ibatis.executor.loader.cglib.CglibProxyFactory)2 Method (java.lang.reflect.Method)1 Proxy (javassist.util.proxy.Proxy)1 Factory (net.sf.cglib.proxy.Factory)1 JavassistProxyFactory (org.apache.ibatis.executor.loader.javassist.JavassistProxyFactory)1