Package org.apache.shale.clay.config.beans

Examples of org.apache.shale.clay.config.beans.ComponentBean


        // +8
        // +9

        AttributeBean attr = null;
        ElementBean child = null;
        ComponentBean root = createVerbatim(ComponentBean.class, "0");
        // root is not a verbatim
        root.setJsfid("outputText");

        child = (ElementBean) createVerbatim(ElementBean.class, "1");
        child.setRenderId(1);
        root.addChild(child);
       

        child = (ElementBean) createVerbatim(ElementBean.class, "2");
        child.setRenderId(2);
        root.addChild(child);

        child = (ElementBean) createVerbatim(ElementBean.class, "3");
        child.setRenderId(3);
        // root is not a verbatim
        child.setJsfid("outputText");
        root.addChild(child);

        child = (ElementBean) createVerbatim(ElementBean.class, "4");
        child.setRenderId(4);
        root.addChild(child);

        child = (ElementBean) createVerbatim(ElementBean.class, "5");
        child.setRenderId(5);
        // root is not a verbatim
        child.setJsfid("outputText");
        root.addChild(child);

        child = (ElementBean) createVerbatim(ElementBean.class, "6");
        child.setRenderId(6);
        root.addChild(child);

        child = (ElementBean) createVerbatim(ElementBean.class, "7");
        child.setRenderId(7);
        // root is not a verbatim
        child.setJsfid("outputText");
        root.addChild(child);

        child = (ElementBean) createVerbatim(ElementBean.class, "8");
        child.setRenderId(8);
        root.addChild(child);

        child = (ElementBean) createVerbatim(ElementBean.class, "9");
        child.setRenderId(9);
        root.addChild(child);

        ((TemplateConfigBean) htmlTemplateConfigBean).optimizeTree(root);

        assertEquals("#Children", 7, root.getChildren().size());

        Iterator ci = root.getChildren().iterator();
        int i = 0;
        while (ci.hasNext()) {
            child = (ElementBean) ci.next();

            switch (++i) {
View Full Code Here


       Map requestParams = new TreeMap();
       //context root import
       requestParams.put("url", "/org/apache/shale/clay/utils/hello.html");
       externalContext.setRequestParameterMap(requestParams);
      
       ComponentBean displayElement = new ComponentBean();
       displayElement.setId("clayImport");
       displayElement.setComponentType("org.apache.shale.clay.component.Clay");
       displayElement.setJsfid("clayImport");
       
       UIComponent component = application.createComponent("org.apache.shale.clay.component.Clay");    
       component.setId("clayImport");
       component.getAttributes().put("url","#{param.url}");
       component.getAttributes().put("escapeXml", Boolean.TRUE.toString());
      
       clayAmalgam.clayImport(facesContext, component, displayElement);
      
       assertEquals("jsfid", "outputText", displayElement.getJsfid());
       assertEquals("componentType", "javax.faces.HtmlOutputText", displayElement.getComponentType());
      
       AttributeBean attr = displayElement.getAttribute("escape");
       assertNotNull("escape", attr);
       assertEquals("escape", Boolean.FALSE.toString(), attr.getValue());
      
       attr = displayElement.getAttribute("isTransient");
       assertNotNull("isTransient", attr);
       assertEquals("isTransient", Boolean.TRUE.toString(), attr.getValue());
      
       attr = displayElement.getAttribute("value");
       assertNotNull("value", attr);
       assertEquals("value", "<html><head></head><body bgcolor=\"blue\">Hello World</body></html>", attr.getValue());

       //test excapeXml=false
       component.getAttributes().put("escapeXml", Boolean.FALSE.toString());
       displayElement = new ComponentBean();
       displayElement.setId("clayImport");
       displayElement.setComponentType("org.apache.shale.clay.component.Clay");
       displayElement.setJsfid("clayImport");
     
       clayAmalgam.clayImport(facesContext, component, displayElement);
      
       assertEquals("jsfid", "outputText", displayElement.getJsfid());
       assertEquals("componentType", "javax.faces.HtmlOutputText", displayElement.getComponentType());
      
       attr = displayElement.getAttribute("escape");
       assertNotNull("escape", attr);
       assertEquals("escape", Boolean.FALSE.toString(), attr.getValue());
      
       attr = displayElement.getAttribute("isTransient");
       assertNotNull("isTransient", attr);
       assertEquals("isTransient", Boolean.TRUE.toString(), attr.getValue());
      
       attr = displayElement.getAttribute("value");
       assertNotNull("value", attr);
       assertEquals("value", "<html><head></head><body bgcolor=\"blue\">Hello World</body></html>", attr.getValue());

      
       //test classpath file import
       requestParams = new TreeMap();
       requestParams.put("url", "classpath*:/org/apache/shale/clay/utils/hello.html");
       externalContext.setRequestParameterMap(requestParams);
      
       displayElement = new ComponentBean();
       displayElement.setId("clayImport");
       displayElement.setComponentType("org.apache.shale.clay.component.Clay");
       displayElement.setJsfid("clayImport");
       
       component = application.createComponent("org.apache.shale.clay.component.Clay");    
       component.setId("clayImport");
       component.getAttributes().put("url","#{param.url}");
       component.getAttributes().put("escapeXml", Boolean.TRUE.toString());
      
       clayAmalgam.clayImport(facesContext, component, displayElement);
       attr = displayElement.getAttribute("value");
       assertNotNull("value", attr);
       assertEquals("value", "", attr.getValue());

      
       //test no file found
       requestParams = new TreeMap();
       requestParams.put("url", "/org/apache/shale/clay/utils/notfound.html");
       externalContext.setRequestParameterMap(requestParams);
      
       displayElement = new ComponentBean();
       displayElement.setId("clayImport");
       displayElement.setComponentType("org.apache.shale.clay.component.Clay");
       displayElement.setJsfid("clayImport");
       
       component = application.createComponent("org.apache.shale.clay.component.Clay");    
       component.setId("clayImport");
       component.getAttributes().put("url","#{param.url}");
       component.getAttributes().put("escapeXml", Boolean.TRUE.toString());
      
       clayAmalgam.clayImport(facesContext, component, displayElement);
       attr = displayElement.getAttribute("value");
       assertNotNull("value", attr);
       assertEquals("value", "", attr.getValue());

      
    }
View Full Code Here

      
    }
   
    //convert an escaped value into a un-escaped outputText
    public void testClayOut() {
        ComponentBean displayElement = new ComponentBean();
        displayElement.setId("clayOut");
        displayElement.setComponentType("org.apache.shale.clay.component.Clay");
        displayElement.setJsfid("clayOut");

        UIComponent component = application.createComponent("org.apache.shale.clay.component.Clay");    
        component.setId("clayOut");
        component.getAttributes().put("value","&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body bgcolor=\"blue\"&gt;Hello World&lt;/body&gt;&lt;/html&gt;");
        component.getAttributes().put("escapeXml", Boolean.FALSE.toString());
       
  
        clayAmalgam.clayOut(facesContext, component, displayElement);
       
        assertEquals("jsfid", "outputText", displayElement.getJsfid());
        assertEquals("componentType", "javax.faces.HtmlOutputText", displayElement.getComponentType());
       
        AttributeBean attr = displayElement.getAttribute("escape");
        assertNotNull("escape", attr);
        assertEquals("escape", Boolean.FALSE.toString(), attr.getValue());
       
        attr = displayElement.getAttribute("isTransient");
        assertNotNull("isTransient", attr);
        assertEquals("isTransient", Boolean.TRUE.toString(), attr.getValue());
       
        attr = displayElement.getAttribute("value");
        assertNotNull("value", attr);
        assertEquals("value", "<html><head></head><body bgcolor=\"blue\">Hello World</body></html>", attr.getValue());
         
    }
