incubator-bval-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From romanst...@apache.org
Subject svn commit: r929554 - in /incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303: DefaultMessageInterpolatorTest.java groups/GroupSequenceTest.java
Date Wed, 31 Mar 2010 14:46:10 GMT
Author: romanstumm
Date: Wed Mar 31 14:46:10 2010
New Revision: 929554

URL: http://svn.apache.org/viewvc?rev=929554&view=rev
Log:
fixed 3 tests (tests affected by different default locale)

Modified:
    incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/DefaultMessageInterpolatorTest.java
    incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GroupSequenceTest.java

Modified: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/DefaultMessageInterpolatorTest.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/DefaultMessageInterpolatorTest.java?rev=929554&r1=929553&r2=929554&view=diff
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/DefaultMessageInterpolatorTest.java
(original)
+++ incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/DefaultMessageInterpolatorTest.java
Wed Mar 31 14:46:10 2010
@@ -28,6 +28,8 @@ import junit.framework.TestSuite;
 import org.apache.bval.jsr303.example.Author;
 import org.apache.bval.jsr303.example.PreferredGuest;
 
+import java.util.Locale;
+
 /**
  * MessageResolverImpl Tester.
  *
@@ -37,60 +39,65 @@ import org.apache.bval.jsr303.example.Pr
  *        Copyright: Agimatec GmbH 2008
  */
 public class DefaultMessageInterpolatorTest extends TestCase {
-    DefaultMessageInterpolator interpolator = new DefaultMessageInterpolator();
+  static {     // required for tests on environments where default locale is not EN
+    Locale.setDefault(Locale.ENGLISH);
+  }
+
+  DefaultMessageInterpolator interpolator = new DefaultMessageInterpolator();
+
+  public DefaultMessageInterpolatorTest(String name) {
+    super(name);
+  }
+
+  public static Test suite() {
+    return new TestSuite(DefaultMessageInterpolatorTest.class);
+  }
+
+
+  public void testCreateResolver() {
+
+    final Validator gvalidator = getValidator();
+
+    assertTrue(!gvalidator.getConstraintsForClass(PreferredGuest.class)
+        .getConstraintsForProperty("guestCreditCardNumber")
+        .getConstraintDescriptors().isEmpty());
+
+    MessageInterpolator.Context ctx = new MessageInterpolator.Context() {
+
+      public ConstraintDescriptor<?> getConstraintDescriptor() {
+        return (ConstraintDescriptor<?>) gvalidator
+            .getConstraintsForClass(PreferredGuest.class).
+                getConstraintsForProperty("guestCreditCardNumber")
+            .getConstraintDescriptors().toArray()[0];
+      }
+
+      public Object getValidatedValue() {
+        return "12345678";
+      }
+    };
+    String msg = interpolator.interpolate("{validator.creditcard}", ctx);
+    Assert.assertEquals("credit card is not valid", msg);
+
+    ctx = new MessageInterpolator.Context() {
+      public ConstraintDescriptor<?> getConstraintDescriptor() {
+        return (ConstraintDescriptor) gvalidator
+            .getConstraintsForClass(Author.class).
+                getConstraintsForProperty("lastName")
+            .getConstraintDescriptors().toArray()[0];
+      }
+
+      public Object getValidatedValue() {
+        return "";
+      }
+    };
+
+
+    msg = interpolator.interpolate("{org.apache.bval.constraints.NotEmpty.message}", ctx);
+    Assert.assertEquals("may not be empty", msg);
+  }
+
 
-    public DefaultMessageInterpolatorTest(String name) {
-        super(name);
-    }
-
-    public static Test suite() {
-        return new TestSuite(DefaultMessageInterpolatorTest.class);
-    }
-
-    public void testCreateResolver() {
-
-        final Validator gvalidator = getValidator();
-
-        assertTrue(!gvalidator.getConstraintsForClass(PreferredGuest.class)
-              .getConstraintsForProperty("guestCreditCardNumber")
-              .getConstraintDescriptors().isEmpty());
-
-        MessageInterpolator.Context ctx = new MessageInterpolator.Context() {
-
-            public ConstraintDescriptor<?> getConstraintDescriptor() {
-                return (ConstraintDescriptor<?>) gvalidator
-                      .getConstraintsForClass(PreferredGuest.class).
-                      getConstraintsForProperty("guestCreditCardNumber")
-                      .getConstraintDescriptors().toArray()[0];
-            }
-
-            public Object getValidatedValue() {
-                return "12345678";
-            }
-        };
-        String msg = interpolator.interpolate("{validator.creditcard}", ctx);
-        Assert.assertEquals("credit card is not valid", msg);
-
-        ctx = new MessageInterpolator.Context() {
-            public ConstraintDescriptor<?> getConstraintDescriptor() {
-                return (ConstraintDescriptor) gvalidator
-                      .getConstraintsForClass(Author.class).
-                      getConstraintsForProperty("lastName")
-                      .getConstraintDescriptors().toArray()[0];
-            }
-
-            public Object getValidatedValue() {
-                return "";
-            }
-        };
-
-
-        msg = interpolator.interpolate("{org.apache.bval.constraints.NotEmpty.message}",
ctx);
-        Assert.assertEquals("may not be empty", msg);
-    }
-
-
-    private Validator getValidator() {
-        return ApacheValidatorFactory.getDefault().getValidator();
-    }
+  private Validator getValidator() {
+    return ApacheValidatorFactory.getDefault().getValidator();
+  }
 }

Modified: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GroupSequenceTest.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GroupSequenceTest.java?rev=929554&r1=929553&r2=929554&view=diff
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GroupSequenceTest.java
(original)
+++ incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GroupSequenceTest.java
Wed Mar 31 14:46:10 2010
@@ -36,6 +36,7 @@ import org.apache.bval.jsr303.util.TestU
 import org.apache.bval.model.MetaBean;
 
 import java.util.List;
+import java.util.Locale;
 import java.util.Set;
 
 /**
@@ -46,6 +47,11 @@ import java.util.Set;
  * Copyright: Agimatec GmbH
  */
 public class GroupSequenceTest extends TestCase {
+    static {   // required for tests on environments where default locale is not EN
+      Locale.setDefault(Locale.ENGLISH);
+    }
+
+  
     public void testGroupSequence1() {
         MetaBean metaBean =
               ApacheValidatorFactory.getDefault().usingContext().getMetaBeanFinder()



Mime
View raw message