Author: gvanmatre
Date: Sat Dec 31 09:07:40 2005
New Revision: 360348

URL: http://svn.apache.org/viewcvs?rev=360348&view=rev
Log:
Refactored to make room for more tests.

Added:
    
struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/AbstractTestCaseConfig.java
   (with props)
    
struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/SymbolsTestCase.java
   (with props)
Modified:
    
struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/ConfigTestCase.java

Added: 
struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/AbstractTestCaseConfig.java
URL: 
http://svn.apache.org/viewcvs/struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/AbstractTestCaseConfig.java?rev=360348&view=auto
==============================================================================
--- 
struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/AbstractTestCaseConfig.java
 (added)
+++ 
struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/AbstractTestCaseConfig.java
 Sat Dec 31 09:07:40 2005
@@ -0,0 +1,175 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.shale.clay.config;
+
+import java.io.File;
+
+import org.apache.shale.clay.config.beans.ComponentConfigBean;
+import org.apache.shale.clay.config.beans.ConfigBean;
+import org.apache.shale.clay.config.beans.ConfigBeanFactory;
+import org.apache.shale.clay.config.beans.TemplateComponentConfigBean;
+import org.apache.shale.clay.config.beans.TemplateConfigBean;
+import org.apache.shale.test.base.AbstractViewControllerTestCase;
+
+// package scope base class that loads factory definitions
+public abstract class AbstractTestCaseConfig extends 
AbstractViewControllerTestCase {
+
+    // Construct a new instance of this test case.
+    public AbstractTestCaseConfig(String name) {
+        super(name);
+    }
+
+
+    protected ConfigBean standardConfigBean = null;
+    protected ConfigBean htmlTemplateConfigBean = null;
+    protected ConfigBean xmlTemplateConfigBean = null;
+
+    //COMPONENTS[0] = jsfid, COMPONENTS[1] = componentType, COMPONENT[2] = 
className
+    protected static final Object[] COMPONENTS = {new String[] {"token", 
"org.apache.shale.Token", "org.apache.shale.component.Token"},
+                          new String[] {"outputText", 
"javax.faces.HtmlOutputText", "javax.faces.component.html.HtmlOutputText"}, 
+                          new String[] {"selectItem", 
"javax.faces.SelectItem", "javax.faces.component.UISelectItem"},
+                          new String[] {"selectItems", 
"javax.faces.SelectItems", "javax.faces.component.UISelectItems"},
+                          new String[] {"selectOneRadio", 
"javax.faces.HtmlSelectOneRadio", 
"javax.faces.component.html.HtmlSelectOneRadio"},
+                          new String[] {"selectOneMenu", 
"javax.faces.HtmlSelectOneMenu", 
"javax.faces.component.html.HtmlSelectOneMenu"},
+                          new String[] {"selectManyMenu", 
"javax.faces.HtmlSelectManyMenu", 
"javax.faces.component.html.HtmlSelectManyMenu"},
+                          new String[] {"manySelectCheckbox", 
"javax.faces.HtmlSelectManyCheckbox", 
"javax.faces.component.html.HtmlSelectManyCheckbox"},
+                          new String[] {"selectBooleanCheckbox", 
"javax.faces.HtmlSelectBooleanCheckbox", 
"javax.faces.component.html.HtmlSelectBooleanCheckbox"},
+                          new String[] {"panelGroup", 
"javax.faces.HtmlPanelGroup", "javax.faces.component.html.HtmlPanelGroup"},
+                          new String[] {"outputLink", 
"javax.faces.HtmlOutputLink", "javax.faces.component.html.HtmlOutputLink"},
+                          new String[] {"outputLabel", 
"javax.faces.HtmlOutputLabel", "javax.faces.component.html.HtmlOutputLabel"},
+                          new String[] {"inputTextarea", 
"javax.faces.HtmlInputTextarea","javax.faces.component.html.HtmlInputTextarea"},
+                          new String[] {"inputSecret", 
"javax.faces.HtmlInputSecret","javax.faces.component.html.HtmlInputSecret"},
+                          new String[] {"inputHidden", 
"javax.faces.HtmlInputHidden", "javax.faces.component.html.HtmlInputText"},
+                          new String[] {"image", 
"javax.faces.HtmlGraphicImage", "javax.faces.component.html.HtmlGraphicImage"},
+                          new String[] {"form", "javax.faces.HtmlForm", 
"javax.faces.component.html.HtmlForm"},
+                          new String[] {"dataTable", 
"javax.faces.HtmlDataTable", "javax.faces.component.html.HtmlDataTable"},
+                          new String[] {"commandLink", 
"javax.faces.HtmlCommandLink", "javax.faces.component.html.HtmlCommandLink"},
+                          new String[] {"column", "javax.faces.Column", 
"javax.faces.component.UIColumn"},
+                          new String[] {"inputText", 
"javax.faces.HtmlInputText", "javax.faces.component.html.HtmlInputHidden"},
+                          new String[] {"outputFormat", 
"javax.faces.HtmlOutputFormat", "javax.faces.component.html.HtmlOutputFormat"},
+                          new String[] {"messages", 
"javax.faces.HtmlMessages", "javax.faces.component.html.HtmlMessages"},
+                          new String[] {"message", "javax.faces.HtmlMessage", 
"javax.faces.component.html.HtmlMessage"},
+                          new String[] {"commandButton", 
"javax.faces.HtmlCommandButton", 
"javax.faces.component.html.HtmlCommandButton"},
+                          new String[] {"panelGrid", 
"javax.faces.HtmlPanelGrid", "javax.faces.component.html.HtmlPanelGrid"},
+                          new String[] {"namingContainer", 
"javax.faces.NamingContainer", "javax.faces.component.UINamingContainer"}
+    };
+
+    // load the mock component config data
+    protected void loadComponents() {
+       for (int i = 0; i < COMPONENTS.length; i++) {
+          application.addComponent(((String[])COMPONENTS[i])[1], 
((String[])COMPONENTS[i])[2]);
+       }
+    }
+    
+    //CONVERTERS[0] = jsfid, CONVERTERS[1] = componentType, CONVERTERS[2] = 
className
+    protected static final Object[] CONVERTERS = {
+               new String[] {"integerConverter", "javax.faces.Integer", 
"javax.faces.convert.IntegerConverter"},
+               new String[] {"dateTimeConverter", "javax.faces.DateTime", 
"javax.faces.convert.DateTimeConverter"}
+    };    
+    
+    // load the mock converter config data
+    protected void loadConverters() {
+        for (int i = 0; i < CONVERTERS.length; i++) {
+           application.addComponent(((String[])CONVERTERS[i])[1], 
((String[])CONVERTERS[i])[2]);
+        }
+     }
+    
+    //VALIDATORS[0] = jsfid, VALIDATORS[1] = componentType, VALIDATORS[2] = 
className
+    public static final Object[] VALIDATORS = {
+               new String[] {"validateLongRange","javax.faces.LongRange", 
"javax.faces.validator.LongRangeValidator"}
+    };     
+
+    // load the mock validator config
+    protected void loadValidators() {
+        for (int i = 0; i < VALIDATORS.length; i++) {
+           application.addComponent(((String[])VALIDATORS[i])[1], 
((String[])VALIDATORS[i])[2]);
+        }
+    }
+
+    // setup the testcase   
+    public void setUp() {
+        super.setUp();
+
+        // Configure document root for tests
+        String documentRoot = System.getProperty("documentRoot");
+        if (documentRoot == null) {
+            documentRoot = System.getProperty("user.dir") + 
"\\WebContent\\WEB-INF\\classes";           
+        }
+        servletContext.setDocumentRoot(new File(documentRoot));
+        
+        
+
+        //load the mock config data
+        loadComponents();
+        loadConverters();
+        loadValidators();
+
+        // sets the default html template suffix ".html"
+        servletContext.addInitParameter(Globals.CLAY_HTML_TEMPLATE_SUFFIX, 
".html");
+
+        // sets the default html template suffix ".xml"
+        servletContext.addInitParameter(Globals.CLAY_XML_TEMPLATE_SUFFIX, 
".xml");
+       
+        // creates the component metadata container from the xml config files
+        standardConfigBean = new ComponentConfigBean();
+        // creates a container that builds the component metadata from an HTML 
 
+        // template configuration.
+        htmlTemplateConfigBean = new TemplateConfigBean();
+        // full xml view support
+        xmlTemplateConfigBean = new TemplateComponentConfigBean();
+
+        
+        // register with the factory
+        ConfigBeanFactory.register(standardConfigBean);
+        ConfigBeanFactory.register(htmlTemplateConfigBean);
+        ConfigBeanFactory.register(xmlTemplateConfigBean);
+
+    }
+
+    public void tearDown() {
+        super.tearDown();
+
+        // deregister
+        ConfigBeanFactory.destroy();
+        standardConfigBean = null;
+        htmlTemplateConfigBean = null;
+        xmlTemplateConfigBean = null;
+    }
+
+    // loads the config files
+    protected void loadConfigFile(String commonConfigFiles) {
+        loadConfigFiles(commonConfigFiles, null);
+    }
+    
+    // loads the config files
+    protected void loadConfigFiles(String commonConfigFiles, String 
fullXmlConfigFiles) {
+        // this would be done in the ClayConfigureListener
+        
+        if (commonConfigFiles !=  null)
+           servletContext.addInitParameter(Globals.CLAY_COMMON_CONFIG_FILES, 
commonConfigFiles);  
+        
+        if (fullXmlConfigFiles != null) {
+           servletContext.addInitParameter(Globals.CLAY_FULLXML_CONFIG_FILES, 
fullXmlConfigFiles);  
+        }
+        
+        standardConfigBean.init(servletContext);
+        htmlTemplateConfigBean.init(servletContext);
+        xmlTemplateConfigBean.init(servletContext);
+
+    }
+
+       
+}

