org.apache.ibatis.reflection.factory.DefaultObjectFactory Java Examples

The following examples show how to use org.apache.ibatis.reflection.factory.DefaultObjectFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PageResultInterceptor.java    From joyqueue with Apache License 2.0 6 votes vote down vote up
@Override
public Object intercept(Invocation invocation) throws Throwable {
    // 目标对象转换
    ResultSetHandler resultSetHandler = (ResultSetHandler) invocation.getTarget();

    // 获取MappedStatement,Configuration对象
    MetaObject metaObject =
            MetaObject.forObject(resultSetHandler, new DefaultObjectFactory(), new DefaultObjectWrapperFactory(), new DefaultReflectorFactory());
    MappedStatement mappedStatement = (MappedStatement) metaObject.getValue("mappedStatement");
    String statement = mappedStatement.getId();
    if (!isPageSql(statement,metaObject.getValue("boundSql.parameterObject"))) {
        return invocation.proceed();
    }

    // 获取分页参数
    QPageQuery pageQuery = (QPageQuery) metaObject.getValue("boundSql.parameterObject");

    List<PageResult> result = new ArrayList<PageResult>(1);
    PageResult page = new PageResult();
    page.setPagination(pageQuery.getPagination());
    page.setResult((List) invocation.proceed());
    result.add(page);

    return result;
}
 
Example #2
Source File: SortListInterceptor.java    From QuickProject with Apache License 2.0 6 votes vote down vote up
@Override
public Object intercept(Invocation invocation) throws Throwable {
       List<Sort> sortList = getSortList();
       if (sortList == null || sortList.size() == 0) {
           return invocation.proceed();
       }

       Executor executor = (Executor) invocation.getTarget();
       Object[] args = invocation.getArgs();
       MappedStatement ms = (MappedStatement) args[0];
       Object parameter = args[1];
       RowBounds rowBounds = (RowBounds) args[2];
       ResultHandler resultHandler = (ResultHandler) args[3];

       // 计算修改BoundSql
       BoundSql boundSql = ms.getBoundSql(parameter);
       MetaObject boundSqlHandler = MetaObject.forObject(boundSql, new DefaultObjectFactory(), new DefaultObjectWrapperFactory());
       Dialect dialect = DialectParser.parse(ms.getConfiguration());
       String sql = (String) boundSqlHandler.getValue("sql");
       sql = dialect.addSortString(sql, sortList);
       boundSqlHandler.setValue("sql", sql);

       // 继续执行原来的代码
       CacheKey key = executor.createCacheKey(ms, parameter, rowBounds, boundSql);
       return executor.query(ms, parameter, rowBounds, resultHandler, key, boundSql);
}
 
Example #3
Source File: PageInterceptor.java    From QuickProject with Apache License 2.0 6 votes vote down vote up
@Override
public Object intercept(Invocation invocation) throws Throwable {
	StatementHandler statementHandler = (StatementHandler) invocation.getTarget();
	BoundSql boundSql = statementHandler.getBoundSql();
	MetaObject metaStatementHandler = MetaObject.forObject(statementHandler, new DefaultObjectFactory(), new DefaultObjectWrapperFactory());
	RowBounds rowBounds = (RowBounds) metaStatementHandler.getValue("delegate.rowBounds");
	if ((rowBounds != null) && (rowBounds != RowBounds.DEFAULT)) {
           Configuration configuration = (Configuration) metaStatementHandler.getValue("delegate.configuration");
           Dialect dialect = DialectParser.parse(configuration);
           String sql = (String) metaStatementHandler.getValue("delegate.boundSql.sql");
           sql = dialect.addLimitString(sql, rowBounds.getOffset(), rowBounds.getLimit());

           metaStatementHandler.setValue("delegate.boundSql.sql", sql);
           metaStatementHandler.setValue("delegate.rowBounds.offset", RowBounds.NO_ROW_OFFSET);
           metaStatementHandler.setValue("delegate.rowBounds.limit", RowBounds.NO_ROW_LIMIT);
	}

	log.debug("SQL : " + boundSql.getSql());
	return invocation.proceed();
}
 
