incubator-bval-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From romanst...@apache.org
Subject svn commit: r929595 - in /incubator/bval/trunk: bval-core/src/main/java/org/apache/bval/integration/ bval-core/src/main/java/org/apache/bval/json/ bval-core/src/main/java/org/apache/bval/model/ bval-core/src/main/java/org/apache/bval/xml/ bval-core/src...
Date Wed, 31 Mar 2010 15:48:44 GMT
Author: romanstumm
Date: Wed Mar 31 15:48:43 2010
New Revision: 929595

URL: http://svn.apache.org/viewvc?rev=929595&view=rev
Log:
fixed tests a better way (tests affected by different default locale)
 + marked optional module JSONGenerator with TODO (split tests)
 + marked feature JAVASCRIPT_VALIDATION_FUNCTIONS deprecated (and proposed to remove it)
 + deleted ThreadBeanValidator (believe me, it never proved to be useful...)
 + some literals in tests changed from agimatec to a more general term
 + using standard JSR303 ValidatorFactory lookup in some tests instead of proprietary lookup

Added:
    incubator/bval/trunk/bval-core/src/test/java/org/apache/bval/json/
    incubator/bval/trunk/bval-core/src/test/java/org/apache/bval/json/JSONGeneratorTest.java
    incubator/bval/trunk/bval-jsr303/src/main/resources/org/apache/bval/jsr303/ValidationMessages_en.properties
    incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/constraints/CompanyEmail.java
  (contents, props changed)
      - copied, changed from r929554, incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/constraints/AgimatecEmail.java
    incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/example/CompanyAddress.java
  (contents, props changed)
      - copied, changed from r929554, incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/example/AgimatecAddress.java
Removed:
    incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/integration/
    incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/constraints/AgimatecEmail.java
    incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/example/AgimatecAddress.java
Modified:
    incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/json/JSONGenerator.java
    incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/model/Features.java
    incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/model/MetaProperty.java
    incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/xml/XMLMetaBeanFactory.java
    incubator/bval/trunk/bval-core/src/main/resources/org/apache/bval/json/bean-infos-json.ftl
    incubator/bval/trunk/bval-core/src/test/java/org/apache/bval/MetaBeanManagerTest.java
    incubator/bval/trunk/bval-core/src/test/java/org/apache/bval/xml/XMLMetaBeanInfosTest.java
    incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/jsr303/ApacheValidatorFactory.java
    incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/ComposedConstraintsTest.java
    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/ValidationTest.java
    incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/groups/GroupSequenceTest.java

Modified: incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/json/JSONGenerator.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/json/JSONGenerator.java?rev=929595&r1=929594&r2=929595&view=diff
==============================================================================
--- incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/json/JSONGenerator.java (original)
+++ incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/json/JSONGenerator.java Wed
Mar 31 15:48:43 2010
@@ -19,14 +19,13 @@ package org.apache.bval.json;
 import freemarker.template.Configuration;
 import freemarker.template.Template;
 import freemarker.template.TemplateException;
+import org.apache.bval.model.MetaBean;
 
 import java.io.IOException;
 import java.io.StringWriter;
 import java.io.Writer;
 import java.util.*;
 
-import org.apache.bval.model.MetaBean;
-
 /**
  * Description: Generate a JSON String for a collection of {@link MetaBean}s.
  * This implementation uses a freemarker template to generate the output.<br/>
@@ -35,6 +34,7 @@ import org.apache.bval.model.MetaBean;
  * Time: 17:14:12 <br/>
  * Copyright: Agimatec GmbH 2008
  */
+// TODO RSt - move. this is an optional module: move freemarker dependency and template "bean-infos-json.ftl"
with it.
 public class JSONGenerator {
     private final Template template;
 

Modified: incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/model/Features.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/model/Features.java?rev=929595&r1=929594&r2=929595&view=diff
==============================================================================
--- incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/model/Features.java (original)
+++ incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/model/Features.java Wed Mar
31 15:48:43 2010
@@ -112,6 +112,7 @@ public interface Features {
         String REF_CASCADE = "refCascade";
 
         /** INFO: an array with the string names of custom java script validation functions
*/
+        @Deprecated // TODO RSt - I suggest to remove this and all related code
         String JAVASCRIPT_VALIDATION_FUNCTIONS = "jsFunctions";
     }
 }

