myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject svn commit: r711704 - in /myfaces/extensions/validator/branches/jsf_1.1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator: ./ baseval/ crossval/
Date Wed, 05 Nov 2008 21:28:57 GMT
Author: gpetracek
Date: Wed Nov  5 13:28:56 2008
New Revision: 711704

URL: http://svn.apache.org/viewvc?rev=711704&view=rev
Log:
unified test cases

Modified:
    myfaces/extensions/validator/branches/jsf_1.1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/AbstractExValViewControllerTestCase.java
    myfaces/extensions/validator/branches/jsf_1.1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/baseval/BaseValTestCase.java
    myfaces/extensions/validator/branches/jsf_1.1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/crossval/CrossValTestCase.java

Modified: myfaces/extensions/validator/branches/jsf_1.1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/AbstractExValViewControllerTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/jsf_1.1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/AbstractExValViewControllerTestCase.java?rev=711704&r1=711703&r2=711704&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/jsf_1.1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/AbstractExValViewControllerTestCase.java
(original)
+++ myfaces/extensions/validator/branches/jsf_1.1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/AbstractExValViewControllerTestCase.java
Wed Nov  5 13:28:56 2008
@@ -24,8 +24,10 @@
 import java.util.Iterator;
 
 import javax.faces.FactoryFinder;
+import javax.faces.el.ValueBinding;
 import javax.faces.application.ApplicationFactory;
 import javax.faces.component.UIViewRoot;
+import javax.faces.component.UIInput;
 import javax.faces.context.FacesContext;
 import javax.faces.event.PhaseEvent;
 import javax.faces.event.PhaseId;
@@ -112,6 +114,8 @@
         threadContextClassLoader = Thread.currentThread().getContextClassLoader();
         Thread.currentThread().setContextClassLoader(new URLClassLoader(new URL[0], getClass().getClassLoader()));
         servletContext = new MockServletContext();
+        //for testing the fallback
+        //servletContext.addInitParameter(ExtValInformation.WEBXML_PARAM_PREFIX + ".DEACTIVATE_EL_RESOLVER",
"true");
         config = new MockServletConfig(servletContext);
         session = new MockHttpSession();
         session.setServletContext(servletContext);
@@ -219,9 +223,17 @@
         assertNotNull("ID is not null", id);
         assertTrue("Response Complete", facesContext.getResponseComplete());
         String output = writer.getWriter().toString();
-//        System.out.println("Output = '" + output + "'");
         assertNotNull("Has output", output);
         assertTrue("Contains id '" + id + "'", output.indexOf(id) != -1);
     }
 
+    protected void createValueBinding(UIInput uiInput, String name, String expression)
+    {
+        ValueBinding valueBinding = application.createValueBinding(expression);
+
+        if(uiInput != null)
+        {
+            uiInput.setValueBinding(name, valueBinding);
+        }
+    }
 }

