super(name);
}
public void testMutableMetaData() throws Throwable
{
MutableMetaDataRepository repository = getMetaDataRepository().getMetaDataRepository();
ScopeKey instanceScope = new ScopeKey(CommonLevels.INSTANCE, "TestBean");
MemoryMetaDataLoader loader = new MemoryMetaDataLoader(instanceScope);
TestAnnotation2 annotation = (TestAnnotation2) AnnotationCreator.createAnnotation("@org.jboss.test.kernel.deployment.support.TestAnnotation2", TestAnnotation2.class);
loader.addAnnotation(annotation);
repository.addMetaDataRetrieval(loader);
ScopeKey setStringScope = new ScopeKey(CommonLevels.JOINPOINT, "setString");
MemoryMetaDataLoader stringProperty = new MemoryMetaDataLoader(setStringScope);
stringProperty.addAnnotation(annotation);
Signature signature = new MethodSignature("setString", String.class);
loader.addComponentMetaDataRetrieval(signature, stringProperty);
KernelDeployment deployment = deploy("MutableMetaDataTestCase_NotAutomatic.xml");
try
{
validate();
ControllerContext ctx = getControllerContext("TestBean");
MetaData metaData = ctx.getScopeInfo().getMetaData();
assertNotNull(metaData);
assertNotNull("TestAnnotation1 from xml", metaData.getAnnotation(TestAnnotation1.class));
assertNotNull("TestAnnotation2 preconfigured", metaData.getAnnotation(TestAnnotation2.class));
assertNotNull("TestAnnotation3 from class", metaData.getAnnotation(TestAnnotation3.class));
MetaData setStringMetaData = metaData.getComponentMetaData(signature);
assertNotNull("TestAnnotation1 from xml", setStringMetaData.getAnnotation(TestAnnotation1.class));
assertNotNull("TestAnnotation2 preconfigured", setStringMetaData.getAnnotation(TestAnnotation2.class));
assertNotNull("TestAnnotation3 from class", setStringMetaData.getAnnotation(TestAnnotation3.class));
}
finally
{
undeploy(deployment);
}
// Check the preconfigured stuff still exists
MetaData metaData = repository.getMetaData(instanceScope);
assertNotNull(metaData);
assertNull("TestAnnotation1 from xml", metaData.getAnnotation(TestAnnotation1.class));
assertNotNull("TestAnnotation2 preconfigured", metaData.getAnnotation(TestAnnotation2.class));
assertNull("TestAnnotation3 from class", metaData.getAnnotation(TestAnnotation3.class));
MetaData setStringMetaData = metaData.getComponentMetaData(signature);