aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ajbrowser/src/org/aspectj/tools/ajbrowser/BrowserProperties.java5
-rw-r--r--ajbrowser/src/org/aspectj/tools/ajbrowser/CompilerMessagesPanel.java91
-rw-r--r--ajde/src/org/aspectj/ajde/ProjectPropertiesAdapter.java13
-rw-r--r--ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java1
-rw-r--r--ajde/src/org/aspectj/ajde/ui/swing/CompilerMessage.java34
-rw-r--r--ajde/src/org/aspectj/ajde/ui/swing/CompilerMessagesCellRenderer.java2
-rw-r--r--ajde/testdata/bug-36071/bin/test/test.props1
-rw-r--r--ajde/testdata/bug-36071/config.lst2
-rw-r--r--ajde/testdata/bug-36071/src/Main.java22
-rw-r--r--ajde/testdata/bug-36071/src/aspects/Logging.java27
-rw-r--r--ajde/testdata/bug-36071/src/test/TestProperties.java29
-rw-r--r--ajde/testdata/bug-36071/src/test/test.props1
-rw-r--r--ajde/testdata/bug-40943/aspects/Logging.java27
-rw-r--r--ajde/testdata/bug-40943/input1.jarbin0 -> 1471 bytes
-rw-r--r--ajde/testdata/bug-40943/input2.jarbin0 -> 1471 bytes
-rw-r--r--ajde/testdata/bug-40943/output.jarbin0 -> 3318 bytes
-rw-r--r--ajde/testdata/examples/coverage/ModelCoverage.java4
-rw-r--r--ajde/testdata/examples/coverage/coverage.ajsymbin20658 -> 20658 bytes
-rw-r--r--ajde/testsrc/org/aspectj/ajde/AjdeTests.java1
-rw-r--r--ajde/testsrc/org/aspectj/ajde/NullIdeManager.java5
-rw-r--r--ajde/testsrc/org/aspectj/ajde/NullIdeProperties.java21
-rw-r--r--ajde/testsrc/org/aspectj/ajde/ResourceCopyTestCase.java196
22 files changed, 381 insertions, 101 deletions
diff --git a/ajbrowser/src/org/aspectj/tools/ajbrowser/BrowserProperties.java b/ajbrowser/src/org/aspectj/tools/ajbrowser/BrowserProperties.java
index d8a09a2d8..8d0d2cf8e 100644
--- a/ajbrowser/src/org/aspectj/tools/ajbrowser/BrowserProperties.java
+++ b/ajbrowser/src/org/aspectj/tools/ajbrowser/BrowserProperties.java
@@ -161,4 +161,9 @@ public class BrowserProperties implements ProjectPropertiesAdapter {
public Set getAspectPath( ) { // XXX unimplemented
return null;
}
+
+ public Map getSourcePathResources() {
+ return null;
+ }
+
}
diff --git a/ajbrowser/src/org/aspectj/tools/ajbrowser/CompilerMessagesPanel.java b/ajbrowser/src/org/aspectj/tools/ajbrowser/CompilerMessagesPanel.java
index e03885ef6..cbc09c877 100644
--- a/ajbrowser/src/org/aspectj/tools/ajbrowser/CompilerMessagesPanel.java
+++ b/ajbrowser/src/org/aspectj/tools/ajbrowser/CompilerMessagesPanel.java
@@ -15,22 +15,13 @@
package org.aspectj.tools.ajbrowser;
import java.awt.BorderLayout;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
-
-import javax.swing.DefaultListModel;
-import javax.swing.JList;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-
-import org.aspectj.ajde.Ajde;
-import org.aspectj.ajde.TaskListManager;
-import org.aspectj.ajde.ui.swing.CompilerMessage;
-import org.aspectj.ajde.ui.swing.CompilerMessagesCellRenderer;
-import org.aspectj.bridge.IMessage;
-import org.aspectj.bridge.ISourceLocation;
-import org.aspectj.bridge.Message;
+import java.awt.event.*;
+
+import javax.swing.*;
+
+import org.aspectj.ajde.*;
+import org.aspectj.ajde.ui.swing.*;
+import org.aspectj.bridge.*;
import org.aspectj.bridge.IMessage.Kind;
/**
@@ -45,11 +36,11 @@ public class CompilerMessagesPanel extends JPanel implements TaskListManager {
private JList list = new JList();
private DefaultListModel listModel = new DefaultListModel();
private BorderLayout borderLayout1 = new BorderLayout();
- private boolean hasWarning = false;
+ private boolean hasWarning = false;
public CompilerMessagesPanel() {
try {
- jbInit();
+ jbInit();
}
catch(Exception e) {
e.printStackTrace();
@@ -61,10 +52,8 @@ public class CompilerMessagesPanel extends JPanel implements TaskListManager {
if (e.getClickCount() >= 1) {
int index = list.locationToIndex(e.getPoint());
if (listModel.getSize() >= index && index != -1) {
- CompilerMessage cm = (CompilerMessage)listModel.getElementAt(index);
- if ((null != cm) && (null != cm.message)) {
- displayMessage(cm.message);
- }
+ IMessage message = (IMessage)listModel.getElementAt(index);
+ Ajde.getDefault().getEditorAdapter().showSourceLine(message.getISourceLocation(), true);
}
}
}
@@ -72,50 +61,29 @@ public class CompilerMessagesPanel extends JPanel implements TaskListManager {
list.addMouseListener(mouseListener);
list.setCellRenderer(new CompilerMessagesCellRenderer());
}
-
- public void addSourcelineTask(
- String message,
- ISourceLocation sourceLocation,
- Kind kind) {
- addSourcelineTask(new Message(message, kind, null, sourceLocation));
- }
-
- /**
- * called when user double-clicks on a message.
- */
- protected void displayMessage(IMessage message) {
- ISourceLocation loc = message.getISourceLocation();
- BrowserManager.getDefault().getEditorManager().showSourceLine(loc, true);
- // show dialog with stack trace if thrown
- Throwable thrown = message.getThrown();
- if (null != thrown) {
- Ajde.getDefault().getErrorHandler().handleError(message.getMessage(), thrown);
- }
- }
- public void addSourcelineTask(IMessage message) {
- listModel.addElement(new CompilerMessage(message));
- if (!hasWarning && IMessage.WARNING.isSameOrLessThan(message.getKind())) {
- hasWarning = true;
- }
- BrowserManager.getDefault().showMessages();
+ public void addSourcelineTask(IMessage message) {
+ listModel.addElement(message);
+ checkIfWarning(message.getKind());
+ }
+
+ public void addSourcelineTask(String message, ISourceLocation sourceLocation, IMessage.Kind kind) {
+ listModel.addElement(new Message(message, kind, null, sourceLocation));
+ checkIfWarning(kind);
}
public void addProjectTask(String message, IMessage.Kind kind) {
- IMessage m = new Message(message, kind, null, null);
- listModel.addElement(new CompilerMessage(m));
- if (!hasWarning && IMessage.WARNING.isSameOrLessThan(kind)) {
- hasWarning = true;
- }
- BrowserManager.getDefault().showMessages();
+ listModel.addElement(new Message(message, kind, null, null));
+ checkIfWarning(kind);
}
-
- public boolean hasWarning() {
- return hasWarning;
- }
-
+
+ private void checkIfWarning(Kind kind) {
+ if (kind.equals(IMessage.WARNING)) hasWarning = true;
+ }
+
public void clearTasks() {
listModel.clear();
+ hasWarning = false;
}
private void jbInit() throws Exception {
@@ -123,6 +91,11 @@ public class CompilerMessagesPanel extends JPanel implements TaskListManager {
this.add(jScrollPane1, BorderLayout.CENTER);
jScrollPane1.getViewport().add(list, null);
}
+
+ public boolean hasWarning() {
+ return hasWarning;
+ }
+
}
diff --git a/ajde/src/org/aspectj/ajde/ProjectPropertiesAdapter.java b/ajde/src/org/aspectj/ajde/ProjectPropertiesAdapter.java
index fd63560e3..2934932ee 100644
--- a/ajde/src/org/aspectj/ajde/ProjectPropertiesAdapter.java
+++ b/ajde/src/org/aspectj/ajde/ProjectPropertiesAdapter.java
@@ -16,8 +16,7 @@
package org.aspectj.ajde;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
/**
* @author Mik Kersten
@@ -70,6 +69,16 @@ public interface ProjectPropertiesAdapter {
public Set getInJars();
/**
+ * Get the set of non-Java resources for this compilation.
+ * Set members should be of type java.io.File.
+ * An empty set or null is acceptable for this option.
+ * From -injars.
+ *
+ * @return map from unique resource name to absolute path to source resource (String to File)
+ */
+ public Map getSourcePathResources();
+
+ /**
* Get the output jar file for the compilation results.
* Return null to leave classfiles unjar'd in output directory
* From -outjar
diff --git a/ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java b/ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java
index d77aee408..c1b838e28 100644
--- a/ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java
+++ b/ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java
@@ -488,6 +488,7 @@ public class CompilerAdapter {
join(config.getSourceRoots(), properties.getSourceRoots());
join(config.getInJars(), properties.getInJars());
+ config.setSourcePathResources(properties.getSourcePathResources());
join(config.getAspectpath(), properties.getAspectPath());
}
diff --git a/ajde/src/org/aspectj/ajde/ui/swing/CompilerMessage.java b/ajde/src/org/aspectj/ajde/ui/swing/CompilerMessage.java
deleted file mode 100644
index 9ca312d83..000000000
--- a/ajde/src/org/aspectj/ajde/ui/swing/CompilerMessage.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 1999-2001 Xerox Corporation,
- * 2002 Palo Alto Research Center, Incorporated (PARC).
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Common Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
- * ******************************************************************/
-
-
-package org.aspectj.ajde.ui.swing;
-
-import org.aspectj.bridge.IMessage;
-import org.aspectj.util.LangUtil;
-
-/**
- * @author Mik Kersten
- */
-public class CompilerMessage {
- public final IMessage message;
-
- public CompilerMessage(IMessage message) {
- LangUtil.throwIaxIfNull(message, "message");
- this.message = message;
- }
-
- public String toString() {
- return message.toString();
- }
- }
diff --git a/ajde/src/org/aspectj/ajde/ui/swing/CompilerMessagesCellRenderer.java b/ajde/src/org/aspectj/ajde/ui/swing/CompilerMessagesCellRenderer.java
index 650eaaae5..9476f3b4e 100644
--- a/ajde/src/org/aspectj/ajde/ui/swing/CompilerMessagesCellRenderer.java
+++ b/ajde/src/org/aspectj/ajde/ui/swing/CompilerMessagesCellRenderer.java
@@ -36,7 +36,7 @@ public class CompilerMessagesCellRenderer extends JLabel implements ListCellRend
boolean cellHasFocus) {
String label = "<no message>";
String detail = null;
- IMessage.Kind kind = IMessage.INFO;
+ IMessage.Kind kind = IMessage.ERROR;
if (value instanceof IMessage) {
IMessage cm = (IMessage) value;
label = cm.getMessage();
diff --git a/ajde/testdata/bug-36071/bin/test/test.props b/ajde/testdata/bug-36071/bin/test/test.props
new file mode 100644
index 000000000..51e670ac7
--- /dev/null
+++ b/ajde/testdata/bug-36071/bin/test/test.props
@@ -0,0 +1 @@
+test=test \ No newline at end of file
diff --git a/ajde/testdata/bug-36071/config.lst b/ajde/testdata/bug-36071/config.lst
new file mode 100644
index 000000000..4fbccffce
--- /dev/null
+++ b/ajde/testdata/bug-36071/config.lst
@@ -0,0 +1,2 @@
+Main.java
+test/TestProperties.java
diff --git a/ajde/testdata/bug-36071/src/Main.java b/ajde/testdata/bug-36071/src/Main.java
new file mode 100644
index 000000000..417fc6809
--- /dev/null
+++ b/ajde/testdata/bug-36071/src/Main.java
@@ -0,0 +1,22 @@
+import java.io.IOException;
+
+/*
+ * Created on 30-Jul-03
+ *
+ * To change this generated comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+
+/**
+ * @author websterm
+ *
+ * To change this generated comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public class Main {
+
+ public static void main(String[] args) throws IOException {
+ String propsName = (args.length > 0)? args[0] : "test.props";
+ new test.TestProperties().load(propsName);
+ }
+}
diff --git a/ajde/testdata/bug-36071/src/aspects/Logging.java b/ajde/testdata/bug-36071/src/aspects/Logging.java
new file mode 100644
index 000000000..2e8ba485a
--- /dev/null
+++ b/ajde/testdata/bug-36071/src/aspects/Logging.java
@@ -0,0 +1,27 @@
+/*
+ * Created on 30-Jul-03
+ *
+ * To change this generated comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+package aspects;
+
+/**
+ * @author websterm
+ *
+ * To change this generated comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public aspect Logging {
+
+ pointcut methods () :
+ execution(* *..*(..)) && !within(Logging);
+
+ before () : methods () {
+ System.err.println("> " + thisJoinPoint.getSignature().toLongString());
+ }
+
+ after () : methods () {
+ System.err.println("< " + thisJoinPoint.getSignature().toLongString());
+ }
+}
diff --git a/ajde/testdata/bug-36071/src/test/TestProperties.java b/ajde/testdata/bug-36071/src/test/TestProperties.java
new file mode 100644
index 000000000..18139e035
--- /dev/null
+++ b/ajde/testdata/bug-36071/src/test/TestProperties.java
@@ -0,0 +1,29 @@
+/*
+ * Created on 30-Jul-03
+ *
+ * To change this generated comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+package test;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+/**
+ * @author websterm
+ *
+ * To change this generated comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public class TestProperties {
+
+ public void load (String name) throws IOException {
+ InputStream in = getClass().getResourceAsStream(name);
+// System.out.println("? load() in=" + in);
+ Properties props = new Properties();
+ props.load(in);
+ in.close();
+ props.list(System.out);
+ }
+}
diff --git a/ajde/testdata/bug-36071/src/test/test.props b/ajde/testdata/bug-36071/src/test/test.props
new file mode 100644
index 000000000..51e670ac7
--- /dev/null
+++ b/ajde/testdata/bug-36071/src/test/test.props
@@ -0,0 +1 @@
+test=test \ No newline at end of file
diff --git a/ajde/testdata/bug-40943/aspects/Logging.java b/ajde/testdata/bug-40943/aspects/Logging.java
new file mode 100644
index 000000000..2e8ba485a
--- /dev/null
+++ b/ajde/testdata/bug-40943/aspects/Logging.java
@@ -0,0 +1,27 @@
+/*
+ * Created on 30-Jul-03
+ *
+ * To change this generated comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+package aspects;
+
+/**
+ * @author websterm
+ *
+ * To change this generated comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public aspect Logging {
+
+ pointcut methods () :
+ execution(* *..*(..)) && !within(Logging);
+
+ before () : methods () {
+ System.err.println("> " + thisJoinPoint.getSignature().toLongString());
+ }
+
+ after () : methods () {
+ System.err.println("< " + thisJoinPoint.getSignature().toLongString());
+ }
+}
diff --git a/ajde/testdata/bug-40943/input1.jar b/ajde/testdata/bug-40943/input1.jar
new file mode 100644
index 000000000..c6305aa57
--- /dev/null
+++ b/ajde/testdata/bug-40943/input1.jar
Binary files differ
diff --git a/ajde/testdata/bug-40943/input2.jar b/ajde/testdata/bug-40943/input2.jar
new file mode 100644
index 000000000..c6305aa57
--- /dev/null
+++ b/ajde/testdata/bug-40943/input2.jar
Binary files differ
diff --git a/ajde/testdata/bug-40943/output.jar b/ajde/testdata/bug-40943/output.jar
new file mode 100644
index 000000000..a5f38e68e
--- /dev/null
+++ b/ajde/testdata/bug-40943/output.jar
Binary files differ
diff --git a/ajde/testdata/examples/coverage/ModelCoverage.java b/ajde/testdata/examples/coverage/ModelCoverage.java
index 6d09ba59d..e1e53be97 100644
--- a/ajde/testdata/examples/coverage/ModelCoverage.java
+++ b/ajde/testdata/examples/coverage/ModelCoverage.java
@@ -57,7 +57,7 @@ aspect AdviceNamingCoverage {
after(): named() { }
after(int i, int j) returning: namedWithArgs(i, j) { }
after() throwing: named() { }
- after(): named() { }
+ after(): named() { }
before(): named() { }
@@ -65,7 +65,7 @@ aspect AdviceNamingCoverage {
int around(int i) throws SizeException: namedWithOneArg(i) { return proceed(i); }
before(): named() { }
- before(int i): call(* *.mumble()) && named() && namedWithOneArg(i) { }
+ before(int i): call(* XXX.mumble()) && named() && namedWithOneArg(i) { }
before(int i): named() && call(* *.mumble()) && namedWithOneArg(i) { }
before(): call(* *.mumble()) { }
diff --git a/ajde/testdata/examples/coverage/coverage.ajsym b/ajde/testdata/examples/coverage/coverage.ajsym
index 25bc2b070..4841e0cfa 100644
--- a/ajde/testdata/examples/coverage/coverage.ajsym
+++ b/ajde/testdata/examples/coverage/coverage.ajsym
Binary files differ
diff --git a/ajde/testsrc/org/aspectj/ajde/AjdeTests.java b/ajde/testsrc/org/aspectj/ajde/AjdeTests.java
index ecaba129d..f5fa1fc98 100644
--- a/ajde/testsrc/org/aspectj/ajde/AjdeTests.java
+++ b/ajde/testsrc/org/aspectj/ajde/AjdeTests.java
@@ -28,6 +28,7 @@ public class AjdeTests extends TestCase {
suite.addTestSuite(VersionTest.class);
suite.addTestSuite(CompilerMessagesTest.class);
suite.addTestSuite(AsmDeclarationsTest.class);
+ suite.addTestSuite(ResourceCopyTestCase.class);
//$JUnit-END$
return suite;
diff --git a/ajde/testsrc/org/aspectj/ajde/NullIdeManager.java b/ajde/testsrc/org/aspectj/ajde/NullIdeManager.java
index 4a73e6ee6..06297be3f 100644
--- a/ajde/testsrc/org/aspectj/ajde/NullIdeManager.java
+++ b/ajde/testsrc/org/aspectj/ajde/NullIdeManager.java
@@ -32,6 +32,7 @@ public class NullIdeManager {
private static NullIdeManager ideManager = null;
private NullIdeTaskListManager taskListManager = null;
+ private NullIdeProperties projectProperties = null;
public static NullIdeManager getIdeManager() {
if ( null == ideManager ) {
@@ -43,7 +44,7 @@ public class NullIdeManager {
public void init(String testProjectPath) {
try {
UserPreferencesAdapter preferencesAdapter = new UserPreferencesStore(false);
- ProjectPropertiesAdapter browserProjectProperties = new NullIdeProperties(testProjectPath);
+ projectProperties = new NullIdeProperties(testProjectPath);
taskListManager = new NullIdeTaskListManager();
EditorAdapter ajdeEditor = new NullIdeEditorAdapter();
IdeUIAdapter uiAdapter = new NullIdeUIAdapter();
@@ -53,7 +54,7 @@ public class NullIdeManager {
AjdeUIManager.getDefault().init(
ajdeEditor,
taskListManager,
- browserProjectProperties,
+ projectProperties,
preferencesAdapter,
uiAdapter,
new IconRegistry(),
diff --git a/ajde/testsrc/org/aspectj/ajde/NullIdeProperties.java b/ajde/testsrc/org/aspectj/ajde/NullIdeProperties.java
index 2f12d7866..90203e61f 100644
--- a/ajde/testsrc/org/aspectj/ajde/NullIdeProperties.java
+++ b/ajde/testsrc/org/aspectj/ajde/NullIdeProperties.java
@@ -14,9 +14,11 @@
package org.aspectj.ajde;
-import java.io.File;
+import java.io.*;
import java.util.*;
+import org.aspectj.util.FileUtil;
+
/**
* @author Mik Kersten
*/
@@ -102,6 +104,23 @@ public class NullIdeProperties implements ProjectPropertiesAdapter {
public Set getInJars( ) {
return inJars;
}
+
+ public Map getSourcePathResources() {
+ File srcBase = new File(getProjectSourcePath());
+ File[] fromResources = FileUtil.listFiles(srcBase, new FileFilter() {
+ public boolean accept(File pathname) {
+ String name = pathname.getName().toLowerCase();
+ return !name.endsWith(".class") && !name.endsWith(".java") && !name.endsWith(".aj");
+ }
+ });
+ Map map = new HashMap();
+ for (int i = 0; i < fromResources.length; i++) {
+ String normPath = FileUtil.normalizedPath(fromResources[i] ,srcBase);
+ map.put(normPath, fromResources[i]);
+
+ }
+ return map;
+ }
public void setOutJar( String jar ){ this.outJar = jar; }
diff --git a/ajde/testsrc/org/aspectj/ajde/ResourceCopyTestCase.java b/ajde/testsrc/org/aspectj/ajde/ResourceCopyTestCase.java
new file mode 100644
index 000000000..2b499edbe
--- /dev/null
+++ b/ajde/testsrc/org/aspectj/ajde/ResourceCopyTestCase.java
@@ -0,0 +1,196 @@
+/*
+ * Created on 31-Jul-2003
+ *
+ * To change the template for this generated file go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+package org.aspectj.ajde;
+
+import java.io.*;
+import java.util.*;
+import java.util.zip.*;
+
+import org.aspectj.util.FileUtil;
+
+/**
+ * @author websterm
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+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 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";
+
+ /**
+ * Constructor for JarResourceCopyTestCase.
+ * @param arg0
+ */
+ public ResourceCopyTestCase(String arg0) {
+ super(arg0);
+ }
+
+ /*
+ * Ensure the output directpry in clean
+ */
+ protected void setUp() throws Exception {
+ super.setUp(PROJECT_DIR);
+ FileUtil.deleteContents(new File(binDir));
+ }
+
+ public void testSrcToBin () {
+ doSynchronousBuild("config.lst");
+ assertTrue(new java.io.File("testdata/bug-36071").getAbsolutePath(), compareDirs("src", "bin"));
+ }
+
+// 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));
+// }
+
+ /*
+ * Ensure -outjar conatins all non-Java resouces from injars
+ */
+ public boolean compareDirs (String indirName, String outdirName) {
+ File srcBase = openFile(indirName);
+ 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));
+ }
+
+ for (int i = 0; i < toResources.length; i++) {
+ String fileName = FileUtil.normalizedPath(toResources[i],binBase);
+ boolean b = resources.remove(fileName);
+ assertTrue(fileName,b);
+ }
+
+ assertTrue(resources.toString(), resources.isEmpty());
+ return true;
+ }
+
+ /*
+ * Ensure -outjar conatins 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) {
+
+ 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));
+ ZipEntry entry;
+ while (null != (entry = injar.getNextEntry())) {
+ String fileName = entry.getName();
+ if (!fileName.endsWith(".class")) {
+ resources.add(fileName);
+ }
+ injar.closeEntry();
+ }
+ injar.close();
+
+ ZipInputStream outjar = new ZipInputStream(new java.io.FileInputStream(outjarFile));
+ while (null != (entry = outjar.getNextEntry())) {
+ String fileName = entry.getName();
+ if (!fileName.endsWith(".class")) {
+ boolean b = resources.remove(fileName);
+ assertTrue(fileName,b);
+ }
+ outjar.closeEntry();
+ }
+ outjar.close();
+
+ assertTrue(resources.toString(),resources.isEmpty());
+ }
+ catch (IOException ex) {
+ fail(ex.toString());
+ }
+
+ return true;
+ }
+
+ 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");
+ }
+ };
+
+}