View Full Code Here

    }

    public void testJpx() {
        loadConfigFile(null);

        ComponentBean document = htmlTemplateConfigBean.getElement("/org/apache/shale/clay/config/limited-jspx.html");
        assertNotNull(document);

        assertEquals("void component count", 2, countVoidComponents(document));

        List clayIncludes = findClayJspxInclude(document);
        assertEquals("includes", 2, clayIncludes.size());

        Iterator ci = clayIncludes.iterator();
        while (ci.hasNext()) {
            ComponentBean clayInclude = (ComponentBean) ci.next();
            if (clayInclude.getSymbol("@file") != null) {

                SymbolBean symbol = clayInclude.getSymbol("@file");
                assertNotNull("file symbol", symbol);
                assertEquals("/org/apache/shale/clay/config/address1.html", symbol.getValue());

                AttributeBean attr = clayInclude.getAttribute("clayJsfid");
                assertNotNull("clayJsfid", attr);
                assertEquals("@file", attr.getValue());


            } else if (clayInclude.getSymbol("@page") != null) {

                SymbolBean symbol = clayInclude.getSymbol("@page");
                assertNotNull("file symbol", symbol);
                assertEquals("/org/apache/shale/clay/config/address1.html", symbol.getValue());

                AttributeBean attr = clayInclude.getAttribute("clayJsfid");
                assertNotNull("clayJsfid", attr);
                assertEquals("@page", attr.getValue());

                for (int i = 0; i < 5; i++) {
                    symbol = clayInclude.getSymbol("@symbol" + i);
                    assertNotNull("@symbol" + i, symbol);
                    assertEquals("value" + i, symbol.getValue());
                }

            } else {
View Full Code Here

            voidcnt++;
        }

        Iterator ci = bean.getChildren().iterator();
        while (ci.hasNext()) {
            ComponentBean child = (ComponentBean) ci.next();
            voidcnt += countVoidComponents(child);
        }

        return voidcnt;
    }
View Full Code Here

        // loads the default config from the META-INF jar folder
        loadConfigFile("");
       
        //verify the components where loaded
        for (int i = 0; i < COMPONENTS.length; i++) {
            ComponentBean bean = standardConfigBean.getElement(((String[])COMPONENTS[i])[0]);
            assertNotNull("component", bean);
            assertEquals("component.jsfid",((String[])COMPONENTS[i])[0],  bean.getJsfid());
            assertEquals("component.componentType", ((String[])COMPONENTS[i])[1], bean.getComponentType());
        }

        //verify converters where loaded
        for (int i = 0; i < CONVERTERS.length; i++) {
            ComponentBean bean = standardConfigBean.getElement(((String[])CONVERTERS[i])[0]);
            assertNotNull("converter", bean);
            assertEquals("converter.jsfid", ((String[])CONVERTERS[i])[0], bean.getJsfid());
            assertEquals("converter.componentType", ((String[])CONVERTERS[i])[1], bean.getComponentType());
        }

        //verify validators where loaded
        for (int i = 0; i < VALIDATORS.length; i++) {
            ComponentBean bean = standardConfigBean.getElement(((String[])VALIDATORS[i])[0]);
            assertNotNull("validator", bean);
            assertEquals("validator.jsfid", ((String[])VALIDATORS[i])[0], bean.getJsfid());
            assertEquals("validator.componentType", ((String[])VALIDATORS[i])[1], bean.getComponentType());
        }

    }
