use of org.jboss.weld.bootstrap.spi.BeansXml in project core by weld.
the class BeansXmlParsingTest method testExplicitVersionAndMode3.
@Test
public void testExplicitVersionAndMode3() {
BeansXml xml = getBeansXml("cdi11-beans3b.xml");
assertEquals(xml.getBeanDiscoveryMode(), BeanDiscoveryMode.ANNOTATED);
assertEquals(xml.getVersion(), "1.1");
}
use of org.jboss.weld.bootstrap.spi.BeansXml in project core by weld.
the class BeansXmlParsingTest method testNoSchemaNoAttributes.
@Test
public void testNoSchemaNoAttributes() {
BeansXml xml = getBeansXml("cdi11-beans1.xml");
assertEquals(xml.getBeanDiscoveryMode(), BeanDiscoveryMode.ALL);
assertNull(xml.getVersion());
}
use of org.jboss.weld.bootstrap.spi.BeansXml in project core by weld.
the class BeansXmlMergingTest method testDuplicatesInSingleFileAreNotRemoved.
@Test
public void testDuplicatesInSingleFileAreNotRemoved() {
WeldBootstrap weldBootstrap = new WeldBootstrap();
URL url = getClass().getResource("/org/jboss/weld/tests/unit/bootstrap/xml/beans3.xml");
BeansXml beansXml = weldBootstrap.parse(Collections.singletonList(url), true);
assertEquals(2, beansXml.getEnabledAlternativeStereotypes().size());
assertEquals(2, beansXml.getEnabledAlternativeClasses().size());
assertEquals(2, beansXml.getEnabledInterceptors().size());
assertEquals(2, beansXml.getEnabledDecorators().size());
}
use of org.jboss.weld.bootstrap.spi.BeansXml in project Payara by payara.
the class DeploymentImpl method createModuleBda.
private void createModuleBda(ReadableArchive archive, Collection<EjbDescriptor> ejbs, DeploymentContext context, String moduleName) {
RootBeanDeploymentArchive rootBda = new RootBeanDeploymentArchive(archive, ejbs, context, moduleName);
BeanDeploymentArchive moduleBda = rootBda.getModuleBda();
BeansXml moduleBeansXml = moduleBda.getBeansXml();
if (moduleBeansXml == null || !moduleBeansXml.getBeanDiscoveryMode().equals(BeanDiscoveryMode.NONE)) {
addBdaToDeploymentBdas(rootBda);
addBdaToDeploymentBdas(moduleBda);
addBeanDeploymentArchives(rootBda);
}
// first check if the parent is an ear and if so see if there are app libs defined there.
if (!earContextAppLibBdasProcessed && context instanceof DeploymentContextImpl) {
DeploymentContextImpl deploymentContext = (DeploymentContextImpl) context;
DeploymentContext parentContext = deploymentContext.getParentContext();
if (parentContext != null) {
processBdasForAppLibs(parentContext.getSource(), parentContext);
parentContext.getSource();
earContextAppLibBdasProcessed = true;
}
}
// then check the module
processBdasForAppLibs(archive, context);
}
use of org.jboss.weld.bootstrap.spi.BeansXml in project Payara by payara.
the class RootBeanDeploymentArchiveTest method testConstructor.
@Test
public void testConstructor() throws Exception {
String archiveName = "an";
String webInfLib1 = "WEB-INF/lib/lib1.jar";
String webInfLib2 = "WEB-INF/lib/lib2.jar";
String subArchive11Name = "sa1";
String subArchive12Name = "sa2";
URI webInfLib1URI = URI.create(webInfLib1);
URI webInfLib2URI = URI.create(webInfLib2);
ArrayList<String> lib1ClassNames = new ArrayList<>();
lib1ClassNames.add(Lib1Class1.class.getName() + ".class");
lib1ClassNames.add(Lib1Class2.class.getName() + ".class");
ArrayList<String> lib2ClassNames = new ArrayList<>();
lib2ClassNames.add(Lib2Class1.class.getName() + ".class");
lib2ClassNames.add(Lib2Class2.class.getName() + ".class");
WeldUtils.BDAType bdaType = WeldUtils.BDAType.WAR;
ArrayList<String> webInfLibEntries = new ArrayList<>();
webInfLibEntries.add(webInfLib1);
webInfLibEntries.add(webInfLib2);
EasyMockSupport mockSupport = new EasyMockSupport();
BeansXml beansXML = mockSupport.createMock(BeansXml.class);
WeldBootstrap wb = mockSupport.createMock(WeldBootstrap.class);
ReadableArchive readableArchive = mockSupport.createMock(ReadableArchive.class);
ReadableArchive subArchive1 = mockSupport.createMock(ReadableArchive.class);
ReadableArchive subArchive2 = mockSupport.createMock(ReadableArchive.class);
Collection<EjbDescriptor> ejbs = Collections.emptyList();
DeploymentContext deploymentContext = mockSupport.createMock(DeploymentContext.class);
expect(deploymentContext.getClassLoader()).andReturn(null).anyTimes();
expect(readableArchive.getName()).andReturn(archiveName).anyTimes();
expect(readableArchive.exists(WeldUtils.WEB_INF_BEANS_XML)).andReturn(true).anyTimes();
expect(readableArchive.exists(WeldUtils.WEB_INF_CLASSES_META_INF_BEANS_XML)).andReturn(false).anyTimes();
// in BeanDeploymentArchiveImpl.populate
expect(deploymentContext.getTransientAppMetadata()).andReturn(null).anyTimes();
expect(deploymentContext.getModuleMetaData(Application.class)).andReturn(null).anyTimes();
expect(deploymentContext.getTransientAppMetaData(WeldDeployer.WELD_BOOTSTRAP, WeldBootstrap.class)).andReturn(wb).anyTimes();
expect(wb.parse(anyObject(URL.class))).andReturn(beansXML).anyTimes();
expect(readableArchive.getURI()).andReturn(URI.create("an.war")).anyTimes();
expect(subArchive1.getURI()).andReturn(webInfLib1URI).anyTimes();
expect(subArchive2.getURI()).andReturn(webInfLib2URI).anyTimes();
expect(beansXML.getBeanDiscoveryMode()).andReturn(BeanDiscoveryMode.ALL).anyTimes();
expect(readableArchive.entries()).andReturn(Collections.<String>emptyEnumeration());
readableArchive.close();
expect(readableArchive.exists(WeldUtils.WEB_INF_LIB)).andReturn(true).anyTimes();
expect(readableArchive.entries(WeldUtils.WEB_INF_LIB)).andReturn(Collections.enumeration(webInfLibEntries));
expect(readableArchive.getSubArchive(webInfLib1)).andReturn(subArchive1);
expect(subArchive1.exists(WeldUtils.META_INF_BEANS_XML)).andReturn(true);
expect(readableArchive.getSubArchive(webInfLib2)).andReturn(subArchive2);
expect(subArchive2.exists(WeldUtils.META_INF_BEANS_XML)).andReturn(true);
// build new BeanDeploymentArchiveImpl for lib1 and lib2
setupMocksForWebInfLibBda(subArchive1, subArchive11Name, lib1ClassNames);
setupMocksForWebInfLibBda(subArchive2, subArchive12Name, lib2ClassNames);
readableArchive.close();
mockSupport.replayAll();
RootBeanDeploymentArchive rootBeanDeploymentArchive = new RootBeanDeploymentArchive(readableArchive, ejbs, deploymentContext);
assertEquals("root_" + archiveName, rootBeanDeploymentArchive.getId());
assertEquals(WeldUtils.BDAType.UNKNOWN, rootBeanDeploymentArchive.getBDAType());
assertEquals(0, rootBeanDeploymentArchive.getBeanClasses().size());
assertEquals(0, rootBeanDeploymentArchive.getBeanClassObjects().size());
assertNull(rootBeanDeploymentArchive.getBeansXml());
BeanDeploymentArchiveImpl moduleBda = (BeanDeploymentArchiveImpl) rootBeanDeploymentArchive.getModuleBda();
assertNotNull(moduleBda);
assertEquals(WeldUtils.BDAType.WAR, moduleBda.getBDAType());
assertEquals(3, rootBeanDeploymentArchive.getBeanDeploymentArchives().size());
assertTrue(rootBeanDeploymentArchive.getBeanDeploymentArchives().contains(moduleBda));
assertEquals(3, moduleBda.getBeanDeploymentArchives().size());
assertTrue(moduleBda.getBeanDeploymentArchives().contains(rootBeanDeploymentArchive));
assertEquals(0, rootBeanDeploymentArchive.getModuleBeanClasses().size());
assertEquals(0, rootBeanDeploymentArchive.getModuleBeanClassObjects().size());
assertSame(rootBeanDeploymentArchive.getModuleClassLoaderForBDA(), moduleBda.getModuleClassLoaderForBDA());
mockSupport.verifyAll();
mockSupport.resetAll();
}
Aggregations