Example #4
Source File: SerializableProxyTest.java    From mybatis with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldNotGenerateWriteReplaceItThereIsAlreadyOne() throws Exception {
  AuthorWithWriteReplaceMethod beanWithWriteReplace = new AuthorWithWriteReplaceMethod(999, "someone", "!@#@!#!@#", "[email protected]", "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);
}
 
Example #5
Source File: SerializableProxyTest.java    From mybatis with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldSerializeAProxyForABeanWithoutDefaultConstructorAndUnloadedProperties() throws Exception {
  AuthorWithoutDefaultConstructor author = new AuthorWithoutDefaultConstructor(999, "someone", "!@#@!#!@#", "[email protected]", "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("[email protected]");
  argValues.add("blah");
  argValues.add(Section.NEWS);
  ResultLoaderMap loader = new ResultLoaderMap();
  loader.addLoader("id", null, null);
  Object proxy = proxyFactory.createProxy(author, loader, new Configuration(), new DefaultObjectFactory(), argTypes, argValues);
  Object proxy2 = deserialize(serialize((Serializable) proxy));
  assertEquals(author, proxy2);
}
 
Example #6
Source File: SerializableProxyTest.java    From mybatis with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldSerializeAProxyForABeanWithoutDefaultConstructor() throws Exception {
  AuthorWithoutDefaultConstructor author = new AuthorWithoutDefaultConstructor(999, "someone", "!@#@!#!@#", "[email protected]", "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("[email protected]");
  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);
}
 
Example #7
Source File: SerializableProxyTest.java    From mybaties with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldNotGenerateWriteReplaceItThereIsAlreadyOne() throws Exception {
  AuthorWithWriteReplaceMethod beanWithWriteReplace = new AuthorWithWriteReplaceMethod(999, "someone", "!@#@!#!@#", "[email protected]", "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);
}
 
Example #8
Source File: SerializableProxyTest.java    From mybaties with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldSerializeAProxyForABeanWithoutDefaultConstructorAndUnloadedProperties() throws Exception {
  AuthorWithoutDefaultConstructor author = new AuthorWithoutDefaultConstructor(999, "someone", "!@#@!#!@#", "[email protected]", "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("[email protected]");
  argValues.add("blah");
  argValues.add(Section.NEWS);
  ResultLoaderMap loader = new ResultLoaderMap();
  loader.addLoader("id", null, null);
  Object proxy = proxyFactory.createProxy(author, loader, new Configuration(), new DefaultObjectFactory(), argTypes, argValues);
  Object proxy2 = deserialize(serialize((Serializable) proxy));
  assertEquals(author, proxy2);
}
 
Example #9
Source File: SerializableProxyTest.java    From mybaties with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldSerializeAProxyForABeanWithoutDefaultConstructor() throws Exception {
  AuthorWithoutDefaultConstructor author = new AuthorWithoutDefaultConstructor(999, "someone", "!@#@!#!@#", "[email protected]", "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("[email protected]");
  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);
}
 
Example #10
Source File: SerializableProxyTest.java    From mybaties with Apache License 2.0 5 votes vote down vote up
@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();
  }
}
 
Example #11
Source File: MybatisSqlInterceptor.java    From taoshop with Apache License 2.0 5 votes vote down vote up
/**
 * 包装sql后,重置到invocation中
 * @param invocation
 * @param sql
 * @throws SQLException
 */
private void resetSql2Invocation(Invocation invocation, String sql) throws SQLException {
    final Object[] args = invocation.getArgs();
    MappedStatement statement = (MappedStatement) args[0];
    Object parameterObject = args[1];
    BoundSql boundSql = statement.getBoundSql(parameterObject);
    MappedStatement newStatement = newMappedStatement(statement, new BoundSqlSqlSource(boundSql));
    MetaObject msObject =  MetaObject.forObject(newStatement, new DefaultObjectFactory(), new DefaultObjectWrapperFactory(),new DefaultReflectorFactory());
    msObject.setValue("sqlSource.boundSql.sql", sql);
    args[0] = newStatement;
}
 
Example #12
Source File: JavassistProxyTest.java    From mybatis with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldSerizalizeADeserlizaliedProxy() throws Exception {
  Object proxy = ((JavassistProxyFactory)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()));
}
 
Example #13
Source File: JavassistProxyTest.java    From mybatis with Apache License 2.0 5 votes vote down vote up
@Test(expected = ExecutorException.class)
public void shouldFailCallingAnUnloadedProperty() throws Exception {
  // yes, it must go in uppercase
  HashMap<String, ResultLoaderMap.LoadPair> unloadedProperties = new HashMap<String, ResultLoaderMap.LoadPair> ();
  unloadedProperties.put("ID", null);
  Author author2 = (Author) ((JavassistProxyFactory)proxyFactory).createDeserializationProxy(author, unloadedProperties, new DefaultObjectFactory(), new ArrayList<Class<?>>(), new ArrayList<Object>());
  author2.getId();
}
 
Example #14
Source File: JavassistProxyTest.java    From mybatis with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldCreateAProxyForAPartiallyLoadedBean() 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));
  assertTrue(author2 instanceof Proxy);
}
 
Example #15
Source File: SerializableProxyTest.java    From mybatis with Apache License 2.0 5 votes vote down vote up
@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());
}
 
Example #16
Source File: SerializableProxyTest.java    From mybatis with Apache License 2.0 5 votes vote down vote up
@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();
}
 
Example #17
Source File: SerializableProxyTest.java    From mybatis with Apache License 2.0 5 votes vote down vote up
@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();
}
 
Example #18
Source File: CglibProxyTest.java    From mybaties with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldCreateAProxyForAPartiallyLoadedBean() 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));
  assertTrue(author2 instanceof Factory);
}
 
