Examples of PlutoWebXmlRewriter


Examples of org.apache.pluto.util.descriptors.web.PlutoWebXmlRewriter

        assembledWebXml.delete();
    }
   
    protected void verifyAssembly( InputStream webXml, InputStream portletXml ) throws Exception {
        PortletAppDescriptorService portletSvc = new PortletAppDescriptorServiceImpl();
        PlutoWebXmlRewriter webXmlRewriter = new PlutoWebXmlRewriter( webXml );
        PortletApplicationDefinition portletApp = portletSvc.read( "test", "/test", portletXml );
       
        assertNotNull( "Web Application Descripter was null.", webXmlRewriter );
        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.", webXmlRewriter.hasServlets() );
        assertTrue( "Web Application Descriptor doesn't define any servlet mappings.", webXmlRewriter.hasServletMappings() );
       
        PortletDefinition portlet = (PortletDefinition) portletApp.getPortlets().iterator().next();
        assertTrue( "Unable to retrieve test portlet named [" + testPortletName + "]", portlet.getPortletName().equals( testPortletName ) );
       
        String servletClassName = webXmlRewriter.getServletClass( testPortletName );
        assertNotNull( "Unable to retrieve portlet dispatch for portlet named [" + testPortletName + "]", servletClassName );       
        assertEquals( "Dispatcher servlet incorrect for test portlet [" + testPortletName + "]",  Assembler.DISPATCH_SERVLET_CLASS, servletClassName );       
    }
View Full Code Here

Examples of org.apache.pluto.util.descriptors.web.PlutoWebXmlRewriter

        assertNotNull( "Unable to retrieve portlet dispatch for portlet named [" + testPortletName + "]", servletClassName );       
        assertEquals( "Dispatcher servlet incorrect for test portlet [" + testPortletName + "]",  Assembler.DISPATCH_SERVLET_CLASS, servletClassName );       
    }

    protected void verifyAssembly( File warFile ) throws Exception {
        PlutoWebXmlRewriter webXmlRewriter = null;
        PortletAppDescriptorService portletSvc = new PortletAppDescriptorServiceImpl();
        int entryCount = 0;
        ByteArrayOutputStream portletXmlBytes = new ByteArrayOutputStream();
        ByteArrayOutputStream webXmlBytes = new ByteArrayOutputStream();
        PortletApplicationDefinition 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( "test", "/test", new ByteArrayInputStream( portletXmlBytes.toByteArray() ) );
            }
            if ( Assembler.SERVLET_XML.equals( tempEntry.getName() ) ) {
                IOUtils.copy( assembledWarIn, webXmlBytes );
                webXmlRewriter = new PlutoWebXmlRewriter( new ByteArrayInputStream( webXmlBytes.toByteArray() ) );
            }
        }
       
        assertTrue( "Assembled WAR file was empty.", entryCount > 0 );
        assertNotNull( "Web Application Descripter was null.", webXmlRewriter );
        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.", webXmlRewriter.hasServlets() );
        assertTrue( "Web Application Descriptor doesn't define any servlet mappings.", webXmlRewriter.hasServletMappings() );

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

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

