POJO pojo = new POJO();
POJO pojo1 = new POJO();
pojo.someMethod(123);
assertFalse(MetadataInterceptor.intercepted);
AdviceBinding binding1 = new AdviceBinding("all(org.jboss.test.aop.dynamicgenadvisor.POJO)", null);
binding1.addInterceptor(MetadataInterceptor.class);
AspectManager.instance().addBinding(binding1);
DynamicSimpleClassMetadataLoader loader = new DynamicSimpleClassMetadataLoader(
"TEST", "org.jboss.test.aop.dynamicgenadvisor.POJO");
loader.addDefaultMetaData("default", "default");
loader.addClassMetaData("class", "class");
loader.addMethodMetaData("* someMethod(..)", "fm", "someMethod");
loader.addFieldMetaData("i", "fm", "i");
AspectManager.instance().addClassMetaData(loader.getClassMetaDataBinding());
DynamicSimpleClassMetadataLoader instanceLoader = new DynamicSimpleClassMetadataLoader(
"TEST", "org.jboss.test.aop.dynamicgenadvisor.POJO");
instanceLoader.addDefaultMetaData("default", "defaultXXX");
instanceLoader.addClassMetaData("class", "classXXX");
instanceLoader.addMethodMetaData("* someMethod(..)", "fm", "someMethodXXX");
instanceLoader.addFieldMetaData("i", "fm", "iXXX");
getInstanceDomain(pojo1).addClassMetaData(instanceLoader.getClassMetaDataBinding());
MetadataInterceptor.clear();
pojo.someMethod(123);
pojo.i = 1000;
assertEquals(2, MetadataInterceptor.lastDefaultMetadata.size());
assertEquals(2, MetadataInterceptor.lastClassMetadata.size());
assertEquals(1, MetadataInterceptor.lastMethodMetadata.size());
assertEquals(1, MetadataInterceptor.lastFieldMetadata.size());
//Make sure we get the metadata expected
assertEquals("default", MetadataInterceptor.lastDefaultMetadata.get(0));
assertEquals("default", MetadataInterceptor.lastDefaultMetadata.get(1));
assertEquals("class", MetadataInterceptor.lastClassMetadata.get(0));
assertEquals("class", MetadataInterceptor.lastClassMetadata.get(1));
assertEquals("someMethod", MetadataInterceptor.lastMethodMetadata.get(0));
assertEquals("i", MetadataInterceptor.lastFieldMetadata.get(0));
MetadataInterceptor.clear();
pojo1.someMethod(123);
pojo1.i = 1000;
assertEquals(2, MetadataInterceptor.lastDefaultMetadata.size());
assertEquals(2, MetadataInterceptor.lastClassMetadata.size());
assertEquals(1, MetadataInterceptor.lastMethodMetadata.size());
assertEquals(1, MetadataInterceptor.lastFieldMetadata.size());
//Make sure we get the metadata expected
assertEquals("defaultXXX", MetadataInterceptor.lastDefaultMetadata.get(0));
assertEquals("defaultXXX", MetadataInterceptor.lastDefaultMetadata.get(1));
assertEquals("classXXX", MetadataInterceptor.lastClassMetadata.get(0));
assertEquals("classXXX", MetadataInterceptor.lastClassMetadata.get(1));
assertEquals("someMethodXXX", MetadataInterceptor.lastMethodMetadata.get(0));
assertEquals("iXXX", MetadataInterceptor.lastFieldMetadata.get(0));
getInstanceDomain(pojo1).removeClassMetaData(instanceLoader.getClassMetaDataBinding().getName());
MetadataInterceptor.clear();
pojo1.someMethod(123);
pojo1.i = 1000;
assertEquals(2, MetadataInterceptor.lastDefaultMetadata.size());
assertEquals(2, MetadataInterceptor.lastClassMetadata.size());
assertEquals(1, MetadataInterceptor.lastMethodMetadata.size());
assertEquals(1, MetadataInterceptor.lastFieldMetadata.size());
//Make sure we get the metadata expected
assertEquals("default", MetadataInterceptor.lastDefaultMetadata.get(0));
assertEquals("default", MetadataInterceptor.lastDefaultMetadata.get(1));
assertEquals("class", MetadataInterceptor.lastClassMetadata.get(0));
assertEquals("class", MetadataInterceptor.lastClassMetadata.get(1));
assertEquals("someMethod", MetadataInterceptor.lastMethodMetadata.get(0));
assertEquals("i", MetadataInterceptor.lastFieldMetadata.get(0));
AspectManager.instance().removeClassMetaData(loader.getClassMetaDataBinding().getName());
AspectManager.instance().removeBinding(binding1.getName());
MetadataInterceptor.clear();
pojo.someMethod(123);
assertFalse(MetadataInterceptor.intercepted);
}