diff options
author | Lars Grefer <eclipse@larsgrefer.de> | 2020-08-08 03:11:12 +0200 |
---|---|---|
committer | Lars Grefer <eclipse@larsgrefer.de> | 2020-08-08 03:11:12 +0200 |
commit | c1c373f4278426308689db61f7758185e8f0401b (patch) | |
tree | 9e03af2feb69782c50464fc1e1e2ce0d6b6bb8c5 /weaver/src/test | |
parent | a508fd5315c6330f2057c219aebc35b15d0ea497 (diff) | |
download | aspectj-c1c373f4278426308689db61f7758185e8f0401b.tar.gz aspectj-c1c373f4278426308689db61f7758185e8f0401b.zip |
'String.indexOf()' expression is replaceable with 'contains()'
Reports any String.indexOf() expressions which can be replaced with a call to the String.contains() method available in Java 5 and newer.
Signed-off-by: Lars Grefer <eclipse@larsgrefer.de>
Diffstat (limited to 'weaver/src/test')
4 files changed, 7 insertions, 7 deletions
diff --git a/weaver/src/test/java/org/aspectj/weaver/DumpTestCase.java b/weaver/src/test/java/org/aspectj/weaver/DumpTestCase.java index 752473533..ba78b686b 100644 --- a/weaver/src/test/java/org/aspectj/weaver/DumpTestCase.java +++ b/weaver/src/test/java/org/aspectj/weaver/DumpTestCase.java @@ -122,7 +122,7 @@ public class DumpTestCase extends TestCase { String record; while ((null != (record = reader.readLine())) && (result == false)) { if (record.startsWith("----")) currentHeading = record; - else if ((record.indexOf(contents) != -1) && currentHeading.indexOf(heading) != -1) result = true; + else if ((record.contains(contents)) && currentHeading.contains(heading)) result = true; } reader.close(); } diff --git a/weaver/src/test/java/org/aspectj/weaver/patterns/AnnotationPatternMatchingTestCase.java b/weaver/src/test/java/org/aspectj/weaver/patterns/AnnotationPatternMatchingTestCase.java index 6852da6b7..8e84a71e5 100644 --- a/weaver/src/test/java/org/aspectj/weaver/patterns/AnnotationPatternMatchingTestCase.java +++ b/weaver/src/test/java/org/aspectj/weaver/patterns/AnnotationPatternMatchingTestCase.java @@ -125,7 +125,7 @@ public class AnnotationPatternMatchingTestCase extends TestCase { String expected = "Type referred to is not an annotation type"; String msg = ((IMessage) mh.messages.get(0)).toString(); - assertTrue("Expected: " + expected + " but got " + msg, msg.indexOf(expected) != -1); + assertTrue("Expected: " + expected + " but got " + msg, msg.contains(expected)); } public void testReferenceViaFormalToNonAnnotationType() { @@ -142,7 +142,7 @@ public class AnnotationPatternMatchingTestCase extends TestCase { String expected = "Type referred to is not an annotation type"; String msg = ((IMessage) mh.messages.get(0)).toString(); - assertTrue("Expected: " + expected + " but got " + msg, msg.indexOf(expected) != -1); + assertTrue("Expected: " + expected + " but got " + msg, msg.contains(expected)); // expected = "Binding not supported in @pcds (1.5.0 M1 limitation): null"; // msg = ((IMessage)mh.messages.get(1)).toString(); diff --git a/weaver/src/test/java/org/aspectj/weaver/tools/PointcutDesignatorHandlerTest.java b/weaver/src/test/java/org/aspectj/weaver/tools/PointcutDesignatorHandlerTest.java index ca9835c29..1ea33c465 100644 --- a/weaver/src/test/java/org/aspectj/weaver/tools/PointcutDesignatorHandlerTest.java +++ b/weaver/src/test/java/org/aspectj/weaver/tools/PointcutDesignatorHandlerTest.java @@ -47,7 +47,7 @@ public class PointcutDesignatorHandlerTest extends TestCase { .parsePointcutExpression("bean(service.*"); fail("should not be able to parse bean(service.*)"); } catch(IllegalArgumentException ex) { - assertTrue("contains bean",ex.getMessage().indexOf("bean") != -1); + assertTrue("contains bean", ex.getMessage().contains("bean")); } } diff --git a/weaver/src/test/java/org/aspectj/weaver/tools/PointcutParserTest.java b/weaver/src/test/java/org/aspectj/weaver/tools/PointcutParserTest.java index 9488a5e90..fbf4d3068 100644 --- a/weaver/src/test/java/org/aspectj/weaver/tools/PointcutParserTest.java +++ b/weaver/src/test/java/org/aspectj/weaver/tools/PointcutParserTest.java @@ -336,14 +336,14 @@ public class PointcutParserTest extends TestCase { pc = parser.parsePointcutExpression("args(String)", null, new PointcutParameter[] { param }); fail("Expecting IllegalArgumentException"); } catch (IllegalArgumentException ex) { - assertTrue("formal unbound", ex.getMessage().indexOf("formal unbound") != -1); + assertTrue("formal unbound", ex.getMessage().contains("formal unbound")); } try { pc = parser.parsePointcutExpression("args(y)"); fail("Expecting IllegalArgumentException"); } catch (IllegalArgumentException ex) { - assertTrue("no match for type name", ex.getMessage().indexOf("warning no match for this type name: y") != -1); + assertTrue("no match for type name", ex.getMessage().contains("warning no match for this type name: y")); } } @@ -357,7 +357,7 @@ public class PointcutParserTest extends TestCase { try { p.parsePointcutExpression("this(FooBar)"); } catch (IllegalArgumentException ex) { - assertTrue("should have xlint:invalidAbsoluteTypeName", ex.getMessage().indexOf("Xlint:invalidAbsoluteTypeName") != -1); + assertTrue("should have xlint:invalidAbsoluteTypeName", ex.getMessage().contains("Xlint:invalidAbsoluteTypeName")); } Properties props = new Properties(); props.put("invalidAbsoluteTypeName", "ignore"); |