Return-Path: X-Original-To: apmail-struts-commits-archive@minotaur.apache.org Delivered-To: apmail-struts-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7E8CB184A8 for ; Mon, 15 Jun 2015 17:38:03 +0000 (UTC) Received: (qmail 58914 invoked by uid 500); 15 Jun 2015 17:38:03 -0000 Delivered-To: apmail-struts-commits-archive@struts.apache.org Received: (qmail 58794 invoked by uid 500); 15 Jun 2015 17:38:03 -0000 Mailing-List: contact commits-help@struts.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@struts.apache.org Delivered-To: mailing list commits@struts.apache.org Received: (qmail 58695 invoked by uid 99); 15 Jun 2015 17:38:03 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 15 Jun 2015 17:38:03 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id DB992DFF8C; Mon, 15 Jun 2015 17:38:02 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: jogep@apache.org To: commits@struts.apache.org Date: Mon, 15 Jun 2015 17:38:03 -0000 Message-Id: <26fae9a3631643cb82be7f323754096c@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [2/9] struts git commit: Minor code improvements's in the xwork-core module http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderTest.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderTest.java b/xwork-core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderTest.java index b22045e..b161d02 100644 --- a/xwork-core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderTest.java +++ b/xwork-core/src/test/java/com/opensymphony/xwork2/config/providers/XmlConfigurationProviderTest.java @@ -43,7 +43,7 @@ public class XmlConfigurationProviderTest extends ConfigurationTestBase { XmlConfigurationProvider prov = new XmlConfigurationProvider("xwork-test-load-order.xml", true) { @Override protected Iterator getConfigurationUrls(String fileName) throws IOException { - List urls = new ArrayList(); + List urls = new ArrayList<>(); urls.add(ClassLoaderUtil.getResource("com/opensymphony/xwork2/config/providers/loadorder1/xwork-test-load-order.xml", XmlConfigurationProvider.class)); urls.add(ClassLoaderUtil.getResource("com/opensymphony/xwork2/config/providers/loadorder2/xwork-test-load-order.xml", XmlConfigurationProvider.class)); urls.add(ClassLoaderUtil.getResource("com/opensymphony/xwork2/config/providers/loadorder3/xwork-test-load-order.xml", XmlConfigurationProvider.class)); http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/test/java/com/opensymphony/xwork2/conversion/impl/AnnotationXWorkConverterTest.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/conversion/impl/AnnotationXWorkConverterTest.java b/xwork-core/src/test/java/com/opensymphony/xwork2/conversion/impl/AnnotationXWorkConverterTest.java index 14d9be1..7302359 100644 --- a/xwork-core/src/test/java/com/opensymphony/xwork2/conversion/impl/AnnotationXWorkConverterTest.java +++ b/xwork-core/src/test/java/com/opensymphony/xwork2/conversion/impl/AnnotationXWorkConverterTest.java @@ -200,7 +200,7 @@ public class AnnotationXWorkConverterTest extends XWorkTestCase { } public void testStringArrayToCollection() { - List list = new ArrayList(); + List list = new ArrayList<>(); list.add("foo"); list.add("bar"); list.add("baz"); @@ -224,27 +224,25 @@ public class AnnotationXWorkConverterTest extends XWorkTestCase { "123", "456" }, Long[].class); assertNotNull(longs); - assertTrue(Arrays.equals(new Long[]{new Long(123), new Long(456)}, longs)); + assertTrue(Arrays.equals(new Long[]{123L, 456L}, longs)); Integer[] ints = (Integer[]) converter.convertValue(context, null, null, null, new String[]{ "123", "456" }, Integer[].class); assertNotNull(ints); - assertTrue(Arrays.equals(new Integer[]{ - new Integer(123), new Integer(456) - }, ints)); + assertTrue(Arrays.equals(new Integer[]{123, 456}, ints)); Double[] doubles = (Double[]) converter.convertValue(context, null, null, null, new String[]{ "123", "456" }, Double[].class); assertNotNull(doubles); - assertTrue(Arrays.equals(new Double[]{new Double(123), new Double(456)}, doubles)); + assertTrue(Arrays.equals(new Double[]{123D, 456D}, doubles)); Float[] floats = (Float[]) converter.convertValue(context, null, null, null, new String[]{ "123", "456" }, Float[].class); assertNotNull(floats); - assertTrue(Arrays.equals(new Float[]{new Float(123), new Float(456)}, floats)); + assertTrue(Arrays.equals(new Float[]{123F, 456F}, floats)); Boolean[] booleans = (Boolean[]) converter.convertValue(context, null, null, null, new String[]{ "true", "false" @@ -286,7 +284,7 @@ public class AnnotationXWorkConverterTest extends XWorkTestCase { } public void testStringArrayToSet() { - Set list = new HashSet(); + Set list = new HashSet<>(); list.add("foo"); list.add("bar"); list.add("baz"); @@ -330,8 +328,8 @@ public class AnnotationXWorkConverterTest extends XWorkTestCase { assertEquals(new Integer(123), converter.convertValue(context, null, null, null, "123", Integer.class)); assertEquals(new Double(123.5), converter.convertValue(context, null, null, null, "123.5", Double.class)); assertEquals(new Float(123.5), converter.convertValue(context, null, null, null, "123.5", float.class)); - assertEquals(new Boolean(false), converter.convertValue(context, null, null, null, "false", Boolean.class)); - assertEquals(new Boolean(true), converter.convertValue(context, null, null, null, "true", Boolean.class)); + assertEquals(false, converter.convertValue(context, null, null, null, "false", Boolean.class)); + assertEquals(true, converter.convertValue(context, null, null, null, "true", Boolean.class)); } public void testStringToPrimitives() { @@ -339,8 +337,8 @@ public class AnnotationXWorkConverterTest extends XWorkTestCase { assertEquals(new Integer(123), converter.convertValue(context, null, null, null, "123", int.class)); assertEquals(new Double(123.5), converter.convertValue(context, null, null, null, "123.5", double.class)); assertEquals(new Float(123.5), converter.convertValue(context, null, null, null, "123.5", float.class)); - assertEquals(new Boolean(false), converter.convertValue(context, null, null, null, "false", boolean.class)); - assertEquals(new Boolean(true), converter.convertValue(context, null, null, null, "true", boolean.class)); + assertEquals(false, converter.convertValue(context, null, null, null, "false", boolean.class)); + assertEquals(true, converter.convertValue(context, null, null, null, "true", boolean.class)); assertEquals(new BigDecimal(123.5), converter.convertValue(context, null, null, null, "123.5", BigDecimal.class)); assertEquals(new BigInteger("123"), converter.convertValue(context, null, null, null, "123", BigInteger.class)); } http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/test/java/com/opensymphony/xwork2/conversion/impl/NumberConverterTest.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/conversion/impl/NumberConverterTest.java b/xwork-core/src/test/java/com/opensymphony/xwork2/conversion/impl/NumberConverterTest.java index a3c7c94..76be6e1 100644 --- a/xwork-core/src/test/java/com/opensymphony/xwork2/conversion/impl/NumberConverterTest.java +++ b/xwork-core/src/test/java/com/opensymphony/xwork2/conversion/impl/NumberConverterTest.java @@ -13,7 +13,7 @@ public class NumberConverterTest extends XWorkTestCase { public void testStringToNumberConversionPL() throws Exception { // given NumberConverter converter = new NumberConverter(); - Map context = new HashMap(); + Map context = new HashMap<>(); context.put(ActionContext.LOCALE, new Locale("pl", "PL")); SimpleFooAction foo = new SimpleFooAction(); @@ -28,7 +28,7 @@ public class NumberConverterTest extends XWorkTestCase { public void testStringToNumberConversionUS() throws Exception { // given NumberConverter converter = new NumberConverter(); - Map context = new HashMap(); + Map context = new HashMap<>(); context.put(ActionContext.LOCALE, new Locale("en", "US")); SimpleFooAction foo = new SimpleFooAction(); http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkBasicConverterTest.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkBasicConverterTest.java b/xwork-core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkBasicConverterTest.java index 95fb13f..7bd4906 100644 --- a/xwork-core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkBasicConverterTest.java +++ b/xwork-core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkBasicConverterTest.java @@ -20,13 +20,8 @@ import com.opensymphony.xwork2.XWorkException; import com.opensymphony.xwork2.XWorkTestCase; import com.opensymphony.xwork2.test.annotations.Person; -import java.lang.reflect.Member; import java.text.DateFormat; -import java.util.Calendar; -import java.util.Date; -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; +import java.util.*; /** * Test case for XWorkBasicConverter @@ -60,7 +55,7 @@ public class XWorkBasicConverterTest extends XWorkTestCase { public void testDateWithLocalePoland() throws Exception { - Map map = new HashMap(); + Map map = new HashMap<>(); Locale locale = new Locale("pl", "PL"); map.put(ActionContext.LOCALE, locale); @@ -74,7 +69,7 @@ public class XWorkBasicConverterTest extends XWorkTestCase { public void testDateWithLocaleFrance() throws Exception { - Map map = new HashMap(); + Map map = new HashMap<>(); Locale locale = new Locale("fr", "FR"); map.put(ActionContext.LOCALE, locale); @@ -88,7 +83,7 @@ public class XWorkBasicConverterTest extends XWorkTestCase { public void testDateWithLocaleUK() throws Exception { - Map map = new HashMap(); + Map map = new HashMap<>(); Locale locale = new Locale("en", "US"); map.put(ActionContext.LOCALE, locale); @@ -242,13 +237,12 @@ public class XWorkBasicConverterTest extends XWorkTestCase { public void testConvert() { - Map context = new HashMap(); + Map context = new HashMap<>(); Person o = new Person(); - Member member = null; String s = "names"; Object value = new Person[0]; Class toType = String.class; - basicConverter.convertValue(context, value, member, s, value, toType); + basicConverter.convertValue(context, value, null, s, value, toType); } @Override http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkConverterTest.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkConverterTest.java b/xwork-core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkConverterTest.java index bc0d932..3d7fc49 100644 --- a/xwork-core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkConverterTest.java +++ b/xwork-core/src/test/java/com/opensymphony/xwork2/conversion/impl/XWorkConverterTest.java @@ -15,11 +15,7 @@ */ package com.opensymphony.xwork2.conversion.impl; -import com.opensymphony.xwork2.ActionContext; -import com.opensymphony.xwork2.ModelDrivenAction; -import com.opensymphony.xwork2.SimpleAction; -import com.opensymphony.xwork2.TestBean; -import com.opensymphony.xwork2.XWorkTestCase; +import com.opensymphony.xwork2.*; import com.opensymphony.xwork2.ognl.OgnlValueStack; import com.opensymphony.xwork2.test.ModelDrivenAction2; import com.opensymphony.xwork2.test.User; @@ -39,16 +35,7 @@ import java.sql.Timestamp; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Date; -import java.util.Enumeration; -import java.util.HashSet; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Set; +import java.util.*; /** @@ -223,7 +210,7 @@ public class XWorkConverterTest extends XWorkTestCase { stack.push(action); stack.push(action.getModel()); - Map ognlStackContext = stack.getContext(); + Map ognlStackContext = stack.getContext(); ognlStackContext.put(XWorkConverter.REPORT_CONVERSION_ERRORS, Boolean.TRUE); String value = "asdf:123"; @@ -250,7 +237,7 @@ public class XWorkConverterTest extends XWorkTestCase { stack.push(action); - Map ognlStackContext = stack.getContext(); + Map ognlStackContext = stack.getContext(); ognlStackContext.put(XWorkConverter.REPORT_CONVERSION_ERRORS, Boolean.TRUE); assertEquals("Conversion should have failed.", OgnlRuntime.NoConversionPossible, converter.convertValue(ognlStackContext, action.getBean(), null, "count", "111.1", int.class)); @@ -262,7 +249,7 @@ public class XWorkConverterTest extends XWorkTestCase { } public void testStringArrayToCollection() { - List list = new ArrayList(); + List list = new ArrayList<>(); list.add("foo"); list.add("bar"); list.add("baz"); @@ -272,7 +259,7 @@ public class XWorkConverterTest extends XWorkTestCase { } public void testStringArrayToList() { - List list = new ArrayList(); + List list = new ArrayList<>(); list.add("foo"); list.add("bar"); list.add("baz"); @@ -286,27 +273,25 @@ public class XWorkConverterTest extends XWorkTestCase { "123", "456" }, Long[].class); assertNotNull(longs); - assertTrue(Arrays.equals(new Long[]{new Long(123), new Long(456)}, longs)); + assertTrue(Arrays.equals(new Long[]{123L, 456L}, longs)); Integer[] ints = (Integer[]) converter.convertValue(context, null, null, null, new String[]{ "123", "456" }, Integer[].class); assertNotNull(ints); - assertTrue(Arrays.equals(new Integer[]{ - new Integer(123), new Integer(456) - }, ints)); + assertTrue(Arrays.equals(new Integer[]{123, 456}, ints)); Double[] doubles = (Double[]) converter.convertValue(context, null, null, null, new String[]{ "123", "456" }, Double[].class); assertNotNull(doubles); - assertTrue(Arrays.equals(new Double[]{new Double(123), new Double(456)}, doubles)); + assertTrue(Arrays.equals(new Double[]{123D, 456D}, doubles)); Float[] floats = (Float[]) converter.convertValue(context, null, null, null, new String[]{ "123", "456" }, Float[].class); assertNotNull(floats); - assertTrue(Arrays.equals(new Float[]{new Float(123), new Float(456)}, floats)); + assertTrue(Arrays.equals(new Float[]{123F, 456F}, floats)); Boolean[] booleans = (Boolean[]) converter.convertValue(context, null, null, null, new String[]{ "true", "false" @@ -348,7 +333,7 @@ public class XWorkConverterTest extends XWorkTestCase { } public void testStringArrayToSet() { - Set list = new HashSet(); + Set list = new HashSet<>(); list.add("foo"); list.add("bar"); list.add("baz"); @@ -358,7 +343,7 @@ public class XWorkConverterTest extends XWorkTestCase { } public void testStringToCollectionConversion() { - Map stackContext = stack.getContext(); + Map stackContext = stack.getContext(); stackContext.put(ReflectionContextState.CREATE_NULL_OBJECTS, Boolean.TRUE); stackContext.put(ReflectionContextState.DENY_METHOD_EXECUTION, Boolean.TRUE); stackContext.put(XWorkConverter.REPORT_CONVERSION_ERRORS, Boolean.TRUE); @@ -430,16 +415,16 @@ public class XWorkConverterTest extends XWorkTestCase { assertEquals(new Integer(123), converter.convertValue(context, null, null, null, "123", Integer.class)); assertEquals(new Double(123.5), converter.convertValue(context, null, null, null, "123.5", Double.class)); assertEquals(new Float(123.5), converter.convertValue(context, null, null, null, "123.5", float.class)); - assertEquals(new Boolean(false), converter.convertValue(context, null, null, null, "false", Boolean.class)); - assertEquals(new Boolean(true), converter.convertValue(context, null, null, null, "true", Boolean.class)); + assertEquals(false, converter.convertValue(context, null, null, null, "false", Boolean.class)); + assertEquals(true, converter.convertValue(context, null, null, null, "true", Boolean.class)); } public void testStringToPrimitives() { assertEquals(new Long(123), converter.convertValue(context, null, null, null, "123", long.class)); assertEquals(new Double(123.5), converter.convertValue(context, null, null, null, "123.5", double.class)); assertEquals(new Float(123.5), converter.convertValue(context, null, null, null, "123.5", float.class)); - assertEquals(new Boolean(false), converter.convertValue(context, null, null, null, "false", boolean.class)); - assertEquals(new Boolean(true), converter.convertValue(context, null, null, null, "true", boolean.class)); + assertEquals(false, converter.convertValue(context, null, null, null, "false", boolean.class)); + assertEquals(true, converter.convertValue(context, null, null, null, "true", boolean.class)); assertEquals(new BigDecimal(123.5), converter.convertValue(context, null, null, null, "123.5", BigDecimal.class)); assertEquals(new BigInteger("123"), converter.convertValue(context, null, null, null, "123", BigInteger.class)); } @@ -651,7 +636,7 @@ public class XWorkConverterTest extends XWorkTestCase { } public void testConvertSameCollectionToCollection() { - Collection names = new ArrayList(); + Collection names = new ArrayList<>(); names.add("XWork"); names.add("Struts"); @@ -717,7 +702,7 @@ public class XWorkConverterTest extends XWorkTestCase { class ListAction { - private List ints = new ArrayList(); + private List ints = new ArrayList<>(); public List getInts() { return ints; http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/AliasInterceptorTest.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/AliasInterceptorTest.java b/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/AliasInterceptorTest.java index 44ebab5..00077be 100644 --- a/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/AliasInterceptorTest.java +++ b/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/AliasInterceptorTest.java @@ -43,7 +43,7 @@ import java.util.Map; public class AliasInterceptorTest extends XWorkTestCase { public void testUsingDefaultInterceptorThatAliasPropertiesAreCopied() throws Exception { - Map params = new HashMap(); + Map params = new HashMap<>(); params.put("aliasSource", "source here"); XmlConfigurationProvider provider = new XmlConfigurationProvider("xwork-sample.xml"); http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/ChainingInterceptorTest.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/ChainingInterceptorTest.java b/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/ChainingInterceptorTest.java index 3e3dc61..1b84209 100644 --- a/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/ChainingInterceptorTest.java +++ b/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/ChainingInterceptorTest.java @@ -103,7 +103,7 @@ public class ChainingInterceptorTest extends XWorkTestCase { interceptor.setCopyErrors("true"); interceptor.setCopyMessages("true"); - Collection excludes = new ArrayList(); + Collection excludes = new ArrayList<>(); excludes.add("count"); interceptor.setExcludes(excludes); @@ -125,7 +125,7 @@ public class ChainingInterceptorTest extends XWorkTestCase { stack.push(bean); stack.push(action); - Collection excludes = new ArrayList(); + Collection excludes = new ArrayList<>(); excludes.add("name"); excludes.add("count"); interceptor.setExcludes(excludes); @@ -152,7 +152,7 @@ public class ChainingInterceptorTest extends XWorkTestCase { mockInvocation = new Mock(ActionInvocation.class); mockInvocation.expectAndReturn("getStack", stack); mockInvocation.expectAndReturn("invoke", Action.SUCCESS); - mockInvocation.expectAndReturn("getInvocationContext", new ActionContext(new HashMap())); + mockInvocation.expectAndReturn("getInvocationContext", new ActionContext(new HashMap())); mockInvocation.expectAndReturn("getResult", new ActionChainResult()); invocation = (ActionInvocation) mockInvocation.proxy(); interceptor = new ChainingInterceptor(); http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/ConversionErrorInterceptorTest.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/ConversionErrorInterceptorTest.java b/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/ConversionErrorInterceptorTest.java index 7f505fa..0e34ae1 100644 --- a/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/ConversionErrorInterceptorTest.java +++ b/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/ConversionErrorInterceptorTest.java @@ -138,7 +138,7 @@ public class ConversionErrorInterceptorTest extends XWorkTestCase { invocation = (ActionInvocation) mockInvocation.proxy(); stack = ActionContext.getContext().getValueStack(); context = new ActionContext(stack.getContext()); - conversionErrors = new HashMap(); + conversionErrors = new HashMap<>(); context.setConversionErrors(conversionErrors); mockInvocation.matchAndReturn("getInvocationContext", context); mockInvocation.expect("addPreResultListener", C.isA(PreResultListener.class)); http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/DefaultWorkflowInterceptorTest.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/DefaultWorkflowInterceptorTest.java b/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/DefaultWorkflowInterceptorTest.java index 713aaef..80ccae2 100644 --- a/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/DefaultWorkflowInterceptorTest.java +++ b/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/DefaultWorkflowInterceptorTest.java @@ -16,15 +16,14 @@ package com.opensymphony.xwork2.interceptor; import com.opensymphony.xwork2.*; -import com.opensymphony.xwork2.config.entities.InterceptorConfig; import com.opensymphony.xwork2.config.entities.ActionConfig; +import com.opensymphony.xwork2.config.entities.InterceptorConfig; import com.opensymphony.xwork2.validator.ValidationInterceptor; - -import java.util.HashMap; - import org.easymock.EasyMock; import org.easymock.IAnswer; +import java.util.HashMap; + /** * Unit test for {@link DefaultWorkflowInterceptor}. @@ -191,9 +190,9 @@ public class DefaultWorkflowInterceptorTest extends XWorkTestCase { EasyMock.replay(action); EasyMock.replay(proxy); - ActionContext contex = new ActionContext(new HashMap()); - ActionContext.setContext(contex); - contex.setActionInvocation(invocation); + ActionContext actionContext = new ActionContext(new HashMap()); + ActionContext.setContext(actionContext); + actionContext.setActionInvocation(invocation); } @Override @@ -204,7 +203,7 @@ public class DefaultWorkflowInterceptorTest extends XWorkTestCase { protected ValidationInterceptor create() { ObjectFactory objectFactory = container.getInstance(ObjectFactory.class); return (ValidationInterceptor) objectFactory.buildInterceptor( - new InterceptorConfig.Builder("model", ValidationInterceptor.class.getName()).build(), new HashMap()); + new InterceptorConfig.Builder("model", ValidationInterceptor.class.getName()).build(), new HashMap()); } http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/ExceptionMappingInterceptorTest.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/ExceptionMappingInterceptorTest.java b/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/ExceptionMappingInterceptorTest.java index 37bcaae..aad0aec 100644 --- a/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/ExceptionMappingInterceptorTest.java +++ b/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/ExceptionMappingInterceptorTest.java @@ -289,7 +289,7 @@ public class ExceptionMappingInterceptorTest extends XWorkTestCase { stack = ActionContext.getContext().getValueStack(); mockInvocation = new Mock(ActionInvocation.class); mockInvocation.expectAndReturn("getStack", stack); - mockInvocation.expectAndReturn("getInvocationContext", new ActionContext(new HashMap())); + mockInvocation.expectAndReturn("getInvocationContext", new ActionContext(new HashMap())); interceptor = new ExceptionMappingInterceptor(); interceptor.init(); } http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/I18nInterceptorTest.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/I18nInterceptorTest.java b/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/I18nInterceptorTest.java index 1b585ec..5979e58 100644 --- a/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/I18nInterceptorTest.java +++ b/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/I18nInterceptorTest.java @@ -17,15 +17,15 @@ package com.opensymphony.xwork2.interceptor; import com.opensymphony.xwork2.Action; import com.opensymphony.xwork2.ActionContext; -import com.opensymphony.xwork2.SimpleFooAction; import com.opensymphony.xwork2.ActionInvocation; +import com.opensymphony.xwork2.SimpleFooAction; import com.opensymphony.xwork2.mock.MockActionInvocation; import junit.framework.TestCase; +import java.io.Serializable; import java.util.HashMap; import java.util.Locale; import java.util.Map; -import java.io.Serializable; /** * Unit test for I18nInterceptor. @@ -180,10 +180,10 @@ public class I18nInterceptorTest extends TestCase { protected void setUp() throws Exception { interceptor = new I18nInterceptor(); interceptor.init(); - params = new HashMap(); + params = new HashMap<>(); session = new HashMap(); - Map ctx = new HashMap(); + Map ctx = new HashMap<>(); ctx.put(ActionContext.PARAMETERS, params); ctx.put(ActionContext.SESSION, session); ac = new ActionContext(ctx); http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/MethodFilterInterceptorUtilTest.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/MethodFilterInterceptorUtilTest.java b/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/MethodFilterInterceptorUtilTest.java index 98de1ce..6598050 100644 --- a/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/MethodFilterInterceptorUtilTest.java +++ b/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/MethodFilterInterceptorUtilTest.java @@ -22,12 +22,12 @@ import java.util.HashSet; public class MethodFilterInterceptorUtilTest extends XWorkTestCase { public void testApplyMethodNoWildcards() { - - HashSet included= new HashSet(); + + HashSet included = new HashSet<>(); included.add("included"); included.add("includedAgain"); - HashSet excluded= new HashSet(); + HashSet excluded = new HashSet<>(); excluded.add("excluded"); excluded.add("excludedAgain"); @@ -43,10 +43,10 @@ public class MethodFilterInterceptorUtilTest extends XWorkTestCase { public void testApplyMethodWithWildcards() { - HashSet included= new HashSet(); + HashSet included = new HashSet<>(); included.add("included*"); - HashSet excluded= new HashSet(); + HashSet excluded = new HashSet<>(); excluded.add("excluded*"); assertTrue(MethodFilterInterceptorUtil.applyMethod(excluded, included, "includedMethod")); http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/ParameterFilterInterceptorTest.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/ParameterFilterInterceptorTest.java b/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/ParameterFilterInterceptorTest.java index c1dbb38..b57cb22 100644 --- a/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/ParameterFilterInterceptorTest.java +++ b/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/ParameterFilterInterceptorTest.java @@ -34,12 +34,12 @@ public class ParameterFilterInterceptorTest extends XWorkTestCase { ParameterFilterInterceptor interceptor; Mock mockInvocation; ValueStack stack; - Map contextMap; + Map contextMap; @Override protected void setUp() throws Exception { super.setUp(); - contextMap=new HashMap(); + contextMap = new HashMap<>(); stack = ActionContext.getContext().getValueStack(); mockInvocation = new Mock(ActionInvocation.class); mockInvocation.expectAndReturn("getStack", stack); @@ -106,7 +106,7 @@ public class ParameterFilterInterceptorTest extends XWorkTestCase { } private void setUpParameters(String [] paramNames) { - Map params=new HashMap(); + Map params = new HashMap<>(); for (String paramName : paramNames) { params.put(paramName, "irrelevant what this is"); http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/ParameterRemoverInterceptorTest.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/ParameterRemoverInterceptorTest.java b/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/ParameterRemoverInterceptorTest.java index 14bccd0..e3b4e8f 100644 --- a/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/ParameterRemoverInterceptorTest.java +++ b/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/ParameterRemoverInterceptorTest.java @@ -15,14 +15,14 @@ import java.util.Map; */ public class ParameterRemoverInterceptorTest extends TestCase { - protected Map contextMap; + protected Map contextMap; protected ActionContext context; protected MockControl actionInvocationControl; protected ActionInvocation actionInvocation; @Override protected void setUp() throws Exception { - contextMap = new LinkedHashMap(); + contextMap = new LinkedHashMap<>(); context = new ActionContext(contextMap); actionInvocationControl = MockControl.createControl(ActionInvocation.class); @@ -33,7 +33,7 @@ public class ParameterRemoverInterceptorTest extends TestCase { } public void testInterception1() throws Exception { - contextMap.put(ActionContext.PARAMETERS, new LinkedHashMap() { + contextMap.put(ActionContext.PARAMETERS, new LinkedHashMap() { private static final long serialVersionUID = 0L; { put("param1", new String[] { "paramValue1" }); @@ -62,7 +62,7 @@ public class ParameterRemoverInterceptorTest extends TestCase { public void testInterception2() throws Exception { - contextMap.put(ActionContext.PARAMETERS, new LinkedHashMap() { + contextMap.put(ActionContext.PARAMETERS, new LinkedHashMap() { private static final long serialVersionUID = 0L; { put("param1", new String[] { "paramValue2" }); @@ -85,7 +85,7 @@ public class ParameterRemoverInterceptorTest extends TestCase { public void testInterception3() throws Exception { - contextMap.put(ActionContext.PARAMETERS, new LinkedHashMap() { + contextMap.put(ActionContext.PARAMETERS, new LinkedHashMap() { private static final long serialVersionUID = 0L; { put("param1", new String[] { "paramValueOne" }); http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/ParametersInterceptorTest.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/ParametersInterceptorTest.java b/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/ParametersInterceptorTest.java index f20e178..abf0f72 100644 --- a/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/ParametersInterceptorTest.java +++ b/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/ParametersInterceptorTest.java @@ -15,15 +15,7 @@ */ package com.opensymphony.xwork2.interceptor; -import com.opensymphony.xwork2.Action; -import com.opensymphony.xwork2.ActionContext; -import com.opensymphony.xwork2.ActionProxy; -import com.opensymphony.xwork2.ModelDrivenAction; -import com.opensymphony.xwork2.SimpleAction; -import com.opensymphony.xwork2.TestBean; -import com.opensymphony.xwork2.TextProvider; -import com.opensymphony.xwork2.ValidationAware; -import com.opensymphony.xwork2.XWorkTestCase; +import com.opensymphony.xwork2.*; import com.opensymphony.xwork2.config.entities.ActionConfig; import com.opensymphony.xwork2.config.providers.MockConfigurationProvider; import com.opensymphony.xwork2.config.providers.XWorkConfigurationProvider; @@ -42,14 +34,7 @@ import ognl.OgnlContext; import ognl.PropertyAccessor; import java.io.File; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; +import java.util.*; /** @@ -131,7 +116,7 @@ public class ParametersInterceptorTest extends XWorkTestCase { } }; - final Map excluded = new HashMap(); + final Map excluded = new HashMap<>(); ParametersInterceptor pi = new ParametersInterceptor() { @Override @@ -171,7 +156,7 @@ public class ParametersInterceptorTest extends XWorkTestCase { } }; - final Map excluded = new HashMap(); + final Map excluded = new HashMap<>(); ParametersInterceptor pi = new ParametersInterceptor() { @Override @@ -207,10 +192,10 @@ public class ParametersInterceptorTest extends XWorkTestCase { } public void testDoesNotAllowMethodInvocations() throws Exception { - Map params = new HashMap(); + Map params = new HashMap<>(); params.put("@java.lang.System@exit(1).dummy", "dumb value"); - HashMap extraContext = new HashMap(); + HashMap extraContext = new HashMap<>(); extraContext.put(ActionContext.PARAMETERS, params); ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.MODEL_DRIVEN_PARAM_TEST, null, extraContext); @@ -221,7 +206,7 @@ public class ParametersInterceptorTest extends XWorkTestCase { } public void testModelDrivenParameters() throws Exception { - Map params = new HashMap(); + Map params = new HashMap<>(); final String fooVal = "com.opensymphony.xwork2.interceptor.ParametersInterceptorTest.foo"; params.put("foo", fooVal); @@ -229,7 +214,7 @@ public class ParametersInterceptorTest extends XWorkTestCase { params.put("name", nameVal); params.put("count", "15"); - HashMap extraContext = new HashMap(); + HashMap extraContext = new HashMap<>(); extraContext.put(ActionContext.PARAMETERS, params); ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.MODEL_DRIVEN_PARAM_TEST, null, extraContext); @@ -243,7 +228,7 @@ public class ParametersInterceptorTest extends XWorkTestCase { } public void testParametersDoesNotAffectSession() throws Exception { - Map params = new HashMap(); + Map params = new HashMap<>(); params.put("blah", "This is blah"); params.put("#session.foo", "Foo"); params.put("\u0023session[\'user\']", "0wn3d"); @@ -255,12 +240,12 @@ public class ParametersInterceptorTest extends XWorkTestCase { params.put("('\u0023'%2b'session[\'user5\']')(unused)", "0wn3d"); params.put("('\\u0023'%2b'session[\'user5\']')(unused)", "0wn3d"); - HashMap extraContext = new HashMap(); + HashMap extraContext = new HashMap<>(); extraContext.put(ActionContext.PARAMETERS, params); ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.PARAM_INTERCEPTOR_ACTION_NAME, null, extraContext); ValueStack stack = proxy.getInvocation().getStack(); - HashMap session = new HashMap(); + HashMap session = new HashMap<>(); stack.getContext().put("session", session); proxy.execute(); assertEquals("This is blah", ((SimpleAction) proxy.getAction()).getBlah()); @@ -324,13 +309,13 @@ public class ParametersInterceptorTest extends XWorkTestCase { public void testAccessToOgnlInternals() throws Exception { // given - Map params = new HashMap(); + Map params = new HashMap<>(); params.put("blah", "This is blah"); params.put("('\\u0023_memberAccess[\\'allowStaticMethodAccess\\']')(meh)", "true"); params.put("('(aaa)(('\\u0023context[\\'xwork.MethodAccessor.denyMethodExecution\\']\\u003d\\u0023foo')(\\u0023foo\\u003dnew java.lang.Boolean(\"false\")))", ""); params.put("(asdf)(('\\u0023rt.exit(1)')(\\u0023rt\\u003d@java.lang.Runtime@getRuntime()))", "1"); - HashMap extraContext = new HashMap(); + HashMap extraContext = new HashMap<>(); extraContext.put(ActionContext.PARAMETERS, params); ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.PARAM_INTERCEPTOR_ACTION_NAME, null, extraContext); @@ -347,10 +332,10 @@ public class ParametersInterceptorTest extends XWorkTestCase { } public void testParameters() throws Exception { - Map params = new HashMap(); + Map params = new HashMap<>(); params.put("blah", "This is blah"); - HashMap extraContext = new HashMap(); + HashMap extraContext = new HashMap<>(); extraContext.put(ActionContext.PARAMETERS, params); ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.PARAM_INTERCEPTOR_ACTION_NAME, null, extraContext); @@ -359,13 +344,13 @@ public class ParametersInterceptorTest extends XWorkTestCase { } public void testParametersWithSpacesInTheName() throws Exception { - Map params = new HashMap(); + Map params = new HashMap<>(); params.put("theProtectedMap['p0 p1']", "test1"); params.put("theProtectedMap['p0p1 ']", "test2"); params.put("theProtectedMap[' p0p1 ']", "test3"); params.put("theProtectedMap[' p0 p1 ']", "test4"); - HashMap extraContext = new HashMap(); + HashMap extraContext = new HashMap<>(); extraContext.put(ActionContext.PARAMETERS, params); ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.PARAM_INTERCEPTOR_ACTION_NAME, null, extraContext); @@ -375,10 +360,10 @@ public class ParametersInterceptorTest extends XWorkTestCase { } public void testParametersWithChineseInTheName() throws Exception { - Map params = new HashMap(); + Map params = new HashMap<>(); params.put("theProtectedMap['名字']", "test1"); - HashMap extraContext = new HashMap(); + HashMap extraContext = new HashMap<>(); extraContext.put(ActionContext.PARAMETERS, params); ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.PARAM_INTERCEPTOR_ACTION_NAME, null, extraContext); @@ -406,11 +391,11 @@ public class ParametersInterceptorTest extends XWorkTestCase { sb.append("x"); } - Map actual = new LinkedHashMap(); + Map actual = new LinkedHashMap<>(); parametersInterceptor.setValueStackFactory(createValueStackFactory(actual)); ValueStack stack = createStubValueStack(actual); - Map parameters = new HashMap(); + Map parameters = new HashMap<>(); parameters.put(sb.toString(), ""); parameters.put("huuhaa", ""); @@ -434,7 +419,7 @@ public class ParametersInterceptorTest extends XWorkTestCase { } }; - HashMap extraContext = new HashMap(); + HashMap extraContext = new HashMap<>(); extraContext.put(ActionContext.PARAMETERS, params); ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.PARAM_INTERCEPTOR_ACTION_NAME, null, extraContext); @@ -465,7 +450,7 @@ public class ParametersInterceptorTest extends XWorkTestCase { } }; - HashMap extraContext = new HashMap(); + HashMap extraContext = new HashMap<>(); extraContext.put(ActionContext.PARAMETERS, params); ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.PARAM_INTERCEPTOR_ACTION_NAME, null, extraContext); @@ -484,11 +469,11 @@ public class ParametersInterceptorTest extends XWorkTestCase { public void testParametersNotAccessPrivateVariables() throws Exception { - Map params = new HashMap(); + Map params = new HashMap<>(); params.put("protectedMap.foo", "This is blah"); params.put("theProtectedMap.boo", "This is blah"); - HashMap extraContext = new HashMap(); + HashMap extraContext = new HashMap<>(); extraContext.put(ActionContext.PARAMETERS, params); ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.PARAM_INTERCEPTOR_ACTION_NAME, null, extraContext); @@ -500,11 +485,11 @@ public class ParametersInterceptorTest extends XWorkTestCase { } public void testParametersNotAccessProtectedMethods() throws Exception { - Map params = new HashMap(); + Map params = new HashMap<>(); params.put("theSemiProtectedMap.foo", "This is blah"); params.put("theProtectedMap.boo", "This is blah"); - HashMap extraContext = new HashMap(); + HashMap extraContext = new HashMap<>(); extraContext.put(ActionContext.PARAMETERS, params); ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.PARAM_INTERCEPTOR_ACTION_NAME, null, extraContext); @@ -522,13 +507,13 @@ public class ParametersInterceptorTest extends XWorkTestCase { * @throws Exception */ public void testEvalExpressionAsParameterName() throws Exception { - Map params = new HashMap(); + Map params = new HashMap<>(); params.put("blah", "(#context[\"xwork.MethodAccessor.denyMethodExecution\"]= new " + "java.lang.Boolean(false), #_memberAccess[\"allowStaticMethodAccess\"]= new java.lang.Boolean(true), " + "@java.lang.Runtime@getRuntime().exec('mkdir /tmp/PWNAGE'))(meh)"); params.put("top['blah'](0)", "true"); - HashMap extraContext = new HashMap(); + HashMap extraContext = new HashMap<>(); extraContext.put(ActionContext.PARAMETERS, params); ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.PARAM_INTERCEPTOR_ACTION_NAME, null, extraContext); @@ -543,10 +528,10 @@ public class ParametersInterceptorTest extends XWorkTestCase { } public void testParametersOverwriteField() throws Exception { - Map params = new LinkedHashMap(); + Map params = new LinkedHashMap<>(); params.put("existingMap.boo", "This is blah"); - HashMap extraContext = new HashMap(); + HashMap extraContext = new HashMap<>(); extraContext.put(ActionContext.PARAMETERS, params); ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.PARAM_INTERCEPTOR_ACTION_NAME, null, extraContext); @@ -562,10 +547,10 @@ public class ParametersInterceptorTest extends XWorkTestCase { container.inject(provider); loadConfigurationProviders(provider, new MockConfigurationProvider(Collections.singletonMap("devMode", "true"))); - Map params = new HashMap(); + Map params = new HashMap<>(); params.put("not_a_property", "There is no action property named like this"); - HashMap extraContext = new HashMap(); + HashMap extraContext = new HashMap<>(); extraContext.put(ActionContext.PARAMETERS, params); ActionConfig config = configuration.getRuntimeConfiguration().getActionConfig("", MockConfigurationProvider.PARAM_INTERCEPTOR_ACTION_NAME); @@ -581,10 +566,10 @@ public class ParametersInterceptorTest extends XWorkTestCase { container.inject(provider); loadConfigurationProviders(provider, new MockConfigurationProvider(Collections.singletonMap("devMode", "false"))); - Map params = new HashMap(); + Map params = new HashMap<>(); params.put("not_a_property", "There is no action property named like this"); - HashMap extraContext = new HashMap(); + HashMap extraContext = new HashMap<>(); extraContext.put(ActionContext.PARAMETERS, params); ActionConfig config = configuration.getRuntimeConfiguration().getActionConfig("", MockConfigurationProvider.PARAM_INTERCEPTOR_ACTION_NAME); @@ -608,11 +593,11 @@ public class ParametersInterceptorTest extends XWorkTestCase { public void testNoOrdered() throws Exception { ParametersInterceptor pi = createParametersInterceptor(); - final Map actual = new LinkedHashMap(); + final Map actual = new LinkedHashMap<>(); pi.setValueStackFactory(createValueStackFactory(actual)); ValueStack stack = createStubValueStack(actual); - Map parameters = new HashMap(); + Map parameters = new HashMap<>(); parameters.put("user.address.city", "London"); parameters.put("user.name", "Superman"); @@ -634,11 +619,11 @@ public class ParametersInterceptorTest extends XWorkTestCase { ParametersInterceptor pi = new ParametersInterceptor(); pi.setOrdered(true); container.inject(pi); - final Map actual = new LinkedHashMap(); + final Map actual = new LinkedHashMap<>(); pi.setValueStackFactory(createValueStackFactory(actual)); ValueStack stack = createStubValueStack(actual); - Map parameters = new HashMap(); + Map parameters = new HashMap<>(); parameters.put("user.address.city", "London"); parameters.put("user.address['postal']", "QJR387"); parameters.put("user.name", "Superman"); @@ -728,7 +713,7 @@ public class ParametersInterceptorTest extends XWorkTestCase { } private Map injectValueStackFactory(ParametersInterceptor interceptor) { - final Map actual = new HashMap(); + final Map actual = new HashMap<>(); interceptor.setValueStackFactory(createValueStackFactory(actual)); return actual; } @@ -806,7 +791,7 @@ public class ParametersInterceptorTest extends XWorkTestCase { class ValidateAction implements ValidationAware { - private List messages = new LinkedList(); + private List messages = new LinkedList<>(); private String name; public void setActionErrors(Collection errorMessages) { http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/PreResultListenerTest.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/PreResultListenerTest.java b/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/PreResultListenerTest.java index fce27b8..9682741 100644 --- a/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/PreResultListenerTest.java +++ b/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/PreResultListenerTest.java @@ -41,7 +41,7 @@ public class PreResultListenerTest extends XWorkTestCase { public void testPreResultListenersAreCalled() throws Exception { - ActionProxy proxy = actionProxyFactory.createActionProxy("package", "action", new HashMap(), false, true); + ActionProxy proxy = actionProxyFactory.createActionProxy("package", "action", new HashMap(), false, true); ActionInvocation invocation = proxy.getInvocation(); Mock preResultListenerMock1 = new Mock(PreResultListener.class); preResultListenerMock1.expect("beforeResult", C.args(C.eq(invocation), C.eq(Action.SUCCESS))); @@ -51,7 +51,7 @@ public class PreResultListenerTest extends XWorkTestCase { } public void testPreResultListenersAreCalledInOrder() throws Exception { - ActionProxy proxy = actionProxyFactory.createActionProxy("package", "action", new HashMap(), false, true); + ActionProxy proxy = actionProxyFactory.createActionProxy("package", "action", new HashMap(), false, true); ActionInvocation invocation = proxy.getInvocation(); CountPreResultListener listener1 = new CountPreResultListener(); CountPreResultListener listener2 = new CountPreResultListener(); @@ -60,7 +60,7 @@ public class PreResultListenerTest extends XWorkTestCase { proxy.execute(); assertNotNull(listener1.getMyOrder()); assertNotNull(listener2.getMyOrder()); - assertEquals(listener1.getMyOrder().intValue() + 1, listener2.getMyOrder().intValue()); + assertEquals(listener1.getMyOrder() + 1, listener2.getMyOrder().intValue()); } @Override @@ -113,7 +113,7 @@ public class PreResultListenerTest extends XWorkTestCase { } public void beforeResult(ActionInvocation invocation, String resultCode) { - myOrder = new Integer(count++); + myOrder = count++; } } } http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/ScopedModelDrivenInterceptorTest.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/ScopedModelDrivenInterceptorTest.java b/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/ScopedModelDrivenInterceptorTest.java index 959a768..1a5a81e 100644 --- a/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/ScopedModelDrivenInterceptorTest.java +++ b/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/ScopedModelDrivenInterceptorTest.java @@ -41,7 +41,7 @@ public class ScopedModelDrivenInterceptorTest extends XWorkTestCase { public void testResolveModel() throws Exception { ActionContext ctx = ActionContext.getContext(); - ctx.setSession(new HashMap()); + ctx.setSession(new HashMap()); ObjectFactory factory = ObjectFactory.getObjectFactory(); Object obj = inter.resolveModel(factory, ctx, "java.lang.String", "request", "foo"); http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/ValidationInterceptorPrefixMethodInvocationTest.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/ValidationInterceptorPrefixMethodInvocationTest.java b/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/ValidationInterceptorPrefixMethodInvocationTest.java index f269d90..8add1d6 100644 --- a/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/ValidationInterceptorPrefixMethodInvocationTest.java +++ b/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/ValidationInterceptorPrefixMethodInvocationTest.java @@ -16,13 +16,11 @@ package com.opensymphony.xwork2.interceptor; import com.opensymphony.xwork2.*; -import com.opensymphony.xwork2.config.entities.InterceptorConfig; import com.opensymphony.xwork2.config.entities.ActionConfig; +import com.opensymphony.xwork2.config.entities.InterceptorConfig; import com.opensymphony.xwork2.validator.ValidationInterceptor; -import org.easymock.MockControl; import org.easymock.EasyMock; import org.easymock.IAnswer; -import org.easymock.IMocksControl; import java.util.HashMap; @@ -63,8 +61,8 @@ public class ValidationInterceptorPrefixMethodInvocationTest extends XWorkTestCa protected ValidationInterceptor create() { ObjectFactory objectFactory = container.getInstance(ObjectFactory.class); return (ValidationInterceptor) objectFactory.buildInterceptor( - new InterceptorConfig.Builder("model", ValidationInterceptor.class.getName()).build(), new HashMap()); - } + new InterceptorConfig.Builder("model", ValidationInterceptor.class.getName()).build(), new HashMap()); + } private interface ValidateAction extends Action, Validateable, ValidationAware { void validateDoSave(); http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/annotations/AllowingByDefaultModel.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/annotations/AllowingByDefaultModel.java b/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/annotations/AllowingByDefaultModel.java index a357101..e315577 100644 --- a/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/annotations/AllowingByDefaultModel.java +++ b/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/annotations/AllowingByDefaultModel.java @@ -1,6 +1,5 @@ package com.opensymphony.xwork2.interceptor.annotations; -import com.opensymphony.xwork2.ActionSupport; /** * @author jafl http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/annotations/AnnotationParameterFilterUnitTest.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/annotations/AnnotationParameterFilterUnitTest.java b/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/annotations/AnnotationParameterFilterUnitTest.java index abdfd4e..d1ea4ca 100644 --- a/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/annotations/AnnotationParameterFilterUnitTest.java +++ b/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/annotations/AnnotationParameterFilterUnitTest.java @@ -32,9 +32,9 @@ public class AnnotationParameterFilterUnitTest extends TestCase { * @throws Exception */ public void testBlockingByDefault() throws Exception { - - Map contextMap = new HashMap(); - Map parameterMap = new HashMap(); + + Map contextMap = new HashMap<>(); + Map parameterMap = new HashMap<>(); parameterMap.put("job", "Baker"); parameterMap.put("name", "Martin"); @@ -54,8 +54,8 @@ public class AnnotationParameterFilterUnitTest extends TestCase { AnnotationParameterFilterIntereptor intereptor = new AnnotationParameterFilterIntereptor(); intereptor.intercept(invocation); - - assertEquals("Paramter map should contain one entry", 1, parameterMap.size()); + + assertEquals("Parameter map should contain one entry", 1, parameterMap.size()); assertNull(parameterMap.get("job")); assertNotNull(parameterMap.get("name")); @@ -67,9 +67,9 @@ public class AnnotationParameterFilterUnitTest extends TestCase { * @throws Exception */ public void testAllowingByDefault() throws Exception { - - Map contextMap = new HashMap(); - Map parameterMap = new HashMap(); + + Map contextMap = new HashMap<>(); + Map parameterMap = new HashMap<>(); parameterMap.put("job", "Baker"); parameterMap.put("name", "Martin"); @@ -102,9 +102,9 @@ public class AnnotationParameterFilterUnitTest extends TestCase { * @throws Exception */ public void testBlockingByDefaultWithModel() throws Exception { - - Map contextMap = new HashMap(); - Map parameterMap = new HashMap(); + + Map contextMap = new HashMap<>(); + Map parameterMap = new HashMap<>(); parameterMap.put("job", "Baker"); parameterMap.put("name", "Martin"); @@ -139,9 +139,9 @@ public class AnnotationParameterFilterUnitTest extends TestCase { * @throws Exception */ public void testAllowingByDefaultWithModel() throws Exception { - - Map contextMap = new HashMap(); - Map parameterMap = new HashMap(); + + Map contextMap = new HashMap<>(); + Map parameterMap = new HashMap<>(); parameterMap.put("job", "Baker"); parameterMap.put("name", "Martin"); http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/annotations/AnnotationWorkflowInterceptorTest.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/annotations/AnnotationWorkflowInterceptorTest.java b/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/annotations/AnnotationWorkflowInterceptorTest.java index f5683a8..e8b8d4f 100644 --- a/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/annotations/AnnotationWorkflowInterceptorTest.java +++ b/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/annotations/AnnotationWorkflowInterceptorTest.java @@ -28,7 +28,7 @@ import com.opensymphony.xwork2.inject.ContainerBuilder; import com.opensymphony.xwork2.mock.MockResult; import com.opensymphony.xwork2.util.location.LocatableProperties; -import java.util.Arrays; +import java.util.Collections; /** * @author Zsolt Szasz, zsolt at lorecraft dot com @@ -87,11 +87,11 @@ public class AnnotationWorkflowInterceptorTest extends XWorkTestCase { public void loadPackages() throws ConfigurationException { PackageConfig packageConfig = new PackageConfig.Builder("default") .addActionConfig(ANNOTATED_ACTION, new ActionConfig.Builder("defaultPackage", ANNOTATED_ACTION, AnnotatedAction.class.getName()) - .addInterceptors(Arrays.asList(new InterceptorMapping[]{ new InterceptorMapping("annotationWorkflow", annotationWorkflow) })) + .addInterceptors(Collections.singletonList(new InterceptorMapping("annotationWorkflow", annotationWorkflow))) .addResultConfig(new ResultConfig.Builder("success", MockResult.class.getName()).build()) .build()) .addActionConfig(SHORTCIRCUITED_ACTION, new ActionConfig.Builder("defaultPackage", SHORTCIRCUITED_ACTION, ShortcircuitedAction.class.getName()) - .addInterceptors(Arrays.asList(new InterceptorMapping[]{ new InterceptorMapping("annotationWorkflow", annotationWorkflow) })) + .addInterceptors(Collections.singletonList(new InterceptorMapping("annotationWorkflow", annotationWorkflow))) .addResultConfig(new ResultConfig.Builder("shortcircuit", MockResult.class.getName()).build()) .build()) .build(); http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/test/java/com/opensymphony/xwork2/security/DefaultExcludedPatternsCheckerTest.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/security/DefaultExcludedPatternsCheckerTest.java b/xwork-core/src/test/java/com/opensymphony/xwork2/security/DefaultExcludedPatternsCheckerTest.java index 22e4a73..367e199 100644 --- a/xwork-core/src/test/java/com/opensymphony/xwork2/security/DefaultExcludedPatternsCheckerTest.java +++ b/xwork-core/src/test/java/com/opensymphony/xwork2/security/DefaultExcludedPatternsCheckerTest.java @@ -67,7 +67,7 @@ public class DefaultExcludedPatternsCheckerTest extends XWorkTestCase { public void testParamWithClassInName() throws Exception { // given - List properParams = new ArrayList(); + List properParams = new ArrayList<>(); properParams.add("eventClass"); properParams.add("form.eventClass"); properParams.add("form[\"eventClass\"]"); @@ -88,7 +88,7 @@ public class DefaultExcludedPatternsCheckerTest extends XWorkTestCase { public void testStrutsTokenIsExcluded() throws Exception { // given - List tokens = new ArrayList(); + List tokens = new ArrayList<>(); tokens.add("struts.token.name"); tokens.add("struts.token"); http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/test/java/com/opensymphony/xwork2/spring/SpringObjectFactoryTest.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/spring/SpringObjectFactoryTest.java b/xwork-core/src/test/java/com/opensymphony/xwork2/spring/SpringObjectFactoryTest.java index ea39a12..6aa6f7b 100644 --- a/xwork-core/src/test/java/com/opensymphony/xwork2/spring/SpringObjectFactoryTest.java +++ b/xwork-core/src/test/java/com/opensymphony/xwork2/spring/SpringObjectFactoryTest.java @@ -19,15 +19,7 @@ package com.opensymphony.xwork2.spring; * Created on Mar 8, 2004 */ -import com.opensymphony.xwork2.Action; -import com.opensymphony.xwork2.ActionChainResult; -import com.opensymphony.xwork2.ActionContext; -import com.opensymphony.xwork2.ModelDrivenAction; -import com.opensymphony.xwork2.ObjectFactory; -import com.opensymphony.xwork2.Result; -import com.opensymphony.xwork2.SimpleAction; -import com.opensymphony.xwork2.TestBean; -import com.opensymphony.xwork2.XWorkTestCase; +import com.opensymphony.xwork2.*; import com.opensymphony.xwork2.config.ConfigurationException; import com.opensymphony.xwork2.config.entities.ActionConfig; import com.opensymphony.xwork2.config.entities.InterceptorConfig; @@ -115,7 +107,7 @@ public class SpringObjectFactoryTest extends XWorkTestCase { } public void testFallsBackToDefaultObjectFactoryValidatorBuilding() throws Exception { - Map extraContext = new HashMap(); + Map extraContext = new HashMap<>(); Validator validator = objectFactory.buildValidator(RequiredStringValidator.class.getName(), new HashMap(), extraContext); assertEquals(RequiredStringValidator.class, validator.getClass()); @@ -152,7 +144,7 @@ public class SpringObjectFactoryTest extends XWorkTestCase { public void testObtainValidatorBySpringName() throws Exception { sac.registerPrototype("expression-validator", ExpressionValidator.class, new MutablePropertyValues()); - Map extraContext = new HashMap(); + Map extraContext = new HashMap<>(); Validator validator = objectFactory.buildValidator("expression-validator", new HashMap(), extraContext); assertEquals(ExpressionValidator.class, validator.getClass()); http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/test/java/com/opensymphony/xwork2/spring/interceptor/ActionAutowiringInterceptorTest.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/spring/interceptor/ActionAutowiringInterceptorTest.java b/xwork-core/src/test/java/com/opensymphony/xwork2/spring/interceptor/ActionAutowiringInterceptorTest.java index 1465ad3..b399edf 100644 --- a/xwork-core/src/test/java/com/opensymphony/xwork2/spring/interceptor/ActionAutowiringInterceptorTest.java +++ b/xwork-core/src/test/java/com/opensymphony/xwork2/spring/interceptor/ActionAutowiringInterceptorTest.java @@ -62,10 +62,10 @@ public class ActionAutowiringInterceptorTest extends XWorkTestCase { } protected void loadSpringApplicationContextIntoApplication(ApplicationContext appContext) { - Map application = new HashMap(); + Map application = new HashMap<>(); application.put(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, appContext); - Map context = new HashMap(); + Map context = new HashMap<>(); context.put(ActionContext.APPLICATION, application); ActionContext actionContext = new ActionContext(context); ActionContext.setContext(actionContext); @@ -90,7 +90,7 @@ public class ActionAutowiringInterceptorTest extends XWorkTestCase { } public void testIfApplicationContextIsNullThenBeanWillNotBeWiredUp() throws Exception { - Map context = new HashMap(); + Map context = new HashMap<>(); context.put(ActionContext.APPLICATION, new HashMap()); ActionContext actionContext = new ActionContext(context); ActionContext.setContext(actionContext); http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/test/java/com/opensymphony/xwork2/util/ClassLoaderUtilTest.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/util/ClassLoaderUtilTest.java b/xwork-core/src/test/java/com/opensymphony/xwork2/util/ClassLoaderUtilTest.java index a179da9..2439bf3 100644 --- a/xwork-core/src/test/java/com/opensymphony/xwork2/util/ClassLoaderUtilTest.java +++ b/xwork-core/src/test/java/com/opensymphony/xwork2/util/ClassLoaderUtilTest.java @@ -19,9 +19,9 @@ import junit.framework.TestCase; import java.io.IOException; import java.net.URL; -import java.util.Iterator; import java.util.Arrays; import java.util.Enumeration; +import java.util.Iterator; public class ClassLoaderUtilTest extends TestCase { @@ -79,26 +79,26 @@ public class ClassLoaderUtilTest extends TestCase { } public void testAggregateIterator() { - ClassLoaderUtil.AggregateIterator aggr = new ClassLoaderUtil.AggregateIterator(); + ClassLoaderUtil.AggregateIterator aggr = new ClassLoaderUtil.AggregateIterator<>(); - Enumeration en1 = new Enumeration() { - private Iterator itt = Arrays.asList("str1", "str1", "str3", "str1").iterator(); + Enumeration en1 = new Enumeration() { + private Iterator itt = Arrays.asList("str1", "str1", "str3", "str1").iterator(); public boolean hasMoreElements() { return itt.hasNext(); } - public Object nextElement() { + public String nextElement() { return itt.next(); } }; - Enumeration en2 = new Enumeration() { - private Iterator itt = Arrays.asList("str4", "str5").iterator(); + Enumeration en2 = new Enumeration() { + private Iterator itt = Arrays.asList("str4", "str5").iterator(); public boolean hasMoreElements() { return itt.hasNext(); } - public Object nextElement() { + public String nextElement() { return itt.next(); } }; http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/test/java/com/opensymphony/xwork2/util/Indexed.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/util/Indexed.java b/xwork-core/src/test/java/com/opensymphony/xwork2/util/Indexed.java index 70b2492..15c6193 100644 --- a/xwork-core/src/test/java/com/opensymphony/xwork2/util/Indexed.java +++ b/xwork-core/src/test/java/com/opensymphony/xwork2/util/Indexed.java @@ -10,7 +10,7 @@ import java.util.Map; public class Indexed { public Object[] values = new Object[3]; - public Map map = new HashMap(); + public Map map = new HashMap<>(); public void setSimple(int i, Object v) { values[i] = v; http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/test/java/com/opensymphony/xwork2/util/MyBeanActionTest.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/util/MyBeanActionTest.java b/xwork-core/src/test/java/com/opensymphony/xwork2/util/MyBeanActionTest.java index 9552236..9289de6 100644 --- a/xwork-core/src/test/java/com/opensymphony/xwork2/util/MyBeanActionTest.java +++ b/xwork-core/src/test/java/com/opensymphony/xwork2/util/MyBeanActionTest.java @@ -31,11 +31,11 @@ import java.util.Map; public class MyBeanActionTest extends XWorkTestCase { public void testIndexedList() { - HashMap params = new HashMap(); + HashMap params = new HashMap<>(); params.put("beanList(1234567890).name", "This is the bla bean"); params.put("beanList(1234567891).name", "This is the 2nd bla bean"); - HashMap extraContext = new HashMap(); + HashMap extraContext = new HashMap<>(); extraContext.put(ActionContext.PARAMETERS, params); try { @@ -56,14 +56,14 @@ public class MyBeanActionTest extends XWorkTestCase { } public void testIndexedMap() { - HashMap params = new HashMap(); + HashMap params = new HashMap<>(); params.put("beanMap[1234567890].id", "1234567890"); params.put("beanMap[1234567891].id", "1234567891"); params.put("beanMap[1234567890].name", "This is the bla bean"); params.put("beanMap[1234567891].name", "This is the 2nd bla bean"); - HashMap extraContext = new HashMap(); + HashMap extraContext = new HashMap<>(); extraContext.put(ActionContext.PARAMETERS, params); try { @@ -74,8 +74,8 @@ public class MyBeanActionTest extends XWorkTestCase { assertEquals(2, Integer.parseInt(proxy.getInvocation().getStack().findValue("beanMap.size").toString())); Map map = (Map) proxy.getInvocation().getStack().findValue("beanMap"); - assertEquals(true, action.getBeanMap().containsKey(new Long(1234567890))); - assertEquals(true, action.getBeanMap().containsKey(new Long(1234567891))); + assertEquals(true, action.getBeanMap().containsKey(1234567890L)); + assertEquals(true, action.getBeanMap().containsKey(1234567891L)); assertEquals(MyBean.class.getName(), proxy.getInvocation().getStack().findValue("beanMap.get(1234567890L)").getClass().getName()); http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/test/java/com/opensymphony/xwork2/util/NamedVariablePatternMatcherTest.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/util/NamedVariablePatternMatcherTest.java b/xwork-core/src/test/java/com/opensymphony/xwork2/util/NamedVariablePatternMatcherTest.java index 3e284e5..b659731 100644 --- a/xwork-core/src/test/java/com/opensymphony/xwork2/util/NamedVariablePatternMatcherTest.java +++ b/xwork-core/src/test/java/com/opensymphony/xwork2/util/NamedVariablePatternMatcherTest.java @@ -15,19 +15,15 @@ */ package com.opensymphony.xwork2.util; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import com.opensymphony.xwork2.util.NamedVariablePatternMatcher.CompiledPattern; +import org.junit.Test; import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.regex.Pattern; -import org.junit.Test; - -import com.opensymphony.xwork2.util.NamedVariablePatternMatcher.CompiledPattern; +import static org.junit.Assert.*; public class NamedVariablePatternMatcherTest { @@ -64,7 +60,7 @@ public class NamedVariablePatternMatcherTest { public void testMatch() { NamedVariablePatternMatcher matcher = new NamedVariablePatternMatcher(); - Map vars = new HashMap(); + Map vars = new HashMap<>(); CompiledPattern pattern = new CompiledPattern(Pattern.compile("foo([^/]+)"), Arrays.asList("bar")); assertTrue(matcher.match(vars, "foobaz", pattern)); http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/test/java/com/opensymphony/xwork2/util/ResolverUtilTest.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/util/ResolverUtilTest.java b/xwork-core/src/test/java/com/opensymphony/xwork2/util/ResolverUtilTest.java index be9774f..791abe7 100644 --- a/xwork-core/src/test/java/com/opensymphony/xwork2/util/ResolverUtilTest.java +++ b/xwork-core/src/test/java/com/opensymphony/xwork2/util/ResolverUtilTest.java @@ -25,7 +25,7 @@ import java.util.Set; public class ResolverUtilTest extends TestCase { public void testSimpleFind() throws Exception { - ResolverUtil resolver = new ResolverUtil(); + ResolverUtil resolver = new ResolverUtil<>(); resolver.findImplementations(ObjectFactory.class, "com"); Set> impls = resolver.getClasses(); @@ -34,7 +34,7 @@ public class ResolverUtilTest extends TestCase { } public void testMissingSomeFind() throws Exception { - ResolverUtil resolver = new ResolverUtil(); + ResolverUtil resolver = new ResolverUtil<>(); resolver.findImplementations(ObjectFactory.class, "com.opensymphony.xwork2.spring"); Set> impls = resolver.getClasses(); http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/test/java/com/opensymphony/xwork2/util/TextParseUtilTest.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/util/TextParseUtilTest.java b/xwork-core/src/test/java/com/opensymphony/xwork2/util/TextParseUtilTest.java index a624a10..b6f68d4 100644 --- a/xwork-core/src/test/java/com/opensymphony/xwork2/util/TextParseUtilTest.java +++ b/xwork-core/src/test/java/com/opensymphony/xwork2/util/TextParseUtilTest.java @@ -15,18 +15,11 @@ */ package com.opensymphony.xwork2.util; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; - -import org.junit.Assert; - import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.XWorkTestCase; +import org.junit.Assert; + +import java.util.*; /** * Unit test of {@link TextParseUtil}. @@ -49,8 +42,8 @@ public class TextParseUtilTest extends XWorkTestCase { TextParseUtil.ParsedValueEvaluator evaluator = new TextParseUtil.ParsedValueEvaluator() { public Object evaluate(String parsedValue) { - return parsedValue.toString()+"Something"; - } + return parsedValue + "Something"; + } }; String result = TextParseUtil.translateVariables("Hello ${myVariable}", stack, evaluator); @@ -125,7 +118,7 @@ public class TextParseUtilTest extends XWorkTestCase { public void testCommaDelimitedStringToSet() { assertEquals(0, TextParseUtil.commaDelimitedStringToSet("").size()); - assertEquals(new HashSet(Arrays.asList("foo", "bar", "tee")), + assertEquals(new HashSet<>(Arrays.asList("foo", "bar", "tee")), TextParseUtil.commaDelimitedStringToSet(" foo, bar,tee")); } http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/test/java/com/opensymphony/xwork2/util/URLUtilTest.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/util/URLUtilTest.java b/xwork-core/src/test/java/com/opensymphony/xwork2/util/URLUtilTest.java index e359640..e0c0096 100644 --- a/xwork-core/src/test/java/com/opensymphony/xwork2/util/URLUtilTest.java +++ b/xwork-core/src/test/java/com/opensymphony/xwork2/util/URLUtilTest.java @@ -5,11 +5,7 @@ import com.opensymphony.xwork2.util.fs.DefaultFileManager; import junit.framework.TestCase; import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; -import java.net.URLStreamHandler; -import java.net.URLStreamHandlerFactory; +import java.net.*; public class URLUtilTest extends TestCase { @@ -151,6 +147,8 @@ public class URLUtilTest extends TestCase { assertEquals(false, URLUtil.verifyUrl("")); assertEquals(false, URLUtil.verifyUrl(" ")); assertEquals(false, URLUtil.verifyUrl("no url")); + assertEquals(false, URLUtil.verifyUrl("http://no url")); + assertEquals(false, URLUtil.verifyUrl("https://no url")); assertEquals(true, URLUtil.verifyUrl("http://www.opensymphony.com")); assertEquals(true, URLUtil.verifyUrl("https://www.opensymphony.com")); http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/test/java/com/opensymphony/xwork2/util/WildcardHelperTest.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/util/WildcardHelperTest.java b/xwork-core/src/test/java/com/opensymphony/xwork2/util/WildcardHelperTest.java index 16d3a7d..6cbd6d2 100644 --- a/xwork-core/src/test/java/com/opensymphony/xwork2/util/WildcardHelperTest.java +++ b/xwork-core/src/test/java/com/opensymphony/xwork2/util/WildcardHelperTest.java @@ -26,7 +26,7 @@ public class WildcardHelperTest extends XWorkTestCase { public void testMatch() { WildcardHelper wild = new WildcardHelper(); - HashMap matchedPatterns = new HashMap(); + HashMap matchedPatterns = new HashMap<>(); int[] pattern = wild.compilePattern("wes-rules"); assertEquals(wild.match(matchedPatterns,"wes-rules", pattern), true); assertEquals(wild.match(matchedPatterns, "rules-wes", pattern), false); http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/test/java/com/opensymphony/xwork2/util/WildcardUtilTest.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/util/WildcardUtilTest.java b/xwork-core/src/test/java/com/opensymphony/xwork2/util/WildcardUtilTest.java index 14fa012..79bb924 100644 --- a/xwork-core/src/test/java/com/opensymphony/xwork2/util/WildcardUtilTest.java +++ b/xwork-core/src/test/java/com/opensymphony/xwork2/util/WildcardUtilTest.java @@ -20,7 +20,6 @@ package com.opensymphony.xwork2.util; import com.opensymphony.xwork2.XWorkTestCase; import java.util.regex.Pattern; -import java.util.regex.Matcher; public class WildcardUtilTest extends XWorkTestCase { http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/test/java/com/opensymphony/xwork2/util/XWorkListTest.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/util/XWorkListTest.java b/xwork-core/src/test/java/com/opensymphony/xwork2/util/XWorkListTest.java index d2aea36..412673f 100644 --- a/xwork-core/src/test/java/com/opensymphony/xwork2/util/XWorkListTest.java +++ b/xwork-core/src/test/java/com/opensymphony/xwork2/util/XWorkListTest.java @@ -32,7 +32,7 @@ public class XWorkListTest extends XWorkTestCase { xworkList.add(new String[]{"a"}); xworkList.add("b"); - ArrayList addList = new ArrayList(); + ArrayList addList = new ArrayList<>(); addList.add(new String[]{"1"}); addList.add(new String[]{"2"}); addList.add(new String[]{"3"}); @@ -52,7 +52,7 @@ public class XWorkListTest extends XWorkTestCase { xworkList.add(new String[]{"a"}); xworkList.add("b"); - addList = new ArrayList(); + addList = new ArrayList<>(); addList.add(new String[]{"1"}); addList.add(new String[]{"2"}); addList.add(new String[]{"3"}); @@ -70,7 +70,7 @@ public class XWorkListTest extends XWorkTestCase { xworkList.add(new String[]{"a"}); xworkList.add("b"); - addList = new ArrayList(); + addList = new ArrayList<>(); addList.add(new String[]{"1"}); addList.add(new String[]{"2"}); addList.add(new String[]{"3"}); http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/test/java/com/opensymphony/xwork2/validator/ConversionErrorFieldValidatorTest.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/validator/ConversionErrorFieldValidatorTest.java b/xwork-core/src/test/java/com/opensymphony/xwork2/validator/ConversionErrorFieldValidatorTest.java index 9faec48..ab22d48 100644 --- a/xwork-core/src/test/java/com/opensymphony/xwork2/validator/ConversionErrorFieldValidatorTest.java +++ b/xwork-core/src/test/java/com/opensymphony/xwork2/validator/ConversionErrorFieldValidatorTest.java @@ -48,7 +48,7 @@ public class ConversionErrorFieldValidatorTest extends XWorkTestCase { ValueStack stack = ActionContext.getContext().getValueStack(); ActionContext context = new ActionContext(stack.getContext()); - Map conversionErrors = new HashMap(); + Map conversionErrors = new HashMap<>(); conversionErrors.put("foo", "bar"); context.setConversionErrors(conversionErrors); validator = new ConversionErrorFieldValidator(); http://git-wip-us.apache.org/repos/asf/struts/blob/2e9df577/xwork-core/src/test/java/com/opensymphony/xwork2/validator/DateRangeValidatorTest.java ---------------------------------------------------------------------- diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/validator/DateRangeValidatorTest.java b/xwork-core/src/test/java/com/opensymphony/xwork2/validator/DateRangeValidatorTest.java index 316f414..a937292 100644 --- a/xwork-core/src/test/java/com/opensymphony/xwork2/validator/DateRangeValidatorTest.java +++ b/xwork-core/src/test/java/com/opensymphony/xwork2/validator/DateRangeValidatorTest.java @@ -22,12 +22,7 @@ import com.opensymphony.xwork2.XWorkTestCase; import com.opensymphony.xwork2.config.providers.MockConfigurationProvider; import com.opensymphony.xwork2.validator.validators.DateRangeFieldValidator; -import java.util.Calendar; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; +import java.util.*; /** @@ -45,8 +40,8 @@ public class DateRangeValidatorTest extends XWorkTestCase { public void testRangeValidation() throws Exception { Calendar date = Calendar.getInstance(); date.set(2002, Calendar.NOVEMBER, 20); - Map context = new HashMap(); - HashMap params = new HashMap(); + Map context = new HashMap<>(); + HashMap params = new HashMap<>(); params.put("date", date.getTime()); context.put(ActionContext.PARAMETERS, params);