diff options
author | mkersten <mkersten> | 2003-08-06 21:17:57 +0000 |
---|---|---|
committer | mkersten <mkersten> | 2003-08-06 21:17:57 +0000 |
commit | 5edccbfaeb8bb4dc5b34d553267365ae3c7eda41 (patch) | |
tree | 7fe52f8582e5a0240443801f2003b09117b419de /ajde/testsrc | |
parent | 3b729301c726c44f028906ec53e518e2d3081e83 (diff) | |
download | aspectj-5edccbfaeb8bb4dc5b34d553267365ae3c7eda41.tar.gz aspectj-5edccbfaeb8bb4dc5b34d553267365ae3c7eda41.zip |
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
Diffstat (limited to 'ajde/testsrc')
-rw-r--r-- | ajde/testsrc/org/aspectj/ajde/AjdeTests.java | 1 | ||||
-rw-r--r-- | ajde/testsrc/org/aspectj/ajde/NullIdeManager.java | 5 | ||||
-rw-r--r-- | ajde/testsrc/org/aspectj/ajde/NullIdeProperties.java | 21 | ||||
-rw-r--r-- | ajde/testsrc/org/aspectj/ajde/ResourceCopyTestCase.java | 196 |
4 files changed, 220 insertions, 3 deletions
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"); + } + }; + +} |