aboutsummaryrefslogtreecommitdiffstats
path: root/build/testsrc
diff options
context:
space:
mode:
authorwisberg <wisberg>2003-04-23 08:35:40 +0000
committerwisberg <wisberg>2003-04-23 08:35:40 +0000
commit887932498cd5bd1c88f5849a1244caa36f280838 (patch)
tree42c5501acb8c33b2e3ac00be2516c01b21789a8c /build/testsrc
parentd850ca48e8696e82b319c5b17377d6f19df2b719 (diff)
downloadaspectj-887932498cd5bd1c88f5849a1244caa36f280838.tar.gz
aspectj-887932498cd5bd1c88f5849a1244caa36f280838.zip
ugh. updating XML .classpath parser to handle any number of attributes
still does not handle quoted spaces or nested entities. Also updated for new attribute names in 2.1?
Diffstat (limited to 'build/testsrc')
-rw-r--r--build/testsrc/BuildModuleTests.java2
-rw-r--r--build/testsrc/org/aspectj/internal/build/ModulesTest.java132
2 files changed, 134 insertions, 0 deletions
diff --git a/build/testsrc/BuildModuleTests.java b/build/testsrc/BuildModuleTests.java
index 9e7c5e857..828478f64 100644
--- a/build/testsrc/BuildModuleTests.java
+++ b/build/testsrc/BuildModuleTests.java
@@ -16,6 +16,7 @@
import org.aspectj.internal.tools.ant.taskdefs.Checklics;
import org.aspectj.internal.build.BuildModuleTest;
+import org.aspectj.internal.build.ModulesTest;
import java.io.File;
@@ -39,6 +40,7 @@ public class BuildModuleTests extends TestCase {
TestSuite suite = new TestSuite("Build module tests");
suite.addTestSuite(BuildModuleTests.class);
suite.addTestSuite(BuildModuleTest.class);
+ suite.addTestSuite(ModulesTest.class);
return suite;
}
diff --git a/build/testsrc/org/aspectj/internal/build/ModulesTest.java b/build/testsrc/org/aspectj/internal/build/ModulesTest.java
new file mode 100644
index 000000000..67b6d1a3e
--- /dev/null
+++ b/build/testsrc/org/aspectj/internal/build/ModulesTest.java
@@ -0,0 +1,132 @@
+/* *******************************************************************
+ * 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.internal.build;
+
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.taskdefs.Java;
+import org.apache.tools.ant.types.Path;
+import org.apache.tools.ant.types.Commandline.Argument;
+import org.aspectj.internal.tools.ant.taskdefs.AntBuilder;
+import org.aspectj.internal.tools.ant.taskdefs.BuildModule;
+import org.aspectj.internal.tools.build.Messager;
+import org.aspectj.internal.tools.build.Module;
+import org.aspectj.internal.tools.build.Modules;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import junit.framework.TestCase;
+/**
+ *
+ */
+public class ModulesTest extends TestCase {
+
+ private static boolean delete(File file) { // XXX Util
+ if ((null == file) || !file.exists()) {
+ return true;
+ }
+ if (file.isFile()) {
+ return file.delete();
+ } else {
+ File[] files = file.listFiles();
+ boolean result = true;
+ for (int i = 0; i < files.length; i++) {
+ if (!ModulesTest.delete(files[i])
+ && result) {
+ result = false;
+ }
+ }
+ return (file.delete() && result);
+ }
+ }
+
+ ArrayList tempFiles = new ArrayList();
+
+ public ModulesTest(String name) {
+ super(name);
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ for (Iterator iter = tempFiles.iterator(); iter.hasNext();) {
+ File file = (File) iter.next();
+ if (!ModulesTest.delete(file)) {
+ System.err.println("warning: ModulesTest unable to delete " + file);
+ }
+ }
+ }
+ Modules getModules(Messager handler) {
+ File jarDir = new File("../aj-build-test-jars");
+ if (!jarDir.exists()) {
+ assertTrue(jarDir.mkdirs());
+ tempFiles.add(jarDir);
+ }
+ File baseDir = new File("..");
+ if (null == handler) {
+ handler = new Messager();
+ }
+ return new Modules(baseDir, jarDir, true, handler);
+ }
+
+ public void testModuleCreation() {
+ Modules modules = getModules(null);
+ Module eclipse = modules.getModule("org.eclipse.jdt.core");
+ assertTrue(eclipse.valid);
+ }
+
+ public void testAllModulesCreation() {
+ File baseDir = new File("..");
+ File[] files = baseDir.listFiles();
+ for (int i = 0; i < files.length; i++) {
+ if (files[i].isDirectory()) {
+ File classpath = new File(files[i], ".classpath");
+ if (classpath.exists()) {
+ checkModule(files[i].getName());
+ }
+ }
+ }
+ }
+
+ void checkModule(String s) {
+ if ("docs".equals(s) || "lib".equals(s)) {
+ return;
+ }
+ Modules modules = getModules(null);
+ Module module = modules.getModule(s);
+ if (!module.valid) {
+ assertTrue(module.toString(), false);
+ }
+ }
+
+ public void testClasspathCreation() {
+ Modules modules = getModules(null);
+ Module ajdt = modules.getModule("org.aspectj.ajdt.core");
+ assertTrue(ajdt.valid);
+
+ Project project = new Project();
+ project.setBaseDir(new File("."));
+ project.setName("testClasspathCreation");
+ File tempDir = new File(".");
+ AntBuilder builder = (AntBuilder) AntBuilder.getBuilder("", project, tempDir);
+ Path classpath = new Path(project);
+ boolean hasLibraries = builder.setupClasspath(ajdt, classpath);
+ assertTrue(hasLibraries);
+ if ((null == classpath) || (2 > classpath.size())) {
+ assertTrue(classpath.toString(), false);
+ }
+ }
+
+
+}