diff --git a/src/main/org/apache/tools/ant/filters/LineContains.java b/src/main/org/apache/tools/ant/filters/LineContains.java index d74d4dd91..a5492518a 100644 --- a/src/main/org/apache/tools/ant/filters/LineContains.java +++ b/src/main/org/apache/tools/ant/filters/LineContains.java @@ -118,7 +118,7 @@ public final class LineContains boolean matches = true; for (int i = 0; matches && i < containsSize; i++) { String containsStr = (String) contains.elementAt(i); - matches = line.indexOf(containsStr) >= 0; + matches = line.contains(containsStr); } if (matches ^ isNegated()) { break; diff --git a/src/main/org/apache/tools/ant/filters/TokenFilter.java b/src/main/org/apache/tools/ant/filters/TokenFilter.java index ebad76027..7da00cd60 100644 --- a/src/main/org/apache/tools/ant/filters/TokenFilter.java +++ b/src/main/org/apache/tools/ant/filters/TokenFilter.java @@ -428,7 +428,7 @@ public class TokenFilter extends BaseFilterReader if (contains == null) { throw new BuildException("Missing contains in containsstring"); } - if (string.indexOf(contains) > -1) { + if (string.contains(contains)) { return string; } return null; diff --git a/src/main/org/apache/tools/ant/taskdefs/Copy.java b/src/main/org/apache/tools/ant/taskdefs/Copy.java index de7badb1d..62c62c1ff 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Copy.java +++ b/src/main/org/apache/tools/ant/taskdefs/Copy.java @@ -1088,7 +1088,7 @@ public class Copy extends Task { } message.append(ex.getMessage()); } - if (ex.getClass().getName().indexOf("MalformedInput") != -1) { + if (ex.getClass().getName().contains("MalformedInput")) { message.append(LINE_SEPARATOR); message.append( "This is normally due to the input file containing invalid"); diff --git a/src/main/org/apache/tools/ant/taskdefs/Exec.java b/src/main/org/apache/tools/ant/taskdefs/Exec.java index a1c100f52..75a9f70b4 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Exec.java +++ b/src/main/org/apache/tools/ant/taskdefs/Exec.java @@ -89,7 +89,7 @@ public class Exec extends Task { // test if os match String myos = System.getProperty("os.name"); log("Myos = " + myos, Project.MSG_VERBOSE); - if ((os != null) && (os.indexOf(myos) < 0)) { + if (os != null && !os.contains(myos)) { // this command will be executed only on the specified OS log("Not found in " + os, Project.MSG_VERBOSE); return 0; @@ -100,9 +100,9 @@ public class Exec extends Task { dir = getProject().getBaseDir(); } - if (myos.toLowerCase(Locale.ENGLISH).indexOf("windows") >= 0) { + if (myos.toLowerCase(Locale.ENGLISH).contains("windows")) { if (!dir.equals(getProject().resolveFile("."))) { - if (myos.toLowerCase(Locale.ENGLISH).indexOf("nt") >= 0) { + if (myos.toLowerCase(Locale.ENGLISH).contains("nt")) { command = "cmd /c cd " + dir + " && " + command; } else { String ant = getProject().getProperty(MagicNames.ANT_HOME); diff --git a/src/main/org/apache/tools/ant/taskdefs/ExecTask.java b/src/main/org/apache/tools/ant/taskdefs/ExecTask.java index 4159c39f6..9d58fb70c 100644 --- a/src/main/org/apache/tools/ant/taskdefs/ExecTask.java +++ b/src/main/org/apache/tools/ant/taskdefs/ExecTask.java @@ -563,7 +563,7 @@ public class ExecTask extends Task { //for the current os.name String myos = System.getProperty("os.name"); log("Current OS is " + myos, Project.MSG_VERBOSE); - if ((os != null) && (os.indexOf(myos) < 0)) { + if (os != null && !os.contains(myos)) { // this command will be executed only on the specified OS log("This OS, " + myos + " was not found in the specified list of valid OSes: " + os, diff --git a/src/main/org/apache/tools/ant/taskdefs/JDBCTask.java b/src/main/org/apache/tools/ant/taskdefs/JDBCTask.java index 5f3da78f3..6377d28ea 100644 --- a/src/main/org/apache/tools/ant/taskdefs/JDBCTask.java +++ b/src/main/org/apache/tools/ant/taskdefs/JDBCTask.java @@ -269,7 +269,7 @@ public abstract class JDBCTask extends Task { String theVendor = dmd.getDatabaseProductName().toLowerCase(); log("RDBMS = " + theVendor, Project.MSG_VERBOSE); - if (theVendor == null || theVendor.indexOf(rdbms) < 0) { + if (theVendor == null || !theVendor.contains(rdbms)) { log("Not the required RDBMS: " + rdbms, Project.MSG_VERBOSE); return false; } @@ -281,7 +281,7 @@ public abstract class JDBCTask extends Task { log("Version = " + theVersion, Project.MSG_VERBOSE); if (theVersion == null || !(theVersion.startsWith(version) - || theVersion.indexOf(" " + version) >= 0)) { + || theVersion.contains(" " + version))) { log("Not the required version: \"" + version + "\"", Project.MSG_VERBOSE); return false; } diff --git a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java index 8b2150c7c..9b5e3c7ff 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java +++ b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java @@ -2459,7 +2459,7 @@ public class Javadoc extends Task { // check if file may be vulnerable because it was not // patched with "validURL(url)": - if (fileContents.indexOf("function validURL(url) {") < 0) { + if (!fileContents.contains("function validURL(url) {")) { // we need to patch the file! final String patchedFileContents = patchContent(fileContents, fixData); if (!patchedFileContents.equals(fileContents)) { diff --git a/src/main/org/apache/tools/ant/taskdefs/Jikes.java b/src/main/org/apache/tools/ant/taskdefs/Jikes.java index 89ac3f1f7..3896001a4 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Jikes.java +++ b/src/main/org/apache/tools/ant/taskdefs/Jikes.java @@ -83,7 +83,7 @@ public class Jikes { // Windows has a 32k limit on total arg size, so // create a temporary file to store all the arguments - if (myos.toLowerCase(Locale.ENGLISH).indexOf("windows") >= 0 + if (myos.toLowerCase(Locale.ENGLISH).contains("windows") && args.length > MAX_FILES_ON_COMMAND_LINE) { BufferedWriter out = null; try { diff --git a/src/main/org/apache/tools/ant/taskdefs/JikesOutputParser.java b/src/main/org/apache/tools/ant/taskdefs/JikesOutputParser.java index b0fc19ddb..5ffb954d3 100644 --- a/src/main/org/apache/tools/ant/taskdefs/JikesOutputParser.java +++ b/src/main/org/apache/tools/ant/taskdefs/JikesOutputParser.java @@ -136,9 +136,9 @@ public class JikesOutputParser implements ExecuteStreamHandler { if (line.trim().equals("")) { continue; } - if (lower.indexOf("error") != -1) { + if (lower.contains("error")) { setError(true); - } else if (lower.indexOf("warning") != -1) { + } else if (lower.contains("warning")) { setError(false); } else { // If we don't know the type of the line diff --git a/src/main/org/apache/tools/ant/taskdefs/Rmic.java b/src/main/org/apache/tools/ant/taskdefs/Rmic.java index a645e8609..119e4b987 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Rmic.java +++ b/src/main/org/apache/tools/ant/taskdefs/Rmic.java @@ -754,7 +754,7 @@ public class Rmic extends MatchingTask { if (idl) { log("will leave uptodate test to rmic implementation in idl mode.", Project.MSG_VERBOSE); - } else if (iiop && iiopOpts != null && iiopOpts.indexOf("-always") > -1) { + } else if (iiop && iiopOpts != null && iiopOpts.contains("-always")) { log("no uptodate test as -always option has been specified", Project.MSG_VERBOSE); } else { diff --git a/src/main/org/apache/tools/ant/taskdefs/SQLExec.java b/src/main/org/apache/tools/ant/taskdefs/SQLExec.java index 83383c298..9d4b5d63d 100644 --- a/src/main/org/apache/tools/ant/taskdefs/SQLExec.java +++ b/src/main/org/apache/tools/ant/taskdefs/SQLExec.java @@ -761,7 +761,7 @@ public class SQLExec extends JDBCTask { // SQL defines "--" as a comment to EOL // and in Oracle it may contain a hint // so we cannot just remove it, instead we must end it - if (!keepformat && line.indexOf("--") >= 0) { + if (!keepformat && line.contains("--")) { sql.append("\n"); } int lastDelimPos = lastDelimiterPosition(sql, line); @@ -906,7 +906,7 @@ public class SQLExec extends JDBCTask { } private String maybeQuote(String s) { - if (csvQuoteChar == null || s == null || (!forceCsvQuoteChar && s.indexOf(csvColumnSep) == -1 && s.indexOf(csvQuoteChar) == -1)) { + if (csvQuoteChar == null || s == null || (!forceCsvQuoteChar && !s.contains(csvColumnSep) && !s.contains(csvQuoteChar))) { return s; } StringBuilder sb = new StringBuilder(csvQuoteChar); diff --git a/src/main/org/apache/tools/ant/taskdefs/VerifyJar.java b/src/main/org/apache/tools/ant/taskdefs/VerifyJar.java index b7e98b6ef..ef90fb62d 100644 --- a/src/main/org/apache/tools/ant/taskdefs/VerifyJar.java +++ b/src/main/org/apache/tools/ant/taskdefs/VerifyJar.java @@ -180,7 +180,7 @@ public class VerifyJar extends AbstractJarSignerTask { String results = outputCache.toString(); //deal with jdk1.4.2 bug: if (ex != null) { - if (results.indexOf("zip file closed") >= 0) { + if (results.contains("zip file closed")) { log("You are running " + JARSIGNER_COMMAND + " against a JVM with a known bug that manifests as an IllegalStateException.", Project.MSG_WARN); @@ -188,7 +188,7 @@ public class VerifyJar extends AbstractJarSignerTask { throw ex; } } - if (results.indexOf(VERIFIED_TEXT) < 0) { + if (!results.contains(VERIFIED_TEXT)) { throw new BuildException(ERROR_NO_VERIFY + jar); } } diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/Contains.java b/src/main/org/apache/tools/ant/taskdefs/condition/Contains.java index 79cf698ed..91726b27c 100644 --- a/src/main/org/apache/tools/ant/taskdefs/condition/Contains.java +++ b/src/main/org/apache/tools/ant/taskdefs/condition/Contains.java @@ -71,7 +71,7 @@ public class Contains implements Condition { } return caseSensitive - ? string.indexOf(subString) > -1 - : string.toLowerCase().indexOf(subString.toLowerCase()) > -1; + ? string.contains(subString) + : string.toLowerCase().contains(subString.toLowerCase()); } } diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/Os.java b/src/main/org/apache/tools/ant/taskdefs/condition/Os.java index 1d9e2d106..da638584a 100644 --- a/src/main/org/apache/tools/ant/taskdefs/condition/Os.java +++ b/src/main/org/apache/tools/ant/taskdefs/condition/Os.java @@ -259,17 +259,17 @@ public class Os implements Condition { //windows probing logic relies on the word 'windows' in //the OS - boolean isWindows = OS_NAME.indexOf(FAMILY_WINDOWS) > -1; + boolean isWindows = OS_NAME.contains(FAMILY_WINDOWS); boolean is9x = false; boolean isNT = false; if (isWindows) { //there are only four 9x platforms that we look for - is9x = (OS_NAME.indexOf("95") >= 0 - || OS_NAME.indexOf("98") >= 0 - || OS_NAME.indexOf("me") >= 0 + is9x = (OS_NAME.contains("95") + || OS_NAME.contains("98") + || OS_NAME.contains("me") //wince isn't really 9x, but crippled enough to //be a muchness. Ant doesn't run on CE, anyway. - || OS_NAME.indexOf("ce") >= 0); + || OS_NAME.contains("ce")); isNT = !is9x; } if (family.equals(FAMILY_WINDOWS)) { @@ -279,28 +279,28 @@ public class Os implements Condition { } else if (family.equals(FAMILY_NT)) { isFamily = isWindows && isNT; } else if (family.equals(FAMILY_OS2)) { - isFamily = OS_NAME.indexOf(FAMILY_OS2) > -1; + isFamily = OS_NAME.contains(FAMILY_OS2); } else if (family.equals(FAMILY_NETWARE)) { - isFamily = OS_NAME.indexOf(FAMILY_NETWARE) > -1; + isFamily = OS_NAME.contains(FAMILY_NETWARE); } else if (family.equals(FAMILY_DOS)) { isFamily = PATH_SEP.equals(";") && !isFamily(FAMILY_NETWARE); } else if (family.equals(FAMILY_MAC)) { - isFamily = OS_NAME.indexOf(FAMILY_MAC) > -1 - || OS_NAME.indexOf(DARWIN) > -1; + isFamily = OS_NAME.contains(FAMILY_MAC) + || OS_NAME.contains(DARWIN); } else if (family.equals(FAMILY_TANDEM)) { - isFamily = OS_NAME.indexOf("nonstop_kernel") > -1; + isFamily = OS_NAME.contains("nonstop_kernel"); } else if (family.equals(FAMILY_UNIX)) { isFamily = PATH_SEP.equals(":") && !isFamily(FAMILY_VMS) && (!isFamily(FAMILY_MAC) || OS_NAME.endsWith("x") - || OS_NAME.indexOf(DARWIN) > -1); + || OS_NAME.contains(DARWIN)); } else if (family.equals(FAMILY_ZOS)) { - isFamily = OS_NAME.indexOf(FAMILY_ZOS) > -1 - || OS_NAME.indexOf("os/390") > -1; + isFamily = OS_NAME.contains(FAMILY_ZOS) + || OS_NAME.contains("os/390"); } else if (family.equals(FAMILY_OS400)) { - isFamily = OS_NAME.indexOf(FAMILY_OS400) > -1; + isFamily = OS_NAME.contains(FAMILY_OS400); } else if (family.equals(FAMILY_VMS)) { - isFamily = OS_NAME.indexOf(FAMILY_VMS) > -1; + isFamily = OS_NAME.contains(FAMILY_VMS); } else { throw new BuildException( "Don\'t know how to detect os family \"" diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/ResourceContains.java b/src/main/org/apache/tools/ant/taskdefs/condition/ResourceContains.java index ae7e1f544..033701b47 100644 --- a/src/main/org/apache/tools/ant/taskdefs/condition/ResourceContains.java +++ b/src/main/org/apache/tools/ant/taskdefs/condition/ResourceContains.java @@ -155,7 +155,7 @@ public class ResourceContains implements Condition { contents = contents.toLowerCase(); sub = sub.toLowerCase(); } - return contents.indexOf(sub) >= 0; + return contents.contains(sub); } catch (IOException e) { throw new BuildException("There was a problem accessing resource : " + resource); } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java b/src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java index fb7071caa..ed6614521 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java @@ -308,7 +308,7 @@ public class ANTLR extends Task { throw new BuildException("ANTLR returned: " + err, getLocation()); } String output = bos.toString(); - if (output.indexOf("error:") > -1) { + if (output.contains("error:")) { throw new BuildException("ANTLR signaled an error: " + output, getLocation()); } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java b/src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java index f2c6a0477..e0c4d83b1 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java @@ -819,24 +819,24 @@ public class NetRexxC extends MatchingTask { } // verbose level logging for suppressed messages if (suppressMethodArgumentNotUsed - && l.indexOf(MSG_METHOD_ARGUMENT_NOT_USED) != -1) { + && l.contains(MSG_METHOD_ARGUMENT_NOT_USED)) { log(l, Project.MSG_VERBOSE); } else if (suppressPrivatePropertyNotUsed - && l.indexOf(MSG_PRIVATE_PROPERTY_NOT_USED) != -1) { + && l.contains(MSG_PRIVATE_PROPERTY_NOT_USED)) { log(l, Project.MSG_VERBOSE); } else if (suppressVariableNotUsed - && l.indexOf(MSG_VARIABLE_NOT_USED) != -1) { + && l.contains(MSG_VARIABLE_NOT_USED)) { log(l, Project.MSG_VERBOSE); } else if (suppressExceptionNotSignalled - && l.indexOf(MSG_EXCEPTION_NOT_SIGNALLED) != -1) { + && l.contains(MSG_EXCEPTION_NOT_SIGNALLED)) { log(l, Project.MSG_VERBOSE); } else if (suppressDeprecation - && l.indexOf(MSG_DEPRECATION) != -1) { + && l.contains(MSG_DEPRECATION)) { log(l, Project.MSG_VERBOSE); - } else if (l.indexOf("Error:") != -1) { + } else if (l.contains("Error:")) { // error level logging for compiler errors log(l, Project.MSG_ERR); - } else if (l.indexOf("Warning:") != -1) { + } else if (l.contains("Warning:")) { // warning for all warning messages log(l, Project.MSG_WARN); } else { diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/JonasDeploymentTool.java b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/JonasDeploymentTool.java index 4f983796c..33e125176 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/JonasDeploymentTool.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/JonasDeploymentTool.java @@ -471,7 +471,7 @@ public class JonasDeploymentTool extends GenericDeploymentTool { if (getConfig().namingScheme.getValue().equals(EjbJar.NamingScheme.DESCRIPTOR)) { // try to find JOnAS specific convention name - if (descriptorFileName.indexOf(getConfig().baseNameTerminator) == -1) { + if (!descriptorFileName.contains(getConfig().baseNameTerminator)) { // baseNameTerminator not found: the descriptor use the // JOnAS naming convention, ie [Foo.xml,jonas-Foo.xml] and diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/javah/Gcjh.java b/src/main/org/apache/tools/ant/taskdefs/optional/javah/Gcjh.java index 712bb76ab..c04eea348 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/javah/Gcjh.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/javah/Gcjh.java @@ -42,7 +42,7 @@ public class Gcjh implements JavahAdapter { Execute.runCommand(javah, cmd.getCommandline()); return true; } catch (BuildException e) { - if (e.getMessage().indexOf("failed with return code") == -1) { + if (!e.getMessage().contains("failed with return code")) { throw e; } } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/javah/Kaffeh.java b/src/main/org/apache/tools/ant/taskdefs/optional/javah/Kaffeh.java index d37f77175..6bcba8caa 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/javah/Kaffeh.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/javah/Kaffeh.java @@ -47,7 +47,7 @@ public class Kaffeh implements JavahAdapter { Execute.runCommand(javah, cmd.getCommandline()); return true; } catch (BuildException e) { - if (e.getMessage().indexOf("failed with return code") == -1) { + if (!e.getMessage().contains("failed with return code")) { throw e; } } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/jlink/jlink.java b/src/main/org/apache/tools/ant/taskdefs/optional/jlink/jlink.java index ee9d7d265..2a3e519e7 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/jlink/jlink.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/jlink/jlink.java @@ -228,7 +228,7 @@ public class jlink { //entry from another mergefile was called "com". //In that case, just ignore the error and go on to the //next entry. - if (ex.getMessage().indexOf("duplicate") >= 0) { + if (ex.getMessage().contains("duplicate")) { //It was the duplicate entry. continue; } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java index 118008d69..d7683b376 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java @@ -1171,7 +1171,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR private static boolean filterLine(final String line) { for (String filter : DEFAULT_TRACE_FILTERS) { - if (line.indexOf(filter) != -1) { + if (line.contains(filter)) { return true; } } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java index 8154a1ddc..bd8702142 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java @@ -2124,7 +2124,7 @@ public class FTP extends Task implements FTPTaskConfig { log("Failed to issue Site Command: " + theCMD, Project.MSG_WARN); } else { for (String reply : ftp.getReplyStrings()) { - if (reply != null && reply.indexOf("200") == -1) { + if (reply != null && !reply.contains("200")) { log(reply, Project.MSG_WARN); } } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java index b60bf9514..2b6e5733e 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java @@ -1505,7 +1505,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror { Project.MSG_WARN); } else { for (String reply : ftp.getReplyStrings()) { - if (reply.indexOf("200") == -1) { + if (!reply.contains("200")) { task.log(reply, Project.MSG_WARN); } } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java index c3e4821b4..c3caae43a 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java @@ -452,7 +452,7 @@ public class SSHExec extends SSHBase { } catch (final BuildException e) { throw e; } catch (final JSchException e) { - if (e.getMessage().indexOf("session is down") >= 0) { + if (e.getMessage().contains("session is down")) { if (getFailonerror()) { throw new BuildException(TIMEOUT_MESSAGE, e); } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHSession.java b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHSession.java index 98dceacdb..4d038ab4e 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHSession.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHSession.java @@ -165,7 +165,7 @@ public class SSHSession extends SSHBase { // completed successfully } catch (final JSchException e) { - if (e.getMessage().indexOf("session is down") >= 0) { + if (e.getMessage().contains("session is down")) { if (getFailonerror()) { throw new BuildException(TIMEOUT_MESSAGE, e); } diff --git a/src/main/org/apache/tools/ant/types/Commandline.java b/src/main/org/apache/tools/ant/types/Commandline.java index f75be2f41..98173e0ce 100644 --- a/src/main/org/apache/tools/ant/types/Commandline.java +++ b/src/main/org/apache/tools/ant/types/Commandline.java @@ -428,15 +428,14 @@ public class Commandline implements Cloneable { * and double quotes. */ public static String quoteArgument(String argument) { - if (argument.indexOf("\"") > -1) { - if (argument.indexOf("\'") > -1) { + if (argument.contains("\"")) { + if (argument.contains("\'")) { throw new BuildException("Can\'t handle single and double" + " quotes in same argument"); } return '\'' + argument + '\''; } - if (argument.indexOf("\'") > -1 - || argument.indexOf(" ") > -1 + if (argument.contains("\'") || argument.contains(" ") // WIN9x uses a bat file for executing commands || (IS_WIN_9X && argument.indexOf(';') != -1)) { return '\"' + argument + '\"'; diff --git a/src/main/org/apache/tools/ant/types/FilterSet.java b/src/main/org/apache/tools/ant/types/FilterSet.java index 133a27b76..21e8a44ba 100644 --- a/src/main/org/apache/tools/ant/types/FilterSet.java +++ b/src/main/org/apache/tools/ant/types/FilterSet.java @@ -597,7 +597,7 @@ public class FilterSet extends DataType implements Cloneable { } passedTokens.addElement(parent); String value = iReplaceTokens(line); - if (value.indexOf(beginToken) == -1 && !duplicateToken + if (!value.contains(beginToken) && !duplicateToken && recurseDepth == 1) { passedTokens = null; } else if (duplicateToken) { diff --git a/src/main/org/apache/tools/ant/types/Path.java b/src/main/org/apache/tools/ant/types/Path.java index b52ca29f6..72ed1a630 100644 --- a/src/main/org/apache/tools/ant/types/Path.java +++ b/src/main/org/apache/tools/ant/types/Path.java @@ -608,7 +608,7 @@ public class Path extends DataType implements Cloneable, ResourceCollection { addExisting(systemBootClasspath); } - if (System.getProperty("java.vendor").toLowerCase(Locale.ENGLISH).indexOf("microsoft") >= 0) { + if (System.getProperty("java.vendor").toLowerCase(Locale.ENGLISH).contains("microsoft")) { // TODO is this code still necessary? is there any 1.2+ port? // Pull in *.zip from packages directory FileSet msZipFiles = new FileSet(); diff --git a/src/main/org/apache/tools/ant/types/selectors/ContainsSelector.java b/src/main/org/apache/tools/ant/types/selectors/ContainsSelector.java index ebfd1eab3..ee04a0d06 100644 --- a/src/main/org/apache/tools/ant/types/selectors/ContainsSelector.java +++ b/src/main/org/apache/tools/ant/types/selectors/ContainsSelector.java @@ -186,7 +186,7 @@ public class ContainsSelector extends BaseExtendSelector implements ResourceSele if (ignorewhitespace) { teststr = SelectorUtils.removeWhitespace(teststr); } - if (teststr.indexOf(userstr) > -1) { + if (teststr.contains(userstr)) { return true; } teststr = in.readLine(); diff --git a/src/main/org/apache/tools/ant/util/RegexpPatternMapper.java b/src/main/org/apache/tools/ant/util/RegexpPatternMapper.java index 495a644b9..98330a21f 100644 --- a/src/main/org/apache/tools/ant/util/RegexpPatternMapper.java +++ b/src/main/org/apache/tools/ant/util/RegexpPatternMapper.java @@ -119,7 +119,7 @@ public class RegexpPatternMapper implements FileNameMapper { return null; } if (handleDirSep) { - if (sourceFileName.indexOf("\\") != -1) { + if (sourceFileName.contains("\\")) { sourceFileName = sourceFileName.replace('\\', '/'); } } diff --git a/src/main/org/apache/tools/tar/TarEntry.java b/src/main/org/apache/tools/tar/TarEntry.java index c44e47f7a..afdd9511e 100644 --- a/src/main/org/apache/tools/tar/TarEntry.java +++ b/src/main/org/apache/tools/tar/TarEntry.java @@ -1042,7 +1042,7 @@ public class TarEntry implements TarConstants { fileName = fileName.substring(2); } } - } else if (osname.indexOf("netware") > -1) { + } else if (osname.contains("netware")) { int colon = fileName.indexOf(':'); if (colon != -1) { fileName = fileName.substring(colon + 1); diff --git a/src/tests/junit/org/apache/tools/ant/BuildFileTest.java b/src/tests/junit/org/apache/tools/ant/BuildFileTest.java index e821bae6d..60bf68b84 100644 --- a/src/tests/junit/org/apache/tools/ant/BuildFileTest.java +++ b/src/tests/junit/org/apache/tools/ant/BuildFileTest.java @@ -122,7 +122,7 @@ public abstract class BuildFileTest extends TestCase { String realLog = getLog(); assertTrue("expecting log to contain \"" + substring + "\" log was \"" + realLog + "\"", - realLog.indexOf(substring) >= 0); + realLog.contains(substring)); } /** @@ -134,7 +134,7 @@ public abstract class BuildFileTest extends TestCase { String realLog = getLog(); assertFalse("didn't expect log to contain \"" + substring + "\" log was \"" + realLog + "\"", - realLog.indexOf(substring) >= 0); + realLog.contains(substring)); } /** @@ -160,7 +160,7 @@ public abstract class BuildFileTest extends TestCase { String realMessage = (message != null) ? message : "expecting output to contain \"" + substring + "\" output was \"" + realOutput + "\""; - assertTrue(realMessage, realOutput.indexOf(substring) >= 0); + assertTrue(realMessage, realOutput.contains(substring)); } /** @@ -176,7 +176,7 @@ public abstract class BuildFileTest extends TestCase { String realMessage = (message != null) ? message : "expecting output to not contain \"" + substring + "\" output was \"" + realOutput + "\""; - assertFalse(realMessage, realOutput.indexOf(substring) >= 0); + assertFalse(realMessage, realOutput.contains(substring)); } /** @@ -237,7 +237,7 @@ public abstract class BuildFileTest extends TestCase { assertTrue("expecting debug log to contain \"" + substring + "\" log was \"" + realLog + "\"", - realLog.indexOf(substring) >= 0); + realLog.contains(substring)); } /** @@ -425,7 +425,7 @@ public abstract class BuildFileTest extends TestCase { executeTarget(target); } catch (org.apache.tools.ant.BuildException ex) { buildException = ex; - if ((null != contains) && (ex.getMessage().indexOf(contains) == -1)) { + if ((null != contains) && (!ex.getMessage().contains(contains))) { fail("Should throw BuildException because '" + cause + "' with message containing '" + contains + "' (actual message '" + ex.getMessage() + "' instead)"); } return; diff --git a/src/tests/junit/org/apache/tools/ant/LocationTest.java b/src/tests/junit/org/apache/tools/ant/LocationTest.java index c8048a31a..ca7f9b1d9 100644 --- a/src/tests/junit/org/apache/tools/ant/LocationTest.java +++ b/src/tests/junit/org/apache/tools/ant/LocationTest.java @@ -70,18 +70,16 @@ public class LocationTest { public void testMacrodefWrappedTask() { buildRule.executeTarget("testMacrodefWrappedTask"); Echo e = (Echo) buildRule.getProject().getReference("echo3"); - assertTrue(buildRule.getLog().indexOf("Line: " - + (e.getLocation().getLineNumber() + 1)) - > -1); + assertTrue(buildRule.getLog().contains("Line: " + + (e.getLocation().getLineNumber() + 1))); } @Test public void testPresetdefWrappedTask() { buildRule.executeTarget("testPresetdefWrappedTask"); Echo e = (Echo) buildRule.getProject().getReference("echo4"); - assertTrue(buildRule.getLog().indexOf("Line: " - + (e.getLocation().getLineNumber() + 1)) - > -1); + assertTrue(buildRule.getLog().contains("Line: " + + (e.getLocation().getLineNumber() + 1))); } public static class EchoLocation extends Task { diff --git a/src/tests/junit/org/apache/tools/ant/TaskContainerTest.java b/src/tests/junit/org/apache/tools/ant/TaskContainerTest.java index 1fc745fae..491d3618f 100644 --- a/src/tests/junit/org/apache/tools/ant/TaskContainerTest.java +++ b/src/tests/junit/org/apache/tools/ant/TaskContainerTest.java @@ -38,29 +38,29 @@ public class TaskContainerTest { public void testPropertyExpansion() { buildRule.executeTarget("testPropertyExpansion"); assertTrue("attribute worked", - buildRule.getLog().indexOf("As attribute: it worked") > -1); + buildRule.getLog().contains("As attribute: it worked")); assertTrue("nested text worked", - buildRule.getLog().indexOf("As nested text: it worked") > -1); + buildRule.getLog().contains("As nested text: it worked")); } @Test public void testTaskdef() { buildRule.executeTarget("testTaskdef"); assertTrue("attribute worked", - buildRule.getLog().indexOf("As attribute: it worked") > -1); + buildRule.getLog().contains("As attribute: it worked")); assertTrue("nested text worked", - buildRule.getLog().indexOf("As nested text: it worked") > -1); + buildRule.getLog().contains("As nested text: it worked")); assertTrue("nested text worked", - buildRule.getLog().indexOf("As nested task: it worked") > -1); + buildRule.getLog().contains("As nested task: it worked")); } @Test public void testCaseInsensitive() { buildRule.executeTarget("testCaseInsensitive"); assertTrue("works outside of container", - buildRule.getLog().indexOf("hello ") > -1); + buildRule.getLog().contains("hello ")); assertTrue("works inside of container", - buildRule.getLog().indexOf("world") > -1); + buildRule.getLog().contains("world")); } } diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/AntTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/AntTest.java index 3581b1835..684cb62cc 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/AntTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/AntTest.java @@ -318,9 +318,9 @@ public class AntTest { @Test public void testPropertySet() { buildRule.executeTarget("test-propertyset"); - assertTrue(buildRule.getLog().indexOf("test1 is ${test1}") > -1); - assertTrue(buildRule.getLog().indexOf("test2 is ${test2}") > -1); - assertTrue(buildRule.getLog().indexOf("test1.x is 1") > -1); + assertTrue(buildRule.getLog().contains("test1 is ${test1}")); + assertTrue(buildRule.getLog().contains("test2 is ${test2}")); + assertTrue(buildRule.getLog().contains("test1.x is 1")); } @Test diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/ConcatTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/ConcatTest.java index b42165033..daec44bf7 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/ConcatTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/ConcatTest.java @@ -199,7 +199,7 @@ public class ConcatTest { @Test public void testFilter() { buildRule.executeTarget("testfilter"); - assertTrue(buildRule.getLog().indexOf("REPLACED") > -1); + assertTrue(buildRule.getLog().contains("REPLACED")); } @Test @@ -251,7 +251,7 @@ public class ConcatTest { @Test public void testfilterinline() { buildRule.executeTarget("testfilterinline"); - assertTrue(buildRule.getLog().indexOf("REPLACED") > -1); + assertTrue(buildRule.getLog().contains("REPLACED")); } /** @@ -260,8 +260,8 @@ public class ConcatTest { @Test public void testmultireader() { buildRule.executeTarget("testmultireader"); - assertTrue(buildRule.getLog().indexOf("Bye") > -1); - assertTrue(buildRule.getLog().indexOf("Hello") == -1); + assertTrue(buildRule.getLog().contains("Bye")); + assertTrue(!buildRule.getLog().contains("Hello")); } /** * Check if fixlastline works @@ -302,7 +302,7 @@ public class ConcatTest { assertTrue( "expecting file " + filename + " to contain " + contains + - " but got " + content, content.indexOf(contains) > -1); + " but got " + content, content.contains(contains)); } } diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/CopyTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/CopyTest.java index 24c5e1592..c027ae232 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/CopyTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/CopyTest.java @@ -110,7 +110,7 @@ public class CopyTest { @Test public void testFilterTest() { buildRule.executeTarget("filtertest"); - assertTrue(buildRule.getLog().indexOf("loop in tokens") == -1); + assertTrue(!buildRule.getLog().contains("loop in tokens")); } @Test diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/JarTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/JarTest.java index 3b916b6d1..402979c27 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/JarTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/JarTest.java @@ -344,33 +344,33 @@ public class JarTest { @Test public void testNoVersionInfoIgnore() { buildRule.executeTarget("testNoVersionInfoIgnore"); - assertTrue(buildRule.getFullLog().indexOf("No Implementation-Title set.") > -1); - assertTrue(buildRule.getFullLog().indexOf("No Implementation-Version set.") > -1); - assertTrue(buildRule.getFullLog().indexOf("No Implementation-Vendor set.") > -1); + assertTrue(buildRule.getFullLog().contains("No Implementation-Title set.")); + assertTrue(buildRule.getFullLog().contains("No Implementation-Version set.")); + assertTrue(buildRule.getFullLog().contains("No Implementation-Vendor set.")); } @Test public void testNoVersionInfoWarn() { buildRule.executeTarget("testNoVersionInfoWarn"); - assertTrue(buildRule.getLog().indexOf("No Implementation-Title set.") > -1); - assertTrue(buildRule.getLog().indexOf("No Implementation-Version set.") > -1); - assertTrue(buildRule.getLog().indexOf("No Implementation-Vendor set.") > -1); + assertTrue(buildRule.getLog().contains("No Implementation-Title set.")); + assertTrue(buildRule.getLog().contains("No Implementation-Version set.")); + assertTrue(buildRule.getLog().contains("No Implementation-Vendor set.")); } @Test public void testNoVersionInfoNoStrict() { buildRule.executeTarget("testNoVersionInfoNoStrict"); - assertFalse(buildRule.getLog().indexOf("No Implementation-Title set.") > -1); - assertFalse(buildRule.getLog().indexOf("No Implementation-Version set.") > -1); - assertFalse(buildRule.getLog().indexOf("No Implementation-Vendor set.") > -1); + assertFalse(buildRule.getLog().contains("No Implementation-Title set.")); + assertFalse(buildRule.getLog().contains("No Implementation-Version set.")); + assertFalse(buildRule.getLog().contains("No Implementation-Vendor set.")); } @Test public void testHasVersionInfo() { buildRule.executeTarget("testHasVersionInfo"); - assertFalse(buildRule.getLog().indexOf("No Implementation-Title set.") > -1); - assertFalse(buildRule.getLog().indexOf("No Implementation-Version set.") > -1); - assertFalse(buildRule.getLog().indexOf("No Implementation-Vendor set.") > -1); + assertFalse(buildRule.getLog().contains("No Implementation-Title set.")); + assertFalse(buildRule.getLog().contains("No Implementation-Version set.")); + assertFalse(buildRule.getLog().contains("No Implementation-Vendor set.")); } } diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/LoadFileTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/LoadFileTest.java index 48f47b890..ab665adc1 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/LoadFileTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/LoadFileTest.java @@ -102,7 +102,7 @@ public class LoadFileTest { @Test public void testLoadAFile() throws BuildException { buildRule.executeTarget("testLoadAFile"); - if(buildRule.getProject().getProperty("testLoadAFile").indexOf("eh?")<0) { + if(!buildRule.getProject().getProperty("testLoadAFile").contains("eh?")) { fail("property is not all in the file"); } } @@ -122,7 +122,7 @@ public class LoadFileTest { @Test public void testEvalProps() throws BuildException { buildRule.executeTarget("testEvalProps"); - if(buildRule.getProject().getProperty("testEvalProps").indexOf("rain")<0) { + if(!buildRule.getProject().getProperty("testEvalProps").contains("rain")) { fail("property eval broken"); } } @@ -133,7 +133,7 @@ public class LoadFileTest { @Test public void testFilterChain() throws BuildException { buildRule.executeTarget("testFilterChain"); - if(buildRule.getProject().getProperty("testFilterChain").indexOf("World!")<0) { + if(!buildRule.getProject().getProperty("testFilterChain").contains("World!")) { fail("Filter Chain broken"); } } diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/MacroDefTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/MacroDefTest.java index 9ee7b20d2..59b6bd74f 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/MacroDefTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/MacroDefTest.java @@ -188,7 +188,7 @@ public class MacroDefTest { try { buildRule.executeTarget("backtraceoff"); } catch (BuildException ex) { - if (ex.getMessage().indexOf("following error occurred") != -1) { + if (ex.getMessage().contains("following error occurred")) { fail("error message contained backtrace - " + ex.getMessage()); } } diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/MakeUrlTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/MakeUrlTest.java index 592f1d7ec..b60604b90 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/MakeUrlTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/MakeUrlTest.java @@ -161,7 +161,7 @@ public class MakeUrlTest { String result = getProperty(property); assertTrue("expected " + contains + " in " + result, - result != null && result.indexOf(contains) >= 0); + result != null && result.contains(contains)); } /** diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestTest.java index ca1a94d8f..e51878219 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestTest.java @@ -395,14 +395,14 @@ public class ManifestTest { String mfAsString = mf.toString(); assertNotNull(mfAsString); assertTrue(mfAsString.startsWith("Manifest-Version: 2.0")); - assertTrue(mfAsString.indexOf("Foo: Bar") > -1); + assertTrue(mfAsString.contains("Foo: Bar")); mf = getManifest(new File(outDir, "mftest2.mf")); assertNotNull(mf); mfAsString = mf.toString(); assertNotNull(mfAsString); assertEquals(-1, mfAsString.indexOf("Foo: Bar")); - assertTrue(mfAsString.indexOf("Foo: Baz") > -1); + assertTrue(mfAsString.contains("Foo: Baz")); } @Test diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/PropertyTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/PropertyTest.java index 7cead6678..c40d744cf 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/PropertyTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/PropertyTest.java @@ -68,7 +68,7 @@ public class PropertyTest { fail("Did not throw exception on circular exception"); } catch (BuildException e) { assertTrue("Circular definition not detected - ", - e.getMessage().indexOf("was circularly defined") != -1); + e.getMessage().contains("was circularly defined")); } } diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/SQLExecTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/SQLExecTest.java index 24b042d85..faa890e26 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/SQLExecTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/SQLExecTest.java @@ -90,7 +90,7 @@ public class SQLExecTest { try { sql.execute(); } catch (BuildException e){ - assertTrue(e.getCause().getMessage().indexOf("No suitable Driver") != -1); + assertTrue(e.getCause().getMessage().contains("No suitable Driver")); } assertTrue(JDBCTask.getLoaderMap().containsKey(NULL_DRIVER)); assertSame(sql.getLoader(), JDBCTask.getLoaderMap().get(NULL_DRIVER)); diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/StyleTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/StyleTest.java index 9fd4667fb..e95852476 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/StyleTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/StyleTest.java @@ -232,7 +232,7 @@ public class StyleTest { "expecting file " + filename + " to contain " + contains + " but got " + content, - content.indexOf(contains) > -1); + content.contains(contains)); } } diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/SyncTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/SyncTest.java index 93431dcbc..b296b7ba5 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/SyncTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/SyncTest.java @@ -41,7 +41,7 @@ public class SyncTest { buildRule.executeTarget("simplecopy"); String d = buildRule.getProject().getProperty("dest") + "/a/b/c/d"; assertFileIsPresent(d); - assertTrue(buildRule.getFullLog().indexOf("dangling") == -1); + assertTrue(!buildRule.getFullLog().contains("dangling")); } @Test @@ -51,7 +51,7 @@ public class SyncTest { assertFileIsNotPresent(d); String c = buildRule.getProject().getProperty("dest") + "/a/b/c"; assertFileIsNotPresent(c); - assertTrue(buildRule.getFullLog().indexOf("dangling") == -1); + assertTrue(!buildRule.getFullLog().contains("dangling")); } @Test @@ -61,7 +61,7 @@ public class SyncTest { assertFileIsNotPresent(d); String c = buildRule.getProject().getProperty("dest") + "/a/b/c"; assertFileIsPresent(c); - assertTrue(buildRule.getFullLog().indexOf("dangling") == -1); + assertTrue(!buildRule.getFullLog().contains("dangling")); } @Test @@ -85,7 +85,7 @@ public class SyncTest { assertFileIsPresent(d); String f = buildRule.getProject().getProperty("dest") + "/e/f"; assertFileIsNotPresent(f); - assertTrue(buildRule.getFullLog().indexOf("Removing orphan file:") > -1); + assertTrue(buildRule.getFullLog().contains("Removing orphan file:")); assertContains("Removed 1 dangling file from", buildRule.getFullLog()); assertContains("Removed 1 dangling directory from", buildRule.getFullLog()); } @@ -97,7 +97,7 @@ public class SyncTest { assertFileIsPresent(d); String f = buildRule.getProject().getProperty("dest") + "/e/f"; assertFileIsNotPresent(f); - assertTrue(buildRule.getFullLog().indexOf("Removing orphan file:") > -1); + assertTrue(buildRule.getFullLog().contains("Removing orphan file:")); assertContains("Removed 1 dangling file from", buildRule.getFullLog()); assertContains("Removed 1 dangling directory from", buildRule.getFullLog()); } @@ -111,7 +111,7 @@ public class SyncTest { assertFileIsPresent(c); String f = buildRule.getProject().getProperty("dest") + "/e/f"; assertFileIsNotPresent(f); - assertTrue(buildRule.getFullLog().indexOf("Removing orphan directory:") > -1); + assertTrue(buildRule.getFullLog().contains("Removing orphan directory:")); assertContains("NO dangling file to remove from", buildRule.getFullLog()); assertContains("Removed 2 dangling directories from", buildRule.getFullLog()); } @@ -123,7 +123,7 @@ public class SyncTest { assertFileIsPresent(d); String f = buildRule.getProject().getProperty("dest") + "/e/f"; assertFileIsPresent(f); - assertTrue(buildRule.getFullLog().indexOf("Removing orphan file:") == -1); + assertTrue(!buildRule.getFullLog().contains("Removing orphan file:")); } @Test @@ -133,7 +133,7 @@ public class SyncTest { assertFileIsPresent(d); String f = buildRule.getProject().getProperty("dest") + "/e/f"; assertFileIsPresent(f); - assertTrue(buildRule.getFullLog().indexOf("Removing orphan file:") == -1); + assertTrue(!buildRule.getFullLog().contains("Removing orphan file:")); } public void assertFileIsPresent(String f) { diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/TaskdefTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/TaskdefTest.java index 7f28de05c..24e509097 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/TaskdefTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/TaskdefTest.java @@ -119,10 +119,10 @@ public class TaskdefTest { buildRule.executeTarget("testOverride"); String log = buildRule.getLog(); assertTrue("override warning sent", - log.indexOf("Trying to override old definition of task copy") > -1); + log.contains("Trying to override old definition of task copy")); assertTrue("task inside target worked", - log.indexOf("In target") > -1); + log.contains("In target")); assertTrue("task inside target worked", - log.indexOf("In TaskContainer") > -1); + log.contains("In TaskContainer")); } } diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/EchoPropertiesTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/EchoPropertiesTest.java index d1c3aea12..9d34760ea 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/EchoPropertiesTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/EchoPropertiesTest.java @@ -131,7 +131,7 @@ public class EchoPropertiesTest { try { String read = null; while ((read = br.readLine()) != null) { - if (read.indexOf("") >= 0) { + if (read.contains("")) { // found the property we set - it's good. return; } diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XmlValidateTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XmlValidateTest.java index 9cd6eb2e9..2e5bbbbcf 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XmlValidateTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XmlValidateTest.java @@ -137,7 +137,7 @@ public class XmlValidateTest { throw new AssumptionViolatedException("parser doesn't support schema"); } else { assertTrue( - e.getMessage().indexOf("not a valid XML document") > -1); + e.getMessage().contains("not a valid XML document")); } } } diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XsltTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XsltTest.java index d84fc6907..e757faeee 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XsltTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XsltTest.java @@ -77,7 +77,7 @@ public class XsltTest { @Test public void testStyleSheetWithInclude() throws Exception { buildRule.executeTarget("testStyleSheetWithInclude"); - if (buildRule.getLog().indexOf("java.io.FileNotFoundException") != -1) { + if (buildRule.getLog().contains("java.io.FileNotFoundException")) { fail("xsl:include was not found"); } } diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/image/ImageTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/image/ImageTest.java index 40d0caacf..1fb82d4db 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/image/ImageTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/image/ImageTest.java @@ -116,7 +116,7 @@ public class ImageTest { } catch (RuntimeException re){ assertTrue("Run time exception should say 'Unable to process image stream'. :" + re.toString(), - re.toString().indexOf("Unable to process image stream") > -1); + re.toString().contains("Unable to process image stream")); } } diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunnerTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunnerTest.java index 7ea41e8a4..d23a59b65 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunnerTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunnerTest.java @@ -80,7 +80,7 @@ public class JUnitTestRunnerTest { runner.run(); String error = runner.getFormatter().getError(); assertEquals(error, JUnitTestRunner.ERRORS, runner.getRetCode()); - assertTrue(error, error.indexOf("thrown on purpose") != -1); + assertTrue(error, error.contains("thrown on purpose")); } // check that something which is not a testcase generates no errors diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/script/ScriptDefTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/script/ScriptDefTest.java index 89aa38579..2361dc956 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/script/ScriptDefTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/script/ScriptDefTest.java @@ -56,10 +56,10 @@ public class ScriptDefTest { File baseDir = fileset.getDir(p); String log = buildRule.getLog(); assertTrue("Expecting attribute value printed", - log.indexOf("Attribute attr1 = test") != -1); + log.contains("Attribute attr1 = test")); assertTrue("Expecting nested element value printed", - log.indexOf("Fileset basedir = " + baseDir.getAbsolutePath()) != -1); + log.contains("Fileset basedir = " + baseDir.getAbsolutePath())); } @Test @@ -91,10 +91,10 @@ public class ScriptDefTest { File baseDir = fileset.getDir(p); String log = buildRule.getLog(); assertTrue("Expecting attribute value to be printed", - log.indexOf("Attribute attr1 = test") != -1); + log.contains("Attribute attr1 = test")); assertTrue("Expecting nested element value to be printed", - log.indexOf("Fileset basedir = " + baseDir.getAbsolutePath()) != -1); + log.contains("Fileset basedir = " + baseDir.getAbsolutePath())); } @Test @@ -117,8 +117,8 @@ public class ScriptDefTest { public void testDoubleDef() { buildRule.executeTarget("doubledef"); String log = buildRule.getLog(); - assertTrue("Task1 did not execute", log.indexOf("Task1") != -1); - assertTrue("Task2 did not execute", log.indexOf("Task2") != -1); + assertTrue("Task1 did not execute", log.contains("Task1")); + assertTrue("Task2 did not execute", log.contains("Task2")); } @Test @@ -137,7 +137,7 @@ public class ScriptDefTest { // get the fileset and its basedir String log = buildRule.getLog(); assertTrue("Expecting property in attribute value replaced", - log.indexOf("Attribute value = test") != -1); + log.contains("Attribute value = test")); } @Test diff --git a/src/tests/junit/org/apache/tools/ant/types/CommandlineJavaTest.java b/src/tests/junit/org/apache/tools/ant/types/CommandlineJavaTest.java index db70ac49e..5f6bb506d 100644 --- a/src/tests/junit/org/apache/tools/ant/types/CommandlineJavaTest.java +++ b/src/tests/junit/org/apache/tools/ant/types/CommandlineJavaTest.java @@ -94,7 +94,7 @@ public class CommandlineJavaTest { assertEquals("with classpath", "-Djava.compiler=NONE", s[1]); assertEquals("with classpath", "-classpath", s[2]); assertTrue("build.xml contained", - s[3].indexOf("build.xml"+java.io.File.pathSeparator) >= 0); + s[3].contains("build.xml" + java.io.File.pathSeparator)); assertTrue("ant.jar contained", s[3].endsWith("ant.jar")); assertEquals("with classpath", "junit.textui.TestRunner", s[4]); assertEquals("with classpath", diff --git a/src/tests/junit/org/apache/tools/ant/types/PathTest.java b/src/tests/junit/org/apache/tools/ant/types/PathTest.java index 20c0b3a9e..b75e9f506 100644 --- a/src/tests/junit/org/apache/tools/ant/types/PathTest.java +++ b/src/tests/junit/org/apache/tools/ant/types/PathTest.java @@ -572,7 +572,7 @@ public class PathTest { assertEquals(0, p.list().length); } catch (BuildException x) { String m = x.toString(); - assertTrue(m, m.indexOf("circular") != -1); + assertTrue(m, m.contains("circular")); } } diff --git a/src/tests/junit/org/apache/tools/ant/types/RedirectorElementTest.java b/src/tests/junit/org/apache/tools/ant/types/RedirectorElementTest.java index b7bfa5d09..9ed6ef64d 100644 --- a/src/tests/junit/org/apache/tools/ant/types/RedirectorElementTest.java +++ b/src/tests/junit/org/apache/tools/ant/types/RedirectorElementTest.java @@ -73,7 +73,7 @@ public class RedirectorElementTest { @Test public void testLogInputString() { buildRule.executeTarget("testLogInputString"); - if (buildRule.getLog().indexOf("testLogInputString can-cat") >= 0) { + if (buildRule.getLog().contains("testLogInputString can-cat")) { AntAssert.assertContains("Using input string", buildRule.getFullLog()); } } diff --git a/src/tests/junit/org/apache/tools/ant/types/selectors/ModifiedSelectorTest.java b/src/tests/junit/org/apache/tools/ant/types/selectors/ModifiedSelectorTest.java index e9591b528..0b940ad64 100644 --- a/src/tests/junit/org/apache/tools/ant/types/selectors/ModifiedSelectorTest.java +++ b/src/tests/junit/org/apache/tools/ant/types/selectors/ModifiedSelectorTest.java @@ -185,7 +185,7 @@ public class ModifiedSelectorTest { assertNotNull("'fs.full.value' must be set.", fsFullValue); assertTrue("'fs.full.value' must not be null.", !"".equals(fsFullValue)); - assertTrue("'fs.full.value' must contain ant.bat.", fsFullValue.indexOf("ant.bat")>-1); + assertTrue("'fs.full.value' must contain ant.bat.", fsFullValue.contains("ant.bat")); assertNotNull("'fs.mod.value' must be set.", fsModValue); // must be empty according to the Mock* implementations diff --git a/src/tests/junit/org/apache/tools/ant/util/LayoutPreservingPropertiesTest.java b/src/tests/junit/org/apache/tools/ant/util/LayoutPreservingPropertiesTest.java index 4309098f8..78a987a0f 100644 --- a/src/tests/junit/org/apache/tools/ant/util/LayoutPreservingPropertiesTest.java +++ b/src/tests/junit/org/apache/tools/ant/util/LayoutPreservingPropertiesTest.java @@ -59,8 +59,8 @@ public class LayoutPreservingPropertiesTest { // and now make sure that the comments made it into the new file String s = readFile(tmp); - assertTrue("missing comment", s.indexOf("# a comment") > -1); - assertTrue("missing comment", s.indexOf("! more comment") > -1); + assertTrue("missing comment", s.contains("# a comment")); + assertTrue("missing comment", s.contains("! more comment")); } /** @@ -89,16 +89,16 @@ public class LayoutPreservingPropertiesTest { // and check that the resulting file looks okay String s = readFile(tmp); - assertTrue(s.indexOf("\\ prop\\ one\\ =\\ \\ leading and trailing" - + " spaces ") > -1); - assertTrue(s.indexOf("prop\\ttwo=contains\\ttab") > -1); - assertTrue(s.indexOf("prop\\nthree=contains\\nnewline") > -1); - assertTrue(s.indexOf("prop\\rfour=contains\\rcarriage return") > -1); - assertTrue(s.indexOf("prop\\\\six=contains\\\\backslash") > -1); - assertTrue(s.indexOf("prop\\:seven=contains\\:colon") > -1); - assertTrue(s.indexOf("prop\\=eight=contains\\=equals") > -1); - assertTrue(s.indexOf("prop\\#nine=contains\\#hash") > -1); - assertTrue(s.indexOf("prop\\!ten=contains\\!exclamation") > -1); + assertTrue(s.contains("\\ prop\\ one\\ =\\ \\ leading and trailing" + + " spaces ")); + assertTrue(s.contains("prop\\ttwo=contains\\ttab")); + assertTrue(s.contains("prop\\nthree=contains\\nnewline")); + assertTrue(s.contains("prop\\rfour=contains\\rcarriage return")); + assertTrue(s.contains("prop\\\\six=contains\\\\backslash")); + assertTrue(s.contains("prop\\:seven=contains\\:colon")); + assertTrue(s.contains("prop\\=eight=contains\\=equals")); + assertTrue(s.contains("prop\\#nine=contains\\#hash")); + assertTrue(s.contains("prop\\!ten=contains\\!exclamation")); } /** @@ -125,13 +125,13 @@ public class LayoutPreservingPropertiesTest { // and check that the resulting file looks okay String s = readFile(tmp); - assertTrue(s.indexOf("\\ prop\\ one\\ =\\ \\ leading and" - + " trailing spaces ") == -1); - assertTrue(s.indexOf("\\ prop\\ one\\ =new one") > -1); - assertTrue(s.indexOf("prop\\ttwo=contains\\ttab") == -1); - assertTrue(s.indexOf("prop\\ttwo=new two") > -1); - assertTrue(s.indexOf("prop\\nthree=contains\\nnewline") == -1); - assertTrue(s.indexOf("prop\\nthree=new three") > -1); + assertTrue(!s.contains("\\ prop\\ one\\ =\\ \\ leading and" + + " trailing spaces ")); + assertTrue(s.contains("\\ prop\\ one\\ =new one")); + assertTrue(!s.contains("prop\\ttwo=contains\\ttab")); + assertTrue(s.contains("prop\\ttwo=new two")); + assertTrue(!s.contains("prop\\nthree=contains\\nnewline")); + assertTrue(s.contains("prop\\nthree=new three")); } @Test @@ -172,18 +172,18 @@ public class LayoutPreservingPropertiesTest { String s = readFile(tmp); assertTrue("should have had no properties ", - s.indexOf("prop.alpha") == -1); + !s.contains("prop.alpha")); assertTrue("should have had no properties ", - s.indexOf("prop.beta") == -1); + !s.contains("prop.beta")); assertTrue("should have had no properties ", - s.indexOf("prop.gamma") == -1); + !s.contains("prop.gamma")); assertTrue("should have had no comments", - s.indexOf("# a comment") == -1); + !s.contains("# a comment")); assertTrue("should have had no comments", - s.indexOf("! more comment") == -1); + !s.contains("! more comment")); assertTrue("should have had no comments", - s.indexOf("# now a line wrapping one") == -1); + !s.contains("# now a line wrapping one")); } @Test @@ -204,9 +204,9 @@ public class LayoutPreservingPropertiesTest { String s = readFile(tmp); assertTrue("should not have had prop.beta", - s.indexOf("prop.beta") == -1); + !s.contains("prop.beta")); assertTrue("should have had prop.beta's comment", - s.indexOf("! more comment") > -1); + s.contains("! more comment")); } @Test @@ -229,9 +229,9 @@ public class LayoutPreservingPropertiesTest { String s = readFile(tmp); assertTrue("should not have had prop.beta", - s.indexOf("prop.beta") == -1); + !s.contains("prop.beta")); assertTrue("should not have had prop.beta's comment", - s.indexOf("! more comment") == -1); + !s.contains("! more comment")); } @Test @@ -262,13 +262,13 @@ public class LayoutPreservingPropertiesTest { String s2 = readFile(tmp2); // check original is untouched - assertTrue("should have had 'simple'", s1.indexOf("simple") > -1); - assertTrue("should not have had prop.new", s1.indexOf("prop.new") == -1); + assertTrue("should have had 'simple'", s1.contains("simple")); + assertTrue("should not have had prop.new", !s1.contains("prop.new")); // check clone has the changes assertTrue("should have had 'a new value for beta'", - s2.indexOf("a new value for beta") > -1); - assertTrue("should have had prop.new", s2.indexOf("prop.new") > -1); + s2.contains("a new value for beta")); + assertTrue("should have had prop.new", s2.contains("prop.new")); } @Test @@ -293,16 +293,16 @@ public class LayoutPreservingPropertiesTest { // and check that the resulting file looks okay String s = readFile(tmp); - assertTrue(s.indexOf("prop\\:seven=new value for seven") > -1); - assertTrue(s.indexOf("prop\\=eight=new value for eight") > -1); - assertTrue(s.indexOf("prop\\ eleven=new value for eleven") > -1); - assertTrue(s.indexOf("alpha=new value for alpha") > -1); - assertTrue(s.indexOf("beta=new value for beta") > -1); + assertTrue(s.contains("prop\\:seven=new value for seven")); + assertTrue(s.contains("prop\\=eight=new value for eight")); + assertTrue(s.contains("prop\\ eleven=new value for eleven")); + assertTrue(s.contains("alpha=new value for alpha")); + assertTrue(s.contains("beta=new value for beta")); - assertTrue(s.indexOf("prop\\:seven=contains\\:colon") == -1); - assertTrue(s.indexOf("prop\\=eight=contains\\=equals") == -1); - assertTrue(s.indexOf("alpha:set with a colon") == -1); - assertTrue(s.indexOf("beta set with a space") == -1); + assertTrue(!s.contains("prop\\:seven=contains\\:colon")); + assertTrue(!s.contains("prop\\=eight=contains\\=equals")); + assertTrue(!s.contains("alpha:set with a colon")); + assertTrue(!s.contains("beta set with a space")); } private static String readFile(File f) throws IOException {