struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject [08/17] struts git commit: Renames class to match its purpose
Date Mon, 13 Mar 2017 17:46:17 GMT
Renames class to match its purpose


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/c063704d
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/c063704d
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/c063704d

Branch: refs/heads/master
Commit: c063704d279b6dc7d349c232f17b3b2aebe19b99
Parents: 3dc8480
Author: Lukasz Lenart <lukaszlenart@apache.org>
Authored: Fri Mar 10 09:21:24 2017 +0100
Committer: Lukasz Lenart <lukaszlenart@apache.org>
Committed: Fri Mar 10 09:21:24 2017 +0100

----------------------------------------------------------------------
 .../xwork2/validator/DummyValidatorContext.java | 145 +++++++++++++++++++
 .../validator/GenericValidatorContext.java      | 145 -------------------
 .../validators/DateRangeFieldValidatorTest.java |   8 +-
 .../validators/IntRangeFieldValidatorTest.java  |   8 +-
 .../validators/LongRangeFieldValidatorTest.java |   8 +-
 .../validators/RequiredStringValidatorTest.java |   6 +-
 .../ShortRangeFieldValidatorTest.java           |   8 +-
 7 files changed, 164 insertions(+), 164 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/c063704d/core/src/test/java/com/opensymphony/xwork2/validator/DummyValidatorContext.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/com/opensymphony/xwork2/validator/DummyValidatorContext.java
b/core/src/test/java/com/opensymphony/xwork2/validator/DummyValidatorContext.java
new file mode 100644
index 0000000..9d3400f
--- /dev/null
+++ b/core/src/test/java/com/opensymphony/xwork2/validator/DummyValidatorContext.java
@@ -0,0 +1,145 @@
+/*
+ * Copyright 2002-2003,2009 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 com.opensymphony.xwork2.validator;
+
+import com.opensymphony.xwork2.TextProviderFactory;
+
+import java.util.*;
+
+
+/**
+ * Dummy validator context to use to capture error messages.
+ *
+ * @author Mark Woon
+ * @author Matthew Payne
+ */
+public class DummyValidatorContext extends DelegatingValidatorContext {
+
+    private Collection<String> actionErrors;
+    private Collection<String> actionMessages;
+    private Map<String, List<String>> fieldErrors;
+
+
+    public DummyValidatorContext(Object object, TextProviderFactory tpf) {
+        super(object, tpf);
+    }
+
+
+    @Override
+    public synchronized void setActionErrors(Collection<String> errorMessages) {
+        this.actionErrors = errorMessages;
+    }
+
+    @Override
+    public synchronized Collection<String> getActionErrors() {
+        return new ArrayList<>(internalGetActionErrors());
+    }
+
+    @Override
+    public synchronized void setActionMessages(Collection<String> messages) {
+        this.actionMessages = messages;
+    }
+
+    @Override
+    public synchronized Collection<String> getActionMessages() {
+        return new ArrayList<String>(internalGetActionMessages());
+    }
+
+    @Override
+    public synchronized void setFieldErrors(Map<String, List<String>> errorMap)
{
+        this.fieldErrors = errorMap;
+    }
+
+    /**
+     * Get the field specific errors.
+     *
+     * @return an unmodifiable Map with errors mapped from fieldname (String) to Collection
of String error messages
+     */
+    @Override
+    public synchronized Map<String, List<String>> getFieldErrors() {
+        return new HashMap<String, List<String>>(internalGetFieldErrors());
+    }
+
+    @Override
+    public synchronized void addActionError(String anErrorMessage) {
+        internalGetActionErrors().add(anErrorMessage);
+    }
+
+    /**
+     * Add an Action level message to this Action
+     */
+    @Override
+    public void addActionMessage(String aMessage) {
+        internalGetActionMessages().add(aMessage);
+    }
+
+    @Override
+    public synchronized void addFieldError(String fieldName, String errorMessage) {
+        final Map<String, List<String>> errors = internalGetFieldErrors();
+        List<String> thisFieldErrors = errors.get(fieldName);
+
+        if (thisFieldErrors == null) {
+            thisFieldErrors = new ArrayList<>();
+            errors.put(fieldName, thisFieldErrors);
+        }
+
+        thisFieldErrors.add(errorMessage);
+    }
+
+    @Override
+    public synchronized boolean hasActionErrors() {
+        return (actionErrors != null) && !actionErrors.isEmpty();
+    }
+
+    /**
+     * Note that this does not have the same meaning as in WW 1.x
+     *
+     * @return (hasActionErrors() || hasFieldErrors())
+     */
+    @Override
+    public synchronized boolean hasErrors() {
+        return (hasActionErrors() || hasFieldErrors());
+    }
+
+    @Override
+    public synchronized boolean hasFieldErrors() {
+        return (fieldErrors != null) && !fieldErrors.isEmpty();
+    }
+
+    private Collection<String> internalGetActionErrors() {
+        if (actionErrors == null) {
+            actionErrors = new ArrayList<>();
+        }
+
+        return actionErrors;
+    }
+
+    private Collection<String> internalGetActionMessages() {
+        if (actionMessages == null) {
+            actionMessages = new ArrayList<>();
+        }
+
+        return actionMessages;
+    }
+
+    private Map<String, List<String>> internalGetFieldErrors() {
+        if (fieldErrors == null) {
+            fieldErrors = new HashMap<>();
+        }
+
+        return fieldErrors;
+    }
+}