Examples of org.apache.pluto.util.descriptors.web.PlutoWebXmlRewriter

                earFile.exists() && earFile.canRead() );
       
        PortletAppDescriptorService portletSvc = new PortletAppDescriptorServiceImpl();
        PortletApplicationDefinition portletApp = null;

        PlutoWebXmlRewriter webXmlRewriter = 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() ) ) {
                      portletApp = portletSvc.read( "test", "/test",
                                new ByteArrayInputStream( IOUtils.toByteArray( warIn ) ) );
                    }
                    if ( Assembler.SERVLET_XML.equals( warEntry.getName() ) ) {
                        webXmlRewriter = new PlutoWebXmlRewriter( 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", portletApp );
        assertNotNull( "WAR archive did not contain a servlet.xml", webXmlRewriter );
        assertTrue( "WAR archive did not contain any servlets", webXmlRewriter.hasServlets() );
        assertTrue( "WAR archive did not contain any servlet mappings", webXmlRewriter.hasServletMappings() );
        assertTrue( "WAR archive did not contain any portlets", portletApp.getPortlets().size() > 0 );
       
        PortletDefinition portlet = (PortletDefinition) portletApp.getPortlets().iterator().next();
        assertEquals( "Unexpected test portlet name.", testPortletName, portlet.getPortletName() );
       
        String servletClassName = webXmlRewriter.getServletClass( portlet.getPortletName() );
        assertNotNull( "web.xml does not contain assembly for test portlet", servletClassName );
        assertEquals( "web.xml does not contain correct dispatch servet", Assembler.DISPATCH_SERVLET_CLASS,
                servletClassName );
    }
View Full Code Here

Examples of org.apache.pluto.util.descriptors.web.PlutoWebXmlRewriter

                earFile.exists() && earFile.canRead() );
       
        PortletAppDescriptorService portletSvc = new PortletAppDescriptorServiceImpl();
        PortletApplicationDefinition portletApp = null;
       
        PlutoWebXmlRewriter webXmlRewriter = null;
       
        List<String> portletWarEntries = Arrays.asList( testWarEntryNames );
        List<String> unassembledWarEntries = Arrays.asList( unassembledWarEntryName );
        List<String> 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() ) ) {
                        portletApp = portletSvc.read( "test", "/test",
                                new ByteArrayInputStream( IOUtils.toByteArray( warIn ) ) );
                    }
                    if ( Assembler.SERVLET_XML.equals( warEntry.getName() ) ) {
                        webXmlRewriter = new PlutoWebXmlRewriter( new ByteArrayInputStream( IOUtils.toByteArray( warIn ) ) );
                    }
                }
               
                if ( portletWarEntries.contains( earEntry.getName() ) ) {
                    portletWarEntryCount++;
                    assertNotNull( "WAR archive did not contain a portlet.xml", portletApp );
                    assertNotNull( "WAR archive did not contain a servlet.xml", webXmlRewriter );
                    assertTrue( "WAR archive did not contain any servlets", webXmlRewriter.hasServlets() );
                    assertTrue( "WAR archive did not contain any servlet mappings", webXmlRewriter.hasServletMappings() );
                    assertTrue( "WAR archive did not contain any portlets", portletApp.getPortlets().size() > 0 );
                   
                    for ( Iterator<? extends PortletDefinition> iter = portletApp.getPortlets().iterator(); iter.hasNext(); ) {
                        PortletDefinition portlet = iter.next();
                        if (! testPortlets.contains( portlet.getPortletName() ) ) {
                            fail( "Unexpected test portlet name encountered: [" + portlet.getPortletName() + "]" );
                        }
                        String servletClassName = webXmlRewriter.getServletClass( portlet.getPortletName() );
                        assertNotNull( "web.xml does not contain assembly for test portlet", servletClassName );
                        assertEquals( "web.xml does not contain correct dispatch servet", Assembler.DISPATCH_SERVLET_CLASS,
                                servletClassName );
                    }
                   
View Full Code Here

Examples of org.apache.pluto.util.descriptors.web.PlutoWebXmlRewriter

        if (dispatchServletClass == null || dispatchServletClass.length() == 0 ||
            dispatchServletClass.trim().length() == 0)
        {
            dispatchServletClass = Assembler.DISPATCH_SERVLET_CLASS;
        }
        PlutoWebXmlRewriter webXmlRewriter = null;
        try
        {
            webXmlRewriter = new PlutoWebXmlRewriter(webXmlIn);
        }
        catch (Exception e)
        {
            if (e instanceof IOException)
            {
                throw (IOException) e;
            }
            throw new IOException(e.getMessage());
        }
        PortletApplicationDefinition portletAppDD = new PortletAppDescriptorServiceImpl().read("test", "/test", portletXmlIn);
        portletXmlIn.close();
        for (PortletDefinition portlet : portletAppDD.getPortlets())
        {
            webXmlRewriter.injectPortletServlet(dispatchServletClass, portlet.getPortletName());
        }
        webXmlRewriter.write(assembledWebXmlOut);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.