Propchange: 
struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/AbstractTestCaseConfig.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/AbstractTestCaseConfig.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Modified: 
struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/ConfigTestCase.java
URL: 
http://svn.apache.org/viewcvs/struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/ConfigTestCase.java?rev=360348&r1=360347&r2=360348&view=diff
==============================================================================
--- 
struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/ConfigTestCase.java
 (original)
+++ 
struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/ConfigTestCase.java
 Sat Dec 31 09:07:40 2005
@@ -15,29 +15,17 @@
  */
 package org.apache.shale.clay.config;
 
-import java.io.File;
 import java.util.Iterator;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
-import org.apache.commons.chain.Command;
-import org.apache.shale.clay.component.chain.ClayContext;
-import org.apache.shale.clay.component.chain.PropertyValueCommand;
 import org.apache.shale.clay.config.beans.AttributeBean;
 import org.apache.shale.clay.config.beans.ComponentBean;
-import org.apache.shale.clay.config.beans.ComponentConfigBean;
-import org.apache.shale.clay.config.beans.ConfigBean;
-import org.apache.shale.clay.config.beans.ConfigBeanFactory;
 import org.apache.shale.clay.config.beans.ElementBean;
-import org.apache.shale.clay.config.beans.TemplateComponentConfigBean;
-import org.apache.shale.clay.config.beans.TemplateConfigBean;
-import org.apache.shale.faces.ShaleConstants;
-import org.apache.shale.test.base.AbstractViewControllerTestCase;
-import org.apache.shale.util.Tags;
 
 // Tests that the clay component metadata can be loaded and inheritance 
