use of org.apache.ibatis.domain.blog.Author in project mybatis-3 by mybatis.
the class SerializableProxyTest method shouldNotLetReadUnloadedPropertyAfterSerialization.
@Test(expected = ExecutorException.class)
public void shouldNotLetReadUnloadedPropertyAfterSerialization() 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));
author2.getId();
}
use of org.apache.ibatis.domain.blog.Author in project mybatis-3 by mybatis.
the class BaseExecutorTest method shouldSelectAllAuthorsAutoMapped.
@Test
public void shouldSelectAllAuthorsAutoMapped() throws Exception {
Executor executor = createExecutor(new JdbcTransaction(ds, null, false));
try {
MappedStatement selectStatement = ExecutorTestHelper.prepareSelectAllAuthorsAutoMappedStatement(config);
List<Author> authors = executor.query(selectStatement, null, RowBounds.DEFAULT, Executor.NO_RESULT_HANDLER);
assertEquals(2, authors.size());
Author author = authors.get(0);
// id,username, password, email, bio, favourite_section
// (101,'jim','********','jim@ibatis.apache.org','','NEWS');
assertEquals(101, author.getId());
assertEquals("jim", author.getUsername());
assertEquals("jim@ibatis.apache.org", author.getEmail());
assertEquals("", author.getBio());
assertEquals(Section.NEWS, author.getFavouriteSection());
} 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 shouldDeleteAuthor.
@Test
public void shouldDeleteAuthor() throws Exception {
Executor executor = createExecutor(new JdbcTransaction(ds, null, false));
try {
Author author = new Author(101, null, null, null, null, null);
MappedStatement deleteStatement = ExecutorTestHelper.prepareDeleteAuthorMappedStatement(config);
MappedStatement selectStatement = ExecutorTestHelper.prepareSelectOneAuthorMappedStatement(config);
int rows = executor.update(deleteStatement, author);
List<Author> authors = executor.query(selectStatement, 101, RowBounds.DEFAULT, Executor.NO_RESULT_HANDLER);
executor.flushStatements();
executor.rollback(true);
assertEquals(0, authors.size());
assertTrue(1 == rows || BatchExecutor.BATCH_UPDATE_RETURN_VALUE == rows);
} finally {
executor.rollback(true);
executor.close(false);
}
}
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);
}
}
Aggregations