http://git-wip-us.apache.org/repos/asf/struts/blob/c063704d/core/src/test/java/com/opensymphony/xwork2/validator/GenericValidatorContext.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/com/opensymphony/xwork2/validator/GenericValidatorContext.java
b/core/src/test/java/com/opensymphony/xwork2/validator/GenericValidatorContext.java
deleted file mode 100644
index 948cd97..0000000
--- a/core/src/test/java/com/opensymphony/xwork2/validator/GenericValidatorContext.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Copyright 2002-2003,2009 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 com.opensymphony.xwork2.validator;
-
-import com.opensymphony.xwork2.TextProviderFactory;
-
-import java.util.*;
-
-
-/**
- * Dummy validator context to use to capture error messages.
- *
- * @author Mark Woon
- * @author Matthew Payne
- */
-public class GenericValidatorContext extends DelegatingValidatorContext {
-
-    private Collection<String> actionErrors;
-    private Collection<String> actionMessages;
-    private Map<String, List<String>> fieldErrors;
-
-
-    public GenericValidatorContext(Object object, TextProviderFactory tpf) {
-        super(object, tpf);
-    }
-
-
-    @Override
-    public synchronized void setActionErrors(Collection<String> errorMessages) {
-        this.actionErrors = errorMessages;
-    }
-
-    @Override
-    public synchronized Collection<String> getActionErrors() {
-        return new ArrayList<>(internalGetActionErrors());
-    }
-
-    @Override
-    public synchronized void setActionMessages(Collection<String> messages) {
-        this.actionMessages = messages;
-    }
-
-    @Override
-    public synchronized Collection<String> getActionMessages() {
-        return new ArrayList<String>(internalGetActionMessages());
-    }
-
-    @Override
-    public synchronized void setFieldErrors(Map<String, List<String>> errorMap)
{
-        this.fieldErrors = errorMap;
-    }
-
-    /**
-     * Get the field specific errors.
-     *
-     * @return an unmodifiable Map with errors mapped from fieldname (String) to Collection
of String error messages
-     */
-    @Override
-    public synchronized Map<String, List<String>> getFieldErrors() {
-        return new HashMap<String, List<String>>(internalGetFieldErrors());
-    }
-
-    @Override
-    public synchronized void addActionError(String anErrorMessage) {
-        internalGetActionErrors().add(anErrorMessage);
-    }
-
-    /**
-     * Add an Action level message to this Action
-     */
-    @Override
-    public void addActionMessage(String aMessage) {
-        internalGetActionMessages().add(aMessage);
-    }
-
-    @Override
-    public synchronized void addFieldError(String fieldName, String errorMessage) {
-        final Map<String, List<String>> errors = internalGetFieldErrors();
-        List<String> thisFieldErrors = errors.get(fieldName);
-
-        if (thisFieldErrors == null) {
-            thisFieldErrors = new ArrayList<>();
-            errors.put(fieldName, thisFieldErrors);
-        }
-
-        thisFieldErrors.add(errorMessage);
-    }
-
-    @Override
-    public synchronized boolean hasActionErrors() {
-        return (actionErrors != null) && !actionErrors.isEmpty();
-    }
-
-    /**
-     * Note that this does not have the same meaning as in WW 1.x
-     *
-     * @return (hasActionErrors() || hasFieldErrors())
-     */
-    @Override
-    public synchronized boolean hasErrors() {
-        return (hasActionErrors() || hasFieldErrors());
-    }
-
-    @Override
-    public synchronized boolean hasFieldErrors() {
-        return (fieldErrors != null) && !fieldErrors.isEmpty();
-    }
-
-    private Collection<String> internalGetActionErrors() {
-        if (actionErrors == null) {
-            actionErrors = new ArrayList<>();
-        }
-
-        return actionErrors;
-    }
-
-    private Collection<String> internalGetActionMessages() {
-        if (actionMessages == null) {
-            actionMessages = new ArrayList<>();
-        }
-
-        return actionMessages;
-    }
-
-    private Map<String, List<String>> internalGetFieldErrors() {
-        if (fieldErrors == null) {
-            fieldErrors = new HashMap<>();
-        }
-
-        return fieldErrors;
-    }
-}

