cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jheym...@apache.org
Subject svn commit: r330548 [3/132] - in /cocoon/whiteboard/maven2/cocoon-flat-layout: ./ cocoon-ajax-block/ cocoon-ajax-block/api/ cocoon-ajax-block/api/src/ cocoon-ajax-block/api/src/main/ cocoon-ajax-block/api/src/main/java/ cocoon-ajax-block/api/src/main/r...
Date Thu, 03 Nov 2005 14:00:48 GMT
Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/DynamicSelectionListTestCase.xtest
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/DynamicSelectionListTestCase.xtest?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/DynamicSelectionListTestCase.xtest (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/DynamicSelectionListTestCase.xtest Thu Nov  3 05:41:06 2005
@@ -0,0 +1,91 @@
+<?xml version="1.0" ?>
+<!--
+  Copyright 1999-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.
+-->
+<testcase>
+ <roles>
+
+  <role name="org.apache.cocoon.forms.datatype.DatatypeManager"
+    shorthand="forms-datatype"
+    default-class="org.apache.cocoon.forms.datatype.DefaultDatatypeManager"/>
+
+  <role name="org.apache.cocoon.forms.expression.ExpressionManager"
+    shorthand="forms-expression"
+    default-class="org.apache.cocoon.forms.expression.DefaultExpressionManager"/>
+
+  <role name="org.apache.excalibur.xmlizer.XMLizer"
+        shorthand="xmlizer"
+        default-class="org.apache.excalibur.xmlizer.DefaultXMLizer"/>
+
+  <role name="org.apache.excalibur.xml.sax.SAXParser"
+        shorthand="xml-parser"
+        default-class="org.apache.excalibur.xml.impl.JaxpParser"/>
+
+ </roles>
+
+ <components>
+  <forms-datatype logger="forms">
+    <datatypes>
+      <datatype name="string" src="org.apache.cocoon.forms.datatype.typeimpl.StringTypeBuilder">
+        <convertors default="dummy" plain="dummy">
+          <convertor name="dummy" src="org.apache.cocoon.forms.datatype.convertor.DummyStringConvertorBuilder"/>
+        </convertors>
+      </datatype>
+      <datatype name="long" src="org.apache.cocoon.forms.datatype.typeimpl.LongTypeBuilder">
+        <convertors default="formatting" plain="plain">
+          <convertor name="plain" src="org.apache.cocoon.forms.datatype.convertor.PlainLongConvertorBuilder"/>
+          <convertor name="formatting" src="org.apache.cocoon.forms.datatype.convertor.FormattingLongConvertorBuilder"/>
+        </convertors>
+      </datatype>
+      <datatype name="decimal" src="org.apache.cocoon.forms.datatype.typeimpl.DecimalTypeBuilder">
+        <convertors default="formatting" plain="plain">
+          <convertor name="plain" src="org.apache.cocoon.forms.datatype.convertor.PlainDecimalConvertorBuilder"/>
+          <convertor name="formatting" src="org.apache.cocoon.forms.datatype.convertor.FormattingDecimalConvertorBuilder"/>
+        </convertors>
+      </datatype>
+      <datatype name="date" src="org.apache.cocoon.forms.datatype.typeimpl.DateTypeBuilder">
+        <convertors default="formatting" plain="millis">
+          <convertor name="formatting" src="org.apache.cocoon.forms.datatype.convertor.FormattingDateConvertorBuilder"/>
+          <convertor name="millis" src="org.apache.cocoon.forms.datatype.convertor.MillisDateConvertorBuilder"/>
+        </convertors>
+      </datatype>
+      <datatype name="boolean" src="org.apache.cocoon.forms.datatype.typeimpl.BooleanTypeBuilder">
+        <convertors default="plain" plain="plain">
+          <convertor name="plain" src="org.apache.cocoon.forms.datatype.convertor.PlainBooleanConvertorBuilder"/>
+        </convertors>
+      </datatype>  
+      <datatype name="integer" src="org.apache.cocoon.forms.datatype.typeimpl.IntegerTypeBuilder">
+        <convertors default="formatting" plain="plain">
+          <convertor name="plain" src="org.apache.cocoon.forms.datatype.convertor.PlainIntegerConvertorBuilder"/>
+          <convertor name="formatting" src="org.apache.cocoon.forms.datatype.convertor.FormattingIntegerConvertorBuilder"/>
+        </convertors>
+      </datatype>  
+    </datatypes>
+    <validation-rules>
+      <validation-rule name="length" src="org.apache.cocoon.forms.datatype.validationruleimpl.LengthValidationRuleBuilder"/>
+      <validation-rule name="email" src="org.apache.cocoon.forms.datatype.validationruleimpl.EmailValidationRuleBuilder"/>
+      <validation-rule name="value-count" src="org.apache.cocoon.forms.datatype.validationruleimpl.ValueCountValidationRuleBuilder"/>
+      <validation-rule name="range" src="org.apache.cocoon.forms.datatype.validationruleimpl.RangeValidationRuleBuilder"/>
+      <validation-rule name="assert" src="org.apache.cocoon.forms.datatype.validationruleimpl.AssertValidationRuleBuilder"/>
+      <validation-rule name="mod10" src="org.apache.cocoon.forms.datatype.validationruleimpl.Mod10ValidationRuleBuilder"/>
+      <validation-rule name="regexp" src="org.apache.cocoon.forms.datatype.validationruleimpl.RegExpValidationRuleBuilder"/>
+    </validation-rules>
+  </forms-datatype>
+
+  <forms-expression logger="forms.expression"/>
+
+ </components>
+
+</testcase>

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/EnumSelectionListTestCase.dest-no-null.xml
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/EnumSelectionListTestCase.dest-no-null.xml?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/EnumSelectionListTestCase.dest-no-null.xml (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/EnumSelectionListTestCase.dest-no-null.xml Thu Nov  3 05:41:06 2005
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Copyright 1999-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.
+-->
+<fi:selection-list
+  xmlns:fi="http://apache.org/cocoon/forms/1.0#instance"
+  xmlns:i18n="http://apache.org/cocoon/i18n/2.1"><fi:item value="org.apache.cocoon.forms.datatype.Sex.MALE"><fi:label><i18n:text>org.apache.cocoon.forms.datatype.Sex.MALE</i18n:text></fi:label></fi:item><fi:item value="org.apache.cocoon.forms.datatype.Sex.FEMALE"><fi:label><i18n:text>org.apache.cocoon.forms.datatype.Sex.FEMALE</i18n:text></fi:label></fi:item></fi:selection-list>

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/EnumSelectionListTestCase.dest-no-null.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/EnumSelectionListTestCase.dest.xml
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/EnumSelectionListTestCase.dest.xml?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/EnumSelectionListTestCase.dest.xml (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/EnumSelectionListTestCase.dest.xml Thu Nov  3 05:41:06 2005
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Copyright 1999-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.
+-->
+<fi:selection-list
+  xmlns:fi="http://apache.org/cocoon/forms/1.0#instance"
+  xmlns:i18n="http://apache.org/cocoon/i18n/2.1"><fi:item value=""/><fi:item value="org.apache.cocoon.forms.datatype.Sex.MALE"><fi:label><i18n:text>org.apache.cocoon.forms.datatype.Sex.MALE</i18n:text></fi:label></fi:item><fi:item value="org.apache.cocoon.forms.datatype.Sex.FEMALE"><fi:label><i18n:text>org.apache.cocoon.forms.datatype.Sex.FEMALE</i18n:text></fi:label></fi:item></fi:selection-list>

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/EnumSelectionListTestCase.dest.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/EnumSelectionListTestCase.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/EnumSelectionListTestCase.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/EnumSelectionListTestCase.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/EnumSelectionListTestCase.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,140 @@
+/*
+ * Copyright 1999-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.cocoon.forms.datatype;
+
+import java.io.Writer;
+import java.util.Locale;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.apache.cocoon.transformation.I18nTransformer;
+import org.apache.cocoon.core.container.ContainerTestCase;
+import org.apache.cocoon.forms.FormsConstants;
+import org.apache.cocoon.forms.datatype.typeimpl.EnumType;
+import org.apache.cocoon.xml.dom.DOMBuilder;
+import org.apache.excalibur.source.impl.ResourceSource;
+import org.custommonkey.xmlunit.Diff;
+import org.w3c.dom.Document;
+
+/**
+ * Test case for CForms's DynamicSelectionList datatype.
+ *
+ * @version $Id: EnumSelectionListTestCase.java 326838 2005-10-20 06:26:53Z sylvain $
+ */
+public class EnumSelectionListTestCase extends ContainerTestCase {
+
+    protected DatatypeManager datatypeManager;
+    protected DocumentBuilder parser;
+
+    /* (non-Javadoc)
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception {
+        super.setUp();
+        datatypeManager = (DatatypeManager) this.lookup(DatatypeManager.ROLE);
+        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+        factory.setNamespaceAware(true);
+        parser = factory.newDocumentBuilder();
+    }
+    
+    /* (non-Javadoc)
+     * @see junit.framework.TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception {
+        if (datatypeManager != null) {
+            this.release(datatypeManager);
+        }
+        super.tearDown();
+    }
+    
+    /**
+     * Test the generateSaxFragment method.
+     * @throws MalformedURLException
+     * @throws ParserConfigurationException
+     */
+    public void testGenerateSaxFragment() throws Exception {
+        DOMBuilder dest = new DOMBuilder();
+        EnumSelectionList list = 
+            new EnumSelectionList(Sex.class.getName(), new EnumType(), false);
+        list.generateSaxFragment(dest, Locale.ENGLISH);
+        ResourceSource expectedSource =
+            new ResourceSource("resource://org/apache/cocoon/forms/datatype/EnumSelectionListTestCase.dest-no-null.xml");
+        Document expected = parser.parse(expectedSource.getInputStream());
+        assertEqual("Test if output is what is expected",
+                expected, dest.getDocument());
+    }
+    
+    /**
+     * Test the generateSaxFragment method with a nullable selection list
+     * @throws MalformedURLException
+     * @throws ParserConfigurationException
+     */
+    public void testGenerateSaxFragmentNullable() throws Exception {
+        DOMBuilder dest = new DOMBuilder();
+        EnumSelectionList list = 
+            new EnumSelectionList(Sex.class.getName(), new EnumType(), true);
+        list.generateSaxFragment(dest, Locale.ENGLISH);
+        ResourceSource expectedSource =
+            new ResourceSource("resource://org/apache/cocoon/forms/datatype/EnumSelectionListTestCase.dest.xml");
+        Document expected = parser.parse(expectedSource.getInputStream());
+        assertEqual("Test if output is what is expected",
+                expected, dest.getDocument());
+    }
+    
+    /**
+     * Check is the source document is equal to the one produced by the method under test.
+     * @param message A message to print in case of failure.
+     * @param expected The expected (source) document.
+     * @param actual The actual (output) document.
+     */
+    private void assertEqual(String message, Document expected, Document actual) {
+        expected.getDocumentElement().normalize();
+        actual.getDocumentElement().normalize();
+        // DIRTY HACK WARNING: we add the "xmlns:*" attributes reported
+        // by DOM, as expected, but not generated by the method under test,
+        // otherwise the comparison would fail. 
+        actual.getDocumentElement().setAttribute(FormsConstants.INSTANCE_PREFIX,
+                FormsConstants.INSTANCE_NS);
+        actual.getDocumentElement().setAttribute("i18n",
+                I18nTransformer.I18N_NAMESPACE_URI);
+        Diff diff =  new Diff(expected, actual);
+        assertTrue(message + ", " + diff.toString(), diff.similar());
+    }
+
+    /**
+     * Print a document to a writer for debugging purposes.
+     * @param document The document to print.
+     * @param out The writer to write to.
+     */
+    public final void print(Document document, Writer out) {
+        TransformerFactory factory = TransformerFactory.newInstance();
+        try {
+            javax.xml.transform.Transformer serializer =
+                factory.newTransformer();
+            serializer.transform(
+                new DOMSource(document),
+                new StreamResult(out));
+            out.write('\n');
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/EnumSelectionListTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/EnumSelectionListTestCase.xtest
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/EnumSelectionListTestCase.xtest?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/EnumSelectionListTestCase.xtest (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/EnumSelectionListTestCase.xtest Thu Nov  3 05:41:06 2005
@@ -0,0 +1,91 @@
+<?xml version="1.0" ?>
+<!--
+  Copyright 1999-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.
+-->
+<testcase>
+ <roles>
+
+  <role name="org.apache.cocoon.forms.datatype.DatatypeManager"
+    shorthand="forms-datatype"
+    default-class="org.apache.cocoon.forms.datatype.DefaultDatatypeManager"/>
+
+  <role name="org.apache.cocoon.forms.expression.ExpressionManager"
+    shorthand="forms-expression"
+    default-class="org.apache.cocoon.forms.expression.DefaultExpressionManager"/>
+
+  <role name="org.apache.excalibur.xmlizer.XMLizer"
+        shorthand="xmlizer"
+        default-class="org.apache.excalibur.xmlizer.DefaultXMLizer"/>
+
+  <role name="org.apache.excalibur.xml.sax.SAXParser"
+        shorthand="xml-parser"
+        default-class="org.apache.excalibur.xml.impl.JaxpParser"/>
+
+ </roles>
+
+ <components>
+  <forms-datatype logger="forms">
+    <datatypes>
+      <datatype name="string" src="org.apache.cocoon.forms.datatype.typeimpl.StringTypeBuilder">
+        <convertors default="dummy" plain="dummy">
+          <convertor name="dummy" src="org.apache.cocoon.forms.datatype.convertor.DummyStringConvertorBuilder"/>
+        </convertors>
+      </datatype>
+      <datatype name="long" src="org.apache.cocoon.forms.datatype.typeimpl.LongTypeBuilder">
+        <convertors default="formatting" plain="plain">
+          <convertor name="plain" src="org.apache.cocoon.forms.datatype.convertor.PlainLongConvertorBuilder"/>
+          <convertor name="formatting" src="org.apache.cocoon.forms.datatype.convertor.FormattingLongConvertorBuilder"/>
+        </convertors>
+      </datatype>
+      <datatype name="decimal" src="org.apache.cocoon.forms.datatype.typeimpl.DecimalTypeBuilder">
+        <convertors default="formatting" plain="plain">
+          <convertor name="plain" src="org.apache.cocoon.forms.datatype.convertor.PlainDecimalConvertorBuilder"/>
+          <convertor name="formatting" src="org.apache.cocoon.forms.datatype.convertor.FormattingDecimalConvertorBuilder"/>
+        </convertors>
+      </datatype>
+      <datatype name="date" src="org.apache.cocoon.forms.datatype.typeimpl.DateTypeBuilder">
+        <convertors default="formatting" plain="millis">
+          <convertor name="formatting" src="org.apache.cocoon.forms.datatype.convertor.FormattingDateConvertorBuilder"/>
+          <convertor name="millis" src="org.apache.cocoon.forms.datatype.convertor.MillisDateConvertorBuilder"/>
+        </convertors>
+      </datatype>
+      <datatype name="boolean" src="org.apache.cocoon.forms.datatype.typeimpl.BooleanTypeBuilder">
+        <convertors default="plain" plain="plain">
+          <convertor name="plain" src="org.apache.cocoon.forms.datatype.convertor.PlainBooleanConvertorBuilder"/>
+        </convertors>
+      </datatype>  
+      <datatype name="integer" src="org.apache.cocoon.forms.datatype.typeimpl.IntegerTypeBuilder">
+        <convertors default="formatting" plain="plain">
+          <convertor name="plain" src="org.apache.cocoon.forms.datatype.convertor.PlainIntegerConvertorBuilder"/>
+          <convertor name="formatting" src="org.apache.cocoon.forms.datatype.convertor.FormattingIntegerConvertorBuilder"/>
+        </convertors>
+      </datatype>  
+    </datatypes>
+    <validation-rules>
+      <validation-rule name="length" src="org.apache.cocoon.forms.datatype.validationruleimpl.LengthValidationRuleBuilder"/>
+      <validation-rule name="email" src="org.apache.cocoon.forms.datatype.validationruleimpl.EmailValidationRuleBuilder"/>
+      <validation-rule name="value-count" src="org.apache.cocoon.forms.datatype.validationruleimpl.ValueCountValidationRuleBuilder"/>
+      <validation-rule name="range" src="org.apache.cocoon.forms.datatype.validationruleimpl.RangeValidationRuleBuilder"/>
+      <validation-rule name="assert" src="org.apache.cocoon.forms.datatype.validationruleimpl.AssertValidationRuleBuilder"/>
+      <validation-rule name="mod10" src="org.apache.cocoon.forms.datatype.validationruleimpl.Mod10ValidationRuleBuilder"/>
+      <validation-rule name="regexp" src="org.apache.cocoon.forms.datatype.validationruleimpl.RegExpValidationRuleBuilder"/>
+    </validation-rules>
+  </forms-datatype>
+
+  <forms-expression logger="forms.expression"/>
+
+ </components>
+
+</testcase>

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/FlowJXPathSelectionListTestCase.dest.xml
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/FlowJXPathSelectionListTestCase.dest.xml?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/FlowJXPathSelectionListTestCase.dest.xml (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/FlowJXPathSelectionListTestCase.dest.xml Thu Nov  3 05:41:06 2005
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Copyright 1999-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.
+-->
+<fi:selection-list xmlns:fi="http://apache.org/cocoon/forms/1.0#instance"><fi:item value="1"><fi:label>One</fi:label></fi:item><fi:item value="2"><fi:label>Two</fi:label></fi:item></fi:selection-list>

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/FlowJXPathSelectionListTestCase.dest.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/FlowJXPathSelectionListTestCase.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/FlowJXPathSelectionListTestCase.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/FlowJXPathSelectionListTestCase.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/FlowJXPathSelectionListTestCase.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,197 @@
+/*
+ * Copyright 1999-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.cocoon.forms.datatype;
+
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.context.DefaultContext;
+import org.apache.cocoon.components.ContextHelper;
+import org.apache.cocoon.components.flow.FlowHelper;
+import org.apache.cocoon.core.container.ContainerTestCase;
+import org.apache.cocoon.environment.ObjectModelHelper;
+import org.apache.cocoon.environment.Request;
+import org.apache.cocoon.environment.mock.MockRequest;
+import org.apache.cocoon.forms.FormsConstants;
+import org.apache.cocoon.xml.dom.DOMBuilder;
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.impl.ResourceSource;
+import org.custommonkey.xmlunit.Diff;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * Test case for CForms's FlowModelSelectionList datatype.
+ * @version $Id: FlowJXPathSelectionListTestCase.java 326838 2005-10-20 06:26:53Z sylvain $
+ */
+public class FlowJXPathSelectionListTestCase extends ContainerTestCase {
+
+    protected DatatypeManager datatypeManager;
+    protected DocumentBuilder parser;
+
+    /* (non-Javadoc)
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception {
+        super.setUp();
+        datatypeManager = (DatatypeManager) this.lookup(DatatypeManager.ROLE);
+        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+        factory.setNamespaceAware(true);
+        parser = factory.newDocumentBuilder();
+    }
+    
+    /* (non-Javadoc)
+     * @see junit.framework.TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception {
+        if (datatypeManager != null) {
+            this.release(datatypeManager);
+        }
+        super.tearDown();
+    }
+    
+    /**
+     * Test the generateSaxFragment method.
+     */
+    public void testGenerateSaxFragment() throws Exception {
+        List beans = new ArrayList(2);
+        beans.add(new TestBean("1", "One"));
+        beans.add(new TestBean("2", "Two"));
+        Map flowContextObject = new HashMap();
+        flowContextObject.put("beans", beans);
+        Request request = new MockRequest();
+        Map objectModel = new HashMap();
+        FlowHelper.setContextObject(objectModel, flowContextObject);
+        objectModel.put(ObjectModelHelper.REQUEST_OBJECT, request);
+        Map contextObjectModel = new HashMap();
+        contextObjectModel.put(ContextHelper.CONTEXT_OBJECT_MODEL, objectModel);
+        Context context = new DefaultContext(contextObjectModel);
+        Source sampleSource = new ResourceSource("resource://org/apache/cocoon/forms/datatype/FlowJXPathSelectionListTestCase.source.xml");
+        Document sample = parser.parse(sampleSource.getInputStream());
+        Element datatypeElement = (Element) sample.getElementsByTagNameNS(FormsConstants.DEFINITION_NS, "datatype").item(0);
+        Datatype datatype = datatypeManager.createDatatype(datatypeElement, false);
+        FlowJXPathSelectionList list = new FlowJXPathSelectionList
+            (context, "beans", "key", "value", datatype,null,false,null,false);
+        DOMBuilder dest = new DOMBuilder();
+        list.generateSaxFragment(dest, Locale.ENGLISH);
+        Source expectedSource = new ResourceSource("resource://org/apache/cocoon/forms/datatype/FlowJXPathSelectionListTestCase.dest.xml");
+        Document expected = parser.parse(expectedSource.getInputStream());
+        assertEqual("Test if generated list matches expected",
+            expected, dest.getDocument());
+    }
+    
+    /**
+     * Test the generateSaxFragment method with a list containing a null value.
+     */
+    public void testGenerateSaxFragmentWithNull() throws Exception {
+        List beans = new ArrayList(2);
+        beans.add(null);
+        beans.add(new TestBean("1", "One"));
+        beans.add(new TestBean("2", "Two"));
+        Map flowContextObject = new HashMap();
+        flowContextObject.put("beans", beans);
+        Request request = new MockRequest();
+        Map objectModel = new HashMap();
+        FlowHelper.setContextObject(objectModel, flowContextObject);
+        objectModel.put(ObjectModelHelper.REQUEST_OBJECT, request);
+        Map contextObjectModel = new HashMap();
+        contextObjectModel.put(ContextHelper.CONTEXT_OBJECT_MODEL, objectModel);
+        Context context = new DefaultContext(contextObjectModel);
+        Source sampleSource = new ResourceSource("resource://org/apache/cocoon/forms/datatype/FlowJXPathSelectionListTestCase.source.xml");
+        Document sample = parser.parse(sampleSource.getInputStream());
+        Element datatypeElement = (Element) sample.getElementsByTagNameNS(FormsConstants.DEFINITION_NS, "datatype").item(0);
+        Datatype datatype = datatypeManager.createDatatype(datatypeElement, false);
+        FlowJXPathSelectionList list = new FlowJXPathSelectionList
+            (context, "beans", "key", "value", datatype,null,false,null,false);
+        DOMBuilder dest = new DOMBuilder();
+        list.generateSaxFragment(dest, Locale.ENGLISH);
+        Source expectedSource = new ResourceSource("resource://org/apache/cocoon/forms/datatype/FlowJXPathSelectionListTestCaseWithNull.dest.xml");
+        Document expected = parser.parse(expectedSource.getInputStream());
+        assertEqual("Test if generated list matches expected",
+                expected, dest.getDocument());
+    }
+    
+    /**
+     * Check is the source document is equal to the one produced by the method under test.
+     * @param message A message to print in case of failure.
+     * @param expected The expected (source) document.
+     * @param actual The actual (output) document.
+     */
+    private void assertEqual(String message, Document expected, Document actual) {
+        expected.getDocumentElement().normalize();
+        actual.getDocumentElement().normalize();
+        // DIRTY HACK WARNING: we add the "xmlns:wi" attribute reported
+        // by DOM, as expected, but not generated by the method under test,
+        // otherwise the comparison would fail. 
+        actual.getDocumentElement().setAttribute(FormsConstants.INSTANCE_PREFIX,
+                FormsConstants.INSTANCE_NS);
+        Diff diff =  new Diff(expected, actual);
+        assertTrue(message + ", " + diff.toString(), diff.similar());
+    }
+
+    /**
+     * Print a document to a writer for debugging purposes.
+     * @param document The document to print.
+     * @param out The writer to write to.
+     */
+    public final void print(Document document, Writer out) {
+        TransformerFactory factory = TransformerFactory.newInstance();
+        try {
+            javax.xml.transform.Transformer serializer =
+                factory.newTransformer();
+            serializer.transform(
+                new DOMSource(document),
+                new StreamResult(out));
+            out.write('\n');
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+    
+    public static class TestBean {
+        private String key;
+        private String value;
+
+        public TestBean(String key, String value) {
+            this.key = key;
+            this.value = value;
+        }
+        
+        public String getKey() {
+            return key;
+        }
+        
+        public String getValue() {
+            return value;
+        }
+        
+        public String toString() {
+            return "{ " + key + " : " + value + " }";
+        }
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/FlowJXPathSelectionListTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/FlowJXPathSelectionListTestCase.source.xml
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/FlowJXPathSelectionListTestCase.source.xml?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/FlowJXPathSelectionListTestCase.source.xml (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/FlowJXPathSelectionListTestCase.source.xml Thu Nov  3 05:41:06 2005
@@ -0,0 +1,27 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-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.
+-->
+
+<!--+
+    |   Source file for FlowModelSelectionList test case.
+    |   $Id: FlowJXPathSelectionListTestCase.source.xml 149119 2005-01-30 10:20:07Z sylvain $
+    +-->
+
+<fd:field xmlns:fd="http://apache.org/cocoon/forms/1.0#definition"
+  id="sample" required="false">
+  <fd:datatype base="string"/>
+  <fd:selection-list model="beans"/>
+</fd:field>

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/FlowJXPathSelectionListTestCase.source.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/FlowJXPathSelectionListTestCase.xtest
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/FlowJXPathSelectionListTestCase.xtest?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/FlowJXPathSelectionListTestCase.xtest (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/FlowJXPathSelectionListTestCase.xtest Thu Nov  3 05:41:06 2005
@@ -0,0 +1,83 @@
+<?xml version="1.0" ?>
+<!--
+  Copyright 1999-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.
+-->
+<testcase>
+ <roles>
+
+  <role name="org.apache.cocoon.forms.datatype.DatatypeManager"
+    shorthand="forms-datatype"
+    default-class="org.apache.cocoon.forms.datatype.DefaultDatatypeManager"/>
+
+  <role name="org.apache.cocoon.forms.expression.ExpressionManager"
+    shorthand="forms-expression"
+    default-class="org.apache.cocoon.forms.expression.DefaultExpressionManager"/>
+
+ </roles>
+
+ <components>
+  <forms-datatype logger="forms">
+    <datatypes>
+      <datatype name="string" src="org.apache.cocoon.forms.datatype.typeimpl.StringTypeBuilder">
+        <convertors default="dummy" plain="dummy">
+          <convertor name="dummy" src="org.apache.cocoon.forms.datatype.convertor.DummyStringConvertorBuilder"/>
+        </convertors>
+      </datatype>
+      <datatype name="long" src="org.apache.cocoon.forms.datatype.typeimpl.LongTypeBuilder">
+        <convertors default="formatting" plain="plain">
+          <convertor name="plain" src="org.apache.cocoon.forms.datatype.convertor.PlainLongConvertorBuilder"/>
+          <convertor name="formatting" src="org.apache.cocoon.forms.datatype.convertor.FormattingLongConvertorBuilder"/>
+        </convertors>
+      </datatype>
+      <datatype name="decimal" src="org.apache.cocoon.forms.datatype.typeimpl.DecimalTypeBuilder">
+        <convertors default="formatting" plain="plain">
+          <convertor name="plain" src="org.apache.cocoon.forms.datatype.convertor.PlainDecimalConvertorBuilder"/>
+          <convertor name="formatting" src="org.apache.cocoon.forms.datatype.convertor.FormattingDecimalConvertorBuilder"/>
+        </convertors>
+      </datatype>
+      <datatype name="date" src="org.apache.cocoon.forms.datatype.typeimpl.DateTypeBuilder">
+        <convertors default="formatting" plain="millis">
+          <convertor name="formatting" src="org.apache.cocoon.forms.datatype.convertor.FormattingDateConvertorBuilder"/>
+          <convertor name="millis" src="org.apache.cocoon.forms.datatype.convertor.MillisDateConvertorBuilder"/>
+        </convertors>
+      </datatype>
+      <datatype name="boolean" src="org.apache.cocoon.forms.datatype.typeimpl.BooleanTypeBuilder">
+        <convertors default="plain" plain="plain">
+          <convertor name="plain" src="org.apache.cocoon.forms.datatype.convertor.PlainBooleanConvertorBuilder"/>
+        </convertors>
+      </datatype>  
+      <datatype name="integer" src="org.apache.cocoon.forms.datatype.typeimpl.IntegerTypeBuilder">
+        <convertors default="formatting" plain="plain">
+          <convertor name="plain" src="org.apache.cocoon.forms.datatype.convertor.PlainIntegerConvertorBuilder"/>
+          <convertor name="formatting" src="org.apache.cocoon.forms.datatype.convertor.FormattingIntegerConvertorBuilder"/>
+        </convertors>
+      </datatype>  
+    </datatypes>
+    <validation-rules>
+      <validation-rule name="length" src="org.apache.cocoon.forms.datatype.validationruleimpl.LengthValidationRuleBuilder"/>
+      <validation-rule name="email" src="org.apache.cocoon.forms.datatype.validationruleimpl.EmailValidationRuleBuilder"/>
+      <validation-rule name="value-count" src="org.apache.cocoon.forms.datatype.validationruleimpl.ValueCountValidationRuleBuilder"/>
+      <validation-rule name="range" src="org.apache.cocoon.forms.datatype.validationruleimpl.RangeValidationRuleBuilder"/>
+      <validation-rule name="assert" src="org.apache.cocoon.forms.datatype.validationruleimpl.AssertValidationRuleBuilder"/>
+      <validation-rule name="mod10" src="org.apache.cocoon.forms.datatype.validationruleimpl.Mod10ValidationRuleBuilder"/>
+      <validation-rule name="regexp" src="org.apache.cocoon.forms.datatype.validationruleimpl.RegExpValidationRuleBuilder"/>
+    </validation-rules>
+  </forms-datatype>
+
+  <forms-expression logger="forms.expression"/>
+
+ </components>
+
+</testcase>

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/FlowJXPathSelectionListTestCaseWithNull.dest.xml
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/FlowJXPathSelectionListTestCaseWithNull.dest.xml?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/FlowJXPathSelectionListTestCaseWithNull.dest.xml (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/FlowJXPathSelectionListTestCaseWithNull.dest.xml Thu Nov  3 05:41:06 2005
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Copyright 1999-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.
+-->
+<fi:selection-list xmlns:fi="http://apache.org/cocoon/forms/1.0#instance"><fi:item value=""/><fi:item value="1"><fi:label>One</fi:label></fi:item><fi:item value="2"><fi:label>Two</fi:label></fi:item></fi:selection-list>

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/FlowJXPathSelectionListTestCaseWithNull.dest.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/Sex.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/Sex.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/Sex.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/Sex.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,40 @@
+/*
+ * Copyright 1999-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.cocoon.forms.datatype;
+
+
+/**
+ * Description of Sex.
+ *
+ * @version $Id: Sex.java 151050 2005-02-02 20:47:40Z tim $
+ */
+public class Sex {
+
+    public static final Sex MALE = new Sex("M");
+    public static final Sex FEMALE = new Sex("F");
+    private String code;
+
+    private Sex(String code) { this.code = code; }
+
+    public String toString() {
+      // Will probably have some i18n support here
+      switch(code.charAt(0)) {
+          case 'M' : return this.getClass().getName() + ".MALE";
+          case 'F' : return this.getClass().getName() + ".FEMALE";
+          default : return "unknown"; // Should never happen
+      }
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/Sex.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/convertor/EnumConvertorBuilderTestCase.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/convertor/EnumConvertorBuilderTestCase.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/convertor/EnumConvertorBuilderTestCase.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/convertor/EnumConvertorBuilderTestCase.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,69 @@
+/*
+ * Copyright 1999-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.cocoon.forms.datatype.convertor;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import junit.framework.TestCase;
+
+import org.apache.cocoon.forms.FormsConstants;
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.impl.ResourceSource;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * Test case for the {@link EnumConvertorBuilder} class.
+ * 
+ * @version $Id: EnumConvertorBuilderTestCase.java 326838 2005-10-20 06:26:53Z sylvain $
+ */
+public class EnumConvertorBuilderTestCase extends TestCase {
+
+    protected DocumentBuilder parser;
+
+    /* (non-Javadoc)
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception {
+        super.setUp();
+        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+        factory.setNamespaceAware(true);
+        parser = factory.newDocumentBuilder();
+    }
+
+    public EnumConvertorBuilderTestCase(String name) {
+        super(name);
+    }
+
+    /**
+     * Test the {@link EnumConvertorBuilder#build(org.w3c.dom.Element)
+     * build} method.
+     * @throws Exception
+     */
+    public void testBuild() throws Exception {
+        Source confSource = new ResourceSource("resource://org/apache/cocoon/forms/datatype/convertor/EnumConvertorTestCase.conf.xml");
+        Document sample = parser.parse(confSource.getInputStream());
+        Element convertorElement = (Element) sample.getElementsByTagNameNS(FormsConstants.DEFINITION_NS, "convertor").item(0);
+        String enumClassName = convertorElement.getElementsByTagNameNS(FormsConstants.DEFINITION_NS, "enum").item(0).getFirstChild().getNodeValue();
+        EnumConvertorBuilder builder = new EnumConvertorBuilder();
+        Convertor convertor = builder.build(convertorElement);
+        assertTrue("The returned convertor is not an EnumConvertor",
+                convertor instanceof EnumConvertor);
+        assertEquals("The convertor does not convert the expected class",
+                Class.forName(enumClassName), convertor.getTypeClass());
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/convertor/EnumConvertorBuilderTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/convertor/EnumConvertorTestCase.conf.xml
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/convertor/EnumConvertorTestCase.conf.xml?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/convertor/EnumConvertorTestCase.conf.xml (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/convertor/EnumConvertorTestCase.conf.xml Thu Nov  3 05:41:06 2005
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Copyright 1999-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.
+-->
+
+<fd:field id="sex" xmlns:fd="http://apache.org/cocoon/forms/1.0#definition">
+  <fd:label>Sex</fd:label>
+  <fd:datatype base="enum">
+  	<fd:convertor type="enum">
+      <fd:enum>org.apache.cocoon.forms.datatype.Sex</fd:enum>
+  	</fd:convertor>
+  </fd:datatype>
+  <fd:selection-list type="enum" class="org.apache.cocoon.forms.datatype.Sex"/>
+</fd:field>

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/convertor/EnumConvertorTestCase.conf.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/convertor/EnumConvertorTestCase.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/convertor/EnumConvertorTestCase.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/convertor/EnumConvertorTestCase.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/convertor/EnumConvertorTestCase.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,57 @@
+/*
+ * Copyright 1999-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.cocoon.forms.datatype.convertor;
+
+import java.util.Locale;
+
+import org.apache.cocoon.forms.datatype.Sex;
+
+import junit.framework.TestCase;
+
+/**
+ * Test case for the {@link EnumConvertor} class.
+ * 
+ * @version $Id: EnumConvertorTestCase.java 151050 2005-02-02 20:47:40Z tim $
+ */
+public class EnumConvertorTestCase extends TestCase {
+
+    public EnumConvertorTestCase(String name) {
+        super(name);
+    }
+
+    /**
+     * Test the {@link EnumConvertor#convertFromString(java.lang.String, java.util.Locale, org.apache.cocoon.forms.datatype.convertor.Convertor.FormatCache)
+     * method.
+     */
+    public void testConvertFromString() {
+        EnumConvertor convertor = new EnumConvertor("org.apache.cocoon.forms.datatype.Sex");
+        ConversionResult conversionResult = convertor.convertFromString
+            (Sex.class.getName() + ".FEMALE", Locale.getDefault(), null);
+        assertSame("Returned sex must be FEMALE", Sex.FEMALE, conversionResult.getResult());
+    }
+    
+    /**
+     * Test the {@link EnumConvertor##convertToString(java.lang.Object, java.util.Locale, org.apache.cocoon.forms.datatype.convertor.Convertor.FormatCache)
+     * method.
+     */
+    public void testConvertToString() {
+        EnumConvertor convertor = new EnumConvertor("org.apache.cocoon.forms.datatype.Sex");
+        assertEquals("Converted value must match string",
+                Sex.class.getName() + ".MALE",
+                convertor.convertToString
+                    (Sex.MALE, Locale.getDefault(), null));
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/convertor/EnumConvertorTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/validationruleimpl/EmailValidationRuleTest.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/validationruleimpl/EmailValidationRuleTest.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/validationruleimpl/EmailValidationRuleTest.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/validationruleimpl/EmailValidationRuleTest.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,49 @@
+/*
+ * Copyright 1999-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.cocoon.forms.datatype.validationruleimpl;
+
+import junit.framework.TestCase;
+
+
+/**
+ * Description of EmailValidationRuleTest.
+ * 
+ * @version $Id: EmailValidationRuleTest.java 151179 2005-02-03 16:55:16Z tim $
+ */
+public class EmailValidationRuleTest extends TestCase {
+
+    public EmailValidationRuleTest(String name) {
+        super(name);
+    }
+    
+    /**
+     * Test some patterns that should be accepted.
+     */
+    public void testAccept() {
+        EmailValidationRule rule = new EmailValidationRule();
+        assertTrue("dev@cocoon.apache.org", rule.isEmail("dev@cocoon.apache.org"));
+        assertTrue("\"Arc, Joan\"@ird.govt.nz", rule.isEmail("\"Arc, Joan\"@ird.govt.nz"));
+    }
+    
+    /**
+     * Test some patterns that should be rejected.
+     */
+    public void testReject() {
+        EmailValidationRule rule = new EmailValidationRule();
+        assertTrue("x@....", ! rule.isEmail("x@...."));
+        assertTrue("neville.@hotmail.com", ! rule.isEmail("neville.@hotmail.com"));
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/datatype/validationruleimpl/EmailValidationRuleTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/formmodel/FieldTestCase.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/formmodel/FieldTestCase.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/formmodel/FieldTestCase.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/formmodel/FieldTestCase.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,227 @@
+/*
+ * Copyright 1999-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.cocoon.forms.formmodel;
+
+import org.apache.cocoon.core.container.ContainerTestCase;
+import org.apache.cocoon.environment.mock.MockRequest;
+import org.apache.cocoon.forms.FormContext;
+import org.apache.cocoon.forms.event.ValueChangedEvent;
+import org.apache.cocoon.forms.event.ValueChangedListener;
+import org.w3c.dom.Document;
+
+/**
+ * Test case for CForm's Field widget
+ *
+ * @version $Id: FieldTestCase.java 106132 2004-11-21 22:29:26Z sylvain $
+ */
+
+public class FieldTestCase extends ContainerTestCase {
+    
+    public static final String VALUE_PATH = "fi:fragment/fi:field/fi:value";
+    public static final String VALIDATION_PATH = "fi:fragment/fi:field/fi:validation-message";
+    
+    
+    /**
+     * Nominal test where the request data is syntactically correct and validates
+     */
+    public void testValueDoesParseAndValidate() throws Exception {
+        Form form = WidgetTestHelper.loadForm(getManager(), this, "FieldTestCase.model.xml");
+        Field field = (Field)form.getChild("intfield");
+        Action button = (Action)form.getChild("action");
+        MockRequest request;
+        
+        request = new MockRequest();
+        request.addParameter("intfield", "11");
+        request.addParameter("action", "pressed");
+        form.process(new FormContext(request));
+        
+        // No parsing nor validation where performed
+        Document doc = WidgetTestHelper.getWidgetFragment(field, null);
+        WidgetTestHelper.assertXPathEquals("Displayed value", "11", VALUE_PATH, doc);
+        WidgetTestHelper.assertXPathNotExists("Validation error", VALIDATION_PATH, doc);
+        
+        // Now do some parsing.
+        assertEquals("Field value", new Integer(11), field.getValue());
+        // And still no validation error (do not call getValidationError() as it does validate)
+        doc = WidgetTestHelper.getWidgetFragment(field, null);
+        WidgetTestHelper.assertXPathNotExists("Validation error", VALIDATION_PATH, doc);
+        
+        // Now validate
+        assertTrue("Field does validate", field.validate());
+        assertNull("getValidationError() null after validation", field.getValidationError());
+        doc = WidgetTestHelper.getWidgetFragment(field, null);
+        WidgetTestHelper.assertXPathNotExists("Validation error", VALIDATION_PATH, doc);        
+    }
+    
+    /**
+     * Request data is not syntactically correct
+     */
+    public void testValueDoesNotParse() throws Exception {
+        Form form = WidgetTestHelper.loadForm(getManager(), this, "FieldTestCase.model.xml");
+        Field field = (Field)form.getChild("intfield");
+        Action button = (Action)form.getChild("action");
+        MockRequest request;
+        
+        request = new MockRequest();
+        request.addParameter("intfield", "foo");
+        request.addParameter("action", "pressed");
+        form.process(new FormContext(request));
+        
+        // No parsing nor validation where performed
+        Document doc = WidgetTestHelper.getWidgetFragment(field, null);
+        WidgetTestHelper.assertXPathEquals("Displayed velue", "foo", VALUE_PATH, doc);
+        WidgetTestHelper.assertXPathNotExists("Validation error before parse", VALIDATION_PATH, doc);
+        
+        // Now do some parsing. Will return null as it's not parseable
+        assertNull("Field value", field.getValue());
+        // But still no validation error
+        doc = WidgetTestHelper.getWidgetFragment(field, null);
+        WidgetTestHelper.assertXPathEquals("Displayed value", "foo", VALUE_PATH, doc);
+        WidgetTestHelper.assertXPathNotExists("Validation error after parse", VALIDATION_PATH, doc);
+        
+        // Now validate
+        assertFalse("Field validation", field.validate());
+        doc = WidgetTestHelper.getWidgetFragment(field, null);
+        WidgetTestHelper.assertXPathEquals("Displayed velue", "foo", VALUE_PATH, doc);
+        WidgetTestHelper.assertXPathExists("Validation not null after parse", VALIDATION_PATH, doc);
+        assertNotNull("getValidationError() not null after validation", field.getValidationError());
+    }
+    
+    /**
+     * Request data is syntactically correct but doesn't validate
+     */
+    public void testValueDoesNotValidate() throws Exception {
+        Form form = WidgetTestHelper.loadForm(getManager(), this, "FieldTestCase.model.xml");
+        Field field = (Field)form.getChild("intfield");
+        Action button = (Action)form.getChild("action");
+        MockRequest request;
+        
+        request = new MockRequest();
+        request.addParameter("intfield", "1");
+        request.addParameter("action", "pressed");
+        form.process(new FormContext(request));
+        
+        // No parsing nor validation where performed
+        Document doc = WidgetTestHelper.getWidgetFragment(field, null);
+        WidgetTestHelper.assertXPathEquals("Displayed value", "1", VALUE_PATH, doc);
+        WidgetTestHelper.assertXPathNotExists("Validation error before parse", VALIDATION_PATH, doc);
+        
+        // Now do some parsing. Will return null although syntactically correct as it's invalid
+        assertNull("Field value", field.getValue());
+        // But still no validation error
+        doc = WidgetTestHelper.getWidgetFragment(field, null);
+        WidgetTestHelper.assertXPathNotExists("Validation error after parse", VALIDATION_PATH, doc);
+        
+        // Now validate
+        assertFalse("Field validation", field.validate());
+        doc = WidgetTestHelper.getWidgetFragment(field, null);
+        WidgetTestHelper.assertXPathExists("Validation error after validation", VALIDATION_PATH, doc);
+        assertNotNull("getValidationError() not null after validation", field.getValidationError());
+    }
+    
+    /**
+     * Test that a field's value is properly set by a call to setValue("") with an
+     * empty string when the field is in unparsed state (there used to be a bug in
+     * that case)
+     */
+    public void testSetEmptyValueWhenValueChangedOnRequest() throws Exception {
+        Form form = WidgetTestHelper.loadForm(getManager(), this, "FieldTestCase.model.xml");
+        Field field = (Field)form.getChild("stringfield");
+        Action button = (Action)form.getChild("action");
+        MockRequest request;
+        
+        // Set a value in stringfield and submit with an action
+        // (no validation, thus no call to doParse())
+        request = new MockRequest();
+        request.addParameter("stringfield", "bar");
+        request.addParameter("action", "pressed");
+        form.process(new FormContext(request));
+        
+        // Verify submit widget, just to be sure that validation did not occur
+        assertEquals("Form submit widget", button, form.getSubmitWidget());
+        
+        // Set the value to an empty string. In that case, a faulty test made
+        // it actually ignore it when state was VALUE_UNPARSED
+        field.setValue("");
+        
+        // Check value by various means
+        Document doc = WidgetTestHelper.getWidgetFragment(field, null);
+        WidgetTestHelper.assertXPathEquals("Displayed value", "", VALUE_PATH, doc);
+        assertEquals("Datatype string conversion", "", field.getDatatype().convertToString(field.value, null));
+        assertEquals("Field value", "", (String)field.getValue());
+    }
+    
+    /**
+     * Test that the previous field value is correctly passed to event listeners
+     * even if it was not already parsed.
+     */
+    public void testOldValuePresentInEventEvenIfNotParsed() throws Exception {
+        Form form = WidgetTestHelper.loadForm(getManager(), this, "FieldTestCase.model.xml");
+        Field field = (Field)form.getChild("stringfield");
+        Action button = (Action)form.getChild("action");
+        MockRequest request;
+        
+        // Set a value on "stringfield", and submit using an action so that
+        // it stays in unparsed state
+        request = new MockRequest();
+        request.addParameter("stringfield", "foo");
+        request.addParameter("action", "pressed");
+        form.process(new FormContext(request));
+
+        // Now add an event listener that will check old an new value
+        field.addValueChangedListener(new ValueChangedListener (){
+            public void valueChanged(ValueChangedEvent event) {
+                assertEquals("Old value", "foo", (String)event.getOldValue());
+                assertEquals("New value", "bar", (String)event.getNewValue());
+            }
+        });
+        
+        // Change value to "bar", still without explicit validation
+        // That will call the event listener
+        request = new MockRequest();
+        request.addParameter("stringfield", "bar");
+        request.addParameter("button", "pressed");
+        form.process(new FormContext(request));
+    }
+    
+    /**
+     * Request parameters are not read when a field is not in active state
+     */
+    public void testParameterNotReadWhenDisabled() throws Exception {
+        Form form = WidgetTestHelper.loadForm(getManager(), this, "FieldTestCase.model.xml");
+        Field field = (Field)form.getChild("stringfield");
+        MockRequest request;
+
+        // Disable the form
+        form.setState(WidgetState.DISABLED);
+        field.setValue("foo");
+        
+        request = new MockRequest();
+        request.addParameter("stringfield", "bar");
+        form.process(new FormContext(request));
+        
+        // Check that "bar" was not read
+        assertEquals("foo", field.getValue());
+        
+        // Switch back to active and resumbit the same request
+        form.setState(WidgetState.ACTIVE);
+        form.process(new FormContext(request));
+        
+        // Should have changed now
+        assertEquals("bar", field.getValue());
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/formmodel/FieldTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/formmodel/FieldTestCase.model.xml
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/formmodel/FieldTestCase.model.xml?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/formmodel/FieldTestCase.model.xml (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/formmodel/FieldTestCase.model.xml Thu Nov  3 05:41:06 2005
@@ -0,0 +1,36 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 2005 The Apache Software Foundation or its licensors,
+  as applicable.
+
+  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.
+-->
+<fd:form xmlns:fd="http://apache.org/cocoon/forms/1.0#definition">
+    <fd:widgets>
+        <fd:field id="stringfield">
+            <fd:datatype base="string"/>
+        </fd:field>
+        
+        <fd:field id="intfield">
+            <fd:datatype base="integer">
+                <fd:convertor type="plain"/>
+            </fd:datatype>
+            <fd:validation>
+                <fd:range min="10"/>
+            </fd:validation>
+        </fd:field>
+        
+        <fd:action id="action" action-command="blah"/>
+        
+    </fd:widgets>
+</fd:form>

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/formmodel/FieldTestCase.model.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/formmodel/FieldTestCase.xtest
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/formmodel/FieldTestCase.xtest?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/formmodel/FieldTestCase.xtest (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/formmodel/FieldTestCase.xtest Thu Nov  3 05:41:06 2005
@@ -0,0 +1,81 @@
+<?xml version="1.0" ?>
+<!--
+  Copyright 1999-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.
+-->
+<testcase>
+ <roles>
+
+  <role name="org.apache.cocoon.forms.datatype.DatatypeManager"
+        shorthand="forms-datatype"
+        default-class="org.apache.cocoon.forms.datatype.DefaultDatatypeManager"/>
+
+  <role name="org.apache.cocoon.forms.expression.ExpressionManager"
+    shorthand="forms-expression"
+    default-class="org.apache.cocoon.forms.expression.DefaultExpressionManager"/>
+
+  <role name="org.apache.cocoon.forms.FormManager"
+        shorthand="forms-formmanager"
+        default-class="org.apache.cocoon.forms.DefaultFormManager"/>
+
+  <role name="org.apache.cocoon.forms.CacheManager"
+        shorthand="forms-cachemanager"
+        default-class="org.apache.cocoon.forms.DefaultCacheManager"/>
+
+  <role name="org.apache.cocoon.forms.validation.WidgetValidatorBuilderSelector"
+        shorthand="forms-validators"
+        default-class="org.apache.cocoon.components.ExtendedComponentSelector"/>
+
+  <role name="org.apache.cocoon.forms.event.WidgetListenerBuilderSelector"
+        shorthand="forms-widgetlisteners"
+        default-class="org.apache.cocoon.components.ExtendedComponentSelector"/>
+</roles>
+
+ <components>
+  <forms-datatype logger="forms">
+    <datatypes>
+      <datatype name="string" src="org.apache.cocoon.forms.datatype.typeimpl.StringTypeBuilder">
+        <convertors default="dummy" plain="dummy">
+          <convertor name="dummy" src="org.apache.cocoon.forms.datatype.convertor.DummyStringConvertorBuilder"/>
+        </convertors>
+      </datatype>
+      <datatype name="integer" src="org.apache.cocoon.forms.datatype.typeimpl.IntegerTypeBuilder">
+        <convertors default="formatting" plain="plain">
+          <convertor name="plain" src="org.apache.cocoon.forms.datatype.convertor.PlainIntegerConvertorBuilder"/>
+          <convertor name="formatting" src="org.apache.cocoon.forms.datatype.convertor.FormattingIntegerConvertorBuilder"/>
+        </convertors>
+      </datatype>  
+    </datatypes>
+    <!--validation-rules>
+      <validation-rule name="range" src="org.apache.cocoon.forms.datatype.validationruleimpl.RangeValidationRuleBuilder"/>
+    </validation-rules-->
+  </forms-datatype>
+ 	
+  <forms-validators>
+    <validator name="range" class="org.apache.cocoon.forms.validation.impl.RangeValidatorBuilder"/>
+  </forms-validators>
+  
+  <forms-formmanager>
+    <widgets>
+      <widget name="form" src="org.apache.cocoon.forms.formmodel.FormDefinitionBuilder"/>
+      <widget name="field" src="org.apache.cocoon.forms.formmodel.FieldDefinitionBuilder"/>
+      <widget name="action" src="org.apache.cocoon.forms.formmodel.ActionDefinitionBuilder"/>
+    </widgets>
+  </forms-formmanager>
+  
+  <forms-expression logger="forms.expression"/>
+
+ </components>
+
+</testcase>

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/formmodel/GroupTestCase.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/formmodel/GroupTestCase.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/formmodel/GroupTestCase.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/formmodel/GroupTestCase.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,49 @@
+/*
+ * Copyright 1999-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.cocoon.forms.formmodel;
+
+import junit.framework.Assert;
+
+import org.apache.cocoon.core.container.ContainerTestCase;
+import org.apache.cocoon.forms.datatype.typeimpl.IntegerType;
+
+/**
+ * Test case for CForm's group widget and inheritance
+ *
+ * @version $Id: GroupTestCase.java 289538 2005-09-16 13:46:22Z sylvain $
+ */
+
+public class GroupTestCase extends ContainerTestCase {
+
+    /**
+     * checks for correct inheritance
+     */
+    public void testInheritance() throws Exception {
+        Form form = WidgetTestHelper.loadForm(getManager(), this, "GroupTestCase.model.xml");
+        Field field1 = (Field)((Group)form.getChild("group2")).getChild("field1");
+        Field field2 = (Field)((Group)form.getChild("group2")).getChild("field2");
+        Field field3 = (Field)((Group)form.getChild("group2")).getChild("field3");
+        Group group2 = (Group)form.getChild("group2");
+        
+        Assert.assertNotNull("Inherited field present", field1 );
+        Assert.assertNotNull("Added field present", field2 );
+        Assert.assertNotNull("Internally inherited field present", field3 );
+        
+        // check datatype
+        Assert.assertTrue("Datatype of internally inherited field", field3.getDatatype() instanceof IntegerType);
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/formmodel/GroupTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/formmodel/GroupTestCase.model.xml
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/formmodel/GroupTestCase.model.xml?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/formmodel/GroupTestCase.model.xml (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/formmodel/GroupTestCase.model.xml Thu Nov  3 05:41:06 2005
@@ -0,0 +1,41 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 2005 The Apache Software Foundation or its licensors,
+  as applicable.
+
+  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.
+-->
+<fd:form xmlns:fd="http://apache.org/cocoon/forms/1.0#definition">
+    <fd:widgets>
+        
+        <fd:group id="group1">
+            <fd:widgets>
+                <fd:field id="field1">
+                    <fd:label>Field1</fd:label>
+                    <fd:datatype base="integer"/>
+                 </fd:field>
+            </fd:widgets>
+        </fd:group>
+        
+        <fd:group id="group2" extends="group1">
+            <fd:widgets>
+                <fd:field id="field2">
+                    <fd:label>Field2</fd:label>
+                    <fd:datatype base="string"/>
+                </fd:field>
+                <fd:field id="field3" extends="field1"/>
+            </fd:widgets>
+        </fd:group>
+        
+    </fd:widgets>
+</fd:form>

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/formmodel/GroupTestCase.model.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/formmodel/GroupTestCase.xtest
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/formmodel/GroupTestCase.xtest?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/formmodel/GroupTestCase.xtest (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-ajax-block/impl/src/test/java/org/apache/cocoon/forms/formmodel/GroupTestCase.xtest Thu Nov  3 05:41:06 2005
@@ -0,0 +1,91 @@
+<?xml version="1.0" ?>
+<!--
+  Copyright 1999-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.
+-->
+<testcase>
+ <roles>
+
+  <role name="org.apache.cocoon.forms.datatype.DatatypeManager"
+        shorthand="forms-datatype"
+        default-class="org.apache.cocoon.forms.datatype.DefaultDatatypeManager"/>
+
+  <role name="org.apache.cocoon.forms.expression.ExpressionManager"
+    shorthand="forms-expression"
+    default-class="org.apache.cocoon.forms.expression.DefaultExpressionManager"/>
+
+  <role name="org.apache.cocoon.forms.FormManager"
+        shorthand="forms-formmanager"
+        default-class="org.apache.cocoon.forms.DefaultFormManager"/>
+
+  <role name="org.apache.cocoon.forms.CacheManager"
+        shorthand="forms-cachemanager"
+        default-class="org.apache.cocoon.forms.DefaultCacheManager"/>
+
+  <role name="org.apache.cocoon.forms.validation.WidgetValidatorBuilderSelector"
+        shorthand="forms-validators"
+        default-class="org.apache.cocoon.core.container.DefaultServiceSelector"/>
+
+  <role name="org.apache.cocoon.forms.event.WidgetListenerBuilderSelector"
+        shorthand="forms-widgetlisteners"
+        default-class="org.apache.cocoon.core.container.DefaultServiceSelector"/>
+</roles>
+
+ <components>
+  <forms-datatype logger="forms">
+    <datatypes>
+      <datatype name="string" src="org.apache.cocoon.forms.datatype.typeimpl.StringTypeBuilder">
+        <convertors default="dummy" plain="dummy">
+          <convertor name="dummy" src="org.apache.cocoon.forms.datatype.convertor.DummyStringConvertorBuilder"/>
+        </convertors>
+      </datatype>
+      <datatype name="integer" src="org.apache.cocoon.forms.datatype.typeimpl.IntegerTypeBuilder">
+        <convertors default="formatting" plain="plain">
+          <convertor name="plain" src="org.apache.cocoon.forms.datatype.convertor.PlainIntegerConvertorBuilder"/>
+          <convertor name="formatting" src="org.apache.cocoon.forms.datatype.convertor.FormattingIntegerConvertorBuilder"/>
+        </convertors>
+      </datatype>
+      <datatype name="float" src="org.apache.cocoon.forms.datatype.typeimpl.FloatTypeBuilder">
+        <convertors default="formatting" plain="plain">
+          <convertor name="plain" src="org.apache.cocoon.forms.datatype.convertor.PlainFloatConvertorBuilder"/>
+        </convertors>
+      </datatype>
+    </datatypes>
+    <!--validation-rules>
+      <validation-rule name="range" src="org.apache.cocoon.forms.datatype.validationruleimpl.RangeValidationRuleBuilder"/>
+    </validation-rules-->
+  </forms-datatype>
+ 	
+  <forms-validators>
+    <validator name="range" class="org.apache.cocoon.forms.validation.impl.RangeValidatorBuilder"/>
+  </forms-validators>
+  
+  <forms-formmanager>
+    <widgets>
+      <widget name="form" src="org.apache.cocoon.forms.formmodel.FormDefinitionBuilder"/>
+      <widget name="group" src="org.apache.cocoon.forms.formmodel.GroupDefinitionBuilder"/>
+      <widget name="field" src="org.apache.cocoon.forms.formmodel.FieldDefinitionBuilder"/>
+      <widget name="action" src="org.apache.cocoon.forms.formmodel.ActionDefinitionBuilder"/>
+    </widgets>
+  </forms-formmanager>
+  
+  <forms-expression logger="forms.expression"/>
+  
+  <forms-cachemanager logger="forms.cache"/>
+  
+  <forms-widgetlisteners logger="forms.listeners"/>
+
+ </components>
+
+</testcase>



Mime
View raw message