This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-configuration.git
The following commit(s) were added to refs/heads/master by this push:
new 36b274f7 Fix some Checkstyle issues in tests
36b274f7 is described below
commit 36b274f71ef87390192954224848d7fe006f4a85
Author: Gary Gregory <[email protected]>
AuthorDate: Sun May 5 12:22:14 2024 -0400
Fix some Checkstyle issues in tests
- Whitespace
---
pom.xml | 1 +
src/conf/checkstyle-suppressions.xml | 50 +++++-----
.../configuration2/ConfigurationAssert.java | 7 +-
.../DatabaseConfigurationTestHelper.java | 9 +-
.../configuration2/InterpolationTestHelper.java | 7 +-
.../TestAbstractConfigurationBasicFeatures.java | 3 +-
.../configuration2/TestBaseConfiguration.java | 3 +-
.../configuration2/TestBaseNullConfiguration.java | 3 +-
.../configuration2/TestCombinedConfiguration.java | 6 +-
.../configuration2/TestCompositeConfiguration.java | 12 +--
.../configuration2/TestConfigurationMap.java | 6 +-
.../configuration2/TestConfigurationSet.java | 6 +-
.../configuration2/TestDataConfiguration.java | 20 ----
.../configuration2/TestDatabaseConfiguration.java | 2 +-
.../TestDefaultImmutableConfiguration.java | 2 +-
.../TestDynamicCombinedConfiguration.java | 8 +-
.../TestHierarchicalXMLConfiguration.java | 5 +-
.../configuration2/TestINIConfiguration.java | 22 ++---
.../configuration2/TestJSONConfiguration.java | 21 ++--
.../TestNullCompositeConfiguration.java | 12 +--
.../TestPropertiesConfiguration.java | 108 +++++++++++----------
.../TestPropertiesConfigurationLayout.java | 4 +-
.../configuration2/TestSubsetConfiguration.java | 11 +--
.../configuration2/TestXMLConfiguration.java | 2 +-
...ation_605.java => TestXMLConfiguration605.java} | 2 +-
.../configuration2/TestYAMLConfiguration.java | 15 +--
.../configuration2/beanutils/TestBeanHelper.java | 7 +-
.../beanutils/TestConfigurationDynaBean.java | 25 ++---
.../TestConfigurationDynaBeanXMLConfig.java | 3 +-
.../builder/TestFileBasedConfigurationBuilder.java | 9 +-
.../AbstractMultiFileConfigurationBuilderTest.java | 5 +-
.../builder/fluent/TestConfigurations.java | 26 ++---
.../event/TestEventListenerList.java | 2 +-
.../configuration2/event/TestEventSource.java | 7 +-
.../interpol/TestConfigurationInterpolator.java | 21 ++--
.../configuration2/interpol/TestExprLookup.java | 4 +-
.../configuration2/io/TestConfigurationLogger.java | 3 +-
.../apache/commons/configuration2/test/HsqlDB.java | 6 +-
.../configuration2/tree/NodeStructureHelper.java | 7 +-
.../tree/TestDefaultExpressionEngine.java | 45 ++++-----
.../web/TestAppletConfiguration.java | 3 +-
41 files changed, 267 insertions(+), 253 deletions(-)
diff --git a/pom.xml b/pom.xml
index 9f74a5d3..a8617568 100644
--- a/pom.xml
+++ b/pom.xml
@@ -397,6 +397,7 @@
<propertyExpansion>basedir=${basedir}/src</propertyExpansion>
<includeResources>false</includeResources>
<includeTestResources>false</includeTestResources>
+ <includeTestSourceDirectory>true</includeTestSourceDirectory>
<sourceDirectories>
<sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
</sourceDirectories>
diff --git a/src/conf/checkstyle-suppressions.xml
b/src/conf/checkstyle-suppressions.xml
index 5954b250..fd47dcf0 100644
--- a/src/conf/checkstyle-suppressions.xml
+++ b/src/conf/checkstyle-suppressions.xml
@@ -1,9 +1,8 @@
<?xml version="1.0"?>
-
<!DOCTYPE suppressions PUBLIC
- "-//Checkstyle//DTD SuppressionFilter Configuration 1.0//EN"
- "https://checkstyle.org/dtds/suppressions_1_0.dtd">
-<!--
+ "-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
+ "https://checkstyle.org/dtds/suppressions_1_2.dtd">
+ <!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
@@ -22,24 +21,29 @@
<!-- ===================================================================== -->
<!-- Exceptions for Checkstyle -->
<!-- ===================================================================== -->
-
<suppressions>
-
- <suppress checks="MissingSwitchDefault"
files="PropertiesConfiguration.java"/>
-
- <!-- There is an empty catch block ignoring unsupported operation
exceptions
- from the list delimiter handler. This is okay, then the property is
- written out in multiple lines.
- -->
- <suppress checks="EmptyBlock" files="PropertiesConfiguration.java"
- lines="1074-1107"/>
-
- <suppress files="FileUtils\.java" checks="[a-zA-Z0-9]*"/>
-
- <!-- There is an import for an exception class which is used in the
- Javadoc for almost every method.
- -->
- <suppress checks="UnusedImports" files="DataConfiguration"/>
- <suppress checks="UnusedImports" files="ConversionHandler"/>
- <suppress checks="UnusedImports" files="DefaultConversionHandler"/>
+ <suppress checks="MissingSwitchDefault"
files="PropertiesConfiguration.java"/>
+ <!-- There is an empty catch block ignoring unsupported operation exceptions
+ from the list delimiter handler. This is okay, then the property is
+ written out in multiple lines.
+ -->
+ <suppress checks="EmptyBlock" files="PropertiesConfiguration.java"
lines="1074-1107"/>
+ <suppress files="FileUtils\.java" checks="[a-zA-Z0-9]*"/>
+ <!-- There is an import for an exception class which is used in the
+ Javadoc for almost every method.
+ -->
+ <suppress checks="UnusedImports" files="DataConfiguration"/>
+ <suppress checks="UnusedImports" files="ConversionHandler"/>
+ <suppress checks="UnusedImports" files="DefaultConversionHandler"/>
+ <!-- Tests -->
+ <suppress checks="MagicNumber" files="src[/\\]test[/\\]java[/\\]" />
+ <suppress checks="JavadocMethod" files="src[/\\]test[/\\]java[/\\]" />
+ <suppress checks="JavadocPackage" files="src[/\\]test[/\\]java[/\\]" />
+ <suppress checks="JavadocVariable" files="src[/\\]test[/\\]java[/\\]" />
+ <suppress checks="ParameterNumber" files="src[/\\]test[/\\]java[/\\]" />
+ <suppress checks="VisibilityModifier" files="src[/\\]test[/\\]java[/\\]"
message="Variable 'tempFolder' must be private and have accessor methods"/>
+ <suppress checks="MethodLength" files="src[/\\]test[/\\]java[/\\]" />
+ <suppress checks="SuperClone"
files="src[/\\]test[/\\]java[/\\]org[/\\]apache[/\\]commons[/\\]configuration2[/\\]TestConfigurationUtils.java"
/>
+ <!-- Class can't be final for Mockito -->
+ <suppress checks="FinalClass"
files="src[/\\]test[/\\]java[/\\]org[/\\]apache[/\\]commons[/\\]configuration2[/\\]io[/\\]TestFileHandler.java"
/>
</suppressions>
diff --git
a/src/test/java/org/apache/commons/configuration2/ConfigurationAssert.java
b/src/test/java/org/apache/commons/configuration2/ConfigurationAssert.java
index 0f3caaa9..c1f4d4bc 100644
--- a/src/test/java/org/apache/commons/configuration2/ConfigurationAssert.java
+++ b/src/test/java/org/apache/commons/configuration2/ConfigurationAssert.java
@@ -35,7 +35,8 @@ import
org.apache.commons.configuration2.ex.ConfigurationRuntimeException;
/**
* Assertions on configurations for the unit tests. This class also provides
access to test files.
*/
-public class ConfigurationAssert {
+public final class ConfigurationAssert {
+
/** Constant for the name of the directory with the test files. */
public static final String TEST_DIR_NAME = "target/test-classes";
@@ -177,4 +178,8 @@ public class ConfigurationAssert {
throw new ConfigurationRuntimeException(mex);
}
}
+
+ private ConfigurationAssert() {
+ // empty
+ }
}
diff --git
a/src/test/java/org/apache/commons/configuration2/DatabaseConfigurationTestHelper.java
b/src/test/java/org/apache/commons/configuration2/DatabaseConfigurationTestHelper.java
index 7ae9f866..1110dcee 100644
---
a/src/test/java/org/apache/commons/configuration2/DatabaseConfigurationTestHelper.java
+++
b/src/test/java/org/apache/commons/configuration2/DatabaseConfigurationTestHelper.java
@@ -41,6 +41,7 @@ import org.dbunit.operation.DatabaseOperation;
* and column names and database connection settings are provided, too.
*/
public class DatabaseConfigurationTestHelper {
+
/** Constant for the configuration table. */
public static final String TABLE = "configuration";
@@ -60,16 +61,16 @@ public class DatabaseConfigurationTestHelper {
public static final String CONFIG_NAME = "test";
/** Constant for the JDBC driver class. */
- public final String DATABASE_DRIVER = "org.hsqldb.jdbcDriver";
+ public static final String DATABASE_DRIVER = "org.hsqldb.jdbcDriver";
/** Constant for the connection URL. */
- public final String DATABASE_URL = "jdbc:hsqldb:mem:testdb";
+ public static final String DATABASE_URL = "jdbc:hsqldb:mem:testdb";
/** Constant for the DB user name. */
- public final String DATABASE_USERNAME = "sa";
+ public static final String DATABASE_USERNAME = "sa";
/** Constant for the DB password. */
- public final String DATABASE_PASSWORD = "";
+ public static final String DATABASE_PASSWORD = "";
/** Stores the in-process database. */
private HsqlDB hsqlDB;
diff --git
a/src/test/java/org/apache/commons/configuration2/InterpolationTestHelper.java
b/src/test/java/org/apache/commons/configuration2/InterpolationTestHelper.java
index c66506ca..5b8046ec 100644
---
a/src/test/java/org/apache/commons/configuration2/InterpolationTestHelper.java
+++
b/src/test/java/org/apache/commons/configuration2/InterpolationTestHelper.java
@@ -33,7 +33,8 @@ import org.apache.commons.lang3.SystemProperties;
* A helper class that defines a bunch of tests related to variable
interpolation. It can be used for running these
* tests on different configuration implementations.
*/
-public class InterpolationTestHelper {
+public final class InterpolationTestHelper {
+
/**
* Tests accessing and manipulating the interpolator object.
*
@@ -223,4 +224,8 @@ public class InterpolationTestHelper {
assertEquals(expectedValue, config.getString("test.third-level"));
}
+
+ private InterpolationTestHelper() {
+ // empty
+ }
}
diff --git
a/src/test/java/org/apache/commons/configuration2/TestAbstractConfigurationBasicFeatures.java
b/src/test/java/org/apache/commons/configuration2/TestAbstractConfigurationBasicFeatures.java
index 1af273ed..2761c4e8 100644
---
a/src/test/java/org/apache/commons/configuration2/TestAbstractConfigurationBasicFeatures.java
+++
b/src/test/java/org/apache/commons/configuration2/TestAbstractConfigurationBasicFeatures.java
@@ -56,7 +56,8 @@ public class TestAbstractConfigurationBasicFeatures {
* An event listener implementation that simply collects all received
configuration events.
*/
private static final class CollectingConfigurationListener implements
EventListener<ConfigurationEvent> {
- final List<ConfigurationEvent> events = new ArrayList<>();
+
+ private final List<ConfigurationEvent> events = new ArrayList<>();
@Override
public void onEvent(final ConfigurationEvent event) {
diff --git
a/src/test/java/org/apache/commons/configuration2/TestBaseConfiguration.java
b/src/test/java/org/apache/commons/configuration2/TestBaseConfiguration.java
index c974e8ab..b7575614 100644
--- a/src/test/java/org/apache/commons/configuration2/TestBaseConfiguration.java
+++ b/src/test/java/org/apache/commons/configuration2/TestBaseConfiguration.java
@@ -242,7 +242,8 @@ public class TestBaseConfiguration {
@Test
public void testGetBoolean() {
config.setProperty("boolA", Boolean.TRUE);
- final boolean boolT = true, boolF = false;
+ final boolean boolT = true;
+ final boolean boolF = false;
assertEquals(boolT, config.getBoolean("boolA"));
assertEquals(boolT, config.getBoolean("boolA", boolF));
assertEquals(boolF, config.getBoolean("boolNotInConfig", boolF));
diff --git
a/src/test/java/org/apache/commons/configuration2/TestBaseNullConfiguration.java
b/src/test/java/org/apache/commons/configuration2/TestBaseNullConfiguration.java
index 3eaa61d0..9d63832c 100644
---
a/src/test/java/org/apache/commons/configuration2/TestBaseNullConfiguration.java
+++
b/src/test/java/org/apache/commons/configuration2/TestBaseNullConfiguration.java
@@ -111,7 +111,8 @@ public class TestBaseNullConfiguration {
@Test
public void testGetBoolean() {
config.setProperty("boolA", Boolean.TRUE);
- final boolean boolT = true, boolF = false;
+ final boolean boolT = true;
+ final boolean boolF = false;
assertEquals(boolT, config.getBoolean("boolA"));
assertEquals(boolT, config.getBoolean("boolA", boolF));
assertEquals(boolF, config.getBoolean("boolNotInConfig", boolF));
diff --git
a/src/test/java/org/apache/commons/configuration2/TestCombinedConfiguration.java
b/src/test/java/org/apache/commons/configuration2/TestCombinedConfiguration.java
index 9c161f3e..876aba39 100644
---
a/src/test/java/org/apache/commons/configuration2/TestCombinedConfiguration.java
+++
b/src/test/java/org/apache/commons/configuration2/TestCombinedConfiguration.java
@@ -66,9 +66,10 @@ public class TestCombinedConfiguration {
* Test event listener class for checking if the expected invalidate
events are fired.
*/
private static final class CombinedListener implements
EventListener<ConfigurationEvent> {
- int invalidateEvents;
- int otherEvents;
+ private int invalidateEvents;
+
+ private int otherEvents;
/**
* Checks if the expected number of events was fired.
@@ -96,6 +97,7 @@ public class TestCombinedConfiguration {
* configuration. If everything works well, this property should have at
least one and at most two values.
*/
private static final class ReadThread extends Thread {
+
/** The configuration to be accessed. */
private final Configuration config;
diff --git
a/src/test/java/org/apache/commons/configuration2/TestCompositeConfiguration.java
b/src/test/java/org/apache/commons/configuration2/TestCompositeConfiguration.java
index 9d605e53..d2954376 100644
---
a/src/test/java/org/apache/commons/configuration2/TestCompositeConfiguration.java
+++
b/src/test/java/org/apache/commons/configuration2/TestCompositeConfiguration.java
@@ -209,11 +209,11 @@ public class TestCompositeConfiguration {
@Test
public void testCheckingInMemoryConfiguration() throws Exception {
- final String TEST_KEY = "testKey";
+ final String testKey = "testKey";
final Configuration defaults = new PropertiesConfiguration();
- defaults.setProperty(TEST_KEY, "testValue");
+ defaults.setProperty(testKey, "testValue");
final Configuration testConfiguration = new
CompositeConfiguration(defaults);
- assertTrue(testConfiguration.containsKey(TEST_KEY));
+ assertTrue(testConfiguration.containsKey(testKey));
assertFalse(testConfiguration.isEmpty());
boolean foundTestKey = false;
final Iterator<String> i = testConfiguration.getKeys();
@@ -222,13 +222,13 @@ public class TestCompositeConfiguration {
// assertEquals(2,i.size());
while (i.hasNext()) {
final String key = i.next();
- if (key.equals(TEST_KEY)) {
+ if (key.equals(testKey)) {
foundTestKey = true;
}
}
assertTrue(foundTestKey);
- testConfiguration.clearProperty(TEST_KEY);
- assertFalse(testConfiguration.containsKey(TEST_KEY));
+ testConfiguration.clearProperty(testKey);
+ assertFalse(testConfiguration.containsKey(testKey));
}
/**
diff --git
a/src/test/java/org/apache/commons/configuration2/TestConfigurationMap.java
b/src/test/java/org/apache/commons/configuration2/TestConfigurationMap.java
index 21f7bd53..00467a84 100644
--- a/src/test/java/org/apache/commons/configuration2/TestConfigurationMap.java
+++ b/src/test/java/org/apache/commons/configuration2/TestConfigurationMap.java
@@ -29,11 +29,11 @@ import org.junit.jupiter.api.Test;
*/
public class TestConfigurationMap {
- ConfigurationMap map;
+ private ConfigurationMap map;
- String[] properties = {"booleanProperty", "doubleProperty",
"floatProperty", "intProperty", "longProperty", "shortProperty",
"stringProperty"};
+ private String[] properties = {"booleanProperty", "doubleProperty",
"floatProperty", "intProperty", "longProperty", "shortProperty",
"stringProperty"};
- Object[] values = {Boolean.TRUE, Double.valueOf(Double.MAX_VALUE),
Float.valueOf(Float.MAX_VALUE), Integer.valueOf(Integer.MAX_VALUE),
+ private Object[] values = {Boolean.TRUE, Double.valueOf(Double.MAX_VALUE),
Float.valueOf(Float.MAX_VALUE), Integer.valueOf(Integer.MAX_VALUE),
Long.valueOf(Long.MAX_VALUE), Short.valueOf(Short.MAX_VALUE), "This is
a string"};
/**
diff --git
a/src/test/java/org/apache/commons/configuration2/TestConfigurationSet.java
b/src/test/java/org/apache/commons/configuration2/TestConfigurationSet.java
index 63079501..01cb1676 100644
--- a/src/test/java/org/apache/commons/configuration2/TestConfigurationSet.java
+++ b/src/test/java/org/apache/commons/configuration2/TestConfigurationSet.java
@@ -31,11 +31,11 @@ import org.junit.jupiter.api.Test;
*/
public class TestConfigurationSet {
- ConfigurationMap.ConfigurationSet set;
+ private ConfigurationMap.ConfigurationSet set;
- String[] properties = {"booleanProperty", "doubleProperty",
"floatProperty", "intProperty", "longProperty", "shortProperty",
"stringProperty"};
+ private String[] properties = {"booleanProperty", "doubleProperty",
"floatProperty", "intProperty", "longProperty", "shortProperty",
"stringProperty"};
- Object[] values = {Boolean.TRUE, Double.valueOf(Double.MAX_VALUE),
Float.valueOf(Float.MAX_VALUE), Integer.valueOf(Integer.MAX_VALUE),
+ private Object[] values = {Boolean.TRUE, Double.valueOf(Double.MAX_VALUE),
Float.valueOf(Float.MAX_VALUE), Integer.valueOf(Integer.MAX_VALUE),
Long.valueOf(Long.MAX_VALUE), Short.valueOf(Short.MAX_VALUE), "This is
a string"};
/**
diff --git
a/src/test/java/org/apache/commons/configuration2/TestDataConfiguration.java
b/src/test/java/org/apache/commons/configuration2/TestDataConfiguration.java
index adabda04..dfdec4cc 100644
--- a/src/test/java/org/apache/commons/configuration2/TestDataConfiguration.java
+++ b/src/test/java/org/apache/commons/configuration2/TestDataConfiguration.java
@@ -79,10 +79,8 @@ public class TestDataConfiguration {
final BaseConfiguration baseConfig = new BaseConfiguration();
baseConfig.setListDelimiterHandler(new
DefaultListDelimiterHandler(','));
conf = new DataConfiguration(baseConfig);
-
// empty value
conf.addProperty("empty", "");
-
// lists of boolean
conf.addProperty("boolean.list1", "true");
conf.addProperty("boolean.list1", "false");
@@ -98,7 +96,6 @@ public class TestDataConfiguration {
conf.addProperty("boolean.string", "true");
conf.addProperty("boolean.object", Boolean.TRUE);
conf.addProperty("boolean.list.interpolated",
"${boolean.string},false");
-
// lists of bytes
conf.addProperty("byte.list1", "1");
conf.addProperty("byte.list1", "2");
@@ -114,7 +111,6 @@ public class TestDataConfiguration {
conf.addProperty("byte.string", "1");
conf.addProperty("byte.object", Byte.valueOf("1"));
conf.addProperty("byte.list.interpolated", "${byte.string},2");
-
// lists of shorts
conf.addProperty("short.list1", "1");
conf.addProperty("short.list1", "2");
@@ -130,7 +126,6 @@ public class TestDataConfiguration {
conf.addProperty("short.string", "1");
conf.addProperty("short.object", Short.valueOf("1"));
conf.addProperty("short.list.interpolated", "${short.string},2");
-
// lists of integers
conf.addProperty("integer.list1", "1");
conf.addProperty("integer.list1", "2");
@@ -146,7 +141,6 @@ public class TestDataConfiguration {
conf.addProperty("integer.string", "1");
conf.addProperty("integer.object", Integer.valueOf("1"));
conf.addProperty("integer.list.interpolated", "${integer.string},2");
-
// lists of longs
conf.addProperty("long.list1", "1");
conf.addProperty("long.list1", "2");
@@ -162,7 +156,6 @@ public class TestDataConfiguration {
conf.addProperty("long.string", "1");
conf.addProperty("long.object", Long.valueOf("1"));
conf.addProperty("long.list.interpolated", "${long.string},2");
-
// lists of floats
conf.addProperty("float.list1", "1");
conf.addProperty("float.list1", "2");
@@ -178,7 +171,6 @@ public class TestDataConfiguration {
conf.addProperty("float.string", "1");
conf.addProperty("float.object", Float.valueOf("1"));
conf.addProperty("float.list.interpolated", "${float.string},2");
-
// lists of doubles
conf.addProperty("double.list1", "1");
conf.addProperty("double.list1", "2");
@@ -194,7 +186,6 @@ public class TestDataConfiguration {
conf.addProperty("double.string", "1");
conf.addProperty("double.object", Double.valueOf("1"));
conf.addProperty("double.list.interpolated", "${double.string},2");
-
// lists of big integers
conf.addProperty("biginteger.list1", "1");
conf.addProperty("biginteger.list1", "2");
@@ -209,7 +200,6 @@ public class TestDataConfiguration {
conf.addProperty("biginteger.string", "1");
conf.addProperty("biginteger.object", new BigInteger("1"));
conf.addProperty("biginteger.list.interpolated",
"${biginteger.string},2");
-
// lists of big decimals
conf.addProperty("bigdecimal.list1", "1");
conf.addProperty("bigdecimal.list1", "2");
@@ -224,7 +214,6 @@ public class TestDataConfiguration {
conf.addProperty("bigdecimal.string", "1");
conf.addProperty("bigdecimal.object", new BigDecimal("1"));
conf.addProperty("bigdecimal.list.interpolated",
"${bigdecimal.string},2");
-
// URIs
final String uri1 = "http://jakarta.apache.org";
final String uri2 = "http://www.apache.org";
@@ -242,7 +231,6 @@ public class TestDataConfiguration {
uris.add(new URI(uri2));
conf.addProperty("uri.list6", uris);
conf.addProperty("uri.list.interpolated", "${uri.string}," + uri2);
-
// URLs
final String url1 = "http://jakarta.apache.org";
final String url2 = "http://www.apache.org";
@@ -260,7 +248,6 @@ public class TestDataConfiguration {
urls.add(new URL(url2));
conf.addProperty("url.list6", urls);
conf.addProperty("url.list.interpolated", "${url.string}," + url2);
-
// Locales
conf.addProperty("locale.string", "fr");
conf.addProperty("locale.string.interpolated", "${locale.string}");
@@ -276,7 +263,6 @@ public class TestDataConfiguration {
locales.add(Locale.GERMAN);
conf.addProperty("locale.list6", locales);
conf.addProperty("locale.list.interpolated", "${locale.string},de");
-
// Colors
final String color1 = "FF0000";
final String color2 = "0000FF";
@@ -294,19 +280,16 @@ public class TestDataConfiguration {
colors.add(Color.blue);
conf.addProperty("color.list6", colors);
conf.addProperty("color.list.interpolated", "${color.string}," +
color2);
-
// Dates & Calendars
final String pattern = DATE_PATTERN;
final DateFormat format = new SimpleDateFormat(pattern);
conf.setProperty(DataConfiguration.DATE_FORMAT_KEY, pattern);
-
final Date date1 = format.parse("2004-01-01");
final Date date2 = format.parse("2004-12-31");
final Calendar calendar1 = Calendar.getInstance();
calendar1.setTime(date1);
final Calendar calendar2 = Calendar.getInstance();
calendar2.setTime(date2);
-
conf.addProperty("date.string", "2004-01-01");
conf.addProperty("date.string.interpolated", "${date.string}");
conf.addProperty("date.object", date1);
@@ -323,7 +306,6 @@ public class TestDataConfiguration {
conf.addProperty("date.list6", dates);
conf.addProperty("date.list.interpolated",
"${date.string},2004-12-31");
conf.addPropertyDirect("date.list7", new String[] {"2004-01-01",
"2004-12-31"});
-
conf.addProperty("calendar.string", "2004-01-01");
conf.addProperty("calendar.string.interpolated", "${calendar.string}");
conf.addProperty("calendar.object", calendar1);
@@ -340,12 +322,10 @@ public class TestDataConfiguration {
conf.addProperty("calendar.list6", calendars);
conf.addProperty("calendar.list.interpolated",
"${calendar.string},2004-12-31");
conf.addPropertyDirect("calendar.list7", new String[] {"2004-01-01",
"2004-12-31"});
-
// host address
conf.addProperty("ip.string", "127.0.0.1");
conf.addProperty("ip.string.interpolated", "${ip.string}");
conf.addProperty("ip.object", InetAddress.getByName("127.0.0.1"));
-
// email address
conf.addProperty("email.string", "[email protected]");
conf.addProperty("email.string.interpolated", "${email.string}");
diff --git
a/src/test/java/org/apache/commons/configuration2/TestDatabaseConfiguration.java
b/src/test/java/org/apache/commons/configuration2/TestDatabaseConfiguration.java
index 74de7b6f..4acd132a 100644
---
a/src/test/java/org/apache/commons/configuration2/TestDatabaseConfiguration.java
+++
b/src/test/java/org/apache/commons/configuration2/TestDatabaseConfiguration.java
@@ -60,7 +60,7 @@ public class TestDatabaseConfiguration {
*/
public static class PotentialErrorDatabaseConfiguration extends
DatabaseConfiguration {
/** A flag whether a getConnection() call should fail. */
- boolean failOnConnect;
+ private boolean failOnConnect;
@Override
public DataSource getDatasource() {
diff --git
a/src/test/java/org/apache/commons/configuration2/TestDefaultImmutableConfiguration.java
b/src/test/java/org/apache/commons/configuration2/TestDefaultImmutableConfiguration.java
index d16162bc..a7583320 100644
---
a/src/test/java/org/apache/commons/configuration2/TestDefaultImmutableConfiguration.java
+++
b/src/test/java/org/apache/commons/configuration2/TestDefaultImmutableConfiguration.java
@@ -45,7 +45,7 @@ public class TestDefaultImmutableConfiguration {
/** Tests default methods. This class MUST NOT override the default
methods! */
private static final class MapImmutableConfiguration implements
ImmutableConfiguration {
- Map<String, Object> map = new HashMap<>();
+ private Map<String, Object> map = new HashMap<>();
@Override
public boolean containsKey(final String key) {
diff --git
a/src/test/java/org/apache/commons/configuration2/TestDynamicCombinedConfiguration.java
b/src/test/java/org/apache/commons/configuration2/TestDynamicCombinedConfiguration.java
index f4b36668..ddfd73bf 100644
---
a/src/test/java/org/apache/commons/configuration2/TestDynamicCombinedConfiguration.java
+++
b/src/test/java/org/apache/commons/configuration2/TestDynamicCombinedConfiguration.java
@@ -145,11 +145,13 @@ public class TestDynamicCombinedConfiguration {
}
}
}
+
public static class ThreadLookup implements Lookup {
- private static final ThreadLocal<String> id = new ThreadLocal<>();
+
+ private static final ThreadLocal<String> ID = new ThreadLocal<>();
public static void setId(final String value) {
- id.set(value);
+ ID.set(value);
}
public ThreadLookup() {
@@ -164,7 +166,7 @@ public class TestDynamicCombinedConfiguration {
if (value != null) {
return value;
}
- return id.get();
+ return ID.get();
}
}
diff --git
a/src/test/java/org/apache/commons/configuration2/TestHierarchicalXMLConfiguration.java
b/src/test/java/org/apache/commons/configuration2/TestHierarchicalXMLConfiguration.java
index 3a81a6f7..aa20a8db 100644
---
a/src/test/java/org/apache/commons/configuration2/TestHierarchicalXMLConfiguration.java
+++
b/src/test/java/org/apache/commons/configuration2/TestHierarchicalXMLConfiguration.java
@@ -38,6 +38,7 @@ import org.junit.jupiter.api.io.TempDir;
* nature of this class and structured data access.
*/
public class TestHierarchicalXMLConfiguration {
+
/** Test resources directory. */
private static final String TEST_DIR = "conf";
@@ -252,7 +253,7 @@ public class TestHierarchicalXMLConfiguration {
@Test
public void testXmlNodeTypes() throws Exception {
// Number of keys expected from test configuration file
- final int KEY_COUNT = 5;
+ final int keyCount = 5;
// Load the configuration file
final FileHandler handler = new FileHandler(config);
@@ -280,6 +281,6 @@ public class TestHierarchicalXMLConfiguration {
iter.next();
count++;
}
- assertEquals(KEY_COUNT, count);
+ assertEquals(keyCount, count);
}
}
diff --git
a/src/test/java/org/apache/commons/configuration2/TestINIConfiguration.java
b/src/test/java/org/apache/commons/configuration2/TestINIConfiguration.java
index e5cf2056..93ecd6e7 100644
--- a/src/test/java/org/apache/commons/configuration2/TestINIConfiguration.java
+++ b/src/test/java/org/apache/commons/configuration2/TestINIConfiguration.java
@@ -1,18 +1,18 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
under
- * the License.
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.commons.configuration2;
@@ -75,7 +75,7 @@ public class TestINIConfiguration {
private final INIConfiguration config;
/** A flag whether an error was found. */
- volatile boolean error;
+ private volatile boolean error;
/**
* Creates a new instance of {@code GlobalSectionTestThread} and
initializes it.
diff --git
a/src/test/java/org/apache/commons/configuration2/TestJSONConfiguration.java
b/src/test/java/org/apache/commons/configuration2/TestJSONConfiguration.java
index 7fd70b12..83239c8e 100644
--- a/src/test/java/org/apache/commons/configuration2/TestJSONConfiguration.java
+++ b/src/test/java/org/apache/commons/configuration2/TestJSONConfiguration.java
@@ -41,6 +41,7 @@ import com.fasterxml.jackson.databind.type.MapType;
* {@link JSONConfiguration} itself
*/
public class TestJSONConfiguration {
+
/** The files that we test with. */
private final String testJson =
ConfigurationAssert.getTestFile("test.json").getAbsolutePath();
@@ -64,53 +65,53 @@ public class TestJSONConfiguration {
/**
* Tests CONFIGURATION-793.
*/
- public void testGetList_nested_with_list() {
+ public void testGetListNestedWithList() {
assertEquals(Arrays.asList("col1", "col2"),
jsonConfiguration.getList(String.class, "key4.key5"));
}
@Test
- public void testGetProperty_dictionary() {
+ public void testGetPropertyDictionary() {
assertEquals("Martin D'vloper",
jsonConfiguration.getProperty("martin.name"));
assertEquals("Developer", jsonConfiguration.getProperty("martin.job"));
assertEquals("Elite", jsonConfiguration.getProperty("martin.skill"));
}
@Test
- public void testGetProperty_dictionaryInList() {
+ public void testGetPropertyDictionaryInList() {
assertEquals("UK", jsonConfiguration.getString("capitals(1).country"));
assertEquals("Washington",
jsonConfiguration.getString("capitals(0).capital"));
}
@Test
- public void testGetProperty_integer() {
+ public void testGetPropertyInteger() {
final Object property = jsonConfiguration.getProperty("int1");
assertInstanceOf(Integer.class, property);
assertEquals(37, property);
}
@Test
- public void testGetProperty_nested() {
+ public void testGetPropertyNested() {
assertEquals("value23", jsonConfiguration.getProperty("key2.key3"));
}
@Test
- public void testGetProperty_nested_with_list() {
+ public void testGetPropertyNestedWithList() {
assertEquals(Arrays.asList("col1", "col2"),
jsonConfiguration.getProperty("key4.key5"));
}
@Test
- public void testGetProperty_simple() {
+ public void testGetPropertySimple() {
assertEquals("value1", jsonConfiguration.getProperty("key1"));
}
@Test
- public void testGetProperty_subset() {
+ public void testGetPropertySubset() {
final Configuration subset = jsonConfiguration.subset("key4");
assertEquals(Arrays.asList("col1", "col2"),
subset.getProperty("key5"));
}
@Test
- public void testGetProperty_very_nested_properties() {
+ public void testGetPropertyVeryNestedProperties() {
final Object property =
jsonConfiguration.getProperty("very.nested.properties");
assertEquals(Arrays.asList("nested1", "nested2", "nested3"), property);
}
@@ -149,7 +150,7 @@ public class TestJSONConfiguration {
assertEquals(7, parsed.entrySet().size());
assertEquals("value1", parsed.get("key1"));
- final Map<?, ?> key2 = (Map<? , ?>) parsed.get("key2");
+ final Map<?, ?> key2 = (Map<?, ?>) parsed.get("key2");
assertEquals("value23", key2.get("key3"));
final List<?> key5 = (List<?>) ((Map<?, ?>)
parsed.get("key4")).get("key5");
diff --git
a/src/test/java/org/apache/commons/configuration2/TestNullCompositeConfiguration.java
b/src/test/java/org/apache/commons/configuration2/TestNullCompositeConfiguration.java
index 0c5b65be..ce2fb999 100644
---
a/src/test/java/org/apache/commons/configuration2/TestNullCompositeConfiguration.java
+++
b/src/test/java/org/apache/commons/configuration2/TestNullCompositeConfiguration.java
@@ -119,23 +119,23 @@ public class TestNullCompositeConfiguration {
@Test
public void testCheckingInMemoryConfiguration() throws Exception {
- final String TEST_KEY = "testKey";
+ final String testKey = "testKey";
final Configuration defaults = new PropertiesConfiguration();
- defaults.setProperty(TEST_KEY, "testValue");
+ defaults.setProperty(testKey, "testValue");
final Configuration testConfiguration = new
CompositeConfiguration(defaults);
- assertTrue(testConfiguration.containsKey(TEST_KEY));
+ assertTrue(testConfiguration.containsKey(testKey));
assertFalse(testConfiguration.isEmpty());
boolean foundTestKey = false;
final Iterator<String> i = testConfiguration.getKeys();
while (i.hasNext()) {
final String key = i.next();
- if (key.equals(TEST_KEY)) {
+ if (key.equals(testKey)) {
foundTestKey = true;
}
}
assertTrue(foundTestKey);
- testConfiguration.clearProperty(TEST_KEY);
- assertFalse(testConfiguration.containsKey(TEST_KEY));
+ testConfiguration.clearProperty(testKey);
+ assertFalse(testConfiguration.containsKey(testKey));
}
/**
diff --git
a/src/test/java/org/apache/commons/configuration2/TestPropertiesConfiguration.java
b/src/test/java/org/apache/commons/configuration2/TestPropertiesConfiguration.java
index da85e4bb..6ccc1652 100644
---
a/src/test/java/org/apache/commons/configuration2/TestPropertiesConfiguration.java
+++
b/src/test/java/org/apache/commons/configuration2/TestPropertiesConfiguration.java
@@ -99,7 +99,7 @@ public class TestPropertiesConfiguration {
*/
static class DummyLayout extends PropertiesConfigurationLayout {
/** Stores the number how often load() was called. */
- public int loadCalls;
+ private int loadCalls;
@Override
public void load(final PropertiesConfiguration config, final Reader
in) throws ConfigurationException {
@@ -215,25 +215,27 @@ public class TestPropertiesConfiguration {
*/
private static final class PropertiesWriterTestImpl extends
PropertiesConfiguration.PropertiesWriter {
public PropertiesWriterTestImpl(final ListDelimiterHandler handler)
throws IOException {
- super(new FileWriter(testSavePropertiesFile), handler);
+ super(new FileWriter(TEST_SAVE_PROPERTIES_FILE), handler);
}
}
/** Constant for a test property name. */
private static final String PROP_NAME = "testProperty";
+
/** Constant for a test property value. */
private static final String PROP_VALUE = "value";
+
/** Constant for the line break character. */
private static final String CR = System.lineSeparator();
/** The File that we test with */
- private static final String testProperties =
ConfigurationAssert.getTestFile("test.properties").getAbsolutePath();
+ private static final String TEST_PROPERTIES =
ConfigurationAssert.getTestFile("test.properties").getAbsolutePath();
- private static final String testBasePath =
ConfigurationAssert.TEST_DIR.getAbsolutePath();
+ private static final String TEST_BASE_PATH =
ConfigurationAssert.TEST_DIR.getAbsolutePath();
- private static final String testBasePath2 =
ConfigurationAssert.TEST_DIR.getParentFile().getAbsolutePath();
+ private static final String TEST_BASE_PATH_2 =
ConfigurationAssert.TEST_DIR.getParentFile().getAbsolutePath();
- private static final File testSavePropertiesFile =
ConfigurationAssert.getOutFile("testsave.properties");
+ private static final File TEST_SAVE_PROPERTIES_FILE =
ConfigurationAssert.getOutFile("testsave.properties");
/**
* Helper method for loading a configuration from a given file.
@@ -278,7 +280,7 @@ public class TestPropertiesConfiguration {
private void checkCopiedConfig(final Configuration copyConf) throws
ConfigurationException {
saveTestConfig();
final PropertiesConfiguration checkConf = new
PropertiesConfiguration();
- load(checkConf, testSavePropertiesFile.getAbsolutePath());
+ load(checkConf, TEST_SAVE_PROPERTIES_FILE.getAbsolutePath());
for (final Iterator<String> it = copyConf.getKeys(); it.hasNext();) {
final String key = it.next();
assertEquals(checkConf.getProperty(key),
copyConf.getProperty(key), "Wrong value for property " + key);
@@ -306,7 +308,7 @@ public class TestPropertiesConfiguration {
private PropertiesConfiguration checkSavedConfig() throws
ConfigurationException {
final PropertiesConfiguration checkConfig = new
PropertiesConfiguration();
checkConfig.setListDelimiterHandler(new
LegacyListDelimiterHandler(','));
- load(checkConfig, testSavePropertiesFile.getAbsolutePath());
+ load(checkConfig, TEST_SAVE_PROPERTIES_FILE.getAbsolutePath());
ConfigurationAssert.assertConfigurationEquals(conf, checkConfig);
return checkConfig;
}
@@ -318,18 +320,18 @@ public class TestPropertiesConfiguration {
*/
private void saveTestConfig() throws ConfigurationException {
final FileHandler handler = new FileHandler(conf);
- handler.save(testSavePropertiesFile);
+ handler.save(TEST_SAVE_PROPERTIES_FILE);
}
@BeforeEach
public void setUp() throws Exception {
conf = new PropertiesConfiguration();
conf.setListDelimiterHandler(new LegacyListDelimiterHandler(','));
- load(conf, testProperties);
+ load(conf, TEST_PROPERTIES);
// remove the test save file if it exists
- if (testSavePropertiesFile.exists()) {
- assertTrue(testSavePropertiesFile.delete());
+ if (TEST_SAVE_PROPERTIES_FILE.exists()) {
+ assertTrue(TEST_SAVE_PROPERTIES_FILE.delete());
}
}
@@ -387,7 +389,7 @@ public class TestPropertiesConfiguration {
assertEquals("a^b^c", conf.getString("test.other.delimiter"));
final PropertiesConfiguration pc2 = new PropertiesConfiguration();
pc2.setListDelimiterHandler(new DefaultListDelimiterHandler('^'));
- load(pc2, testProperties);
+ load(pc2, TEST_PROPERTIES);
assertEquals("a", pc2.getString("test.other.delimiter"));
assertEquals(3, pc2.getList("test.other.delimiter").size());
}
@@ -580,7 +582,7 @@ public class TestPropertiesConfiguration {
assertEquals(4, conf.getList("test.mixed.array").size());
final PropertiesConfiguration pc2 = new PropertiesConfiguration();
- load(pc2, testProperties);
+ load(pc2, TEST_PROPERTIES);
assertEquals(2, pc2.getList("test.mixed.array").size());
}
@@ -634,7 +636,7 @@ public class TestPropertiesConfiguration {
assertTrue(out.toString().contains(text));
saveTestConfig();
final PropertiesConfiguration c2 = new PropertiesConfiguration();
- load(c2, testSavePropertiesFile.getAbsolutePath());
+ load(c2, TEST_SAVE_PROPERTIES_FILE.getAbsolutePath());
assertEquals(text, c2.getString(PROP_NAME));
}
@@ -715,7 +717,7 @@ public class TestPropertiesConfiguration {
final PropertiesConfiguration pc = new PropertiesConfiguration();
pc.setIncludeListener(PropertiesConfiguration.NOOP_INCLUDE_LISTENER);
final FileHandler handler = new FileHandler(pc);
- handler.setBasePath(testBasePath);
+ handler.setBasePath(TEST_BASE_PATH);
handler.setFileName("include-include-not-found.properties");
handler.load();
assertEquals("valueA", pc.getString("keyA"));
@@ -726,7 +728,7 @@ public class TestPropertiesConfiguration {
public void testIncludeIncludeLoadCyclicalReferenceFail() throws Exception
{
final PropertiesConfiguration pc = new PropertiesConfiguration();
final FileHandler handler = new FileHandler(pc);
- handler.setBasePath(testBasePath);
+ handler.setBasePath(TEST_BASE_PATH);
handler.setFileName("include-include-cyclical-reference.properties");
assertThrows(ConfigurationException.class, handler::load);
assertNull(pc.getString("keyA"));
@@ -737,7 +739,7 @@ public class TestPropertiesConfiguration {
final PropertiesConfiguration pc = new PropertiesConfiguration();
pc.setIncludeListener(PropertiesConfiguration.NOOP_INCLUDE_LISTENER);
final FileHandler handler = new FileHandler(pc);
- handler.setBasePath(testBasePath);
+ handler.setBasePath(TEST_BASE_PATH);
handler.setFileName("include-include-cyclical-reference.properties");
handler.load();
assertEquals("valueA", pc.getString("keyA"));
@@ -761,7 +763,7 @@ public class TestPropertiesConfiguration {
final PropertiesConfiguration pc = new PropertiesConfiguration();
pc.setIncludeListener(PropertiesConfiguration.NOOP_INCLUDE_LISTENER);
final FileHandler handler = new FileHandler(pc);
- handler.setBasePath(testBasePath);
+ handler.setBasePath(TEST_BASE_PATH);
handler.setFileName("include-load-exception.properties");
handler.load();
assertEquals("valueA", pc.getString("keyA"));
@@ -772,7 +774,7 @@ public class TestPropertiesConfiguration {
final PropertiesConfiguration pc = new PropertiesConfiguration();
pc.setIncludeListener(PropertiesConfiguration.NOOP_INCLUDE_LISTENER);
final FileHandler handler = new FileHandler(pc);
- handler.setBasePath(testBasePath);
+ handler.setBasePath(TEST_BASE_PATH);
handler.setFileName("include-not-found.properties");
handler.load();
assertEquals("valueA", pc.getString("keyA"));
@@ -782,7 +784,7 @@ public class TestPropertiesConfiguration {
public void testIncludeLoadCyclicalMultiStepReferenceFail() throws
Exception {
final PropertiesConfiguration pc = new PropertiesConfiguration();
final FileHandler handler = new FileHandler(pc);
- handler.setBasePath(testBasePath);
+ handler.setBasePath(TEST_BASE_PATH);
handler.setFileName("include-cyclical-root.properties");
assertThrows(ConfigurationException.class, handler::load);
assertNull(pc.getString("keyA"));
@@ -793,7 +795,7 @@ public class TestPropertiesConfiguration {
final PropertiesConfiguration pc = new PropertiesConfiguration();
pc.setIncludeListener(PropertiesConfiguration.NOOP_INCLUDE_LISTENER);
final FileHandler handler = new FileHandler(pc);
- handler.setBasePath(testBasePath);
+ handler.setBasePath(TEST_BASE_PATH);
handler.setFileName("include-cyclical-root.properties");
handler.load();
assertEquals("valueA", pc.getString("keyA"));
@@ -803,7 +805,7 @@ public class TestPropertiesConfiguration {
public void testIncludeLoadCyclicalReferenceFail() throws Exception {
final PropertiesConfiguration pc = new PropertiesConfiguration();
final FileHandler handler = new FileHandler(pc);
- handler.setBasePath(testBasePath);
+ handler.setBasePath(TEST_BASE_PATH);
handler.setFileName("include-cyclical-reference.properties");
assertThrows(ConfigurationException.class, handler::load);
assertNull(pc.getString("keyA"));
@@ -814,7 +816,7 @@ public class TestPropertiesConfiguration {
final PropertiesConfiguration pc = new PropertiesConfiguration();
pc.setIncludeListener(PropertiesConfiguration.NOOP_INCLUDE_LISTENER);
final FileHandler handler = new FileHandler(pc);
- handler.setBasePath(testBasePath);
+ handler.setBasePath(TEST_BASE_PATH);
handler.setFileName("include-cyclical-reference.properties");
handler.load();
assertEquals("valueA", pc.getString("keyA"));
@@ -829,7 +831,7 @@ public class TestPropertiesConfiguration {
final String testProperty = "test.successfull";
conf = new PropertiesConfiguration();
final FileHandler handler = new FileHandler(conf);
- handler.setFile(testSavePropertiesFile);
+ handler.setFile(TEST_SAVE_PROPERTIES_FILE);
conf.addProperty(testProperty, "true");
handler.save();
checkSavedConfig();
@@ -848,7 +850,7 @@ public class TestPropertiesConfiguration {
// save the configuration
saveTestConfig();
- assertTrue(testSavePropertiesFile.exists());
+ assertTrue(TEST_SAVE_PROPERTIES_FILE.exists());
// read the configuration and compare the properties
checkSavedConfig();
@@ -917,11 +919,11 @@ public class TestPropertiesConfiguration {
// save the configuration
saveTestConfig();
- assertTrue(testSavePropertiesFile.exists());
+ assertTrue(TEST_SAVE_PROPERTIES_FILE.exists());
// load the saved file...
final Properties testProps = new Properties();
- try (InputStream in =
Files.newInputStream(testSavePropertiesFile.toPath())) {
+ try (InputStream in =
Files.newInputStream(TEST_SAVE_PROPERTIES_FILE.toPath())) {
testProps.load(in);
}
@@ -960,12 +962,12 @@ public class TestPropertiesConfiguration {
// save the configuration as UTF-8
final FileHandler handler = new FileHandler(conf);
handler.setEncoding(StandardCharsets.UTF_8.name());
- handler.save(testSavePropertiesFile);
- assertTrue(testSavePropertiesFile.exists());
+ handler.save(TEST_SAVE_PROPERTIES_FILE);
+ assertTrue(TEST_SAVE_PROPERTIES_FILE.exists());
// load the saved file...
final Properties testProps = new Properties();
- try (BufferedReader in =
Files.newBufferedReader(testSavePropertiesFile.toPath(),
StandardCharsets.UTF_8)) {
+ try (BufferedReader in =
Files.newBufferedReader(TEST_SAVE_PROPERTIES_FILE.toPath(),
StandardCharsets.UTF_8)) {
testProps.load(in);
}
@@ -980,7 +982,7 @@ public class TestPropertiesConfiguration {
}
// ensure that the written properties file contains no Unicode escapes
- for (final String line :
Files.readAllLines(testSavePropertiesFile.toPath())) {
+ for (final String line :
Files.readAllLines(TEST_SAVE_PROPERTIES_FILE.toPath())) {
assertThat(line, not(containsString("\\u")));
}
}
@@ -994,7 +996,7 @@ public class TestPropertiesConfiguration {
final String[] separatorTests = {"test.separator.equal = foo",
"test.separator.colon : foo", "test.separator.tab\tfoo",
"test.separator.whitespace foo",
"test.separator.no.space=foo"};
final Set<String> foundLines = new HashSet<>();
- try (BufferedReader in = new BufferedReader(new
FileReader(testSavePropertiesFile))) {
+ try (BufferedReader in = new BufferedReader(new
FileReader(TEST_SAVE_PROPERTIES_FILE))) {
String s;
while ((s = in.readLine()) != null) {
for (final String separatorTest : separatorTests) {
@@ -1034,7 +1036,7 @@ public class TestPropertiesConfiguration {
*/
@Test
public void testLineSeparator() throws ConfigurationException {
- final String EOL = System.lineSeparator();
+ final String eol = System.lineSeparator();
conf = new PropertiesConfiguration();
conf.setHeader("My header");
conf.setProperty("prop", "value");
@@ -1042,8 +1044,8 @@ public class TestPropertiesConfiguration {
final StringWriter out = new StringWriter();
new FileHandler(conf).save(out);
final String content = out.toString();
- assertEquals(0, content.indexOf("# My header" + EOL + EOL));
- assertThat(content, containsString("prop = value" + EOL));
+ assertEquals(0, content.indexOf("# My header" + eol + eol));
+ assertThat(content, containsString("prop = value" + eol));
}
/**
@@ -1103,7 +1105,7 @@ public class TestPropertiesConfiguration {
};
final Parameters params = new Parameters();
final FileBasedConfigurationBuilder<PropertiesConfiguration> builder =
new FileBasedConfigurationBuilder<>(PropertiesConfiguration.class);
-
builder.configure(params.fileBased().setFile(testSavePropertiesFile).setBasePath(ConfigurationAssert.OUT_DIR.toURI().toString()).setFileSystem(fs));
+
builder.configure(params.fileBased().setFile(TEST_SAVE_PROPERTIES_FILE).setBasePath(ConfigurationAssert.OUT_DIR.toURI().toString()).setFileSystem(fs));
final PropertiesConfiguration configuration =
builder.getConfiguration();
assertEquals("success", configuration.getString("test.outcome"));
}
@@ -1141,7 +1143,7 @@ public class TestPropertiesConfiguration {
public void testLoadIncludeOptional() throws Exception {
final PropertiesConfiguration pc = new PropertiesConfiguration();
final FileHandler handler = new FileHandler(pc);
- handler.setBasePath(testBasePath);
+ handler.setBasePath(TEST_BASE_PATH);
handler.setFileName("includeoptional.properties");
handler.load();
@@ -1157,7 +1159,7 @@ public class TestPropertiesConfiguration {
public void testLoadViaPropertyWithBasePath() throws Exception {
final PropertiesConfiguration pc = new PropertiesConfiguration();
final FileHandler handler = new FileHandler(pc);
- handler.setBasePath(testBasePath);
+ handler.setBasePath(TEST_BASE_PATH);
handler.setFileName("test.properties");
handler.load();
@@ -1168,7 +1170,7 @@ public class TestPropertiesConfiguration {
public void testLoadViaPropertyWithBasePath2() throws Exception {
final PropertiesConfiguration pc = new PropertiesConfiguration();
final FileHandler handler = new FileHandler(pc);
- handler.setBasePath(testBasePath2);
+ handler.setBasePath(TEST_BASE_PATH_2);
handler.setFileName("test.properties");
handler.load();
@@ -1291,7 +1293,7 @@ public class TestPropertiesConfiguration {
// save the configuration
saveTestConfig();
- assertTrue(testSavePropertiesFile.exists());
+ assertTrue(TEST_SAVE_PROPERTIES_FILE.exists());
// read the configuration and compare the properties
checkSavedConfig();
@@ -1335,7 +1337,7 @@ public class TestPropertiesConfiguration {
*/
@Test
public void testSaveToHTTPServerFail() throws Exception {
- final MockHttpURLStreamHandler handler = new
MockHttpURLStreamHandler(HttpURLConnection.HTTP_BAD_REQUEST,
testSavePropertiesFile);
+ final MockHttpURLStreamHandler handler = new
MockHttpURLStreamHandler(HttpURLConnection.HTTP_BAD_REQUEST,
TEST_SAVE_PROPERTIES_FILE);
final URL url = new URL(null, "http://jakarta.apache.org", handler);
final FileHandler fileHandler = new FileHandler(conf);
final ConfigurationException cex =
assertThrows(ConfigurationException.class, () -> fileHandler.save(url));
@@ -1347,7 +1349,7 @@ public class TestPropertiesConfiguration {
*/
@Test
public void testSaveToHTTPServerSuccess() throws Exception {
- final MockHttpURLStreamHandler handler = new
MockHttpURLStreamHandler(HttpURLConnection.HTTP_OK, testSavePropertiesFile);
+ final MockHttpURLStreamHandler handler = new
MockHttpURLStreamHandler(HttpURLConnection.HTTP_OK, TEST_SAVE_PROPERTIES_FILE);
final URL url = new URL(null, "http://jakarta.apache.org", handler);
new FileHandler(conf).save(url);
final MockHttpURLConnection con = handler.getMockConnection();
@@ -1363,10 +1365,10 @@ public class TestPropertiesConfiguration {
public void testSaveWithBasePath() throws Exception {
conf.setProperty("test", "true");
final FileHandler handler = new FileHandler(conf);
-
handler.setBasePath(testSavePropertiesFile.getParentFile().toURI().toURL().toString());
- handler.setFileName(testSavePropertiesFile.getName());
+
handler.setBasePath(TEST_SAVE_PROPERTIES_FILE.getParentFile().toURI().toURL().toString());
+ handler.setFileName(TEST_SAVE_PROPERTIES_FILE.getName());
handler.save();
- assertTrue(testSavePropertiesFile.exists());
+ assertTrue(TEST_SAVE_PROPERTIES_FILE.exists());
}
/**
@@ -1376,14 +1378,14 @@ public class TestPropertiesConfiguration {
public void testSaveWithDataConfig() throws ConfigurationException {
conf = new PropertiesConfiguration();
final FileHandler handler = new FileHandler(conf);
- handler.setFile(testSavePropertiesFile);
+ handler.setFile(TEST_SAVE_PROPERTIES_FILE);
final DataConfiguration dataConfig = new DataConfiguration(conf);
dataConfig.setProperty("foo", "bar");
assertEquals("bar", conf.getString("foo"));
handler.save();
final PropertiesConfiguration config2 = new PropertiesConfiguration();
- load(config2, testSavePropertiesFile.getAbsolutePath());
+ load(config2, TEST_SAVE_PROPERTIES_FILE.getAbsolutePath());
assertEquals("bar", config2.getString("foo"));
}
@@ -1397,7 +1399,7 @@ public class TestPropertiesConfiguration {
final PropertiesConfiguration checkConfig = new
PropertiesConfiguration();
checkConfig.setListDelimiterHandler(conf.getListDelimiterHandler());
- new FileHandler(checkConfig).load(testSavePropertiesFile);
+ new FileHandler(checkConfig).load(TEST_SAVE_PROPERTIES_FILE);
ConfigurationAssert.assertConfigurationEquals(conf, checkConfig);
}
@@ -1414,7 +1416,7 @@ public class TestPropertiesConfiguration {
final PropertiesConfiguration checkConfig = new
PropertiesConfiguration();
checkConfig.setListDelimiterHandler(new
DisabledListDelimiterHandler());
- new FileHandler(checkConfig).load(testSavePropertiesFile);
+ new FileHandler(checkConfig).load(TEST_SAVE_PROPERTIES_FILE);
ConfigurationAssert.assertConfigurationEquals(conf, checkConfig);
}
@@ -1447,7 +1449,7 @@ public class TestPropertiesConfiguration {
PropertiesConfiguration.setInclude("import");
// load the configuration
- load(conf, testProperties);
+ load(conf, TEST_PROPERTIES);
// restore the previous value for the other tests
PropertiesConfiguration.setInclude("include");
@@ -1481,7 +1483,7 @@ public class TestPropertiesConfiguration {
throw new UnsupportedOperationException("Unexpected call!");
}
});
- load(conf, testProperties);
+ load(conf, TEST_PROPERTIES);
for (int i = 1; i <= propertyCount; i++) {
assertEquals(PROP_VALUE + i, conf.getString(PROP_NAME + i), "Wrong
property value at " + i);
}
@@ -1527,7 +1529,7 @@ public class TestPropertiesConfiguration {
conf.setProperty(prop, list);
saveTestConfig();
conf.clear();
- load(conf, testSavePropertiesFile.getAbsolutePath());
+ load(conf, TEST_SAVE_PROPERTIES_FILE.getAbsolutePath());
assertEquals(list, conf.getProperty(prop));
}
diff --git
a/src/test/java/org/apache/commons/configuration2/TestPropertiesConfigurationLayout.java
b/src/test/java/org/apache/commons/configuration2/TestPropertiesConfigurationLayout.java
index ee9669d5..780a6a71 100644
---
a/src/test/java/org/apache/commons/configuration2/TestPropertiesConfigurationLayout.java
+++
b/src/test/java/org/apache/commons/configuration2/TestPropertiesConfigurationLayout.java
@@ -44,12 +44,14 @@ import org.junit.jupiter.api.Test;
* Test class for PropertiesConfigurationLayout.
*/
public class TestPropertiesConfigurationLayout {
+
/**
* A mock properties configuration implementation that is used to check
whether some expected methods are called.
*/
static class LayoutTestConfiguration extends PropertiesConfiguration {
+
/** Stores a builder object. */
- public PropertiesBuilder builder;
+ private PropertiesBuilder builder;
/**
* Simulates the propertyLoaded() callback. If a builder was set, a
load() call on the layout is invoked.
diff --git
a/src/test/java/org/apache/commons/configuration2/TestSubsetConfiguration.java
b/src/test/java/org/apache/commons/configuration2/TestSubsetConfiguration.java
index c3a6ba1d..3633df52 100644
---
a/src/test/java/org/apache/commons/configuration2/TestSubsetConfiguration.java
+++
b/src/test/java/org/apache/commons/configuration2/TestSubsetConfiguration.java
@@ -44,6 +44,7 @@ import org.junit.jupiter.api.Test;
* Test case for the {@link SubsetConfiguration} class.
*/
public class TestSubsetConfiguration {
+
static final String TEST_DIR = ConfigurationAssert.TEST_DIR_NAME;
static final String TEST_FILE = "testDigesterConfiguration2.xml";
@@ -244,7 +245,7 @@ public class TestSubsetConfiguration {
}
@Test
- public void testPrefixDelimiter(){
+ public void testPrefixDelimiter() {
final BaseConfiguration config = new BaseConfiguration();
config.setProperty("[email protected]", "value1");
config.setProperty("part1.part2", "value2");
@@ -263,7 +264,7 @@ public class TestSubsetConfiguration {
}
@Test
- public void testPrefixDelimiterNegativeTest(){
+ public void testPrefixDelimiterNegativeTest() {
final BaseConfiguration config = new BaseConfiguration();
config.setProperty("[email protected]", "value1");
config.setProperty("[email protected]", "value2");
@@ -276,10 +277,8 @@ public class TestSubsetConfiguration {
protected Iterator<String> getKeysInternal() {
Class<?> subsetIteratorClass;
try {
- subsetIteratorClass = Class
-
.forName("org.apache.commons.configuration2.SubsetConfiguration$SubsetIterator");
- final Constructor<?> ctor =
subsetIteratorClass.getDeclaredConstructor(SubsetConfiguration.class,
- Iterator.class);
+ subsetIteratorClass =
Class.forName("org.apache.commons.configuration2.SubsetConfiguration$SubsetIterator");
+ final Constructor<?> ctor =
subsetIteratorClass.getDeclaredConstructor(SubsetConfiguration.class,
Iterator.class);
ctor.setAccessible(true);
return (Iterator<String>) ctor.newInstance(this,
parent.getKeys("part1.part2"));
diff --git
a/src/test/java/org/apache/commons/configuration2/TestXMLConfiguration.java
b/src/test/java/org/apache/commons/configuration2/TestXMLConfiguration.java
index 01ba754d..de8c4a24 100644
--- a/src/test/java/org/apache/commons/configuration2/TestXMLConfiguration.java
+++ b/src/test/java/org/apache/commons/configuration2/TestXMLConfiguration.java
@@ -1297,7 +1297,7 @@ public class TestXMLConfiguration {
}
@Test
- public void testSaveWithRootAttributes_ByHand() throws
ConfigurationException {
+ public void testSaveWithRootAttributesByHand() throws
ConfigurationException {
conf = new XMLConfiguration();
conf.addProperty("[@xmlns:foo]", "http://example.com/");
assertEquals("http://example.com/", conf.getString("[@xmlns:foo]"));
diff --git
a/src/test/java/org/apache/commons/configuration2/TestXMLConfiguration_605.java
b/src/test/java/org/apache/commons/configuration2/TestXMLConfiguration605.java
similarity index 99%
rename from
src/test/java/org/apache/commons/configuration2/TestXMLConfiguration_605.java
rename to
src/test/java/org/apache/commons/configuration2/TestXMLConfiguration605.java
index 6c08b39a..ded3ef11 100644
---
a/src/test/java/org/apache/commons/configuration2/TestXMLConfiguration_605.java
+++
b/src/test/java/org/apache/commons/configuration2/TestXMLConfiguration605.java
@@ -32,7 +32,7 @@ import org.junit.jupiter.api.Test;
* Tests for {@code XMLConfiguration} related to CONFIGURATION-605:
XMLConfiguration drops configuration key immediately
* following one whose value contains a comma
*/
-public class TestXMLConfiguration_605 {
+public class TestXMLConfiguration605 {
/**
* Checks whether the specified configuration contains all expected keys.
*
diff --git
a/src/test/java/org/apache/commons/configuration2/TestYAMLConfiguration.java
b/src/test/java/org/apache/commons/configuration2/TestYAMLConfiguration.java
index fca46f24..ea8bd7f0 100644
--- a/src/test/java/org/apache/commons/configuration2/TestYAMLConfiguration.java
+++ b/src/test/java/org/apache/commons/configuration2/TestYAMLConfiguration.java
@@ -43,6 +43,7 @@ import org.yaml.snakeyaml.Yaml;
* Unit test for {@link YAMLConfiguration}
*/
public class TestYAMLConfiguration {
+
/** A folder for temporary files. */
@TempDir
public File tempFolder;
@@ -68,42 +69,42 @@ public class TestYAMLConfiguration {
}
@Test
- public void testGetProperty_dictionary() {
+ public void testGetPropertyDictionary() {
assertEquals("Martin D'vloper",
yamlConfiguration.getProperty("martin.name"));
assertEquals("Developer", yamlConfiguration.getProperty("martin.job"));
assertEquals("Elite", yamlConfiguration.getProperty("martin.skill"));
}
@Test
- public void testGetProperty_integer() {
+ public void testGetPropertyInteger() {
final Object property = yamlConfiguration.getProperty("int1");
assertInstanceOf(Integer.class, property);
assertEquals(37, property);
}
@Test
- public void testGetProperty_nested() {
+ public void testGetPropertyNested() {
assertEquals("value23", yamlConfiguration.getProperty("key2.key3"));
}
@Test
- public void testGetProperty_nested_with_list() {
+ public void testGetPropertyNestedWithList() {
assertEquals(Arrays.asList("col1", "col2"),
yamlConfiguration.getProperty("key4.key5"));
}
@Test
- public void testGetProperty_simple() {
+ public void testGetPropertySimple() {
assertEquals("value1", yamlConfiguration.getProperty("key1"));
}
@Test
- public void testGetProperty_subset() {
+ public void testGetPropertySubset() {
final Configuration subset = yamlConfiguration.subset("key4");
assertEquals(Arrays.asList("col1", "col2"),
subset.getProperty("key5"));
}
@Test
- public void testGetProperty_very_nested_properties() {
+ public void testGetPropertyVeryNestedProperties() {
final Object property =
yamlConfiguration.getProperty("very.nested.properties");
assertEquals(Arrays.asList("nested1", "nested2", "nested3"), property);
}
diff --git
a/src/test/java/org/apache/commons/configuration2/beanutils/TestBeanHelper.java
b/src/test/java/org/apache/commons/configuration2/beanutils/TestBeanHelper.java
index 6f09b11e..f4d993e7 100644
---
a/src/test/java/org/apache/commons/configuration2/beanutils/TestBeanHelper.java
+++
b/src/test/java/org/apache/commons/configuration2/beanutils/TestBeanHelper.java
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.apache.commons.configuration2.beanutils;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -41,14 +42,16 @@ import org.junit.jupiter.api.Test;
* Test class for BeanHelper.
*/
public class TestBeanHelper {
+
/**
* An implementation of the BeanFactory interface used for testing. This
implementation is really simple: If the
* BeanCreationTestBean class is provided, a new instance will be created.
Otherwise an exception is thrown.
*/
private final class TestBeanFactory implements BeanFactory {
- Object parameter;
- boolean supportsDefaultClass;
+ private Object parameter;
+
+ private boolean supportsDefaultClass;
/** A counter for the created instances. */
private int createBeanCount;
diff --git
a/src/test/java/org/apache/commons/configuration2/beanutils/TestConfigurationDynaBean.java
b/src/test/java/org/apache/commons/configuration2/beanutils/TestConfigurationDynaBean.java
index ff8bb9da..ae631fac 100644
---
a/src/test/java/org/apache/commons/configuration2/beanutils/TestConfigurationDynaBean.java
+++
b/src/test/java/org/apache/commons/configuration2/beanutils/TestConfigurationDynaBean.java
@@ -6,7 +6,7 @@
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -43,6 +43,7 @@ import org.junit.jupiter.api.Test;
* </p>
*/
public class TestConfigurationDynaBean {
+
/**
* The basic test bean for each test.
*/
@@ -52,22 +53,22 @@ public class TestConfigurationDynaBean {
* The set of property names we expect to have returned when calling
{@code getDynaProperties()}. You should update this
* list when new properties are added to TestBean.
*/
- String[] properties = {"booleanProperty", "booleanSecond",
"doubleProperty", "floatProperty", "intProperty", "longProperty",
"mappedProperty.key1",
+ private String[] properties = {"booleanProperty", "booleanSecond",
"doubleProperty", "floatProperty", "intProperty", "longProperty",
"mappedProperty.key1",
"mappedProperty.key2", "mappedProperty.key3",
"mappedIntProperty.key1", "shortProperty", "stringProperty", "byteProperty",
"charProperty"};
- Object[] values = {Boolean.TRUE, Boolean.TRUE, Double.MAX_VALUE,
Float.MAX_VALUE, Integer.MAX_VALUE,
+ private Object[] values = {Boolean.TRUE, Boolean.TRUE, Double.MAX_VALUE,
Float.MAX_VALUE, Integer.MAX_VALUE,
Long.MAX_VALUE, "First Value", "Second Value", "Third Value",
Integer.MAX_VALUE, Short.MAX_VALUE,
"This is a string", Byte.MAX_VALUE, Character.MAX_VALUE};
- int[] intArray = {0, 10, 20, 30, 40};
- boolean[] booleanArray = {true, false, true, false, true};
- char[] charArray = {'a', 'b', 'c', 'd', 'e'};
- byte[] byteArray = {0, 10, 20, 30, 40};
- long[] longArray = {0, 10, 20, 30, 40};
- short[] shortArray = {0, 10, 20, 30, 40};
- float[] floatArray = {0, 10, 20, 30, 40};
- double[] doubleArray = {0.0, 10.0, 20.0, 30.0, 40.0};
- String[] stringArray = {"String 0", "String 1", "String 2", "String 3",
"String 4"};
+ private int[] intArray = {0, 10, 20, 30, 40};
+ private boolean[] booleanArray = {true, false, true, false, true};
+ private char[] charArray = {'a', 'b', 'c', 'd', 'e'};
+ private byte[] byteArray = {0, 10, 20, 30, 40};
+ private long[] longArray = {0, 10, 20, 30, 40};
+ private short[] shortArray = {0, 10, 20, 30, 40};
+ private float[] floatArray = {0, 10, 20, 30, 40};
+ private double[] doubleArray = {0.0, 10.0, 20.0, 30.0, 40.0};
+ private String[] stringArray = {"String 0", "String 1", "String 2",
"String 3", "String 4"};
/**
* Creates the underlying configuration object for the dyna bean.
diff --git
a/src/test/java/org/apache/commons/configuration2/beanutils/TestConfigurationDynaBeanXMLConfig.java
b/src/test/java/org/apache/commons/configuration2/beanutils/TestConfigurationDynaBeanXMLConfig.java
index fd1ce846..f1cb1095 100644
---
a/src/test/java/org/apache/commons/configuration2/beanutils/TestConfigurationDynaBeanXMLConfig.java
+++
b/src/test/java/org/apache/commons/configuration2/beanutils/TestConfigurationDynaBeanXMLConfig.java
@@ -6,7 +6,7 @@
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.apache.commons.configuration2.beanutils;
import org.apache.commons.configuration2.Configuration;
diff --git
a/src/test/java/org/apache/commons/configuration2/builder/TestFileBasedConfigurationBuilder.java
b/src/test/java/org/apache/commons/configuration2/builder/TestFileBasedConfigurationBuilder.java
index ee531ea8..ca5f0c48 100644
---
a/src/test/java/org/apache/commons/configuration2/builder/TestFileBasedConfigurationBuilder.java
+++
b/src/test/java/org/apache/commons/configuration2/builder/TestFileBasedConfigurationBuilder.java
@@ -63,6 +63,7 @@ import org.junit.jupiter.api.io.TempDir;
* Test class for {@code FileBasedConfigurationBuilder}.
*/
public class TestFileBasedConfigurationBuilder {
+
/** Constant for a test property name. */
private static final String PROP = "testProperty";
@@ -73,9 +74,7 @@ public class TestFileBasedConfigurationBuilder {
* @param expValue the expected value of the test property
* @throws ConfigurationException if an error occurs
*/
- private static void checkSavedConfig(final File file, final int expValue)
- throws ConfigurationException
- {
+ private static void checkSavedConfig(final File file, final int expValue)
throws ConfigurationException {
final PropertiesConfiguration config = new PropertiesConfiguration();
final FileHandler handler = new FileHandler(config);
handler.load(file);
@@ -383,8 +382,8 @@ public class TestFileBasedConfigurationBuilder {
*/
@Test
public void testGetDefaultEncodingSubClass() {
- final PropertiesConfiguration conf = new PropertiesConfiguration()
- {
+ final PropertiesConfiguration conf = new PropertiesConfiguration() {
+ // empty
};
assertEquals(PropertiesConfiguration.DEFAULT_ENCODING,
FileBasedConfigurationBuilder.getDefaultEncoding(conf.getClass()));
}
diff --git
a/src/test/java/org/apache/commons/configuration2/builder/combined/AbstractMultiFileConfigurationBuilderTest.java
b/src/test/java/org/apache/commons/configuration2/builder/combined/AbstractMultiFileConfigurationBuilderTest.java
index 1ebbbfb7..7f03e54a 100644
---
a/src/test/java/org/apache/commons/configuration2/builder/combined/AbstractMultiFileConfigurationBuilderTest.java
+++
b/src/test/java/org/apache/commons/configuration2/builder/combined/AbstractMultiFileConfigurationBuilderTest.java
@@ -27,14 +27,15 @@ import org.junit.jupiter.api.AfterEach;
* common functionality related to file name pattern which can be used by
concrete tests.
*/
public class AbstractMultiFileConfigurationBuilderTest {
+
/** The system property which selects a sub configuration. */
private static final String PROP = "Id";
/** The part of the pattern containing the variable. */
- protected static String PATTERN_VAR = "${sys:Id}";
+ protected static final String PATTERN_VAR = "${sys:Id}";
/** The pattern for file names. */
- protected static String PATTERN =
"target/test-classes/testMultiConfiguration_" + PATTERN_VAR + ".xml";
+ protected static final String PATTERN =
"target/test-classes/testMultiConfiguration_" + PATTERN_VAR + ".xml";
/**
* Creates a {@code ConfigurationInterpolator} to be used by tests. This
object contains a lookup for system properties.
diff --git
a/src/test/java/org/apache/commons/configuration2/builder/fluent/TestConfigurations.java
b/src/test/java/org/apache/commons/configuration2/builder/fluent/TestConfigurations.java
index d90f3a4a..4d220dfe 100644
---
a/src/test/java/org/apache/commons/configuration2/builder/fluent/TestConfigurations.java
+++
b/src/test/java/org/apache/commons/configuration2/builder/fluent/TestConfigurations.java
@@ -357,30 +357,24 @@ public class TestConfigurations {
final FileBasedConfigurationBuilder<PropertiesConfiguration>
builderFail = configs.propertiesBuilder(absPath);
assertThrows(ConfigurationException.class,
builderFail::getConfiguration);
assertThrows(ConfigurationException.class, () ->
configs.properties(absPath));
- {
- // Expect success:
- // @formatter:off
+ // Expect success:
+ // @formatter:off
final Map<String, Object> map =
new Parameters().properties()
.setPath(absPath)
.setIncludeListener(PropertiesConfiguration.NOOP_INCLUDE_LISTENER)
.getParameters();
- // @formatter:on
- final BasicConfigurationBuilder<PropertiesConfiguration> builderOk
= configs.propertiesBuilder(absPath).addParameters(map);
- final PropertiesConfiguration configuration =
builderOk.getConfiguration();
- assertEquals("valueA", configuration.getString("keyA"));
- }
- {
- // Expect success:
- // @formatter:off
- final BasicConfigurationBuilder<PropertiesConfiguration> builderOk
= configs.propertiesBuilder(
+ // @formatter:on
+ final BasicConfigurationBuilder<PropertiesConfiguration> builderOk =
configs.propertiesBuilder(absPath).addParameters(map);
+ assertEquals("valueA", builderOk.getConfiguration().getString("keyA"));
+ // Expect success:
+ // @formatter:off
+ final BasicConfigurationBuilder<PropertiesConfiguration>
builderOk2 = configs.propertiesBuilder(
new Parameters().properties()
.setPath(absPath)
.setIncludeListener(PropertiesConfiguration.NOOP_INCLUDE_LISTENER));
- // @formatter:on
- final PropertiesConfiguration configuration =
builderOk.getConfiguration();
- assertEquals("valueA", configuration.getString("keyA"));
- }
+ // @formatter:on
+ assertEquals("valueA",
builderOk2.getConfiguration().getString("keyA"));
}
/**
diff --git
a/src/test/java/org/apache/commons/configuration2/event/TestEventListenerList.java
b/src/test/java/org/apache/commons/configuration2/event/TestEventListenerList.java
index ca7bbc62..119b6986 100644
---
a/src/test/java/org/apache/commons/configuration2/event/TestEventListenerList.java
+++
b/src/test/java/org/apache/commons/configuration2/event/TestEventListenerList.java
@@ -229,7 +229,7 @@ public class TestEventListenerList {
*/
@Test
public void testEventListenerIteratorWrongEvent() {
- final EventListener<EventSub2> listener = event -> {};
+ final EventListener<EventSub2> listener = event -> { };
list.addEventListener(typeSub2, listener);
final EventListenerList.EventListenerIterator<EventSub2> iterator =
list.getEventListenerIterator(typeSub2);
assertTrue(iterator.hasNext());
diff --git
a/src/test/java/org/apache/commons/configuration2/event/TestEventSource.java
b/src/test/java/org/apache/commons/configuration2/event/TestEventSource.java
index f42b930f..066d41a4 100644
--- a/src/test/java/org/apache/commons/configuration2/event/TestEventSource.java
+++ b/src/test/java/org/apache/commons/configuration2/event/TestEventSource.java
@@ -38,9 +38,10 @@ public class TestEventSource {
* operation.
*/
private static final class CountingEventSource extends BaseEventSource
implements Cloneable {
- int eventCount;
- int errorCount;
+ private int eventCount;
+
+ private int errorCount;
@Override
protected ConfigurationErrorEvent createErrorEvent(final EventType<?
extends ConfigurationErrorEvent> type, final EventType<?> opType,
@@ -61,7 +62,7 @@ public class TestEventSource {
private static final Object TEST_PROPVALUE = "a test property value";
/** Constant for the event property name. */
- private final String TEST_PROPNAME = "test.property.name";
+ private static final String TEST_PROPNAME = "test.property.name";
/** The object under test. */
private CountingEventSource source;
diff --git
a/src/test/java/org/apache/commons/configuration2/interpol/TestConfigurationInterpolator.java
b/src/test/java/org/apache/commons/configuration2/interpol/TestConfigurationInterpolator.java
index 3108168a..6d0ef809 100644
---
a/src/test/java/org/apache/commons/configuration2/interpol/TestConfigurationInterpolator.java
+++
b/src/test/java/org/apache/commons/configuration2/interpol/TestConfigurationInterpolator.java
@@ -154,7 +154,7 @@ public class TestConfigurationInterpolator {
}
@Test
- public void testDefaultStringLookupsHolder_allLookups() {
+ public void testDefaultStringLookupsHolderAllLookups() {
final Properties props = new Properties();
props.setProperty(ConfigurationInterpolator.DEFAULT_PREFIX_LOOKUPS_PROPERTY,
"BASE64_DECODER BASE64_ENCODER const, date, dns, environment "
@@ -184,34 +184,29 @@ public class TestConfigurationInterpolator {
}
@Test
- public void testDefaultStringLookupsHolder_givenSingleLookup() {
+ public void testDefaultStringLookupsHolderGivenSingleLookup() {
final Properties props = new Properties();
props.setProperty(ConfigurationInterpolator.DEFAULT_PREFIX_LOOKUPS_PROPERTY,
"base64_encoder");
-
- checkDefaultPrefixLookupsHolder(props,
- "base64",
- StringLookupFactory.KEY_BASE64_ENCODER);
+ checkDefaultPrefixLookupsHolder(props, "base64",
StringLookupFactory.KEY_BASE64_ENCODER);
}
@Test
- public void testDefaultStringLookupsHolder_givenSingleLookup_weirdString()
{
+ public void testDefaultStringLookupsHolderGivenSingleLookupWeirdString() {
final Properties props = new Properties();
props.setProperty(ConfigurationInterpolator.DEFAULT_PREFIX_LOOKUPS_PROPERTY, "
\n \t ,, DnS , , ");
-
checkDefaultPrefixLookupsHolder(props, StringLookupFactory.KEY_DNS);
}
@Test
- public void testDefaultStringLookupsHolder_invalidLookupsDefinition() {
+ public void testDefaultStringLookupsHolderInvalidLookupsDefinition() {
final Properties props = new Properties();
props.setProperty(ConfigurationInterpolator.DEFAULT_PREFIX_LOOKUPS_PROPERTY,
"base64_encoder nope");
-
final Exception exc = assertThrows(Exception.class, () -> new
ConfigurationInterpolator.DefaultPrefixLookupsHolder(props));
assertEquals("Invalid default lookups definition: base64_encoder
nope", exc.getMessage());
}
@Test
- public void testDefaultStringLookupsHolder_lookupsPropertyEmptyAndBlank() {
+ public void testDefaultStringLookupsHolderLookupsPropertyEmptyAndBlank() {
final Properties propsWithNull = new Properties();
propsWithNull.setProperty(ConfigurationInterpolator.DEFAULT_PREFIX_LOOKUPS_PROPERTY,
"");
@@ -224,7 +219,7 @@ public class TestConfigurationInterpolator {
}
@Test
- public void testDefaultStringLookupsHolder_lookupsPropertyNotPresent() {
+ public void testDefaultStringLookupsHolderLookupsPropertyNotPresent() {
checkDefaultPrefixLookupsHolder(new Properties(),
"base64",
StringLookupFactory.KEY_BASE64_DECODER,
@@ -244,7 +239,7 @@ public class TestConfigurationInterpolator {
}
@Test
- public void testDefaultStringLookupsHolder_multipleLookups() {
+ public void testDefaultStringLookupsHolderMultipleLookups() {
final Properties props = new Properties();
props.setProperty(ConfigurationInterpolator.DEFAULT_PREFIX_LOOKUPS_PROPERTY,
"dns, url script ");
diff --git
a/src/test/java/org/apache/commons/configuration2/interpol/TestExprLookup.java
b/src/test/java/org/apache/commons/configuration2/interpol/TestExprLookup.java
index 8ef670b5..27c7b181 100644
---
a/src/test/java/org/apache/commons/configuration2/interpol/TestExprLookup.java
+++
b/src/test/java/org/apache/commons/configuration2/interpol/TestExprLookup.java
@@ -41,8 +41,10 @@ import org.junit.jupiter.api.Test;
* Test class for ExprLookup.
*/
public class TestExprLookup {
+
public static class Utility {
- String message;
+
+ private String message;
public Utility(final String msg) {
this.message = msg;
diff --git
a/src/test/java/org/apache/commons/configuration2/io/TestConfigurationLogger.java
b/src/test/java/org/apache/commons/configuration2/io/TestConfigurationLogger.java
index 2eb3dd2c..1a348c56 100644
---
a/src/test/java/org/apache/commons/configuration2/io/TestConfigurationLogger.java
+++
b/src/test/java/org/apache/commons/configuration2/io/TestConfigurationLogger.java
@@ -171,9 +171,8 @@ public class TestConfigurationLogger {
assertNotNull(logger1.getLog());
if (logger1.getLog() instanceof Log4JLogger) {
assertEquals(logger1.getLog(), logger2.getLog());
- } else {
- // TODO assert what for the Slf4j adapter?
}
+ // else: TODO assert what for the Slf4j adapter?
}
/**
diff --git a/src/test/java/org/apache/commons/configuration2/test/HsqlDB.java
b/src/test/java/org/apache/commons/configuration2/test/HsqlDB.java
index 44dc905a..c6004446 100644
--- a/src/test/java/org/apache/commons/configuration2/test/HsqlDB.java
+++ b/src/test/java/org/apache/commons/configuration2/test/HsqlDB.java
@@ -32,7 +32,9 @@ import org.apache.commons.logging.LogFactory;
*/
public class HsqlDB {
- private static final Log log = LogFactory.getLog(HsqlDB.class);
+
+ private static final Log LOG = LogFactory.getLog(HsqlDB.class);
+
private final Connection connection;
public HsqlDB(final String uri, final String databaseDriver, final String
loadFile) throws Exception {
@@ -80,7 +82,7 @@ public class HsqlDB {
try {
statement.execute(cmd);
} catch (final SQLException sqle) {
- log.warn("Statement: " + cmd + ": " + sqle.getMessage());
+ LOG.warn("Statement: " + cmd + ": " + sqle.getMessage());
}
commands = commands.substring(targetPos + 2);
diff --git
a/src/test/java/org/apache/commons/configuration2/tree/NodeStructureHelper.java
b/src/test/java/org/apache/commons/configuration2/tree/NodeStructureHelper.java
index d480445b..ce68c037 100644
---
a/src/test/java/org/apache/commons/configuration2/tree/NodeStructureHelper.java
+++
b/src/test/java/org/apache/commons/configuration2/tree/NodeStructureHelper.java
@@ -30,7 +30,8 @@ import org.apache.commons.lang3.StringUtils;
* A helper class for tests related to hierarchies of {@code ImmutableNode}
objects. This class provides functionality
* for creating test trees and accessing single nodes. It can be used by
various test classes.
*/
-public class NodeStructureHelper {
+public final class NodeStructureHelper {
+
/** A pattern for parsing node keys with optional indices. */
private static final Pattern PAT_KEY_WITH_INDEX =
Pattern.compile("(\\w+)\\((\\d+)\\)");
@@ -466,4 +467,8 @@ public class NodeStructureHelper {
public static int worksLength(final int authorIdx) {
return WORKS[authorIdx].length;
}
+
+ private NodeStructureHelper() {
+ // empty
+ }
}
diff --git
a/src/test/java/org/apache/commons/configuration2/tree/TestDefaultExpressionEngine.java
b/src/test/java/org/apache/commons/configuration2/tree/TestDefaultExpressionEngine.java
index fe9f69f4..f39b2049 100644
---
a/src/test/java/org/apache/commons/configuration2/tree/TestDefaultExpressionEngine.java
+++
b/src/test/java/org/apache/commons/configuration2/tree/TestDefaultExpressionEngine.java
@@ -34,14 +34,15 @@ import org.junit.jupiter.api.Test;
* Test class for DefaultExpressionEngine.
*/
public class TestDefaultExpressionEngine {
+
/** Stores the names of the test nodes representing tables. */
- private static final String[] tables = {"users", "documents"};
+ private static final String[] TABLES = {"users", "documents"};
/** Stores the types of the test table nodes. */
- private static final String[] tabTypes = {"system", "application"};
+ private static final String[] TAB_TYPES = {"system", "application"};
/** Test data fields for the node hierarchy. */
- private static final String[][] fields = {{"uid", "uname", "firstName",
"lastName", "email"}, {"docid", "name", "creationDate", "authorID", "version"}};
+ private static final String[][] FIELDS = {{"uid", "uname", "firstName",
"lastName", "email"}, {"docid", "name", "creationDate", "authorID", "version"}};
/** The root of a hierarchy with test nodes. */
private static ImmutableNode root;
@@ -95,17 +96,17 @@ public class TestDefaultExpressionEngine {
* @return the root of the test node hierarchy
*/
private static ImmutableNode setUpNodes() {
- final ImmutableNode.Builder nodeTablesBuilder = new
ImmutableNode.Builder(tables.length);
+ final ImmutableNode.Builder nodeTablesBuilder = new
ImmutableNode.Builder(TABLES.length);
nodeTablesBuilder.name("tables");
- for (int i = 0; i < tables.length; i++) {
+ for (int i = 0; i < TABLES.length; i++) {
final ImmutableNode.Builder nodeTableBuilder = new
ImmutableNode.Builder(2);
nodeTableBuilder.name("table");
- nodeTableBuilder.addChild(new
ImmutableNode.Builder().name("name").value(tables[i]).create());
- nodeTableBuilder.addAttribute("type", tabTypes[i]);
+ nodeTableBuilder.addChild(new
ImmutableNode.Builder().name("name").value(TABLES[i]).create());
+ nodeTableBuilder.addAttribute("type", TAB_TYPES[i]);
- final ImmutableNode.Builder nodeFieldsBuilder = new
ImmutableNode.Builder(fields[i].length);
- for (int j = 0; j < fields[i].length; j++) {
- nodeFieldsBuilder.addChild(createFieldNode(fields[i][j]));
+ final ImmutableNode.Builder nodeFieldsBuilder = new
ImmutableNode.Builder(FIELDS[i].length);
+ for (int j = 0; j < FIELDS[i].length; j++) {
+ nodeFieldsBuilder.addChild(createFieldNode(FIELDS[i][j]));
}
nodeTableBuilder.addChild(nodeFieldsBuilder.name("fields").create());
nodeTablesBuilder.addChild(nodeTableBuilder.create());
@@ -403,7 +404,7 @@ public class TestDefaultExpressionEngine {
@Test
public void testPrepareAddAttribute() {
final NodeAddData<ImmutableNode> data = engine.prepareAdd(root,
"tables.table(0)[@tableSpace]", handler);
- assertEquals(tables[0],
data.getParent().getChildren().get(0).getValue());
+ assertEquals(TABLES[0],
data.getParent().getChildren().get(0).getValue());
assertEquals("tableSpace", data.getNewNodeName());
assertTrue(data.isAttribute());
assertTrue(data.getPathNodes().isEmpty());
@@ -484,7 +485,7 @@ public class TestDefaultExpressionEngine {
NodeAddData<ImmutableNode> data = engine.prepareAdd(root,
"tables/table[0]/test", handler);
assertEquals("test", data.getNewNodeName());
assertFalse(data.isAttribute());
- assertEquals(tables[0],
data.getParent().getChildren().get(0).getValue());
+ assertEquals(TABLES[0],
data.getParent().getChildren().get(0).getValue());
data = engine.prepareAdd(root, "a/complete/new/path@attr", handler);
assertEquals("attr", data.getNewNodeName());
@@ -502,7 +503,7 @@ public class TestDefaultExpressionEngine {
assertTrue(data.getPathNodes().isEmpty());
assertEquals("table", data.getParent().getNodeName());
final ImmutableNode node = data.getParent().getChildren().get(0);
- assertEquals(tables[0], node.getValue());
+ assertEquals(TABLES[0], node.getValue());
data = engine.prepareAdd(root,
"tables.table(1).fields.field(2).alias", handler);
assertEquals("alias", data.getNewNodeName());
@@ -557,8 +558,8 @@ public class TestDefaultExpressionEngine {
@Test
public void testQueryAlternativeSyntax() {
setUpAlternativeSyntax();
- checkKeyValue("tables/table[1]/name", "name", tables[1]);
- checkAttributeValue("tables/table[0]@type", "type", tabTypes[0]);
+ checkKeyValue("tables/table[1]/name", "name", TABLES[1]);
+ checkAttributeValue("tables/table[0]@type", "type", TAB_TYPES[0]);
checkAttributeValue("@test", "test", "true");
checkKeyValue("connection.settings/usr.name", "usr.name", "scott");
}
@@ -571,8 +572,8 @@ public class TestDefaultExpressionEngine {
final DefaultExpressionEngineSymbols symbols = new
DefaultExpressionEngineSymbols.Builder(DefaultExpressionEngineSymbols.DEFAULT_SYMBOLS)
.setAttributeEnd(null).setAttributeStart(DefaultExpressionEngineSymbols.DEFAULT_PROPERTY_DELIMITER).create();
engine = new DefaultExpressionEngine(symbols);
- checkKeyValue("tables.table(0).name", "name", tables[0]);
- checkAttributeValue("tables.table(0).type", "type", tabTypes[0]);
+ checkKeyValue("tables.table(0).name", "name", TABLES[0]);
+ checkAttributeValue("tables.table(0).type", "type", TAB_TYPES[0]);
checkKey("tables.table.type", "type", 2);
}
@@ -612,12 +613,12 @@ public class TestDefaultExpressionEngine {
*/
@Test
public void testQueryNodes() {
- for (int i = 0; i < tables.length; i++) {
- checkKeyValue("tables.table(" + i + ").name", "name", tables[i]);
- checkAttributeValue("tables.table(" + i + ")[@type]", "type",
tabTypes[i]);
+ for (int i = 0; i < TABLES.length; i++) {
+ checkKeyValue("tables.table(" + i + ").name", "name", TABLES[i]);
+ checkAttributeValue("tables.table(" + i + ")[@type]", "type",
TAB_TYPES[i]);
- for (int j = 0; j < fields[i].length; j++) {
- checkKeyValue("tables.table(" + i + ").fields.field(" + j +
").name", "name", fields[i][j]);
+ for (int j = 0; j < FIELDS[i].length; j++) {
+ checkKeyValue("tables.table(" + i + ").fields.field(" + j +
").name", "name", FIELDS[i][j]);
}
}
}
diff --git
a/src/test/java/org/apache/commons/configuration2/web/TestAppletConfiguration.java
b/src/test/java/org/apache/commons/configuration2/web/TestAppletConfiguration.java
index a9822a56..17ddb4c4 100644
---
a/src/test/java/org/apache/commons/configuration2/web/TestAppletConfiguration.java
+++
b/src/test/java/org/apache/commons/configuration2/web/TestAppletConfiguration.java
@@ -34,8 +34,9 @@ import org.junit.jupiter.api.Test;
* Test case for the {@link AppletConfiguration} class.
*/
public class TestAppletConfiguration extends TestAbstractConfiguration {
+
/** A flag whether tests with an applet can be run. */
- boolean supportsApplet;
+ private boolean supportsApplet;
@Override
protected AbstractConfiguration getConfiguration() {