http://git-wip-us.apache.org/repos/asf/struts/blob/c063704d/core/src/test/java/com/opensymphony/xwork2/validator/validators/DateRangeFieldValidatorTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/com/opensymphony/xwork2/validator/validators/DateRangeFieldValidatorTest.java
b/core/src/test/java/com/opensymphony/xwork2/validator/validators/DateRangeFieldValidatorTest.java
index fd4a480..6129fc0 100644
--- a/core/src/test/java/com/opensymphony/xwork2/validator/validators/DateRangeFieldValidatorTest.java
+++ b/core/src/test/java/com/opensymphony/xwork2/validator/validators/DateRangeFieldValidatorTest.java
@@ -5,7 +5,7 @@ import com.opensymphony.xwork2.TextProviderFactory;
 import com.opensymphony.xwork2.XWorkTestCase;
 import com.opensymphony.xwork2.util.ValueStack;
 import com.opensymphony.xwork2.util.ValueStackFactory;
-import com.opensymphony.xwork2.validator.GenericValidatorContext;
+import com.opensymphony.xwork2.validator.DummyValidatorContext;
 import com.opensymphony.xwork2.validator.ValidatorContext;
 
 import java.util.Calendar;
@@ -19,7 +19,7 @@ public class DateRangeFieldValidatorTest extends XWorkTestCase {
     public void testPassValidation() throws Exception {
         // given
         ValidationAction action = prepareAction(createDate(2013, 6, 6));
-        ValidatorContext context = new GenericValidatorContext(action, tpf);
+        ValidatorContext context = new DummyValidatorContext(action, tpf);
         DateRangeFieldValidator validator = prepareValidator(action, context);
 
         // when
@@ -32,7 +32,7 @@ public class DateRangeFieldValidatorTest extends XWorkTestCase {
     public void testMinValidation() throws Exception {
         // given
         ValidationAction action = prepareAction(createDate(2012, Calendar.MARCH, 3));
-        ValidatorContext context = new GenericValidatorContext(action, tpf);
+        ValidatorContext context = new DummyValidatorContext(action, tpf);
         DateRangeFieldValidator validator = prepareValidator(action, context);
 
         // when
@@ -46,7 +46,7 @@ public class DateRangeFieldValidatorTest extends XWorkTestCase {
     public void testMaxValidation() throws Exception {
         // given
         ValidationAction action = prepareAction(createDate(2014, Calendar.APRIL, 4));
-        ValidatorContext context = new GenericValidatorContext(action, tpf);
+        ValidatorContext context = new DummyValidatorContext(action, tpf);
         DateRangeFieldValidator validator = prepareValidator(action, context);
 
         // when

http://git-wip-us.apache.org/repos/asf/struts/blob/c063704d/core/src/test/java/com/opensymphony/xwork2/validator/validators/IntRangeFieldValidatorTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/com/opensymphony/xwork2/validator/validators/IntRangeFieldValidatorTest.java
b/core/src/test/java/com/opensymphony/xwork2/validator/validators/IntRangeFieldValidatorTest.java
index a729ec8..7703732 100644
--- a/core/src/test/java/com/opensymphony/xwork2/validator/validators/IntRangeFieldValidatorTest.java
+++ b/core/src/test/java/com/opensymphony/xwork2/validator/validators/IntRangeFieldValidatorTest.java
@@ -4,7 +4,7 @@ import com.opensymphony.xwork2.TextProviderFactory;
 import com.opensymphony.xwork2.XWorkTestCase;
 import com.opensymphony.xwork2.util.ValueStack;
 import com.opensymphony.xwork2.util.ValueStackFactory;
-import com.opensymphony.xwork2.validator.GenericValidatorContext;
+import com.opensymphony.xwork2.validator.DummyValidatorContext;
 import com.opensymphony.xwork2.validator.ValidatorContext;
 
 public class IntRangeFieldValidatorTest extends XWorkTestCase {
@@ -19,7 +19,7 @@ public class IntRangeFieldValidatorTest extends XWorkTestCase {
     public void testPassValidation() throws Exception {
         // given
         ValidationAction action = prepareAction(100);
-        ValidatorContext context = new GenericValidatorContext(action, tpf);
+        ValidatorContext context = new DummyValidatorContext(action, tpf);
         IntRangeFieldValidator validator = prepareValidator(action, context);
 
         // when
@@ -32,7 +32,7 @@ public class IntRangeFieldValidatorTest extends XWorkTestCase {
     public void testMinValidation() throws Exception {
         // given
         ValidationAction action = prepareAction(98);
-        ValidatorContext context = new GenericValidatorContext(action, tpf);
+        ValidatorContext context = new DummyValidatorContext(action, tpf);
         IntRangeFieldValidator validator = prepareValidator(action, context);
 
         // when
@@ -46,7 +46,7 @@ public class IntRangeFieldValidatorTest extends XWorkTestCase {
     public void testMaxValidation() throws Exception {
         // given
         ValidationAction action = prepareAction(102);
-        ValidatorContext context = new GenericValidatorContext(action, tpf);
+        ValidatorContext context = new DummyValidatorContext(action, tpf);
         IntRangeFieldValidator validator = prepareValidator(action, context);
 
         // when

http://git-wip-us.apache.org/repos/asf/struts/blob/c063704d/core/src/test/java/com/opensymphony/xwork2/validator/validators/LongRangeFieldValidatorTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/com/opensymphony/xwork2/validator/validators/LongRangeFieldValidatorTest.java
b/core/src/test/java/com/opensymphony/xwork2/validator/validators/LongRangeFieldValidatorTest.java
index b2e5ad3..bc14b57 100644
--- a/core/src/test/java/com/opensymphony/xwork2/validator/validators/LongRangeFieldValidatorTest.java
+++ b/core/src/test/java/com/opensymphony/xwork2/validator/validators/LongRangeFieldValidatorTest.java
@@ -4,7 +4,7 @@ import com.opensymphony.xwork2.TextProviderFactory;
 import com.opensymphony.xwork2.XWorkTestCase;
 import com.opensymphony.xwork2.util.ValueStack;
 import com.opensymphony.xwork2.util.ValueStackFactory;
-import com.opensymphony.xwork2.validator.GenericValidatorContext;
+import com.opensymphony.xwork2.validator.DummyValidatorContext;
 import com.opensymphony.xwork2.validator.ValidatorContext;
 
 public class LongRangeFieldValidatorTest extends XWorkTestCase {
@@ -19,7 +19,7 @@ public class LongRangeFieldValidatorTest extends XWorkTestCase {
     public void testPassValidation() throws Exception {
         // given
         ValidationAction action = prepareAction(100);
-        ValidatorContext context = new GenericValidatorContext(action, tpf);
+        ValidatorContext context = new DummyValidatorContext(action, tpf);
         LongRangeFieldValidator validator = prepareValidator(action, context);
 
         // when
@@ -32,7 +32,7 @@ public class LongRangeFieldValidatorTest extends XWorkTestCase {
     public void testMinValidation() throws Exception {
         // given
         ValidationAction action = prepareAction(98);
-        ValidatorContext context = new GenericValidatorContext(action, tpf);
+        ValidatorContext context = new DummyValidatorContext(action, tpf);
         LongRangeFieldValidator validator = prepareValidator(action, context);
 
         // when
@@ -46,7 +46,7 @@ public class LongRangeFieldValidatorTest extends XWorkTestCase {
     public void testMaxValidation() throws Exception {
         // given
         ValidationAction action = prepareAction(102);
-        ValidatorContext context = new GenericValidatorContext(action, tpf);
+        ValidatorContext context = new DummyValidatorContext(action, tpf);
         LongRangeFieldValidator validator = prepareValidator(action, context);
 
         // when

http://git-wip-us.apache.org/repos/asf/struts/blob/c063704d/core/src/test/java/com/opensymphony/xwork2/validator/validators/RequiredStringValidatorTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/com/opensymphony/xwork2/validator/validators/RequiredStringValidatorTest.java
b/core/src/test/java/com/opensymphony/xwork2/validator/validators/RequiredStringValidatorTest.java
index 906fcd3..1495733 100644
--- a/core/src/test/java/com/opensymphony/xwork2/validator/validators/RequiredStringValidatorTest.java
+++ b/core/src/test/java/com/opensymphony/xwork2/validator/validators/RequiredStringValidatorTest.java
@@ -5,7 +5,7 @@ import com.opensymphony.xwork2.ActionSupport;
 import com.opensymphony.xwork2.TextProviderFactory;
 import com.opensymphony.xwork2.XWorkTestCase;
 import com.opensymphony.xwork2.util.ValueStack;
-import com.opensymphony.xwork2.validator.GenericValidatorContext;
+import com.opensymphony.xwork2.validator.DummyValidatorContext;
 import com.opensymphony.xwork2.validator.ValidatorContext;
 
 public class RequiredStringValidatorTest extends XWorkTestCase {
@@ -25,7 +25,7 @@ public class RequiredStringValidatorTest extends XWorkTestCase {
         action.setStringValue("a string");
         valueStack.push(action);
 
-        ValidatorContext context = new GenericValidatorContext(action, tpf);
+        ValidatorContext context = new DummyValidatorContext(action, tpf);
         RequiredStringValidator validator = new RequiredStringValidator();
         validator.setValidatorContext(context);
         validator.setFieldName("stringValue");
@@ -45,7 +45,7 @@ public class RequiredStringValidatorTest extends XWorkTestCase {
         ValidationAction action = new ValidationAction();
         valueStack.push(action);
 
-        ValidatorContext context = new GenericValidatorContext(action, tpf);
+        ValidatorContext context = new DummyValidatorContext(action, tpf);
         RequiredStringValidator validator = new RequiredStringValidator();
         validator.setValidatorContext(context);
         validator.setFieldName("stringValue");

http://git-wip-us.apache.org/repos/asf/struts/blob/c063704d/core/src/test/java/com/opensymphony/xwork2/validator/validators/ShortRangeFieldValidatorTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/com/opensymphony/xwork2/validator/validators/ShortRangeFieldValidatorTest.java
b/core/src/test/java/com/opensymphony/xwork2/validator/validators/ShortRangeFieldValidatorTest.java
index 18c450c..bb27664 100644
--- a/core/src/test/java/com/opensymphony/xwork2/validator/validators/ShortRangeFieldValidatorTest.java
+++ b/core/src/test/java/com/opensymphony/xwork2/validator/validators/ShortRangeFieldValidatorTest.java
@@ -4,7 +4,7 @@ import com.opensymphony.xwork2.TextProviderFactory;
 import com.opensymphony.xwork2.XWorkTestCase;
 import com.opensymphony.xwork2.util.ValueStack;
 import com.opensymphony.xwork2.util.ValueStackFactory;
-import com.opensymphony.xwork2.validator.GenericValidatorContext;
+import com.opensymphony.xwork2.validator.DummyValidatorContext;
 import com.opensymphony.xwork2.validator.ValidatorContext;
 
 public class ShortRangeFieldValidatorTest extends XWorkTestCase {
@@ -19,7 +19,7 @@ public class ShortRangeFieldValidatorTest extends XWorkTestCase {
     public void testPassValidation() throws Exception {
         // given
         ValidationAction action = prepareAction((short) 5);
-        ValidatorContext context = new GenericValidatorContext(action, tpf);
+        ValidatorContext context = new DummyValidatorContext(action, tpf);
         ShortRangeFieldValidator validator = prepareValidator(action, context);
 
         // when
@@ -32,7 +32,7 @@ public class ShortRangeFieldValidatorTest extends XWorkTestCase {
     public void testMinValidation() throws Exception {
         // given
         ValidationAction action = prepareAction((short) 1);
-        ValidatorContext context = new GenericValidatorContext(action, tpf);
+        ValidatorContext context = new DummyValidatorContext(action, tpf);
         ShortRangeFieldValidator validator = prepareValidator(action, context);
 
         // when
@@ -46,7 +46,7 @@ public class ShortRangeFieldValidatorTest extends XWorkTestCase {
     public void testMaxValidation() throws Exception {
         // given
         ValidationAction action = prepareAction((short) 11);
-        ValidatorContext context = new GenericValidatorContext(action, tpf);
+        ValidatorContext context = new DummyValidatorContext(action, tpf);
         ShortRangeFieldValidator validator = prepareValidator(action, context);
 
         // when


Mime
View raw message