resolved.
-public class ConfigTestCase extends AbstractViewControllerTestCase {
+public class ConfigTestCase extends AbstractTestCaseConfig {
 
     // Construct a new instance of this test case.
     public ConfigTestCase(String name) {
@@ -51,144 +39,7 @@
 
     }
 
-    protected ConfigBean standardConfigBean = null;
-    protected ConfigBean htmlTemplateConfigBean = null;
-    protected ConfigBean xmlTemplateConfigBean = null;
-
-    //COMPONENTS[0] = jsfid, COMPONENTS[1] = componentType, COMPONENT[2] = 
className
-    protected static final Object[] COMPONENTS = {new String[] {"token", 
"org.apache.shale.Token", "org.apache.shale.component.Token"},
-                          new String[] {"outputText", 
"javax.faces.HtmlOutputText", "javax.faces.component.html.HtmlOutputText"}, 
-                          new String[] {"selectItem", 
"javax.faces.SelectItem", "javax.faces.component.UISelectItem"},
-                          new String[] {"selectItems", 
"javax.faces.SelectItems", "javax.faces.component.UISelectItems"},
-                          new String[] {"selectOneRadio", 
"javax.faces.HtmlSelectOneRadio", 
"javax.faces.component.html.HtmlSelectOneRadio"},
-                          new String[] {"selectOneMenu", 
"javax.faces.HtmlSelectOneMenu", 
"javax.faces.component.html.HtmlSelectOneMenu"},
-                          new String[] {"selectManyMenu", 
"javax.faces.HtmlSelectManyMenu", 
"javax.faces.component.html.HtmlSelectManyMenu"},
-                          new String[] {"manySelectCheckbox", 
"javax.faces.HtmlSelectManyCheckbox", 
"javax.faces.component.html.HtmlSelectManyCheckbox"},
-                          new String[] {"selectBooleanCheckbox", 
"javax.faces.HtmlSelectBooleanCheckbox", 
"javax.faces.component.html.HtmlSelectBooleanCheckbox"},
-                          new String[] {"panelGroup", 
"javax.faces.HtmlPanelGroup", "javax.faces.component.html.HtmlPanelGroup"},
-                          new String[] {"outputLink", 
"javax.faces.HtmlOutputLink", "javax.faces.component.html.HtmlOutputLink"},
-                          new String[] {"outputLabel", 
"javax.faces.HtmlOutputLabel", "javax.faces.component.html.HtmlOutputLabel"},
-                          new String[] {"inputTextarea", 
"javax.faces.HtmlInputTextarea","javax.faces.component.html.HtmlInputTextarea"},
-                          new String[] {"inputSecret", 
"javax.faces.HtmlInputSecret","javax.faces.component.html.HtmlInputSecret"},
-                          new String[] {"inputHidden", 
"javax.faces.HtmlInputHidden", "javax.faces.component.html.HtmlInputText"},
-                          new String[] {"image", 
"javax.faces.HtmlGraphicImage", "javax.faces.component.html.HtmlGraphicImage"},
-                          new String[] {"form", "javax.faces.HtmlForm", 
"javax.faces.component.html.HtmlForm"},
-                          new String[] {"dataTable", 
"javax.faces.HtmlDataTable", "javax.faces.component.html.HtmlDataTable"},
-                          new String[] {"commandLink", 
"javax.faces.HtmlCommandLink", "javax.faces.component.html.HtmlCommandLink"},
-                          new String[] {"column", "javax.faces.Column", 
"javax.faces.component.UIColumn"},
-                          new String[] {"inputText", 
"javax.faces.HtmlInputText", "javax.faces.component.html.HtmlInputHidden"},
-                          new String[] {"outputFormat", 
"javax.faces.HtmlOutputFormat", "javax.faces.component.html.HtmlOutputFormat"},
-                          new String[] {"messages", 
"javax.faces.HtmlMessages", "javax.faces.component.html.HtmlMessages"},
-                          new String[] {"message", "javax.faces.HtmlMessage", 
"javax.faces.component.html.HtmlMessage"},
-                          new String[] {"commandButton", 
"javax.faces.HtmlCommandButton", 
"javax.faces.component.html.HtmlCommandButton"},
-                          new String[] {"panelGrid", 
"javax.faces.HtmlPanelGrid", "javax.faces.component.html.HtmlPanelGrid"},
-                          new String[] {"namingContainer", 
"javax.faces.NamingContainer", "javax.faces.component.UINamingContainer"}
-    };
-
-    // load the mock component config data
-    protected void loadComponents() {
-       for (int i = 0; i < COMPONENTS.length; i++) {
-          application.addComponent(((String[])COMPONENTS[i])[1], 
((String[])COMPONENTS[i])[2]);
-       }
-    }
-    
-    //CONVERTERS[0] = jsfid, CONVERTERS[1] = componentType, CONVERTERS[2] = 
className
-    protected static final Object[] CONVERTERS = {
-               new String[] {"integerConverter", "javax.faces.Integer", 
"javax.faces.convert.IntegerConverter"},
-               new String[] {"dateTimeConverter", "javax.faces.DateTime", 
"javax.faces.convert.DateTimeConverter"}
-    };    
-    
-    // load the mock converter config data
-    protected void loadConverters() {
-        for (int i = 0; i < CONVERTERS.length; i++) {
-           application.addComponent(((String[])CONVERTERS[i])[1], 
((String[])CONVERTERS[i])[2]);
-        }
-     }
-    
-    //VALIDATORS[0] = jsfid, VALIDATORS[1] = componentType, VALIDATORS[2] = 
className
-    public static final Object[] VALIDATORS = {
-               new String[] {"validateLongRange","javax.faces.LongRange", 
"javax.faces.validator.LongRangeValidator"}
-    };     
-
-    // load the mock validator config
-    protected void loadValidators() {
-        for (int i = 0; i < VALIDATORS.length; i++) {
-           application.addComponent(((String[])VALIDATORS[i])[1], 
((String[])VALIDATORS[i])[2]);
-        }
-    }
-
-    // setup the testcase   
-    public void setUp() {
-        super.setUp();
-
-        // Configure document root for tests
-        String documentRoot = System.getProperty("documentRoot");
-        if (documentRoot == null) {
-            documentRoot = System.getProperty("user.dir") + 
"\\WebContent\\WEB-INF\\classes";           
-        }
-        servletContext.setDocumentRoot(new File(documentRoot));
-        
-        
-
-        //load the mock config data
-        loadComponents();
-        loadConverters();
-        loadValidators();
 
-        // sets the default html template suffix ".html"
-        servletContext.addInitParameter(Globals.CLAY_HTML_TEMPLATE_SUFFIX, 
".html");
-
-        // sets the default html template suffix ".xml"
-        servletContext.addInitParameter(Globals.CLAY_XML_TEMPLATE_SUFFIX, 
".xml");
-       
-        // creates the component metadata container from the xml config files
-        standardConfigBean = new ComponentConfigBean();
-        // creates a container that builds the component metadata from an HTML 
 
-        // template configuration.
-        htmlTemplateConfigBean = new TemplateConfigBean();
-        // full xml view support
-        xmlTemplateConfigBean = new TemplateComponentConfigBean();
-
-        
-        // register with the factory
-        ConfigBeanFactory.register(standardConfigBean);
-        ConfigBeanFactory.register(htmlTemplateConfigBean);
-        ConfigBeanFactory.register(xmlTemplateConfigBean);
-
-    }
-
-    public void tearDown() {
-        super.tearDown();
-
-        // deregister
-        ConfigBeanFactory.destroy();
-        standardConfigBean = null;
-        htmlTemplateConfigBean = null;
-        xmlTemplateConfigBean = null;
-    }
-
-    
-    // loads the config files
-    protected void loadConfigFile(String commonConfigFiles) {
-        loadConfigFiles(commonConfigFiles, null);
-    }
-    
-    // loads the config files
-    protected void loadConfigFiles(String commonConfigFiles, String 
fullXmlConfigFiles) {
-        // this would be done in the ClayConfigureListener
-        
-        if (commonConfigFiles !=  null)
-           servletContext.addInitParameter(Globals.CLAY_COMMON_CONFIG_FILES, 
commonConfigFiles);  
-        
-        if (fullXmlConfigFiles != null) {
-           servletContext.addInitParameter(Globals.CLAY_FULLXML_CONFIG_FILES, 
fullXmlConfigFiles);  
-        }
-        
-        standardConfigBean.init(servletContext);
-        htmlTemplateConfigBean.init(servletContext);
-        xmlTemplateConfigBean.init(servletContext);
-
-    }
     public void testLoadConfigFile() {
 
         // loads the default config from the META-INF jar folder
@@ -594,212 +445,7 @@
         return -1;
     }
    
-    
-    public void testGenericPropertyCommand () throws Exception {
-        javax.faces.component.html.HtmlOutputText child = 
(javax.faces.component.html.HtmlOutputText) 
facesContext.getApplication().createComponent("javax.faces.HtmlOutputText"); 
-       assertNotNull("javax.faces.HtmlOutputText", child);
-       
-       
-       AttributeBean attr = new AttributeBean();
-       attr.setName("value");
-       attr.setBindingType(AttributeBean.BINDING_TYPE_NONE);
-       attr.setValue("10");
-       
-       ComponentBean displayElement = new ComponentBean();
-       displayElement.setJsfid("inputText");
-       displayElement.setComponentType("javax.faces.HtmlOutputText");
-       displayElement.setId("testId");
-       displayElement.addAttribute(attr);
-       
-       assertNotNull("attribute case insensitive", 
displayElement.getAttribute("VaLue"));
-       
-       ClayContext clayContext = new ClayContext();
-       clayContext.setFacesContext(facesContext);
-       clayContext.setChild(child);
-       clayContext.setAttribute(attr);
-       clayContext.setDisplayElement(displayElement);
-       
-       //shale core utility class
-       servletContext.setAttribute(ShaleConstants.TAG_UTILITY_BEAN, new 
Tags());
-       
-       Command command = new PropertyValueCommand();
-       boolean isFinal = command.execute(clayContext);
-       assertEquals("command finished", isFinal, true);       
-       assertEquals("value = 10", child.getValue(), "10");
-
-       
-       child = (javax.faces.component.html.HtmlOutputText) 
facesContext.getApplication().createComponent("javax.faces.HtmlOutputText"); 
-       assertNotNull("javax.faces.HtmlOutputText", child);
-       clayContext.setChild(child);
-       
-       servletContext.setAttribute("goodYear", "1969");
-       attr.setBindingType(AttributeBean.BINDING_TYPE_VALUE);
-       attr.setValue("#{goodYear}");
-
-       isFinal = command.execute(clayContext);
-       assertEquals("command finished", isFinal, true);       
-       assertEquals("value = 1969", child.getValue(), "1969");
-       
-       child = (javax.faces.component.html.HtmlOutputText) 
facesContext.getApplication().createComponent("javax.faces.HtmlOutputText"); 
-       assertNotNull("javax.faces.HtmlOutputText", child);
-       clayContext.setChild(child);
-       
-       servletContext.setAttribute("ping", "pong");
-       attr.setBindingType(AttributeBean.BINDING_TYPE_EARLY);
-       attr.setValue("#{ping}");
-
-       isFinal = command.execute(clayContext);
-       assertEquals("command finished", isFinal, true);       
-       assertEquals("value = pong", child.getValue(), "pong");
-
-
-       child = (javax.faces.component.html.HtmlOutputText) 
facesContext.getApplication().createComponent("javax.faces.HtmlOutputText"); 
-       assertNotNull("javax.faces.HtmlOutputText", child);
-       clayContext.setChild(child);
-       
-       attr.setBindingType(AttributeBean.BINDING_TYPE_NONE);
-       attr.setValue("#{forManfred}");
-
-       isFinal = command.execute(clayContext);
-       assertEquals("command finished", isFinal, true);       
-       assertEquals("value = #{forManfred}", child.getValue(), 
"#{forManfred}");
-
         
-    }
-   
-    // test symbolic property replacement
-    public void testSymbolicProperties() throws Exception {
-            javax.faces.component.html.HtmlOutputText child = 
(javax.faces.component.html.HtmlOutputText) 
facesContext.getApplication().createComponent("javax.faces.HtmlOutputText"); 
-           assertNotNull("javax.faces.HtmlOutputText", child);
-           
-           
-           AttributeBean attr = new AttributeBean();
-           attr.setName("value");
-           attr.setBindingType(AttributeBean.BINDING_TYPE_NONE);
-           attr.setValue("@value");  //symbolic attribute 
-                      
-           ComponentBean displayElement = new ComponentBean();
-           displayElement.setJsfid("inputText");
-           displayElement.setComponentType("javax.faces.HtmlOutputText");
-           displayElement.setId("testId");
-           displayElement.addAttribute(attr);
-           displayElement.addSymbol("@value", "10");
-                      
-           ClayContext clayContext = new ClayContext();
-           clayContext.setFacesContext(facesContext);
-           clayContext.setChild(child);
-           clayContext.setAttribute(attr);
-           clayContext.setDisplayElement(displayElement);
-           // normally done in the AssignChildrenCommand
-           clayContext.setSymbols(displayElement.getSymbols());
-           
-           //shale core utility class
-           servletContext.setAttribute(ShaleConstants.TAG_UTILITY_BEAN, new 
Tags());
-           
-           Command command = new PropertyValueCommand();
-           boolean isFinal = command.execute(clayContext);
-           assertEquals("command finished", isFinal, true);       
-           assertEquals("value = 10", child.getValue(), "10");
-
-           
-           // test a symbol value of an el value
-           child = (javax.faces.component.html.HtmlOutputText) 
facesContext.getApplication().createComponent("javax.faces.HtmlOutputText"); 
-           assertNotNull("javax.faces.HtmlOutputText", child);
-
-           displayElement.addSymbol("@value", "#{value}");
-           attr.setBindingType(AttributeBean.BINDING_TYPE_EARLY);
-           servletContext.setAttribute("value", "10");
-          
-           clayContext.setFacesContext(facesContext);
-           clayContext.setChild(child);
-           clayContext.setAttribute(attr);
-           clayContext.setDisplayElement(displayElement);
-           // normally done in the AssignChildrenCommand
-           clayContext.setSymbols(displayElement.getSymbols());
-           
-           isFinal = command.execute(clayContext);
-           assertEquals("command finished", isFinal, true);       
-           assertEquals("value = 10", child.getValue(), "10");
-
-           
-           // test a symbol value with a null value symbol replacement
-           child = (javax.faces.component.html.HtmlOutputText) 
facesContext.getApplication().createComponent("javax.faces.HtmlOutputText"); 
-           assertNotNull("javax.faces.HtmlOutputText", child);
-
-           displayElement.addSymbol("@value", null);
-           attr.setBindingType(AttributeBean.BINDING_TYPE_EARLY);
-          
-           clayContext.setFacesContext(facesContext);
-           clayContext.setChild(child);
-           clayContext.setAttribute(attr);
-           clayContext.setDisplayElement(displayElement);
-           // normally done in the AssignChildrenCommand
-           clayContext.setSymbols(displayElement.getSymbols());
-           
-           isFinal = command.execute(clayContext);
-           assertEquals("command finished", isFinal, true);       
-           assertEquals("value = null", child.getValue(), null);
-
-
-           // test a symbol value with an empty String value.  
-           // this will evaluate to null since it is a symbol replacement.
-           child = (javax.faces.component.html.HtmlOutputText) 
facesContext.getApplication().createComponent("javax.faces.HtmlOutputText"); 
-           assertNotNull("javax.faces.HtmlOutputText", child);
-
-           displayElement.addSymbol("@value", "");
-           attr.setBindingType(AttributeBean.BINDING_TYPE_EARLY);
-          
-           clayContext.setFacesContext(facesContext);
-           clayContext.setChild(child);
-           clayContext.setAttribute(attr);
-           clayContext.setDisplayElement(displayElement);
-           // normally done in the AssignChildrenCommand
-           clayContext.setSymbols(displayElement.getSymbols());
-           
-           isFinal = command.execute(clayContext);
-           assertEquals("command finished", isFinal, true);       
-           assertEquals("value = null", child.getValue(), null);
-
-           //no symbol replacement for a empty string - should return
-           //an empty string.  This allows components like the selectItem
-           //to create an empty select list pick.
-           attr.setValue("");  //empty string           
-           child = (javax.faces.component.html.HtmlOutputText) 
facesContext.getApplication().createComponent("javax.faces.HtmlOutputText"); 
-           assertNotNull("javax.faces.HtmlOutputText", child);
-
-           clayContext.setFacesContext(facesContext);
-           clayContext.setChild(child);
-           clayContext.setAttribute(attr);
-           clayContext.setDisplayElement(displayElement);
-           
-           isFinal = command.execute(clayContext);
-           assertEquals("command finished", isFinal, true);       
-           assertEquals("value = \"\"", child.getValue(), "");
-
-           //Case insensitive and reoccurring replacement
-           attr.setValue("@TeSt1, @tEst1 never @test2; @test1, @teSt1 till ya 
@tesT3");  //test multiple symbols           
-           child = (javax.faces.component.html.HtmlOutputText) 
facesContext.getApplication().createComponent("javax.faces.HtmlOutputText"); 
-           assertNotNull("javax.faces.HtmlOutputText", child);
-
-           displayElement.addSymbol("@test1", "rock");
-           displayElement.addSymbol("@test2", "stop");
-           displayElement.addSymbol("@test3", "drop");
-
-           clayContext.setFacesContext(facesContext);
-           clayContext.setChild(child);
-           clayContext.setAttribute(attr);
-           clayContext.setDisplayElement(displayElement);
-           // normally done in the AssignChildrenCommand
-           clayContext.setSymbols(displayElement.getSymbols());
-           
-           isFinal = command.execute(clayContext);
-           assertEquals("command finished", isFinal, true);       
-           assertEquals("value = \"rock, rock never stop; rock, rock till ya 
drop\"", 
-                   child.getValue(), "rock, rock never stop; rock, rock till 
ya drop");
-
-    }
-    
-    
     // test duplicate id check
     public void testDuplicateComponentIds() {
         
@@ -822,61 +468,6 @@
         
     } 
        
-    //test symbol inheritance
-    public void testSymbolInheritance() {
-
-        //loads the default and the custom address config files
-        loadConfigFile("/org/apache/shale/clay/config/address-config.xml");
-          
-        // test vertical inheritance
-        ComponentBean bean = standardConfigBean.getElement("baseSymbolLabel");
-        assertNotNull(bean);
-        //look for a base symbol definition
-        String symbol = (String) bean.getSymbols().get("@mystyle");
-        assertNotNull(symbol);
-        assertEquals("@mystyle == color:blue", symbol, "color:blue");
-
-        // symbol1Label extends baseSymbolLabel
-        bean = standardConfigBean.getElement("symbol1Label");
-        assertNotNull(bean);
-        //look for inherited symbol
-        symbol = (String) bean.getSymbols().get("@mystyle");
-        assertNotNull(symbol);
-        assertEquals("@mystyle == color:blue", symbol, "color:blue");
-
-        // symbol2Label extends symbol1Label
-        bean = standardConfigBean.getElement("symbol2Label");
-        assertNotNull(bean);
-        //look for an overridden symbol
-        symbol = (String) bean.getSymbols().get("@mystyle");
-        assertNotNull(symbol);
-        assertEquals("@mystyle == color:red", symbol, "color:red");
-
-        
-        //test nested/inner element inheritance
-        bean = standardConfigBean.getElement("symbolPanel");
-        assertNotNull(bean);
-        
-        assertEquals(bean.getChildren().size(), 2);
-        Iterator ei = bean.getChildrenIterator();
-        while (ei.hasNext()) {
-            ElementBean ebean = (ElementBean) ei.next();
-            if (ebean.getRenderId() == 1) {
-                //look for inherited symbol
-                symbol = (String) ebean.getSymbols().get("@mystyle");
-                assertNotNull(symbol);
-                assertEquals("@mystyle == color:blue", symbol, "color:blue");  
              
-            } else if (ebean.getRenderId() == 2) {
-                //look for an overridden symbol
-                symbol = (String) ebean.getSymbols().get("@mystyle");
-                assertNotNull(symbol);
-                assertEquals("@mystyle == color:red", symbol, "color:red");
-                
-            }
-        }
-        
-               
-    }
 
     
 }

Added: 
struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/SymbolsTestCase.java
URL: 
http://svn.apache.org/viewcvs/struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/SymbolsTestCase.java?rev=360348&view=auto
==============================================================================
--- 
struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/SymbolsTestCase.java
 (added)
+++ 
struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/SymbolsTestCase.java
 Sat Dec 31 09:07:40 2005
@@ -0,0 +1,357 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.shale.clay.config;
+
+import java.util.Iterator;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.commons.chain.Command;
+import org.apache.shale.clay.component.chain.ClayContext;
+import org.apache.shale.clay.component.chain.PropertyValueCommand;
+import org.apache.shale.clay.config.beans.AttributeBean;
+import org.apache.shale.clay.config.beans.ComponentBean;
+import org.apache.shale.clay.config.beans.ElementBean;
+import org.apache.shale.faces.ShaleConstants;
+import org.apache.shale.util.Tags;
+
+// tests properties and symbol evaluation
+public class SymbolsTestCase extends AbstractTestCaseConfig {
+
+    // Construct a new instance of this test case.
+    public SymbolsTestCase(String name) {
+        super(name);
+    }
+
+    // Return the tests included in this test case.
+    public static Test suite() {
+
+        return (new TestSuite(SymbolsTestCase.class));
+
+    }
+ 
+    public void testGenericPropertyCommand () throws Exception {
+        javax.faces.component.html.HtmlOutputText child = 
(javax.faces.component.html.HtmlOutputText) 
+                                
facesContext.getApplication().createComponent("javax.faces.HtmlOutputText"); 
+       assertNotNull("javax.faces.HtmlOutputText", child);
+       
+       
+       AttributeBean attr = new AttributeBean();
+       attr.setName("value");
+       attr.setBindingType(AttributeBean.BINDING_TYPE_NONE);
+       attr.setValue("10");
+       
+       ComponentBean displayElement = new ComponentBean();
+       displayElement.setJsfid("inputText");
+       displayElement.setComponentType("javax.faces.HtmlOutputText");
+       displayElement.setId("testId");
+       displayElement.addAttribute(attr);
+       
+       assertNotNull("attribute case insensitive", 
displayElement.getAttribute("VaLue"));
+       
+       ClayContext clayContext = new ClayContext();
+       clayContext.setFacesContext(facesContext);
+       clayContext.setChild(child);
+       clayContext.setAttribute(attr);
+       clayContext.setDisplayElement(displayElement);
+       
+       //shale core utility class
+       servletContext.setAttribute(ShaleConstants.TAG_UTILITY_BEAN, new 
Tags());
+       
+       Command command = new PropertyValueCommand();
+       boolean isFinal = command.execute(clayContext);
+       assertEquals("command finished", isFinal, true);       
+       assertEquals("value = 10", child.getValue(), "10");
+
+       
+       child = (javax.faces.component.html.HtmlOutputText) 
+                               
facesContext.getApplication().createComponent("javax.faces.HtmlOutputText"); 
+       assertNotNull("javax.faces.HtmlOutputText", child);
+       clayContext.setChild(child);
+       
+       servletContext.setAttribute("goodYear", "1969");
+       attr.setBindingType(AttributeBean.BINDING_TYPE_VALUE);
+       attr.setValue("#{goodYear}");
+
+       isFinal = command.execute(clayContext);
+       assertEquals("command finished", isFinal, true);       
+       assertEquals("value = 1969", child.getValue(), "1969");
+       
+       child = (javax.faces.component.html.HtmlOutputText) 
+                             
facesContext.getApplication().createComponent("javax.faces.HtmlOutputText"); 
+       assertNotNull("javax.faces.HtmlOutputText", child);
+       clayContext.setChild(child);
+       
+       servletContext.setAttribute("ping", "pong");
+       attr.setBindingType(AttributeBean.BINDING_TYPE_EARLY);
+       attr.setValue("#{ping}");
+
+       isFinal = command.execute(clayContext);
+       assertEquals("command finished", isFinal, true);       
+       assertEquals("value = pong", child.getValue(), "pong");
+
+
+       child = (javax.faces.component.html.HtmlOutputText) 
+                               
facesContext.getApplication().createComponent("javax.faces.HtmlOutputText"); 
+       assertNotNull("javax.faces.HtmlOutputText", child);
+       clayContext.setChild(child);
+       
+       attr.setBindingType(AttributeBean.BINDING_TYPE_NONE);
+       attr.setValue("#{forManfred}");
+
+       isFinal = command.execute(clayContext);
+       assertEquals("command finished", isFinal, true);       
+       assertEquals("value = #{forManfred}", child.getValue(), 
"#{forManfred}");
+
+        
+    }
+   
+    // test symbolic property replacement
+    public void testSymbolicProperties() throws Exception {
+            javax.faces.component.html.HtmlOutputText child = 
(javax.faces.component.html.HtmlOutputText) 
+                              
facesContext.getApplication().createComponent("javax.faces.HtmlOutputText"); 
+           assertNotNull("javax.faces.HtmlOutputText", child);
+           
+           
+           AttributeBean attr = new AttributeBean();
+           attr.setName("value");
+           attr.setBindingType(AttributeBean.BINDING_TYPE_NONE);
+           attr.setValue("@value");  //symbolic attribute 
+                      
+           ComponentBean displayElement = new ComponentBean();
+           displayElement.setJsfid("inputText");
+           displayElement.setComponentType("javax.faces.HtmlOutputText");
+           displayElement.setId("testId");
+           displayElement.addAttribute(attr);
+           displayElement.addSymbol("@value", "10");
+                      
+           ClayContext clayContext = new ClayContext();
+           clayContext.setFacesContext(facesContext);
+           clayContext.setChild(child);
+           clayContext.setAttribute(attr);
+           clayContext.setDisplayElement(displayElement);
+           // normally done in the AssignChildrenCommand
+           clayContext.setSymbols(displayElement.getSymbols());
+           
+           //shale core utility class
+           servletContext.setAttribute(ShaleConstants.TAG_UTILITY_BEAN, new 
Tags());
+           
+           Command command = new PropertyValueCommand();
+           boolean isFinal = command.execute(clayContext);
+           assertEquals("command finished", isFinal, true);       
+           assertEquals("value = 10", child.getValue(), "10");
+
+           
+           // test a symbol value of an el value
+           child = (javax.faces.component.html.HtmlOutputText) 
+                        
facesContext.getApplication().createComponent("javax.faces.HtmlOutputText"); 
+           assertNotNull("javax.faces.HtmlOutputText", child);
+
+           displayElement.addSymbol("@value", "#{value}");
+           attr.setBindingType(AttributeBean.BINDING_TYPE_EARLY);
+           servletContext.setAttribute("value", "10");
+          
+           clayContext.setFacesContext(facesContext);
+           clayContext.setChild(child);
+           clayContext.setAttribute(attr);
+           clayContext.setDisplayElement(displayElement);
+           // normally done in the AssignChildrenCommand
+           clayContext.setSymbols(displayElement.getSymbols());
+           
+           isFinal = command.execute(clayContext);
+           assertEquals("command finished", isFinal, true);       
+           assertEquals("value = 10", child.getValue(), "10");
+
+           
+           // test a symbol value with a null value symbol replacement
+           child = (javax.faces.component.html.HtmlOutputText) 
+                 
facesContext.getApplication().createComponent("javax.faces.HtmlOutputText"); 
+           assertNotNull("javax.faces.HtmlOutputText", child);
+
+           displayElement.addSymbol("@value", null);
+           attr.setBindingType(AttributeBean.BINDING_TYPE_EARLY);
+          
+           clayContext.setFacesContext(facesContext);
+           clayContext.setChild(child);
+           clayContext.setAttribute(attr);
+           clayContext.setDisplayElement(displayElement);
+           // normally done in the AssignChildrenCommand
+           clayContext.setSymbols(displayElement.getSymbols());
+           
+           isFinal = command.execute(clayContext);
+           assertEquals("command finished", isFinal, true);       
+           assertEquals("value = null", child.getValue(), null);
+
+
+           // test a symbol value with an empty String value.  
+           // this will evaluate to null since it is a symbol replacement.
+           child = (javax.faces.component.html.HtmlOutputText) 
+                     
facesContext.getApplication().createComponent("javax.faces.HtmlOutputText"); 
+           assertNotNull("javax.faces.HtmlOutputText", child);
+
+           displayElement.addSymbol("@value", "");
+           attr.setBindingType(AttributeBean.BINDING_TYPE_EARLY);
+          
+           clayContext.setFacesContext(facesContext);
+           clayContext.setChild(child);
+           clayContext.setAttribute(attr);
+           clayContext.setDisplayElement(displayElement);
+           // normally done in the AssignChildrenCommand
+           clayContext.setSymbols(displayElement.getSymbols());
+           
+           isFinal = command.execute(clayContext);
+           assertEquals("command finished", isFinal, true);       
+           assertEquals("value = null", child.getValue(), null);
+
+           //no symbol replacement for a empty string - should return
+           //an empty string.  This allows components like the selectItem
+           //to create an empty select list pick.
+           attr.setValue("");  //empty string           
+           child = (javax.faces.component.html.HtmlOutputText) 
+                        
facesContext.getApplication().createComponent("javax.faces.HtmlOutputText"); 
+           assertNotNull("javax.faces.HtmlOutputText", child);
+
+           clayContext.setFacesContext(facesContext);
+           clayContext.setChild(child);
+           clayContext.setAttribute(attr);
+           clayContext.setDisplayElement(displayElement);
+           
+           isFinal = command.execute(clayContext);
+           assertEquals("command finished", isFinal, true);       
+           assertEquals("value = \"\"", child.getValue(), "");
+
+           //Case insensitive and reoccurring replacement
+           attr.setValue("@TeSt1, @tEst1 never @test2; @test1, @teSt1 till ya 
@tesT3");  //test multiple symbols           
+           child = (javax.faces.component.html.HtmlOutputText) 
+                     
facesContext.getApplication().createComponent("javax.faces.HtmlOutputText"); 
+           assertNotNull("javax.faces.HtmlOutputText", child);
+
+           displayElement.addSymbol("@test1", "rock");
+           displayElement.addSymbol("@test2", "stop");
+           displayElement.addSymbol("@test3", "drop");
+
+           clayContext.setFacesContext(facesContext);
+           clayContext.setChild(child);
+           clayContext.setAttribute(attr);
+           clayContext.setDisplayElement(displayElement);
+           // normally done in the AssignChildrenCommand
+           clayContext.setSymbols(displayElement.getSymbols());
+           
+           isFinal = command.execute(clayContext);
+           assertEquals("command finished", isFinal, true);       
+           assertEquals("value = \"rock, rock never stop; rock, rock till ya 
drop\"", 
+                   child.getValue(), "rock, rock never stop; rock, rock till 
ya drop");
+
+    }
+    
+ 
+    public void testSymbolDelimiters() throws Exception {
+
+        //create a target component
+        javax.faces.component.html.HtmlOutputText child = 
(javax.faces.component.html.HtmlOutputText) 
+                           
facesContext.getApplication().createComponent("javax.faces.HtmlOutputText"); 
+        assertNotNull("javax.faces.HtmlOutputText", child);
+        
+        //setup some metadata
+        AttributeBean attr = new AttributeBean();
+        attr.setName("value");
+        attr.setBindingType(AttributeBean.BINDING_TYPE_NONE);
+        attr.setValue("@[EMAIL PROTECTED]");  //symbolic attribute 
+                   
+        ComponentBean displayElement = new ComponentBean();
+        displayElement.setJsfid("inputText");
+        displayElement.setComponentType("javax.faces.HtmlOutputText");
+        displayElement.setId("testId");
+        displayElement.addAttribute(attr);
+        displayElement.addSymbol("@[ab]", "43");
+        displayElement.addSymbol("@[a]", "67");
+             
+        ClayContext clayContext = new ClayContext();
+        clayContext.setFacesContext(facesContext);
+        clayContext.setChild(child);
+        clayContext.setAttribute(attr);
+        clayContext.setDisplayElement(displayElement);
+        // normally done in the AssignChildrenCommand
+        clayContext.setSymbols(displayElement.getSymbols());
+        
+        //shale core utility class
+        servletContext.setAttribute(ShaleConstants.TAG_UTILITY_BEAN, new 
Tags());
+        
+        Command command = new PropertyValueCommand();
+        boolean isFinal = command.execute(clayContext);
+        assertEquals("command finished", isFinal, true);       
+        assertEquals("value = 6743", child.getValue(), "6743");      
+    }
+     
+    //test symbol inheritance
+    public void testSymbolInheritance() {
+
+        //loads the default and the custom address config files
+        loadConfigFile("/org/apache/shale/clay/config/address-config.xml");
+          
+        // test vertical inheritance
+        ComponentBean bean = standardConfigBean.getElement("baseSymbolLabel");
+        assertNotNull(bean);
+        //look for a base symbol definition
+        String symbol = (String) bean.getSymbols().get("@mystyle");
+        assertNotNull(symbol);
+        assertEquals("@mystyle == color:blue", symbol, "color:blue");
+
+        // symbol1Label extends baseSymbolLabel
+        bean = standardConfigBean.getElement("symbol1Label");
+        assertNotNull(bean);
+        //look for inherited symbol
+        symbol = (String) bean.getSymbols().get("@mystyle");
+        assertNotNull(symbol);
+        assertEquals("@mystyle == color:blue", symbol, "color:blue");
+
+        // symbol2Label extends symbol1Label
+        bean = standardConfigBean.getElement("symbol2Label");
+        assertNotNull(bean);
+        //look for an overridden symbol
+        symbol = (String) bean.getSymbols().get("@mystyle");
+        assertNotNull(symbol);
+        assertEquals("@mystyle == color:red", symbol, "color:red");
+
+        
+        //test nested/inner element inheritance
+        bean = standardConfigBean.getElement("symbolPanel");
+        assertNotNull(bean);
+        
+        assertEquals(bean.getChildren().size(), 2);
+        Iterator ei = bean.getChildrenIterator();
+        while (ei.hasNext()) {
+            ElementBean ebean = (ElementBean) ei.next();
+            if (ebean.getRenderId() == 1) {
+                //look for inherited symbol
+                symbol = (String) ebean.getSymbols().get("@mystyle");
+                assertNotNull(symbol);
+                assertEquals("@mystyle == color:blue", symbol, "color:blue");  
              
+            } else if (ebean.getRenderId() == 2) {
+                //look for an overridden symbol
+                symbol = (String) ebean.getSymbols().get("@mystyle");
+                assertNotNull(symbol);
+                assertEquals("@mystyle == color:red", symbol, "color:red");
+                
+            }
+        }
+        
+               
+    }
+
+    
+}

Propchange: 
struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/SymbolsTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
struts/shale/trunk/clay-plugin/src/test/org/apache/shale/clay/config/SymbolsTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to