Browse Source

Use String.contains()

master
Gintas Grigelionis 7 years ago
parent
commit
92f18cff48
59 changed files with 178 additions and 181 deletions
  1. +1
    -1
      src/main/org/apache/tools/ant/filters/LineContains.java
  2. +1
    -1
      src/main/org/apache/tools/ant/filters/TokenFilter.java
  3. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/Copy.java
  4. +3
    -3
      src/main/org/apache/tools/ant/taskdefs/Exec.java
  5. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/ExecTask.java
  6. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/JDBCTask.java
  7. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/Javadoc.java
  8. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/Jikes.java
  9. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/JikesOutputParser.java
  10. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/Rmic.java
  11. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/SQLExec.java
  12. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/VerifyJar.java
  13. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/condition/Contains.java
  14. +15
    -15
      src/main/org/apache/tools/ant/taskdefs/condition/Os.java
  15. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/condition/ResourceContains.java
  16. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java
  17. +7
    -7
      src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java
  18. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/ejb/JonasDeploymentTool.java
  19. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/javah/Gcjh.java
  20. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/javah/Kaffeh.java
  21. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/jlink/jlink.java
  22. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java
  23. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
  24. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java
  25. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java
  26. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHSession.java
  27. +3
    -4
      src/main/org/apache/tools/ant/types/Commandline.java
  28. +1
    -1
      src/main/org/apache/tools/ant/types/FilterSet.java
  29. +1
    -1
      src/main/org/apache/tools/ant/types/Path.java
  30. +1
    -1
      src/main/org/apache/tools/ant/types/selectors/ContainsSelector.java
  31. +1
    -1
      src/main/org/apache/tools/ant/util/RegexpPatternMapper.java
  32. +1
    -1
      src/main/org/apache/tools/tar/TarEntry.java
  33. +6
    -6
      src/tests/junit/org/apache/tools/ant/BuildFileTest.java
  34. +4
    -6
      src/tests/junit/org/apache/tools/ant/LocationTest.java
  35. +7
    -7
      src/tests/junit/org/apache/tools/ant/TaskContainerTest.java
  36. +3
    -3
      src/tests/junit/org/apache/tools/ant/taskdefs/AntTest.java
  37. +5
    -5
      src/tests/junit/org/apache/tools/ant/taskdefs/ConcatTest.java
  38. +1
    -1
      src/tests/junit/org/apache/tools/ant/taskdefs/CopyTest.java
  39. +12
    -12
      src/tests/junit/org/apache/tools/ant/taskdefs/JarTest.java
  40. +3
    -3
      src/tests/junit/org/apache/tools/ant/taskdefs/LoadFileTest.java
  41. +1
    -1
      src/tests/junit/org/apache/tools/ant/taskdefs/MacroDefTest.java
  42. +1
    -1
      src/tests/junit/org/apache/tools/ant/taskdefs/MakeUrlTest.java
  43. +2
    -2
      src/tests/junit/org/apache/tools/ant/taskdefs/ManifestTest.java
  44. +1
    -1
      src/tests/junit/org/apache/tools/ant/taskdefs/PropertyTest.java
  45. +1
    -1
      src/tests/junit/org/apache/tools/ant/taskdefs/SQLExecTest.java
  46. +1
    -1
      src/tests/junit/org/apache/tools/ant/taskdefs/StyleTest.java
  47. +8
    -8
      src/tests/junit/org/apache/tools/ant/taskdefs/SyncTest.java
  48. +3
    -3
      src/tests/junit/org/apache/tools/ant/taskdefs/TaskdefTest.java
  49. +1
    -1
      src/tests/junit/org/apache/tools/ant/taskdefs/optional/EchoPropertiesTest.java
  50. +1
    -1
      src/tests/junit/org/apache/tools/ant/taskdefs/optional/XmlValidateTest.java
  51. +1
    -1
      src/tests/junit/org/apache/tools/ant/taskdefs/optional/XsltTest.java
  52. +1
    -1
      src/tests/junit/org/apache/tools/ant/taskdefs/optional/image/ImageTest.java
  53. +1
    -1
      src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunnerTest.java
  54. +7
    -7
      src/tests/junit/org/apache/tools/ant/taskdefs/optional/script/ScriptDefTest.java
  55. +1
    -1
      src/tests/junit/org/apache/tools/ant/types/CommandlineJavaTest.java
  56. +1
    -1
      src/tests/junit/org/apache/tools/ant/types/PathTest.java
  57. +1
    -1
      src/tests/junit/org/apache/tools/ant/types/RedirectorElementTest.java
  58. +1
    -1
      src/tests/junit/org/apache/tools/ant/types/selectors/ModifiedSelectorTest.java
  59. +42
    -42
      src/tests/junit/org/apache/tools/ant/util/LayoutPreservingPropertiesTest.java

