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 2019/08/05 15:26:29 UTC
[commons-configuration] 01/03: Sort members.
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
commit af66286c84e0761ffbecea15a90c773adbd93ff7
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Aug 5 11:22:17 2019 -0400
Sort members.
---
.../interpol/TestInterpolatorSpecification.java | 198 ++++++++++-----------
1 file changed, 99 insertions(+), 99 deletions(-)
diff --git a/src/test/java/org/apache/commons/configuration2/interpol/TestInterpolatorSpecification.java b/src/test/java/org/apache/commons/configuration2/interpol/TestInterpolatorSpecification.java
index c082679..3abfb30 100644
--- a/src/test/java/org/apache/commons/configuration2/interpol/TestInterpolatorSpecification.java
+++ b/src/test/java/org/apache/commons/configuration2/interpol/TestInterpolatorSpecification.java
@@ -41,37 +41,21 @@ public class TestInterpolatorSpecification
/** Constant for another prefix for a prefix lookup. */
private static final String PREFIX2 = "p2";
- /** The builder for creating new instances. */
- private InterpolatorSpecification.Builder builder;
-
- @Before
- public void setUp() throws Exception
- {
- builder = new InterpolatorSpecification.Builder();
- }
-
/**
- * Convenience method for creating a mock object.
- *
- * @param cls the class of the mock
- * @param <T> the type of the mock
- * @return the mock
- */
- private static <T> T createMock(final Class<T> cls)
- {
- final T mock = EasyMock.createMock(cls);
- EasyMock.replay(mock);
- return mock;
- }
-
- /**
- * Convenience method for creating a mock lookup.
+ * Checks whether the given test object contains the expected default
+ * lookups.
*
- * @return the mock lookup
+ * @param spec the object to be tested
+ * @param defLook1 default lookup 1
+ * @param defLook2 default lookup 2
*/
- private static Lookup createLookup()
+ private static void checkDefaultLookups(final InterpolatorSpecification spec,
+ final Lookup defLook1, final Lookup defLook2)
{
- return createMock(Lookup.class);
+ assertEquals("Wrong number of default lookups", 2, spec
+ .getDefaultLookups().size());
+ assertTrue("Wrong default lookups", spec.getDefaultLookups()
+ .containsAll(Arrays.asList(defLook1, defLook2)));
}
/**
@@ -94,20 +78,65 @@ public class TestInterpolatorSpecification
}
/**
- * Checks whether the given test object contains the expected default
- * lookups.
+ * Convenience method for creating a mock lookup.
*
- * @param spec the object to be tested
- * @param defLook1 default lookup 1
- * @param defLook2 default lookup 2
+ * @return the mock lookup
*/
- private static void checkDefaultLookups(final InterpolatorSpecification spec,
- final Lookup defLook1, final Lookup defLook2)
+ private static Lookup createLookup()
{
- assertEquals("Wrong number of default lookups", 2, spec
- .getDefaultLookups().size());
- assertTrue("Wrong default lookups", spec.getDefaultLookups()
- .containsAll(Arrays.asList(defLook1, defLook2)));
+ return createMock(Lookup.class);
+ }
+
+ /**
+ * Convenience method for creating a mock object.
+ *
+ * @param cls the class of the mock
+ * @param <T> the type of the mock
+ * @return the mock
+ */
+ private static <T> T createMock(final Class<T> cls)
+ {
+ final T mock = EasyMock.createMock(cls);
+ EasyMock.replay(mock);
+ return mock;
+ }
+
+ /** The builder for creating new instances. */
+ private InterpolatorSpecification.Builder builder;
+
+ @Before
+ public void setUp() throws Exception
+ {
+ builder = new InterpolatorSpecification.Builder();
+ }
+
+ /**
+ * Tests whether a builder can be reused.
+ */
+ @Test
+ public void testBuilderReuse()
+ {
+ builder.withDefaultLookup(createLookup())
+ .withInterpolator(createMock(ConfigurationInterpolator.class))
+ .withPrefixLookup("test", createLookup())
+ .withParentInterpolator(
+ createMock(ConfigurationInterpolator.class)).create();
+ final Lookup prefLook1 = createLookup();
+ final Lookup prefLook2 = createLookup();
+ final Lookup defLook1 = createLookup();
+ final Lookup defLook2 = createLookup();
+ final ConfigurationInterpolator parent =
+ createMock(ConfigurationInterpolator.class);
+ final InterpolatorSpecification spec =
+ builder.withPrefixLookup(PREFIX1, prefLook1)
+ .withPrefixLookup(PREFIX2, prefLook2)
+ .withDefaultLookups(Arrays.asList(defLook1, defLook2))
+ .withParentInterpolator(parent).create();
+ assertNull("Got an interpolator", spec.getInterpolator());
+ assertSame("Wrong parent interpolator", parent,
+ spec.getParentInterpolator());
+ checkPrefixLookups(spec, prefLook1, prefLook2);
+ checkDefaultLookups(spec, defLook1, defLook2);
}
/**
@@ -160,104 +189,75 @@ public class TestInterpolatorSpecification
}
/**
- * Tests whether a null map with prefix lookups is accepted.
+ * Tests that the collection with default lookups cannot be modified.
*/
- @Test
- public void testWithPrefixLookupsNull()
+ @Test(expected = UnsupportedOperationException.class)
+ public void testGetDefaultLookupsModify()
{
final InterpolatorSpecification spec =
- builder.withPrefixLookups(null).create();
- assertTrue("No empty map with prefix lookups", spec.getPrefixLookups()
- .isEmpty());
+ builder.withDefaultLookup(createLookup()).create();
+ spec.getDefaultLookups().add(createLookup());
}
/**
- * Tests whether a null collection with default lookups is accepted.
+ * Tests that the map with prefix lookups cannot be modified.
*/
- @Test
- public void testWithDefaultLookupsNull()
+ @Test(expected = UnsupportedOperationException.class)
+ public void testGetPrefixLookupsModify()
{
final InterpolatorSpecification spec =
- builder.withDefaultLookups(null).create();
- assertTrue("No empty default lookups collection", spec
- .getDefaultLookups().isEmpty());
+ builder.withPrefixLookup(PREFIX1, createLookup()).create();
+ spec.getPrefixLookups().put(PREFIX1, createLookup());
}
/**
- * Tests whether a null prefix causes an exception.
+ * Tests whether a null default lookup causes an exception.
*/
@Test(expected = IllegalArgumentException.class)
- public void testWithPrefixLookupNoPrefix()
+ public void testWithDefaultLookupNull()
{
- builder.withPrefixLookup(null, createLookup());
+ builder.withDefaultLookup(null);
}
/**
- * Tests whether a null prefix lookup causes an exception.
+ * Tests whether a null collection with default lookups is accepted.
*/
- @Test(expected = IllegalArgumentException.class)
- public void testWithPrefixLookupNoLookup()
+ @Test
+ public void testWithDefaultLookupsNull()
{
- builder.withPrefixLookup(PREFIX1, null);
+ final InterpolatorSpecification spec =
+ builder.withDefaultLookups(null).create();
+ assertTrue("No empty default lookups collection", spec
+ .getDefaultLookups().isEmpty());
}
/**
- * Tests whether a null default lookup causes an exception.
+ * Tests whether a null prefix lookup causes an exception.
*/
@Test(expected = IllegalArgumentException.class)
- public void testWithDefaultLookupNull()
- {
- builder.withDefaultLookup(null);
- }
-
- /**
- * Tests that the map with prefix lookups cannot be modified.
- */
- @Test(expected = UnsupportedOperationException.class)
- public void testGetPrefixLookupsModify()
+ public void testWithPrefixLookupNoLookup()
{
- final InterpolatorSpecification spec =
- builder.withPrefixLookup(PREFIX1, createLookup()).create();
- spec.getPrefixLookups().put(PREFIX1, createLookup());
+ builder.withPrefixLookup(PREFIX1, null);
}
/**
- * Tests that the collection with default lookups cannot be modified.
+ * Tests whether a null prefix causes an exception.
*/
- @Test(expected = UnsupportedOperationException.class)
- public void testGetDefaultLookupsModify()
+ @Test(expected = IllegalArgumentException.class)
+ public void testWithPrefixLookupNoPrefix()
{
- final InterpolatorSpecification spec =
- builder.withDefaultLookup(createLookup()).create();
- spec.getDefaultLookups().add(createLookup());
+ builder.withPrefixLookup(null, createLookup());
}
/**
- * Tests whether a builder can be reused.
+ * Tests whether a null map with prefix lookups is accepted.
*/
@Test
- public void testBuilderReuse()
+ public void testWithPrefixLookupsNull()
{
- builder.withDefaultLookup(createLookup())
- .withInterpolator(createMock(ConfigurationInterpolator.class))
- .withPrefixLookup("test", createLookup())
- .withParentInterpolator(
- createMock(ConfigurationInterpolator.class)).create();
- final Lookup prefLook1 = createLookup();
- final Lookup prefLook2 = createLookup();
- final Lookup defLook1 = createLookup();
- final Lookup defLook2 = createLookup();
- final ConfigurationInterpolator parent =
- createMock(ConfigurationInterpolator.class);
final InterpolatorSpecification spec =
- builder.withPrefixLookup(PREFIX1, prefLook1)
- .withPrefixLookup(PREFIX2, prefLook2)
- .withDefaultLookups(Arrays.asList(defLook1, defLook2))
- .withParentInterpolator(parent).create();
- assertNull("Got an interpolator", spec.getInterpolator());
- assertSame("Wrong parent interpolator", parent,
- spec.getParentInterpolator());
- checkPrefixLookups(spec, prefLook1, prefLook2);
- checkDefaultLookups(spec, defLook1, defLook2);
+ builder.withPrefixLookups(null).create();
+ assertTrue("No empty map with prefix lookups", spec.getPrefixLookups()
+ .isEmpty());
}
}