myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject svn commit: r711696 - in /myfaces/extensions/validator/trunk/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator: AbstractExValViewControllerTestCase.java baseval/BaseValTestCase.java crossval/CrossValTestCase.java
Date Wed, 05 Nov 2008 21:07:06 GMT
Author: gpetracek
Date: Wed Nov  5 13:07:05 2008
New Revision: 711696

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

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

Modified: myfaces/extensions/validator/trunk/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/AbstractExValViewControllerTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/AbstractExValViewControllerTestCase.java?rev=711696&r1=711695&r2=711696&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/AbstractExValViewControllerTestCase.java
(original)
+++ myfaces/extensions/validator/trunk/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/AbstractExValViewControllerTestCase.java
Wed Nov  5 13:07:05 2008
@@ -24,13 +24,16 @@
 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;
 import javax.faces.render.RenderKit;
 import javax.faces.render.RenderKitFactory;
+import javax.el.ValueExpression;
 
 import junit.framework.TestCase;
 
@@ -231,4 +234,16 @@
         assertTrue("Contains id '" + id + "'", output.indexOf(id) != -1);
     }
 
+    protected void createValueBinding(UIInput uiInput, String name, String expression)
+    {
+        ValueBinding valueBinding = application.createValueBinding(expression);
+        ValueExpression valueExpression = expressionFactory.createValueExpression(
+            facesContext.getELContext(), expression, Object.class);
+
+        if(uiInput != null)
+        {
+            uiInput.setValueBinding(name, valueBinding);
+            uiInput.setValueExpression(name, valueExpression);
+        }
+    }
 }

