Package org.apache.pluto.descriptors.servlet

Examples of org.apache.pluto.descriptors.servlet.WebAppDD


                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() );
                    }
                   
View Full Code Here


    }
   
    protected void verifyAssembly( InputStream webXml, InputStream portletXml ) throws Exception {
        WebAppDescriptorService webSvc = new WebAppDescriptorServiceImpl();
        PortletAppDescriptorService portletSvc = new PortletAppDescriptorServiceImpl();
        WebAppDD webApp = webSvc.read( webXml ) ;
        PortletAppDD portletApp = portletSvc.read( portletXml );
       
        assertNotNull( "Web Application Descripter was null.", webApp );
        assertNotNull( "Portlet Application Descriptor was null.", portletApp );
        assertTrue( "Portlet Application Descriptor doesn't define any portlets.", portletApp.getPortlets().size() > 0 );
        assertTrue( "Web Application Descriptor doesn't define any servlets.", webApp.getServlets().size() > 0 );
        assertTrue( "Web Application Descriptor doesn't define any servlet mappings.", webApp.getServletMappings().size() > 0 );
       
        PortletDD portlet = (PortletDD) portletApp.getPortlets().iterator().next();
        assertTrue( "Unable to retrieve test portlet named [" + testPortletName + "]", portlet.getPortletName().equals( testPortletName ) );
       
        ServletDD servlet = webApp.getServlet( testPortletName );
        assertNotNull( "Unable to retrieve portlet dispatch for portlet named [" + testPortletName + "]", servlet );       
        assertEquals( "Dispatcher servlet incorrect for test portlet [" + testPortletName + "]",  Assembler.DISPATCH_SERVLET_CLASS, servlet.getServletClass() );       
    }
View Full Code Here

        WebAppDescriptorService webSvc = new WebAppDescriptorServiceImpl();
        PortletAppDescriptorService portletSvc = new PortletAppDescriptorServiceImpl();
        int entryCount = 0;
        ByteArrayOutputStream portletXmlBytes = new ByteArrayOutputStream();
        ByteArrayOutputStream webXmlBytes = new ByteArrayOutputStream();
        WebAppDD webApp = null;
        PortletAppDD portletApp = null;       
               
        JarInputStream assembledWarIn = new JarInputStream( new FileInputStream( warFile ) );
        JarEntry tempEntry;
       
        while ( ( tempEntry = assembledWarIn.getNextJarEntry() ) != null  ) {
            entryCount++;
           
            if ( Assembler.PORTLET_XML.equals( tempEntry.getName() ) ) {
                IOUtils.copy( assembledWarIn, portletXmlBytes );
                portletApp = portletSvc.read( new ByteArrayInputStream( portletXmlBytes.toByteArray() ) );
            }
            if ( Assembler.SERVLET_XML.equals( tempEntry.getName() ) ) {
                IOUtils.copy( assembledWarIn, webXmlBytes );
                webApp = webSvc.read( new ByteArrayInputStream( webXmlBytes.toByteArray() ) );
            }
        }
       
        assertTrue( "Assembled WAR file was empty.", entryCount > 0 );
        assertNotNull( "Web Application Descripter was null.", webApp );
        assertNotNull( "Portlet Application Descriptor was null.", portletApp );
        assertTrue( "Portlet Application Descriptor doesn't define any portlets.", portletApp.getPortlets().size() > 0 );
        assertTrue( "Web Application Descriptor doesn't define any servlets.", webApp.getServlets().size() > 0 );
        assertTrue( "Web Application Descriptor doesn't define any servlet mappings.", webApp.getServletMappings().size() > 0 );

        PortletDD portlet = (PortletDD) portletApp.getPortlets().iterator().next();
        assertTrue( "Unable to retrieve test portlet named [" + testPortletName + "]", portlet.getPortletName().equals( testPortletName ) );

        ServletDD servlet = webApp.getServlet( testPortletName );
        assertNotNull( "Unable to retrieve portlet dispatch for portlet named [" + testPortletName + "]", servlet );       
        assertEquals( "Dispatcher servlet incorrect for test portlet [" + testPortletName + "]",  Assembler.DISPATCH_SERVLET_CLASS, servlet.getServletClass() );
    }
View Full Code Here

        in = null;
    }

    public void testRead() throws Exception
    {
        WebAppDD webappdd = underTest.read(in);
        assertNotNull(webappdd);
        assertEquals("2.3", webappdd.getServletVersion());
    }
View Full Code Here

    public void testWrite() throws Exception
    {
        File outputFile = File.createTempFile( "webapp-2.3-descriptor-test", ".xml" );
        OutputStream out = new FileOutputStream( outputFile );
        WebAppDD webappdd = underTest.read(in);
        underTest.write(webappdd, out);
        // now round-trip it
        WebAppDD webappdd2 = underTest.read(new FileInputStream(outputFile));
        assertNotNull(webappdd2);
        assertEquals("2.3", webappdd2.getServletVersion());
        outputFile.delete();
    }
View Full Code Here

        underTest = null;
    }

    public void testRead() throws Exception
    {
        WebAppDD webapp = underTest.read(in);
        assertNotNull(webapp);
        assertEquals("2.4", webapp.getServletVersion());
    }
View Full Code Here

        assertEquals("2.4", webapp.getServletVersion());
    }

    public void testWrite() throws Exception
    {
        WebAppDD webapp = underTest.read(in);
        File outputFile = File.createTempFile("webapp-2.4-descriptor-test", ".xml");
        FileOutputStream out = new FileOutputStream(outputFile);
        underTest.write(webapp, out);
        // roundtrip it.
        WebAppDD webapp2 = underTest.read(new FileInputStream(outputFile));
        assertNotNull(webapp2);
        assertEquals("2.4", webapp2.getServletVersion());
        outputFile.delete();
    }
View Full Code Here

     *
     * @return WebAppDD instance representing the descriptor.
     * @throws IOException
     */
    public WebAppDD read(InputStream in) throws IOException {
        WebAppDD webApp = (WebAppDD) readInternal(in);
       return webApp;
    }
View Full Code Here

    }

    public void updateDescriptors()
        throws IOException {
        PortletAppDD portletApp = portletAppDescriptorService.read();
        WebAppDD webApp = webAppDescriptorService.read();

        Iterator portlets = portletApp.getPortlets().iterator();
        PortletDD portlet;
        while (portlets.hasNext()) {
            portlet = (PortletDD) portlets.next();
View Full Code Here

     *
     * @return WebAppDD instance representing the descriptor.
     * @throws IOException
     */
    public WebAppDD read(InputStream in) throws IOException {
        WebAppDD webApp = (WebAppDD) readInternal(in);
       return webApp;
    }
View Full Code Here

TOP

Related Classes of org.apache.pluto.descriptors.servlet.WebAppDD

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.