From 19e77cd140d6efd2736a43b8688a8a3ffb6f2a7b Mon Sep 17 00:00:00 2001 From: Philippe Marschall Date: Sat, 31 Dec 2016 11:14:14 +0100 Subject: [PATCH] Remove use of Boolean constructors Codacy warns us that there are several references to Boolean constructors in the tests. Direct usage of the Boolean constructor is discouraged and even deprecated in Java 9 [1]. Boolean constructor use can easily be replaced with the constant instances. This commit contains the following changes: - replace references to Boolean constructors with boolean constants in JSP tag tests - update the copyright year where necessary - BooleanComparatorTests is intentionally left unchanged as it should also work with the non-constant instances correctly [1] http://download.java.net/java/jdk9/docs/api/java/lang/Boolean.html#Boolean-boolean- Issue: SPR-15076 --- .../web/servlet/tags/form/CheckboxTagTests.java | 4 ++-- .../web/servlet/tags/form/CheckboxesTagTests.java | 4 ++-- .../web/servlet/tags/form/RadioButtonsTagTests.java | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/CheckboxTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/CheckboxTagTests.java index e8fe9c6dac..f5c8addcda 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/CheckboxTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/CheckboxTagTests.java @@ -164,7 +164,7 @@ public class CheckboxTagTests extends AbstractFormTagTests { @Test public void withSingleValueBooleanObjectUnchecked() throws Exception { - this.bean.setSomeBoolean(new Boolean(false)); + this.bean.setSomeBoolean(Boolean.FALSE); this.tag.setPath("someBoolean"); int result = this.tag.doStartTag(); assertEquals(Tag.SKIP_BODY, result); @@ -692,7 +692,7 @@ public class CheckboxTagTests extends AbstractFormTagTests { this.bean.setDate(getDate()); this.bean.setName("Rob Harrop"); this.bean.setJedi(true); - this.bean.setSomeBoolean(new Boolean(true)); + this.bean.setSomeBoolean(Boolean.TRUE); this.bean.setStringArray(new String[] {"bar", "foo"}); this.bean.setSomeIntegerArray(new Integer[] {new Integer(2), new Integer(1)}); this.bean.setOtherColours(colours); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/CheckboxesTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/CheckboxesTagTests.java index 6ec93354c8..ace4220a93 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/CheckboxesTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/CheckboxesTagTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -773,7 +773,7 @@ public class CheckboxesTagTests extends AbstractFormTagTests { this.bean.setDate(getDate()); this.bean.setName("Rob Harrop"); this.bean.setJedi(true); - this.bean.setSomeBoolean(new Boolean(true)); + this.bean.setSomeBoolean(Boolean.TRUE); this.bean.setStringArray(new String[] {"bar", "foo"}); this.bean.setSomeIntegerArray(new Integer[] {new Integer(2), new Integer(1)}); this.bean.setOtherColours(colours); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/RadioButtonsTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/RadioButtonsTagTests.java index 13971094ec..927c4a27f7 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/RadioButtonsTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/RadioButtonsTagTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -620,7 +620,7 @@ public class RadioButtonsTagTests extends AbstractFormTagTests { this.bean.setDate(getDate()); this.bean.setName("Rob Harrop"); this.bean.setJedi(true); - this.bean.setSomeBoolean(new Boolean(true)); + this.bean.setSomeBoolean(Boolean.TRUE); this.bean.setStringArray(new String[] {"bar", "foo"}); this.bean.setSomeIntegerArray(new Integer[] {new Integer(2), new Integer(1)}); this.bean.setOtherColours(colours);