use of org.apache.ibatis.session.Configuration in project mybatis-3 by mybatis.
the class ClobReaderTypeHandlerTest method setupSqlSessionFactory.
@BeforeClass
public static void setupSqlSessionFactory() throws Exception {
DataSource dataSource = BaseDataTest.createUnpooledDataSource("org/apache/ibatis/type/jdbc.properties");
BaseDataTest.runScript(dataSource, "org/apache/ibatis/type/ClobReaderTypeHandlerTest.sql");
TransactionFactory transactionFactory = new JdbcTransactionFactory();
Environment environment = new Environment("Production", transactionFactory, dataSource);
Configuration configuration = new Configuration(environment);
configuration.addMapper(Mapper.class);
sqlSessionFactory = new SqlSessionFactoryBuilder().build(configuration);
}
use of org.apache.ibatis.session.Configuration in project mybatis-3 by mybatis.
the class SerializableProxyTest method shouldNotGenerateWriteReplaceItThereIsAlreadyOne.
@Test
public void shouldNotGenerateWriteReplaceItThereIsAlreadyOne() throws Exception {
AuthorWithWriteReplaceMethod beanWithWriteReplace = new AuthorWithWriteReplaceMethod(999, "someone", "!@#@!#!@#", "someone@somewhere.com", "blah", Section.NEWS);
try {
beanWithWriteReplace.getClass().getDeclaredMethod("writeReplace");
} catch (NoSuchMethodException e) {
fail("Bean should declare a writeReplace method");
}
Object proxy = proxyFactory.createProxy(beanWithWriteReplace, new ResultLoaderMap(), new Configuration(), new DefaultObjectFactory(), new ArrayList<Class<?>>(), new ArrayList<Object>());
Class<?>[] interfaces = proxy.getClass().getInterfaces();
boolean ownInterfaceFound = false;
for (Class<?> i : interfaces) {
if (i.equals(WriteReplaceInterface.class)) {
ownInterfaceFound = true;
break;
}
}
assertFalse(ownInterfaceFound);
}
use of org.apache.ibatis.session.Configuration in project mybatis-3 by mybatis.
the class SerializableProxyTest method shouldSerializeAProxyForABeanWithDefaultConstructor.
@Test
public void shouldSerializeAProxyForABeanWithDefaultConstructor() 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, proxy2);
}
use of org.apache.ibatis.session.Configuration in project mybatis-3 by mybatis.
the class SerializableProxyTest method shouldNotLetReadUnloadedPropertyAfterTwoSerializations.
@Test(expected = ExecutorException.class)
public void shouldNotLetReadUnloadedPropertyAfterTwoSerializations() 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(deserialize(serialize((Serializable) proxy))));
author2.getId();
}
use of org.apache.ibatis.session.Configuration in project mybatis-3 by mybatis.
the class SerializableProxyTest method shouldKeepGenericTypes.
@Test
public void shouldKeepGenericTypes() throws Exception {
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<Class<?>>(), new ArrayList<Object>());
proxy.getBio();
}
}
Aggregations