View Full Code Here

    public void testCustomConfigFile() {

        //loads the default and the custom address config files
        loadConfigFile("/org/apache/shale/clay/config/address-config.xml");
      
        ComponentBean bean = standardConfigBean.getElement("agentAddressForm");
        assertNotNull(bean);
       
        Iterator ci = bean.getChildrenIterator();
        while (ci.hasNext()) {
           ElementBean child = (ElementBean) ci.next();
           //look for a component that we have setup to test
           checkComponent(child, CUSTOM_XML_COMPONENTS, true);   
        }
View Full Code Here

    public void testLoadHTMLFile() {

        //loads the default and the custom address config file
        loadConfigFile("/org/apache/shale/clay/config/address-config.xml");

        ComponentBean bean = htmlTemplateConfigBean.getElement("/org/apache/shale/clay/config/address2.html");
        assertNotNull(bean);

        Iterator ci = bean.getChildrenIterator();
        while (ci.hasNext()) {
           ElementBean child = (ElementBean) ci.next();
           //look for a component that we have setup to test
           checkComponent(child, CUSTOM_HTML_COMPONENTS, true);   
        }
View Full Code Here

    public void testLoadXHTMLNamespaceFile1() {

        //loads the default and the custom address config file
        loadConfigFile("/org/apache/shale/clay/config/address-config.xml");

        ComponentBean bean = htmlTemplateConfigBean.getElement("/org/apache/shale/clay/config/address1.html");
        assertNotNull(bean);

        Iterator ci = bean.getChildrenIterator();
        while (ci.hasNext()) {
           ElementBean child = (ElementBean) ci.next();
           //look for a component that we have setup to test
           checkComponent(child, CUSTOM_HTML_COMPONENTS, true);   
        }
View Full Code Here

    public void testLoadXHTMLNamespaceFile3() {

        //loads the default and the custom address config file
        loadConfigFile("/org/apache/shale/clay/config/address-config.xml");

        ComponentBean bean = htmlTemplateConfigBean.getElement("/org/apache/shale/clay/config/address3.html");
        assertNotNull(bean);

        Iterator ci = bean.getChildrenIterator();
        while (ci.hasNext()) {
           ElementBean child = (ElementBean) ci.next();
           //look for a component that we have setup to test
           checkComponent(child, CUSTOM_HTML_COMPONENTS, true);   
        }
View Full Code Here

TOP

Related Classes of org.apache.shale.clay.config.beans.ComponentBean

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.