Modified: myfaces/extensions/validator/trunk/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/baseval/BaseValTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/baseval/BaseValTestCase.java?rev=711696&r1=711695&r2=711696&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/baseval/BaseValTestCase.java
(original)
+++ myfaces/extensions/validator/trunk/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/baseval/BaseValTestCase.java
Wed Nov  5 13:07:05 2008
@@ -81,10 +81,7 @@
 
     public void testNameRequiredFail() throws Exception
     {
-        inputComponent.setValueBinding("value", application
-                .createValueBinding("#{testBean.name}"));
-        inputComponent.setValueExpression("value",
-            expressionFactory.createValueExpression(facesContext.getELContext(), "#{testBean.name}",
Object.class));
+        createValueBinding(inputComponent, "value", "#{testBean.name}");
 
         inputComponent.setSubmittedValue("");
 
@@ -96,10 +93,7 @@
 
     public void testName1LenghtMaxFail() throws Exception
     {
-        inputComponent.setValueBinding("value", application
-                .createValueBinding("#{testBean.name1}"));
-        inputComponent.setValueExpression("value",
-            expressionFactory.createValueExpression(facesContext.getELContext(), "#{testBean.name1}",
Object.class));
+        createValueBinding(inputComponent, "value", "#{testBean.name1}");
 
         //decode
         inputComponent.setSubmittedValue("12345");
@@ -113,10 +107,7 @@
 
     public void testName1LenghtCorrect() throws Exception
     {
-        inputComponent.setValueBinding("value", application
-                .createValueBinding("#{testBean.name1}"));
-        inputComponent.setValueExpression("value",
-            expressionFactory.createValueExpression(facesContext.getELContext(), "#{testBean.name1}",
Object.class));
+        createValueBinding(inputComponent, "value", "#{testBean.name1}");
 
         //decode
         inputComponent.setSubmittedValue("1d3");
@@ -130,10 +121,7 @@
 
     public void testName1LenghtMinFail() throws Exception
     {
-        inputComponent.setValueBinding("value", application
-                .createValueBinding("#{testBean.name1}"));
-        inputComponent.setValueExpression("value",
-            expressionFactory.createValueExpression(facesContext.getELContext(), "#{testBean.name1}",
Object.class));
+        createValueBinding(inputComponent, "value", "#{testBean.name1}");
 
         //decode
         inputComponent.setSubmittedValue("x");
@@ -147,10 +135,7 @@
     
     public void testPatternNameFail() throws Exception
     {
-        inputComponent.setValueBinding("value", application
-                .createValueBinding("#{testBean.patternName}"));
-        inputComponent.setValueExpression("value",
-            expressionFactory.createValueExpression(facesContext.getELContext(), "#{testBean.patternName}",
Object.class));
+        createValueBinding(inputComponent, "value", "#{testBean.patternName}");
 
         //decode
         inputComponent.setSubmittedValue("Peter1");
@@ -164,10 +149,7 @@
     
     public void testPatternNameCorrect() throws Exception
     {
-        inputComponent.setValueBinding("value", application
-                .createValueBinding("#{testBean.patternName}"));
-        inputComponent.setValueExpression("value",
-            expressionFactory.createValueExpression(facesContext.getELContext(), "#{testBean.patternName}",
Object.class));
+        createValueBinding(inputComponent, "value", "#{testBean.patternName}");
 
         //decode
         inputComponent.setSubmittedValue("Peter");
@@ -181,10 +163,7 @@
 
     public void testDoubleValueFail() throws Exception
     {
-        inputComponent.setValueBinding("value", application
-                .createValueBinding("#{}"));
-        inputComponent.setValueExpression("value",
-            expressionFactory.createValueExpression(facesContext.getELContext(), "#{testBean.doubleValue1}",
Object.class));
+        createValueBinding(inputComponent, "value", "#{testBean.doubleValue1}");
 
         //decode
         inputComponent.setSubmittedValue("-301");
@@ -198,10 +177,7 @@
 
     public void testDoubleValueCorrect() throws Exception
     {
-        inputComponent.setValueBinding("value", application
-                .createValueBinding("#{testBean.doubleValue1}"));
-        inputComponent.setValueExpression("value",
-            expressionFactory.createValueExpression(facesContext.getELContext(), "#{testBean.doubleValue1}",
Object.class));
+        createValueBinding(inputComponent, "value", "#{testBean.doubleValue1}");
 
         //decode
         inputComponent.setSubmittedValue("200");

Modified: myfaces/extensions/validator/trunk/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/crossval/CrossValTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/crossval/CrossValTestCase.java?rev=711696&r1=711695&r2=711696&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/crossval/CrossValTestCase.java
(original)
+++ myfaces/extensions/validator/trunk/validation-modules/property-validation/src/test/java/org/apache/myfaces/extensions/validator/crossval/CrossValTestCase.java
Wed Nov  5 13:07:05 2008
@@ -55,8 +55,7 @@
     {
         super.setUp();
         CrossValTestBean bean = new CrossValTestBean();
-        application.createValueBinding("#{testBean}");
-        expressionFactory.createValueExpression(facesContext.getELContext(), "#{testBean}",
Object.class);
+        createValueBinding(null, "value", "#{testBean}");
         facesContext.getExternalContext().getRequestMap().put("testBean",bean);
         
         rootComponent = new UIViewRoot();
@@ -79,14 +78,8 @@
     
     public void testEqualsCorrect() throws Exception
     {
-        inputComponent1.setValueBinding("value", 
-                application.createValueBinding("#{testBean.property1}"));
-        inputComponent1.setValueExpression("value",
-            expressionFactory.createValueExpression(facesContext.getELContext(), "#{testBean.property1}",
Object.class));
-        inputComponent2.setValueBinding("value",
-                application.createValueBinding("#{testBean.property2}"));
-        inputComponent2.setValueExpression("value",
-            expressionFactory.createValueExpression(facesContext.getELContext(), "#{testBean.property2}",
Object.class));
+        createValueBinding(inputComponent1, "value", "#{testBean.property1}");
+        createValueBinding(inputComponent2, "value", "#{testBean.property2}");
 
         //decode
         inputComponent1.setSubmittedValue("1d3");
@@ -104,14 +97,8 @@
     
     public void testEqualsFail() throws Exception
     {
-        inputComponent1.setValueBinding("value", 
-                application.createValueBinding("#{testBean.property1}"));
-        inputComponent1.setValueExpression("value",
-            expressionFactory.createValueExpression(facesContext.getELContext(), "#{testBean.property1}",
Object.class));
-        inputComponent2.setValueBinding("value",
-                application.createValueBinding("#{testBean.property2}"));
-        inputComponent2.setValueExpression("value",
-            expressionFactory.createValueExpression(facesContext.getELContext(), "#{testBean.property2}",
Object.class));
+        createValueBinding(inputComponent1, "value", "#{testBean.property1}");
+        createValueBinding(inputComponent2, "value", "#{testBean.property2}");
 
         //decode
         inputComponent1.setSubmittedValue("1d3");



Mime
View raw message