Polishing
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user