diff --git a/annotator-core/src/test/java/edu/ucr/cs/riple/core/AnalysisModeTest.java b/annotator-core/src/test/java/edu/ucr/cs/riple/core/AnalysisModeTest.java index afac04811..72163d777 100644 --- a/annotator-core/src/test/java/edu/ucr/cs/riple/core/AnalysisModeTest.java +++ b/annotator-core/src/test/java/edu/ucr/cs/riple/core/AnalysisModeTest.java @@ -49,14 +49,14 @@ public void strictModeTest() { .withDependency("Dep") .withSourceFile("Dep.java", "analysismode/Dep.java") .withExpectedReports( - // Resolves 6 errors locally and all errors on downstream dependencies can be resolved - // with no new triggered error, therefore the effect is -6. The fix triggers no error - // in downstream dependencies, should be approved. + // Resolves 6 errors locally, and all errors on downstream dependencies can be resolved + // with no new triggered error; therefore, the effect is -6. + // The fix triggers no error in downstream dependencies, should be approved. new TReport( new OnMethod("Foo.java", "test.target.Foo", "returnNullGood()"), -6, APPROVE), // Resolves 6 errors locally but creates 1 error on downstream dependencies that cannot - // be resolved, therefore the effect is -5. The fix triggers 1 error in downstream - // dependencies, should be rejected. + // be resolved; therefore, the effect is -5. + // The fix triggers 1 error in downstream dependencies, should be rejected. new TReport(new OnMethod("Foo.java", "test.target.Foo", "returnNullBad()"), -5, REJECT)) .setPredicate( (expected, found) -> @@ -105,8 +105,8 @@ public void upperBoundModeTest() { new TReport( new OnMethod("Foo.java", "test.target.Foo", "returnNullGood()"), -6, APPROVE), // Resolves 6 errors locally but creates 1 error on downstream dependencies that cannot - // be resolved, one of the triggered fixes in the tree, triggers an error in downstream - // dependency, the overall effect is -6 + 1 + 1 = -4 in upper bound mode. + // be resolved; one of the triggered fixes in the tree, triggers an error in downstream + // dependency; the overall effect is -6 + 1 + 1 = -4 in upper-bound mode. new TReport( new OnMethod("Foo.java", "test.target.Foo", "returnNullBad()"), -4, APPROVE)) .setPredicate( @@ -129,14 +129,14 @@ public void strictModeWithSuppressRemainingErrorsTest() { .withDependency("Dep") .withSourceFile("Dep.java", "analysismode/Dep.java") .withExpectedReports( - // Resolves 6 errors locally and all errors on downstream dependencies can be resolved - // with no new triggered error, therefore the effect is -6. The fix triggers no error - // in downstream dependencies, should be approved. + // Resolves 6 errors locally, and all errors on downstream dependencies can be resolved + // with no new triggered error; therefore, the effect is -6. + // The fix triggers no error in downstream dependencies, should be approved. new TReport( new OnMethod("Foo.java", "test.target.Foo", "returnNullGood()"), -6, APPROVE), // Resolves 6 errors locally but creates 1 error on downstream dependencies that cannot - // be resolved, therefore the effect is -5. The fix triggers 1 error in downstream - // dependencies, should be rejected. + // be resolved; therefore, the effect is -5. + // The fix triggers 1 error in downstream dependencies, should be rejected. new TReport(new OnMethod("Foo.java", "test.target.Foo", "returnNullBad()"), -5, REJECT)) .setPredicate( (expected, found) -> diff --git a/annotator-core/src/test/java/edu/ucr/cs/riple/core/AnnotatorBaseCoreTest.java b/annotator-core/src/test/java/edu/ucr/cs/riple/core/AnnotatorBaseCoreTest.java index 8e2ad5ff6..9f8577b00 100644 --- a/annotator-core/src/test/java/edu/ucr/cs/riple/core/AnnotatorBaseCoreTest.java +++ b/annotator-core/src/test/java/edu/ucr/cs/riple/core/AnnotatorBaseCoreTest.java @@ -31,12 +31,14 @@ import java.nio.file.Paths; import org.apache.commons.io.FileUtils; import org.junit.Before; +import org.junit.Ignore; import org.junit.Rule; import org.junit.rules.TemporaryFolder; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; /** Base class for all core tests. */ +@Ignore @RunWith(JUnit4.class) public abstract class AnnotatorBaseCoreTest { diff --git a/annotator-core/src/test/java/edu/ucr/cs/riple/core/ConfigurationTest.java b/annotator-core/src/test/java/edu/ucr/cs/riple/core/ConfigurationTest.java index 8f7eecc4e..0dd4e1018 100644 --- a/annotator-core/src/test/java/edu/ucr/cs/riple/core/ConfigurationTest.java +++ b/annotator-core/src/test/java/edu/ucr/cs/riple/core/ConfigurationTest.java @@ -75,7 +75,7 @@ public class ConfigurationTest { @Before public void init() { testDir = temporaryFolder.getRoot().toPath(); - // Make dummy config paths for 5 targets + // Make fake config paths for 5 targets try (OutputStream os = new FileOutputStream(testDir.resolve("paths.tsv").toFile())) { for (int i = 0; i < 5; i++) { String row = i + "nullaway.xml" + "\t" + i + "scanner.xml" + "\n"; @@ -303,9 +303,9 @@ private Config makeConfigWithFlags(List flags) { /** * Helper method for reading value of a node located at /key_1/key_2/.../key_n (in the form of - * {@code Xpath} query) from a xml document at the given path. + * {@code Xpath} query) from an XML document at the given path. * - * @param path Path to xml file. + * @param path Path to an XML file. * @param key Key to locate the value, can be nested in the form of {@code Xpath} query (e.g. * /key1/key2/.../key_n). * @return The value in the specified keychain as {@code String}. diff --git a/annotator-core/src/test/java/edu/ucr/cs/riple/core/CoreTest.java b/annotator-core/src/test/java/edu/ucr/cs/riple/core/CoreTest.java index 9ce6cc946..67325bc10 100644 --- a/annotator-core/src/test/java/edu/ucr/cs/riple/core/CoreTest.java +++ b/annotator-core/src/test/java/edu/ucr/cs/riple/core/CoreTest.java @@ -35,10 +35,7 @@ import java.util.Set; import org.junit.Assert; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -@RunWith(JUnit4.class) public class CoreTest extends AnnotatorBaseCoreTest { public CoreTest() { @@ -386,7 +383,7 @@ public void fieldNoInitialization() { // effect is -1 + 1 (triggered error on this.f = foo()) = 0. new OnMethod("A.java", "test.A", "foo()"), -2, - // adding @Nullable on f will resolve the triggered error by foo() and also resolves + // Adding @Nullable on f will resolve the triggered error by foo() and also resolves // the initialization error on A() as well. // Therefore, the combined effect is -1 + (-1) = -2. It resolves all existing // errors. diff --git a/annotator-core/src/test/java/edu/ucr/cs/riple/core/DeepTest.java b/annotator-core/src/test/java/edu/ucr/cs/riple/core/DeepTest.java index 2adf0d246..9d1655281 100644 --- a/annotator-core/src/test/java/edu/ucr/cs/riple/core/DeepTest.java +++ b/annotator-core/src/test/java/edu/ucr/cs/riple/core/DeepTest.java @@ -33,10 +33,7 @@ import edu.ucr.cs.riple.injector.location.OnParameter; import java.util.Collections; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -@RunWith(JUnit4.class) public class DeepTest extends AnnotatorBaseCoreTest { public DeepTest() { diff --git a/annotator-core/src/test/java/edu/ucr/cs/riple/core/DownstreamAnalysisTest.java b/annotator-core/src/test/java/edu/ucr/cs/riple/core/DownstreamAnalysisTest.java index 70d665501..d7e41300d 100644 --- a/annotator-core/src/test/java/edu/ucr/cs/riple/core/DownstreamAnalysisTest.java +++ b/annotator-core/src/test/java/edu/ucr/cs/riple/core/DownstreamAnalysisTest.java @@ -59,7 +59,7 @@ public void publicMethodWithDownstreamDependencyEnabled() { // DepA by 0, DepB by 1 and DepC by 0. Hence, the total effect is: -4. new TReport(new OnMethod("Foo.java", "test.target.Foo", "returnNullableGood(int)"), -4), // Change increases errors on target by 1, and also increases them in downstream - // dependency DepA by 1. Hence , the total effect is: 2. + // dependency DepA by 1.Hence, the total effect is: 2. new TReport(new OnMethod("Foo.java", "test.target.Foo", "bar()"), 2)) .setPredicate( (expected, found) -> @@ -108,21 +108,21 @@ public void publicFieldWithDownstreamDependencyEnabled() { .withSourceFile("DepC.java", "downstreamDependencyFieldCheck/DepC.java") .withExpectedReports( // Effect on target is -1, Effect on DepA is 0 and on DepB and DepC is 1 -> - // Lower bound is 2. And overall effect is -1 + 2 = 1. Effect is greater than 0 and - // triggers unresolved errors on downstream dependencies, hence the tree should be - // tagged as REJECT. + // Lower bound is 2. And overall effect is -1 + 2 = 1. + // The Effect is greater than 0 and triggers unresolved errors on downstream + // dependencies, hence the tree should be tagged as REJECT. new TReport(new OnField("Foo.java", "test.target.Foo", Set.of("f")), 1, REJECT), // Effect on target is -2. Root is on f1, but it triggers making f @Nullable as well. - // Fix tree containing both fixes resolves two errors leaving no remaining error, effect - // on target is -2. But f creates 2 errors on downstream dependencies, hence the lower - // bound is 2. Overall effect is -2 + 2 = 0. Since f creates unresolved errors on + // Fix a tree containing both fixes resolves two errors leaving no remaining error, + // effect on target is -2. But f creates 2 errors on downstream dependencies, hence the + // lower bound is 2. Overall effect is -2 + 2 = 0. Since f creates unresolved errors on // downstream dependencies, the tree should be tagged as REJECT even though the overall // effect is not greater than 0. new TReport(new OnField("Foo.java", "test.target.Foo", Set.of("f1")), 0, REJECT), // Effect on target is -1. Root is on f2, but it triggers making f3 @Nullable through an - // assignment in DepA and the tree is extended to include the corresponding fix. Since, + // assignment in DepA and the tree is extended to include the corresponding fix. Since // f2 creates a resolvable error in downstream dependencies that the corresponding fix - // is present in the fix tree, the lower bound effect is 0. Overall effect is -1 + 0 = + // is present in the fix tree, the lower-bound effect is 0. Overall effect is -1 + 0 = // -1. Since the overall effect is less than 0, with no error in downstream // dependencies, the tree should be tagged as APPROVE. new TReport(new OnField("Foo.java", "test.target.Foo", Set.of("f2")), -1, APPROVE)) @@ -158,8 +158,8 @@ public void lowerBoundComputationTest() { new TReport(new OnMethod("Foo.java", "test.target.Foo", "returnNullableBad(int)"), 10), // Only returnNullableGood triggers new errors in this fix chain (+1), lower bound is 1. new TReport(new OnMethod("Foo.java", "test.target.Foo", "returnNullableGood(int)"), 1), - // Root fix triggers 1 error on downstream dependency but returnNullableBad is - // present in the fix tree, therefore the lower bound effect for the tree should be 10. + // Root fix triggers 1 error on downstream dependency, but returnNullableBad is + // present in the fix tree, therefore, the lower-bound effect for the tree should be 10. new TReport(new OnMethod("Foo.java", "test.target.Foo", "bar()"), 10)) .setPredicate( (expected, found) -> @@ -191,8 +191,8 @@ public void upperBoundComputationTest() { // should be 1 new TReport(new OnMethod("Foo.java", "test.target.Foo", "returnNullableGood(int)"), 1), // Root fix triggers 1 error on downstream dependency and returnNullableBad is - // present in the fix tree and triggers 10 errors on downstream dependency, therefore - // the upper bound effect for the tree should be 11. + // present in the fix tree and triggers 10 errors on downstream dependency, therefore, + // the upper-bound effect for the tree should be 11. new TReport(new OnMethod("Foo.java", "test.target.Foo", "bar()"), 11)) .setPredicate( (expected, found) -> diff --git a/annotator-core/src/test/java/edu/ucr/cs/riple/core/LombokTest.java b/annotator-core/src/test/java/edu/ucr/cs/riple/core/LombokTest.java index a8d3385ff..3530d59e3 100644 --- a/annotator-core/src/test/java/edu/ucr/cs/riple/core/LombokTest.java +++ b/annotator-core/src/test/java/edu/ucr/cs/riple/core/LombokTest.java @@ -50,10 +50,10 @@ public void regionComputationOnFieldParallelProcessingEnables() { "class Main {", " Object f;", " public Object m1(){", - " return getF();", // Should be error + " return getF();", // Should be an error " }", " public Object m2(){", - " return getF();", // Should be error + " return getF();", // Should be an error " }", "}") .withExpectedReports( @@ -80,7 +80,7 @@ public void rejectOnFieldForGeneratedGetterInDownstreamDependencies() { "package test;", "class Dep {", " public Object returnNullable(){", - " return new Main().getF();", // Should be error + " return new Main().getF();", // Should be an error " }", "}") .withExpectedReports( @@ -88,7 +88,7 @@ public void rejectOnFieldForGeneratedGetterInDownstreamDependencies() { new OnField("Main.java", "test.Main", Collections.singleton("f")), 0, // The copied annotation on the getF creates an unresolvable error in downstream - // dependency, hence, the tree should be rejected. + // dependency; hence, the tree should be rejected. Report.Tag.REJECT)) .setPredicate( (expected, found) -> diff --git a/annotator-core/src/test/java/edu/ucr/cs/riple/core/NullableFlowToUpstreamTest.java b/annotator-core/src/test/java/edu/ucr/cs/riple/core/NullableFlowToUpstreamTest.java index f1e909f3b..cc6a70a4d 100644 --- a/annotator-core/src/test/java/edu/ucr/cs/riple/core/NullableFlowToUpstreamTest.java +++ b/annotator-core/src/test/java/edu/ucr/cs/riple/core/NullableFlowToUpstreamTest.java @@ -77,7 +77,7 @@ public void nullableFlowDetectionEnabledTest() { "Foo.java", "test.target.Foo", "bar1(java.lang.Object,java.lang.Object)")), Collections.emptySet()), // Change creates two errors on downstream dependencies (1 resolvable) and resolves one - // error locally, therefore the overall effect is 0. + // error locally; therefore, the overall effect is 0. new TReport( new OnMethod("Foo.java", "test.target.Foo", "getNull()"), 0, @@ -141,7 +141,6 @@ public void nullableFlowToUpstreamThroughFieldWriteTest() { new TReport( new OnField("Bar.java", "test.Bar", Set.of("foo")), -1, - // fixes in tree: Set.of( new OnMethod("Bar.java", "test.Bar", "getFoo(String)"), // coming from flow of nullable back to target through a field write. diff --git a/annotator-core/src/test/java/edu/ucr/cs/riple/core/OffsetChangeHandlingTest.java b/annotator-core/src/test/java/edu/ucr/cs/riple/core/OffsetChangeHandlingTest.java index d106d1a1a..2eddbb96e 100644 --- a/annotator-core/src/test/java/edu/ucr/cs/riple/core/OffsetChangeHandlingTest.java +++ b/annotator-core/src/test/java/edu/ucr/cs/riple/core/OffsetChangeHandlingTest.java @@ -212,7 +212,7 @@ private void removeAnnotationOn(String... fields) { .collect(Collectors.toSet())); } - /** Verifies if the calculated offsets matches the original offsets. */ + /** Verifies if the calculated offsets match the original offsets. */ private void verifyCalculatedOffsets() { try { String content = Files.readString(root.resolve("benchmark.java")); diff --git a/annotator-scanner/src/test/java/edu/ucr/cs/riple/scanner/AnnotatorScannerBaseTest.java b/annotator-scanner/src/test/java/edu/ucr/cs/riple/scanner/AnnotatorScannerBaseTest.java index bcb60ec19..ece28e78b 100644 --- a/annotator-scanner/src/test/java/edu/ucr/cs/riple/scanner/AnnotatorScannerBaseTest.java +++ b/annotator-scanner/src/test/java/edu/ucr/cs/riple/scanner/AnnotatorScannerBaseTest.java @@ -36,9 +36,14 @@ import java.nio.file.Paths; import java.util.Arrays; import org.junit.Before; +import org.junit.Ignore; import org.junit.Rule; import org.junit.rules.TemporaryFolder; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +@Ignore +@RunWith(JUnit4.class) public abstract class AnnotatorScannerBaseTest { @Rule public final TemporaryFolder temporaryFolder = new TemporaryFolder(); diff --git a/annotator-scanner/src/test/java/edu/ucr/cs/riple/scanner/ClassRecordTest.java b/annotator-scanner/src/test/java/edu/ucr/cs/riple/scanner/ClassRecordTest.java index d3332a3b1..b0869b620 100644 --- a/annotator-scanner/src/test/java/edu/ucr/cs/riple/scanner/ClassRecordTest.java +++ b/annotator-scanner/src/test/java/edu/ucr/cs/riple/scanner/ClassRecordTest.java @@ -28,10 +28,7 @@ import edu.ucr.cs.riple.scanner.tools.ClassRecordDisplay; import edu.ucr.cs.riple.scanner.tools.DisplayFactory; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -@RunWith(JUnit4.class) public class ClassRecordTest extends AnnotatorScannerBaseTest { private static final DisplayFactory CLASS_DISPLAY_FACTORY = @@ -59,7 +56,7 @@ public void basicTest() { } @Test - public void checkClassesAreWrittenInFlatName() { + public void checkClassesAreWrittenInFlatNameTest() { tester .addSourceFile("SampleClassForTest.java") .setExpectedOutputs( diff --git a/annotator-scanner/src/test/java/edu/ucr/cs/riple/scanner/ConfigurationTest.java b/annotator-scanner/src/test/java/edu/ucr/cs/riple/scanner/ConfigurationTest.java index 0fd5e7894..6714958bf 100644 --- a/annotator-scanner/src/test/java/edu/ucr/cs/riple/scanner/ConfigurationTest.java +++ b/annotator-scanner/src/test/java/edu/ucr/cs/riple/scanner/ConfigurationTest.java @@ -58,7 +58,7 @@ public class ConfigurationTest { @Rule public final TemporaryFolder temporaryFolder = new TemporaryFolder(); - // Just a dummy factory to run the tests with, tests will not even start with a null factory. + // Just a fake factory to run the tests with, tests will not even start with a null factory. protected DisplayFactory factory = values -> new ClassRecordDisplay("Unknown", "Unknown"); protected SerializationTestHelper tester; @@ -71,7 +71,7 @@ public void setup() { @Test public void checkExceptionIsThrownIfConfigPathNotSet() { - // -XepOpt:Scanner:ConfigPath is not set should expect an error. + // - XepOpt:Scanner:ConfigPath is not set should expect an error. tester = new SerializationTestHelper<>(root) .setArgs( diff --git a/annotator-scanner/src/test/java/edu/ucr/cs/riple/scanner/FieldImpactedRegionTest.java b/annotator-scanner/src/test/java/edu/ucr/cs/riple/scanner/FieldImpactedRegionTest.java index 968ea736e..64f27d61d 100644 --- a/annotator-scanner/src/test/java/edu/ucr/cs/riple/scanner/FieldImpactedRegionTest.java +++ b/annotator-scanner/src/test/java/edu/ucr/cs/riple/scanner/FieldImpactedRegionTest.java @@ -28,10 +28,7 @@ import edu.ucr.cs.riple.scanner.tools.DisplayFactory; import edu.ucr.cs.riple.scanner.tools.ImpactedRegionRecordDisplay; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -@RunWith(JUnit4.class) public class FieldImpactedRegionTest extends AnnotatorScannerBaseTest { private static final DisplayFactory FIELD_TRACKER_DISPLAY_FACTORY = @@ -57,7 +54,7 @@ public FieldImpactedRegionTest() { } @Test - public void BasicTest() { + public void basicTest() { tester .addSourceLines( "edu/ucr/A.java", @@ -146,7 +143,7 @@ public void fieldDeclaredRegionComputationAllCases() { } @Test - public void LombokGeneratedCodeDetectionTest() { + public void lombokGeneratedCodeDetectionTest() { tester .addSourceLines( "lombok/Generated.java", "package lombok;", "public @interface Generated { }") diff --git a/annotator-scanner/src/test/java/edu/ucr/cs/riple/scanner/MethodImpactedRegionTest.java b/annotator-scanner/src/test/java/edu/ucr/cs/riple/scanner/MethodImpactedRegionTest.java index f1f08501a..51fed5775 100644 --- a/annotator-scanner/src/test/java/edu/ucr/cs/riple/scanner/MethodImpactedRegionTest.java +++ b/annotator-scanner/src/test/java/edu/ucr/cs/riple/scanner/MethodImpactedRegionTest.java @@ -28,10 +28,7 @@ import edu.ucr.cs.riple.scanner.tools.DisplayFactory; import edu.ucr.cs.riple.scanner.tools.ImpactedRegionRecordDisplay; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -@RunWith(JUnit4.class) public class MethodImpactedRegionTest extends AnnotatorScannerBaseTest { @@ -58,7 +55,7 @@ public MethodImpactedRegionTest() { } @Test - public void BasicTest() { + public void basicTest() { tester .addSourceLines( "edu/ucr/A.java", @@ -104,7 +101,7 @@ public void constructorCallTest() { } @Test - public void methodReference() { + public void methodReferenceTest() { tester .addSourceLines( "edu/ucr/A.java", @@ -131,7 +128,7 @@ public void methodReference() { } @Test - public void lambda() { + public void lambdaTest() { tester .addSourceLines( "edu/ucr/A.java", diff --git a/annotator-scanner/src/test/java/edu/ucr/cs/riple/scanner/MethodRecordTest.java b/annotator-scanner/src/test/java/edu/ucr/cs/riple/scanner/MethodRecordTest.java index 5435eb950..a6749737e 100644 --- a/annotator-scanner/src/test/java/edu/ucr/cs/riple/scanner/MethodRecordTest.java +++ b/annotator-scanner/src/test/java/edu/ucr/cs/riple/scanner/MethodRecordTest.java @@ -29,10 +29,7 @@ import edu.ucr.cs.riple.scanner.tools.MethodRecordDisplay; import java.util.Arrays; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -@RunWith(JUnit4.class) public class MethodRecordTest extends AnnotatorScannerBaseTest { private static final DisplayFactory METHOD_DISPLAY_FACTORY = @@ -70,7 +67,7 @@ public MethodRecordTest() { } @Test - public void BasicTest() { + public void basicTest() { tester .addSourceLines( "edu/ucr/A.java", @@ -95,7 +92,7 @@ public void BasicTest() { } @Test - public void TestID() { + public void methodIDAssignmentTest() { tester .addSourceLines( "edu/ucr/A.java", @@ -262,7 +259,7 @@ public void visibilityAndReturnTypeTest() { } @Test - public void testLombokGeneratedAnnotationsOnMethod() { + public void lombokGeneratedAnnotationsOnMethodTest() { tester .addSourceLines( "lombok/Generated.java", "package lombok;", "public @interface Generated { }") @@ -293,7 +290,7 @@ public void testLombokGeneratedAnnotationsOnMethod() { } @Test - public void testTypeUseAnnotationSerialization() { + public void typeUseAnnotationSerializationTest() { tester .addSourceLines( // Exact copy of org.jspecify.annotations.Nullable diff --git a/injector/src/test/java/edu/ucr/cs/riple/injector/AnnotationWithArgumentTest.java b/injector/src/test/java/edu/ucr/cs/riple/injector/AnnotationWithArgumentTest.java index 075bbea47..2b7fba717 100644 --- a/injector/src/test/java/edu/ucr/cs/riple/injector/AnnotationWithArgumentTest.java +++ b/injector/src/test/java/edu/ucr/cs/riple/injector/AnnotationWithArgumentTest.java @@ -30,10 +30,7 @@ import edu.ucr.cs.riple.injector.location.OnParameter; import java.util.Collections; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -@RunWith(JUnit4.class) public class AnnotationWithArgumentTest extends BaseInjectorTest { @Test @@ -422,7 +419,7 @@ public void onFieldMultiLineSuppressWarningTest() { .expectOutput( "package com.edu;", "public class Super {", - // Google java format will convert annot below into multi line format if needed. + // Google java format will convert annot below into multi-line format if needed. " @SuppressWarnings({ \"InvalidThrowsLink\", \"MalformedInlineTag\", \"unchecked\", \"NullAway.Init\" })", " Object h = new Object();", " public void test(Object f) {", diff --git a/injector/src/test/java/edu/ucr/cs/riple/injector/BaseInjectorTest.java b/injector/src/test/java/edu/ucr/cs/riple/injector/BaseInjectorTest.java index b291f95cb..003faff2e 100644 --- a/injector/src/test/java/edu/ucr/cs/riple/injector/BaseInjectorTest.java +++ b/injector/src/test/java/edu/ucr/cs/riple/injector/BaseInjectorTest.java @@ -28,9 +28,14 @@ import java.nio.file.Path; import java.nio.file.Paths; import org.junit.Before; +import org.junit.Ignore; import org.junit.Rule; import org.junit.rules.TemporaryFolder; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +@Ignore +@RunWith(JUnit4.class) public class BaseInjectorTest { @Rule public final TemporaryFolder temporaryFolder = new TemporaryFolder(); diff --git a/injector/src/test/java/edu/ucr/cs/riple/injector/BasicTest.java b/injector/src/test/java/edu/ucr/cs/riple/injector/BasicTest.java index 772bb9cc5..8d004b3e5 100644 --- a/injector/src/test/java/edu/ucr/cs/riple/injector/BasicTest.java +++ b/injector/src/test/java/edu/ucr/cs/riple/injector/BasicTest.java @@ -28,10 +28,7 @@ import edu.ucr.cs.riple.injector.changes.AddMarkerAnnotation; import edu.ucr.cs.riple.injector.location.OnMethod; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -@RunWith(JUnit4.class) public class BasicTest extends BaseInjectorTest { @Test diff --git a/injector/src/test/java/edu/ucr/cs/riple/injector/ClassSearchTest.java b/injector/src/test/java/edu/ucr/cs/riple/injector/ClassSearchTest.java index 7e44871cc..868221349 100644 --- a/injector/src/test/java/edu/ucr/cs/riple/injector/ClassSearchTest.java +++ b/injector/src/test/java/edu/ucr/cs/riple/injector/ClassSearchTest.java @@ -39,10 +39,7 @@ import java.nio.charset.Charset; import java.util.Collections; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -@RunWith(JUnit4.class) public class ClassSearchTest extends BaseInjectorTest { @Test diff --git a/injector/src/test/java/edu/ucr/cs/riple/injector/ComprehensiveTest.java b/injector/src/test/java/edu/ucr/cs/riple/injector/ComprehensiveTest.java index 30f46c58f..74aba77df 100644 --- a/injector/src/test/java/edu/ucr/cs/riple/injector/ComprehensiveTest.java +++ b/injector/src/test/java/edu/ucr/cs/riple/injector/ComprehensiveTest.java @@ -32,10 +32,7 @@ import edu.ucr.cs.riple.injector.location.OnMethod; import edu.ucr.cs.riple.injector.location.OnParameter; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -@RunWith(JUnit4.class) public class ComprehensiveTest extends BaseInjectorTest { @Test diff --git a/injector/src/test/java/edu/ucr/cs/riple/injector/ImportDeclarationAdditionTest.java b/injector/src/test/java/edu/ucr/cs/riple/injector/ImportDeclarationAdditionTest.java index 5d3bb513e..484699433 100644 --- a/injector/src/test/java/edu/ucr/cs/riple/injector/ImportDeclarationAdditionTest.java +++ b/injector/src/test/java/edu/ucr/cs/riple/injector/ImportDeclarationAdditionTest.java @@ -29,10 +29,7 @@ import edu.ucr.cs.riple.injector.location.OnMethod; import java.util.Collections; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -@RunWith(JUnit4.class) public class ImportDeclarationAdditionTest extends BaseInjectorTest { @Test @@ -72,7 +69,7 @@ public void customNullableExists() { @Test public void customEndingWithNullableExists() { // Custom annot ending with Nullable exists, the import declaration should be added since we - // only skip if the simple name is exactly is Nullable. + // only skip if the simple name is exactly Nullable. injectorTestHelper .addInput( "Main.java", diff --git a/injector/src/test/java/edu/ucr/cs/riple/injector/LexicalPreservationTest.java b/injector/src/test/java/edu/ucr/cs/riple/injector/LexicalPreservationTest.java index 387a3b7f2..641d02dea 100644 --- a/injector/src/test/java/edu/ucr/cs/riple/injector/LexicalPreservationTest.java +++ b/injector/src/test/java/edu/ucr/cs/riple/injector/LexicalPreservationTest.java @@ -29,11 +29,9 @@ import edu.ucr.cs.riple.injector.location.OnMethod; import java.util.Collections; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -@RunWith(JUnit4.class) public class LexicalPreservationTest extends BaseInjectorTest { + @Test public void saveImports() { injectorTestHelper diff --git a/injector/src/test/java/edu/ucr/cs/riple/injector/OnClassDeclarationInjectionTest.java b/injector/src/test/java/edu/ucr/cs/riple/injector/OnClassDeclarationInjectionTest.java index 87d1e021e..6751b3457 100644 --- a/injector/src/test/java/edu/ucr/cs/riple/injector/OnClassDeclarationInjectionTest.java +++ b/injector/src/test/java/edu/ucr/cs/riple/injector/OnClassDeclarationInjectionTest.java @@ -29,10 +29,7 @@ import edu.ucr.cs.riple.injector.changes.RemoveTypeUseMarkerAnnotation; import edu.ucr.cs.riple.injector.location.OnClassDeclaration; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -@RunWith(JUnit4.class) public class OnClassDeclarationInjectionTest extends BaseInjectorTest { @Test diff --git a/injector/src/test/java/edu/ucr/cs/riple/injector/OnClassInjectionTest.java b/injector/src/test/java/edu/ucr/cs/riple/injector/OnClassInjectionTest.java index 5b6a16789..8828097df 100644 --- a/injector/src/test/java/edu/ucr/cs/riple/injector/OnClassInjectionTest.java +++ b/injector/src/test/java/edu/ucr/cs/riple/injector/OnClassInjectionTest.java @@ -27,10 +27,7 @@ import edu.ucr.cs.riple.injector.changes.AddMarkerAnnotation; import edu.ucr.cs.riple.injector.location.OnClass; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -@RunWith(JUnit4.class) public class OnClassInjectionTest extends BaseInjectorTest { @Test diff --git a/injector/src/test/java/edu/ucr/cs/riple/injector/OnFieldInjectionTest.java b/injector/src/test/java/edu/ucr/cs/riple/injector/OnFieldInjectionTest.java index c4f3d959d..eac40e475 100644 --- a/injector/src/test/java/edu/ucr/cs/riple/injector/OnFieldInjectionTest.java +++ b/injector/src/test/java/edu/ucr/cs/riple/injector/OnFieldInjectionTest.java @@ -28,11 +28,9 @@ import edu.ucr.cs.riple.injector.location.OnField; import java.util.Collections; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -@RunWith(JUnit4.class) public class OnFieldInjectionTest extends BaseInjectorTest { + @Test public void fieldNullableSimple() { injectorTestHelper diff --git a/injector/src/test/java/edu/ucr/cs/riple/injector/OnLocalVariableInjectionTest.java b/injector/src/test/java/edu/ucr/cs/riple/injector/OnLocalVariableInjectionTest.java index 08ef807d8..3ec6632f7 100644 --- a/injector/src/test/java/edu/ucr/cs/riple/injector/OnLocalVariableInjectionTest.java +++ b/injector/src/test/java/edu/ucr/cs/riple/injector/OnLocalVariableInjectionTest.java @@ -28,10 +28,7 @@ import edu.ucr.cs.riple.injector.changes.RemoveMarkerAnnotation; import edu.ucr.cs.riple.injector.location.OnLocalVariable; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -@RunWith(JUnit4.class) public class OnLocalVariableInjectionTest extends BaseInjectorTest { @Test diff --git a/injector/src/test/java/edu/ucr/cs/riple/injector/OnMethodInjectionTest.java b/injector/src/test/java/edu/ucr/cs/riple/injector/OnMethodInjectionTest.java index 775404013..e4dbfe8d3 100644 --- a/injector/src/test/java/edu/ucr/cs/riple/injector/OnMethodInjectionTest.java +++ b/injector/src/test/java/edu/ucr/cs/riple/injector/OnMethodInjectionTest.java @@ -28,10 +28,7 @@ import edu.ucr.cs.riple.injector.location.OnMethod; import edu.ucr.cs.riple.injector.location.OnParameter; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -@RunWith(JUnit4.class) public class OnMethodInjectionTest extends BaseInjectorTest { @Test diff --git a/injector/src/test/java/edu/ucr/cs/riple/injector/OnMethodSearchTest.java b/injector/src/test/java/edu/ucr/cs/riple/injector/OnMethodSearchTest.java index dbb64e566..2d9d35b21 100644 --- a/injector/src/test/java/edu/ucr/cs/riple/injector/OnMethodSearchTest.java +++ b/injector/src/test/java/edu/ucr/cs/riple/injector/OnMethodSearchTest.java @@ -27,11 +27,9 @@ import edu.ucr.cs.riple.injector.changes.AddMarkerAnnotation; import edu.ucr.cs.riple.injector.location.OnMethod; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -@RunWith(JUnit4.class) public class OnMethodSearchTest extends BaseInjectorTest { + @Test public void initializerConstructor() { injectorTestHelper diff --git a/injector/src/test/java/edu/ucr/cs/riple/injector/OnParameterInjectionTest.java b/injector/src/test/java/edu/ucr/cs/riple/injector/OnParameterInjectionTest.java index 8acf267b1..b6b55aea3 100644 --- a/injector/src/test/java/edu/ucr/cs/riple/injector/OnParameterInjectionTest.java +++ b/injector/src/test/java/edu/ucr/cs/riple/injector/OnParameterInjectionTest.java @@ -28,11 +28,9 @@ import edu.ucr.cs.riple.injector.changes.RemoveMarkerAnnotation; import edu.ucr.cs.riple.injector.location.OnParameter; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -@RunWith(JUnit4.class) public class OnParameterInjectionTest extends BaseInjectorTest { + @Test public void parameterNullableSimple() { injectorTestHelper diff --git a/injector/src/test/java/edu/ucr/cs/riple/injector/RemovalTest.java b/injector/src/test/java/edu/ucr/cs/riple/injector/RemovalTest.java index 8b1ff2059..3158f5621 100644 --- a/injector/src/test/java/edu/ucr/cs/riple/injector/RemovalTest.java +++ b/injector/src/test/java/edu/ucr/cs/riple/injector/RemovalTest.java @@ -32,10 +32,7 @@ import edu.ucr.cs.riple.injector.location.OnParameter; import java.util.Collections; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -@RunWith(JUnit4.class) public class RemovalTest extends BaseInjectorTest { @Test diff --git a/injector/src/test/java/edu/ucr/cs/riple/injector/TypeUseAnnotationTest.java b/injector/src/test/java/edu/ucr/cs/riple/injector/TypeUseAnnotationTest.java index fe1fb7997..7f5d3cf69 100644 --- a/injector/src/test/java/edu/ucr/cs/riple/injector/TypeUseAnnotationTest.java +++ b/injector/src/test/java/edu/ucr/cs/riple/injector/TypeUseAnnotationTest.java @@ -919,4 +919,40 @@ public void nullableArrayDeletionOnComponentType() { ImmutableList.of(ImmutableList.of(0), ImmutableList.of(1, 1, 0)))) .start(); } + + @Test + public void onArrayTypeDuplicateTest() { + injectorTestHelper + .addInput( + "Foo.java", + "package test;", + "import custom.example.Untainted;", + "public class Foo {", + " void baz(java.lang.Object param) {", + " final java.lang.String@RUntainted [] localVar = content.split(\"\\n\");", + " }", + "}") + .expectOutput( + "package test;", + "import custom.example.Untainted;", + "public class Foo {", + " void baz(java.lang.Object param) {", + " final java.lang.String@RUntainted [] localVar = content.split(\"\\n\");", + " }", + "}") + .addChanges( + new AddTypeUseMarkerAnnotation( + new OnLocalVariable("Foo.java", "test.Foo", "baz(java.lang.Object)", "localVar"), + "custom.example.RUntainted"), + new AddTypeUseMarkerAnnotation( + new OnLocalVariable("Foo.java", "test.Foo", "baz(java.lang.Object)", "localVar"), + "custom.example.RUntainted"), + new AddTypeUseMarkerAnnotation( + new OnLocalVariable("Foo.java", "test.Foo", "baz(java.lang.Object)", "localVar"), + "custom.example.RUntainted"), + new AddTypeUseMarkerAnnotation( + new OnLocalVariable("Foo.java", "test.Foo", "baz(java.lang.Object)", "localVar"), + "custom.example.RUntainted")) + .start(); + } } diff --git a/injector/src/test/java/edu/ucr/cs/riple/injector/tools/InjectorTestHelper.java b/injector/src/test/java/edu/ucr/cs/riple/injector/tools/InjectorTestHelper.java index 5482228df..27b6d8242 100644 --- a/injector/src/test/java/edu/ucr/cs/riple/injector/tools/InjectorTestHelper.java +++ b/injector/src/test/java/edu/ucr/cs/riple/injector/tools/InjectorTestHelper.java @@ -40,6 +40,7 @@ import org.apache.commons.io.FileUtils; public class InjectorTestHelper { + private final List changes; private final List files; private final Path rootPath;