use of net.sf.cglib.proxy.Factory in project powermock by powermock.
the class ProxyFrameworksTest method should_return_object_as_original_class_if_no_non_no_mocking_interfaces.
@Test
public void should_return_object_as_original_class_if_no_non_no_mocking_interfaces() {
Factory someClass = (Factory) createCglibProxy(Factory.class);
UnproxiedType unproxiedType = proxyFrameworks.getUnproxiedType(someClass);
assertThatOriginalTypeInstanceOf(unproxiedType, Object.class);
}
use of net.sf.cglib.proxy.Factory in project mybatis-3 by mybatis.
the class CglibProxyTest method shouldCreateAProxyForAPartiallyLoadedBean.
@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);
}
use of net.sf.cglib.proxy.Factory in project CloudStack-archive by CloudStack-extras.
the class GenericDaoBase method createSearchCriteria2.
@Override
@DB(txn = false)
public <K> SearchCriteria2 createSearchCriteria2(Class<K> resultType) {
final T entity = (T) _searchEnhancer.create();
final Factory factory = (Factory) entity;
SearchCriteria2 sc = new SearchCriteria2(entity, resultType, _allAttributes, this);
factory.setCallback(0, sc);
return sc;
}
use of net.sf.cglib.proxy.Factory in project CloudStack-archive by CloudStack-extras.
the class GenericDaoBase method createSearchBuilder.
@Override
@SuppressWarnings("unchecked")
@DB(txn = false)
public <J> GenericSearchBuilder<T, J> createSearchBuilder(Class<J> resultType) {
final T entity = (T) _searchEnhancer.create();
final Factory factory = (Factory) entity;
GenericSearchBuilder<T, J> builder = new GenericSearchBuilder<T, J>(entity, resultType, _allAttributes);
factory.setCallback(0, builder);
return builder;
}
use of net.sf.cglib.proxy.Factory in project CloudStack-archive by CloudStack-extras.
the class GenericSearchBuilder method done.
/**
* Marks the SearchBuilder as completed in building the search conditions.
*/
public synchronized void done() {
if (_entity != null) {
Factory factory = (Factory) _entity;
factory.setCallback(0, null);
_entity = null;
}
if (_joins != null) {
for (JoinBuilder<GenericSearchBuilder<?, ?>> join : _joins.values()) {
join.getT().done();
}
}
if (_selects == null || _selects.size() == 0) {
_selectType = SelectType.Entity;
assert _entityBeanType.equals(_resultType) : "Expecting " + _entityBeanType + " because you didn't specify any selects but instead got " + _resultType;
return;
}
for (Select select : _selects) {
if (select.field == null) {
assert (_selects.size() == 1) : "You didn't specify any fields to put the result in but you're specifying more than one select so where should I put the selects?";
_selectType = SelectType.Single;
return;
}
if (select.func != null) {
_selectType = SelectType.Result;
return;
}
}
_selectType = SelectType.Fields;
}
Aggregations