You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by oh...@apache.org on 2014/07/22 22:02:50 UTC

svn commit: r1612672 - /commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/interpol/TestConstantLookup.java

Author: oheger
Date: Tue Jul 22 20:02:50 2014
New Revision: 1612672

URL: http://svn.apache.org/r1612672
Log:
Changed test fields in TestConstantLookup.

The test class now defines its own constants which are read by test cases
rather than relying on fields from other classes.

Modified:
    commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/interpol/TestConstantLookup.java

Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/interpol/TestConstantLookup.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/interpol/TestConstantLookup.java?rev=1612672&r1=1612671&r2=1612672&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/interpol/TestConstantLookup.java (original)
+++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/interpol/TestConstantLookup.java Tue Jul 22 20:02:50 2014
@@ -21,7 +21,6 @@ import static org.junit.Assert.assertNul
 
 import java.awt.event.KeyEvent;
 
-import org.apache.commons.configuration.AbstractConfiguration;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -33,15 +32,12 @@ import org.junit.Test;
  */
 public class TestConstantLookup
 {
-    /** Constant for the name of the test class. */
-    private static final String CLS_NAME = AbstractConfiguration.class
-            .getName() + '.';
+    /** A public field that can be read by the lookup. */
+    public static final String FIELD = "Field that can be read";
 
-    /** Constant for the name of the test field. */
-    private static final String FIELD = "EVENT_READ_PROPERTY";
-
-    /** Constant for the test variable name. */
-    private static final String VARNAME = CLS_NAME + FIELD;
+    /** A private field that cannot be read by the lookup. */
+    @SuppressWarnings("unused")
+    private static final String PRIVATE_FIELD = "PRIVATE";
 
     /** The lookup object to be tested. */
     private ConstantLookup lookup;
@@ -53,6 +49,18 @@ public class TestConstantLookup
     }
 
     /**
+     * Generates the name of a variable for a lookup operation based on the
+     * given field name of this class.
+     *
+     * @param field the field name
+     * @return the variable for looking up this field
+     */
+    private String variable(String field)
+    {
+        return getClass().getName() + '.' + field;
+    }
+
+    /**
      * Clears the test environment. Here the static cache of the constant lookup
      * class is wiped out.
      */
@@ -68,9 +76,8 @@ public class TestConstantLookup
     @Test
     public void testLookupConstant()
     {
-        assertEquals("Wrong value of constant",
-                AbstractConfiguration.EVENT_READ_PROPERTY, lookup
-                        .lookup(VARNAME));
+        assertEquals("Wrong value of constant", FIELD,
+                lookup.lookup(variable("FIELD")));
     }
 
     /**
@@ -79,8 +86,8 @@ public class TestConstantLookup
     @Test
     public void testLookupNonExisting()
     {
-        assertNull("Non null return value for non existing constant", lookup
-                .lookup(CLS_NAME + "NO_FIELD"));
+        assertNull("Non null return value for non existing constant",
+                lookup.lookup(variable("NO_FIELD")));
     }
 
     /**
@@ -90,8 +97,8 @@ public class TestConstantLookup
     @Test
     public void testLookupPrivate()
     {
-        assertNull("Non null return value for non accessable field", lookup
-                .lookup(CLS_NAME + "DISABLED_DELIMITER"));
+        assertNull("Non null return value for non accessible field", lookup
+                .lookup(variable("PRIVATE_FIELD")));
     }
 
     /**