aboutsummaryrefslogtreecommitdiffstats
path: root/ajde
diff options
context:
space:
mode:
authormkersten <mkersten>2003-08-08 12:44:56 +0000
committermkersten <mkersten>2003-08-08 12:44:56 +0000
commit080e0b8e9940150f2bf7a09df0aa7910af8b5447 (patch)
tree00c0a4306d2c6f23e73e3198a0791e513055c4b9 /ajde
parent7df925d43588c29a9844014d317046d9c444c2e3 (diff)
downloadaspectj-080e0b8e9940150f2bf7a09df0aa7910af8b5447.tar.gz
aspectj-080e0b8e9940150f2bf7a09df0aa7910af8b5447.zip
Matthew's fixes for failing weaver unit tests.
Diffstat (limited to 'ajde')
-rw-r--r--ajde/testdata/bug-36071/config.lst2
-rw-r--r--ajde/testdata/bug-36071/config1.lst2
-rw-r--r--ajde/testdata/bug-36071/config2.lst1
-rw-r--r--ajde/testdata/bug-36071/input1.jarbin0 -> 1489 bytes
-rw-r--r--ajde/testdata/bug-36071/input2.jarbin0 -> 153 bytes
-rw-r--r--ajde/testdata/bug-36071/src/testsrc/TestProperties.java (renamed from ajde/testdata/bug-36071/src/test/TestProperties.java)0
-rw-r--r--ajde/testdata/bug-36071/src/testsrc/test.props (renamed from ajde/testdata/bug-36071/src/test/test.props)0
-rw-r--r--ajde/testsrc/org/aspectj/ajde/NullIdeManager.java9
-rw-r--r--ajde/testsrc/org/aspectj/ajde/NullIdeTaskListManager.java13
-rw-r--r--ajde/testsrc/org/aspectj/ajde/ResourceCopyTestCase.java276
-rw-r--r--ajde/testsrc/org/aspectj/ajde/StructureModelTest.java2
11 files changed, 198 insertions, 107 deletions
diff --git a/ajde/testdata/bug-36071/config.lst b/ajde/testdata/bug-36071/config.lst
deleted file mode 100644
index d7e4ff6dc..000000000
--- a/ajde/testdata/bug-36071/config.lst
+++ /dev/null
@@ -1,2 +0,0 @@
-src/Main.java
-src/test/TestProperties.java
diff --git a/ajde/testdata/bug-36071/config1.lst b/ajde/testdata/bug-36071/config1.lst
new file mode 100644
index 000000000..6ba2da52a
--- /dev/null
+++ b/ajde/testdata/bug-36071/config1.lst
@@ -0,0 +1,2 @@
+src/Main.java
+src/testsrc/TestProperties.java
diff --git a/ajde/testdata/bug-36071/config2.lst b/ajde/testdata/bug-36071/config2.lst
new file mode 100644
index 000000000..c1fd90b45
--- /dev/null
+++ b/ajde/testdata/bug-36071/config2.lst
@@ -0,0 +1 @@
+src/aspects/Logging.java
diff --git a/ajde/testdata/bug-36071/input1.jar b/ajde/testdata/bug-36071/input1.jar
new file mode 100644
index 000000000..83abbbaa1
--- /dev/null
+++ b/ajde/testdata/bug-36071/input1.jar
Binary files differ
diff --git a/ajde/testdata/bug-36071/input2.jar b/ajde/testdata/bug-36071/input2.jar
new file mode 100644
index 000000000..d55b84dfe
--- /dev/null
+++ b/ajde/testdata/bug-36071/input2.jar
Binary files differ
diff --git a/ajde/testdata/bug-36071/src/test/TestProperties.java b/ajde/testdata/bug-36071/src/testsrc/TestProperties.java
index 18139e035..18139e035 100644
--- a/ajde/testdata/bug-36071/src/test/TestProperties.java
+++ b/ajde/testdata/bug-36071/src/testsrc/TestProperties.java
diff --git a/ajde/testdata/bug-36071/src/test/test.props b/ajde/testdata/bug-36071/src/testsrc/test.props
index 51e670ac7..51e670ac7 100644
--- a/ajde/testdata/bug-36071/src/test/test.props
+++ b/ajde/testdata/bug-36071/src/testsrc/test.props
diff --git a/ajde/testsrc/org/aspectj/ajde/NullIdeManager.java b/ajde/testsrc/org/aspectj/ajde/NullIdeManager.java
index 61318014e..504907666 100644
--- a/ajde/testsrc/org/aspectj/ajde/NullIdeManager.java
+++ b/ajde/testsrc/org/aspectj/ajde/NullIdeManager.java
@@ -74,4 +74,13 @@ public class NullIdeManager {
public List getCompilationSourceLineTasks() {
return taskListManager.getSourceLineTasks();
}
+
+ public NullIdeProperties getProjectProperties() {
+ return projectProperties;
+ }
+
+ public void setProjectProperties(NullIdeProperties properties) {
+ projectProperties = properties;
+ }
+
}
diff --git a/ajde/testsrc/org/aspectj/ajde/NullIdeTaskListManager.java b/ajde/testsrc/org/aspectj/ajde/NullIdeTaskListManager.java
index f290197e5..17e4f4722 100644
--- a/ajde/testsrc/org/aspectj/ajde/NullIdeTaskListManager.java
+++ b/ajde/testsrc/org/aspectj/ajde/NullIdeTaskListManager.java
@@ -42,9 +42,16 @@ public class NullIdeTaskListManager implements TaskListManager {
sourceLineTasks.add(new SourceLineTask(message));
if (!hasWarning && IMessage.WARNING.isSameOrLessThan(message.getKind())) {
hasWarning = true;
- }
- System.out.println("NullIde> task: " + message.getMessage() + ", file: " + message.getSourceLocation().getSourceFile().getAbsolutePath()
- + ": " + message.getSourceLocation().getLine());
+ }
+ /* Guard against null source locations e.g. JAR file messages */
+ if (null != message.getSourceLocation()) {
+ System.out.println("> added sourceline task: " + message + ", file: " + message.getSourceLocation().getSourceFile().getAbsolutePath()
+ + ": " + message.getSourceLocation().getLine());
+ }
+ else {
+ System.out.println("> added sourceline task: " + message);
+ }
+
}
public void addProjectTask(String message, IMessage.Kind kind) {
diff --git a/ajde/testsrc/org/aspectj/ajde/ResourceCopyTestCase.java b/ajde/testsrc/org/aspectj/ajde/ResourceCopyTestCase.java
index b5d46eab1..e17175020 100644
--- a/ajde/testsrc/org/aspectj/ajde/ResourceCopyTestCase.java
+++ b/ajde/testsrc/org/aspectj/ajde/ResourceCopyTestCase.java
@@ -22,11 +22,11 @@ public class ResourceCopyTestCase extends AjdeTestCase {
public static final String PROJECT_DIR = "bug-36071";
public static final String srcDir = PROJECT_DIR + "/src";
- public static final String binDir = PROJECT_DIR + "/bin";
+ public static final String binDir = "bin";
- public static final String injar1 = "testdata/bug-40943/input1.jar";
- public static final String injar2 = "testdata/bug-40943/input2.jar";
- public static final String outjar = "testdata/bug-40943/output.jar";
+ public static final String injar1Name = "input1.jar";
+ public static final String injar2Name = "input2.jar";
+ public static final String outjarName = "/bin/output.jar";
/**
* Constructor for JarResourceCopyTestCase.
@@ -41,133 +41,132 @@ public class ResourceCopyTestCase extends AjdeTestCase {
*/
protected void setUp() throws Exception {
super.setUp(PROJECT_DIR);
- FileUtil.deleteContents(new File(binDir));
+ FileUtil.deleteContents(openFile(binDir));
}
-
+
public void testSrcToBin () {
- doSynchronousBuild("config.lst");
assertTrue(!Ajde.getDefault().getTaskListManager().hasWarning());
- assertTrue(new java.io.File("testdata/bug-36071").getAbsolutePath(), compareDirs("src", "bin"));
+ assertTrue("Build failed",doSynchronousBuild("config1.lst"));
+ compareDirs("src","bin");
+ }
+
+ public void testInjarsToOutjar () {
+ Set injars = new HashSet();
+ File injar1 = openFile(injar1Name);
+ injars.add(injar1);
+ ideManager.getProjectProperties().setInJars(injars);
+ File outjar = openFile(outjarName);
+ ideManager.getProjectProperties().setOutJar(outjar.getAbsolutePath());
+ assertTrue("Build failed",doSynchronousBuild("config2.lst"));
+ assertFalse("No build warnings",ideManager.getCompilationSourceLineTasks().isEmpty());
+ List msgs = NullIdeManager.getIdeManager().getCompilationSourceLineTasks();
+ assertTrue("Wrong message",((NullIdeTaskListManager.SourceLineTask)msgs.get(0)).message.getMessage().startsWith("manifest not copied: "));
+ compareJars(injar1,"src",outjar);
}
-// public void testInjarsToBin () {
-// List args = new ArrayList();
-// args.add("-injars");
-// args.add(injar1);
-//
-// args.add("-d");
-// args.add(binDir);
-//
-// args.add("-classpath");
-// args.add("../runtime/bin");
-//
-// args.add("testdata/bug-40943/aspects/Logging.java");
-//
-// CommandTestCase.runCompiler(args, CommandTestCase.NO_ERRORS);
-//
-// assertTrue(new java.io.File("testdata/bug-40943").getAbsolutePath(),compareJarToDirs(injar1,binDir));
-// }
-//
-// public void testInjarsToOutjar () {
-// List args = new ArrayList();
-// args.add("-injars");
-// args.add(injar1);
-//
-// args.add("-outjar");
-// args.add(outjar);
-//
-// args.add("-classpath");
-// args.add("../runtime/bin");
-//
-// args.add("testdata/bug-40943/aspects/Logging.java");
-//
-// CommandTestCase.runCompiler(args, CommandTestCase.NO_ERRORS);
-//
-// assertTrue(new java.io.File("testdata/bug-40943").getAbsolutePath(),compareJars(injar1,outjar));
-// }
-//
-//
-// public void test2InjarsToOutjar () {
-// System.err.println("? test2InjarsToOutjar()");
-// List args = new ArrayList();
-// args.add("-injars");
-// args.add(injar1 + ";" + injar2);
-//
-// args.add("-outjar");
-// args.add(outjar);
-//
-// args.add("-classpath");
-// args.add("../runtime/bin");
-//
-// args.add("testdata/bug-40943/aspects/Logging.java");
-//
-// CommandTestCase.runCompiler(args, CommandTestCase.NO_ERRORS);
-//
-// assertTrue(new java.io.File("testdata/bug-40943").getAbsolutePath(),compareJars(injar1,outjar));
-// }
+ public void testDuplicateResources () {
+ Set injars = new HashSet();
+ File injar1 = openFile(injar1Name);
+ File injar2 = openFile(injar2Name);
+ injars.add(injar1);
+ injars.add(injar2);
+ ideManager.getProjectProperties().setInJars(injars);
+ File outjar = openFile(outjarName);
+ ideManager.getProjectProperties().setOutJar(outjar.getAbsolutePath());
+ assertFalse("Build should have failed",doSynchronousBuild("config2.lst"));
+ assertFalse("No build errors",ideManager.getCompilationSourceLineTasks().isEmpty());
+ List msgs = NullIdeManager.getIdeManager().getCompilationSourceLineTasks();
+ assertTrue("Wrong message",((NullIdeTaskListManager.SourceLineTask)msgs.get(1)).message.getMessage().startsWith("duplicate resource: "));
+ }
+
+ public void testSrcToOutjar () {
+ File outjar = openFile(outjarName);
+ ideManager.getProjectProperties().setOutJar(outjar.getAbsolutePath());
+ assertTrue("Build failed",doSynchronousBuild("config1.lst"));
+ compareSourceToOutjar("src",outjar);
+ }
+
+ public void testInjarsToBin () {
+ Set injars = new HashSet();
+ File injar1 = openFile(injar1Name);
+ injars.add(injar1);
+ ideManager.getProjectProperties().setInJars(injars);
+ assertTrue("Build failed",doSynchronousBuild("config2.lst"));
+ assertFalse("No build warnings",ideManager.getCompilationSourceLineTasks().isEmpty());
+ List msgs = NullIdeManager.getIdeManager().getCompilationSourceLineTasks();
+ assertTrue("Wrong message",((NullIdeTaskListManager.SourceLineTask)msgs.get(0)).message.getMessage().startsWith("manifest not copied: "));
+ compareInjarsToBin(injar1,"src","bin");
+ }
/*
- * Ensure -outjar conatins all non-Java resouces from injars
+ * Ensure bin contains all non-Java resouces from source and injars
*/
- public boolean compareDirs (String indirName, String outdirName) {
- File srcBase = openFile(indirName);
+ public void compareDirs (String indirName, String outdirName) {
File binBase = openFile(outdirName);
- File[] fromResources = FileUtil.listFiles(srcBase,aspectjResourceFileFilter);
File[] toResources = FileUtil.listFiles(binBase,aspectjResourceFileFilter);
- HashSet resources = new HashSet();
- for (int i = 0; i < fromResources.length; i++) {
- resources.add(FileUtil.normalizedPath(fromResources[i],srcBase));
- }
+ HashSet resources = new HashSet();
+ listSourceResources(indirName,resources);
for (int i = 0; i < toResources.length; i++) {
String fileName = FileUtil.normalizedPath(toResources[i],binBase);
boolean b = resources.remove(fileName);
- assertTrue(fileName,b);
+ assertTrue("Extraneous resoures:" + fileName,b);
}
- assertTrue(resources.toString(), resources.isEmpty());
- return true;
+ assertTrue("Missing resources:" + resources.toString(), resources.isEmpty());
}
/*
- * Ensure -outjar conatins all non-Java resouces from injars
+ * Ensure -outjar contains all non-Java resouces from injars
*/
- public boolean compareJarToDirs (String injarName , String outdirName) {
- File baseDir = new File(binDir);
- System.err.println("? compareJarToDirs() baseDir='" + baseDir + "'");
- File[] files = FileUtil.listFiles(baseDir,aspectjResourceFileFilter);
- for (int i = 0; i < files.length; i++) {
- System.err.println("? compareJarToDirs() name='" + files[i] + "'");
- }
-
- return false;
- }
-
- /*
- * Ensure -outjar conatins all non-Java resouces from injars
- */
- public boolean compareJars (String injarName , String outjarName) {
+ public void compareJars (File injarFile, String indirName, File outjarFile) {
HashSet resources = new HashSet();
try {
- File injarFile = new File(injarName);
- File outjarFile = new File(outjarName);
assertTrue("outjar older than injar",(outjarFile.lastModified() > injarFile.lastModified()));
-
- ZipInputStream injar = new ZipInputStream(new java.io.FileInputStream(injarFile));
+ byte[] inManifest = listJarResources(injarFile,resources);
+ listSourceResources(indirName,resources);
+
+ ZipInputStream outjar = new ZipInputStream(new java.io.FileInputStream(outjarFile));
ZipEntry entry;
- while (null != (entry = injar.getNextEntry())) {
+ while (null != (entry = outjar.getNextEntry())) {
String fileName = entry.getName();
if (!fileName.endsWith(".class")) {
- resources.add(fileName);
+
+ /* Ensure we didn't copy any JAR manifests */
+ if (fileName.toLowerCase().startsWith("meta-inf")) {
+ byte[] outManifest = FileUtil.readAsByteArray(outjar);
+// System.err.println("? compareJars() fileName='" + fileName + "', manifest='" + new String(outManifest) + "'");
+ assertFalse("Manifest has been copied",Arrays.equals(inManifest,outManifest));
+ }
+
+ boolean b = resources.remove(fileName);
+ assertTrue(fileName,b);
}
- injar.closeEntry();
+ outjar.closeEntry();
}
- injar.close();
+ outjar.close();
+
+ assertTrue(resources.toString(),resources.isEmpty());
+ }
+ catch (IOException ex) {
+ fail(ex.toString());
+ }
+ }
+
+ /*
+ * Ensure -outjar conatins all non-Java resouces from source and injars
+ */
+ public void compareSourceToOutjar (String indirName, File outjarFile) {
+ HashSet resources = new HashSet();
+ listSourceResources(indirName,resources);
+
+ try {
ZipInputStream outjar = new ZipInputStream(new java.io.FileInputStream(outjarFile));
+ ZipEntry entry;
while (null != (entry = outjar.getNextEntry())) {
String fileName = entry.getName();
if (!fileName.endsWith(".class")) {
@@ -178,19 +177,92 @@ public class ResourceCopyTestCase extends AjdeTestCase {
}
outjar.close();
- assertTrue(resources.toString(),resources.isEmpty());
+ assertTrue("Missing resources:" + resources.toString(), resources.isEmpty());
+ }
+ catch (IOException ex) {
+ fail(ex.toString());
+ }
+ }
+
+ /*
+ * Ensure bin contains all non-Java resouces from source and injars
+ */
+ public void compareInjarsToBin(File injarFile, String indirName, String outdirName) {
+
+ HashSet resources = new HashSet();
+
+ try {
+ byte[] inManifest = listJarResources(injarFile,resources);
+ listSourceResources(indirName,resources);
+
+ File binBase = openFile(outdirName);
+ File[] toResources = FileUtil.listFiles(binBase,aspectjResourceFileFilter);
+ for (int i = 0; i < toResources.length; i++) {
+ String fileName = FileUtil.normalizedPath(toResources[i],binBase);
+
+ /* Ensure we didn't copy any JAR manifests */
+ if (fileName.toLowerCase().startsWith("meta-inf")) {
+ byte[] outManifest = FileUtil.readAsByteArray(toResources[i]);
+// System.err.println("? compareJars() fileName='" + fileName + "', manifest='" + new String(outManifest) + "'");
+ assertFalse("Manifest has been copied",Arrays.equals(inManifest,outManifest));
+ }
+ boolean b = resources.remove(fileName);
+ assertTrue("Extraneous resoures:" + fileName,b);
+ }
+
+ assertTrue("Missing resources:" + resources.toString(), resources.isEmpty());
}
catch (IOException ex) {
fail(ex.toString());
}
-
- return true;
}
+ private void listSourceResources (String indirName, Set resources) {
+ File srcBase = openFile(indirName);
+ File[] fromResources = FileUtil.listFiles(srcBase,aspectjResourceFileFilter);
+ for (int i = 0; i < fromResources.length; i++) {
+ String name = FileUtil.normalizedPath(fromResources[i],srcBase);
+ if (!name.startsWith("CVS/") && (-1 == name.indexOf("/CVS/")) && !name.endsWith("/CVS")) {
+ resources.add(name);
+ }
+ }
+ }
+
+ private byte[] listJarResources (File injarFile, Set resources) {
+ byte[] manifest = null;
+
+ try {
+ ZipInputStream injar = new ZipInputStream(new java.io.FileInputStream(injarFile));
+ ZipEntry entry;
+ while (null != (entry = injar.getNextEntry())) {
+ String fileName = entry.getName();
+ if (!fileName.endsWith(".class")) {
+
+ /* JAR manifests shouldn't be copied */
+ if (fileName.toLowerCase().startsWith("meta-inf")) {
+ manifest = FileUtil.readAsByteArray(injar);
+// System.err.println("? compareJars() fileName='" + fileName + "', manifest='" + new String(manifest) + "'");
+ }
+ else {
+ resources.add(fileName);
+ }
+ }
+ injar.closeEntry();
+ }
+ injar.close();
+ }
+ catch (IOException ex) {
+ fail(ex.toString());
+ }
+
+ return manifest;
+ }
+
public static final FileFilter aspectjResourceFileFilter = new FileFilter() {
public boolean accept(File pathname) {
String name = pathname.getName().toLowerCase();
- return !name.endsWith(".class") && !name.endsWith(".java") && !name.endsWith(".aj");
+ return (!name.endsWith(".class") && !name.endsWith(".java") && !name.endsWith(".aj"));
+
}
};
diff --git a/ajde/testsrc/org/aspectj/ajde/StructureModelTest.java b/ajde/testsrc/org/aspectj/ajde/StructureModelTest.java
index 8dfc26c97..8c2c2003d 100644
--- a/ajde/testsrc/org/aspectj/ajde/StructureModelTest.java
+++ b/ajde/testsrc/org/aspectj/ajde/StructureModelTest.java
@@ -128,6 +128,8 @@ public class StructureModelTest extends AjdeTestCase {
assertTrue("find result", node != null);
+ System.err.println("##### " + node);
+
IProgramElement pNode = (IProgramElement)((IProgramElement)node).getParent();
if (null == pNode) {
assertTrue("null parent of " + node, false);