diff --git a/spring-core/src/main/java/org/springframework/core/env/SimpleCommandLineArgsParser.java b/spring-core/src/main/java/org/springframework/core/env/SimpleCommandLineArgsParser.java index e03f3cc7974..e2c57def919 100644 --- a/spring-core/src/main/java/org/springframework/core/env/SimpleCommandLineArgsParser.java +++ b/spring-core/src/main/java/org/springframework/core/env/SimpleCommandLineArgsParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 the original author or authors. + * Copyright 2002-2020 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. @@ -66,7 +66,7 @@ class SimpleCommandLineArgsParser { String optionValue = null; if (optionText.contains("=")) { optionName = optionText.substring(0, optionText.indexOf('=')); - optionValue = optionText.substring(optionText.indexOf('=')+1, optionText.length()); + optionValue = optionText.substring(optionText.indexOf('=') + 1, optionText.length()); } else { optionName = optionText; diff --git a/spring-core/src/test/java/org/springframework/core/env/JOptCommandLinePropertySourceTests.java b/spring-core/src/test/java/org/springframework/core/env/JOptCommandLinePropertySourceTests.java index 252f11157e2..b2b4063557a 100644 --- a/spring-core/src/test/java/org/springframework/core/env/JOptCommandLinePropertySourceTests.java +++ b/spring-core/src/test/java/org/springframework/core/env/JOptCommandLinePropertySourceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -39,7 +39,7 @@ class JOptCommandLinePropertySourceTests { OptionSet options = parser.parse("--foo=bar"); PropertySource ps = new JOptCommandLinePropertySource(options); - assertThat((String)ps.getProperty("foo")).isEqualTo("bar"); + assertThat(ps.getProperty("foo")).isEqualTo("bar"); } @Test @@ -50,7 +50,7 @@ class JOptCommandLinePropertySourceTests { PropertySource ps = new JOptCommandLinePropertySource(options); assertThat(ps.containsProperty("foo")).isTrue(); - assertThat((String)ps.getProperty("foo")).isEqualTo(""); + assertThat(ps.getProperty("foo")).isEqualTo(""); } @Test @@ -63,7 +63,7 @@ class JOptCommandLinePropertySourceTests { PropertySource ps = new JOptCommandLinePropertySource(options); assertThat(ps.containsProperty("o1")).isTrue(); assertThat(ps.containsProperty("o2")).isFalse(); - assertThat((String)ps.getProperty("o1")).isEqualTo(""); + assertThat(ps.getProperty("o1")).isEqualTo(""); assertThat(ps.getProperty("o2")).isNull(); } @@ -138,8 +138,7 @@ class JOptCommandLinePropertySourceTests { assertThat(ps.containsProperty("o1")).isTrue(); assertThat(ps.containsProperty("o2")).isTrue(); - String nonOptionArgs = (String)ps.getProperty("nonOptionArgs"); - assertThat(nonOptionArgs).isEqualTo("noa1,noa2"); + assertThat(ps.getProperty("nonOptionArgs")).isEqualTo("noa1,noa2"); } @Test @@ -169,7 +168,8 @@ class JOptCommandLinePropertySourceTests { assertThat(ps.getProperty("o1")).isEqualTo("VAL_1"); } - public static enum OptionEnum { + public enum OptionEnum { VAL_1; } + } diff --git a/spring-core/src/test/java/org/springframework/core/env/SimpleCommandLinePropertySourceTests.java b/spring-core/src/test/java/org/springframework/core/env/SimpleCommandLinePropertySourceTests.java index 8d18f609a56..4d4ac70d157 100644 --- a/spring-core/src/test/java/org/springframework/core/env/SimpleCommandLinePropertySourceTests.java +++ b/spring-core/src/test/java/org/springframework/core/env/SimpleCommandLinePropertySourceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -33,8 +33,7 @@ class SimpleCommandLinePropertySourceTests { @Test void withDefaultName() { PropertySource ps = new SimpleCommandLinePropertySource(); - assertThat(ps.getName()) - .isEqualTo(CommandLinePropertySource.COMMAND_LINE_PROPERTY_SOURCE_NAME); + assertThat(ps.getName()).isEqualTo(CommandLinePropertySource.COMMAND_LINE_PROPERTY_SOURCE_NAME); } @Test @@ -52,8 +51,7 @@ class SimpleCommandLinePropertySourceTests { @Test void withOptionArgsOnly() { - CommandLinePropertySource ps = - new SimpleCommandLinePropertySource("--o1=v1", "--o2"); + CommandLinePropertySource ps = new SimpleCommandLinePropertySource("--o1=v1", "--o2"); assertThat(ps.containsProperty("o1")).isTrue(); assertThat(ps.containsProperty("o2")).isTrue(); assertThat(ps.containsProperty("o3")).isFalse(); @@ -77,8 +75,7 @@ class SimpleCommandLinePropertySourceTests { @Test void withDefaultNonOptionArgsNameAndNonOptionArgsPresent() { - CommandLinePropertySource ps = - new SimpleCommandLinePropertySource("--o1=v1", "noa1", "--o2", "noa2"); + CommandLinePropertySource ps = new SimpleCommandLinePropertySource("--o1=v1", "noa1", "--o2", "noa2"); assertThat(ps.containsProperty("nonOptionArgs")).isTrue(); assertThat(ps.containsProperty("o1")).isTrue(); @@ -90,8 +87,7 @@ class SimpleCommandLinePropertySourceTests { @Test void withCustomNonOptionArgsNameAndNoNonOptionArgsPresent() { - CommandLinePropertySource ps = - new SimpleCommandLinePropertySource("--o1=v1", "noa1", "--o2", "noa2"); + CommandLinePropertySource ps = new SimpleCommandLinePropertySource("--o1=v1", "noa1", "--o2", "noa2"); ps.setNonOptionArgsPropertyName("NOA"); assertThat(ps.containsProperty("nonOptionArgs")).isFalse(); @@ -104,8 +100,7 @@ class SimpleCommandLinePropertySourceTests { @Test void covertNonOptionArgsToStringArrayAndList() { - CommandLinePropertySource ps = - new SimpleCommandLinePropertySource("--o1=v1", "noa1", "--o2", "noa2"); + CommandLinePropertySource ps = new SimpleCommandLinePropertySource("--o1=v1", "noa1", "--o2", "noa2"); StandardEnvironment env = new StandardEnvironment(); env.getPropertySources().addFirst(ps);