Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Hammer2019-05-21 15:53:41 +0000
committerAlexander Kurtakov2019-06-10 16:45:00 +0000
commitfff24aab1c4598e4e9c20c35093ef1a27e546aa5 (patch)
tree8acb2a17df4aa8504f7f938edb9adbd0ff51b114 /bundles/org.eclipse.equinox.p2.tests/src/org
parenta0f5386e6c545e3a51c4daefc9b14c25f576d961 (diff)
downloadrt.equinox.p2-fff24aab1c4598e4e9c20c35093ef1a27e546aa5.tar.gz
rt.equinox.p2-fff24aab1c4598e4e9c20c35093ef1a27e546aa5.tar.xz
rt.equinox.p2-fff24aab1c4598e4e9c20c35093ef1a27e546aa5.zip
Replace usage of String.indexOf with String.contains where possible
Change-Id: I5cf1901c5b80a13bb09be0b73966c4709b954a59 Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de>
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.tests/src/org')
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/FileUtilsTest.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/jarprocessor/JarProcessorTests.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ANYConfigCUsActionTest.java12
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ConfigCUsActionTest.java12
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/AbstractSimpleConfiguratorTest.java2
6 files changed, 21 insertions, 21 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java
index d8790d442..37777c0a9 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java
@@ -1013,7 +1013,7 @@ public abstract class AbstractProvisioningTest extends TestCase {
URI[] urls = repoMan.getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL);
for (int i = 0; i < urls.length; i++) {
try {
- if (urls[i].toString().indexOf("cache") != -1 || urls[i].toString().indexOf("rollback") != -1)
+ if (urls[i].toString().contains("cache") || urls[i].toString().contains("rollback"))
repoMan.loadRepository(urls[i], null).removeAll();
} catch (ProvisionException e) {
//if the repository didn't load, then it doesn't exist and we don't need to clear it up
@@ -1504,7 +1504,7 @@ public abstract class AbstractProvisioningTest extends TestCase {
try (BufferedReader reader = new BufferedReader(new FileReader(log))) {
while (reader.ready()) {
String line = reader.readLine();
- if (line.indexOf(lines[idx]) >= 0) {
+ if (line.contains(lines[idx])) {
if (++idx >= lines.length) {
return;
}
@@ -1535,7 +1535,7 @@ public abstract class AbstractProvisioningTest extends TestCase {
try (BufferedReader reader = new BufferedReader(new FileReader(log))) {
while (reader.ready()) {
String line = reader.readLine();
- if (line.indexOf(lines[idx]) >= 0) {
+ if (line.contains(lines[idx])) {
if (++idx >= lines.length) {
fail(String.format("Log file %s contains lines %s", log.getCanonicalPath(), Arrays.toString(lines)));
}
@@ -1662,7 +1662,7 @@ public abstract class AbstractProvisioningTest extends TestCase {
try (BufferedReader reader = new BufferedReader(new FileReader(file));) {
while (reader.ready()) {
String line = reader.readLine();
- if (line.indexOf(lines[idx]) >= 0) {
+ if (line.contains(lines[idx])) {
if (++idx >= lines.length)
return;
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/FileUtilsTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/FileUtilsTest.java
index 48dfcff89..d5ceb7946 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/FileUtilsTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/FileUtilsTest.java
@@ -102,14 +102,14 @@ public class FileUtilsTest extends AbstractProvisioningTest {
FileUtils.unzipFile(badZip, temp);
} catch (IOException e) {
// expected
- assertTrue("Wrong message: " + e.getMessage(), e.getMessage().indexOf("Invalid path: ") >= 0);
+ assertTrue("Wrong message: " + e.getMessage(), e.getMessage().contains("Invalid path: "));
}
try {
Util.unzipFile(badZip, temp, null, null, null);
} catch (IOException e) {
// expected
- assertTrue("Wrong message: " + e.getMessage(), e.getMessage().indexOf("Invalid path: ") >= 0);
+ assertTrue("Wrong message: " + e.getMessage(), e.getMessage().contains("Invalid path: "));
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/jarprocessor/JarProcessorTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/jarprocessor/JarProcessorTests.java
index b2c3a4b39..af633cf60 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/jarprocessor/JarProcessorTests.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/jarprocessor/JarProcessorTests.java
@@ -47,7 +47,7 @@ public class JarProcessorTests extends AbstractProvisioningTest {
FileFilter filter = pathname -> {
String name = pathname.getName();
if (pathname.isFile() && name.endsWith(".jar"))
- if ((name.indexOf("source") == -1) && name.startsWith("org.eclipse.equinox.p2"))
+ if ((!name.contains("source")) && name.startsWith("org.eclipse.equinox.p2"))
return true;
return false;
};
@@ -91,7 +91,7 @@ public class JarProcessorTests extends AbstractProvisioningTest {
File plugins = new File(install, "plugins");
File[] files = plugins.listFiles((FileFilter) pathname -> {
String name = pathname.getName();
- if (pathname.isFile() && name.endsWith(".jar") && name.indexOf(".source") == -1) {
+ if (pathname.isFile() && name.endsWith(".jar") && !name.contains(".source")) {
if (name.startsWith("org.eclipse.core.c") || name.startsWith("org.eclipse.core.r"))
return true;
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ANYConfigCUsActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ANYConfigCUsActionTest.java
index 3bbf4f0e4..26c6fa490 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ANYConfigCUsActionTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ANYConfigCUsActionTest.java
@@ -177,9 +177,9 @@ public class ANYConfigCUsActionTest extends ActionTest {
ITouchpointData data = touchpointData.iterator().next();
ITouchpointInstruction instruction = data.getInstruction("configure"); //$NON-NLS-1$
String body = instruction.getBody();
- assertTrue("arg -foo bar", body.indexOf("addProgramArg(programArg:-foo bar);") > -1); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("vmarg -agentlib", body.indexOf("addJvmArg(jvmArg:-agentlib${#58}jdwp=transport=dt_socket${#44}server=y${#44}suspend=n${#44}address=8272);") > -1); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("arg -product com,ma", body.indexOf("addProgramArg(programArg:-product);addProgramArg(programArg:com${#44}ma);") > -1); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("arg -foo bar", body.contains("addProgramArg(programArg:-foo bar);")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("vmarg -agentlib", body.contains("addJvmArg(jvmArg:-agentlib${#58}jdwp=transport=dt_socket${#44}server=y${#44}suspend=n${#44}address=8272);")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("arg -product com,ma", body.contains("addProgramArg(programArg:-product);addProgramArg(programArg:com${#44}ma);")); //$NON-NLS-1$ //$NON-NLS-2$
}
private void verifyConfigProperties(IInstallableUnit iu) {
@@ -188,9 +188,9 @@ public class ANYConfigCUsActionTest extends ActionTest {
ITouchpointData data = touchpointData.iterator().next();
ITouchpointInstruction instruction = data.getInstruction("configure"); //$NON-NLS-1$
String body = instruction.getBody();
- assertTrue("eclipse.product", body.indexOf("setProgramProperty(propName:eclipse.product,propValue:org.eclipse.platform.ide);") > -1); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("eclipse.buildId", body.indexOf("setProgramProperty(propName:eclipse.buildId,propValue:TEST-ID);") > -1); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("my.property", body.indexOf("setProgramProperty(propName:my.property,propValue:${#123}a${#44}b${#58}c${#59}${#36}d${#125});") > -1); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("eclipse.product", body.contains("setProgramProperty(propName:eclipse.product,propValue:org.eclipse.platform.ide);")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("eclipse.buildId", body.contains("setProgramProperty(propName:eclipse.buildId,propValue:TEST-ID);")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("my.property", body.contains("setProgramProperty(propName:my.property,propValue:${#123}a${#44}b${#58}c${#59}${#36}d${#125});")); //$NON-NLS-1$ //$NON-NLS-2$
}
@Override
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ConfigCUsActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ConfigCUsActionTest.java
index 103613ec6..db4e09866 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ConfigCUsActionTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ConfigCUsActionTest.java
@@ -123,9 +123,9 @@ public class ConfigCUsActionTest extends ActionTest {
ITouchpointData data = touchpointData.iterator().next();
ITouchpointInstruction instruction = data.getInstruction("configure");
String body = instruction.getBody();
- assertTrue("arg -foo bar", body.indexOf("addProgramArg(programArg:-foo bar);") > -1);
- assertTrue("vmarg -agentlib", body.indexOf("addJvmArg(jvmArg:-agentlib${#58}jdwp=transport=dt_socket${#44}server=y${#44}suspend=n${#44}address=8272);") > -1);
- assertTrue("arg -product com,ma", body.indexOf("addProgramArg(programArg:-product);addProgramArg(programArg:com${#44}ma);") > -1);
+ assertTrue("arg -foo bar", body.contains("addProgramArg(programArg:-foo bar);"));
+ assertTrue("vmarg -agentlib", body.contains("addJvmArg(jvmArg:-agentlib${#58}jdwp=transport=dt_socket${#44}server=y${#44}suspend=n${#44}address=8272);"));
+ assertTrue("arg -product com,ma", body.contains("addProgramArg(programArg:-product);addProgramArg(programArg:com${#44}ma);"));
}
private void verifyConfigProperties(IInstallableUnit iu) {
@@ -134,9 +134,9 @@ public class ConfigCUsActionTest extends ActionTest {
ITouchpointData data = touchpointData.iterator().next();
ITouchpointInstruction instruction = data.getInstruction("configure");
String body = instruction.getBody();
- assertTrue("eclipse.product", body.indexOf("setProgramProperty(propName:eclipse.product,propValue:org.eclipse.platform.ide);") > -1);
- assertTrue("eclipse.buildId", body.indexOf("setProgramProperty(propName:eclipse.buildId,propValue:TEST-ID);") > -1);
- assertTrue("my.property", body.indexOf("setProgramProperty(propName:my.property,propValue:${#123}a${#44}b${#58}c${#59}${#36}d${#125});") > -1);
+ assertTrue("eclipse.product", body.contains("setProgramProperty(propName:eclipse.product,propValue:org.eclipse.platform.ide);"));
+ assertTrue("eclipse.buildId", body.contains("setProgramProperty(propName:eclipse.buildId,propValue:TEST-ID);"));
+ assertTrue("my.property", body.contains("setProgramProperty(propName:my.property,propValue:${#123}a${#44}b${#58}c${#59}${#36}d${#125});"));
}
@Override
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/AbstractSimpleConfiguratorTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/AbstractSimpleConfiguratorTest.java
index f560cd381..da868174c 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/AbstractSimpleConfiguratorTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/simpleconfigurator/AbstractSimpleConfiguratorTest.java
@@ -156,7 +156,7 @@ public abstract class AbstractSimpleConfiguratorTest extends AbstractProvisionin
value = bundleJar.getManifest().getMainAttributes().getValue(entry);
}
}
- if (value.indexOf(";") > -1) {
+ if (value.contains(";")) {
String[] valueElements = value.split(";");
return valueElements[0];
}

Back to the top