You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2018/09/27 22:24:26 UTC
svn commit: r1842194 [21/34] - in /commons/proper/configuration/trunk/src:
main/java/org/apache/commons/configuration2/
main/java/org/apache/commons/configuration2/beanutils/
main/java/org/apache/commons/configuration2/builder/
main/java/org/apache/com...
Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestPropertiesConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestPropertiesConfiguration.java?rev=1842194&r1=1842193&r2=1842194&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestPropertiesConfiguration.java (original)
+++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestPropertiesConfiguration.java Thu Sep 27 22:24:23 2018
@@ -105,10 +105,10 @@ public class TestPropertiesConfiguration
* @return the file handler associated with the configuration
* @throws ConfigurationException if an error occurs
*/
- private static FileHandler load(PropertiesConfiguration pc, String fileName)
+ private static FileHandler load(final PropertiesConfiguration pc, final String fileName)
throws ConfigurationException
{
- FileHandler handler = new FileHandler(pc);
+ final FileHandler handler = new FileHandler(pc);
handler.setFileName(fileName);
handler.load();
return handler;
@@ -117,7 +117,7 @@ public class TestPropertiesConfiguration
@Test
public void testLoad() throws Exception
{
- String loaded = conf.getString("configuration.loaded");
+ final String loaded = conf.getString("configuration.loaded");
assertEquals("true", loaded);
}
@@ -128,8 +128,8 @@ public class TestPropertiesConfiguration
@Test
public void testAppend() throws Exception
{
- File file2 = ConfigurationAssert.getTestFile("threesome.properties");
- FileHandler handler = new FileHandler(conf);
+ final File file2 = ConfigurationAssert.getTestFile("threesome.properties");
+ final FileHandler handler = new FileHandler(conf);
handler.load(file2);
assertEquals("aaa", conf.getString("test.threesome.one"));
assertEquals("true", conf.getString("configuration.loaded"));
@@ -140,9 +140,9 @@ public class TestPropertiesConfiguration
*
* @param key the key to be checked
*/
- private void checkEmpty(String key)
+ private void checkEmpty(final String key)
{
- String empty = conf.getString(key);
+ final String empty = conf.getString(key);
assertNotNull("Property not found: " + key, empty);
assertEquals("Wrong value for property " + key, "", empty);
}
@@ -182,7 +182,7 @@ public class TestPropertiesConfiguration
@Test
public void testLoadInclude() throws Exception
{
- String loaded = conf.getString("include.loaded");
+ final String loaded = conf.getString("include.loaded");
assertEquals("true", loaded);
}
@@ -193,7 +193,7 @@ public class TestPropertiesConfiguration
@Test
public void testLoadIncludeInterpol() throws Exception
{
- String loaded = conf.getString("include.interpol.loaded");
+ final String loaded = conf.getString("include.interpol.loaded");
assertEquals("true", loaded);
}
@@ -204,11 +204,11 @@ public class TestPropertiesConfiguration
@Test
public void testLoadIncludeFromReader() throws ConfigurationException
{
- StringReader in =
+ final StringReader in =
new StringReader(PropertiesConfiguration.getInclude() + " = "
+ ConfigurationAssert.getTestURL("include.properties"));
conf = new PropertiesConfiguration();
- FileHandler handler = new FileHandler(conf);
+ final FileHandler handler = new FileHandler(conf);
handler.load(in);
assertEquals("Include file not loaded", "true",
conf.getString("include.loaded"));
@@ -221,11 +221,11 @@ public class TestPropertiesConfiguration
public void testDisableIncludes() throws ConfigurationException,
IOException
{
- String content =
+ final String content =
PropertiesConfiguration.getInclude()
+ " = nonExistingIncludeFile" + CR + PROP_NAME + " = "
+ PROP_VALUE + CR;
- StringReader in = new StringReader(content);
+ final StringReader in = new StringReader(content);
conf = new PropertiesConfiguration();
conf.setIncludesAllowed(false);
conf.read(in);
@@ -239,7 +239,7 @@ public class TestPropertiesConfiguration
public void testMultipleIncludeFiles() throws ConfigurationException
{
conf = new PropertiesConfiguration();
- FileHandler handler = new FileHandler(conf);
+ final FileHandler handler = new FileHandler(conf);
handler.load(ConfigurationAssert.getTestFile("config/testMultiInclude.properties"));
assertEquals("Wrong top-level property", "topValue",
conf.getString("top"));
@@ -271,7 +271,7 @@ public class TestPropertiesConfiguration
@Test
public void testList() throws Exception
{
- List<Object> packages = conf.getList("packages");
+ final List<Object> packages = conf.getList("packages");
// we should get 3 packages here
assertEquals(3, packages.size());
}
@@ -281,7 +281,7 @@ public class TestPropertiesConfiguration
{
// add an array of strings to the configuration
conf.addProperty("string", "value1");
- List<Object> list = new ArrayList<>();
+ final List<Object> list = new ArrayList<>();
for (int i = 1; i < 5; i++)
{
list.add("value" + i);
@@ -300,13 +300,13 @@ public class TestPropertiesConfiguration
public void testSaveToCustomURL() throws Exception
{
// save the configuration to a custom URL
- URL url = new URL("foo", "", 0, folder.newFile("testsave-custom-url.properties").getAbsolutePath(), new FileURLStreamHandler());
- FileHandler handlerSave = new FileHandler(conf);
+ final URL url = new URL("foo", "", 0, folder.newFile("testsave-custom-url.properties").getAbsolutePath(), new FileURLStreamHandler());
+ final FileHandler handlerSave = new FileHandler(conf);
handlerSave.save(url);
// reload the configuration
- PropertiesConfiguration config2 = new PropertiesConfiguration();
- FileHandler handlerLoad = new FileHandler(config2);
+ final PropertiesConfiguration config2 = new PropertiesConfiguration();
+ final FileHandler handlerLoad = new FileHandler(config2);
handlerLoad.load(url);
assertEquals("true", config2.getString("configuration.loaded"));
}
@@ -317,7 +317,7 @@ public class TestPropertiesConfiguration
conf = new PropertiesConfiguration();
// add an array of strings to the configuration
conf.addProperty("string", "value1");
- List<Object> list = new ArrayList<>();
+ final List<Object> list = new ArrayList<>();
for (int i = 1; i < 5; i++)
{
list.add("value" + i);
@@ -344,7 +344,7 @@ public class TestPropertiesConfiguration
conf.addProperty("test.dirs", "C:\\Temp\\,D:\\Data\\");
saveTestConfig();
- PropertiesConfiguration checkConfig = new PropertiesConfiguration();
+ final PropertiesConfiguration checkConfig = new PropertiesConfiguration();
checkConfig.setListDelimiterHandler(new DisabledListDelimiterHandler());
new FileHandler(checkConfig).load(testSavePropertiesFile);
ConfigurationAssert.assertConfigurationEquals(conf, checkConfig);
@@ -360,7 +360,7 @@ public class TestPropertiesConfiguration
conf.setListDelimiterHandler(new DefaultListDelimiterHandler(','));
saveTestConfig();
- PropertiesConfiguration checkConfig = new PropertiesConfiguration();
+ final PropertiesConfiguration checkConfig = new PropertiesConfiguration();
checkConfig.setListDelimiterHandler(conf.getListDelimiterHandler());
new FileHandler(checkConfig).load(testSavePropertiesFile);
ConfigurationAssert.assertConfigurationEquals(conf, checkConfig);
@@ -369,7 +369,7 @@ public class TestPropertiesConfiguration
@Test(expected = ConfigurationException.class)
public void testSaveMissingFilename() throws ConfigurationException
{
- FileHandler handler = new FileHandler(conf);
+ final FileHandler handler = new FileHandler(conf);
handler.save();
}
@@ -380,7 +380,7 @@ public class TestPropertiesConfiguration
public void testSaveWithBasePath() throws Exception
{
conf.setProperty("test", "true");
- FileHandler handler = new FileHandler(conf);
+ final FileHandler handler = new FileHandler(conf);
handler.setBasePath(testSavePropertiesFile.getParentFile().toURI().toURL()
.toString());
handler.setFileName(testSavePropertiesFile.getName());
@@ -397,7 +397,7 @@ public class TestPropertiesConfiguration
throws ConfigurationException
{
conf.addProperty("test.dirs", "C:\\Temp\\\\,D:\\Data\\\\,E:\\Test\\");
- List<Object> dirs = conf.getList("test.dirs");
+ final List<Object> dirs = conf.getList("test.dirs");
assertEquals("Wrong number of list elements", 3, dirs.size());
saveTestConfig();
checkSavedConfig();
@@ -406,8 +406,8 @@ public class TestPropertiesConfiguration
@Test
public void testLoadViaPropertyWithBasePath() throws Exception
{
- PropertiesConfiguration pc = new PropertiesConfiguration();
- FileHandler handler = new FileHandler(pc);
+ final PropertiesConfiguration pc = new PropertiesConfiguration();
+ final FileHandler handler = new FileHandler(pc);
handler.setBasePath(testBasePath);
handler.setFileName("test.properties");
handler.load();
@@ -418,8 +418,8 @@ public class TestPropertiesConfiguration
@Test
public void testLoadViaPropertyWithBasePath2() throws Exception
{
- PropertiesConfiguration pc = new PropertiesConfiguration();
- FileHandler handler = new FileHandler(pc);
+ final PropertiesConfiguration pc = new PropertiesConfiguration();
+ final FileHandler handler = new FileHandler(pc);
handler.setBasePath(testBasePath2);
handler.setFileName("test.properties");
handler.load();
@@ -430,9 +430,9 @@ public class TestPropertiesConfiguration
@Test
public void testLoadFromFile() throws Exception
{
- File file = ConfigurationAssert.getTestFile("test.properties");
+ final File file = ConfigurationAssert.getTestFile("test.properties");
conf.clear();
- FileHandler handler = new FileHandler(conf);
+ final FileHandler handler = new FileHandler(conf);
handler.setFile(file);
handler.load();
@@ -455,7 +455,7 @@ public class TestPropertiesConfiguration
private PropertiesConfiguration checkSavedConfig()
throws ConfigurationException
{
- PropertiesConfiguration checkConfig = new PropertiesConfiguration();
+ final PropertiesConfiguration checkConfig = new PropertiesConfiguration();
checkConfig.setListDelimiterHandler(new LegacyListDelimiterHandler(','));
load(checkConfig, testSavePropertiesFile.getAbsolutePath());
ConfigurationAssert.assertConfigurationEquals(conf, checkConfig);
@@ -465,14 +465,14 @@ public class TestPropertiesConfiguration
@Test
public void testGetStringWithEscapedChars()
{
- String property = conf.getString("test.unescape");
+ final String property = conf.getString("test.unescape");
assertEquals("String with escaped characters", "This \n string \t contains \" escaped \\ characters", property);
}
@Test
public void testGetStringWithEscapedComma()
{
- String property = conf.getString("test.unescape.list-separator");
+ final String property = conf.getString("test.unescape.list-separator");
assertEquals("String with an escaped list separator", "This string contains , an escaped list separator", property);
}
@@ -486,7 +486,7 @@ public class TestPropertiesConfiguration
public void testEscapedKey() throws Exception
{
conf.clear();
- FileHandler handler = new FileHandler(conf);
+ final FileHandler handler = new FileHandler(conf);
handler.load(new StringReader("\\u0066\\u006f\\u006f=bar"));
assertEquals("value of the 'foo' property", "bar", conf.getString("foo"));
@@ -495,7 +495,7 @@ public class TestPropertiesConfiguration
@Test
public void testMixedArray()
{
- String[] array = conf.getStringArray("test.mixed.array");
+ final String[] array = conf.getStringArray("test.mixed.array");
assertEquals("array length", 4, array.length);
assertEquals("1st element", "a", array[0]);
@@ -507,7 +507,7 @@ public class TestPropertiesConfiguration
@Test
public void testMultilines()
{
- String property = "This is a value spread out across several adjacent "
+ final String property = "This is a value spread out across several adjacent "
+ "natural lines by escaping the line terminator with "
+ "a backslash character.";
@@ -523,7 +523,7 @@ public class TestPropertiesConfiguration
{
assertEquals("Wrong initial string", "a^b^c",
conf.getString("test.other.delimiter"));
- PropertiesConfiguration pc2 = new PropertiesConfiguration();
+ final PropertiesConfiguration pc2 = new PropertiesConfiguration();
pc2.setListDelimiterHandler(new DefaultListDelimiterHandler('^'));
load(pc2, testProperties);
assertEquals("Should obtain the first value", "a",
@@ -537,7 +537,7 @@ public class TestPropertiesConfiguration
{
assertEquals(4, conf.getList("test.mixed.array").size());
- PropertiesConfiguration pc2 = new PropertiesConfiguration();
+ final PropertiesConfiguration pc2 = new PropertiesConfiguration();
load(pc2, testProperties);
assertEquals(2, pc2.getList("test.mixed.array").size());
}
@@ -548,7 +548,7 @@ public class TestPropertiesConfiguration
@Test
public void testNewLineEscaping()
{
- List<Object> list = conf.getList("test.path");
+ final List<Object> list = conf.getList("test.path");
assertEquals(3, list.size());
assertEquals("C:\\path1\\", list.get(0));
assertEquals("C:\\path2\\", list.get(1));
@@ -605,9 +605,9 @@ public class TestPropertiesConfiguration
@Test
public void testIncludeInSubDir() throws ConfigurationException
{
- CombinedConfigurationBuilder builder = new CombinedConfigurationBuilder();
+ final CombinedConfigurationBuilder builder = new CombinedConfigurationBuilder();
builder.configure(new FileBasedBuilderParametersImpl().setFileName("testFactoryPropertiesInclude.xml"));
- Configuration config = builder.getConfiguration();
+ final Configuration config = builder.getConfiguration();
assertTrue(config.getBoolean("deeptest"));
assertTrue(config.getBoolean("deepinclude"));
assertFalse(config.containsKey("deeptestinvalid"));
@@ -624,9 +624,9 @@ public class TestPropertiesConfiguration
conf.setHeader("My header");
conf.setProperty("prop", "value");
- StringWriter out = new StringWriter();
+ final StringWriter out = new StringWriter();
new FileHandler(conf).save(out);
- String content = out.toString();
+ final String content = out.toString();
assertTrue("Header could not be found", content.indexOf("# My header"
+ EOL + EOL) == 0);
assertTrue("Property could not be found", content.indexOf("prop = value" + EOL) > 0);
@@ -638,11 +638,11 @@ public class TestPropertiesConfiguration
@Test
public void testGetLayout()
{
- PropertiesConfigurationLayout layout = conf.getLayout();
+ final PropertiesConfigurationLayout layout = conf.getLayout();
assertNotNull("Layout is null", layout);
assertSame("Different object returned", layout, conf.getLayout());
conf.setLayout(null);
- PropertiesConfigurationLayout layout2 = conf.getLayout();
+ final PropertiesConfigurationLayout layout2 = conf.getLayout();
assertNotNull("Layout 2 is null", layout2);
assertNotSame("Same object returned", layout, layout2);
}
@@ -653,7 +653,7 @@ public class TestPropertiesConfiguration
@Test
public void testPropertyLoaded() throws ConfigurationException
{
- DummyLayout layout = new DummyLayout();
+ final DummyLayout layout = new DummyLayout();
conf.setLayout(layout);
conf.propertyLoaded("layoutLoadedProperty", "yes");
assertEquals("Layout's load() was called", 0, layout.loadCalls);
@@ -666,7 +666,7 @@ public class TestPropertiesConfiguration
@Test
public void testPropertyLoadedInclude() throws ConfigurationException
{
- DummyLayout layout = new DummyLayout();
+ final DummyLayout layout = new DummyLayout();
conf.setLayout(layout);
conf.propertyLoaded(PropertiesConfiguration.getInclude(), "testClasspath.properties,testEqual.properties");
assertEquals("Layout's load() was not correctly called", 2, layout.loadCalls);
@@ -680,7 +680,7 @@ public class TestPropertiesConfiguration
@Test
public void testPropertyLoadedIncludeNotAllowed() throws ConfigurationException
{
- DummyLayout layout = new DummyLayout();
+ final DummyLayout layout = new DummyLayout();
conf.setLayout(layout);
conf.setIncludesAllowed(false);
conf.propertyLoaded(PropertiesConfiguration.getInclude(), "testClassPath.properties,testEqual.properties");
@@ -708,7 +708,7 @@ public class TestPropertiesConfiguration
@Test
public void testClone() throws ConfigurationException
{
- PropertiesConfiguration copy = (PropertiesConfiguration) conf.clone();
+ final PropertiesConfiguration copy = (PropertiesConfiguration) conf.clone();
assertNotSame("Copy has same layout object", conf.getLayout(),
copy.getLayout());
assertEquals("Wrong number of event listeners for original", 1, conf
@@ -719,9 +719,9 @@ public class TestPropertiesConfiguration
.getEventListeners(ConfigurationEvent.ANY).iterator().next());
assertSame("Wrong event listener for clone", copy.getLayout(), copy
.getEventListeners(ConfigurationEvent.ANY).iterator().next());
- StringWriter outConf = new StringWriter();
+ final StringWriter outConf = new StringWriter();
new FileHandler(conf).save(outConf);
- StringWriter outCopy = new StringWriter();
+ final StringWriter outCopy = new StringWriter();
new FileHandler(copy).save(outCopy);
assertEquals("Output from copy is different", outConf.toString(), outCopy.toString());
}
@@ -733,7 +733,7 @@ public class TestPropertiesConfiguration
public void testCloneNullLayout()
{
conf = new PropertiesConfiguration();
- PropertiesConfiguration copy = (PropertiesConfiguration) conf.clone();
+ final PropertiesConfiguration copy = (PropertiesConfiguration) conf.clone();
assertNotSame("Layout objects are the same", conf.getLayout(), copy.getLayout());
}
@@ -743,11 +743,11 @@ public class TestPropertiesConfiguration
@Test
public void testSaveToHTTPServerSuccess() throws Exception
{
- MockHttpURLStreamHandler handler = new MockHttpURLStreamHandler(
+ final MockHttpURLStreamHandler handler = new MockHttpURLStreamHandler(
HttpURLConnection.HTTP_OK, testSavePropertiesFile);
- URL url = new URL(null, "http://jakarta.apache.org", handler);
+ final URL url = new URL(null, "http://jakarta.apache.org", handler);
new FileHandler(conf).save(url);
- MockHttpURLConnection con = handler.getMockConnection();
+ final MockHttpURLConnection con = handler.getMockConnection();
assertTrue("Wrong output flag", con.getDoOutput());
assertEquals("Wrong method", "PUT", con.getRequestMethod());
checkSavedConfig();
@@ -760,15 +760,15 @@ public class TestPropertiesConfiguration
@Test
public void testSaveToHTTPServerFail() throws Exception
{
- MockHttpURLStreamHandler handler = new MockHttpURLStreamHandler(
+ final MockHttpURLStreamHandler handler = new MockHttpURLStreamHandler(
HttpURLConnection.HTTP_BAD_REQUEST, testSavePropertiesFile);
- URL url = new URL(null, "http://jakarta.apache.org", handler);
+ final URL url = new URL(null, "http://jakarta.apache.org", handler);
try
{
new FileHandler(conf).save(url);
fail("Response code was not checked!");
}
- catch (ConfigurationException cex)
+ catch (final ConfigurationException cex)
{
assertTrue("Wrong root cause: " + cex,
cex.getCause() instanceof IOException);
@@ -781,10 +781,10 @@ public class TestPropertiesConfiguration
@Test
public void testFileWithSharpSymbol() throws Exception
{
- File file = folder.newFile("sharp#1.properties");
+ final File file = folder.newFile("sharp#1.properties");
- PropertiesConfiguration conf = new PropertiesConfiguration();
- FileHandler handler = new FileHandler(conf);
+ final PropertiesConfiguration conf = new PropertiesConfiguration();
+ final FileHandler handler = new FileHandler(conf);
handler.setFile(file);
handler.load();
handler.save();
@@ -802,7 +802,7 @@ public class TestPropertiesConfiguration
{
final String testProperty = "test.successfull";
conf = new PropertiesConfiguration();
- FileHandler handler = new FileHandler(conf);
+ final FileHandler handler = new FileHandler(conf);
handler.setFile(testSavePropertiesFile);
conf.addProperty(testProperty, "true");
handler.save();
@@ -817,7 +817,7 @@ public class TestPropertiesConfiguration
@Test
public void testCopyAndSave() throws ConfigurationException
{
- Configuration copyConf = setUpCopyConfig();
+ final Configuration copyConf = setUpCopyConfig();
conf.copy(copyConf);
checkCopiedConfig(copyConf);
}
@@ -829,7 +829,7 @@ public class TestPropertiesConfiguration
@Test
public void testAppendAndSave() throws ConfigurationException
{
- Configuration copyConf = setUpCopyConfig();
+ final Configuration copyConf = setUpCopyConfig();
conf.append(copyConf);
checkCopiedConfig(copyConf);
}
@@ -842,14 +842,14 @@ public class TestPropertiesConfiguration
public void testSaveWithDataConfig() throws ConfigurationException
{
conf = new PropertiesConfiguration();
- FileHandler handler = new FileHandler(conf);
+ final FileHandler handler = new FileHandler(conf);
handler.setFile(testSavePropertiesFile);
- DataConfiguration dataConfig = new DataConfiguration(conf);
+ final DataConfiguration dataConfig = new DataConfiguration(conf);
dataConfig.setProperty("foo", "bar");
assertEquals("Property not set", "bar", conf.getString("foo"));
handler.save();
- PropertiesConfiguration config2 = new PropertiesConfiguration();
+ final PropertiesConfiguration config2 = new PropertiesConfiguration();
load(config2, testSavePropertiesFile.getAbsolutePath());
assertEquals("Property not saved", "bar", config2.getString("foo"));
}
@@ -884,14 +884,14 @@ public class TestPropertiesConfiguration
{
@Override
public PropertiesConfiguration.PropertiesReader createPropertiesReader(
- Reader in)
+ final Reader in)
{
return new PropertiesReaderTestImpl(in, propertyCount);
}
@Override
public PropertiesConfiguration.PropertiesWriter createPropertiesWriter(
- Writer out, ListDelimiterHandler handler)
+ final Writer out, final ListDelimiterHandler handler)
{
throw new UnsupportedOperationException("Unexpected call!");
}
@@ -915,22 +915,22 @@ public class TestPropertiesConfiguration
{
@Override
public PropertiesConfiguration.PropertiesReader createPropertiesReader(
- Reader in)
+ final Reader in)
{
throw new UnsupportedOperationException("Unexpected call!");
}
@Override
public PropertiesConfiguration.PropertiesWriter createPropertiesWriter(
- Writer out, ListDelimiterHandler handler)
+ final Writer out, final ListDelimiterHandler handler)
{
try
{
- PropertiesWriterTestImpl propWriter = new PropertiesWriterTestImpl(handler);
+ final PropertiesWriterTestImpl propWriter = new PropertiesWriterTestImpl(handler);
propertiesWriter.setValue(propWriter);
return propWriter;
}
- catch (IOException e)
+ catch (final IOException e)
{
return null;
}
@@ -954,15 +954,15 @@ public class TestPropertiesConfiguration
"test.separator.tab\tfoo", "test.separator.whitespace foo",
"test.separator.no.space=foo"
};
- Set<String> foundLines = new HashSet<>();
- BufferedReader in = new BufferedReader(new FileReader(
+ final Set<String> foundLines = new HashSet<>();
+ final BufferedReader in = new BufferedReader(new FileReader(
testSavePropertiesFile));
try
{
String s;
while ((s = in.readLine()) != null)
{
- for (String separatorTest : separatorTests) {
+ for (final String separatorTest : separatorTests) {
if (separatorTest.equals(s))
{
foundLines.add(s);
@@ -986,9 +986,9 @@ public class TestPropertiesConfiguration
public void testSlashEscaping() throws ConfigurationException
{
conf.setProperty(PROP_NAME, "http://www.apache.org");
- StringWriter writer = new StringWriter();
+ final StringWriter writer = new StringWriter();
new FileHandler(conf).save(writer);
- String s = writer.toString();
+ final String s = writer.toString();
assertTrue("Value not found: " + s, s.contains(PROP_NAME
+ " = http://www.apache.org"));
}
@@ -1012,9 +1012,9 @@ public class TestPropertiesConfiguration
public void testSetPropertyListWithDelimiterParsingDisabled()
throws ConfigurationException
{
- String prop = "delimiterListProp";
+ final String prop = "delimiterListProp";
conf.setListDelimiterHandler(DisabledListDelimiterHandler.INSTANCE);
- List<String> list = Arrays.asList("val", "val2", "val3");
+ final List<String> list = Arrays.asList("val", "val2", "val3");
conf.setProperty(prop, list);
saveTestConfig();
conf.clear();
@@ -1046,7 +1046,7 @@ public class TestPropertiesConfiguration
conf.clear();
conf.setProperty(PROP_NAME, PROP_VALUE);
conf.setFooter(footer);
- StringWriter out = new StringWriter();
+ final StringWriter out = new StringWriter();
conf.write(out);
assertEquals("Wrong result", PROP_NAME + " = " + PROP_VALUE + CR + "# "
+ footer + CR, out.toString());
@@ -1069,7 +1069,7 @@ public class TestPropertiesConfiguration
@Test
public void testGetFooterSynchronized()
{
- SynchronizerTestImpl sync = new SynchronizerTestImpl();
+ final SynchronizerTestImpl sync = new SynchronizerTestImpl();
conf.setSynchronizer(sync);
assertNotNull("No footer comment", conf.getFooter());
sync.verify(Methods.BEGIN_READ, Methods.END_READ);
@@ -1081,7 +1081,7 @@ public class TestPropertiesConfiguration
@Test
public void testSetFooterSynchronized()
{
- SynchronizerTestImpl sync = new SynchronizerTestImpl();
+ final SynchronizerTestImpl sync = new SynchronizerTestImpl();
conf.setSynchronizer(sync);
conf.setFooter("new comment");
sync.verify(Methods.BEGIN_WRITE, Methods.END_WRITE);
@@ -1093,7 +1093,7 @@ public class TestPropertiesConfiguration
@Test
public void testGetHeaderSynchronized()
{
- SynchronizerTestImpl sync = new SynchronizerTestImpl();
+ final SynchronizerTestImpl sync = new SynchronizerTestImpl();
conf.setSynchronizer(sync);
assertNull("Got a header comment", conf.getHeader());
sync.verify(Methods.BEGIN_READ, Methods.END_READ);
@@ -1105,7 +1105,7 @@ public class TestPropertiesConfiguration
@Test
public void testSetHeaderSynchronized()
{
- SynchronizerTestImpl sync = new SynchronizerTestImpl();
+ final SynchronizerTestImpl sync = new SynchronizerTestImpl();
conf.setSynchronizer(sync);
conf.setHeader("new comment");
sync.verify(Methods.BEGIN_WRITE, Methods.END_WRITE);
@@ -1119,14 +1119,14 @@ public class TestPropertiesConfiguration
public void testEscapeQuote() throws ConfigurationException
{
conf.clear();
- String text = "\"Hello World!\"";
+ final String text = "\"Hello World!\"";
conf.setProperty(PROP_NAME, text);
- StringWriter out = new StringWriter();
+ final StringWriter out = new StringWriter();
new FileHandler(conf).save(out);
assertTrue("Value was escaped: " + out,
out.toString().contains(text));
saveTestConfig();
- PropertiesConfiguration c2 = new PropertiesConfiguration();
+ final PropertiesConfiguration c2 = new PropertiesConfiguration();
load(c2, testSavePropertiesFile.getAbsolutePath());
assertEquals("Wrong value", text, c2.getString(PROP_NAME));
}
@@ -1142,10 +1142,10 @@ public class TestPropertiesConfiguration
conf.addProperty("include", "include.properties");
saveTestConfig();
- FileSystem fs = new DefaultFileSystem()
+ final FileSystem fs = new DefaultFileSystem()
{
@Override
- public InputStream getInputStream(URL url)
+ public InputStream getInputStream(final URL url)
throws ConfigurationException
{
if (url.toString().endsWith("include.properties"))
@@ -1155,7 +1155,7 @@ public class TestPropertiesConfiguration
return new ByteArrayInputStream(
"test.outcome = success".getBytes("UTF-8"));
}
- catch (UnsupportedEncodingException e)
+ catch (final UnsupportedEncodingException e)
{
throw new ConfigurationException("Unsupported encoding",
e);
@@ -1164,14 +1164,14 @@ public class TestPropertiesConfiguration
return super.getInputStream(url);
}
};
- Parameters params = new Parameters();
- FileBasedConfigurationBuilder<PropertiesConfiguration> builder =
+ 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));
- PropertiesConfiguration configuration = builder.getConfiguration();
+ final PropertiesConfiguration configuration = builder.getConfiguration();
assertEquals("success", configuration.getString("test.outcome"));
}
@@ -1195,13 +1195,13 @@ public class TestPropertiesConfiguration
public void testReadCalledDirectly() throws IOException
{
conf = new PropertiesConfiguration();
- Reader in = new FileReader(ConfigurationAssert.getTestFile("test.properties"));
+ final Reader in = new FileReader(ConfigurationAssert.getTestFile("test.properties"));
try
{
conf.read(in);
fail("No exception thrown!");
}
- catch (ConfigurationException e)
+ catch (final ConfigurationException e)
{
assertThat(e.getMessage(), containsString("FileHandler"));
}
@@ -1217,11 +1217,11 @@ public class TestPropertiesConfiguration
*
* @param key the key
*/
- private void checkBackslashList(String key)
+ private void checkBackslashList(final String key)
{
- Object prop = conf.getProperty("test." + key);
+ final Object prop = conf.getProperty("test." + key);
assertTrue("Not a list", prop instanceof List);
- List<?> list = (List<?>) prop;
+ final List<?> list = (List<?>) prop;
assertEquals("Wrong number of list elements", 2, list.size());
final String prefix = "\\\\" + key;
assertEquals("Wrong element 1", prefix + "a", list.get(0));
@@ -1236,7 +1236,7 @@ public class TestPropertiesConfiguration
private Configuration setUpCopyConfig()
{
final int count = 25;
- Configuration result = new BaseConfiguration();
+ final Configuration result = new BaseConfiguration();
for (int i = 1; i <= count; i++)
{
result.addProperty("copyKey" + i, "copyValue" + i);
@@ -1251,15 +1251,15 @@ public class TestPropertiesConfiguration
* @param copyConf the copied configuration
* @throws ConfigurationException if an error occurs
*/
- private void checkCopiedConfig(Configuration copyConf)
+ private void checkCopiedConfig(final Configuration copyConf)
throws ConfigurationException
{
saveTestConfig();
- PropertiesConfiguration checkConf = new PropertiesConfiguration();
+ final PropertiesConfiguration checkConf = new PropertiesConfiguration();
load(checkConf, testSavePropertiesFile.getAbsolutePath());
- for (Iterator<String> it = copyConf.getKeys(); it.hasNext();)
+ for (final Iterator<String> it = copyConf.getKeys(); it.hasNext();)
{
- String key = it.next();
+ final String key = it.next();
assertEquals("Wrong value for property " + key, checkConf
.getProperty(key), copyConf.getProperty(key));
}
@@ -1272,7 +1272,7 @@ public class TestPropertiesConfiguration
*/
private void saveTestConfig() throws ConfigurationException
{
- FileHandler handler = new FileHandler(conf);
+ final FileHandler handler = new FileHandler(conf);
handler.save(testSavePropertiesFile);
}
@@ -1286,7 +1286,7 @@ public class TestPropertiesConfiguration
public int loadCalls;
@Override
- public void load(PropertiesConfiguration config, Reader in)
+ public void load(final PropertiesConfiguration config, final Reader in)
throws ConfigurationException
{
loadCalls++;
@@ -1305,7 +1305,7 @@ public class TestPropertiesConfiguration
/** The output file. The output stream will point to this file.*/
private final File outputFile;
- protected MockHttpURLConnection(URL u, int respCode, File outFile)
+ protected MockHttpURLConnection(final URL u, final int respCode, final File outFile)
{
super(u);
returnCode = respCode;
@@ -1355,7 +1355,7 @@ public class TestPropertiesConfiguration
/** Stores the connection.*/
private MockHttpURLConnection connection;
- public MockHttpURLStreamHandler(int respCode, File outFile)
+ public MockHttpURLStreamHandler(final int respCode, final File outFile)
{
responseCode = respCode;
outputFile = outFile;
@@ -1367,7 +1367,7 @@ public class TestPropertiesConfiguration
}
@Override
- protected URLConnection openConnection(URL u) throws IOException
+ protected URLConnection openConnection(final URL u) throws IOException
{
connection = new MockHttpURLConnection(u, responseCode, outputFile);
return connection;
@@ -1388,7 +1388,7 @@ public class TestPropertiesConfiguration
/** The current number of properties. */
private int propertyCount;
- public PropertiesReaderTestImpl(Reader reader, int maxProps)
+ public PropertiesReaderTestImpl(final Reader reader, final int maxProps)
{
super(reader);
maxProperties = maxProps;
@@ -1422,7 +1422,7 @@ public class TestPropertiesConfiguration
private static class PropertiesWriterTestImpl extends
PropertiesConfiguration.PropertiesWriter
{
- public PropertiesWriterTestImpl(ListDelimiterHandler handler) throws IOException
+ public PropertiesWriterTestImpl(final ListDelimiterHandler handler) throws IOException
{
super(new FileWriter(testSavePropertiesFile), handler);
}
Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestPropertiesConfigurationLayout.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestPropertiesConfigurationLayout.java?rev=1842194&r1=1842193&r2=1842194&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestPropertiesConfigurationLayout.java (original)
+++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestPropertiesConfigurationLayout.java Thu Sep 27 22:24:23 2018
@@ -88,7 +88,7 @@ public class TestPropertiesConfiguration
{
assertTrue("Object contains keys", layout.getKeys().isEmpty());
assertNull("Header comment not null", layout.getHeaderComment());
- Iterator<EventListener<? super ConfigurationEvent>> it =
+ final Iterator<EventListener<? super ConfigurationEvent>> it =
config.getEventListeners(ConfigurationEvent.ANY).iterator();
assertTrue("No event listener registered", it.hasNext());
assertSame("Layout not registered as event listener", layout, it.next());
@@ -236,7 +236,7 @@ public class TestPropertiesConfiguration
@Test
public void testHeaderCommentWithBlancsAndPresetHeaderComment() throws ConfigurationException
{
- String presetHeaderComment = "preset" + TEST_COMMENT + CRNORM + CRNORM + TEST_COMMENT;
+ final String presetHeaderComment = "preset" + TEST_COMMENT + CRNORM + CRNORM + TEST_COMMENT;
builder.addComment(TEST_COMMENT);
builder.addComment(null);
builder.addComment(TEST_COMMENT);
@@ -288,7 +288,7 @@ public class TestPropertiesConfiguration
@Test
public void testEventAdd()
{
- ConfigurationEvent event = new ConfigurationEvent(this,
+ final ConfigurationEvent event = new ConfigurationEvent(this,
ConfigurationEvent.ADD_PROPERTY, TEST_KEY, TEST_VALUE,
false);
layout.onEvent(event);
@@ -306,7 +306,7 @@ public class TestPropertiesConfiguration
@Test
public void testEventAddMultiple()
{
- ConfigurationEvent event = new ConfigurationEvent(this,
+ final ConfigurationEvent event = new ConfigurationEvent(this,
ConfigurationEvent.ADD_PROPERTY, TEST_KEY, TEST_VALUE,
false);
layout.onEvent(event);
@@ -324,7 +324,7 @@ public class TestPropertiesConfiguration
builder.addComment(TEST_COMMENT);
builder.addProperty(TEST_KEY, TEST_VALUE);
layout.load(config, builder.getReader());
- ConfigurationEvent event = new ConfigurationEvent(this,
+ final ConfigurationEvent event = new ConfigurationEvent(this,
ConfigurationEvent.ADD_PROPERTY, TEST_KEY, TEST_VALUE,
false);
layout.onEvent(event);
@@ -340,7 +340,7 @@ public class TestPropertiesConfiguration
@Test
public void testEventSetNonExisting()
{
- ConfigurationEvent event = new ConfigurationEvent(this,
+ final ConfigurationEvent event = new ConfigurationEvent(this,
ConfigurationEvent.SET_PROPERTY, TEST_KEY, TEST_VALUE,
false);
layout.onEvent(event);
@@ -373,7 +373,7 @@ public class TestPropertiesConfiguration
public void testEventClearConfig() throws Exception
{
fillLayout();
- ConfigurationEvent event = new ConfigurationEvent(this,
+ final ConfigurationEvent event = new ConfigurationEvent(this,
ConfigurationEvent.CLEAR, null, null, false);
layout.onEvent(event);
assertTrue("Keys not empty", layout.getKeys().isEmpty());
@@ -386,7 +386,7 @@ public class TestPropertiesConfiguration
@Test
public void testEventAddBefore()
{
- ConfigurationEvent event = new ConfigurationEvent(this,
+ final ConfigurationEvent event = new ConfigurationEvent(this,
ConfigurationEvent.ADD_PROPERTY, TEST_KEY, TEST_VALUE,
true);
layout.onEvent(event);
@@ -400,7 +400,7 @@ public class TestPropertiesConfiguration
@Test
public void testRecursiveLoadCall() throws ConfigurationException
{
- PropertiesBuilder b = new PropertiesBuilder();
+ final PropertiesBuilder b = new PropertiesBuilder();
b.addComment("A nested header comment.");
b.addComment("With multiple lines");
b.addComment(null);
@@ -567,7 +567,7 @@ public class TestPropertiesConfiguration
{
fillLayout();
layout.setComment("NonExistingKey", "NonExistingComment");
- String output = getLayoutString();
+ final String output = getLayoutString();
assertTrue("Non existing key was found", !output.contains("NonExistingKey"));
assertTrue("Non existing comment was found", !output.contains("NonExistingComment"));
}
@@ -588,10 +588,10 @@ public class TestPropertiesConfiguration
public void testInitCopy()
{
fillLayout();
- PropertiesConfigurationLayout l2 = new PropertiesConfigurationLayout(layout);
+ final PropertiesConfigurationLayout l2 = new PropertiesConfigurationLayout(layout);
assertEquals("Wrong number of keys", layout.getKeys().size(), l2
.getKeys().size());
- for (String key : layout.getKeys())
+ for (final String key : layout.getKeys())
{
assertTrue("Key was not found: " + key, l2.getKeys().contains(key));
}
@@ -608,7 +608,7 @@ public class TestPropertiesConfiguration
public void testInitCopyModify()
{
fillLayout();
- PropertiesConfigurationLayout l2 = new PropertiesConfigurationLayout(layout);
+ final PropertiesConfigurationLayout l2 = new PropertiesConfigurationLayout(layout);
assertEquals("Comments are not equal", layout.getComment(TEST_KEY), l2
.getComment(TEST_KEY));
layout.setComment(TEST_KEY, "A new comment");
@@ -711,7 +711,7 @@ public class TestPropertiesConfiguration
{
layout.load(config, builder.getReader());
}
- catch (ConfigurationException cex)
+ catch (final ConfigurationException cex)
{
// should not happen
fail("Exception was thrown: " + cex);
@@ -726,7 +726,7 @@ public class TestPropertiesConfiguration
*/
private String getLayoutString() throws ConfigurationException
{
- StringWriter out = new StringWriter();
+ final StringWriter out = new StringWriter();
layout.save(config, out);
return out.toString();
}
@@ -737,7 +737,7 @@ public class TestPropertiesConfiguration
* @param expected the expected result
* @throws ConfigurationException if an error occurs
*/
- private void checkLayoutString(String expected)
+ private void checkLayoutString(final String expected)
throws ConfigurationException
{
assertEquals("Wrong layout file content", expected, getLayoutString());
@@ -759,7 +759,7 @@ public class TestPropertiesConfiguration
*
* @param s the content of the line
*/
- public void addLine(String s)
+ public void addLine(final String s)
{
buf.append(s).append(CR);
}
@@ -770,7 +770,7 @@ public class TestPropertiesConfiguration
* @param key the property key
* @param value the value
*/
- public void addProperty(String key, String value)
+ public void addProperty(final String key, final String value)
{
buf.append(key).append(" = ").append(value).append(CR);
}
@@ -781,7 +781,7 @@ public class TestPropertiesConfiguration
* @param s the comment (can be <b>null</b>, then a blanc line is
* added)
*/
- public void addComment(String s)
+ public void addComment(final String s)
{
if (s != null)
{
@@ -835,7 +835,7 @@ public class TestPropertiesConfiguration
* load() call on the layout is invoked.
*/
@Override
- boolean propertyLoaded(String key, String value)
+ boolean propertyLoaded(final String key, final String value)
throws ConfigurationException
{
if (builder == null)
Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestPropertiesSequence.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestPropertiesSequence.java?rev=1842194&r1=1842193&r2=1842194&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestPropertiesSequence.java (original)
+++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestPropertiesSequence.java Thu Sep 27 22:24:23 2018
@@ -40,23 +40,23 @@ public class TestPropertiesSequence
@Test
public void testConfigurationValuesInSameOrderFromFile() throws Exception
{
- String simpleConfigurationFile = ConfigurationAssert.getTestFile("testSequence.properties").getAbsolutePath();
- String compositeConfigurationFile = ConfigurationAssert.getTestFile("testSequenceDigester.xml").getAbsolutePath();
+ final String simpleConfigurationFile = ConfigurationAssert.getTestFile("testSequence.properties").getAbsolutePath();
+ final String compositeConfigurationFile = ConfigurationAssert.getTestFile("testSequenceDigester.xml").getAbsolutePath();
- PropertiesConfiguration simpleConfiguration = new PropertiesConfiguration();
- FileHandler handler = new FileHandler(simpleConfiguration);
+ final PropertiesConfiguration simpleConfiguration = new PropertiesConfiguration();
+ final FileHandler handler = new FileHandler(simpleConfiguration);
handler.setFileName(simpleConfigurationFile);
handler.load();
- CombinedConfigurationBuilder builder = new CombinedConfigurationBuilder();
+ final CombinedConfigurationBuilder builder = new CombinedConfigurationBuilder();
builder.configure(new FileBasedBuilderParametersImpl().setFileName(compositeConfigurationFile));
- Configuration compositeConfiguration = builder.getConfiguration();
+ final Configuration compositeConfiguration = builder.getConfiguration();
- Configuration a = simpleConfiguration.subset("prefix");
- Configuration b = compositeConfiguration.subset("prefix");
+ final Configuration a = simpleConfiguration.subset("prefix");
+ final Configuration b = compositeConfiguration.subset("prefix");
- List<String> keysSimpleConfiguration = ConfigurationAssert.keysToList(a);
- List<String> keysCompositeConfiguration = ConfigurationAssert.keysToList(b);
+ final List<String> keysSimpleConfiguration = ConfigurationAssert.keysToList(a);
+ final List<String> keysCompositeConfiguration = ConfigurationAssert.keysToList(b);
assertTrue("Size:" + keysSimpleConfiguration.size(), keysSimpleConfiguration.size() > 0);
assertEquals(keysSimpleConfiguration.size(), keysCompositeConfiguration.size());
@@ -70,17 +70,17 @@ public class TestPropertiesSequence
@Test
public void testConfigurationValuesInSameOrderWithManualAdd() throws Exception
{
- String simpleConfigurationFile = ConfigurationAssert.getTestFile("testSequence.properties").getAbsolutePath();
- String compositeConfigurationFile = ConfigurationAssert.getTestFile("testSequenceDigester.xml").getAbsolutePath();
+ final String simpleConfigurationFile = ConfigurationAssert.getTestFile("testSequence.properties").getAbsolutePath();
+ final String compositeConfigurationFile = ConfigurationAssert.getTestFile("testSequenceDigester.xml").getAbsolutePath();
- PropertiesConfiguration simpleConfiguration = new PropertiesConfiguration();
- FileHandler handler = new FileHandler(simpleConfiguration);
+ final PropertiesConfiguration simpleConfiguration = new PropertiesConfiguration();
+ final FileHandler handler = new FileHandler(simpleConfiguration);
handler.setFileName(simpleConfigurationFile);
handler.load();
- CombinedConfigurationBuilder builder = new CombinedConfigurationBuilder();
+ final CombinedConfigurationBuilder builder = new CombinedConfigurationBuilder();
builder.configure(new FileBasedBuilderParametersImpl().setFileName(compositeConfigurationFile));
- Configuration compositeConfiguration = builder.getConfiguration();
+ final Configuration compositeConfiguration = builder.getConfiguration();
simpleConfiguration.setProperty("prefix.Co.test", Boolean.TRUE);
simpleConfiguration.setProperty("prefix.Av.test", Boolean.TRUE);
@@ -88,11 +88,11 @@ public class TestPropertiesSequence
compositeConfiguration.setProperty("prefix.Co.test", Boolean.TRUE);
compositeConfiguration.setProperty("prefix.Av.test", Boolean.TRUE);
- Configuration a = simpleConfiguration.subset("prefix");
- Configuration b = compositeConfiguration.subset("prefix");
+ final Configuration a = simpleConfiguration.subset("prefix");
+ final Configuration b = compositeConfiguration.subset("prefix");
- List<String> keysSimpleConfiguration = ConfigurationAssert.keysToList(a);
- List<String> keysCompositeConfiguration = ConfigurationAssert.keysToList(b);
+ final List<String> keysSimpleConfiguration = ConfigurationAssert.keysToList(a);
+ final List<String> keysCompositeConfiguration = ConfigurationAssert.keysToList(b);
assertTrue("Size:" + keysSimpleConfiguration.size(), keysSimpleConfiguration.size() > 0);
assertEquals(keysSimpleConfiguration.size(), keysCompositeConfiguration.size());
@@ -106,29 +106,29 @@ public class TestPropertiesSequence
@Test
public void testMappingInSameOrder() throws Exception
{
- String simpleConfigurationFile = ConfigurationAssert.getTestFile("testSequence.properties").getAbsolutePath();
- String compositeConfigurationFile = ConfigurationAssert.getTestFile("testSequenceDigester.xml").getAbsolutePath();
+ final String simpleConfigurationFile = ConfigurationAssert.getTestFile("testSequence.properties").getAbsolutePath();
+ final String compositeConfigurationFile = ConfigurationAssert.getTestFile("testSequenceDigester.xml").getAbsolutePath();
- PropertiesConfiguration simpleConfiguration = new PropertiesConfiguration();
- FileHandler handler = new FileHandler(simpleConfiguration);
+ final PropertiesConfiguration simpleConfiguration = new PropertiesConfiguration();
+ final FileHandler handler = new FileHandler(simpleConfiguration);
handler.setFileName(simpleConfigurationFile);
handler.load();
- CombinedConfigurationBuilder builder = new CombinedConfigurationBuilder();
+ final CombinedConfigurationBuilder builder = new CombinedConfigurationBuilder();
builder.configure(new FileBasedBuilderParametersImpl().setFileName(compositeConfigurationFile));
- Configuration compositeConfiguration = builder.getConfiguration();
+ final Configuration compositeConfiguration = builder.getConfiguration();
- Configuration mapping = new BaseConfiguration();
- Configuration mapping2 = new BaseConfiguration();
+ final Configuration mapping = new BaseConfiguration();
+ final Configuration mapping2 = new BaseConfiguration();
- for (Iterator<String> keys = simpleConfiguration.getKeys(); keys.hasNext();)
+ for (final Iterator<String> keys = simpleConfiguration.getKeys(); keys.hasNext();)
{
- String key = keys.next();
- String[] keyParts = StringUtils.split(key, ".");
+ final String key = keys.next();
+ final String[] keyParts = StringUtils.split(key, ".");
if ((keyParts.length == 3) && keyParts[0].equals("prefix") && keyParts[2].equals("postfix"))
{
- String serviceKey = keyParts[1];
+ final String serviceKey = keyParts[1];
if (!mapping.containsKey(serviceKey))
{
@@ -137,14 +137,14 @@ public class TestPropertiesSequence
}
}
- for (Iterator<String> keys = compositeConfiguration.getKeys(); keys.hasNext();)
+ for (final Iterator<String> keys = compositeConfiguration.getKeys(); keys.hasNext();)
{
- String key = keys.next();
- String[] keyParts = StringUtils.split(key, ".");
+ final String key = keys.next();
+ final String[] keyParts = StringUtils.split(key, ".");
if ((keyParts.length == 3) && keyParts[0].equals("prefix") && keyParts[2].equals("postfix"))
{
- String serviceKey = keyParts[1];
+ final String serviceKey = keyParts[1];
if (!mapping2.containsKey(serviceKey))
{
Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestStrictConfigurationComparator.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestStrictConfigurationComparator.java?rev=1842194&r1=1842193&r2=1842194&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestStrictConfigurationComparator.java (original)
+++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestStrictConfigurationComparator.java Thu Sep 27 22:24:23 2018
@@ -60,7 +60,7 @@ public class TestStrictConfigurationComp
comparator.compare(configuration, configuration));
// Create the second configuration
- Configuration other = new BaseConfiguration();
+ final Configuration other = new BaseConfiguration();
assertFalse(
"Compare a configuration with an empty one",
comparator.compare(configuration, other));
Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestSubnodeConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestSubnodeConfiguration.java?rev=1842194&r1=1842193&r2=1842194&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestSubnodeConfiguration.java (original)
+++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestSubnodeConfiguration.java Thu Sep 27 22:24:23 2018
@@ -75,7 +75,7 @@ public class TestSubnodeConfiguration
*/
private static BaseHierarchicalConfiguration setUpParentConfig()
{
- BaseHierarchicalConfiguration conf =
+ final BaseHierarchicalConfiguration conf =
new BaseHierarchicalConfiguration();
appendTree(conf, NodeStructureHelper.ROOT_TABLES_TREE);
return conf;
@@ -87,8 +87,8 @@ public class TestSubnodeConfiguration
* @param configuration the configuration
* @param root the root of the tree structure to be added
*/
- private static void appendTree(BaseHierarchicalConfiguration configuration,
- ImmutableNode root)
+ private static void appendTree(final BaseHierarchicalConfiguration configuration,
+ final ImmutableNode root)
{
configuration.addNodes(null, Collections.singleton(root));
}
@@ -106,7 +106,7 @@ public class TestSubnodeConfiguration
*
* @param key the key
*/
- private void setUpSubnodeConfig(String key)
+ private void setUpSubnodeConfig(final String key)
{
config = (SubnodeConfiguration) parent.configurationAt(key, true);
}
@@ -117,9 +117,9 @@ public class TestSubnodeConfiguration
* @param selector the selector
* @return the tracked model
*/
- private TrackedNodeModel setUpTrackedModel(NodeSelector selector)
+ private TrackedNodeModel setUpTrackedModel(final NodeSelector selector)
{
- InMemoryNodeModel parentModel = (InMemoryNodeModel) parent.getModel();
+ final InMemoryNodeModel parentModel = (InMemoryNodeModel) parent.getModel();
parentModel.trackNode(selector, parent);
return new TrackedNodeModel(parent, selector, true);
}
@@ -178,7 +178,7 @@ public class TestSubnodeConfiguration
{
assertEquals("Wrong table name", NodeStructureHelper.table(0),
config.getString("name"));
- List<Object> fields = config.getList("fields.field.name");
+ final List<Object> fields = config.getList("fields.field.name");
assertEquals("Wrong number of fields",
NodeStructureHelper.fieldsLength(0), fields.size());
for (int i = 0; i < NodeStructureHelper.fieldsLength(0); i++)
@@ -220,7 +220,7 @@ public class TestSubnodeConfiguration
parent.getString("tables.table(0)[@table-type]"));
parent.addProperty("tables.table(0).fields.field(-1).name", "newField");
- List<Object> fields = config.getList("fields.field.name");
+ final List<Object> fields = config.getList("fields.field.name");
assertEquals("New field was not added",
NodeStructureHelper.fieldsLength(0) + 1, fields.size());
assertEquals("Wrong last field", "newField",
@@ -234,7 +234,7 @@ public class TestSubnodeConfiguration
public void testGetKeys()
{
setUpSubnodeConfig();
- Set<String> keys = new HashSet<>();
+ final Set<String> keys = new HashSet<>();
keys.addAll(ConfigurationAssert.keysToList(config));
assertEquals("Incorrect number of keys", 2, keys.size());
assertTrue("Key 1 not contained", keys.contains("name"));
@@ -276,8 +276,8 @@ public class TestSubnodeConfiguration
@Test
public void testSetListDelimiterHandler()
{
- ListDelimiterHandler handler1 = new DefaultListDelimiterHandler('/');
- ListDelimiterHandler handler2 = new DefaultListDelimiterHandler(';');
+ final ListDelimiterHandler handler1 = new DefaultListDelimiterHandler('/');
+ final ListDelimiterHandler handler2 = new DefaultListDelimiterHandler(';');
parent.setListDelimiterHandler(handler1);
setUpSubnodeConfig();
parent.setListDelimiterHandler(handler2);
@@ -301,7 +301,7 @@ public class TestSubnodeConfiguration
setUpSubnodeConfig("tables/table[1]");
assertEquals("Wrong field name", NodeStructureHelper.field(0, 1),
config.getString("fields/field[2]/name"));
- Set<String> keys = ConfigurationAssert.keysToSet(config);
+ final Set<String> keys = ConfigurationAssert.keysToSet(config);
assertEquals("Wrong number of keys", 2, keys.size());
assertTrue("Key 1 not contained", keys.contains("name"));
assertTrue("Key 2 not contained", keys.contains("fields/field/name"));
@@ -317,7 +317,7 @@ public class TestSubnodeConfiguration
public void testConfiguarationAtNoUpdates()
{
setUpSubnodeConfig();
- HierarchicalConfiguration<ImmutableNode> sub2 =
+ final HierarchicalConfiguration<ImmutableNode> sub2 =
config.configurationAt("fields.field(1)");
assertEquals("Wrong value of property",
NodeStructureHelper.field(0, 1), sub2.getString("name"));
@@ -333,7 +333,7 @@ public class TestSubnodeConfiguration
public void testConfigurationAtWithUpdateSupport()
{
setUpSubnodeConfig();
- SubnodeConfiguration sub2 =
+ final SubnodeConfiguration sub2 =
(SubnodeConfiguration) config.configurationAt("fields.field(1)", true);
assertEquals("Wrong value of property",
NodeStructureHelper.field(0, 1), sub2.getString("name"));
@@ -365,14 +365,14 @@ public class TestSubnodeConfiguration
*
* @param withUpdates the supports updates flag
*/
- private void checkInterpolationFromConfigurationAt(boolean withUpdates)
+ private void checkInterpolationFromConfigurationAt(final boolean withUpdates)
{
parent.addProperty("base.dir", "/home/foo");
parent.addProperty("test.absolute.dir.dir1", "${base.dir}/path1");
parent.addProperty("test.absolute.dir.dir2", "${base.dir}/path2");
parent.addProperty("test.absolute.dir.dir3", "${base.dir}/path3");
- Configuration sub =
+ final Configuration sub =
parent.configurationAt("test.absolute.dir", withUpdates);
for (int i = 1; i < 4; i++)
{
@@ -414,7 +414,7 @@ public class TestSubnodeConfiguration
parent.addProperty("test.absolute.dir.dir1", "${base.dir}/path1");
parent.addProperty("test.absolute.dir.dir2", "${dir1}");
- Configuration sub = parent.configurationAt("test.absolute.dir");
+ final Configuration sub = parent.configurationAt("test.absolute.dir");
assertEquals("Wrong interpolation in subnode", "/home/foo/path1",
sub.getString("dir1"));
assertEquals("Wrong local interpolation in subnode", "/home/foo/path1",
@@ -441,11 +441,11 @@ public class TestSubnodeConfiguration
parent.addProperty("tablespaces.tablespace(-1).name", "test");
parent.addProperty("tables.table(0).var", "${brackets:x}");
- ConfigurationInterpolator interpolator = parent.getInterpolator();
+ final ConfigurationInterpolator interpolator = parent.getInterpolator();
interpolator.registerLookup("brackets", new Lookup() {
@Override
- public String lookup(String key) {
+ public String lookup(final String key) {
return "(" + key + ")";
}
@@ -489,11 +489,11 @@ public class TestSubnodeConfiguration
public void testClone()
{
setUpSubnodeConfig();
- SubnodeConfiguration copy = (SubnodeConfiguration) config.clone();
+ final SubnodeConfiguration copy = (SubnodeConfiguration) config.clone();
assertNotSame("Same model", config.getModel(), copy.getModel());
- TrackedNodeModel subModel = (TrackedNodeModel) copy.getModel();
+ final TrackedNodeModel subModel = (TrackedNodeModel) copy.getModel();
assertEquals("Wrong selector", SELECTOR, subModel.getSelector());
- InMemoryNodeModel parentModel = (InMemoryNodeModel) parent.getModel();
+ final InMemoryNodeModel parentModel = (InMemoryNodeModel) parent.getModel();
assertEquals("Wrong parent model", parentModel,
subModel.getParentModel());
@@ -510,12 +510,12 @@ public class TestSubnodeConfiguration
@Test
public void testClose()
{
- TrackedNodeModel model = EasyMock.createMock(TrackedNodeModel.class);
+ final TrackedNodeModel model = EasyMock.createMock(TrackedNodeModel.class);
EasyMock.expect(model.getSelector()).andReturn(SELECTOR).anyTimes();
model.close();
EasyMock.replay(model);
- SubnodeConfiguration config = new SubnodeConfiguration(parent, model);
+ final SubnodeConfiguration config = new SubnodeConfiguration(parent, model);
config.close();
EasyMock.verify(model);
}
@@ -528,7 +528,7 @@ public class TestSubnodeConfiguration
public void testGetNodeModel()
{
setUpSubnodeConfig();
- InMemoryNodeModel nodeModel = config.getNodeModel();
+ final InMemoryNodeModel nodeModel = config.getNodeModel();
assertEquals("Wrong root node", "table",
nodeModel.getNodeHandler().getRootNode().getNodeName());
Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestSubsetConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestSubsetConfiguration.java?rev=1842194&r1=1842193&r2=1842194&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestSubsetConfiguration.java (original)
+++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestSubsetConfiguration.java Thu Sep 27 22:24:23 2018
@@ -62,11 +62,11 @@ public class TestSubsetConfiguration
@Test
public void testGetProperty()
{
- Configuration conf = new BaseConfiguration();
+ final Configuration conf = new BaseConfiguration();
conf.setProperty("test.key1", "value1");
conf.setProperty("testing.key2", "value1");
- Configuration subset = new SubsetConfiguration(conf, "test", ".");
+ final Configuration subset = new SubsetConfiguration(conf, "test", ".");
assertFalse("the subset is empty", subset.isEmpty());
assertTrue("'key1' not found in the subset", subset.containsKey("key1"));
assertFalse("'ng.key2' found in the subset", subset.containsKey("ng.key2"));
@@ -75,8 +75,8 @@ public class TestSubsetConfiguration
@Test
public void testSetProperty()
{
- Configuration conf = new BaseConfiguration();
- Configuration subset = new SubsetConfiguration(conf, "test", ".");
+ final Configuration conf = new BaseConfiguration();
+ final Configuration subset = new SubsetConfiguration(conf, "test", ".");
// set a property in the subset and check the parent
subset.setProperty("key1", "value1");
@@ -92,7 +92,7 @@ public class TestSubsetConfiguration
@Test
public void testGetParentKey()
{
- Configuration conf = new BaseConfiguration();
+ final Configuration conf = new BaseConfiguration();
// subset with delimiter
SubsetConfiguration subset = new SubsetConfiguration(conf, "prefix", ".");
assertEquals("parent key for \"key\"", "prefix.key", subset.getParentKey("key"));
@@ -107,7 +107,7 @@ public class TestSubsetConfiguration
@Test
public void testGetChildKey()
{
- Configuration conf = new BaseConfiguration();
+ final Configuration conf = new BaseConfiguration();
// subset with delimiter
SubsetConfiguration subset = new SubsetConfiguration(conf, "prefix", ".");
assertEquals("parent key for \"prefixkey\"", "key", subset.getChildKey("prefix.key"));
@@ -122,14 +122,14 @@ public class TestSubsetConfiguration
@Test
public void testGetKeys()
{
- Configuration conf = new BaseConfiguration();
+ final Configuration conf = new BaseConfiguration();
conf.setProperty("test", "value0");
conf.setProperty("test.key1", "value1");
conf.setProperty("testing.key2", "value1");
- Configuration subset = new SubsetConfiguration(conf, "test", ".");
+ final Configuration subset = new SubsetConfiguration(conf, "test", ".");
- Iterator<String> it = subset.getKeys();
+ final Iterator<String> it = subset.getKeys();
assertEquals("1st key", "", it.next());
assertEquals("2nd key", "key1", it.next());
assertFalse("too many elements", it.hasNext());
@@ -138,14 +138,14 @@ public class TestSubsetConfiguration
@Test
public void testGetKeysWithPrefix()
{
- Configuration conf = new BaseConfiguration();
+ final Configuration conf = new BaseConfiguration();
conf.setProperty("test.abc", "value0");
conf.setProperty("test.abc.key1", "value1");
conf.setProperty("test.abcdef.key2", "value1");
- Configuration subset = new SubsetConfiguration(conf, "test", ".");
+ final Configuration subset = new SubsetConfiguration(conf, "test", ".");
- Iterator<String> it = subset.getKeys("abc");
+ final Iterator<String> it = subset.getKeys("abc");
assertEquals("1st key", "abc", it.next());
assertEquals("2nd key", "abc.key1", it.next());
assertFalse("too many elements", it.hasNext());
@@ -154,21 +154,21 @@ public class TestSubsetConfiguration
@Test
public void testGetList()
{
- BaseConfiguration conf = new BaseConfiguration();
+ final BaseConfiguration conf = new BaseConfiguration();
conf.setListDelimiterHandler(new DefaultListDelimiterHandler(','));
conf.setProperty("test.abc", "value0,value1");
conf.addProperty("test.abc", "value3");
- Configuration subset = new SubsetConfiguration(conf, "test", ".");
- List<Object> list = subset.getList("abc", new ArrayList<>());
+ final Configuration subset = new SubsetConfiguration(conf, "test", ".");
+ final List<Object> list = subset.getList("abc", new ArrayList<>());
assertEquals(3, list.size());
}
@Test
public void testGetParent()
{
- Configuration conf = new BaseConfiguration();
- SubsetConfiguration subset = new SubsetConfiguration(conf, "prefix", ".");
+ final Configuration conf = new BaseConfiguration();
+ final SubsetConfiguration subset = new SubsetConfiguration(conf, "prefix", ".");
assertEquals("parent", conf, subset.getParent());
}
@@ -176,8 +176,8 @@ public class TestSubsetConfiguration
@Test
public void testGetPrefix()
{
- Configuration conf = new BaseConfiguration();
- SubsetConfiguration subset = new SubsetConfiguration(conf, "prefix", ".");
+ final Configuration conf = new BaseConfiguration();
+ final SubsetConfiguration subset = new SubsetConfiguration(conf, "prefix", ".");
assertEquals("prefix", "prefix", subset.getPrefix());
}
@@ -185,8 +185,8 @@ public class TestSubsetConfiguration
@Test
public void testSetPrefix()
{
- Configuration conf = new BaseConfiguration();
- SubsetConfiguration subset = new SubsetConfiguration(conf, null, ".");
+ final Configuration conf = new BaseConfiguration();
+ final SubsetConfiguration subset = new SubsetConfiguration(conf, null, ".");
subset.setPrefix("prefix");
assertEquals("prefix", "prefix", subset.getPrefix());
@@ -195,17 +195,17 @@ public class TestSubsetConfiguration
@Test
public void testThrowExceptionOnMissing()
{
- BaseConfiguration config = new BaseConfiguration();
+ final BaseConfiguration config = new BaseConfiguration();
config.setThrowExceptionOnMissing(true);
- SubsetConfiguration subset = new SubsetConfiguration(config, "prefix");
+ final SubsetConfiguration subset = new SubsetConfiguration(config, "prefix");
try
{
subset.getString("foo");
fail("NoSuchElementException expected");
}
- catch (NoSuchElementException e)
+ catch (final NoSuchElementException e)
{
// expected
}
@@ -220,7 +220,7 @@ public class TestSubsetConfiguration
config.getString("foo");
fail("NoSuchElementException expected");
}
- catch (NoSuchElementException e)
+ catch (final NoSuchElementException e)
{
// expected
}
@@ -229,21 +229,21 @@ public class TestSubsetConfiguration
@Test
public void testNested() throws Exception
{
- CombinedConfigurationBuilder builder =
+ final CombinedConfigurationBuilder builder =
new CombinedConfigurationBuilder();
builder.configure(new FileBasedBuilderParametersImpl()
.setFile(ConfigurationAssert.getTestFile(TEST_FILE)));
- Configuration config = builder.getConfiguration();
- Configuration subConf = config.subset("tables.table(0)");
+ final Configuration config = builder.getConfiguration();
+ final Configuration subConf = config.subset("tables.table(0)");
assertTrue(subConf.getKeys().hasNext());
- Configuration subSubConf = subConf.subset("fields.field(1)");
- Iterator<String> itKeys = subSubConf.getKeys();
- Set<String> keys = new HashSet<>();
+ final Configuration subSubConf = subConf.subset("fields.field(1)");
+ final Iterator<String> itKeys = subSubConf.getKeys();
+ final Set<String> keys = new HashSet<>();
keys.add("name");
keys.add("type");
while(itKeys.hasNext())
{
- String k = itKeys.next();
+ final String k = itKeys.next();
assertTrue(keys.contains(k));
keys.remove(k);
}
@@ -253,11 +253,11 @@ public class TestSubsetConfiguration
@Test
public void testClear()
{
- Configuration config = new BaseConfiguration();
+ final Configuration config = new BaseConfiguration();
config.setProperty("test.key1", "value1");
config.setProperty("testing.key2", "value1");
- Configuration subset = config.subset("test");
+ final Configuration subset = config.subset("test");
subset.clear();
assertTrue("the subset is not empty", subset.isEmpty());
@@ -270,8 +270,8 @@ public class TestSubsetConfiguration
@Test
public void testListDelimiterHandling()
{
- BaseConfiguration config = new BaseConfiguration();
- Configuration subset = config.subset("prefix");
+ final BaseConfiguration config = new BaseConfiguration();
+ final Configuration subset = config.subset("prefix");
config.setListDelimiterHandler(new DefaultListDelimiterHandler('/'));
subset.addProperty("list", "a/b/c");
assertEquals("Wrong size of list", 3, config.getList("prefix.list")
@@ -291,10 +291,10 @@ public class TestSubsetConfiguration
@Test
public void testSetListDelimiterHandlerInParent()
{
- BaseConfiguration config = new BaseConfiguration();
- AbstractConfiguration subset =
+ final BaseConfiguration config = new BaseConfiguration();
+ final AbstractConfiguration subset =
(AbstractConfiguration) config.subset("prefix");
- ListDelimiterHandler listHandler = new DefaultListDelimiterHandler(',');
+ final ListDelimiterHandler listHandler = new DefaultListDelimiterHandler(',');
subset.setListDelimiterHandler(listHandler);
assertSame("Handler not passed to parent", listHandler,
config.getListDelimiterHandler());
@@ -307,10 +307,10 @@ public class TestSubsetConfiguration
@Test
public void testGetListDelimiterHandlerFromParent()
{
- BaseConfiguration config = new BaseConfiguration();
- AbstractConfiguration subset =
+ final BaseConfiguration config = new BaseConfiguration();
+ final AbstractConfiguration subset =
(AbstractConfiguration) config.subset("prefix");
- ListDelimiterHandler listHandler = new DefaultListDelimiterHandler(',');
+ final ListDelimiterHandler listHandler = new DefaultListDelimiterHandler(',');
config.setListDelimiterHandler(listHandler);
assertSame("Not list handler from parent", listHandler,
subset.getListDelimiterHandler());
@@ -323,10 +323,10 @@ public class TestSubsetConfiguration
@Test
public void testSetListDelimiterHandlerParentNotSupported()
{
- Configuration config = EasyMock.createNiceMock(Configuration.class);
+ final Configuration config = EasyMock.createNiceMock(Configuration.class);
EasyMock.replay(config);
- SubsetConfiguration subset = new SubsetConfiguration(config, "prefix");
- ListDelimiterHandler listHandler = new DefaultListDelimiterHandler(',');
+ final SubsetConfiguration subset = new SubsetConfiguration(config, "prefix");
+ final ListDelimiterHandler listHandler = new DefaultListDelimiterHandler(',');
subset.setListDelimiterHandler(listHandler);
assertSame("List delimiter handler not set", listHandler,
subset.getListDelimiterHandler());
@@ -338,26 +338,26 @@ public class TestSubsetConfiguration
@Test
public void testInterpolator()
{
- BaseConfiguration config = new BaseConfiguration();
- AbstractConfiguration subset = (AbstractConfiguration) config
+ final BaseConfiguration config = new BaseConfiguration();
+ final AbstractConfiguration subset = (AbstractConfiguration) config
.subset("prefix");
InterpolationTestHelper.testGetInterpolator(subset);
}
@Test
public void testLocalLookupsInInterpolatorAreInherited() {
- BaseConfiguration config = new BaseConfiguration();
- ConfigurationInterpolator interpolator = config.getInterpolator();
+ final BaseConfiguration config = new BaseConfiguration();
+ final ConfigurationInterpolator interpolator = config.getInterpolator();
interpolator.registerLookup("brackets", new Lookup(){
@Override
- public String lookup(String key) {
+ public String lookup(final String key) {
return "(" + key +")";
}
});
config.setProperty("prefix.var", "${brackets:x}");
- AbstractConfiguration subset = (AbstractConfiguration) config
+ final AbstractConfiguration subset = (AbstractConfiguration) config
.subset("prefix");
assertEquals("Local lookup was not inherited", "(x)", subset
.getString("var", ""));
@@ -365,10 +365,10 @@ public class TestSubsetConfiguration
@Test
public void testInterpolationForKeysOfTheParent() {
- BaseConfiguration config = new BaseConfiguration();
+ final BaseConfiguration config = new BaseConfiguration();
config.setProperty("test", "junit");
config.setProperty("prefix.key", "${test}");
- AbstractConfiguration subset = (AbstractConfiguration) config
+ final AbstractConfiguration subset = (AbstractConfiguration) config
.subset("prefix");
assertEquals("Interpolation does not resolve parent keys", "junit",
subset.getString("key", ""));
Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestSystemConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestSystemConfiguration.java?rev=1842194&r1=1842193&r2=1842194&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestSystemConfiguration.java (original)
+++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestSystemConfiguration.java Thu Sep 27 22:24:23 2018
@@ -47,17 +47,17 @@ public class TestSystemConfiguration
@Test
public void testSystemConfiguration()
{
- Properties props = System.getProperties();
+ final Properties props = System.getProperties();
props.put("test.number", "123");
- Configuration conf = new SystemConfiguration();
+ final Configuration conf = new SystemConfiguration();
assertEquals("number", 123, conf.getInt("test.number"));
}
@Test
public void testSetSystemProperties()
{
- PropertiesConfiguration props = new PropertiesConfiguration();
+ final PropertiesConfiguration props = new PropertiesConfiguration();
props.addProperty("test.name", "Apache");
SystemConfiguration.setSystemProperties(props);
assertEquals("System Properties", "Apache", System.getProperty("test.name"));
@@ -70,15 +70,15 @@ public class TestSystemConfiguration
public void testSetSystemPropertiesFromPropertiesFile()
throws ConfigurationException, IOException
{
- File file = folder.newFile("sys.properties");
- PropertiesConfiguration pconfig = new PropertiesConfiguration();
- FileHandler handler = new FileHandler(pconfig);
+ final File file = folder.newFile("sys.properties");
+ final PropertiesConfiguration pconfig = new PropertiesConfiguration();
+ final FileHandler handler = new FileHandler(pconfig);
pconfig.addProperty("fromFile", Boolean.TRUE);
handler.setFile(file);
handler.save();
SystemConfiguration.setSystemProperties(handler.getBasePath(),
handler.getFileName());
- SystemConfiguration sconf = new SystemConfiguration();
+ final SystemConfiguration sconf = new SystemConfiguration();
assertTrue("Property from file not found", sconf.getBoolean("fromFile"));
}
@@ -88,8 +88,8 @@ public class TestSystemConfiguration
@Test
public void testChangeSystemProperties()
{
- String testProperty = "someTest";
- SystemConfiguration config = new SystemConfiguration();
+ final String testProperty = "someTest";
+ final SystemConfiguration config = new SystemConfiguration();
config.setProperty(testProperty, "true");
assertEquals("System property not changed", "true",
System.getProperty(testProperty));
@@ -106,7 +106,7 @@ public class TestSystemConfiguration
final AtomicBoolean stop = new AtomicBoolean();
final String property =
SystemConfiguration.class.getName() + ".testProperty";
- Thread t = new Thread()
+ final Thread t = new Thread()
{
@Override
public void run()
@@ -130,15 +130,15 @@ public class TestSystemConfiguration
{
t.start();
- SystemConfiguration config = new SystemConfiguration();
- PropertiesConfiguration props = new PropertiesConfiguration();
+ final SystemConfiguration config = new SystemConfiguration();
+ final PropertiesConfiguration props = new PropertiesConfiguration();
props.append(config);
stop.set(true);
t.join();
- for (Iterator<String> keys = config.getKeys(); keys.hasNext();)
+ for (final Iterator<String> keys = config.getKeys(); keys.hasNext();)
{
- String key = keys.next();
+ final String key = keys.next();
if (!property.equals(key))
{
assertEquals("Wrong value for " + key,
Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestThreesomeConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestThreesomeConfiguration.java?rev=1842194&r1=1842193&r2=1842194&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestThreesomeConfiguration.java (original)
+++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration2/TestThreesomeConfiguration.java Thu Sep 27 22:24:23 2018
@@ -40,9 +40,9 @@ public class TestThreesomeConfiguration
@Before
public void setUp() throws Exception
{
- PropertiesConfiguration c = new PropertiesConfiguration();
+ final PropertiesConfiguration c = new PropertiesConfiguration();
c.setListDelimiterHandler(new LegacyListDelimiterHandler(','));
- FileHandler handler = new FileHandler(c);
+ final FileHandler handler = new FileHandler(c);
handler.setFileName("threesome.properties");
handler.load();
conf = c;
@@ -51,7 +51,7 @@ public class TestThreesomeConfiguration
@Test
public void testList1() throws Exception
{
- List<Object> packages = conf.getList("test.threesome.one");
+ final List<Object> packages = conf.getList("test.threesome.one");
// we should get 3 packages here
assertEquals(3, packages.size());
}
@@ -59,7 +59,7 @@ public class TestThreesomeConfiguration
@Test
public void testList2() throws Exception
{
- List<Object> packages = conf.getList("test.threesome.two");
+ final List<Object> packages = conf.getList("test.threesome.two");
// we should get 3 packages here
assertEquals(3, packages.size());
}
@@ -67,7 +67,7 @@ public class TestThreesomeConfiguration
@Test
public void testList3() throws Exception
{
- List<Object> packages = conf.getList("test.threesome.three");
+ final List<Object> packages = conf.getList("test.threesome.three");
// we should get 3 packages here
assertEquals(3, packages.size());
}