Examples of PortletAppDD


Examples of org.apache.pluto.descriptors.portlet.PortletAppDD

    }
   
    public void testParseFull() throws IOException {
        InputStream in = this.getClass().getResourceAsStream("/portlet-full.xml");
       
        PortletAppDD dd = service.read(in);
        assertEquals("1.0", dd.getVersion());
       
       
        List customPortletModes = dd.getCustomPortletModes();
        assertEquals(2, customPortletModes.size());
       
        CustomPortletModeDD cpm1 = (CustomPortletModeDD)customPortletModes.get(0);
        assertEquals("customMode", cpm1.getPortletMode());
        assertEquals(1, cpm1.getDescriptions().size());
       
        CustomPortletModeDD cpm2 = (CustomPortletModeDD)customPortletModes.get(1);
        assertEquals("customMode2", cpm2.getPortletMode());
        assertEquals(1, cpm2.getDescriptions().size());
       
        assertEquals(2, dd.getCustomWindowStates().size());
        assertEquals(1, dd.getUserAttributes().size());

        assertEquals(1, dd.getSecurityConstraints().size());
        SecurityConstraintDD sc = (SecurityConstraintDD)dd.getSecurityConstraints().get(0);
        assertNotNull(sc.getPortletCollection());
        assertEquals(1, sc.getDisplayNames().size());
        assertEquals(3, sc.getPortletCollection().getPortletNames().size());
        assertEquals("a", sc.getPortletCollection().getPortletNames().get(0));
        assertEquals("b", sc.getPortletCollection().getPortletNames().get(1));
        assertEquals("c", sc.getPortletCollection().getPortletNames().get(2));

        assertNotNull(sc.getUserDataConstraint());
        assertEquals(1, sc.getUserDataConstraint().getDescriptions().size());
        assertEquals("NONE", sc.getUserDataConstraint().getTransportGuarantee());
       
        List portlets = dd.getPortlets();
        assertEquals(1, portlets.size());
        PortletDD pd = (PortletDD)portlets.get(0);
       
        assertEquals(1, pd.getDescriptions().size());
        assertEquals(2, pd.getDisplayNames().size());
View Full Code Here

Examples of org.apache.pluto.descriptors.portlet.PortletAppDD

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

Examples of org.apache.pluto.descriptors.portlet.PortletAppDD

        assertTrue( "EAR archive [" + earFile.getAbsolutePath() + "] cannot be found or cannot be read",
                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,
View Full Code Here

Examples of org.apache.pluto.descriptors.portlet.PortletAppDD

        assertTrue( "EAR archive [" + earFile.getAbsolutePath() + "] cannot be found or cannot be read",
                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() );
View Full Code Here

Examples of org.apache.pluto.descriptors.portlet.PortletAppDD

   
    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

Examples of org.apache.pluto.descriptors.portlet.PortletAppDD

        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

Examples of org.apache.pluto.descriptors.portlet.PortletAppDD

     * @throws PortletContainerException
     */
    public String register(ServletConfig config) throws PortletContainerException {
        InternalPortletContext portletContext = register(config.getServletContext());

        PortletAppDD portletAppDD =
            portletContext.getPortletApplicationDefinition();
        PortletDD portletDD = null;

        LOG.info("Registering "+portletAppDD.getPortlets().size()+" portlets for context "+portletContext.getApplicationId());

        for (Iterator it = portletAppDD.getPortlets().iterator(); it.hasNext();) {
            portletDD = (PortletDD) it.next();
            portletConfigs.put(
                portletContext.getApplicationId() + "/" + portletDD.getPortletName(),
                new PortletConfigImpl(config, portletContext, portletDD)
            );
View Full Code Here

Examples of org.apache.pluto.descriptors.portlet.PortletAppDD

    public InternalPortletContext register(ServletContext servletContext)
        throws PortletContainerException {
        String applicationId = getContextPath(servletContext);
        if (!portletContexts.containsKey(applicationId)) {

            PortletAppDD portletAppDD = PortletDescriptorRegistry.getRegistry()
                .getPortletAppDD(servletContext);

            PortletContextImpl portletContext = new PortletContextImpl(
                applicationId, servletContext, portletAppDD);
View Full Code Here

Examples of org.apache.pluto.descriptors.portlet.PortletAppDD

    }

    public void testParse() throws IOException {
        InputStream in = new ByteArrayInputStream(xml.toString().getBytes());

        PortletAppDD dd = service.read(in);
        assertEquals("1.0", dd.getVersion());
        assertEquals(1, dd.getPortlets().size());

        PortletDD pd = (PortletDD)dd.getPortlets().get(0);
        assertEquals(2, pd.getDisplayNames().size());
        assertEquals(1, pd.getDescriptions().size());
        assertEquals("About Portlet", ((DisplayNameDD)pd.getDisplayNames().get(0)).getDisplayName());
        assertEquals("en", ((DisplayNameDD)pd.getDisplayNames().get(0)).getLang());
        assertEquals("fr", ((DisplayNameDD)pd.getDisplayNames().get(1)).getLang());
        assertEquals(30, pd.getExpirationCache());
        assertEquals(1, pd.getSupportedLocales().size());
        assertEquals("en", pd.getSupportedLocales().get(0));
        assertEquals(1, pd.getInitParams().size());
        assertEquals(1, ((InitParamDD)pd.getInitParams().get(0)).getDescriptions().size());

        assertEquals(2, dd.getCustomPortletModes().size());
        assertEquals(2, dd.getCustomWindowStates().size());
        assertEquals(1, dd.getUserAttributes().size());
        assertEquals(1, dd.getSecurityConstraints().size());

        SecurityConstraintDD sc = (SecurityConstraintDD)dd.getSecurityConstraints().get(0);
        assertNotNull(sc.getPortletCollection());
        assertEquals(1, sc.getDisplayNames().size());
        assertEquals(3, sc.getPortletCollection().getPortletNames().size());
        assertEquals("a", sc.getPortletCollection().getPortletNames().get(0));
        assertEquals("b", sc.getPortletCollection().getPortletNames().get(1));
View Full Code Here

Examples of org.apache.pluto.descriptors.portlet.PortletAppDD

            LOG.debug("Retrieved cross context: " + crossContext);
        }

        // Load PortletAppDD and find out the portlet definition.
        try {
            PortletAppDD appDD = PortletDescriptorRegistry.getRegistry()
                .getPortletAppDD(crossContext);
            for (Iterator it = appDD.getPortlets().iterator(); it.hasNext(); ) {
                PortletDD portletDD = (PortletDD) it.next();
                if (portletDD.getPortletName().equals(portletName)) {
                  portletDefinition = portletDD;
                  break;
                }
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.