}
public void testManagedDeployment() throws Exception
{
DeployerClient main = getMainDeployer();
MockProfileService ps = new MockProfileService(main);
ManagedObjectFactory mof = ManagedObjectFactory.getInstance();
TestServiceMetaDataICF tsicf = new TestServiceMetaDataICF();
mof.setInstanceClassFactory(TestServiceMetaData.class, tsicf);
// Deploy a datasource with local and xa factories
Deployment ctx1 = createSimpleDeployment("deployment1");
DSMetaData dsmd = new DSMetaData();
dsmd.setDiplayName("deployment1 DS");
// TODO: dsmd.setUrl(new URL("vfsfile:/tmp/some-ds.xml"));
// The base LocalDataSourceMeta
LocalDataSourceMetaData ds = new LocalDataSourceMetaData();
ds.setJndiName("java:DefaultDS1");
ds.setMaxSize(100);
ds.setMinSize(10);
ds.setPassword("password1".toCharArray());
ds.setUsername("username1");
SecMetaData smd1 = new SecMetaData();
smd1.setDomain("java:/jaas/domain1");
ds.setSecurityMetaData(smd1);
XADataSourceMetaData xads = new XADataSourceMetaData();
xads.setJndiName("java:DefaultXADS2");
ds.setMaxSize(100);
ds.setMinSize(10);
ds.setPassword("password2".toCharArray());
ds.setUsername("username2");
xads.setXaDataSourceClass("org.jboss.xa.SomeXADS");
xads.setXaResourceTimeout(300);
SecMetaData smd2 = new SecMetaData();
smd2.setDomain("java:/jaas/domain2");
xads.setSecurityMetaData(smd2);
ArrayList<ConnMetaData> deployments = new ArrayList<ConnMetaData>();
deployments.add(ds);
deployments.add(xads);
dsmd.setDeployments(deployments);
MutableAttachments a1 = (MutableAttachments) ctx1.getPredeterminedManagedObjects();
a1.addAttachment(DSMetaData.class, dsmd);
// The mbeans associated with the local DS
TestServiceMetaData localMBeans = new TestServiceMetaData();
localMBeans.setCode(DSService.class.getName());
ArrayList<TestServiceAttributeMetaData> localMBeanAttrs = new ArrayList<TestServiceAttributeMetaData>();
localMBeanAttrs.add(new TestServiceAttributeMetaData("java:DefaultDS1", "managementName"));
localMBeans.setAttributes(localMBeanAttrs);
a1.addAttachment(TestServiceMetaData.class, localMBeans);
ps.addDeployment(ctx1);
// Deploy security domain1
Deployment secCtx1 = createSimpleDeployment("sec-domain1");
MutableAttachments sda1 = (MutableAttachments) secCtx1.getPredeterminedManagedObjects();
SecurityDeployment sd1 = new SecurityDeployment();
sd1.setDomainName("java:/jaas/domain1");
sda1.addAttachment(SecurityDeployment.class, sd1);
ps.addDeployment(secCtx1);
// Deploy security domain2
Deployment secCtx2 = createSimpleDeployment("sec-domain2");
MutableAttachments sda2 = (MutableAttachments) secCtx2.getPredeterminedManagedObjects();
SecurityDeployment sd2 = new SecurityDeployment();
sd2.setDomainName("java:/jaas/domain2");
sda2.addAttachment(SecurityDeployment.class, sd2);
ps.addDeployment(secCtx2);
// Process the deployments to build the ManagedObjects
ps.process();
// Validate the deployment1 ManagedObjects
ManagedDeployment mo1 = ps.getManagedDeployment("deployment1");
validateDeployment1(mo1, ps);
// Validate that the ManagedDeployment is serializable
assertInstanceOf(mo1, Serializable.class);
byte[] bytes = serialize((Serializable)mo1);