earFile.exists() && earFile.canRead() );
PortletAppDescriptorService portletSvc = new PortletAppDescriptorServiceImpl();
WebAppDescriptorService webSvc = new WebAppDescriptorServiceImpl();
PortletAppDD portletAppDD = null;
WebAppDD webAppDD = null;
int earEntryCount = 0;
int warEntryCount = 0;
JarInputStream earIn = new JarInputStream( new FileInputStream( earFile ) );
JarEntry earEntry;
JarEntry warEntry;
while ( ( earEntry = earIn.getNextJarEntry() ) != null ) {
earEntryCount++;
if ( earEntry.getName().endsWith( ".war" ) ) {
warEntryCount++;
JarInputStream warIn = new JarInputStream( earIn );
while ( ( warEntry = warIn.getNextJarEntry() ) != null ) {
if ( Assembler.PORTLET_XML.equals( warEntry.getName() ) ) {
portletAppDD = portletSvc.read(
new ByteArrayInputStream( IOUtils.toByteArray( warIn ) ) );
}
if ( Assembler.SERVLET_XML.equals( warEntry.getName() ) ) {
webAppDD = webSvc.read(
new ByteArrayInputStream( IOUtils.toByteArray( warIn ) ) );
}
}
}
}
assertTrue( "EAR archive did not contain any entries", earEntryCount > 0 );
assertTrue( "WAR archive did not contain any entries", warEntryCount > 0 );
assertNotNull( "WAR archive did not contain a portlet.xml", portletAppDD );
assertNotNull( "WAR archive did not contain a servlet.xml", webAppDD );
assertTrue( "WAR archive did not contain any servlets", webAppDD.getServlets().size() > 0 );
assertTrue( "WAR archive did not contain any servlet mappings", webAppDD.getServletMappings().size() > 0 );
assertTrue( "WAR archive did not contain any portlets", portletAppDD.getPortlets().size() > 0 );
PortletDD portlet = (PortletDD) portletAppDD.getPortlets().iterator().next();
assertEquals( "Unexpected test portlet name.", testPortletName, portlet.getPortletName() );
ServletDD servlet = webAppDD.getServlet( testPortletName );
assertNotNull( "web.xml does not contain assembly for test portlet", servlet );
assertEquals( "web.xml does not contain correct dispatch servet", Assembler.DISPATCH_SERVLET_CLASS,
servlet.getServletClass() );
}