+ 1
- 1
src/main/org/apache/tools/ant/filters/LineContains.java View File

@@ -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;


+ 1
- 1
src/main/org/apache/tools/ant/filters/TokenFilter.java View File

@@ -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;


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/Copy.java View File

@@ -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");


+ 3
- 3
src/main/org/apache/tools/ant/taskdefs/Exec.java View File

@@ -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);


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/ExecTask.java View File

@@ -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,


+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/JDBCTask.java View File

@@ -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;
}


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/Javadoc.java View File

@@ -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)) {


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/Jikes.java View File

@@ -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 {


+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/JikesOutputParser.java View File

@@ -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


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/Rmic.java View File

@@ -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 {


+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/SQLExec.java View File

@@ -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);


+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/VerifyJar.java View File

@@ -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);
}
}


+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/condition/Contains.java View File

@@ -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());
}
}

+ 15
- 15
src/main/org/apache/tools/ant/taskdefs/condition/Os.java View File

@@ -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 \""


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/condition/ResourceContains.java View File

@@ -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);
}


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/optional/ANTLR.java View File

@@ -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());
}


+ 7
- 7
src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java View File

@@ -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 {


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/optional/ejb/JonasDeploymentTool.java View File

@@ -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


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/optional/javah/Gcjh.java View File

@@ -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;
}
}


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/optional/javah/Kaffeh.java View File

@@ -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;
}
}


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/optional/jlink/jlink.java View File

@@ -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;
}


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java View File

@@ -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;
}
}


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java View File

@@ -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);
}
}


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java View File

@@ -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);
}
}


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHExec.java View File

@@ -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);
}


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/optional/ssh/SSHSession.java View File

@@ -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);
}


+ 3
- 4
src/main/org/apache/tools/ant/types/Commandline.java View File

@@ -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 + '\"';


+ 1
- 1
src/main/org/apache/tools/ant/types/FilterSet.java View File

@@ -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) {


+ 1
- 1
src/main/org/apache/tools/ant/types/Path.java View File

@@ -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();


+ 1
- 1
src/main/org/apache/tools/ant/types/selectors/ContainsSelector.java View File

@@ -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();


+ 1
- 1
src/main/org/apache/tools/ant/util/RegexpPatternMapper.java View File

@@ -119,7 +119,7 @@ public class RegexpPatternMapper implements FileNameMapper {
return null;
}
if (handleDirSep) {
if (sourceFileName.indexOf("\\") != -1) {
if (sourceFileName.contains("\\")) {
sourceFileName = sourceFileName.replace('\\', '/');
}
}


+ 1
- 1
src/main/org/apache/tools/tar/TarEntry.java View File

@@ -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);


+ 6
- 6
src/tests/junit/org/apache/tools/ant/BuildFileTest.java View File

@@ -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;


+ 4
- 6
src/tests/junit/org/apache/tools/ant/LocationTest.java View File

@@ -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 {


+ 7
- 7
src/tests/junit/org/apache/tools/ant/TaskContainerTest.java View File

@@ -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"));
}

}

