KernelDeployment deployment = createKernelDeployment(BEAN_NAMES);
// install
installDeployment(deployment);
// Create the managed objects
ManagedObject deploymentMO = getMOF().initManagedObject(deployment, null);
ManagedObject mo = getBeanMO("SimpleAnnotatedBean");
assertNotNull("null mo", mo);
assertTrue(mo.getAttachment() instanceof BeanMetaData);
ManagedComponent component = createComponent(mo);
assertNotNull(component);
assertEquals(component.getAttachmentName(), SimpleAnnotatedBean.class.getName());
// Change value
component.getProperty("stringProperty").setValue(SimpleValueSupport.wrap("changedTestValue"));
PersistenceRoot root = updateComponent(deploymentMO, component);
assertNotNull(root);
// Uninstall for offline attachment persistence
uninstallDeployment(deployment);
// Recreate the kernel deployment
deployment = createKernelDeployment(BEAN_NAMES);
getPersistenceFactory().restorePersistenceRoot(root, deployment, null);
// check bean meta data
BeanMetaData bmd = getBeanMetaData(deployment, "SimpleAnnotatedBean");
boolean sawProperty = false;
for(PropertyMetaData prop : bmd.getProperties())
{
if(prop.getName().equals("stringProperty"))
{
assertEquals("changedTestValue", prop.getValue().getUnderlyingValue());
sawProperty = true;
}
}
assertTrue(sawProperty);
// install
installDeployment(deployment);
mo = getBeanMO("SimpleAnnotatedBean");
assertNotNull(mo);
assertEquals(SimpleValueSupport.wrap("changedTestValue"),
mo.getProperty("stringProperty").getValue());
}