Package org.apache.pluto.descriptors.servlet

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


     *
     * @return WebAppDD instance representing the descriptor.
     * @throws IOException
     */
    public WebAppDD read() throws IOException {
        WebAppDD webApp = (WebAppDD) readInternal();
        if(webApp == null && create) {
            webApp = new WebAppDD();
            webApp.setDisplayName("Portal Application");
            webApp.setDescription("Auto Generated Portal Application Wrapper");
        }
        return webApp;
    }
View Full Code Here


        .append(securityRole).append(envEntry).append(ejbRef)
        .append(xmlEnd);

        InputStream in = new ByteArrayInputStream(xml.toString().getBytes());

        WebAppDD dd = impl.read(in);

        Assert.assertEquals("DisplayName not as expected", "Test Web XML", dd.getDisplayName());
        Assert.assertEquals("Description does not match", "This is a test web.xml file.", dd.getDescription());
        //Assert.assertTrue("Distributable not set", dd.isDistributable());

        assertEquals("Context Parameters not as expected", 2, dd.getContextParams().size());
        assertEquals("Filters not as expected", 1, dd.getFilters().size());
        assertEquals("Filter Mappings not as expected", 2, dd.getFilterMappings().size());
        assertEquals("Listeners not as expected", 2, dd.getListeners().size());
        assertEquals("Servlets not as expected", 2, dd.getServlets().size());
        assertEquals("Servlet Mappings not as expected.", 3, dd.getServletMappings().size());
    }
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

        .append(securityRole).append(envEntry).append(ejbRef)
        .append(xmlEnd);

        InputStream in = new ByteArrayInputStream(xml.toString().getBytes());

        WebAppDD dd = impl.read(in);

        Assert.assertEquals("DisplayName not as expected", "Test Web XML", dd.getDisplayName());
        Assert.assertEquals("Description does not match", "This is a test web.xml file.", dd.getDescription());
        //Assert.assertTrue("Distributable not set", dd.isDistributable());

        assertEquals("Context Parameters not as expected", 2, dd.getContextParams().size());
        assertEquals("Filters not as expected", 1, dd.getFilters().size());
        assertEquals("Filter Mappings not as expected", 2, dd.getFilterMappings().size());
        assertEquals("Listeners not as expected", 2, dd.getListeners().size());
        assertEquals("Servlets not as expected", 2, dd.getServlets().size());
        assertEquals("Servlet Mappings not as expected.", 3, dd.getServletMappings().size());
    }
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

        }

      WebAppDescriptorService descriptorSvc = new WebAppDescriptorServiceImpl()
      PortletAppDescriptorService portletAppDescriptorSvc = new PortletAppDescriptorServiceImpl();
       
        WebAppDD webAppDDIn = descriptorSvc.read(webXmlIn);
        PortletAppDD portletAppDD = portletAppDescriptorSvc.read(portletXmlIn);
        portletXmlIn.close();

        for (Iterator it = portletAppDD.getPortlets().iterator();
                it.hasNext(); ) {

            // Read portlet definition.
            PortletDD portlet = (PortletDD) it.next();
            String name = portlet.getPortletName();

            ServletDD servlet = new ServletDD();
            servlet.setServletName(name);

            servlet.setServletClass(dispatchServletClass);

            InitParamDD initParam = new InitParamDD();
            initParam.setParamName("portlet-name");
            initParam.setParamValue(name);
            servlet.getInitParams().add(initParam);

            LoadOnStartupDD onStartup = new LoadOnStartupDD();
            onStartup.setPriority(1);
            servlet.setLoadOnStartup(onStartup);

            ServletMappingDD servletMapping = new ServletMappingDD();
            servletMapping.setServletName(name);
            servletMapping.setUrlPattern("/PlutoInvoker/" + name);

            webAppDDIn.getServlets().add(servlet);
            webAppDDIn.getServletMappings().add(servletMapping);

        }

        descriptorSvc.write(webAppDDIn, assembledWebXmlOut);
       
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

    protected abstract String getDescriptorVersion();

    public final void testRead() throws Exception
    {
        final InputStream descriptorStream = this.getDescriptorStream();
        WebAppDD webappdd = underTest.read(descriptorStream);
        assertNotNull(webappdd);
        assertEquals(this.getDescriptorVersion(), webappdd.getServletVersion());
    }
View Full Code Here

        XMLUnit.setIgnoreWhitespace(true);
       
        File outputFile = File.createTempFile("web-app-descriptor-test", ".xml");
        OutputStream out = new FileOutputStream(outputFile);
        final InputStream descriptorStream = this.getDescriptorStream();
        WebAppDD webappdd = underTest.read(descriptorStream);
        underTest.write(webappdd, out);
       
        final InputStream expectedDescriptorStream = getExpectedDescriptorStream();
        // Use DetailedDiff to list all differences
        final DetailedDiff diff = new DetailedDiff(
                new Diff(new InputStreamReader(expectedDescriptorStream), new FileReader(outputFile))
                );
        final List diffs = diff.getAllDifferences();
        // diffs.size() will be 0 if no differences were found.
        assertEquals( "Encountered differences in XML: " + System.getProperty( "line.separator" ) +
                diff.toString(),
                0, diffs.size() );
       
        // now round-trip it
        WebAppDD webappdd2 = underTest.read(new FileInputStream(outputFile));
        assertNotNull(webappdd2);
        assertEquals(this.getDescriptorVersion(), webappdd2.getServletVersion());
        outputFile.delete();
    }
View Full Code Here

                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() );
               
    }
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.