+ 3
- 3
src/tests/junit/org/apache/tools/ant/taskdefs/AntTest.java View File

@@ -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


+ 5
- 5
src/tests/junit/org/apache/tools/ant/taskdefs/ConcatTest.java View File

@@ -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));
}

}

+ 1
- 1
src/tests/junit/org/apache/tools/ant/taskdefs/CopyTest.java View File

@@ -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


+ 12
- 12
src/tests/junit/org/apache/tools/ant/taskdefs/JarTest.java View File

@@ -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."));
}

}

+ 3
- 3
src/tests/junit/org/apache/tools/ant/taskdefs/LoadFileTest.java View File

@@ -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");
}
}


+ 1
- 1
src/tests/junit/org/apache/tools/ant/taskdefs/MacroDefTest.java View File

@@ -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());
}
}


+ 1
- 1
src/tests/junit/org/apache/tools/ant/taskdefs/MakeUrlTest.java View File

@@ -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));
}

/**


+ 2
- 2
src/tests/junit/org/apache/tools/ant/taskdefs/ManifestTest.java View File

@@ -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


+ 1
- 1
src/tests/junit/org/apache/tools/ant/taskdefs/PropertyTest.java View File

@@ -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"));
}

}


+ 1
- 1
src/tests/junit/org/apache/tools/ant/taskdefs/SQLExecTest.java View File

@@ -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));


+ 1
- 1
src/tests/junit/org/apache/tools/ant/taskdefs/StyleTest.java View File

@@ -232,7 +232,7 @@ public class StyleTest {
"expecting file " + filename
+ " to contain " + contains
+ " but got " + content,
content.indexOf(contains) > -1);
content.contains(contains));
}

}

+ 8
- 8
src/tests/junit/org/apache/tools/ant/taskdefs/SyncTest.java View File

@@ -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) {


+ 3
- 3
src/tests/junit/org/apache/tools/ant/taskdefs/TaskdefTest.java View File

@@ -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"));
}
}

+ 1
- 1
src/tests/junit/org/apache/tools/ant/taskdefs/optional/EchoPropertiesTest.java View File

@@ -131,7 +131,7 @@ public class EchoPropertiesTest {
try {
String read = null;
while ((read = br.readLine()) != null) {
if (read.indexOf("<property name=\"test.property\" value=\""+TEST_VALUE+"\" />") >= 0) {
if (read.contains("<property name=\"test.property\" value=\"" + TEST_VALUE + "\" />")) {
// found the property we set - it's good.
return;
}


+ 1
- 1
src/tests/junit/org/apache/tools/ant/taskdefs/optional/XmlValidateTest.java View File

@@ -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"));
}
}
}


+ 1
- 1
src/tests/junit/org/apache/tools/ant/taskdefs/optional/XsltTest.java View File

@@ -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");
}
}


+ 1
- 1
src/tests/junit/org/apache/tools/ant/taskdefs/optional/image/ImageTest.java View File

@@ -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"));
}
}



+ 1
- 1
src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunnerTest.java View File

@@ -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


+ 7
- 7
src/tests/junit/org/apache/tools/ant/taskdefs/optional/script/ScriptDefTest.java View File

@@ -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


+ 1
- 1
src/tests/junit/org/apache/tools/ant/types/CommandlineJavaTest.java View File

@@ -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",


+ 1
- 1
src/tests/junit/org/apache/tools/ant/types/PathTest.java View File

@@ -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"));
}
}



+ 1
- 1
src/tests/junit/org/apache/tools/ant/types/RedirectorElementTest.java View File

@@ -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());
}
}


+ 1
- 1
src/tests/junit/org/apache/tools/ant/types/selectors/ModifiedSelectorTest.java View File

@@ -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


+ 42
- 42
src/tests/junit/org/apache/tools/ant/util/LayoutPreservingPropertiesTest.java View File

@@ -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 {


Loading…
Cancel
Save