From 5edccbfaeb8bb4dc5b34d553267365ae3c7eda41 Mon Sep 17 00:00:00 2001 From: mkersten Date: Wed, 6 Aug 2003 21:17:57 +0000 Subject: [PATCH] Fixed bugs: 40943: Binary weaving should copy non-Java resources from "-inja... 36071: 1.1 rc1 should copy resources similar to java compiler 40826: ajbrowser does not report errors properly 40774: task list icons don't show in ajbrowser --- .../tools/ajbrowser/BrowserProperties.java | 5 + .../ajbrowser/CompilerMessagesPanel.java | 91 +++----- .../ajde/ProjectPropertiesAdapter.java | 13 +- .../ajde/internal/CompilerAdapter.java | 1 + .../ajde/ui/swing/CompilerMessage.java | 34 --- .../swing/CompilerMessagesCellRenderer.java | 2 +- ajde/testdata/bug-36071/bin/test/test.props | 1 + ajde/testdata/bug-36071/config.lst | 2 + ajde/testdata/bug-36071/src/Main.java | 22 ++ .../bug-36071/src/aspects/Logging.java | 27 +++ .../bug-36071/src/test/TestProperties.java | 29 +++ ajde/testdata/bug-36071/src/test/test.props | 1 + ajde/testdata/bug-40943/aspects/Logging.java | 27 +++ ajde/testdata/bug-40943/input1.jar | Bin 0 -> 1471 bytes ajde/testdata/bug-40943/input2.jar | Bin 0 -> 1471 bytes ajde/testdata/bug-40943/output.jar | Bin 0 -> 3318 bytes .../examples/coverage/ModelCoverage.java | 4 +- .../testdata/examples/coverage/coverage.ajsym | Bin 20658 -> 20658 bytes ajde/testsrc/org/aspectj/ajde/AjdeTests.java | 1 + .../org/aspectj/ajde/NullIdeManager.java | 5 +- .../org/aspectj/ajde/NullIdeProperties.java | 21 +- .../aspectj/ajde/ResourceCopyTestCase.java | 196 ++++++++++++++++++ 22 files changed, 381 insertions(+), 101 deletions(-) delete mode 100644 ajde/src/org/aspectj/ajde/ui/swing/CompilerMessage.java create mode 100644 ajde/testdata/bug-36071/bin/test/test.props create mode 100644 ajde/testdata/bug-36071/config.lst create mode 100644 ajde/testdata/bug-36071/src/Main.java create mode 100644 ajde/testdata/bug-36071/src/aspects/Logging.java create mode 100644 ajde/testdata/bug-36071/src/test/TestProperties.java create mode 100644 ajde/testdata/bug-36071/src/test/test.props create mode 100644 ajde/testdata/bug-40943/aspects/Logging.java create mode 100644 ajde/testdata/bug-40943/input1.jar create mode 100644 ajde/testdata/bug-40943/input2.jar create mode 100644 ajde/testdata/bug-40943/output.jar create mode 100644 ajde/testsrc/org/aspectj/ajde/ResourceCopyTestCase.java 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 @@ -69,6 +68,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 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 = ""; 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 0000000000000000000000000000000000000000..c6305aa57b5d077a494e9929f413da447491b099 GIT binary patch literal 1471 zcmWIWW@Zs#-~dAB@_%{^NI-;vg~8V~#8KDN&rRRg(a+P(H8@1i*X`da28PeRXHNTg z>*`(P_14uocjo-&AcHH$51u}H%ES=h&Cao@p6Q)5&?reD4uD(WQif^)7f{wWF*8pu zIVZ8WI5*JO|B!<~tvB~lQAWpAKYG=VcnGhT(svV{+@&TU^f`z(jmfCsY@SeHb^Pio~*}w0;ec}U--#pJur#G@5n;`$e{T*-Rh3|P*%olrg zC3sc_OP=`Ab8v;+7SB4lZ!T<}OJrtv7(c0z>^N3(MKG|tysc^BgZ5avoX;Ms{`8wX zX183Jw{Mg6!Wx$o55nI6-I;6LmvX^A(C*yP;P9SgNw$#CD?*Z0;pYFhw2B5DO%l3( zJkVm^l0cP(r}m1qMn7^9@iyETQ1oC`;Mv3z)jUgIDV^rI78rJjSLoA<^*Q2ajwNL8 zW|MyzD$X${&7ybLqo7rLbGPQlt_*N&n&(r?Y4Ej4ME8`9liQ3nXA}0n%5G2cnp~+9 zc;*im$8^rzl!?lr^UkT=6)Bl*X2^M{_ttacH?s==G^He7{ohb+e)!fyX|v~hH-Guw zsPs_lltw21_w7>AH?DQ@lxaH8(iY_SIZH7=O1AA#Ud1VGjYUfq zH(0h+y0iRIcv)Uq@~Eu#+=dq|^In(V@mTS7N5lkqmoppQoC(OkxJ`c7@-4Ym!oszxB`rVaG7N-)SjT4weDgS?AVd za4gt<`N@5*()ga2+M5=iOJKIln*Zy`fh)300vAv9HD0{)hK2jj>|JXwM|gF!>0OMF zWX#y-W4w6EbIz>}=UJn4mzl&L`!c&%F)P}6&D;M6e*G@KW08@^ztMAl_1XLkzK;ou z0@Xzqv>9#P>-Bei;L^U(O}nPOGIQ%mj{W*Ypxr l3@9*=JqQX61V{w>2y6@@Xac-h*+2?dfRG88X_tdN4FDO@D*ylh literal 0 HcmV?d00001 diff --git a/ajde/testdata/bug-40943/input2.jar b/ajde/testdata/bug-40943/input2.jar new file mode 100644 index 0000000000000000000000000000000000000000..c6305aa57b5d077a494e9929f413da447491b099 GIT binary patch literal 1471 zcmWIWW@Zs#-~dAB@_%{^NI-;vg~8V~#8KDN&rRRg(a+P(H8@1i*X`da28PeRXHNTg z>*`(P_14uocjo-&AcHH$51u}H%ES=h&Cao@p6Q)5&?reD4uD(WQif^)7f{wWF*8pu zIVZ8WI5*JO|B!<~tvB~lQAWpAKYG=VcnGhT(svV{+@&TU^f`z(jmfCsY@SeHb^Pio~*}w0;ec}U--#pJur#G@5n;`$e{T*-Rh3|P*%olrg zC3sc_OP=`Ab8v;+7SB4lZ!T<}OJrtv7(c0z>^N3(MKG|tysc^BgZ5avoX;Ms{`8wX zX183Jw{Mg6!Wx$o55nI6-I;6LmvX^A(C*yP;P9SgNw$#CD?*Z0;pYFhw2B5DO%l3( zJkVm^l0cP(r}m1qMn7^9@iyETQ1oC`;Mv3z)jUgIDV^rI78rJjSLoA<^*Q2ajwNL8 zW|MyzD$X${&7ybLqo7rLbGPQlt_*N&n&(r?Y4Ej4ME8`9liQ3nXA}0n%5G2cnp~+9 zc;*im$8^rzl!?lr^UkT=6)Bl*X2^M{_ttacH?s==G^He7{ohb+e)!fyX|v~hH-Guw zsPs_lltw21_w7>AH?DQ@lxaH8(iY_SIZH7=O1AA#Ud1VGjYUfq zH(0h+y0iRIcv)Uq@~Eu#+=dq|^In(V@mTS7N5lkqmoppQoC(OkxJ`c7@-4Ym!oszxB`rVaG7N-)SjT4weDgS?AVd za4gt<`N@5*()ga2+M5=iOJKIln*Zy`fh)300vAv9HD0{)hK2jj>|JXwM|gF!>0OMF zWX#y-W4w6EbIz>}=UJn4mzl&L`!c&%F)P}6&D;M6e*G@KW08@^ztMAl_1XLkzK;ou z0@Xzqv>9#P>-Bei;L^U(O}nPOGIQ%mj{W*Ypxr l3@9*=JqQX61V{w>2y6@@Xac-h*+2?dfRG88X_tdN4FDO@D*ylh literal 0 HcmV?d00001 diff --git a/ajde/testdata/bug-40943/output.jar b/ajde/testdata/bug-40943/output.jar new file mode 100644 index 0000000000000000000000000000000000000000..a5f38e68e1058c04447db42fa1223721653300ef GIT binary patch literal 3318 zcmaKvcQ71W+r}ljtP)ml5oK3zQ6eHj^s=i)v=DVYSnOIQL@XEt|mc?eI>9c z0`6hVs03yDX4};9l!&){;#|HWAkc~Ex<()18kPdRsoG*1br`g;#l@38;%?8Y%4)+k~YFVQR|Ky{>)}c6O>sJGg~u^-y)wLziz*= zOfLI~(Kf9Qqt-MaULw}$K!YCdqt1Y#k7FNUxvl2yq5!njG7r}0l&5kIV6(MZgnC*5 z28gO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0*@uO>SH-vIlF zB`4$INX3xaJ`h+4Wk?5EZRp#4vqfxuffICrm_EKM+r^1F3hIwhzof6;k#(YkRVSN9zx+j!H=d*My zr>B1J4tc9QaJNxQPn7AFiiJ%l=>Is*ODLR6>C$nlZFfsx$FtZ^;BLM+qlbl72lX^oj zlLAGV0Wq_jMM(jZ!7VbAKoTgEKS$32VY3fN9036}lMhH*liw*Klc-6j0yZ$SQA+Xw a0b!FNLlu*JJPMOq8XuF2N(!@#OeO?OrYBVZ delta 118 zcmV-+0Ez#yp#id?0kALu0T8n>0izEAGn3E_8nf>ZFfsx#X0stfBLM+plbl72lX^oj zlLAGV0Wh{DF6Tf 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"); + } + }; + +} -- 2.39.5