Modified: incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/model/MetaProperty.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/model/MetaProperty.java?rev=929595&r1=929594&r2=929595&view=diff
==============================================================================
--- incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/model/MetaProperty.java (original)
+++ incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/model/MetaProperty.java Wed
Mar 31 15:48:43 2010
@@ -89,6 +89,7 @@ public class MetaProperty extends Featur
         putFeature(MANDATORY, Boolean.valueOf(mandatory));
     }
 
+    @Deprecated // remove this method?
     public String[] getJavaScriptValidations() {
         return getFeature(JAVASCRIPT_VALIDATION_FUNCTIONS);
     }

Modified: incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/xml/XMLMetaBeanFactory.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/xml/XMLMetaBeanFactory.java?rev=929595&r1=929594&r2=929595&view=diff
==============================================================================
--- incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/xml/XMLMetaBeanFactory.java
(original)
+++ incubator/bval/trunk/bval-core/src/main/java/org/apache/bval/xml/XMLMetaBeanFactory.java
Wed Mar 31 15:48:43 2010
@@ -16,9 +16,6 @@
  */
 package org.apache.bval.xml;
 
-import static org.apache.bval.model.Features.Property.JAVASCRIPT_VALIDATION_FUNCTIONS;
-
-
 import org.apache.bval.MetaBeanFactory;
 import org.apache.bval.model.FeaturesCapable;
 import org.apache.bval.model.MetaBean;
@@ -30,6 +27,8 @@ import org.apache.commons.logging.LogFac
 import java.io.IOException;
 import java.util.*;
 
+import static org.apache.bval.model.Features.Property.JAVASCRIPT_VALIDATION_FUNCTIONS;
+
 /**
  * Description: Create or enrich MetaBeans from agimatec beanInfos xml<br/>
  * User: roman <br/>
@@ -130,12 +129,13 @@ public class XMLMetaBeanFactory implemen
                                      XMLResult result, boolean addStandard)
           throws Exception {
         if (xmlProp.getValidators() != null) {
+            // obsolete code? remove from here --->
             String[] func = prop.getFeature(JAVASCRIPT_VALIDATION_FUNCTIONS);
             List<String> jsValidators = new ArrayList<String>(
                   xmlProp.getValidators().size() + (func == null ? 0 : func.length));
             if (func != null && func.length > 0) {
                 jsValidators.addAll(Arrays.asList(func));
-            }
+            }  // <--- to here
             boolean useStandard = prop instanceof MetaProperty;
             for (XMLMetaValidatorReference valRef : xmlProp.getValidators()) {
                 if (standardValidation != null &&

Modified: incubator/bval/trunk/bval-core/src/main/resources/org/apache/bval/json/bean-infos-json.ftl
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-core/src/main/resources/org/apache/bval/json/bean-infos-json.ftl?rev=929595&r1=929594&r2=929595&view=diff
==============================================================================
--- incubator/bval/trunk/bval-core/src/main/resources/org/apache/bval/json/bean-infos-json.ftl
(original)
+++ incubator/bval/trunk/bval-core/src/main/resources/org/apache/bval/json/bean-infos-json.ftl
Wed Mar 31 15:48:43 2010
@@ -1,4 +1,4 @@
-agimatec.namespace("agimatec.metadata");
+bval.namespace("bval.metadata");
 
 (function(){
 <#assign var = 0>
@@ -56,7 +56,7 @@ var metaBean${var} = {
     property.metaBean?? && varrefs[property.metaBean.id]??>
 metaBean${var}.properties.${property.name}.metaBean = metaBean${varrefs[property.metaBean.id]};
 </#if></#list><#assign var = var + 1></#list><#assign var = 0>
-agimatec.metadata.metaBeans = {
+bval.metadata.metaBeans = {
 <#list metaBeans as metaBean>
        "${metaBean.id}" : metaBean${var}<#if metaBean_has_next>,</#if>
        <#assign var = var + 1>

Modified: incubator/bval/trunk/bval-core/src/test/java/org/apache/bval/MetaBeanManagerTest.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-core/src/test/java/org/apache/bval/MetaBeanManagerTest.java?rev=929595&r1=929594&r2=929595&view=diff
==============================================================================
--- incubator/bval/trunk/bval-core/src/test/java/org/apache/bval/MetaBeanManagerTest.java
(original)
+++ incubator/bval/trunk/bval-core/src/test/java/org/apache/bval/MetaBeanManagerTest.java
Wed Mar 31 15:48:43 2010
@@ -16,27 +16,15 @@
  */
 package org.apache.bval;
 
