use of org.apache.ibatis.domain.blog.Author in project mybatis-3 by mybatis.
the class CglibProxyTest method shouldSerizalizeADeserlizaliedProxy.
@Test
public void shouldSerizalizeADeserlizaliedProxy() throws Exception {
Object proxy = ((CglibProxyFactory) proxyFactory).createDeserializationProxy(author, new HashMap<String, ResultLoaderMap.LoadPair>(), new DefaultObjectFactory(), new ArrayList<Class<?>>(), new ArrayList<Object>());
Author author2 = (Author) deserialize(serialize((Serializable) proxy));
assertEquals(author, author2);
assertFalse(author.getClass().equals(author2.getClass()));
}
use of org.apache.ibatis.domain.blog.Author in project mybatis-3 by mybatis.
the class BaseExecutorTest method shouldMapConstructorResults.
@Test
public void shouldMapConstructorResults() throws Exception {
Executor executor = createExecutor(new JdbcTransaction(ds, null, false));
try {
MappedStatement selectStatement = ExecutorTestHelper.prepareSelectOneAuthorMappedStatementWithConstructorResults(config);
List<Author> authors = executor.query(selectStatement, 102, RowBounds.DEFAULT, Executor.NO_RESULT_HANDLER);
executor.flushStatements();
executor.rollback(true);
assertEquals(1, authors.size());
Author author = authors.get(0);
assertEquals(102, author.getId());
} finally {
executor.rollback(true);
executor.close(false);
}
}
use of org.apache.ibatis.domain.blog.Author in project mybatis-3 by mybatis.
the class BaseExecutorTest method shouldInsertNewAuthorWithAutoKey.
@Test
public void shouldInsertNewAuthorWithAutoKey() throws Exception {
Executor executor = createExecutor(new JdbcTransaction(ds, null, false));
try {
Author author = new Author(-1, "someone", "******", "someone@apache.org", null, Section.NEWS);
MappedStatement insertStatement = ExecutorTestHelper.prepareInsertAuthorMappedStatementWithAutoKey(config);
MappedStatement selectStatement = ExecutorTestHelper.prepareSelectOneAuthorMappedStatement(config);
int rows = executor.update(insertStatement, author);
assertTrue(rows > 0 || rows == BatchExecutor.BATCH_UPDATE_RETURN_VALUE);
if (rows == BatchExecutor.BATCH_UPDATE_RETURN_VALUE) {
executor.flushStatements();
}
assertTrue(-1 != author.getId());
if (author.getId() != BatchExecutor.BATCH_UPDATE_RETURN_VALUE) {
List<Author> authors = executor.query(selectStatement, author.getId(), RowBounds.DEFAULT, Executor.NO_RESULT_HANDLER);
executor.rollback(true);
assertEquals(1, authors.size());
assertEquals(author.toString(), authors.get(0).toString());
assertTrue(author.getId() >= 10000);
}
} finally {
executor.rollback(true);
executor.close(false);
}
}
use of org.apache.ibatis.domain.blog.Author in project mybatis-3 by mybatis.
the class BaseExecutorTest method shouldClearDeferredLoads.
@Test
public void shouldClearDeferredLoads() throws Exception {
Executor executor = createExecutor(new JdbcTransaction(ds, null, false));
try {
MappedStatement selectBlog = ExecutorTestHelper.prepareComplexSelectBlogMappedStatement(config);
MappedStatement selectPosts = ExecutorTestHelper.prepareSelectPostsForBlogMappedStatement(config);
config.addMappedStatement(selectBlog);
config.addMappedStatement(selectPosts);
MappedStatement selectAuthor = ExecutorTestHelper.prepareSelectOneAuthorMappedStatement(config);
MappedStatement insertAuthor = ExecutorTestHelper.prepareInsertAuthorMappedStatement(config);
//generate DeferredLoads
executor.query(selectPosts, 1, RowBounds.DEFAULT, Executor.NO_RESULT_HANDLER);
Author author = new Author(-1, "someone", "******", "someone@apache.org", null, Section.NEWS);
executor.update(insertAuthor, author);
executor.query(selectAuthor, -1, RowBounds.DEFAULT, Executor.NO_RESULT_HANDLER);
executor.flushStatements();
executor.rollback(true);
} finally {
executor.rollback(true);
executor.close(false);
}
}
use of org.apache.ibatis.domain.blog.Author in project mybatis-3 by mybatis.
the class ExpressionEvaluatorTest method shouldCompareStringsReturnTrue.
@Test
public void shouldCompareStringsReturnTrue() {
boolean value = evaluator.evaluateBoolean("username == 'cbegin'", new Author(1, "cbegin", "******", "cbegin@apache.org", "N/A", Section.NEWS));
assertEquals(true, value);
}
Aggregations