use of jodd.proxetta.pointcuts.AllRealMethodsPointcut in project jodd by oblac.
the class AnnTest method testMethodAnnotationsProxy.
@Test
public void testMethodAnnotationsProxy() {
ProxyProxetta proxetta = ProxyProxetta.withAspects(new ProxyAspect(HeroProxyAdvice.class, new AllRealMethodsPointcut() {
@Override
public boolean apply(MethodInfo methodInfo) {
if (!methodInfo.isTopLevelMethod()) {
return false;
}
return super.apply(methodInfo);
}
}));
ProxettaBuilder proxettaBuilder = proxetta.builder();
proxettaBuilder.setTarget(Hero.class);
proxetta.setVariableClassName(true);
Hero hero = (Hero) proxettaBuilder.newInstance();
assertEquals("BatmanHero37W88.3CatWoman99speeeeedXRAYnull", hero.name());
}
use of jodd.proxetta.pointcuts.AllRealMethodsPointcut in project jodd by oblac.
the class AnnTest method testClassAnnotationsProxy.
@Test
public void testClassAnnotationsProxy() {
ProxyProxetta proxetta = ProxyProxetta.withAspects(new ProxyAspect(HeroProxyAdvice2.class, new AllRealMethodsPointcut() {
@Override
public boolean apply(MethodInfo methodInfo) {
if (!methodInfo.isTopLevelMethod()) {
return false;
}
return super.apply(methodInfo);
}
}));
ProxettaBuilder proxettaBuilder = proxetta.builder();
proxettaBuilder.setTarget(Hero.class);
proxetta.setVariableClassName(true);
Hero hero = (Hero) proxettaBuilder.newInstance();
assertEquals("SilverHero89W99.222None1000speeeeedXRAYnull", hero.name());
}
use of jodd.proxetta.pointcuts.AllRealMethodsPointcut in project jodd by oblac.
the class AnnTest method testClassAnnotationsWrapper.
@Test
public void testClassAnnotationsWrapper() throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
WrapperProxetta proxetta = WrapperProxetta.withAspects(new ProxyAspect(HeroProxyAdvice2.class, new AllRealMethodsPointcut() {
@Override
public boolean apply(MethodInfo methodInfo) {
if (!methodInfo.isTopLevelMethod()) {
return false;
}
return super.apply(methodInfo);
}
}));
WrapperProxettaBuilder proxettaBuilder = proxetta.builder();
proxettaBuilder.setTarget(Hero.class);
proxetta.setVariableClassName(true);
Object hero = proxettaBuilder.newInstance();
assertEquals("SilverHero89W99.222None1000speeeeedXRAYnull", ReflectUtil.invoke(hero, "name"));
}
use of jodd.proxetta.pointcuts.AllRealMethodsPointcut in project jodd by oblac.
the class AnnTest method testMethodAnnotationsWrapper.
@Test
public void testMethodAnnotationsWrapper() throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
WrapperProxetta proxetta = WrapperProxetta.withAspects(new ProxyAspect(HeroProxyAdvice.class, new AllRealMethodsPointcut() {
@Override
public boolean apply(MethodInfo methodInfo) {
if (!methodInfo.isTopLevelMethod()) {
return false;
}
return super.apply(methodInfo);
}
}));
WrapperProxettaBuilder proxettaBuilder = proxetta.builder();
proxettaBuilder.setTarget(Hero.class);
proxetta.setVariableClassName(true);
Object hero = proxettaBuilder.newInstance();
assertEquals("BatmanHero37W88.3CatWoman99speeeeedXRAYnull", ReflectUtil.invoke(hero, "name"));
}
use of jodd.proxetta.pointcuts.AllRealMethodsPointcut in project jodd by oblac.
the class ProxettaAwareContainerTest method testProxyProxetta.
@Test
public void testProxyProxetta() {
ProxyProxetta proxetta = ProxyProxetta.withAspects(new ProxyAspect(AddStringAdvice.class, new AllRealMethodsPointcut()));
PetiteContainer papc = new ProxettaAwarePetiteContainer(proxetta);
papc.registerPetiteBean(SecretService.class, null, null, null, false);
BeanDefinition beanDefinition = papc.registerPetiteBean(PublicService.class, null, null, null, false);
papc.registerPetiteBean(PublicService2.class, null, null, null, false);
papc.registerPetiteBean(PublicService3.class, null, null, null, false);
assertNotEquals(PublicService.class, beanDefinition.getType());
PublicService publicService = (PublicService) papc.getBean(beanDefinition.getName());
assertNotNull(publicService.secretService);
assertEquals("Hello World! And Universe, too!", publicService.hello());
PublicService2 publicService2 = papc.getBean(PublicService2.class);
assertNotNull(publicService2.secretService);
assertEquals("Hello World! And Universe, too!", publicService2.hello());
PublicService3 publicService3 = papc.getBean(PublicService3.class);
assertNotNull(publicService3.secretService);
assertEquals("Hello World! And Universe, too!", publicService3.hello());
}
Aggregations