public void testBuildEar() throws Exception {
JarFile rarFile = null;
try {
rarFile = JarUtils.createJarFile(new File(BASEDIR, "target/test-ear-noger.ear"));
GBeanBuilder serviceBuilder = new GBeanBuilder(null, null);
EARConfigBuilder configBuilder = new EARConfigBuilder(defaultEnvironment,
transactionManagerName,
connectionTrackerName,
null,
null,
new AbstractNameQuery(serverName, J2EEServerImpl.GBEAN_INFO.getInterfaces()),
Collections.singleton(repository),
null,
null,
new ConnectorModuleBuilder(defaultEnvironment, defaultMaxSize, defaultMinSize, defaultBlockingTimeoutMilliseconds, defaultidleTimeoutMinutes, defaultXATransactionCaching, defaultXAThreadCaching, defaultWorkManagerName, Collections.<NamespaceDrivenBuilder>singleton(serviceBuilder), null, bundleContext),
activationSpecInfoLocator,
null,
serviceBuilder,
null,
null,
new NamingBuilderCollection(Collections.<NamingBuilder>emptyList()),
kernel.getNaming(),
null,
bundleContext);
configBuilder.doStart();
ConfigurationData configData = null;
DeploymentContext context = null;
ArtifactManager artifactManager = new DefaultArtifactManager();
ArtifactResolver artifactResolver = new DefaultArtifactResolver(artifactManager, repository);
try {
File planFile = new File(BASEDIR, "src/test/resources/data/external-application-plan.xml");
ModuleIDBuilder idBuilder = new ModuleIDBuilder();
Object plan = configBuilder.getDeploymentPlan(planFile, rarFile, idBuilder);
context = configBuilder.buildConfiguration(false, configBuilder.getConfigurationID(plan, rarFile, idBuilder), plan, rarFile, Collections.singleton(configurationStore), artifactResolver, configurationStore);
// add the a j2ee server so the application context reference can be resolved
context.addGBean("geronimo", J2EEServerImpl.GBEAN_INFO);
// add the module validator so the connector artifacts will resolve to an instance
AbstractName abstractName = context.getNaming().createChildName(((Module)plan).getModuleName(), "ValidatorFactory", NameFactory.VALIDATOR_FACTORY);
GBeanData gbeanData = new GBeanData(abstractName, ValidatorFactoryGBean.class);
context.addGBean(gbeanData);
configData = context.getConfigurationData();
} finally {
if (context != null) {
context.close();
}
if (configData != null) {
FileUtils.recursiveDelete(configData.getConfigurationDir());
}
}
configBuilder.doStop();
} finally {
JarUtils.close(rarFile);
}
}