aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndy Clement <aclement@pivotal.io>2018-04-18 13:15:22 -0700
committerAndy Clement <aclement@pivotal.io>2018-04-18 13:15:22 -0700
commit836beab108ef4be8b59c1ad9c8596ce959bdf1c7 (patch)
tree9346f87088aceecb16fad6f3b70753235051f504 /tests
parentb2cb18ef127097ad2c258b9d061cc70b5fb19432 (diff)
downloadaspectj-836beab108ef4be8b59c1ad9c8596ce959bdf1c7.tar.gz
aspectj-836beab108ef4be8b59c1ad9c8596ce959bdf1c7.zip
Support Java10
Diffstat (limited to 'tests')
-rw-r--r--tests/bugs191/var/Code1.java6
-rw-r--r--tests/bugs191/var/Code2.java11
-rw-r--r--tests/bugs191/var/Code3.java12
-rw-r--r--tests/src/org/aspectj/systemtest/ajc164/Ajc164Tests.java20
-rw-r--r--tests/src/org/aspectj/systemtest/ajc165/Ajc165Tests.java8
-rw-r--r--tests/src/org/aspectj/systemtest/ajc171/NewFeatures.java6
-rw-r--r--tests/src/org/aspectj/systemtest/ajc191/Ajc191Tests.java48
-rw-r--r--tests/src/org/aspectj/systemtest/ajc191/AllTestsAspectJ191.java25
-rw-r--r--tests/src/org/aspectj/systemtest/ajc191/ajc191.xml36
-rw-r--r--tests/src/org/aspectj/systemtest/incremental/tools/IncrementalPerformanceTests.java4
-rw-r--r--tests/src/org/aspectj/systemtest/incremental/tools/MoreOutputLocationManagerTests.java14
11 files changed, 173 insertions, 17 deletions
diff --git a/tests/bugs191/var/Code1.java b/tests/bugs191/var/Code1.java
new file mode 100644
index 000000000..58f93d1ba
--- /dev/null
+++ b/tests/bugs191/var/Code1.java
@@ -0,0 +1,6 @@
+public class Code1 {
+ public static void main(String []argv) {
+ var x = "hello";
+ System.out.println(x.getClass());
+ }
+}
diff --git a/tests/bugs191/var/Code2.java b/tests/bugs191/var/Code2.java
new file mode 100644
index 000000000..7f8ba93b6
--- /dev/null
+++ b/tests/bugs191/var/Code2.java
@@ -0,0 +1,11 @@
+import java.util.*;
+public class Code2 {
+ public static void main(String []argv) {
+ foo(new ArrayList<String>());
+ }
+
+ public static void foo(ArrayList<String> als) {
+ var aly = als;
+ System.out.println(aly.getClass());
+ }
+}
diff --git a/tests/bugs191/var/Code3.java b/tests/bugs191/var/Code3.java
new file mode 100644
index 000000000..f2494bc6d
--- /dev/null
+++ b/tests/bugs191/var/Code3.java
@@ -0,0 +1,12 @@
+public class Code3 {
+ public static void main(String []argv) {
+ var x = "hello";
+ System.out.println(x.getClass());
+ }
+}
+
+aspect X {
+ before(): call(* *.getClass()) && target(String) {
+ System.out.println(thisJoinPointStaticPart);
+ }
+}
diff --git a/tests/src/org/aspectj/systemtest/ajc164/Ajc164Tests.java b/tests/src/org/aspectj/systemtest/ajc164/Ajc164Tests.java
index 58de6b447..866fbb729 100644
--- a/tests/src/org/aspectj/systemtest/ajc164/Ajc164Tests.java
+++ b/tests/src/org/aspectj/systemtest/ajc164/Ajc164Tests.java
@@ -15,9 +15,6 @@ import java.io.PrintWriter;
import java.util.Iterator;
import java.util.List;
-import junit.framework.Test;
-
-import org.aspectj.apache.bcel.classfile.JavaClass;
import org.aspectj.apache.bcel.classfile.LocalVariable;
import org.aspectj.apache.bcel.classfile.LocalVariableTable;
import org.aspectj.apache.bcel.classfile.Method;
@@ -27,6 +24,8 @@ import org.aspectj.asm.IProgramElement;
import org.aspectj.asm.IRelationship;
import org.aspectj.testing.XMLBasedAjcTestCase;
+import junit.framework.Test;
+
public class Ajc164Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
public void testGenericAspectsNpe_pr268689() {
@@ -116,14 +115,14 @@ public class Ajc164Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
// assertEquals("/binaries<{Aspect.java}Aspect)Fruit.Fruit_new)QColor;)QString;", itdCtorHandle);
assertEquals("/binaries<(Aspect.class'Aspect)Fruit.Fruit_new)QColor;)QString;", itdCtorHandle);
IProgramElement itdcpe = model.getHierarchy().findElementForHandle(itdCtorHandle);
- List ptypes = itdcpe.getParameterTypes();
- assertEquals("java.awt.Color", new String((char[]) ptypes.get(0)));
- assertEquals("java.lang.String", new String((char[]) ptypes.get(1)));
+ List<char[]> ptypes = itdcpe.getParameterTypes();
+ assertEquals("java.awt.Color", new String(ptypes.get(0)));
+ assertEquals("java.lang.String", new String(ptypes.get(1)));
}
private void printModel(AsmManager model) {
try {
- model.dumptree(model.getHierarchy().getRoot(), 0);
+ AsmManager.dumptree(model.getHierarchy().getRoot(), 0);
model.dumprels(new PrintWriter(System.out));
} catch (Exception e) {
}
@@ -416,6 +415,7 @@ public class Ajc164Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
return XMLBasedAjcTestCase.loadSuite(Ajc164Tests.class);
}
+ @Override
protected File getSpecFile() {
return getClassResource("ajc164.xml");
}
@@ -427,9 +427,9 @@ public class Ajc164Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
if (whereToLook.getSourceLocation() != null && whereToLook.getSourceLocation().getLine() == line) {
return whereToLook;
}
- List kids = whereToLook.getChildren();
- for (Iterator iterator = kids.iterator(); iterator.hasNext();) {
- IProgramElement object = (IProgramElement) iterator.next();
+ List<IProgramElement> kids = whereToLook.getChildren();
+ for (Iterator<IProgramElement> iterator = kids.iterator(); iterator.hasNext();) {
+ IProgramElement object = iterator.next();
if (object.getSourceLocation() != null && object.getSourceLocation().getLine() == line) {
return object;
}
diff --git a/tests/src/org/aspectj/systemtest/ajc165/Ajc165Tests.java b/tests/src/org/aspectj/systemtest/ajc165/Ajc165Tests.java
index 441e0b4e6..196e07ca1 100644
--- a/tests/src/org/aspectj/systemtest/ajc165/Ajc165Tests.java
+++ b/tests/src/org/aspectj/systemtest/ajc165/Ajc165Tests.java
@@ -13,11 +13,12 @@ package org.aspectj.systemtest.ajc165;
import java.io.File;
import java.util.List;
-import junit.framework.Test;
-
+import org.aspectj.bridge.IMessage;
import org.aspectj.testing.XMLBasedAjcTestCase;
import org.aspectj.weaver.LintMessage;
+import junit.framework.Test;
+
public class Ajc165Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
// fix is too disruptive for 1.6.5
@@ -82,7 +83,7 @@ public class Ajc165Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
public void testAnnotationStyle_pr265356() {
runTest("annotation style message positions");
- List ms = ajc.getLastCompilationResult().getWarningMessages();
+ List<IMessage> ms = ajc.getLastCompilationResult().getWarningMessages();
boolean checked = true;
// Look for the message relating to 'List' and check the offsets
for (int i = 0; i < ms.size(); i++) {
@@ -115,6 +116,7 @@ public class Ajc165Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
return XMLBasedAjcTestCase.loadSuite(Ajc165Tests.class);
}
+ @Override
protected File getSpecFile() {
return getClassResource("ajc165.xml");
}
diff --git a/tests/src/org/aspectj/systemtest/ajc171/NewFeatures.java b/tests/src/org/aspectj/systemtest/ajc171/NewFeatures.java
index 79d1a4669..6a713e930 100644
--- a/tests/src/org/aspectj/systemtest/ajc171/NewFeatures.java
+++ b/tests/src/org/aspectj/systemtest/ajc171/NewFeatures.java
@@ -12,11 +12,11 @@ package org.aspectj.systemtest.ajc171;
import java.io.File;
-import junit.framework.Test;
-
import org.aspectj.apache.bcel.classfile.JavaClass;
import org.aspectj.testing.XMLBasedAjcTestCase;
+import junit.framework.Test;
+
// NOTE THIS IS ACTUALLY IN 1.7.2 - IT IS JUST THAT THE PATCH WAS CREATED AGAINST 1.7.1
public class NewFeatures extends org.aspectj.testing.XMLBasedAjcTestCase {
@@ -60,10 +60,12 @@ public class NewFeatures extends org.aspectj.testing.XMLBasedAjcTestCase {
return XMLBasedAjcTestCase.loadSuite(NewFeatures.class);
}
+ @SuppressWarnings("unused")
private JavaClass getMyClass(String className) throws ClassNotFoundException {
return getClassFrom(ajc.getSandboxDirectory(), className);
}
+ @Override
protected File getSpecFile() {
return new File("../tests/src/org/aspectj/systemtest/ajc171/newfeatures-tests.xml");
}
diff --git a/tests/src/org/aspectj/systemtest/ajc191/Ajc191Tests.java b/tests/src/org/aspectj/systemtest/ajc191/Ajc191Tests.java
new file mode 100644
index 000000000..230a9128d
--- /dev/null
+++ b/tests/src/org/aspectj/systemtest/ajc191/Ajc191Tests.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andy Clement - initial API and implementation
+ *******************************************************************************/
+package org.aspectj.systemtest.ajc191;
+
+import java.io.File;
+
+import org.aspectj.testing.XMLBasedAjcTestCase;
+import org.aspectj.testing.XMLBasedAjcTestCaseForJava10OrLater;
+
+import junit.framework.Test;
+
+/**
+ * @author Andy Clement
+ */
+public class Ajc191Tests extends XMLBasedAjcTestCaseForJava10OrLater {
+
+ public void testVar1() {
+ runTest("var 1");
+ }
+
+ public void testVar2() {
+ runTest("var 2");
+ }
+
+ public void testVarIncludesAspect3() {
+ runTest("var 3");
+ }
+
+ // ---
+
+ public static Test suite() {
+ return XMLBasedAjcTestCase.loadSuite(Ajc191Tests.class);
+ }
+
+ @Override
+ protected File getSpecFile() {
+ return getClassResource("ajc191.xml");
+ }
+
+}
diff --git a/tests/src/org/aspectj/systemtest/ajc191/AllTestsAspectJ191.java b/tests/src/org/aspectj/systemtest/ajc191/AllTestsAspectJ191.java
new file mode 100644
index 000000000..a42ad5b4c
--- /dev/null
+++ b/tests/src/org/aspectj/systemtest/ajc191/AllTestsAspectJ191.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andy Clement - initial API and implementation
+ *******************************************************************************/
+package org.aspectj.systemtest.ajc191;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTestsAspectJ191 {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite("AspectJ 1.9.1 tests");
+ // $JUnit-BEGIN$
+ suite.addTest(Ajc191Tests.suite());
+ // $JUnit-END$
+ return suite;
+ }
+}
diff --git a/tests/src/org/aspectj/systemtest/ajc191/ajc191.xml b/tests/src/org/aspectj/systemtest/ajc191/ajc191.xml
new file mode 100644
index 000000000..ab14b9e73
--- /dev/null
+++ b/tests/src/org/aspectj/systemtest/ajc191/ajc191.xml
@@ -0,0 +1,36 @@
+<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[]>
+
+<suite>
+
+ <ajc-test dir="bugs191/var" title="var 1">
+ <compile files="Code1.java" options="-10">
+ </compile>
+ <run class="Code1">
+ <stdout>
+ <line text="class java.lang.String"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="bugs191/var" title="var 2">
+ <compile files="Code2.java" options="-10">
+ </compile>
+ <run class="Code2">
+ <stdout>
+ <line text="class java.util.ArrayList"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="bugs191/var" title="var 3">
+ <compile files="Code3.java" options="-10">
+ </compile>
+ <run class="Code3">
+ <stdout>
+ <line text="call(Class java.lang.Object.getClass())"/>
+ <line text="class java.util.ArrayList"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+</suite>
diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/IncrementalPerformanceTests.java b/tests/src/org/aspectj/systemtest/incremental/tools/IncrementalPerformanceTests.java
index c5e53cdeb..428c037d8 100644
--- a/tests/src/org/aspectj/systemtest/incremental/tools/IncrementalPerformanceTests.java
+++ b/tests/src/org/aspectj/systemtest/incremental/tools/IncrementalPerformanceTests.java
@@ -141,6 +141,7 @@ public class IncrementalPerformanceTests extends AbstractMultiProjectIncremental
// --- helper code ---
+ @SuppressWarnings("unused")
private void waitFor10() {
try {
Thread.sleep(10000);
@@ -149,6 +150,7 @@ public class IncrementalPerformanceTests extends AbstractMultiProjectIncremental
}
}
+ @SuppressWarnings("unused")
private void waitForReturn() {
try {
System.in.read();
@@ -157,11 +159,13 @@ public class IncrementalPerformanceTests extends AbstractMultiProjectIncremental
}
}
+ @Override
protected void setUp() throws Exception {
super.setUp();
testdataSrcDir = "../tests/incrementalPerformance";
}
+ @Override
protected void tearDown() throws Exception {
super.tearDown();
testdataSrcDir = "../tests/multiIncremental";
diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/MoreOutputLocationManagerTests.java b/tests/src/org/aspectj/systemtest/incremental/tools/MoreOutputLocationManagerTests.java
index 308ed42d5..c35b88610 100644
--- a/tests/src/org/aspectj/systemtest/incremental/tools/MoreOutputLocationManagerTests.java
+++ b/tests/src/org/aspectj/systemtest/incremental/tools/MoreOutputLocationManagerTests.java
@@ -48,6 +48,7 @@ public class MoreOutputLocationManagerTests extends AbstractMultiProjectIncremen
private String inpathTestingDir;
private String expectedOutputDir;
+ @Override
protected void setUp() throws Exception {
super.setUp();
initialiseProject("inpathTesting");
@@ -71,7 +72,7 @@ public class MoreOutputLocationManagerTests extends AbstractMultiProjectIncremen
Map.Entry<String,File> entry = iterator.next();
String className = entry.getKey();
String fullClassName = expectedOutputDir + File.separator + className.replace('.', File.separatorChar) + ".class";
- File file = (File) entry.getValue();
+ File file = entry.getValue();
assertEquals("expected file to have path \n" + fullClassName + ", but" + " found path \n" + file.getAbsolutePath(),
fullClassName, file.getAbsolutePath());
}
@@ -289,7 +290,7 @@ public class MoreOutputLocationManagerTests extends AbstractMultiProjectIncremen
configureNonStandardCompileOptions("inpathTesting", "-outxml");
build("inpathTesting");
AjState state = getState();
- Map m = state.getAspectNamesToFileNameMap();
+ Map<String,char[]> m = state.getAspectNamesToFileNameMap();
assertEquals("Expected only one aspect recored in the state but found " + m.size(), 1, m.size());
build("inpathTesting");
m = state.getAspectNamesToFileNameMap();
@@ -333,37 +334,46 @@ public class MoreOutputLocationManagerTests extends AbstractMultiProjectIncremen
allOutputLocations.add(outputLoc);
}
+ @Override
public File getOutputLocationForClass(File compilationUnit) {
return outputLoc;
}
+ @Override
public Map<File,String> getInpathMap() {
return Collections.emptyMap();
}
+ @Override
public File getOutputLocationForResource(File resource) {
return outputLoc;
}
+ @Override
public List<File> getAllOutputLocations() {
return allOutputLocations;
}
+ @Override
public File getDefaultOutputLocation() {
return outputLoc;
}
+ @Override
public void reportFileWrite(String outputfile, int filetype) {
}
+ @Override
public void reportFileRemove(String outputfile, int filetype) {
}
+ @Override
public String getSourceFolderForFile(File sourceFile) {
return null; // no impl
}
+ @Override
public int discoverChangesSince(File dir, long buildtime) {
return 0; // no impl
}