-import freemarker.template.TemplateException;
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.bval.MetaBeanFinder;
-import org.apache.bval.MetaBeanManager;
-import org.apache.bval.example.BusinessEnum;
 import org.apache.bval.example.BusinessObject;
-import org.apache.bval.example.BusinessObjectAddress;
-import org.apache.bval.json.JSONGenerator;
-import org.apache.bval.model.DynaTypeEnum;
 import org.apache.bval.model.MetaBean;
-import org.apache.bval.model.MetaProperty;
 import org.apache.bval.xml.XMLMetaBeanURLLoader;
 
+import java.util.Map;
+
 /**
  * MetaBeanManager Tester.
  *
@@ -90,29 +78,7 @@ public class MetaBeanManagerTest extends
         assertTrue(info.getProperty("email").getJavaScriptValidations().length > 0);
     }
 
-    public void testBeanInfosCustomPatchGenerated()
-          throws IOException, TemplateException {
-        MetaBean mbean = mbm.findForClass(BusinessObject.class);
-        MetaProperty mprop = mbean.getProperty("lastName");
-        assertTrue(mprop.isMandatory());
 
-        mbm.getCache().removeFromCache(mbean);
-        mbm.getBuilder().addLoader(new XMLMetaBeanURLLoader(
-              BusinessObject.class.getResource("test-beanInfos-custom.xml")));
-        mbean = mbm.findForClass(BusinessObject.class);
-        mprop = mbean.getProperty("lastName");
-        assertTrue(!mprop.isMandatory());
-
-        JSONGenerator converter = new JSONGenerator();
-
-        List<MetaBean> metaBeans = new ArrayList(2);
-        metaBeans.add(mbean);
-        MetaBean mbean2 = mbm.findForId("UnknownObject");
-        metaBeans.add(mbean2);
-        String json = converter.toJSON(metaBeans);
-        assertNotNull(json);
-        System.out.println(json);
-    }
 
     public void testFindAll() {
         Map<String, MetaBean> all = mbm.findAll();
@@ -129,39 +95,7 @@ public class MetaBeanManagerTest extends
               .getProperty("owner").getMetaBean());
     }
 
-    public void testJSON() throws Exception {
-        MetaBean info = mbm.findForClass(BusinessObject.class);
-        MetaBean info2 = info.getProperty("address").getMetaBean();
-
-        // empty default bean without xml backup
-        MetaBean info3 = mbm.findForClass(BusinessObjectAddress.class);
-        JSONGenerator converter = new JSONGenerator();
-
-        List<MetaBean> metaBeans = new ArrayList(2);
-        metaBeans.add(info);
-        metaBeans.add(info2);
-        metaBeans.add(info3);
-        String json = converter.toJSON(metaBeans);
-        assertNotNull(json);
-        System.out.println(json);
-    }
-
-    public void testJSON_dynaTypeEnum() throws Exception {
-        MetaBean info = mbm.findForClass(BusinessObject.class);
-        MetaProperty choice = info.getProperty("choice");
-        choice.setType(new DynaTypeEnum(BusinessEnum.class, "CUSTOM_1", "CUSTOM_2"));
-
-        JSONGenerator converter = new JSONGenerator();
-
-        List<MetaBean> metaBeans = new ArrayList(1);
-        metaBeans.add(info);
-        String json = converter.toJSON(metaBeans);
-        assertNotNull(json);
-//        System.out.println(json);
-        assertTrue(json.indexOf("CUSTOM_1")>0);
-        assertTrue(json.indexOf("CUSTOM_2")>0);
-        assertTrue(json.indexOf("VALUE1")<0);
-    }
+
 
     public static Test suite() {
         return new TestSuite(MetaBeanManagerTest.class);

Added: incubator/bval/trunk/bval-core/src/test/java/org/apache/bval/json/JSONGeneratorTest.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-core/src/test/java/org/apache/bval/json/JSONGeneratorTest.java?rev=929595&view=auto
==============================================================================
--- incubator/bval/trunk/bval-core/src/test/java/org/apache/bval/json/JSONGeneratorTest.java
(added)
+++ incubator/bval/trunk/bval-core/src/test/java/org/apache/bval/json/JSONGeneratorTest.java
Wed Mar 31 15:48:43 2010
@@ -0,0 +1,111 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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.bval.json;
+
+import junit.framework.TestCase;
+import org.apache.bval.MetaBeanManager;
+import org.apache.bval.example.BusinessEnum;
+import org.apache.bval.example.BusinessObject;
+import org.apache.bval.example.BusinessObjectAddress;
+import org.apache.bval.model.DynaTypeEnum;
+import org.apache.bval.model.MetaBean;
+import org.apache.bval.model.MetaProperty;
+import org.apache.bval.xml.XMLMetaBeanURLLoader;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Description: <br>
+ * User: roman.stumm<br>
+ * Date: 31.03.2010<br>
+ * Time: 17:00:17<br>
+ * viaboxx GmbH, 2010
+ */
+// TODO RSt - move. this tests an optional module
+public class JSONGeneratorTest extends TestCase {
+  private MetaBeanManager mbm;
+
+  public JSONGeneratorTest(String name) {
+    super(name);
+  }
+
+  public void setUp() throws Exception {
+    super.setUp();
+    mbm = new MetaBeanManager();
+    mbm.getBuilder().addLoader(new XMLMetaBeanURLLoader(
+        BusinessObject.class.getResource("test-beanInfos.xml")));
+  }
+
+  public void testBeanInfosCustomPatchGenerated()
+      throws Exception {
+    MetaBean mbean = mbm.findForClass(BusinessObject.class);
+    MetaProperty mprop = mbean.getProperty("lastName");
+    assertTrue(mprop.isMandatory());
+
+    mbm.getCache().removeFromCache(mbean);
+    mbm.getBuilder().addLoader(new XMLMetaBeanURLLoader(
+        BusinessObject.class.getResource("test-beanInfos-custom.xml")));
+    mbean = mbm.findForClass(BusinessObject.class);
+    mprop = mbean.getProperty("lastName");
+    assertTrue(!mprop.isMandatory());
+
+    JSONGenerator converter = new JSONGenerator();
+
+    List<MetaBean> metaBeans = new ArrayList(2);
+    metaBeans.add(mbean);
+    MetaBean mbean2 = mbm.findForId("UnknownObject");
+    metaBeans.add(mbean2);
+    String json = converter.toJSON(metaBeans);
+    assertNotNull(json);
+    //System.out.println(json);
+  }
+
+  public void testJSON() throws Exception {
+    MetaBean info = mbm.findForClass(BusinessObject.class);
+    MetaBean info2 = info.getProperty("address").getMetaBean();
+
+    // empty default bean without xml backup
+    MetaBean info3 = mbm.findForClass(BusinessObjectAddress.class);
+    JSONGenerator converter = new JSONGenerator();
+
+    List<MetaBean> metaBeans = new ArrayList(2);
+    metaBeans.add(info);
+    metaBeans.add(info2);
+    metaBeans.add(info3);
+    String json = converter.toJSON(metaBeans);
+    assertNotNull(json);
+    //System.out.println(json);
+  }
+
+  public void testJSON_dynaTypeEnum() throws Exception {
+    MetaBean info = mbm.findForClass(BusinessObject.class);
+    MetaProperty choice = info.getProperty("choice");
+    choice.setType(new DynaTypeEnum(BusinessEnum.class, "CUSTOM_1", "CUSTOM_2"));
+
+    JSONGenerator converter = new JSONGenerator();
+
+    List<MetaBean> metaBeans = new ArrayList(1);
+    metaBeans.add(info);
+    String json = converter.toJSON(metaBeans);
+    assertNotNull(json);
+//        System.out.println(json);
+    assertTrue(json.indexOf("CUSTOM_1") > 0);
+    assertTrue(json.indexOf("CUSTOM_2") > 0);
+    assertTrue(json.indexOf("VALUE1") < 0);
+  }
+}