Example #19
Source File: SerializableProxyTest.java    From mybatis with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldGenerateWriteReplace() throws Exception {
  try {
    author.getClass().getDeclaredMethod("writeReplace");
    fail("Author should not have a writeReplace method");
  } catch (NoSuchMethodException e) {
    // ok
  }
  Object proxy = proxyFactory.createProxy(author, new ResultLoaderMap(), new Configuration(), new DefaultObjectFactory(), new ArrayList<Class<?>>(), new ArrayList<Object>());
  Method m = proxy.getClass().getDeclaredMethod("writeReplace");
}
 
Example #20
Source File: CglibProxyTest.java    From mybaties with Apache License 2.0 5 votes vote down vote up
@Test(expected = ExecutorException.class)
public void shouldFailCallingAnUnloadedProperty() throws Exception {
  // yes, it must go in uppercase
  HashMap<String, ResultLoaderMap.LoadPair> unloadedProperties = new HashMap<String, ResultLoaderMap.LoadPair>();
  unloadedProperties.put("ID", null);
  Author author2 = (Author) ((CglibProxyFactory)proxyFactory).createDeserializationProxy(author, unloadedProperties, new DefaultObjectFactory(), new ArrayList<Class<?>>(), new ArrayList<Object>());
  author2.getId();
}
 
Example #21
Source File: SerializableProxyTest.java    From mybatis with Apache License 2.0 5 votes vote down vote up
@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();
  }
}
 
Example #22
Source File: CglibProxyTest.java    From mybatis with Apache License 2.0 5 votes vote down vote up
@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()));
}
 
Example #23
Source File: CglibProxyTest.java    From mybatis with Apache License 2.0 5 votes vote down vote up
@Test(expected = ExecutorException.class)
public void shouldFailCallingAnUnloadedProperty() throws Exception {
  // yes, it must go in uppercase
  HashMap<String, ResultLoaderMap.LoadPair> unloadedProperties = new HashMap<String, ResultLoaderMap.LoadPair>();
  unloadedProperties.put("ID", null);
  Author author2 = (Author) ((CglibProxyFactory)proxyFactory).createDeserializationProxy(author, unloadedProperties, new DefaultObjectFactory(), new ArrayList<Class<?>>(), new ArrayList<Object>());
  author2.getId();
}
 
Example #24
Source File: QueryInformation.java    From sinavi-jfw with Apache License 2.0 5 votes vote down vote up
/**
 * コンストラクタです。
 * MyBatisの{@link StatementHandler}の解析に失敗した場合に{@link InternalException}をスローします。
 * @param statementHandler {@link StatementHandler}
 */
public QueryInformation(StatementHandler statementHandler) {
    try {
        this.typeHandlerRegistry = new TypeHandlerRegistry();
        this.statementHandler = getConcreteStatementHandler(statementHandler);
        this.mappedStatement = getMappedStatement(this.statementHandler);
        this.boundSql = this.statementHandler.getBoundSql();
        this.parameterObject = this.boundSql.getParameterObject();
        this.parameterMappingList = boundSql.getParameterMappings();
        this.sqlCommandType = mappedStatement.getSqlCommandType();
        this.statementType = mappedStatement.getStatementType();
        this.metaObject = parameterObject == null ? null : MetaObject.forObject(parameterObject, new DefaultObjectFactory(), new DefaultObjectWrapperFactory());

        switch (statementType) {
            case STATEMENT:
                this.query = boundSql.getSql();
                break;
            case PREPARED:
                this.preparedQuery = boundSql.getSql();
                break;
            case CALLABLE:
                this.callableQuery = boundSql.getSql();
                break;
            default:
                throw new InternalException(QueryInformation.class, "");
        }
    } catch (Exception e) {
        throw new InternalException(QueryInformation.class, "E-JDBC-MYBATIS#0002", e);
    }
}
 
Example #25
Source File: SerializableProxyTest.java    From mybaties with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldGenerateWriteReplace() throws Exception {
  try {
    author.getClass().getDeclaredMethod("writeReplace");
    fail("Author should not have a writeReplace method");
  } catch (NoSuchMethodException e) {
    // ok
  }
  Object proxy = proxyFactory.createProxy(author, new ResultLoaderMap(), new Configuration(), new DefaultObjectFactory(), new ArrayList<Class<?>>(), new ArrayList<Object>());
  Method m = proxy.getClass().getDeclaredMethod("writeReplace");
}
 
Example #26
Source File: CglibProxyTest.java    From mybaties with Apache License 2.0 5 votes vote down vote up
@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()));
}
 
Example #27
Source File: SerializableProxyTest.java    From mybaties with Apache License 2.0 5 votes vote down vote up
@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();
}
 
Example #28
Source File: SerializableProxyTest.java    From mybaties with Apache License 2.0 5 votes vote down vote up
@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();
}
 
Example #29
Source File: SerializableProxyTest.java    From mybaties with Apache License 2.0 5 votes vote down vote up
@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());
}
 
Example #30
Source File: JavassistProxyTest.java    From mybaties with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldCreateAProxyForAPartiallyLoadedBean() 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));
  assertTrue(author2 instanceof Proxy);
}