use of org.apache.ibatis.session.Configuration 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.session.Configuration 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.session.Configuration 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());
}
use of org.apache.ibatis.session.Configuration in project mybatis-3 by mybatis.
the class BindingTest method setup.
@BeforeClass
public static void setup() throws Exception {
DataSource dataSource = BaseDataTest.createBlogDataSource();
BaseDataTest.runScript(dataSource, BaseDataTest.BLOG_DDL);
BaseDataTest.runScript(dataSource, BaseDataTest.BLOG_DATA);
TransactionFactory transactionFactory = new JdbcTransactionFactory();
Environment environment = new Environment("Production", transactionFactory, dataSource);
Configuration configuration = new Configuration(environment);
configuration.setLazyLoadingEnabled(true);
// to test legacy style reference (#{0} #{1})
configuration.setUseActualParamName(false);
configuration.getTypeAliasRegistry().registerAlias(Blog.class);
configuration.getTypeAliasRegistry().registerAlias(Post.class);
configuration.getTypeAliasRegistry().registerAlias(Author.class);
configuration.addMapper(BoundBlogMapper.class);
configuration.addMapper(BoundAuthorMapper.class);
sqlSessionFactory = new SqlSessionFactoryBuilder().build(configuration);
}
use of org.apache.ibatis.session.Configuration in project mybatis-3 by mybatis.
the class DynamicSqlSourceTest method shouldTrimWHEREANDWithCRLFForFirstCondition.
@Test
public void shouldTrimWHEREANDWithCRLFForFirstCondition() throws Exception {
final String expected = "SELECT * FROM BLOG WHERE \r\n ID = ?";
DynamicSqlSource source = createDynamicSqlSource(new TextSqlNode("SELECT * FROM BLOG"), new WhereSqlNode(new Configuration(), mixedContents(new IfSqlNode(mixedContents(new TextSqlNode(" and\r\n ID = ? ")), "true"))));
BoundSql boundSql = source.getBoundSql(null);
assertEquals(expected, boundSql.getSql());
}
Aggregations