Modified: incubator/bval/trunk/bval-core/src/test/java/org/apache/bval/xml/XMLMetaBeanInfosTest.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-core/src/test/java/org/apache/bval/xml/XMLMetaBeanInfosTest.java?rev=929595&r1=929594&r2=929595&view=diff
==============================================================================
--- incubator/bval/trunk/bval-core/src/test/java/org/apache/bval/xml/XMLMetaBeanInfosTest.java
(original)
+++ incubator/bval/trunk/bval-core/src/test/java/org/apache/bval/xml/XMLMetaBeanInfosTest.java
Wed Mar 31 15:48:43 2010
@@ -19,21 +19,13 @@ package org.apache.bval.xml;
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
+import org.apache.bval.example.BusinessObject;
+import org.apache.bval.example.BusinessObjectAddress;
 
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.bval.example.BusinessObject;
-import org.apache.bval.example.BusinessObjectAddress;
-import org.apache.bval.xml.XMLMapper;
-import org.apache.bval.xml.XMLMetaBean;
-import org.apache.bval.xml.XMLMetaBeanInfos;
-import org.apache.bval.xml.XMLMetaBeanReference;
-import org.apache.bval.xml.XMLMetaProperty;
-import org.apache.bval.xml.XMLMetaValidator;
-import org.apache.bval.xml.XMLMetaValue;
-
 /**
  * XMLMetaBean Tester.
  *
@@ -158,7 +150,7 @@ public class XMLMetaBeanInfosTest extend
 
     public void testMaxValueParsing() {
         String xml = "\n" +
-              "<beanInfos>  <bean id=\"com.agimatec.connecta.model.Profile\">\n"
+
+              "<beanInfos>  <bean id=\"org.apache.bval.test.model.Profile\">\n"
+
               "    <property name=\"activationDay\" minValue=\"1\" maxValue=\"31\"/>\n"
+
               "    <property name=\"activationMonth\" minValue=\"1\" maxValue=\"12\"/>\n"
+
               "  </bean></beanInfos>";

Modified: incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/jsr303/ApacheValidatorFactory.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/jsr303/ApacheValidatorFactory.java?rev=929595&r1=929594&r2=929595&view=diff
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/jsr303/ApacheValidatorFactory.java
(original)
+++ incubator/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/jsr303/ApacheValidatorFactory.java
Wed Mar 31 15:48:43 2010
@@ -71,7 +71,11 @@ public class ApacheValidatorFactory impl
         return DEFAULT_FACTORY;
     }
 
-    public ApacheValidatorFactory() {
+    public static void setDefault(ApacheValidatorFactory aDefaultFactory) {
+     DEFAULT_FACTORY = aDefaultFactory;
+    }
+
+  public ApacheValidatorFactory() {
         properties = new HashMap<String, String>();
         defaultSequences = new HashMap();
         validAccesses = new HashMap();

Added: incubator/bval/trunk/bval-jsr303/src/main/resources/org/apache/bval/jsr303/ValidationMessages_en.properties
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/main/resources/org/apache/bval/jsr303/ValidationMessages_en.properties?rev=929595&view=auto
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/main/resources/org/apache/bval/jsr303/ValidationMessages_en.properties
(added)
+++ incubator/bval/trunk/bval-jsr303/src/main/resources/org/apache/bval/jsr303/ValidationMessages_en.properties
Wed Mar 31 15:48:43 2010
@@ -0,0 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+
+# intentionally empty, because english messages are located in the default bundle.
+# this file ensures, that a lookup with an english locale uses the default bundle and not
the
+# bundle of the default locale, which is platform specific
\ No newline at end of file

Copied: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/constraints/CompanyEmail.java
(from r929554, incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/constraints/AgimatecEmail.java)
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/constraints/CompanyEmail.java?p2=incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/constraints/CompanyEmail.java&p1=incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/constraints/AgimatecEmail.java&r1=929554&r2=929595&rev=929595&view=diff
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/constraints/AgimatecEmail.java
(original)
+++ incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/constraints/CompanyEmail.java
Wed Mar 31 15:48:43 2010
@@ -23,16 +23,17 @@ import javax.validation.OverridesAttribu
 import javax.validation.Payload;
 import javax.validation.constraints.Pattern;
 import java.lang.annotation.Documented;
-import static java.lang.annotation.ElementType.*;
 import java.lang.annotation.Retention;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
 import java.lang.annotation.Target;
 
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
 @Pattern.List({
     // email
     @Pattern(regexp = "[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}"),
     // agimatec
-    @Pattern(regexp = ".*?AGIMATEC.*?")
+    @Pattern(regexp = ".*?COMPANY.*?")
 })
 /**
  * test a constraint WITHOUT an own ConstraintValidator implementation.
@@ -44,14 +45,14 @@ import java.lang.annotation.Target;
 @Documented
 @Target({ANNOTATION_TYPE, METHOD, FIELD, CONSTRUCTOR, PARAMETER})
 @Retention(RUNTIME)
-public @interface AgimatecEmail {
-    String message() default "Not an agimatec email";
+public @interface CompanyEmail {
+    String message() default "Not an email of COMPANY";
 
     @OverridesAttribute(constraint = Pattern.class, name = "message",
           constraintIndex = 0) String emailMessage() default "Not an email";
 
     @OverridesAttribute(constraint = Pattern.class, name = "message",
-          constraintIndex = 1) String agimatecMessage() default "Not Agimatec";
+          constraintIndex = 1) String agimatecMessage() default "Not COMPANY";
 
     Class<?>[] groups() default {};
 
@@ -61,6 +62,6 @@ public @interface AgimatecEmail {
     @Retention(RUNTIME)
     @Documented
           @interface List {
-        AgimatecEmail[] value();
+        CompanyEmail[] value();
     }
 }
\ No newline at end of file

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/constraints/CompanyEmail.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/constraints/CompanyEmail.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/constraints/CompanyEmail.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/ComposedConstraintsTest.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/ComposedConstraintsTest.java?rev=929595&r1=929594&r2=929595&view=diff
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/ComposedConstraintsTest.java
(original)
+++ incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/ComposedConstraintsTest.java
Wed Mar 31 15:48:43 2010
@@ -18,7 +18,11 @@
  */
 package org.apache.bval.jsr303;
 
