commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ebo...@apache.org
Subject svn commit: r1152749 - in /commons/proper/configuration/branches/configuration2_experimental/src: main/java/org/apache/commons/configuration2/ main/java/org/apache/commons/configuration2/expr/def/ test/java/org/apache/commons/configuration2/ test/java/...
Date Mon, 01 Aug 2011 12:08:36 GMT
Author: ebourg
Date: Mon Aug  1 12:08:34 2011
New Revision: 1152749

URL: http://svn.apache.org/viewvc?rev=1152749&view=rev
Log:
Replaced String.indexOf() with contains()

Modified:
    commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/PropertiesConfiguration.java
    commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/expr/def/DefaultConfigurationKey.java
    commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestCompositeConfiguration.java
    commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestDefaultConfigurationBuilder.java
    commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestJNDIConfiguration.java
    commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestPropertiesConfiguration.java
    commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestPropertiesConfigurationLayout.java
    commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestXMLConfiguration.java
    commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/base/impl/TestXMLConfigurationSource.java

Modified: commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/PropertiesConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/PropertiesConfiguration.java?rev=1152749&r1=1152748&r2=1152749&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/PropertiesConfiguration.java
(original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/PropertiesConfiguration.java
Mon Aug  1 12:08:34 2011
@@ -1133,7 +1133,7 @@ public class PropertiesConfiguration ext
         {
             String strValue = String.valueOf(value);
 
-            if (inList && strValue.indexOf(DOUBLE_ESC) >= 0)
+            if (inList && strValue.contains(DOUBLE_ESC))
             {
                 char esc = ESCAPE.charAt(0);
                 StringBuffer buf = new StringBuffer(strValue.length() + 8);

Modified: commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/expr/def/DefaultConfigurationKey.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/expr/def/DefaultConfigurationKey.java?rev=1152749&r1=1152748&r2=1152749&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/expr/def/DefaultConfigurationKey.java
(original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/expr/def/DefaultConfigurationKey.java
Mon Aug  1 12:08:34 2011
@@ -446,11 +446,9 @@ public class DefaultConfigurationKey
      */
     private String escapeDelimiters(String key)
     {
-        return (getExpressionEngine().getEscapedDelimiter() == null || key
-                .indexOf(getExpressionEngine().getPropertyDelimiter()) < 0) ? key
-                : StringUtils.replace(key, getExpressionEngine()
-                        .getPropertyDelimiter(), getExpressionEngine()
-                        .getEscapedDelimiter());
+        String delimiter = getExpressionEngine().getPropertyDelimiter();
+        return (getExpressionEngine().getEscapedDelimiter() == null || !key.contains(delimiter))
? key
+                : StringUtils.replace(key, delimiter, getExpressionEngine().getEscapedDelimiter());
     }
 
     /**

Modified: commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestCompositeConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestCompositeConfiguration.java?rev=1152749&r1=1152748&r2=1152749&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestCompositeConfiguration.java
(original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestCompositeConfiguration.java
Mon Aug  1 12:08:34 2011
@@ -128,7 +128,7 @@ public class TestCompositeConfiguration 
         }
         catch (NoSuchElementException nsee)
         {
-            assertTrue(nsee.getMessage().indexOf("bogus.property") > -1);
+            assertTrue(nsee.getMessage().contains("bogus.property"));
         }
 
         assertTrue("Should be false", !cc.getBoolean("test.missing.boolean", false));

Modified: commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestDefaultConfigurationBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestDefaultConfigurationBuilder.java?rev=1152749&r1=1152748&r2=1152749&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestDefaultConfigurationBuilder.java
(original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestDefaultConfigurationBuilder.java
Mon Aug  1 12:08:34 2011
@@ -1042,7 +1042,7 @@ public class TestDefaultConfigurationBui
         verify("1001", config, 15);
         String xml = writer.getBuffer().toString();
         assertNotNull("No XML returned", xml);
-        assertTrue("Incorect configuration data: " + xml, xml.indexOf("<rowsPerPage>15</rowsPerPage>")
>= 0);
+        assertTrue("Incorect configuration data: " + xml, xml.contains("<rowsPerPage>15</rowsPerPage>"));
         logger.removeAppender(app);
         logger.setLevel(org.apache.log4j.Level.OFF);
         verify("1002", config, 25);

Modified: commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestJNDIConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestJNDIConfiguration.java?rev=1152749&r1=1152748&r2=1152749&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestJNDIConfiguration.java
(original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestJNDIConfiguration.java
Mon Aug  1 12:08:34 2011
@@ -166,7 +166,7 @@ public class TestJNDIConfiguration exten
         }
         catch (NoSuchElementException e)
         {
-            assertTrue(e.getMessage(), e.getMessage().indexOf("test.imaginarykey") != -1);
+            assertTrue(e.getMessage(), e.getMessage().contains("test.imaginarykey"));
         }
     }
 

Modified: commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestPropertiesConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestPropertiesConfiguration.java?rev=1152749&r1=1152748&r2=1152749&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestPropertiesConfiguration.java
(original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestPropertiesConfiguration.java
Mon Aug  1 12:08:34 2011
@@ -986,8 +986,7 @@ public class TestPropertiesConfiguration
         StringWriter writer = new StringWriter();
         conf.save(writer);
         String s = writer.toString();
-        assertTrue("Value not found: " + s, s.indexOf(PROP_NAME
-                + " = http://www.apache.org") >= 0);
+        assertTrue("Value not found: " + s, s.contains(PROP_NAME + " = http://www.apache.org"));
     }
 
     /**

Modified: commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestPropertiesConfigurationLayout.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestPropertiesConfigurationLayout.java?rev=1152749&r1=1152748&r2=1152749&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestPropertiesConfigurationLayout.java
(original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestPropertiesConfigurationLayout.java
Mon Aug  1 12:08:34 2011
@@ -568,10 +568,8 @@ public class TestPropertiesConfiguration
         fillLayout();
         layout.setComment("NonExistingKey", "NonExistingComment");
         String output = getLayoutString();
-        assertTrue("Non existing key was found", output
-                .indexOf("NonExistingKey") < 0);
-        assertTrue("Non existing comment was found", output
-                .indexOf("NonExistingComment") < 0);
+        assertTrue("Non existing key was found", !output.contains("NonExistingKey"));
+        assertTrue("Non existing comment was found", !output.contains("NonExistingComment"));
     }
 
     /**

Modified: commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestXMLConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestXMLConfiguration.java?rev=1152749&r1=1152748&r2=1152749&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestXMLConfiguration.java
(original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestXMLConfiguration.java
Mon Aug  1 12:08:34 2011
@@ -973,8 +973,7 @@ public class TestXMLConfiguration extend
 
         StringWriter out = new StringWriter();
         conf.save(out);
-        assertTrue("Encoding was not written to file", out.toString().indexOf(
-                "encoding=\"" + ENCODING + "\"") >= 0);
+        assertTrue("Encoding was not written to file", out.toString().contains("encoding=\""
+ ENCODING + "\""));
     }
 
     /**
@@ -990,8 +989,7 @@ public class TestXMLConfiguration extend
 
         StringWriter out = new StringWriter();
         conf.save(out);
-        assertTrue("Encoding was written to file", out.toString().indexOf(
-                "encoding=\"UTF-") >= 0);
+        assertTrue("Encoding was written to file", out.toString().contains("encoding=\"UTF-"));
     }
 
     /**
@@ -1016,7 +1014,7 @@ public class TestXMLConfiguration extend
         StringWriter out = new StringWriter();
         conf.save(out);
         System.out.println(out.toString());
-        assertTrue("Did not find DOCTYPE", out.toString().indexOf(DOCTYPE) >= 0);
+        assertTrue("Did not find DOCTYPE", out.toString().contains(DOCTYPE));
     }
 
     /**
@@ -1031,8 +1029,7 @@ public class TestXMLConfiguration extend
         conf.setSystemID(SYSTEM_ID);
         StringWriter out = new StringWriter();
         conf.save(out);
-        assertTrue("Did not find DOCTYPE", out.toString().indexOf(
-                DOCTYPE + "testconfig" + DOCTYPE_DECL) >= 0);
+        assertTrue("Did not find DOCTYPE", out.toString().contains(DOCTYPE + "testconfig"
+ DOCTYPE_DECL));
     }
 
     /**

Modified: commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/base/impl/TestXMLConfigurationSource.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/base/impl/TestXMLConfigurationSource.java?rev=1152749&r1=1152748&r2=1152749&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/base/impl/TestXMLConfigurationSource.java
(original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/base/impl/TestXMLConfigurationSource.java
Mon Aug  1 12:08:34 2011
@@ -751,8 +751,7 @@ public class TestXMLConfigurationSource
         locSupport.setEncoding(ENCODING);
         StringWriter out = new StringWriter();
         source.save(out);
-        assertTrue("Encoding was not written to file", out.toString().indexOf(
-                "encoding=\"" + ENCODING + "\"") >= 0);
+        assertTrue("Encoding was not written to file", out.toString().contains("encoding=\""
+ ENCODING + "\""));
     }
 
     /**
@@ -768,8 +767,7 @@ public class TestXMLConfigurationSource
         locSupport.setEncoding(null);
         StringWriter out = new StringWriter();
         source.save(out);
-        assertTrue("Encoding was written to file", out.toString().indexOf(
-                "encoding=\"UTF-") >= 0);
+        assertTrue("Encoding was written to file", out.toString().contains("encoding=\"UTF-"));
     }
 
     /**
@@ -826,7 +824,7 @@ public class TestXMLConfigurationSource
         assertEquals("Wrong system ID", SYSTEM_ID, source.getSystemID());
         StringWriter out = new StringWriter();
         source.save(out);
-        assertTrue("Did not find DOCTYPE", out.toString().indexOf(DOCTYPE) >= 0);
+        assertTrue("Did not find DOCTYPE", out.toString().contains(DOCTYPE));
     }
 
     /**
@@ -843,8 +841,7 @@ public class TestXMLConfigurationSource
         source.setSystemID(SYSTEM_ID);
         StringWriter out = new StringWriter();
         source.save(out);
-        assertTrue("Did not find DOCTYPE", out.toString().indexOf(
-                DOCTYPE + "testconfig" + DOCTYPE_DECL) >= 0);
+        assertTrue("Did not find DOCTYPE", out.toString().contains(DOCTYPE + "testconfig"
+ DOCTYPE_DECL));
     }
 
     /**



Mime
View raw message