public void testJavaBeanXmlAttribute() throws Exception {
ReferenceCollection referenceCollection = new MockReferenceCollection();
JavaBeanXmlAttributeBuilder javaBeanXmlAttributeBuilder = new JavaBeanXmlAttributeBuilder();
//this is kind of cheating, we rely on the builder to iterate through existing members of the collection.
referenceCollection.add(javaBeanXmlAttributeBuilder);
Naming naming = new Jsr77Naming();
new ServiceConfigBuilder(parentEnvironment, null, referenceCollection, null, naming);
ClassLoader cl = Thread.currentThread().getContextClassLoader();
final URL plan1 = cl.getResource("services/plan1.xml");
ModuleDocument doc = ModuleDocument.Factory.parse(plan1);
ModuleType plan = doc.getModule();
File outFile = File.createTempFile("foo", "bar");
outFile.delete();
if (!outFile.mkdirs()) {
fail("could not create temp dir");
}
try {
Environment environment = EnvironmentBuilder.buildEnvironment(plan.getEnvironment());
MockRepository mockRepository = new MockRepository();
ArtifactManager artifactManager = new DefaultArtifactManager();
ArtifactResolver artifactResolver = new DefaultArtifactResolver(artifactManager, Collections.singleton(mockRepository), null);
ConfigurationManager configurationManager = new SimpleConfigurationManager(Collections.EMPTY_SET, artifactResolver, Collections.EMPTY_SET);
DeploymentContext context = new DeploymentContext(outFile, null, environment, ConfigurationModuleType.CAR, naming, configurationManager, Collections.singleton(mockRepository));
AbstractName j2eeContext = naming.createRootName(environment.getConfigId(), environment.getConfigId().toString(), "Configuration");
GbeanType[] gbeans = plan.getGbeanArray();
ServiceConfigBuilder.addGBeans(gbeans, cl, j2eeContext, context);
Set gbeanNames = context.getGBeanNames();
assertEquals(1, gbeanNames.size());