-import java.util.Set;
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import org.apache.bval.jsr303.example.CompanyAddress;
+import org.apache.bval.jsr303.example.FrenchAddress;
+import org.apache.bval.jsr303.util.TestUtils;
 
 import javax.validation.ConstraintViolation;
 import javax.validation.Validation;
@@ -27,13 +31,7 @@ import javax.validation.ValidatorFactory
 import javax.validation.constraints.Size;
 import javax.validation.metadata.ConstraintDescriptor;
 import javax.validation.metadata.ElementDescriptor;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.apache.bval.jsr303.example.AgimatecAddress;
-import org.apache.bval.jsr303.example.FrenchAddress;
-import org.apache.bval.jsr303.util.TestUtils;
+import java.util.Set;
 
 /**
  * Description: <br/>
@@ -95,19 +93,19 @@ public class ComposedConstraintsTest ext
     }
 
     public void testOverridesAttributeConstraintIndex() {
-        AgimatecAddress adr = new AgimatecAddress("invalid-string");
+        CompanyAddress adr = new CompanyAddress("invalid-string");
         Validator val = factory.getValidator();
-        Set<ConstraintViolation<AgimatecAddress>> findings = val.validate(adr);
+        Set<ConstraintViolation<CompanyAddress>> findings = val.validate(adr);
         assertEquals(2, findings.size()); // without @ReportAsSingleConstraintViolation
-        assertNotNull(TestUtils.getViolationWithMessage(findings, "Not Agimatec"));
+        assertNotNull(TestUtils.getViolationWithMessage(findings, "Not COMPANY"));
         assertNotNull(TestUtils.getViolationWithMessage(findings, "Not an email"));
 
-        adr =  new AgimatecAddress("ROMAN@GMX.DE");
+        adr =  new CompanyAddress("JOHN_DO@WEB.DE");
         findings = val.validate(adr);
         assertEquals(1, findings.size());
-        assertNotNull(TestUtils.getViolationWithMessage(findings, "Not Agimatec"));
+        assertNotNull(TestUtils.getViolationWithMessage(findings, "Not COMPANY"));
 
-        adr =  new AgimatecAddress("ROMAN@AGIMATEC.DE");
+        adr =  new CompanyAddress("JOHN_DO@COMPANY.DE");
         findings = val.validate(adr);
         Assert.assertTrue(findings.isEmpty());
     }

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=929595&r1=929594&r2=929595&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 15:48:43 2010
@@ -16,18 +16,16 @@
  */
 package org.apache.bval.jsr303;
 