Modified: myfaces/extensions/validator/branches/jsf_1.1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/baseval/BaseValTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/jsf_1.1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/baseval/BaseValTestCase.java?rev=711704&r1=711703&r2=711704&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/jsf_1.1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/baseval/BaseValTestCase.java
(original)
+++ myfaces/extensions/validator/branches/jsf_1.1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/baseval/BaseValTestCase.java
Wed Nov  5 13:28:56 2008
@@ -81,8 +81,7 @@
 
     public void testNameRequiredFail() throws Exception
     {
-        inputComponent.setValueBinding("value", application
-                .createValueBinding("#{testBean.name}"));
+        createValueBinding(inputComponent, "value", "#{testBean.name}");
 
         inputComponent.setSubmittedValue("");
 
@@ -94,8 +93,7 @@
 
     public void testName1LenghtMaxFail() throws Exception
     {
-        inputComponent.setValueBinding("value", application
-                .createValueBinding("#{testBean.name1}"));
+        createValueBinding(inputComponent, "value", "#{testBean.name1}");
 
         //decode
         inputComponent.setSubmittedValue("12345");
@@ -109,8 +107,7 @@
 
     public void testName1LenghtCorrect() throws Exception
     {
-        inputComponent.setValueBinding("value", application
-                .createValueBinding("#{testBean.name1}"));
+        createValueBinding(inputComponent, "value", "#{testBean.name1}");
 
         //decode
         inputComponent.setSubmittedValue("1d3");
@@ -124,8 +121,7 @@
 
     public void testName1LenghtMinFail() throws Exception
     {
-        inputComponent.setValueBinding("value", application
-                .createValueBinding("#{testBean.name1}"));
+        createValueBinding(inputComponent, "value", "#{testBean.name1}");
 
         //decode
         inputComponent.setSubmittedValue("x");
@@ -139,8 +135,7 @@
     
     public void testPatternNameFail() throws Exception
     {
-        inputComponent.setValueBinding("value", application
-                .createValueBinding("#{testBean.patternName}"));
+        createValueBinding(inputComponent, "value", "#{testBean.patternName}");
 
         //decode
         inputComponent.setSubmittedValue("Peter1");
@@ -154,8 +149,7 @@
     
     public void testPatternNameCorrect() throws Exception
     {
-        inputComponent.setValueBinding("value", application
-                .createValueBinding("#{testBean.patternName}"));
+        createValueBinding(inputComponent, "value", "#{testBean.patternName}");
 
         //decode
         inputComponent.setSubmittedValue("Peter");
@@ -169,8 +163,7 @@
 
     public void testDoubleValueFail() throws Exception
     {
-        inputComponent.setValueBinding("value", application
-                .createValueBinding("#{testBean.doubleValue1}"));
+        createValueBinding(inputComponent, "value", "#{testBean.doubleValue1}");
 
         //decode
         inputComponent.setSubmittedValue("-301");
@@ -184,8 +177,7 @@
 
     public void testDoubleValueCorrect() throws Exception
     {
-        inputComponent.setValueBinding("value", application
-                .createValueBinding("#{testBean.doubleValue1}"));
+        createValueBinding(inputComponent, "value", "#{testBean.doubleValue1}");
 
         //decode
         inputComponent.setSubmittedValue("200");

Modified: myfaces/extensions/validator/branches/jsf_1.1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/crossval/CrossValTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/jsf_1.1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/crossval/CrossValTestCase.java?rev=711704&r1=711703&r2=711704&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/jsf_1.1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/crossval/CrossValTestCase.java
(original)
+++ myfaces/extensions/validator/branches/jsf_1.1/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/crossval/CrossValTestCase.java
Wed Nov  5 13:28:56 2008
@@ -21,7 +21,6 @@
 import javax.faces.component.UIViewRoot;
 import javax.faces.component.html.HtmlForm;
 import javax.faces.component.html.HtmlInputText;
-import javax.faces.el.ValueBinding;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
@@ -56,7 +55,7 @@
     {
         super.setUp();
         CrossValTestBean bean = new CrossValTestBean();
-        ValueBinding vb = application.createValueBinding("#{testBean}");
+        createValueBinding(null, "value", "#{testBean}");
         facesContext.getExternalContext().getRequestMap().put("testBean",bean);
         
         rootComponent = new UIViewRoot();
@@ -79,11 +78,9 @@
     
     public void testEqualsCorrect() throws Exception
     {
-        inputComponent1.setValueBinding("value", 
-                application.createValueBinding("#{testBean.property1}"));
-        inputComponent2.setValueBinding("value", 
-                application.createValueBinding("#{testBean.property2}"));
-        
+        createValueBinding(inputComponent1, "value", "#{testBean.property1}");
+        createValueBinding(inputComponent2, "value", "#{testBean.property2}");
+
         //decode
         inputComponent1.setSubmittedValue("1d3");
         inputComponent2.setSubmittedValue("1d3");
@@ -92,22 +89,17 @@
         inputComponent1.validate(facesContext);
         inputComponent2.validate(facesContext);
 
-        //update model since it is necessary for crossval
-        inputComponent1.updateModel(facesContext);
-        inputComponent1.updateModel(facesContext);
-        
         processCrossValValidation();
-        
         checkMessageCount(0);
+
+        //no update model needed
     }
     
     public void testEqualsFail() throws Exception
     {
-        inputComponent1.setValueBinding("value", 
-                application.createValueBinding("#{testBean.property1}"));
-        inputComponent2.setValueBinding("value", 
-                application.createValueBinding("#{testBean.property2}"));
-        
+        createValueBinding(inputComponent1, "value", "#{testBean.property1}");
+        createValueBinding(inputComponent2, "value", "#{testBean.property2}");
+
         //decode
         inputComponent1.setSubmittedValue("1d3");
         inputComponent2.setSubmittedValue("1d4");
@@ -116,12 +108,10 @@
         inputComponent1.validate(facesContext);
         inputComponent2.validate(facesContext);
         
-        //update model since it is necessary for crossval
-        inputComponent1.updateModel(facesContext);
-        inputComponent1.updateModel(facesContext);
-        
+
         processCrossValValidation();
-        
         checkMessageCount(2);
+
+        //no update model needed
     }
 }



Mime
View raw message