@@ -118,7 +118,7 @@ public final class LineContains | |||||
boolean matches = true; | boolean matches = true; | ||||
for (int i = 0; matches && i < containsSize; i++) { | for (int i = 0; matches && i < containsSize; i++) { | ||||
String containsStr = (String) contains.elementAt(i); | String containsStr = (String) contains.elementAt(i); | ||||
matches = line.indexOf(containsStr) >= 0; | |||||
matches = line.contains(containsStr); | |||||
} | } | ||||
if (matches ^ isNegated()) { | if (matches ^ isNegated()) { | ||||
break; | break; | ||||
@@ -428,7 +428,7 @@ public class TokenFilter extends BaseFilterReader | |||||
if (contains == null) { | if (contains == null) { | ||||
throw new BuildException("Missing contains in containsstring"); | throw new BuildException("Missing contains in containsstring"); | ||||
} | } | ||||
if (string.indexOf(contains) > -1) { | |||||
if (string.contains(contains)) { | |||||
return string; | return string; | ||||
} | } | ||||
return null; | return null; | ||||
@@ -1091,7 +1091,7 @@ public class Copy extends Task { | |||||
} | } | ||||
message.append(ex.getMessage()); | message.append(ex.getMessage()); | ||||
} | } | ||||
if (ex.getClass().getName().indexOf("MalformedInput") != -1) { | |||||
if (ex.getClass().getName().contains("MalformedInput")) { | |||||
message.append(LINE_SEPARATOR); | message.append(LINE_SEPARATOR); | ||||
message.append( | message.append( | ||||
"This is normally due to the input file containing invalid"); | "This is normally due to the input file containing invalid"); | ||||
@@ -87,7 +87,7 @@ public class Exec extends Task { | |||||
// test if os match | // test if os match | ||||
String myos = System.getProperty("os.name"); | String myos = System.getProperty("os.name"); | ||||
log("Myos = " + myos, Project.MSG_VERBOSE); | 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 | // this command will be executed only on the specified OS | ||||
log("Not found in " + os, Project.MSG_VERBOSE); | log("Not found in " + os, Project.MSG_VERBOSE); | ||||
return 0; | return 0; | ||||
@@ -98,9 +98,9 @@ public class Exec extends Task { | |||||
dir = getProject().getBaseDir(); | dir = getProject().getBaseDir(); | ||||
} | } | ||||
if (myos.toLowerCase(Locale.ENGLISH).indexOf("windows") >= 0) { | |||||
if (myos.toLowerCase(Locale.ENGLISH).contains("windows")) { | |||||
if (!dir.equals(getProject().resolveFile("."))) { | 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; | command = "cmd /c cd " + dir + " && " + command; | ||||
} else { | } else { | ||||
String ant = getProject().getProperty(MagicNames.ANT_HOME); | String ant = getProject().getProperty(MagicNames.ANT_HOME); | ||||
@@ -563,7 +563,7 @@ public class ExecTask extends Task { | |||||
//for the current os.name | //for the current os.name | ||||
String myos = System.getProperty("os.name"); | String myos = System.getProperty("os.name"); | ||||
log("Current OS is " + myos, Project.MSG_VERBOSE); | 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 | // this command will be executed only on the specified OS | ||||
log("This OS, " + myos | log("This OS, " + myos | ||||
+ " was not found in the specified list of valid OSes: " + os, | + " was not found in the specified list of valid OSes: " + os, | ||||
@@ -270,7 +270,7 @@ public abstract class JDBCTask extends Task { | |||||
String theVendor = dmd.getDatabaseProductName().toLowerCase(); | String theVendor = dmd.getDatabaseProductName().toLowerCase(); | ||||
log("RDBMS = " + theVendor, Project.MSG_VERBOSE); | 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); | log("Not the required RDBMS: " + rdbms, Project.MSG_VERBOSE); | ||||
return false; | return false; | ||||
} | } | ||||
@@ -282,7 +282,7 @@ public abstract class JDBCTask extends Task { | |||||
log("Version = " + theVersion, Project.MSG_VERBOSE); | log("Version = " + theVersion, Project.MSG_VERBOSE); | ||||
if (theVersion == null | if (theVersion == null | ||||
|| !(theVersion.startsWith(version) | || !(theVersion.startsWith(version) | ||||
|| theVersion.indexOf(" " + version) >= 0)) { | |||||
|| theVersion.contains(" " + version))) { | |||||
log("Not the required version: \"" + version + "\"", Project.MSG_VERBOSE); | log("Not the required version: \"" + version + "\"", Project.MSG_VERBOSE); | ||||
return false; | return false; | ||||
} | } | ||||
@@ -714,7 +714,7 @@ public class Jar extends Zip { | |||||
+ " be replaced by a newly generated one.", | + " be replaced by a newly generated one.", | ||||
Project.MSG_WARN); | Project.MSG_WARN); | ||||
} else { | } else { | ||||
if (index && vPath.indexOf("/") == -1) { | |||||
if (index && !vPath.contains("/")) { | |||||
rootEntries.addElement(vPath); | rootEntries.addElement(vPath); | ||||
} | } | ||||
super.zipFile(is, zOut, vPath, lastModified, fromArchive, mode); | super.zipFile(is, zOut, vPath, lastModified, fromArchive, mode); | ||||
@@ -2230,7 +2230,7 @@ public class Javadoc extends Task { | |||||
if (useExternalFile) { | if (useExternalFile) { | ||||
// TODO what is the following doing? | // TODO what is the following doing? | ||||
// should it run if !javadoc4 && executable != null? | // should it run if !javadoc4 && executable != null? | ||||
if (sourceFileName.indexOf(" ") > -1) { | |||||
if (sourceFileName.contains(" ")) { | |||||
String name = sourceFileName; | String name = sourceFileName; | ||||
if (File.separatorChar == '\\') { | if (File.separatorChar == '\\') { | ||||
name = sourceFileName.replace(File.separatorChar, '/'); | name = sourceFileName.replace(File.separatorChar, '/'); | ||||
@@ -2516,7 +2516,7 @@ public class Javadoc extends Task { | |||||
// check if file may be vulnerable because it was not | // check if file may be vulnerable because it was not | ||||
// patched with "validURL(url)": | // patched with "validURL(url)": | ||||
if (fileContents.indexOf("function validURL(url) {") < 0) { | |||||
if (!fileContents.contains("function validURL(url) {")) { | |||||
// we need to patch the file! | // we need to patch the file! | ||||
final String patchedFileContents = patchContent(fileContents, fixData); | final String patchedFileContents = patchContent(fileContents, fixData); | ||||
if (!patchedFileContents.equals(fileContents)) { | if (!patchedFileContents.equals(fileContents)) { | ||||
@@ -83,7 +83,7 @@ public class Jikes { | |||||
// Windows has a 32k limit on total arg size, so | // Windows has a 32k limit on total arg size, so | ||||
// create a temporary file to store all the arguments | // 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) { | && args.length > MAX_FILES_ON_COMMAND_LINE) { | ||||
BufferedWriter out = null; | BufferedWriter out = null; | ||||
try { | try { | ||||
@@ -136,9 +136,9 @@ public class JikesOutputParser implements ExecuteStreamHandler { | |||||
if (line.trim().equals("")) { | if (line.trim().equals("")) { | ||||
continue; | continue; | ||||
} | } | ||||
if (lower.indexOf("error") != -1) { | |||||
if (lower.contains("error")) { | |||||
setError(true); | setError(true); | ||||
} else if (lower.indexOf("warning") != -1) { | |||||
} else if (lower.contains("warning")) { | |||||
setError(false); | setError(false); | ||||
} else { | } else { | ||||
// If we don't know the type of the line | // If we don't know the type of the line | ||||
@@ -761,7 +761,7 @@ public class Rmic extends MatchingTask { | |||||
if (idl) { | if (idl) { | ||||
log("will leave uptodate test to rmic implementation in idl mode.", | log("will leave uptodate test to rmic implementation in idl mode.", | ||||
Project.MSG_VERBOSE); | 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", | log("no uptodate test as -always option has been specified", | ||||
Project.MSG_VERBOSE); | Project.MSG_VERBOSE); | ||||
} else { | } else { | ||||
@@ -778,7 +778,7 @@ public class SQLExec extends JDBCTask { | |||||
// SQL defines "--" as a comment to EOL | // SQL defines "--" as a comment to EOL | ||||
// and in Oracle it may contain a hint | // and in Oracle it may contain a hint | ||||
// so we cannot just remove it, instead we must end it | // so we cannot just remove it, instead we must end it | ||||
if (!keepformat && line.indexOf("--") >= 0) { | |||||
if (!keepformat && line.contains("--")) { | |||||
sql.append("\n"); | sql.append("\n"); | ||||
} | } | ||||
int lastDelimPos = lastDelimiterPosition(sql, line); | int lastDelimPos = lastDelimiterPosition(sql, line); | ||||
@@ -934,7 +934,8 @@ public class SQLExec extends JDBCTask { | |||||
} | } | ||||
private String maybeQuote(String s) { | 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; | return s; | ||||
} | } | ||||
StringBuilder sb = new StringBuilder(csvQuoteChar); | StringBuilder sb = new StringBuilder(csvQuoteChar); | ||||
@@ -180,15 +180,15 @@ public class VerifyJar extends AbstractJarSignerTask { | |||||
String results = outputCache.toString(); | String results = outputCache.toString(); | ||||
//deal with jdk1.4.2 bug: | //deal with jdk1.4.2 bug: | ||||
if (ex != null) { | if (ex != null) { | ||||
if (results.indexOf("zip file closed") >= 0) { | |||||
log("You are running " + JARSIGNER_COMMAND + " against a JVM with" | |||||
+ " a known bug that manifests as an IllegalStateException.", | |||||
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); | Project.MSG_WARN); | ||||
} else { | } else { | ||||
throw ex; | throw ex; | ||||
} | } | ||||
} | } | ||||
if (results.indexOf(VERIFIED_TEXT) < 0) { | |||||
if (!results.contains(VERIFIED_TEXT)) { | |||||
throw new BuildException(ERROR_NO_VERIFY + jar); | throw new BuildException(ERROR_NO_VERIFY + jar); | ||||
} | } | ||||
} | } | ||||
@@ -559,7 +559,7 @@ public abstract class DefaultCompilerAdapter | |||||
"files", "", getJavac().getTempdir(), true, true); | "files", "", getJavac().getTempdir(), true, true); | ||||
out = new BufferedWriter(new FileWriter(tmpFile)); | out = new BufferedWriter(new FileWriter(tmpFile)); | ||||
for (int i = firstFileName; i < args.length; i++) { | for (int i = firstFileName; i < args.length; i++) { | ||||
if (quoteFiles && args[i].indexOf(" ") > -1) { | |||||
if (quoteFiles && args[i].contains(" ")) { | |||||
args[i] = args[i].replace(File.separatorChar, '/'); | args[i] = args[i].replace(File.separatorChar, '/'); | ||||
out.write("\"" + args[i] + "\""); | out.write("\"" + args[i] + "\""); | ||||
} else { | } else { | ||||
@@ -70,7 +70,7 @@ public class Contains implements Condition { | |||||
} | } | ||||
return caseSensitive | return caseSensitive | ||||
? string.indexOf(subString) > -1 | |||||
: string.toLowerCase().indexOf(subString.toLowerCase()) > -1; | |||||
? string.contains(subString) | |||||
: string.toLowerCase().contains(subString.toLowerCase()); | |||||
} | } | ||||
} | } |
@@ -257,17 +257,17 @@ public class Os implements Condition { | |||||
//windows probing logic relies on the word 'windows' in | //windows probing logic relies on the word 'windows' in | ||||
//the OS | //the OS | ||||
boolean isWindows = OS_NAME.indexOf(FAMILY_WINDOWS) > -1; | |||||
boolean isWindows = OS_NAME.contains(FAMILY_WINDOWS); | |||||
boolean is9x = false; | boolean is9x = false; | ||||
boolean isNT = false; | boolean isNT = false; | ||||
if (isWindows) { | if (isWindows) { | ||||
//there are only four 9x platforms that we look for | //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 | //wince isn't really 9x, but crippled enough to | ||||
//be a muchness. Ant doesn't run on CE, anyway. | //be a muchness. Ant doesn't run on CE, anyway. | ||||
|| OS_NAME.indexOf("ce") >= 0); | |||||
|| OS_NAME.contains("ce")); | |||||
isNT = !is9x; | isNT = !is9x; | ||||
} | } | ||||
if (family.equals(FAMILY_WINDOWS)) { | if (family.equals(FAMILY_WINDOWS)) { | ||||
@@ -277,28 +277,28 @@ public class Os implements Condition { | |||||
} else if (family.equals(FAMILY_NT)) { | } else if (family.equals(FAMILY_NT)) { | ||||
isFamily = isWindows && isNT; | isFamily = isWindows && isNT; | ||||
} else if (family.equals(FAMILY_OS2)) { | } 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)) { | } 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)) { | } else if (family.equals(FAMILY_DOS)) { | ||||
isFamily = PATH_SEP.equals(";") && !isFamily(FAMILY_NETWARE); | isFamily = PATH_SEP.equals(";") && !isFamily(FAMILY_NETWARE); | ||||
} else if (family.equals(FAMILY_MAC)) { | } 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)) { | } 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)) { | } else if (family.equals(FAMILY_UNIX)) { | ||||
isFamily = PATH_SEP.equals(":") | isFamily = PATH_SEP.equals(":") | ||||
&& !isFamily(FAMILY_VMS) | && !isFamily(FAMILY_VMS) | ||||
&& (!isFamily(FAMILY_MAC) || OS_NAME.endsWith("x") | && (!isFamily(FAMILY_MAC) || OS_NAME.endsWith("x") | ||||
|| OS_NAME.indexOf(DARWIN) > -1); | |||||
|| OS_NAME.contains(DARWIN)); | |||||
} else if (family.equals(FAMILY_ZOS)) { | } 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)) { | } 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)) { | } else if (family.equals(FAMILY_VMS)) { | ||||
isFamily = OS_NAME.indexOf(FAMILY_VMS) > -1; | |||||
isFamily = OS_NAME.contains(FAMILY_VMS); | |||||
} else { | } else { | ||||
throw new BuildException( | throw new BuildException( | ||||
"Don\'t know how to detect os family \"" | "Don\'t know how to detect os family \"" | ||||
@@ -155,7 +155,7 @@ public class ResourceContains implements Condition { | |||||
contents = contents.toLowerCase(); | contents = contents.toLowerCase(); | ||||
sub = sub.toLowerCase(); | sub = sub.toLowerCase(); | ||||
} | } | ||||
return contents.indexOf(sub) >= 0; | |||||
return contents.contains(sub); | |||||
} catch (IOException e) { | } catch (IOException e) { | ||||
throw new BuildException("There was a problem accessing resource : " + resource); | throw new BuildException("There was a problem accessing resource : " + resource); | ||||
} finally { | } finally { | ||||
@@ -302,12 +302,11 @@ public class ANTLR extends Task { | |||||
int err = run(commandline.getCommandline()); | int err = run(commandline.getCommandline()); | ||||
if (err != 0) { | if (err != 0) { | ||||
throw new BuildException("ANTLR returned: " + err, getLocation()); | throw new BuildException("ANTLR returned: " + err, getLocation()); | ||||
} else { | |||||
String output = bos.toString(); | |||||
if (output.indexOf("error:") > -1) { | |||||
throw new BuildException("ANTLR signaled an error: " | |||||
+ output, getLocation()); | |||||
} | |||||
} | |||||
String output = bos.toString(); | |||||
if (output.contains("error:")) { | |||||
throw new BuildException("ANTLR signaled an error: " | |||||
+ output, getLocation()); | |||||
} | } | ||||
} else { | } else { | ||||
log("Skipped grammar file. Generated file " + generatedFile | log("Skipped grammar file. Generated file " + generatedFile | ||||
@@ -887,24 +887,24 @@ public class NetRexxC extends MatchingTask { | |||||
} | } | ||||
// verbose level logging for suppressed messages | // verbose level logging for suppressed messages | ||||
if (suppressMethodArgumentNotUsed | if (suppressMethodArgumentNotUsed | ||||
&& l.indexOf(MSG_METHOD_ARGUMENT_NOT_USED) != -1) { | |||||
&& l.contains(MSG_METHOD_ARGUMENT_NOT_USED)) { | |||||
log(l, Project.MSG_VERBOSE); | log(l, Project.MSG_VERBOSE); | ||||
} else if (suppressPrivatePropertyNotUsed | } else if (suppressPrivatePropertyNotUsed | ||||
&& l.indexOf(MSG_PRIVATE_PROPERTY_NOT_USED) != -1) { | |||||
&& l.contains(MSG_PRIVATE_PROPERTY_NOT_USED)) { | |||||
log(l, Project.MSG_VERBOSE); | log(l, Project.MSG_VERBOSE); | ||||
} else if (suppressVariableNotUsed | } else if (suppressVariableNotUsed | ||||
&& l.indexOf(MSG_VARIABLE_NOT_USED) != -1) { | |||||
&& l.contains(MSG_VARIABLE_NOT_USED)) { | |||||
log(l, Project.MSG_VERBOSE); | log(l, Project.MSG_VERBOSE); | ||||
} else if (suppressExceptionNotSignalled | } else if (suppressExceptionNotSignalled | ||||
&& l.indexOf(MSG_EXCEPTION_NOT_SIGNALLED) != -1) { | |||||
&& l.contains(MSG_EXCEPTION_NOT_SIGNALLED)) { | |||||
log(l, Project.MSG_VERBOSE); | log(l, Project.MSG_VERBOSE); | ||||
} else if (suppressDeprecation | } else if (suppressDeprecation | ||||
&& l.indexOf(MSG_DEPRECATION) != -1) { | |||||
&& l.contains(MSG_DEPRECATION)) { | |||||
log(l, Project.MSG_VERBOSE); | log(l, Project.MSG_VERBOSE); | ||||
} else if (l.indexOf("Error:") != -1) { | |||||
} else if (l.contains("Error:")) { | |||||
// error level logging for compiler errors | // error level logging for compiler errors | ||||
log(l, Project.MSG_ERR); | log(l, Project.MSG_ERR); | ||||
} else if (l.indexOf("Warning:") != -1) { | |||||
} else if (l.contains("Warning:")) { | |||||
// warning for all warning messages | // warning for all warning messages | ||||
log(l, Project.MSG_WARN); | log(l, Project.MSG_WARN); | ||||
} else { | } else { | ||||
@@ -522,7 +522,7 @@ public class Depend extends MatchingTask { | |||||
// without closure we may delete an inner class but not the | // without closure we may delete an inner class but not the | ||||
// top level class which would not trigger a recompile. | // top level class which would not trigger a recompile. | ||||
if (affectedClass.indexOf("$") == -1) { | |||||
if (!affectedClass.contains("$")) { | |||||
continue; | continue; | ||||
} | } | ||||
// need to delete the main class | // need to delete the main class | ||||
@@ -465,7 +465,7 @@ public class JonasDeploymentTool extends GenericDeploymentTool { | |||||
if (getConfig().namingScheme.getValue().equals(EjbJar.NamingScheme.DESCRIPTOR)) { | if (getConfig().namingScheme.getValue().equals(EjbJar.NamingScheme.DESCRIPTOR)) { | ||||
// try to find JOnAS specific convention name | // 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 | // baseNameTerminator not found: the descriptor use the | ||||
// JOnAS naming convention, ie [Foo.xml,jonas-Foo.xml] and | // JOnAS naming convention, ie [Foo.xml,jonas-Foo.xml] and | ||||
@@ -42,7 +42,7 @@ public class Gcjh implements JavahAdapter { | |||||
Execute.runCommand(javah, cmd.getCommandline()); | Execute.runCommand(javah, cmd.getCommandline()); | ||||
return true; | return true; | ||||
} catch (BuildException e) { | } catch (BuildException e) { | ||||
if (e.getMessage().indexOf("failed with return code") == -1) { | |||||
if (!e.getMessage().contains("failed with return code")) { | |||||
throw e; | throw e; | ||||
} | } | ||||
} | } | ||||
@@ -47,7 +47,7 @@ public class Kaffeh implements JavahAdapter { | |||||
Execute.runCommand(javah, cmd.getCommandline()); | Execute.runCommand(javah, cmd.getCommandline()); | ||||
return true; | return true; | ||||
} catch (BuildException e) { | } catch (BuildException e) { | ||||
if (e.getMessage().indexOf("failed with return code") == -1) { | |||||
if (!e.getMessage().contains("failed with return code")) { | |||||
throw e; | throw e; | ||||
} | } | ||||
} | } | ||||
@@ -245,9 +245,7 @@ public class jlink { | |||||
//entry from another mergefile was called "com". | //entry from another mergefile was called "com". | ||||
//In that case, just ignore the error and go on to the | //In that case, just ignore the error and go on to the | ||||
//next entry. | //next entry. | ||||
String mess = ex.getMessage(); | |||||
if (mess.indexOf("duplicate") >= 0) { | |||||
if (ex.getMessage().contains("duplicate")) { | |||||
//It was the duplicate entry. | //It was the duplicate entry. | ||||
continue; | continue; | ||||
} else { | } else { | ||||
@@ -1154,7 +1154,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
private static boolean filterLine(final String line) { | private static boolean filterLine(final String line) { | ||||
for (String filter : DEFAULT_TRACE_FILTERS) { | for (String filter : DEFAULT_TRACE_FILTERS) { | ||||
if (line.indexOf(filter) != -1) { | |||||
if (line.contains(filter)) { | |||||
return true; | return true; | ||||
} | } | ||||
} | } | ||||
@@ -2093,12 +2093,9 @@ public class FTP extends Task implements FTPTaskConfig { | |||||
if (!rc) { | if (!rc) { | ||||
log("Failed to issue Site Command: " + theCMD, Project.MSG_WARN); | log("Failed to issue Site Command: " + theCMD, Project.MSG_WARN); | ||||
} else { | } else { | ||||
myReply = ftp.getReplyStrings(); | |||||
for (int x = 0; x < myReply.length; x++) { | |||||
if (myReply[x] != null && myReply[x].indexOf("200") == -1) { | |||||
log(myReply[x], Project.MSG_WARN); | |||||
for (String reply : ftp.getReplyStrings()) { | |||||
if (reply != null && !reply.contains("200")) { | |||||
log(reply, Project.MSG_WARN); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -1480,12 +1480,9 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror { | |||||
if (!rc) { | if (!rc) { | ||||
task.log("Failed to issue Site Command: " + theCMD, Project.MSG_WARN); | task.log("Failed to issue Site Command: " + theCMD, Project.MSG_WARN); | ||||
} else { | } else { | ||||
myReply = ftp.getReplyStrings(); | |||||
for (int x = 0; x < myReply.length; x++) { | |||||
if (myReply[x].indexOf("200") == -1) { | |||||
task.log(myReply[x], Project.MSG_WARN); | |||||
for (String reply : ftp.getReplyStrings()) { | |||||
if (!reply.contains("200")) { | |||||
task.log(reply, Project.MSG_WARN); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -461,7 +461,7 @@ public class SSHExec extends SSHBase { | |||||
} catch (final BuildException e) { | } catch (final BuildException e) { | ||||
throw e; | throw e; | ||||
} catch (final JSchException e) { | } catch (final JSchException e) { | ||||
if (e.getMessage().indexOf("session is down") >= 0) { | |||||
if (e.getMessage().contains("session is down")) { | |||||
if (getFailonerror()) { | if (getFailonerror()) { | ||||
throw new BuildException(TIMEOUT_MESSAGE, e); | throw new BuildException(TIMEOUT_MESSAGE, e); | ||||
} else { | } else { | ||||
@@ -174,7 +174,7 @@ public class SSHSession extends SSHBase { | |||||
// completed successfully | // completed successfully | ||||
} catch (final JSchException e) { | } catch (final JSchException e) { | ||||
if (e.getMessage().indexOf("session is down") >= 0) { | |||||
if (e.getMessage().contains("session is down")) { | |||||
if (getFailonerror()) { | if (getFailonerror()) { | ||||
throw new BuildException(TIMEOUT_MESSAGE, e); | throw new BuildException(TIMEOUT_MESSAGE, e); | ||||
} else { | } else { | ||||
@@ -428,21 +428,19 @@ public class Commandline implements Cloneable { | |||||
* and double quotes. | * and double quotes. | ||||
*/ | */ | ||||
public static String quoteArgument(String argument) { | 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" | throw new BuildException("Can\'t handle single and double" | ||||
+ " quotes in same argument"); | + " quotes in same argument"); | ||||
} else { | |||||
return '\'' + argument + '\''; | |||||
} | } | ||||
} else if (argument.indexOf("\'") > -1 | |||||
|| argument.indexOf(" ") > -1 | |||||
// WIN9x uses a bat file for executing commands | |||||
|| (IS_WIN_9X && argument.indexOf(';') != -1)) { | |||||
return '\'' + argument + '\''; | |||||
} | |||||
if (argument.contains("\'") || argument.contains(" ") | |||||
// WIN9x uses a bat file for executing commands | |||||
|| (IS_WIN_9X && argument.contains(";"))) { | |||||
return '\"' + argument + '\"'; | return '\"' + argument + '\"'; | ||||
} else { | |||||
return argument; | |||||
} | } | ||||
return argument; | |||||
} | } | ||||
/** | /** | ||||
@@ -616,8 +616,7 @@ public class FilterSet extends DataType implements Cloneable { | |||||
} | } | ||||
passedTokens.addElement(parent); | passedTokens.addElement(parent); | ||||
String value = iReplaceTokens(line); | String value = iReplaceTokens(line); | ||||
if (value.indexOf(beginToken) == -1 && !duplicateToken | |||||
&& recurseDepth == 1) { | |||||
if (!value.contains(beginToken) && !duplicateToken && recurseDepth == 1) { | |||||
passedTokens = null; | passedTokens = null; | ||||
} else if (duplicateToken) { | } else if (duplicateToken) { | ||||
// should always be the case... | // should always be the case... | ||||
@@ -601,7 +601,7 @@ public class Path extends DataType implements Cloneable, ResourceCollection { | |||||
addExisting(systemBootClasspath); | 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? | // TODO is this code still necessary? is there any 1.2+ port? | ||||
// Pull in *.zip from packages directory | // Pull in *.zip from packages directory | ||||
FileSet msZipFiles = new FileSet(); | FileSet msZipFiles = new FileSet(); | ||||
@@ -765,8 +765,7 @@ public class Path extends DataType implements Cloneable, ResourceCollection { | |||||
* @since Ant 1.8.2 | * @since Ant 1.8.2 | ||||
*/ | */ | ||||
private static boolean containsWildcards(String path) { | private static boolean containsWildcards(String path) { | ||||
return path != null | |||||
&& (path.indexOf("*") > -1 || path.indexOf("?") > -1); | |||||
return path != null && (path.contains("*") || path.contains("?")); | |||||
} | } | ||||
} | } |
@@ -143,7 +143,7 @@ public class Name implements ResourceSelector { | |||||
} | } | ||||
private String modify(String s) { | private String modify(String s) { | ||||
if (s == null || !handleDirSep || s.indexOf("\\") == -1) { | |||||
if (s == null || !handleDirSep || !s.contains("\\")) { | |||||
return s; | return s; | ||||
} | } | ||||
return s.replace('\\', '/'); | return s.replace('\\', '/'); | ||||
@@ -204,7 +204,7 @@ public class ContainsSelector extends BaseExtendSelector implements ResourceSele | |||||
if (ignorewhitespace) { | if (ignorewhitespace) { | ||||
teststr = SelectorUtils.removeWhitespace(teststr); | teststr = SelectorUtils.removeWhitespace(teststr); | ||||
} | } | ||||
if (teststr.indexOf(userstr) > -1) { | |||||
if (teststr.contains(userstr)) { | |||||
return true; | return true; | ||||
} | } | ||||
teststr = in.readLine(); | teststr = in.readLine(); | ||||
@@ -118,7 +118,7 @@ public class RegexpPatternMapper implements FileNameMapper { | |||||
return null; | return null; | ||||
} | } | ||||
if (handleDirSep) { | if (handleDirSep) { | ||||
if (sourceFileName.indexOf("\\") != -1) { | |||||
if (sourceFileName.contains("\\")) { | |||||
sourceFileName = sourceFileName.replace('\\', '/'); | sourceFileName = sourceFileName.replace('\\', '/'); | ||||
} | } | ||||
} | } | ||||
@@ -1042,7 +1042,7 @@ public class TarEntry implements TarConstants { | |||||
fileName = fileName.substring(2); | fileName = fileName.substring(2); | ||||
} | } | ||||
} | } | ||||
} else if (osname.indexOf("netware") > -1) { | |||||
} else if (osname.contains("netware")) { | |||||
int colon = fileName.indexOf(':'); | int colon = fileName.indexOf(':'); | ||||
if (colon != -1) { | if (colon != -1) { | ||||
fileName = fileName.substring(colon + 1); | fileName = fileName.substring(colon + 1); | ||||
@@ -122,7 +122,7 @@ public abstract class BuildFileTest extends TestCase { | |||||
String realLog = getLog(); | String realLog = getLog(); | ||||
assertTrue("expecting log to contain \"" + substring + "\" log was \"" | assertTrue("expecting log to contain \"" + substring + "\" log was \"" | ||||
+ realLog + "\"", | + realLog + "\"", | ||||
realLog.indexOf(substring) >= 0); | |||||
realLog.contains(substring)); | |||||
} | } | ||||
/** | /** | ||||
@@ -134,7 +134,7 @@ public abstract class BuildFileTest extends TestCase { | |||||
String realLog = getLog(); | String realLog = getLog(); | ||||
assertFalse("didn't expect log to contain \"" + substring + "\" log was \"" | assertFalse("didn't expect log to contain \"" + substring + "\" log was \"" | ||||
+ realLog + "\"", | + realLog + "\"", | ||||
realLog.indexOf(substring) >= 0); | |||||
realLog.contains(substring)); | |||||
} | } | ||||
/** | /** | ||||
@@ -160,7 +160,7 @@ public abstract class BuildFileTest extends TestCase { | |||||
String realMessage = (message != null) | String realMessage = (message != null) | ||||
? message | ? message | ||||
: "expecting output to contain \"" + substring + "\" output was \"" + realOutput + "\""; | : "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) | String realMessage = (message != null) | ||||
? message | ? message | ||||
: "expecting output to not contain \"" + substring + "\" output was \"" + realOutput + "\""; | : "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 | assertTrue("expecting debug log to contain \"" + substring | ||||
+ "\" log was \"" | + "\" log was \"" | ||||
+ realLog + "\"", | + realLog + "\"", | ||||
realLog.indexOf(substring) >= 0); | |||||
realLog.contains(substring)); | |||||
} | } | ||||
/** | /** | ||||
@@ -425,8 +425,9 @@ public abstract class BuildFileTest extends TestCase { | |||||
executeTarget(target); | executeTarget(target); | ||||
} catch (org.apache.tools.ant.BuildException ex) { | } catch (org.apache.tools.ant.BuildException ex) { | ||||
buildException = ex; | buildException = ex; | ||||
if ((null != contains) && (ex.getMessage().indexOf(contains) == -1)) { | |||||
fail("Should throw BuildException because '" + cause + "' with message containing '" + contains + "' (actual message '" + ex.getMessage() + "' instead)"); | |||||
if (null != contains && !ex.getMessage().contains(contains)) { | |||||
fail("Should throw BuildException because '" + cause + "' with message containing '" | |||||
+ contains + "' (actual message '" + ex.getMessage() + "' instead)"); | |||||
} | } | ||||
return; | return; | ||||
} | } | ||||
@@ -70,18 +70,16 @@ public class LocationTest { | |||||
public void testMacrodefWrappedTask() { | public void testMacrodefWrappedTask() { | ||||
buildRule.executeTarget("testMacrodefWrappedTask"); | buildRule.executeTarget("testMacrodefWrappedTask"); | ||||
Echo e = (Echo) buildRule.getProject().getReference("echo3"); | 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 | @Test | ||||
public void testPresetdefWrappedTask() { | public void testPresetdefWrappedTask() { | ||||
buildRule.executeTarget("testPresetdefWrappedTask"); | buildRule.executeTarget("testPresetdefWrappedTask"); | ||||
Echo e = (Echo) buildRule.getProject().getReference("echo4"); | 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 { | public static class EchoLocation extends Task { | ||||
@@ -38,29 +38,29 @@ public class TaskContainerTest { | |||||
public void testPropertyExpansion() { | public void testPropertyExpansion() { | ||||
buildRule.executeTarget("testPropertyExpansion"); | buildRule.executeTarget("testPropertyExpansion"); | ||||
assertTrue("attribute worked", | assertTrue("attribute worked", | ||||
buildRule.getLog().indexOf("As attribute: it worked") > -1); | |||||
buildRule.getLog().contains("As attribute: it worked")); | |||||
assertTrue("nested text worked", | assertTrue("nested text worked", | ||||
buildRule.getLog().indexOf("As nested text: it worked") > -1); | |||||
buildRule.getLog().contains("As nested text: it worked")); | |||||
} | } | ||||
@Test | @Test | ||||
public void testTaskdef() { | public void testTaskdef() { | ||||
buildRule.executeTarget("testTaskdef"); | buildRule.executeTarget("testTaskdef"); | ||||
assertTrue("attribute worked", | assertTrue("attribute worked", | ||||
buildRule.getLog().indexOf("As attribute: it worked") > -1); | |||||
buildRule.getLog().contains("As attribute: it worked")); | |||||
assertTrue("nested text 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", | assertTrue("nested text worked", | ||||
buildRule.getLog().indexOf("As nested task: it worked") > -1); | |||||
buildRule.getLog().contains("As nested task: it worked")); | |||||
} | } | ||||
@Test | @Test | ||||
public void testCaseInsensitive() { | public void testCaseInsensitive() { | ||||
buildRule.executeTarget("testCaseInsensitive"); | buildRule.executeTarget("testCaseInsensitive"); | ||||
assertTrue("works outside of container", | assertTrue("works outside of container", | ||||
buildRule.getLog().indexOf("hello ") > -1); | |||||
buildRule.getLog().contains("hello ")); | |||||
assertTrue("works inside of container", | assertTrue("works inside of container", | ||||
buildRule.getLog().indexOf("world") > -1); | |||||
buildRule.getLog().contains("world")); | |||||
} | } | ||||
} | } |
@@ -318,9 +318,9 @@ public class AntTest { | |||||
@Test | @Test | ||||
public void testPropertySet() { | public void testPropertySet() { | ||||
buildRule.executeTarget("test-propertyset"); | 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 | @Test | ||||
@@ -199,7 +199,7 @@ public class ConcatTest { | |||||
@Test | @Test | ||||
public void testFilter() { | public void testFilter() { | ||||
buildRule.executeTarget("testfilter"); | buildRule.executeTarget("testfilter"); | ||||
assertTrue(buildRule.getLog().indexOf("REPLACED") > -1); | |||||
assertTrue(buildRule.getLog().contains("REPLACED")); | |||||
} | } | ||||
@Test | @Test | ||||
@@ -251,7 +251,7 @@ public class ConcatTest { | |||||
@Test | @Test | ||||
public void testfilterinline() { | public void testfilterinline() { | ||||
buildRule.executeTarget("testfilterinline"); | buildRule.executeTarget("testfilterinline"); | ||||
assertTrue(buildRule.getLog().indexOf("REPLACED") > -1); | |||||
assertTrue(buildRule.getLog().contains("REPLACED")); | |||||
} | } | ||||
/** | /** | ||||
@@ -260,8 +260,8 @@ public class ConcatTest { | |||||
@Test | @Test | ||||
public void testmultireader() { | public void testmultireader() { | ||||
buildRule.executeTarget("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 | * Check if fixlastline works | ||||
@@ -302,7 +302,7 @@ public class ConcatTest { | |||||
assertTrue( | assertTrue( | ||||
"expecting file " + filename + " to contain " + | "expecting file " + filename + " to contain " + | ||||
contains + | contains + | ||||
" but got " + content, content.indexOf(contains) > -1); | |||||
" but got " + content, content.contains(contains)); | |||||
} | } | ||||
} | } |
@@ -110,7 +110,7 @@ public class CopyTest { | |||||
@Test | @Test | ||||
public void testFilterTest() { | public void testFilterTest() { | ||||
buildRule.executeTarget("filtertest"); | buildRule.executeTarget("filtertest"); | ||||
assertTrue(buildRule.getLog().indexOf("loop in tokens") == -1); | |||||
assertTrue(!buildRule.getLog().contains("loop in tokens")); | |||||
} | } | ||||
@Test | @Test | ||||
@@ -344,33 +344,33 @@ public class JarTest { | |||||
@Test | @Test | ||||
public void testNoVersionInfoIgnore() { | public void testNoVersionInfoIgnore() { | ||||
buildRule.executeTarget("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 | @Test | ||||
public void testNoVersionInfoWarn() { | public void testNoVersionInfoWarn() { | ||||
buildRule.executeTarget("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 | @Test | ||||
public void testNoVersionInfoNoStrict() { | public void testNoVersionInfoNoStrict() { | ||||
buildRule.executeTarget("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 | @Test | ||||
public void testHasVersionInfo() { | public void testHasVersionInfo() { | ||||
buildRule.executeTarget("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.")); | |||||
} | } | ||||
} | } |
@@ -102,7 +102,7 @@ public class LoadFileTest { | |||||
@Test | @Test | ||||
public void testLoadAFile() throws BuildException { | public void testLoadAFile() throws BuildException { | ||||
buildRule.executeTarget("testLoadAFile"); | 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"); | fail("property is not all in the file"); | ||||
} | } | ||||
} | } | ||||
@@ -122,7 +122,7 @@ public class LoadFileTest { | |||||
@Test | @Test | ||||
public void testEvalProps() throws BuildException { | public void testEvalProps() throws BuildException { | ||||
buildRule.executeTarget("testEvalProps"); | buildRule.executeTarget("testEvalProps"); | ||||
if(buildRule.getProject().getProperty("testEvalProps").indexOf("rain")<0) { | |||||
if(!buildRule.getProject().getProperty("testEvalProps").contains("rain")) { | |||||
fail("property eval broken"); | fail("property eval broken"); | ||||
} | } | ||||
} | } | ||||
@@ -133,7 +133,7 @@ public class LoadFileTest { | |||||
@Test | @Test | ||||
public void testFilterChain() throws BuildException { | public void testFilterChain() throws BuildException { | ||||
buildRule.executeTarget("testFilterChain"); | buildRule.executeTarget("testFilterChain"); | ||||
if(buildRule.getProject().getProperty("testFilterChain").indexOf("World!")<0) { | |||||
if(!buildRule.getProject().getProperty("testFilterChain").contains("World!")) { | |||||
fail("Filter Chain broken"); | fail("Filter Chain broken"); | ||||
} | } | ||||
} | } | ||||
@@ -188,7 +188,7 @@ public class MacroDefTest { | |||||
try { | try { | ||||
buildRule.executeTarget("backtraceoff"); | buildRule.executeTarget("backtraceoff"); | ||||
} catch (BuildException ex) { | } 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()); | fail("error message contained backtrace - " + ex.getMessage()); | ||||
} | } | ||||
} | } | ||||
@@ -161,7 +161,7 @@ public class MakeUrlTest { | |||||
String result = getProperty(property); | String result = getProperty(property); | ||||
assertTrue("expected " + contains + " in " + result, | assertTrue("expected " + contains + " in " + result, | ||||
result != null && result.indexOf(contains) >= 0); | |||||
result != null && result.contains(contains)); | |||||
} | } | ||||
/** | /** | ||||
@@ -395,14 +395,14 @@ public class ManifestTest { | |||||
String mfAsString = mf.toString(); | String mfAsString = mf.toString(); | ||||
assertNotNull(mfAsString); | assertNotNull(mfAsString); | ||||
assertTrue(mfAsString.startsWith("Manifest-Version: 2.0")); | 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")); | mf = getManifest(new File(outDir, "mftest2.mf")); | ||||
assertNotNull(mf); | assertNotNull(mf); | ||||
mfAsString = mf.toString(); | mfAsString = mf.toString(); | ||||
assertNotNull(mfAsString); | assertNotNull(mfAsString); | ||||
assertEquals(-1, mfAsString.indexOf("Foo: Bar")); | assertEquals(-1, mfAsString.indexOf("Foo: Bar")); | ||||
assertTrue(mfAsString.indexOf("Foo: Baz") > -1); | |||||
assertTrue(mfAsString.contains("Foo: Baz")); | |||||
} | } | ||||
@Test | @Test | ||||
@@ -69,7 +69,7 @@ public class PropertyTest { | |||||
fail("Did not throw exception on circular exception"); | fail("Did not throw exception on circular exception"); | ||||
} catch (BuildException e) { | } catch (BuildException e) { | ||||
assertTrue("Circular definition not detected - ", | assertTrue("Circular definition not detected - ", | ||||
e.getMessage().indexOf("was circularly defined") != -1); | |||||
e.getMessage().contains("was circularly defined")); | |||||
} | } | ||||
} | } | ||||
@@ -465,7 +465,7 @@ public class RmicAdvancedTest { | |||||
buildRule.executeTarget(target); | buildRule.executeTarget(target); | ||||
fail("Target should have thrown a BuildException"); | fail("Target should have thrown a BuildException"); | ||||
} catch (BuildException ex) { | } catch (BuildException ex) { | ||||
if (target.indexOf("IDL") > -1) { | |||||
if (target.contains("IDL")) { | |||||
assertEquals("this rmic implementation doesn't support the -idl switch", ex.getMessage()); | assertEquals("this rmic implementation doesn't support the -idl switch", ex.getMessage()); | ||||
} else { | } else { | ||||
assertEquals("this rmic implementation doesn't support the -iiop switch", ex.getMessage()); | assertEquals("this rmic implementation doesn't support the -iiop switch", ex.getMessage()); | ||||
@@ -90,7 +90,7 @@ public class SQLExecTest { | |||||
try { | try { | ||||
sql.execute(); | sql.execute(); | ||||
} catch (BuildException e){ | } 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)); | assertTrue(JDBCTask.getLoaderMap().containsKey(NULL_DRIVER)); | ||||
assertSame(sql.getLoader(), JDBCTask.getLoaderMap().get(NULL_DRIVER)); | assertSame(sql.getLoader(), JDBCTask.getLoaderMap().get(NULL_DRIVER)); | ||||
@@ -232,7 +232,7 @@ public class StyleTest { | |||||
"expecting file " + filename | "expecting file " + filename | ||||
+ " to contain " + contains | + " to contain " + contains | ||||
+ " but got " + content, | + " but got " + content, | ||||
content.indexOf(contains) > -1); | |||||
content.contains(contains)); | |||||
} | } | ||||
} | } |
@@ -41,7 +41,7 @@ public class SyncTest { | |||||
buildRule.executeTarget("simplecopy"); | buildRule.executeTarget("simplecopy"); | ||||
String d = buildRule.getProject().getProperty("dest") + "/a/b/c/d"; | String d = buildRule.getProject().getProperty("dest") + "/a/b/c/d"; | ||||
assertFileIsPresent(d); | assertFileIsPresent(d); | ||||
assertTrue(buildRule.getFullLog().indexOf("dangling") == -1); | |||||
assertTrue(!buildRule.getFullLog().contains("dangling")); | |||||
} | } | ||||
@Test | @Test | ||||
@@ -51,7 +51,7 @@ public class SyncTest { | |||||
assertFileIsNotPresent(d); | assertFileIsNotPresent(d); | ||||
String c = buildRule.getProject().getProperty("dest") + "/a/b/c"; | String c = buildRule.getProject().getProperty("dest") + "/a/b/c"; | ||||
assertFileIsNotPresent(c); | assertFileIsNotPresent(c); | ||||
assertTrue(buildRule.getFullLog().indexOf("dangling") == -1); | |||||
assertTrue(!buildRule.getFullLog().contains("dangling")); | |||||
} | } | ||||
@Test | @Test | ||||
@@ -61,7 +61,7 @@ public class SyncTest { | |||||
assertFileIsNotPresent(d); | assertFileIsNotPresent(d); | ||||
String c = buildRule.getProject().getProperty("dest") + "/a/b/c"; | String c = buildRule.getProject().getProperty("dest") + "/a/b/c"; | ||||
assertFileIsPresent(c); | assertFileIsPresent(c); | ||||
assertTrue(buildRule.getFullLog().indexOf("dangling") == -1); | |||||
assertTrue(!buildRule.getFullLog().contains("dangling")); | |||||
} | } | ||||
@Test | @Test | ||||
@@ -85,7 +85,7 @@ public class SyncTest { | |||||
assertFileIsPresent(d); | assertFileIsPresent(d); | ||||
String f = buildRule.getProject().getProperty("dest") + "/e/f"; | String f = buildRule.getProject().getProperty("dest") + "/e/f"; | ||||
assertFileIsNotPresent(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 file from", buildRule.getFullLog()); | ||||
assertContains("Removed 1 dangling directory from", buildRule.getFullLog()); | assertContains("Removed 1 dangling directory from", buildRule.getFullLog()); | ||||
} | } | ||||
@@ -97,7 +97,7 @@ public class SyncTest { | |||||
assertFileIsPresent(d); | assertFileIsPresent(d); | ||||
String f = buildRule.getProject().getProperty("dest") + "/e/f"; | String f = buildRule.getProject().getProperty("dest") + "/e/f"; | ||||
assertFileIsNotPresent(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 file from", buildRule.getFullLog()); | ||||
assertContains("Removed 1 dangling directory from", buildRule.getFullLog()); | assertContains("Removed 1 dangling directory from", buildRule.getFullLog()); | ||||
} | } | ||||
@@ -111,7 +111,7 @@ public class SyncTest { | |||||
assertFileIsPresent(c); | assertFileIsPresent(c); | ||||
String f = buildRule.getProject().getProperty("dest") + "/e/f"; | String f = buildRule.getProject().getProperty("dest") + "/e/f"; | ||||
assertFileIsNotPresent(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("NO dangling file to remove from", buildRule.getFullLog()); | ||||
assertContains("Removed 2 dangling directories from", buildRule.getFullLog()); | assertContains("Removed 2 dangling directories from", buildRule.getFullLog()); | ||||
} | } | ||||
@@ -123,7 +123,7 @@ public class SyncTest { | |||||
assertFileIsPresent(d); | assertFileIsPresent(d); | ||||
String f = buildRule.getProject().getProperty("dest") + "/e/f"; | String f = buildRule.getProject().getProperty("dest") + "/e/f"; | ||||
assertFileIsPresent(f); | assertFileIsPresent(f); | ||||
assertTrue(buildRule.getFullLog().indexOf("Removing orphan file:") == -1); | |||||
assertTrue(!buildRule.getFullLog().contains("Removing orphan file:")); | |||||
} | } | ||||
@Test | @Test | ||||
@@ -133,7 +133,7 @@ public class SyncTest { | |||||
assertFileIsPresent(d); | assertFileIsPresent(d); | ||||
String f = buildRule.getProject().getProperty("dest") + "/e/f"; | String f = buildRule.getProject().getProperty("dest") + "/e/f"; | ||||
assertFileIsPresent(f); | assertFileIsPresent(f); | ||||
assertTrue(buildRule.getFullLog().indexOf("Removing orphan file:") == -1); | |||||
assertTrue(!buildRule.getFullLog().contains("Removing orphan file:")); | |||||
} | } | ||||
public void assertFileIsPresent(String f) { | public void assertFileIsPresent(String f) { | ||||
@@ -119,10 +119,10 @@ public class TaskdefTest { | |||||
buildRule.executeTarget("testOverride"); | buildRule.executeTarget("testOverride"); | ||||
String log = buildRule.getLog(); | String log = buildRule.getLog(); | ||||
assertTrue("override warning sent", | 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", | assertTrue("task inside target worked", | ||||
log.indexOf("In target") > -1); | |||||
log.contains("In target")); | |||||
assertTrue("task inside target worked", | assertTrue("task inside target worked", | ||||
log.indexOf("In TaskContainer") > -1); | |||||
log.contains("In TaskContainer")); | |||||
} | } | ||||
} | } |
@@ -131,7 +131,7 @@ public class EchoPropertiesTest { | |||||
try { | try { | ||||
String read = null; | String read = null; | ||||
while ((read = br.readLine()) != 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. | // found the property we set - it's good. | ||||
return; | return; | ||||
} | } | ||||
@@ -136,8 +136,7 @@ public class XmlValidateTest { | |||||
" doesn't support feature http://apache.org/xml/features/validation/schema")) { | " doesn't support feature http://apache.org/xml/features/validation/schema")) { | ||||
throw new AssumptionViolatedException("parser doesn't support schema"); | throw new AssumptionViolatedException("parser doesn't support schema"); | ||||
} else { | } else { | ||||
assertTrue( | |||||
e.getMessage().indexOf("not a valid XML document") > -1); | |||||
assertTrue(e.getMessage().contains("not a valid XML document")); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -77,7 +77,7 @@ public class XsltTest { | |||||
@Test | @Test | ||||
public void testStyleSheetWithInclude() throws Exception { | public void testStyleSheetWithInclude() throws Exception { | ||||
buildRule.executeTarget("testStyleSheetWithInclude"); | buildRule.executeTarget("testStyleSheetWithInclude"); | ||||
if (buildRule.getLog().indexOf("java.io.FileNotFoundException") != -1) { | |||||
if (buildRule.getLog().contains("java.io.FileNotFoundException")) { | |||||
fail("xsl:include was not found"); | fail("xsl:include was not found"); | ||||
} | } | ||||
} | } | ||||
@@ -112,7 +112,7 @@ public class ImageTest { | |||||
} catch (RuntimeException re){ | } catch (RuntimeException re){ | ||||
assertTrue("Run time exception should say 'Unable to process image stream'. :" | assertTrue("Run time exception should say 'Unable to process image stream'. :" | ||||
+ re.toString(), | + re.toString(), | ||||
re.toString().indexOf("Unable to process image stream") > -1); | |||||
re.toString().contains("Unable to process image stream")); | |||||
} | } | ||||
} | } | ||||
@@ -80,7 +80,7 @@ public class JUnitTestRunnerTest { | |||||
runner.run(); | runner.run(); | ||||
String error = runner.getFormatter().getError(); | String error = runner.getFormatter().getError(); | ||||
assertEquals(error, JUnitTestRunner.ERRORS, runner.getRetCode()); | 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 | // check that something which is not a testcase generates no errors | ||||
@@ -56,10 +56,10 @@ public class ScriptDefTest { | |||||
File baseDir = fileset.getDir(p); | File baseDir = fileset.getDir(p); | ||||
String log = buildRule.getLog(); | String log = buildRule.getLog(); | ||||
assertTrue("Expecting attribute value printed", | assertTrue("Expecting attribute value printed", | ||||
log.indexOf("Attribute attr1 = test") != -1); | |||||
log.contains("Attribute attr1 = test")); | |||||
assertTrue("Expecting nested element value printed", | assertTrue("Expecting nested element value printed", | ||||
log.indexOf("Fileset basedir = " + baseDir.getAbsolutePath()) != -1); | |||||
log.contains("Fileset basedir = " + baseDir.getAbsolutePath())); | |||||
} | } | ||||
@Test | @Test | ||||
@@ -91,10 +91,10 @@ public class ScriptDefTest { | |||||
File baseDir = fileset.getDir(p); | File baseDir = fileset.getDir(p); | ||||
String log = buildRule.getLog(); | String log = buildRule.getLog(); | ||||
assertTrue("Expecting attribute value to be printed", | 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", | assertTrue("Expecting nested element value to be printed", | ||||
log.indexOf("Fileset basedir = " + baseDir.getAbsolutePath()) != -1); | |||||
log.contains("Fileset basedir = " + baseDir.getAbsolutePath())); | |||||
} | } | ||||
@Test | @Test | ||||
@@ -117,8 +117,8 @@ public class ScriptDefTest { | |||||
public void testDoubleDef() { | public void testDoubleDef() { | ||||
buildRule.executeTarget("doubledef"); | buildRule.executeTarget("doubledef"); | ||||
String log = buildRule.getLog(); | 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 | @Test | ||||
@@ -137,7 +137,7 @@ public class ScriptDefTest { | |||||
// get the fileset and its basedir | // get the fileset and its basedir | ||||
String log = buildRule.getLog(); | String log = buildRule.getLog(); | ||||
assertTrue("Expecting property in attribute value replaced", | assertTrue("Expecting property in attribute value replaced", | ||||
log.indexOf("Attribute value = test") != -1); | |||||
log.contains("Attribute value = test")); | |||||
} | } | ||||
@@ -94,7 +94,7 @@ public class CommandlineJavaTest { | |||||
assertEquals("with classpath", "-Djava.compiler=NONE", s[1]); | assertEquals("with classpath", "-Djava.compiler=NONE", s[1]); | ||||
assertEquals("with classpath", "-classpath", s[2]); | assertEquals("with classpath", "-classpath", s[2]); | ||||
assertTrue("build.xml contained", | 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")); | assertTrue("ant.jar contained", s[3].endsWith("ant.jar")); | ||||
assertEquals("with classpath", "junit.textui.TestRunner", s[4]); | assertEquals("with classpath", "junit.textui.TestRunner", s[4]); | ||||
assertEquals("with classpath", | assertEquals("with classpath", | ||||
@@ -572,7 +572,7 @@ public class PathTest { | |||||
assertEquals(0, p.list().length); | assertEquals(0, p.list().length); | ||||
} catch (BuildException x) { | } catch (BuildException x) { | ||||
String m = x.toString(); | String m = x.toString(); | ||||
assertTrue(m, m.indexOf("circular") != -1); | |||||
assertTrue(m, m.contains("circular")); | |||||
} | } | ||||
} | } | ||||
@@ -73,7 +73,7 @@ public class RedirectorElementTest { | |||||
@Test | @Test | ||||
public void testLogInputString() { | public void testLogInputString() { | ||||
buildRule.executeTarget("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()); | AntAssert.assertContains("Using input string", buildRule.getFullLog()); | ||||
} | } | ||||
} | } | ||||
@@ -185,7 +185,7 @@ public class ModifiedSelectorTest { | |||||
assertNotNull("'fs.full.value' must be set.", fsFullValue); | assertNotNull("'fs.full.value' must be set.", fsFullValue); | ||||
assertTrue("'fs.full.value' must not be null.", !"".equals(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); | assertNotNull("'fs.mod.value' must be set.", fsModValue); | ||||
// must be empty according to the Mock* implementations | // must be empty according to the Mock* implementations | ||||
@@ -59,8 +59,8 @@ public class LayoutPreservingPropertiesTest { | |||||
// and now make sure that the comments made it into the new file | // and now make sure that the comments made it into the new file | ||||
String s = readFile(tmp); | 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,15 @@ public class LayoutPreservingPropertiesTest { | |||||
// and check that the resulting file looks okay | // and check that the resulting file looks okay | ||||
String s = readFile(tmp); | 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 +124,12 @@ public class LayoutPreservingPropertiesTest { | |||||
// and check that the resulting file looks okay | // and check that the resulting file looks okay | ||||
String s = readFile(tmp); | 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 | @Test | ||||
@@ -171,19 +169,13 @@ public class LayoutPreservingPropertiesTest { | |||||
// and check that the resulting file looks okay | // and check that the resulting file looks okay | ||||
String s = readFile(tmp); | String s = readFile(tmp); | ||||
assertTrue("should have had no properties ", | |||||
s.indexOf("prop.alpha") == -1); | |||||
assertTrue("should have had no properties ", | |||||
s.indexOf("prop.beta") == -1); | |||||
assertTrue("should have had no properties ", | |||||
s.indexOf("prop.gamma") == -1); | |||||
assertTrue("should have had no comments", | |||||
s.indexOf("# a comment") == -1); | |||||
assertTrue("should have had no comments", | |||||
s.indexOf("! more comment") == -1); | |||||
assertTrue("should have had no comments", | |||||
s.indexOf("# now a line wrapping one") == -1); | |||||
assertTrue("should have had no properties ", !s.contains("prop.alpha")); | |||||
assertTrue("should have had no properties ", !s.contains("prop.beta")); | |||||
assertTrue("should have had no properties ", !s.contains("prop.gamma")); | |||||
assertTrue("should have had no comments", !s.contains("# a comment")); | |||||
assertTrue("should have had no comments", !s.contains("! more comment")); | |||||
assertTrue("should have had no comments", !s.contains("# now a line wrapping one")); | |||||
} | } | ||||
@Test | @Test | ||||
@@ -203,10 +195,8 @@ public class LayoutPreservingPropertiesTest { | |||||
// and check that the resulting file looks okay | // and check that the resulting file looks okay | ||||
String s = readFile(tmp); | String s = readFile(tmp); | ||||
assertTrue("should not have had prop.beta", | |||||
s.indexOf("prop.beta") == -1); | |||||
assertTrue("should have had prop.beta's comment", | |||||
s.indexOf("! more comment") > -1); | |||||
assertTrue("should not have had prop.beta", !s.contains("prop.beta")); | |||||
assertTrue("should have had prop.beta's comment", s.contains("! more comment")); | |||||
} | } | ||||
@Test | @Test | ||||
@@ -228,10 +218,8 @@ public class LayoutPreservingPropertiesTest { | |||||
// and check that the resulting file looks okay | // and check that the resulting file looks okay | ||||
String s = readFile(tmp); | String s = readFile(tmp); | ||||
assertTrue("should not have had prop.beta", | |||||
s.indexOf("prop.beta") == -1); | |||||
assertTrue("should not have had prop.beta's comment", | |||||
s.indexOf("! more comment") == -1); | |||||
assertTrue("should not have had prop.beta", !s.contains("prop.beta")); | |||||
assertTrue("should not have had prop.beta's comment", !s.contains("! more comment")); | |||||
} | } | ||||
@Test | @Test | ||||
@@ -262,13 +250,13 @@ public class LayoutPreservingPropertiesTest { | |||||
String s2 = readFile(tmp2); | String s2 = readFile(tmp2); | ||||
// check original is untouched | // 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 | // check clone has the changes | ||||
assertTrue("should have had 'a new value for beta'", | 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 | @Test | ||||
@@ -293,16 +281,16 @@ public class LayoutPreservingPropertiesTest { | |||||
// and check that the resulting file looks okay | // and check that the resulting file looks okay | ||||
String s = readFile(tmp); | 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 { | private static String readFile(File f) throws IOException { | ||||