-import javax.validation.MessageInterpolator;
-import javax.validation.Validator;
-import javax.validation.metadata.ConstraintDescriptor;
-
 import junit.framework.Assert;
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
-
 import org.apache.bval.jsr303.example.Author;
 import org.apache.bval.jsr303.example.PreferredGuest;
 
+import javax.validation.MessageInterpolator;
+import javax.validation.Validator;
+import javax.validation.metadata.ConstraintDescriptor;
 import java.util.Locale;
 
 /**
@@ -39,11 +37,8 @@ import java.util.Locale;
  *        Copyright: Agimatec GmbH 2008
  */
 public class DefaultMessageInterpolatorTest extends TestCase {
-  static {     // required for tests on environments where default locale is not EN
-    Locale.setDefault(Locale.ENGLISH);
-  }
 
-  DefaultMessageInterpolator interpolator = new DefaultMessageInterpolator();
+  private DefaultMessageInterpolator interpolator;
 
   public DefaultMessageInterpolatorTest(String name) {
     super(name);
@@ -53,6 +48,12 @@ public class DefaultMessageInterpolatorT
     return new TestSuite(DefaultMessageInterpolatorTest.class);
   }
 
+  @Override
+  protected void setUp() throws Exception {
+    super.setUp();    // call super!
+    interpolator = new DefaultMessageInterpolator();
+    interpolator.setLocale(Locale.ENGLISH);
+  }
 
   public void testCreateResolver() {
 

Modified: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/ValidationTest.java
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/ValidationTest.java?rev=929595&r1=929594&r2=929595&view=diff
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/ValidationTest.java
(original)
+++ incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/ValidationTest.java
Wed Mar 31 15:48:43 2010
@@ -18,35 +18,27 @@
  */
 package org.apache.bval.jsr303;
 
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.Set;
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import org.apache.bval.constraints.NotNullValidator;
+import org.apache.bval.jsr303.example.*;
+import org.apache.bval.jsr303.util.TestUtils;
 
 import javax.validation.ConstraintViolation;
+import javax.validation.Validation;
 import javax.validation.Validator;
+import javax.validation.ValidatorFactory;
 import javax.validation.constraints.NotNull;
 import javax.validation.constraints.Size;
 import javax.validation.groups.Default;
 import javax.validation.metadata.BeanDescriptor;
 import javax.validation.metadata.ConstraintDescriptor;
 import javax.validation.metadata.PropertyDescriptor;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.apache.bval.constraints.NotNullValidator;
-import org.apache.bval.jsr303.example.AccessTestBusinessObject;
-import org.apache.bval.jsr303.example.AccessTestBusinessObjectSub;
-import org.apache.bval.jsr303.example.Address;
-import org.apache.bval.jsr303.example.Author;
-import org.apache.bval.jsr303.example.Book;
-import org.apache.bval.jsr303.example.BusinessAddress;
-import org.apache.bval.jsr303.example.Country;
-import org.apache.bval.jsr303.example.First;
-import org.apache.bval.jsr303.example.Last;
-import org.apache.bval.jsr303.example.RecursiveFoo;
-import org.apache.bval.jsr303.util.TestUtils;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Set;
 
 /**
  * Description: <br/>
@@ -56,6 +48,17 @@ import org.apache.bval.jsr303.util.TestU
  * Copyright: Agimatec GmbH 2008
  */
 public class ValidationTest extends TestCase {
+    static ValidatorFactory factory;
+
+    static {
+        factory = Validation.buildDefaultValidatorFactory();
+        ((DefaultMessageInterpolator)factory.getMessageInterpolator()).setLocale(Locale.ENGLISH);
+    }
+
+    private Validator getValidator() {
+        return factory.getValidator();
+    }
+
     public void testAccessStrategies_field_method() {
         AccessTestBusinessObject o1 = new AccessTestBusinessObject("1");
         AccessTestBusinessObjectSub o2 = new AccessTestBusinessObjectSub("3");
@@ -160,7 +163,7 @@ public class ValidationTest extends Test
 
         adr.setCity("Berlin");
         adr.setZipCode("12345");
-        adr.setCompany("agimatec GmbH");
+        adr.setCompany("apache");
         found = v.validate(a, Default.class, First.class, Last.class);
         Assert.assertEquals(1, found.size());
         ConstraintViolation ic = (ConstraintViolation) found.iterator().next();
@@ -227,10 +230,6 @@ public class ValidationTest extends Test
         // check that no nullpointer exception gets thrown
     }
 
-    private Validator getValidator() {
-        return ApacheValidatorFactory.getDefault().getValidator();
-    }
-
     public void testGroups() {
         Validator validator = getValidator();
         Author author = new Author();
@@ -245,8 +244,8 @@ public class ValidationTest extends Test
         //assuming an english locale, the interpolated message is returned
         for (ConstraintViolation constraintViolation : constraintViolations) {
             if (constraintViolation.getRootBean().getClass() == Book.class) {
-                Assert.assertTrue(
-                      "may not be empty".equals(constraintViolation.getMessage()));
+                Assert.assertEquals(
+                      "may not be empty", constraintViolation.getMessage());
                 Assert.assertTrue(book == constraintViolation.getRootBean());
 
                 //the offending property

Copied: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/example/CompanyAddress.java
(from r929554, incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/example/AgimatecAddress.java)
URL: http://svn.apache.org/viewvc/incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/example/CompanyAddress.java?p2=incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/example/CompanyAddress.java&p1=incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/example/AgimatecAddress.java&r1=929554&r2=929595&rev=929595&view=diff
==============================================================================
--- incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/example/AgimatecAddress.java
(original)
+++ incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/example/CompanyAddress.java
Wed Mar 31 15:48:43 2010
@@ -18,7 +18,7 @@
  */
 package org.apache.bval.jsr303.example;
 
-import org.apache.bval.constraints.AgimatecEmail;
+import org.apache.bval.constraints.CompanyEmail;
 
 /**
  * Description: <br/>
@@ -27,14 +27,14 @@ import org.apache.bval.constraints.Agima
  * Time: 11:58:37 <br/>
  * Copyright: Agimatec GmbH
  */
-public class AgimatecAddress {
-    @AgimatecEmail
+public class CompanyAddress {
+    @CompanyEmail
     private String email;
 
-    public AgimatecAddress() {
+    public CompanyAddress() {
     }
 
-    public AgimatecAddress(String email) {
+    public CompanyAddress(String email) {
         this.email = email;
     }
 

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/example/CompanyAddress.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/example/CompanyAddress.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/bval/trunk/bval-jsr303/src/test/java/org/apache/bval/jsr303/example/CompanyAddress.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

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=929595&r1=929594&r2=929595&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 15:48:43 2010
@@ -18,23 +18,19 @@
  */
 package org.apache.bval.jsr303.groups;
 
-import org.apache.bval.jsr303.ApacheValidatorFactory;
 import junit.framework.Assert;
 import junit.framework.TestCase;
-
-import javax.validation.ConstraintViolation;
-import javax.validation.Validator;
-
+import org.apache.bval.jsr303.ApacheValidatorFactory;
+import org.apache.bval.jsr303.DefaultMessageInterpolator;
 import org.apache.bval.jsr303.Jsr303Features;
-import org.apache.bval.jsr303.example.Author;
-import org.apache.bval.jsr303.example.Book;
-import org.apache.bval.jsr303.example.First;
-import org.apache.bval.jsr303.example.Last;
-import org.apache.bval.jsr303.example.Second;
-import org.apache.bval.jsr303.groups.Group;
+import org.apache.bval.jsr303.example.*;
 import org.apache.bval.jsr303.util.TestUtils;
 import org.apache.bval.model.MetaBean;
 
+import javax.validation.ConstraintViolation;
+import javax.validation.Validation;
+import javax.validation.Validator;
+import javax.validation.ValidatorFactory;
 import java.util.List;
 import java.util.Locale;
 import java.util.Set;
@@ -47,11 +43,19 @@ 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);
+
+    static ValidatorFactory factory;
+
+    static {
+        factory = Validation.buildDefaultValidatorFactory();
+        ((DefaultMessageInterpolator)factory.getMessageInterpolator()).setLocale(Locale.ENGLISH);
     }
 
-  
+    private Validator getValidator() {
+        return factory.getValidator();
+    }
+
+
     public void testGroupSequence1() {
         MetaBean metaBean =
               ApacheValidatorFactory.getDefault().usingContext().getMetaBeanFinder()
@@ -144,7 +148,7 @@ public class GroupSequenceTest extends T
         assertEquals(author.getCompany(), constraintViolation.getInvalidValue());
         assertEquals("author.company", constraintViolation.getPropertyPath().toString());
 
-        author.setCompany("agimatec");
+        author.setCompany("apache");
 
         constraintViolations = validator.validate(book, First.class, Second.class, Last.class);
         assertEquals(0, constraintViolations.size());
@@ -181,7 +185,4 @@ public class GroupSequenceTest extends T
         assertEquals(1, constraintViolations.size());
     }
 
-    public Validator getValidator() {
-        return ApacheValidatorFactory.getDefault().getValidator();
-    }
 }



Mime
View raw message