earFile.exists() && earFile.canRead() );
PortletAppDescriptorService portletSvc = new PortletAppDescriptorServiceImpl();
WebAppDescriptorService webSvc = new WebAppDescriptorServiceImpl();
PortletAppDD portletAppDD = null;
WebAppDD webAppDD = null;
List portletWarEntries = Arrays.asList( testWarEntryNames );
List unassembledWarEntries = Arrays.asList( unassembledWarEntryName );
List testPortlets = Arrays.asList( testPortletNames );
int earEntryCount = 0;
int totalWarEntryCount = 0;
int portletWarEntryCount = 0;
JarInputStream earIn = new JarInputStream( new FileInputStream( earFile ) );
JarEntry earEntry;
JarEntry warEntry;
while ( ( earEntry = earIn.getNextJarEntry() ) != null ) {
earEntryCount++;
if ( earEntry.getName().endsWith( ".war" ) ) {
totalWarEntryCount++;
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 ) ) );
}
}
if ( portletWarEntries.contains( earEntry.getName() ) ) {
portletWarEntryCount++;
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 );
for ( Iterator iter = portletAppDD.getPortlets().iterator(); iter.hasNext(); ) {
PortletDD portlet = (PortletDD) iter.next();
if (! testPortlets.contains( portlet.getPortletName() ) ) {
fail( "Unexpected test portlet name encountered: [" + portlet.getPortletName() + "]" );
}
ServletDD servlet = webAppDD.getServlet( portlet.getPortletName() );
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() );
}