@Test
public void testThatEmbeddedLibsAreHandledProperly() throws Exception {

	WabProcessor wabProcessor = new TestWabProcessor(
		getFile("/tck-V3URLTests.wab.war"),
		Collections.singletonMap(
			"Web-ContextPath",
			new String[] {"/portlet-V3-annotated-demo"}));
	File processedFile = wabProcessor.getProcessedFile();
	Assert.assertNotNull(processedFile);
	try (Jar jar = new Jar(processedFile)) {
		// Check if the basic metadata is correct
		Assert.assertEquals("portlet-V3-annotated-demo", jar.getBsn());
		Assert.assertEquals("1.0.0", jar.getVersion());
		// Does this WAR have a beans.xml file that would trigger
		// OSGi CDI Integration analysis?
		Resource beansXMLFile = jar.getResource("WEB-INF/beans.xml");
		Assert.assertNotNull(beansXMLFile);
		// Did the beans.xml file have a discovery mode of none?
		try (InputStream inputStream = beansXMLFile.openInputStream()) {
			Document document = SAXReaderUtil.read(inputStream);
			Node beanDiscoveryMode = document.selectSingleNode(
				"/beans/@bean-discovery-mode");
			String value = beanDiscoveryMode.getStringValue();
			Assert.assertNotEquals("none", value);
		}
		// Finally, make sure the requirement on the OSGi CDI
		// Integration extender was added to the manifest
		Domain domain = Domain.domain(jar.getManifest());
		Parameters requirements = domain.getRequireCapability();
		Map.Entry<String, Attrs> entry = findRequirement(
			requirements, "osgi.extender",
			HashMapBuilder.<String, Object>put(
				"osgi.extender", "osgi.cdi"
			).put(
				"version", new Version(1)
			).build());
		Assert.assertNotNull(entry);
		// Assert the expected number of beans were discovered
		Attrs attrs = entry.getValue();
		List<String> beans = attrs.getTyped(Attrs.LIST_STRING, "beans");
		Assert.assertEquals(beans.toString(), 5, beans.size());
		List<String> expectedList = Arrays.asList(
			"javax.portlet.tck.portlets.URLTests_ActionURL",
			"javax.portlet.tck.portlets.URLTests_BaseURL",
			"javax.portlet.tck.portlets.URLTests_RenderURL",
			"javax.portlet.tck.portlets.URLTests_ResourceURL",
			"javax.portlet.tck.util.ModuleTestCaseDetails");
		Assert.assertEquals(expectedList.toString(), expectedList, beans);
		// Make sure other CDI requirements were added
		// The bean portlet extension
		Assert.assertNotNull(
			findRequirement(
				requirements, "osgi.cdi.extension",
				Collections.singletonMap(
					"osgi.cdi.extension",
					"com.liferay.bean.portlet.cdi.extension")));
		// The http extension
		Assert.assertNotNull(
			findRequirement(
				requirements, "osgi.cdi.extension",
				Collections.singletonMap(
					"osgi.cdi.extension", "aries.cdi.http")));
		// The EL extension
		Assert.assertNotNull(
			findRequirement(
				requirements, "osgi.cdi.extension",
				Collections.singletonMap(
					"osgi.cdi.extension", "aries.cdi.el.jsp")));
	}
}