aboutsummaryrefslogtreecommitdiffstats
path: root/build/src/test/java/org
diff options
context:
space:
mode:
authorAndy Clement <aclement@pivotal.io>2019-02-01 12:42:09 -0800
committerAndy Clement <aclement@pivotal.io>2019-02-01 12:42:09 -0800
commitaac7e58448f0e5a961075baca670dac1ae53ce98 (patch)
tree556fc80a0eee42b870de96bf6cbb41cc6fb452e4 /build/src/test/java/org
parent5eec03130695a6b918792ec7b87a2f69a20ed778 (diff)
downloadaspectj-aac7e58448f0e5a961075baca670dac1ae53ce98.tar.gz
aspectj-aac7e58448f0e5a961075baca670dac1ae53ce98.zip
mavenizing build - wip
Diffstat (limited to 'build/src/test/java/org')
-rw-r--r--build/src/test/java/org/aspectj/build/BuildModuleTests.java304
-rw-r--r--build/src/test/java/org/aspectj/internal/build/BuildClasspathTest.java67
-rw-r--r--build/src/test/java/org/aspectj/internal/build/BuildModuleTest.java468
-rw-r--r--build/src/test/java/org/aspectj/internal/build/ModulesTest.java304
-rw-r--r--build/src/test/java/org/aspectj/internal/tools/build/UtilsTest.01.MF8
-rw-r--r--build/src/test/java/org/aspectj/internal/tools/build/UtilsTest.02.MF9
-rw-r--r--build/src/test/java/org/aspectj/internal/tools/build/UtilsTest.03.MF9
-rw-r--r--build/src/test/java/org/aspectj/internal/tools/build/UtilsTest.java200
8 files changed, 1369 insertions, 0 deletions
diff --git a/build/src/test/java/org/aspectj/build/BuildModuleTests.java b/build/src/test/java/org/aspectj/build/BuildModuleTests.java
new file mode 100644
index 000000000..52510c75f
--- /dev/null
+++ b/build/src/test/java/org/aspectj/build/BuildModuleTests.java
@@ -0,0 +1,304 @@
+package org.aspectj.build;
+/* *******************************************************************
+ * 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 Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Xerox/PARC initial implementation
+ * ******************************************************************/
+
+
+// default package
+
+import org.aspectj.internal.tools.ant.taskdefs.Checklics;
+import org.aspectj.internal.tools.build.Builder;
+import org.aspectj.internal.tools.build.Util;
+import org.aspectj.internal.tools.build.UtilsTest;
+import org.aspectj.internal.build.BuildModuleTest;
+import org.aspectj.internal.build.ModulesTest;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import junit.framework.*;
+
+/**
+ * Master suite for build module
+ * and test of all source directories for correct licenses and known file types.
+ */
+public class BuildModuleTests extends TestCase {
+
+ /** if true, then replace old headers with new first */
+ private static final boolean replacing = false; // XXX never to enable again...
+
+ /** replace commented out below - if any replace failed, halt all */
+ private static boolean replaceFailed = false;
+
+ private static final String BASE_DIR = ".." + File.separator;
+ private static final String[] JDT_SOURCE_DIRS = new String[] {};
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite("Build module tests");
+ suite.addTestSuite(BuildModuleTests.class);
+ suite.addTestSuite(BuildModuleTest.class);
+ suite.addTestSuite(ModulesTest.class);
+ suite.addTestSuite(UtilsTest.class);
+ return suite;
+ }
+
+ /** @return String tag of license if not default */
+ public static String getLicense(String module) {
+ return null; // use permissive default
+ }
+
+ final static List<String> SOURCE_NAMES = Collections.unmodifiableList(
+ Arrays.asList(new String[]{"src", "testsrc", "java5-src", "java5-testsrc", "aspectj-src"}));
+
+ /**
+ * @param moduleDir
+ * @return
+ */
+ private static File[] findSourceRoots(File moduleDir) {
+ ArrayList<File> result = new ArrayList<File>();
+ for (String name: SOURCE_NAMES) {
+ File srcDir = new File(moduleDir, name);
+ if (srcDir.canRead() && srcDir.isDirectory()) {
+ result.add(srcDir);
+ }
+ }
+ return (File[]) result.toArray(new File[0]);
+ }
+
+ public BuildModuleTests(String name) { super(name); }
+
+ public void testSuffixList() {
+ if (!UnknownFileCheck.STATIC_ERRORS.isEmpty()) {
+ fail("" + UnknownFileCheck.STATIC_ERRORS);
+ }
+ }
+ public void testLicense_ajbrowser() {
+ checkLicense("ajbrowser");
+ }
+ public void testLicense_ajde() {
+ checkLicense("ajde");
+ }
+ public void testLicense_aspectj5rt() {
+ checkLicense("aspectj5rt");
+ }
+ public void testLicense_asm() {
+ checkLicense("asm");
+ }
+
+ public void testLicense_bridge() {
+ checkLicense("bridge");
+ }
+ public void testLicense_build() {
+ checkLicense("build");
+ }
+ public void testLicense_org_aspectj_ajdt_core() {
+ checkLicense("org.aspectj.ajdt.core");
+ }
+ public void testLicense_org_aspectj_lib() {
+ checkLicense("org.aspectj.lib");
+ }
+ public void testLicense_org_eclipse_jdt_core() {
+ final String mod = "org.eclipse.jdt.core";
+ final String pre = BASE_DIR + mod + File.separator;
+ for (int i = 0; i < JDT_SOURCE_DIRS.length; i++) {
+ checkSourceDirectory(new File(pre + JDT_SOURCE_DIRS[i]), mod);
+ }
+ }
+
+ public void testLicense_runtime() {
+ checkLicense("runtime");
+ }
+ public void testLicense_taskdefs() {
+ checkLicense("taskdefs");
+ }
+ public void testLicense_testing() {
+ checkLicense("testing");
+ }
+ public void testLicense_testing_client() {
+ checkLicense("testing-client");
+ }
+ public void testLicense_testing_drivers() {
+ checkLicense("testing-drivers");
+ }
+ public void testLicense_testing_util() {
+ checkLicense("testing-util");
+ }
+ public void testLicense_util() {
+ checkLicense("util");
+ }
+ public void testLicense_weaver() {
+ String module = "weaver";
+ // skip (testdata) packages fluffy, reflect
+ checkSourceDirectory(new File(Util.path(new String[] {"..", module, "src"})), module);
+ checkSourceDirectory(new File(Util.path(new String[] {"..", module, "testsrc", "org"})), module);
+ }
+
+ public void testLicense_ajdoc() {
+ checkLicense("ajdoc");
+ }
+
+ public void testLicense_loadtime() {
+ checkLicense("loadtime");
+ }
+
+ public void testLicense_loadtime5() {
+ checkLicense("loadtime5");
+ }
+
+ public void testLicense_weaver5() {
+ checkLicense("weaver5");
+ }
+
+ void checkLicense(String module) {
+ File moduleDir = new File(Util.path("..", module));
+ File[] srcDirs = findSourceRoots(moduleDir);
+ for (int i = 0; i < srcDirs.length; i++) {
+ checkSourceDirectory(srcDirs[i], module);
+ }
+ }
+
+ void checkSourceDirectory(File srcDir, String module) {
+ final String label = "source dir " + srcDir + " (module " + module + ")";
+ assertTrue(label, (srcDir.exists() && srcDir.isDirectory()));
+ String license = getLicense(module);
+// if (replacing) {
+// if (replacing && true) {
+// throw new Error("replacing done - code left for other replaces");
+// }
+// assertTrue("aborting - replace failed", !replaceFailed);
+// // do the replace
+// int fails = Checklics.runDirect(moduleDir.getPath(), "replace-headers");
+// replaceFailed = (0 != fails);
+// assertTrue(!replaceFailed);
+// license = Checklics.CPL_IBM_PARC_XEROX_TAG;
+// }
+ int fails = Checklics.runDirect(srcDir.getPath(), license, true);
+ if (0 != fails) {
+ if (replacing) {
+ BuildModuleTests.replaceFailed = true;
+ }
+ assertTrue(label + " fails", !BuildModuleTests.replaceFailed);
+ }
+
+ // separate check to verify all file types (suffixes) are known
+ if (!"testsrc".equals(srcDir.getName())) {
+ ArrayList<File> unknownFiles = new ArrayList<File>();
+ UnknownFileCheck.SINGLETON.unknownFiles(srcDir, unknownFiles);
+ if (!unknownFiles.isEmpty()) {
+ String s = "unknown files (see readme-build-module.html to "
+ + "update Builder.properties resource patterns): ";
+ fail(s + unknownFiles);
+ }
+ }
+ }
+ /**
+ * Check tree for files not managed by the build system
+ * (either source files or managed as resources).
+ * This should pick up situations where new kinds of resources are added
+ * to the tree without updating the build script patterns to pick them
+ * up.
+ * @see Builder#BINARY_SOURCE_PATTERN
+ * @see Builder#RESOURCE_PATTERN
+ * @see org.aspectj.util.FileUtil#SOURCE_SUFFIXES
+ */
+ static class UnknownFileCheck implements FileFilter {
+ private static final UnknownFileCheck SINGLETON = new UnknownFileCheck();
+ private static final ArrayList<String> STATIC_ERRORS = new ArrayList<String>();
+ // Builder.BINARY_SOURCE_PATTERN and Builder.RESOURCE_PATTERN
+ public static final List<String> KNOWN_SUFFIXES;
+
+ static {
+ List<String> suffixes = new ArrayList<String>();
+ // sources from org.aspectj.util.FileUtil.SOURCE_SUFFIXES
+ suffixes.add(".aj");
+ suffixes.add(".java");
+
+ // just because we know...
+ suffixes.add(".html");
+
+ // others from Builder
+ final String input = Builder.BINARY_SOURCE_PATTERN
+ + "," + Builder.RESOURCE_PATTERN;
+ StringTokenizer st = new StringTokenizer(input, ",");
+ while (st.hasMoreTokens()) {
+ String token = st.nextToken().trim();
+ if (0 == token.length()) {
+ continue;
+ }
+ if (token.startsWith("**/*.")) {
+ token = token.substring(4);
+ } else if (token.startsWith("*.")) {
+ token = token.substring(1);
+ } else {
+ String s = input + " at \"" + token + "\"";
+ STATIC_ERRORS.add("unable to read pattern: " + s);
+ }
+ suffixes.add(token);
+ }
+ KNOWN_SUFFIXES = Collections.unmodifiableList(suffixes);
+ }
+
+ private UnknownFileCheck() {
+
+ }
+ /**
+ * Return true if input File file is a valid path to a directory
+ * or to a file
+ * which is not hidden (starts with .)
+ * and does not have a known suffix.
+ * Caller is responsible for pruning CVS directories
+ * @return true iff unknown or a directory
+ */
+ public boolean accept(File file) {
+ if (null == file) {
+ return false;
+ }
+ if (file.isDirectory()) {
+ return file.canRead();
+ }
+
+ String name = file.getName();
+ if ("CVS".equals(name) || name.startsWith(".")) {
+ return false;
+ }
+ // to do not accepting uppercase suffixes...
+ for (String suffix: KNOWN_SUFFIXES) {
+ if (name.endsWith(suffix)) {
+ return false;
+ }
+ }
+ return true;
+
+ }
+ void unknownFiles(File dir, ArrayList<File> results) {
+ File[] files = dir.listFiles(this);
+ for (int j = 0; j < files.length; j++) {
+ File file = files[j];
+ if (file.isDirectory()) {
+ String name = file.getName();
+ if (!("CVS".equals(name))) {
+ unknownFiles(file, results);
+ }
+ } else {
+ results.add(file);
+ }
+ }
+ }
+
+ }
+}
+
diff --git a/build/src/test/java/org/aspectj/internal/build/BuildClasspathTest.java b/build/src/test/java/org/aspectj/internal/build/BuildClasspathTest.java
new file mode 100644
index 000000000..b8cb4b896
--- /dev/null
+++ b/build/src/test/java/org/aspectj/internal/build/BuildClasspathTest.java
@@ -0,0 +1,67 @@
+/* *******************************************************************
+ * Copyright (c) 2005 Contributors.
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wes Isberg initial implementation
+ * ******************************************************************/
+
+
+package org.aspectj.internal.build;
+
+import java.io.File;
+
+import junit.framework.TestCase;
+
+import org.aspectj.internal.tools.build.Messager;
+import org.aspectj.internal.tools.build.Module;
+import org.aspectj.internal.tools.build.Modules;
+import org.aspectj.internal.tools.build.Result;
+import org.aspectj.internal.tools.build.Result.Kind;
+
+public class BuildClasspathTest extends TestCase {
+
+ public void testKindsGet() {
+ Kind kind = Result.kind(Result.NORMAL, Result.ASSEMBLE);
+ same(kind, "RELEASE_ALL");
+ kind = Result.kind(Result.NORMAL, !Result.ASSEMBLE);
+ same(kind, "RELEASE");
+ kind = Result.kind(!Result.NORMAL, Result.ASSEMBLE);
+ same(kind, "TEST_ALL");
+ kind = Result.kind(!Result.NORMAL, !Result.ASSEMBLE);
+ same(kind, "TEST");
+ }
+ private void same(Kind kind, String name) {
+ if (!name.equals(kind.toString())) {
+ fail("expected \"" + name + "\" got \"" + kind + "\"");
+ }
+ }
+ public void testClasspath() {
+ Messager handler = new Messager();
+ File baseDir = new File("..");
+ File jarDir = new File("../aj-build/jars");
+ Modules modules = new Modules(baseDir, jarDir, handler);
+ Module module = modules.getModule("ajbrowser");
+ Kind kind = Result.kind(Result.NORMAL, !Result.ASSEMBLE);
+ Result result = module.getResult(kind);
+ print(result);
+ }
+ public void testBuildClasspath() {
+ Messager handler = new Messager();
+ File baseDir = new File("..");
+ File jarDir = new File("../aj-build/jars");
+ Modules modules = new Modules(baseDir, jarDir, handler);
+ Module module = modules.getModule("build");
+ Kind kind = Result.kind(Result.NORMAL, !Result.ASSEMBLE);
+ Result result = module.getResult(kind);
+ print(result);
+ }
+ private void print(Result result) {
+ System.out.println(result + " libjars" + result.getLibJars());
+ System.out.println(result + " required" + result.getRequired());
+ }
+}
diff --git a/build/src/test/java/org/aspectj/internal/build/BuildModuleTest.java b/build/src/test/java/org/aspectj/internal/build/BuildModuleTest.java
new file mode 100644
index 000000000..bc96bef6a
--- /dev/null
+++ b/build/src/test/java/org/aspectj/internal/build/BuildModuleTest.java
@@ -0,0 +1,468 @@
+/* *******************************************************************
+ * Copyright (c) 1999-2001 Xerox Corporation,
+ * 2002 Palo Alto Research Center, Incorporated (PARC),
+ * 2005-2006 Contributors.
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Xerox/PARC initial implementation
+ * ******************************************************************/
+
+package org.aspectj.internal.build;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipException;
+import java.util.zip.ZipFile;
+
+import junit.framework.TestCase;
+
+import org.apache.tools.ant.BuildException;
+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.BuildModule;
+import org.aspectj.internal.tools.ant.taskdefs.Checklics;
+import org.aspectj.internal.tools.build.Util;
+
+/**
+ * Test our integrated taskdef build.
+ * This responds to two environment variables:
+ * (1) run.build.tests must be defined before
+ * tests that build the tree (and hence take minutes)
+ * will run;
+ * (2) build.config takes the same form as it does for the
+ * builder task, e.g., "useEclipseCompiles" will avoid
+ * recompiling with Javac and adopt classes in the
+ * {module}/bin directories.
+ */
+public class BuildModuleTest extends TestCase {
+
+ private static boolean printInfoMessages = false;
+ private static boolean printedMessage;
+ private static final boolean REMOVE_JARS_AFTER_DEBUGGING = true;
+ // to just build one module verbosely
+ private static final String[] DEBUGS
+ = {};
+
+ // skip those requiring ajdoc, which requires tools.jar
+ // also skip those requiring java5 unless manually set up
+ // also skip big ones to avoid slowing the build too much
+ private static final String[] SKIPS
+ //= {};
+ = {"aspectjtools", "ajdoc", "aspectj5rt", "run-all-junit-tests",
+ "ajbrowser", "testing", "testing-drivers", "org.aspectj.ajdt.core", "weaver"};
+
+ private static final String SKIP_MESSAGE =
+ "BuildModuleTest: Define \"run.build.tests\" as a system "
+ + "property to run tests to build ";
+ private static final String BUILD_CONFIG;
+ static {
+ String config = null;
+ try {
+ config = System.getProperty("build.config");
+ } catch (Throwable t) {
+ // ignore
+ }
+ BUILD_CONFIG = config;
+ if (printInfoMessages) {
+ System.out.println("BuildModuleTest build.config: " + config);
+ }
+ }
+
+ ArrayList<File> tempFiles = new ArrayList<File>();
+ private File jarDir;
+ private boolean deleteJars;
+ boolean building; // must be enabled for tests to run
+
+ public BuildModuleTest(String name) {
+ super(name);
+ building = Boolean.getBoolean("run.build.tests");
+ }
+ protected void setUp() {
+ // change to view whether prior output is used
+ deleteJars = true; // todo
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ if (debugging() && !REMOVE_JARS_AFTER_DEBUGGING) {
+ if (0 < tempFiles.size()) {
+ System.err.println("debugging files left: " + tempFiles);
+ }
+ return;
+ }
+ deleteTempFiles();
+ }
+
+ protected void deleteTempFiles() {
+ for (Iterator iter = tempFiles.iterator(); iter.hasNext();) {
+ File file = (File) iter.next();
+ if (!Util.delete(file)) {
+ File[] list = file.listFiles();
+ if (!Util.isEmpty(list)) {
+ StringBuffer sb = new StringBuffer();
+ sb.append("warning: BuildModuleTest unable to delete ");
+ sb.append(file.toString());
+ sb.append("\n"); // XXX platform
+ for (int i = 0; i < list.length; i++) {
+ sb.append(" ");
+ sb.append(list[i].toString());
+ sb.append("\n"); // XXX platform
+ }
+ System.err.println(sb.toString());
+ }
+ }
+ }
+ }
+
+ public void testAllJunitTests() {
+ checkBuild("run-all-junit-tests");
+ }
+
+ public void testBuild() {
+ checkBuild("build",
+ Checklics.class.getName(),
+ new String[0], // help message
+ true); // ant needed
+ }
+
+ public void testUtil() {
+ checkBuild("util");
+ }
+
+ public void testAsm() {
+ checkBuild("asm");
+ }
+
+ public void testRuntime() {
+ checkBuild("runtime");
+ }
+
+ public void testAspectj5rt() {
+ checkBuild("aspectj5rt");
+ }
+
+// public void testLocalOutOfDate() {
+// Messager handler = new Messager();
+// File jarDir = new File("c:/home/ws/head/aj-build/jars");
+// File baseDir = new File("c:/home/ws/head");
+// Modules mods = new Modules(baseDir, jarDir, handler);
+// Module module = mods.getModule("ajbrowser");
+// Result r = module.getResult(Result.kind(true, true));
+// r.outOfDate();
+// }
+// public void testAspectj5rtRequired() {
+// File baseDir = new File("..");
+// Modules modules = new Modules(baseDir, getJarDir(), new Messager());
+// Module module = modules.getModule("aspectj5rt");
+// Result result = module.getResult(Result.kind(true, true));
+// Result[] results = result.getRequired();
+// System.out.println(result.toLongString());
+// System.out.println("results: " + Arrays.asList(results));
+// deleteTempFiles();
+// }
+ public void testNoDuplicates() {
+ File weaverAllJar = null;
+ try {
+ weaverAllJar = doTask("weaver",true, true, true);
+ } catch (Throwable t) {
+ System.err.println(getClass() + ".testNoDuplicates() incomplete");
+ t.printStackTrace(System.err);
+ return;
+ }
+ String dupError = duplicateEntryError(weaverAllJar);
+ weaverAllJar.delete();
+ if (null != dupError) {
+ fail(dupError);
+ }
+ }
+ public void testAjbrowser() {
+ checkBuild("ajbrowser",
+ "org.aspectj.tools.ajbrowser.Main",
+ new String[] {"-noExit", "-version"}); // compiler version
+ }
+ public void testTestingUtils() {
+ checkBuild("testing-util");
+ }
+
+ public void testAjdt() {
+ checkBuild("org.aspectj.ajdt.core",
+ "org.aspectj.tools.ajc.Main",
+ new String[] { "-noExit", "-version" });
+ }//
+ public void testTesting() {
+ checkBuild("testing",
+ "org.aspectj.testing.util.LangUtilTest",
+ new String[] {"ignored"});
+ }
+ public void testTestingDrivers() {
+ checkBuild("testing-drivers",
+ "org.aspectj.testing.drivers.Harness",
+ new String[] {"-help"});
+ }
+ public void testWeaver() {
+ checkBuild("weaver");
+ }
+
+ // ajdoc relies on tools.jar
+ public void testAspectjtools() {
+ if (!shouldBuild("aspectjtools")) {
+ return;
+ }
+ File baseDir = new File("..");
+ File tempBuildDir = new File(baseDir, "aj-build");
+ File distDir = new File(tempBuildDir, "dist");
+ File jarDir = new File(tempBuildDir, "jars");
+ assertTrue(distDir.canWrite() || distDir.mkdirs());
+ File productDir = new File(baseDir.getPath() + "/build/products/tools");
+ assertTrue(""+productDir, productDir.canRead());
+ checkBuildProduct(productDir, baseDir, distDir, jarDir);
+ }
+
+ void checkBuildProduct(File productDir, File baseDir, File distDir, File jarDir) {
+ if (!shouldBuild(productDir.getPath())) {
+ return;
+ }
+ assertTrue(null != productDir);
+ assertTrue(productDir.canRead());
+
+ checkJavac();
+
+ BuildModule task = new BuildModule();
+ Project project = new Project();
+ task.setProject(project);
+ assertTrue(jarDir.canWrite() || jarDir.mkdirs());
+ tempFiles.add(jarDir);
+ task.setJardir(new Path(project, jarDir.getAbsolutePath()));
+ task.setProductdir(new Path(project, productDir.getAbsolutePath()));
+ task.setBasedir(new Path(project, baseDir.getAbsolutePath()));
+ task.setDistdir(new Path(project, distDir.getAbsolutePath()));
+ task.setFailonerror(true);
+ if (null != BUILD_CONFIG) {
+ task.setBuildConfig(BUILD_CONFIG);
+ }
+ //task.setVerbose(true);
+ task.setCreateinstaller(true);
+ task.execute();
+ // now run installer and do product tests?
+ }
+
+ File getAntJar() {
+ return new File("../lib/ant/lib/ant.jar");
+ }
+ File getJUnitJar() {
+ return new File("../lib/junit/junit.jar");
+ }
+
+ File getJarDir() {
+ if (null == jarDir) {
+ File baseDir = new File("../aj-build/");
+ if (!baseDir.canWrite()) {
+ baseDir = new File(".");
+ }
+ jarDir = new File(baseDir, "BuildModuleTest-jars");
+ tempFiles.add(jarDir);
+ }
+ if (!jarDir.exists()) {
+ assertTrue(jarDir.mkdirs());
+ }
+ return jarDir;
+ }
+
+ BuildModule getTask(String module) {
+ BuildModule task = new BuildModule();
+ Project project = new Project();
+ task.setProject(project);
+ File jarDir = getJarDir();
+ assertTrue(jarDir.canWrite() || jarDir.mkdirs());
+ tempFiles.add(jarDir);
+ File moduleDir = new File(Util.path("..", module));
+ assertTrue(moduleDir.canRead());
+ task.setModuledir(new Path(project, moduleDir.getAbsolutePath()));
+ task.setJardir(new Path(project, jarDir.getAbsolutePath()));
+ task.setFailonerror(true);
+ if (null != BUILD_CONFIG) {
+ task.setBuildConfig(BUILD_CONFIG);
+ }
+ return task;
+ }
+
+ void checkBuild(String module) {
+ checkBuild(module, null, null, false);
+ }
+
+ void checkBuild(String module,
+ String classname,
+ String[] args) {
+ checkBuild(module, classname, args, true);
+ }
+
+ boolean shouldBuild(String target) {
+ if (null == target) {
+ return false;
+ }
+ if (!building && !printedMessage) {
+ System.err.println(SKIP_MESSAGE + target + " (this is the only warning)");
+ printedMessage = true;
+ }
+ if (debugging()) {
+ for (int i = 0; i < DEBUGS.length; i++) {
+ if (target.equals(DEBUGS[i])) {
+ return true;
+ }
+ }
+ return false;
+ } else {
+ for (int i = 0; i < SKIPS.length; i++) {
+ if (SKIPS[i].equals(target)) {
+ if (printInfoMessages) {
+ System.err.println(target + " skipped build test [" + getClass().getName() + ".shouldBuild(..)]");
+ }
+ return false;
+ }
+ }
+ }
+ return building;
+ }
+ private static boolean debugging() {
+ return ((null != DEBUGS) && (0 < DEBUGS.length));
+ }
+ private static String duplicateEntryError(File weaverAllJar) {
+ ZipFile zipFile = null;
+ try {
+ zipFile = new ZipFile(weaverAllJar);
+ Enumeration e = zipFile.entries();
+ ArrayList<String> entryNames = new ArrayList<String>();
+ while (e.hasMoreElements()) {
+ ZipEntry entry = (ZipEntry) e.nextElement();
+ String name = entry.getName();
+ if (entryNames.contains(name)) {
+ return "duplicate entry: " + name;
+ }
+ entryNames.add(name);
+ }
+ } catch (ZipException e) {
+ return "ZipException " + e;
+ } catch (IOException e) {
+ return "IOException " + e;
+ } finally {
+ if (null != zipFile) {
+ try {
+ zipFile.close();
+ } catch (IOException e) {
+ return "IOException closing " + zipFile + ": " + e;
+ }
+ }
+ }
+ return null;
+ }
+
+ private static String name(String module, boolean trimTesting, boolean assemble) {
+ return module + (trimTesting?"":"-test") + (assemble?"-all":"");
+ }
+ private void deleteJar(File jar) {
+ if (!deleteJars) {
+ return ;
+ }
+ if (jar.exists()) {
+ jar.delete();
+ }
+ if (jar.exists()) {
+ try {
+ Thread.sleep(5000);
+ } catch (Throwable t) {
+ }
+ }
+ if (jar.exists()) {
+ assertTrue("cannot delete " + jar, jar.delete());
+ }
+ }
+ void checkBuild(String module,
+ String classname,
+ String[] args,
+ boolean addAnt) {
+ if (!shouldBuild(module)) {
+ return;
+ }
+ assertTrue(null != module);
+ checkJavac();
+ doTask(module, true, false);
+ doTask(module, true, true);
+ doTask(module, false, false);
+ File jar = doTask(module, false, true, true);
+
+ // verify if possible
+ if (null != classname) {
+ Java java = new Java();
+ Project project = new Project();
+ java.setProject(project);
+ java.setFailonerror(true);
+ Path cp = new Path(project);
+ assertTrue(jar.canRead());
+ cp.append(new Path(project, jar.getAbsolutePath()));
+ if (addAnt) {
+ cp.append(new Path(project, getAntJar().getAbsolutePath()));
+ cp.append(new Path(project, getJUnitJar().getAbsolutePath()));
+ }
+ java.setClasspath(cp);
+ java.setClassname(classname);
+ if (null != args) {
+ for (int i = 0; i < args.length; i++) {
+ Argument arg = java.createArg();
+ arg.setValue(args[i]);
+ }
+ }
+ try {
+ java.execute();
+ } catch (BuildException e) {
+ e.printStackTrace(System.err);
+ assertTrue("BuildException running " + classname, false);
+ }
+ }
+ deleteJar(jar);
+ }
+ void doTask(String module, boolean trimTesting, boolean assembleAll) {
+ doTask(module, trimTesting, assembleAll, false);
+ }
+
+ File doTask(String module, boolean trimTesting, boolean assembleAll, boolean keepJars) {
+ BuildModule task = getTask(module);
+ String name = name(module, trimTesting, assembleAll);
+ File jar = new File(getJarDir(), name+ ".jar");
+ task.setAssembleall(assembleAll);
+ task.setTrimtesting(trimTesting);
+ task.execute();
+ if (!jar.canRead()) {
+ File[] files = getJarDir().listFiles();
+ fail("cannot read " + jar + " in " + Arrays.asList(files));
+ }
+ if (!keepJars && deleteJars) {
+ deleteTempFiles();
+ }
+ return jar;
+ }
+
+ void checkJavac() {
+ boolean result = false;
+ try {
+ result = (null != Class.forName("sun.tools.javac.Main"));
+ } catch (Throwable t) {
+ // ignore
+ }
+ if (! result) {
+ assertTrue("add tools.jar to the classpath for Ant's use of javac", false);
+ }
+ }
+
+}
diff --git a/build/src/test/java/org/aspectj/internal/build/ModulesTest.java b/build/src/test/java/org/aspectj/internal/build/ModulesTest.java
new file mode 100644
index 000000000..16786404c
--- /dev/null
+++ b/build/src/test/java/org/aspectj/internal/build/ModulesTest.java
@@ -0,0 +1,304 @@
+/* *******************************************************************
+ * Copyright (c) 1999-2001 Xerox Corporation,
+ * 2002 Palo Alto Research Center, Incorporated (PARC),
+ * 2005-2006 Contributors.
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Xerox/PARC initial implementation
+ * Wes Isberg build tests
+ * ******************************************************************/
+
+package org.aspectj.internal.build;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.apache.tools.ant.BuildEvent;
+import org.apache.tools.ant.BuildListener;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.types.Path;
+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 org.aspectj.internal.tools.build.Result;
+import org.aspectj.internal.tools.build.Util;
+import org.aspectj.internal.tools.build.Result.Kind;
+/**
+ *
+ */
+public class ModulesTest extends TestCase {
+ public static final List<String> MODULE_NAMES;
+ private static final File BASE_DIR = new File("..");
+ static {
+ String[] names = {
+ "ajbrowser", "ajde", "ajdoc", "asm", "aspectj5rt",
+ "bridge", "loadtime", "loadtime5", "org.aspectj.ajdt.core",
+ "runtime", "taskdefs", "testing-client", "testing-util",
+ "tests", "util", "weaver"};
+ List<String> list = Arrays.asList(names);
+ MODULE_NAMES = Collections.unmodifiableList(list);
+ }
+
+ 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<File> tempFiles = new ArrayList<File>();
+
+ public ModulesTest(String name) {
+ super(name);
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ for (Iterator<File> 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, handler);
+ }
+
+ public void testAllModulesCreation() {
+ ArrayList<Module> badModules = new ArrayList<Module>();
+ for (String name: MODULE_NAMES) {
+ File dir = new File(BASE_DIR, name);
+ if (dir.isDirectory()) {
+ File classpath = new File(dir, ".classpath");
+ if (classpath.exists()) {
+ Modules modules = getModules(null);
+ Module module = modules.getModule(name);
+ if (!module.valid) {
+ badModules.add(module);
+ }
+ }
+ }
+ }
+ if (!badModules.isEmpty()) {
+ StringBuffer sb = new StringBuffer();
+ for (Module module: badModules) {
+ System.err.println(module.toLongString());
+ sb.append("\n");
+ sb.append(module);
+ }
+ fail(sb.toString());
+ }
+ }
+
+ 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.toLongString(), false);
+ }
+ }
+
+ public void testClasspathCreation() {
+ Modules modules = getModules(null);
+ Module ajdt = modules.getModule("org.aspectj.ajdt.core");
+ assertTrue(ajdt.valid);
+
+ Project project = new Project();
+ AntBuilder builder = getBuilder(project);
+ Path classpath = new Path(project);
+ Kind kind = Result.kind(Result.NORMAL, !Result.ASSEMBLE);
+ Result result = ajdt.getResult(kind);
+ boolean hasLibraries = builder.setupClasspath(result, classpath);
+ assertTrue(hasLibraries);
+ if ((null == classpath) || (2 > classpath.size())) {
+ assertTrue(classpath.toString(), false);
+ }
+ }
+
+ /**
+ * This test requires two OSGI modules:
+ * org.aspectj.util, which optionally depends on tempaspectjrt.
+ * Currently, the Ant builder does not handle linked source folders,
+ * and the OSGI support does not work around optional plugins.
+ */
+ public void skip_testOSGIModuleCreation() {
+ final String MODULE = "org.aspectj.util";
+ final String USES_MODULE = "tempaspectjrt";
+
+ Modules modules = getModules(null);
+ Module newutil = modules.getModule(MODULE);
+ assertTrue(newutil.valid);
+
+ Project project = new Project();
+ AntBuilder builder = getBuilder(project);
+ Path classpath = new Path(project);
+ Kind kind = Result.kind(Result.NORMAL, !Result.ASSEMBLE);
+ Result result = newutil.getResult(kind);
+ builder.setupClasspath(result, classpath);
+ System.out.println(newutil + " classpath: " + classpath);
+ if ((1 != classpath.size())) {
+ assertTrue(classpath.toString(), false);
+ }
+ String cpEntry = classpath.list()[0];
+ if (!cpEntry.endsWith(USES_MODULE + ".jar")) {
+ fail("expected " + classpath + " to end with " + USES_MODULE + ".jar");
+ }
+ }
+
+ private AntBuilder getBuilder(Project project) {
+ project.setBaseDir(new File("."));
+ project.setName("testOSGIModuleCreation");
+ File tempDir = new File(".");
+ return (AntBuilder) AntBuilder.getBuilder("", project, tempDir);
+ }
+
+
+ /*********************************************************************
+ * The following tests/code enable you to run the entire build in JUnit
+ * to debug directly from Eclipse. To compile using Javac, you will
+ * need to add tools.jar to the run classpath.
+ */
+ public void skip_testBuildingAspectJModule() {
+ final String moduleName = "org.aspectj.lib";
+
+ File modulesDir = new File("..").getAbsoluteFile();
+ File buildDir = new File(modulesDir, "aj-build");
+ File distDir = new File(buildDir, "dist");
+ File jarDir = new File(buildDir, "jars");
+ File moduleDir = new File(modulesDir, moduleName);
+ File jar = new File(jarDir, "org.aspectj.lib.jar");
+ jarDir.mkdirs();
+ distDir.mkdirs();
+ if (jar.canRead()) {
+ assertTrue(jar.delete());
+ }
+ Project project = new Project();
+ project.setBaseDir(modulesDir);
+ project.setName("testAspectjbuild");
+
+ BuildModule bm = new BuildModule();
+ bm.setProject(project);
+ bm.setAssembleall(true);
+ bm.setBuildConfig("");
+ bm.setModule(moduleName);
+ bm.setBasedir(new Path(project, modulesDir.getPath()));
+ bm.setDistdir(new Path(project, buildDir.getPath()));
+ bm.setJardir(new Path(project, jarDir.getPath()));
+ bm.setModuledir(new Path(project, moduleDir.getPath()));
+ bm.setTrimtesting(true);
+ bm.setBuildConfig("");
+ bm.setVersion("1.2");
+ bm.setVerbose(true);
+ bm.setFailonerror(true);
+
+ bm.execute();
+
+ assertTrue(jar.canRead());
+ }
+
+ public void skip_testBuildingProduct() {
+ final String productName = "tools";
+ File modulesDir = new File("..").getAbsoluteFile();
+ File buildDir = new File(modulesDir, "aj-build");
+ File distDir = new File(buildDir, "dist");
+ File jarDir = new File(buildDir, "jars");
+ File productDir = new File(modulesDir,
+ Util.path(new String[] {"build", "products", productName}));
+
+ jarDir.mkdirs();
+ distDir.mkdirs();
+
+ Project project = new Project();
+ project.setBaseDir(modulesDir);
+ project.setName("testAspectjToolsbuild");
+ project.addBuildListener(new EventBuildListener(Project.MSG_WARN));
+
+ BuildModule bm = new BuildModule();
+ bm.setProject(project);
+ bm.setAssembleall(true);
+ bm.setBuildConfig("");
+ bm.setProductdir(new Path(project, productDir.getPath()));
+ bm.setBasedir(new Path(project, modulesDir.getPath()));
+ bm.setDistdir(new Path(project, distDir.getPath()));
+ bm.setJardir(new Path(project, jarDir.getPath()));
+ bm.setTrimtesting(true);
+ bm.setBuildConfig("");
+ bm.setVersion("1.2");
+ bm.setFailonerror(true);
+ bm.execute();
+
+ File libDir = new File(distDir, "tools/lib");
+ String[] jars = { "tools", "rt", "weaver", "lib"};
+ for (int i = 0; i < jars.length; i++) {
+ File jar = new File(libDir, "aspectj" + jars[i] + ".jar");
+ assertTrue(jar.getPath(), jar.canRead());
+ if (10 > jar.length()) {
+ assertTrue(jar + " too small", false);
+ }
+ }
+ }
+ /**
+ * Show messages from the task.
+ * (normally shown by Ant's default listener)
+ */
+ static class EventBuildListener implements BuildListener {
+ final int min;
+ EventBuildListener(int min) {
+ this.min = min;
+ }
+ public void buildFinished(BuildEvent event) {}
+ public void buildStarted(BuildEvent event) { }
+ public void messageLogged(BuildEvent event) {
+ if (min <= event.getPriority()) {
+ Task t = event.getTask();
+ String src = (null == t ? "project" : t.getTaskName());
+ System.out.println(src + ": " + event.getMessage());
+ }
+ }
+ public void targetFinished(BuildEvent event) { }
+ public void targetStarted(BuildEvent event) { }
+ public void taskFinished(BuildEvent event) { }
+ public void taskStarted(BuildEvent event) { }
+
+ }
+
+}
diff --git a/build/src/test/java/org/aspectj/internal/tools/build/UtilsTest.01.MF b/build/src/test/java/org/aspectj/internal/tools/build/UtilsTest.01.MF
new file mode 100644
index 000000000..e3ba88396
--- /dev/null
+++ b/build/src/test/java/org/aspectj/internal/tools/build/UtilsTest.01.MF
@@ -0,0 +1,8 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Client Plug-in
+Bundle-SymbolicName: org.aspectj.testing.client
+Bundle-Version: 1.0.0
+Bundle-Localization: plugin
+Bundle-ClassPath: lib/commons/commons.jar
+
diff --git a/build/src/test/java/org/aspectj/internal/tools/build/UtilsTest.02.MF b/build/src/test/java/org/aspectj/internal/tools/build/UtilsTest.02.MF
new file mode 100644
index 000000000..5888ab3c0
--- /dev/null
+++ b/build/src/test/java/org/aspectj/internal/tools/build/UtilsTest.02.MF
@@ -0,0 +1,9 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Client Plug-in
+Bundle-SymbolicName: org.aspectj.testing.client
+Bundle-Version: 1.0.0
+Bundle-Localization: plugin
+Bundle-ClassPath: lib/commons/commons.jar, lib/ant/lib/ant.jar
+Require-Bundle: util, org.aspectj.runtime
+
diff --git a/build/src/test/java/org/aspectj/internal/tools/build/UtilsTest.03.MF b/build/src/test/java/org/aspectj/internal/tools/build/UtilsTest.03.MF
new file mode 100644
index 000000000..b9717c5f2
--- /dev/null
+++ b/build/src/test/java/org/aspectj/internal/tools/build/UtilsTest.03.MF
@@ -0,0 +1,9 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Client Plug-in
+Bundle-SymbolicName: org.aspectj.testing.client
+Bundle-Version: 1.0.0
+Bundle-Localization: plugin
+Bundle-ClassPath: lib/commons/commons.jar, lib/ant/lib/ant.jar
+Require-Bundle: util, aspectjrt;bundle-version="[1.5.0,1.5.5]";resolution:=optional
+
diff --git a/build/src/test/java/org/aspectj/internal/tools/build/UtilsTest.java b/build/src/test/java/org/aspectj/internal/tools/build/UtilsTest.java
new file mode 100644
index 000000000..4926d42e8
--- /dev/null
+++ b/build/src/test/java/org/aspectj/internal/tools/build/UtilsTest.java
@@ -0,0 +1,200 @@
+/* *******************************************************************
+ * Copyright (c) 2006 Contributors.
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wes Isberg initial implementation
+ * ******************************************************************/
+
+package org.aspectj.internal.tools.build;
+
+import java.io.IOException;
+import java.util.jar.Attributes.Name;
+
+import junit.framework.TestCase;
+
+import org.aspectj.internal.tools.build.Util.OSGIBundle;
+import org.aspectj.internal.tools.build.Util.OSGIBundle.RequiredBundle;
+
+public class UtilsTest extends TestCase {
+ private static final String PREFIX = UtilsTest.class.getName().replace('.',
+ '/');
+
+ private static final ClassLoader LOADER = UtilsTest.class.getClassLoader();
+
+ private static final ManifestTest[] TESTS = {
+ new ManifestTest("01",
+ new Name[] { OSGIBundle.BUNDLE_CLASSPATH,
+ OSGIBundle.BUNDLE_SYMBOLIC_NAME,
+ OSGIBundle.BUNDLE_VERSION }, new String[] {
+ "lib/commons/commons.jar",
+ "org.aspectj.testing.client", "1.0.0" }),
+ new ManifestTest("02",
+ new Name[] { OSGIBundle.BUNDLE_SYMBOLIC_NAME,
+ OSGIBundle.BUNDLE_VERSION }, new String[] {
+ "org.aspectj.testing.client", "1.0.0" },
+ new String[] { "lib/commons/commons.jar",
+ "lib/ant/lib/ant.jar" }, new String[] { "util",
+ "org.aspectj.runtime" }),
+ new ManifestTest("03",
+ new Name[] { OSGIBundle.BUNDLE_SYMBOLIC_NAME,
+ OSGIBundle.BUNDLE_VERSION }, new String[] {
+ "org.aspectj.testing.client", "1.0.0" },
+ new String[] { "lib/commons/commons.jar",
+ "lib/ant/lib/ant.jar" }, new String[] { "util",
+ "aspectjrt" }) {
+ void checkOthers(OSGIBundle osgiBundle, StringBuffer sb) {
+ RequiredBundle[] bundles = osgiBundle.getRequiredBundles();
+ for (int i = 0; i < bundles.length; i++) {
+ RequiredBundle bundle = bundles[i];
+ if ("aspectjrt".equals(bundle.name)) {
+ if (!bundle.optional) {
+ sb
+ .append("expected required bundle aspectjrt to be optional");
+ }
+ String version = "[1.5.0,1.5.5]";
+ if (!(version.equals(bundle.versions))) {
+ sb.append("expected version " + version
+ + " got " + bundle.versions
+ + " for required bundle aspectjrt");
+ }
+ }
+ }
+
+ }
+ } };
+
+ private static class ManifestTest {
+ final String name;
+
+ final Name[] expectedNames;
+
+ final String[] expectedValues;
+
+ final String[] classpathEntries;
+
+ final String[] requiredBundleNames;
+
+ ManifestTest(String name, Name[] expectedNames, String[] expectedValues) {
+ this(name, expectedNames, expectedValues, null, null);
+ }
+
+ ManifestTest(String name, Name[] expectedNames,
+ String[] expectedValues, String[] classpathEntries,
+ String[] requiredBundleNames) {
+ this.name = name;
+ this.expectedNames = expectedNames;
+ this.expectedValues = expectedValues;
+ this.classpathEntries = classpathEntries;
+ this.requiredBundleNames = requiredBundleNames;
+ }
+
+ void run(StringBuffer sb) throws IOException {
+ String path = PREFIX + "." + name + ".MF";
+ OSGIBundle bundle = new OSGIBundle(LOADER.getResourceAsStream(path));
+ int len = sb.length();
+ checkNamesAndValues(bundle, sb);
+ checkOthers(bundle, sb);
+ if (sb.length() != len) {
+ sb.append("failure was in test " + name);
+ }
+ }
+
+ void checkOthers(OSGIBundle bundle, StringBuffer sb) {
+ }
+
+ void checkNamesAndValues(OSGIBundle bundle, StringBuffer sb) {
+ for (int i = 0; i < expectedNames.length; i++) {
+ Name name = expectedNames[i];
+ String expected = expectedValues[i];
+ String actual = bundle.getAttribute(expectedNames[i]);
+ if (!((expected == actual) || expected.equals(actual))) {
+ sb.append(name);
+ sb.append(" ");
+ sb.append("expected ");
+ sb.append(expected);
+ sb.append("actual ");
+ sb.append(actual);
+ sb.append("\n");
+ }
+ }
+ if (null != classpathEntries) {
+ String[] cp = bundle.getClasspath();
+ Util.reportMemberDiffs(classpathEntries, cp, sb);
+ }
+ if (null != requiredBundleNames) {
+ RequiredBundle[] bundles = bundle.getRequiredBundles();
+ String[] names = new String[bundles.length];
+ for (int i = 0; i < names.length; i++) {
+ names[i] = bundles[i].name;
+ }
+ Util.reportMemberDiffs(requiredBundleNames, names, sb);
+ }
+ }
+ }
+
+ /** disabled pending research */
+ public void skip_testOSGIManifests() throws Exception {
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < TESTS.length; i++) {
+ TESTS[i].run(sb);
+ }
+ if (0 < sb.length()) {
+ fail(sb.toString());
+ }
+ }
+
+ public void testReportMemberDiffs() {
+ StringBuffer sb = new StringBuffer();
+ String[] exp = null;
+ String[] act = null;
+ assertFalse(Util.reportMemberDiffs(exp, act, sb));
+ assertEquals("", sb.toString());
+
+ sb.setLength(0);
+ exp = new String[] { "" };
+ act = null;
+ assertTrue(Util.reportMemberDiffs(exp, act, sb));
+ assertEquals("unexpected [] missing [\"\"]", sb.toString());
+
+ sb.setLength(0);
+ exp = null;
+ act = new String[] { "" };
+ assertTrue(Util.reportMemberDiffs(exp, act, sb));
+ assertEquals("unexpected [\"\"] missing []", sb.toString());
+
+ sb.setLength(0);
+ exp = new String[] { "1", "2", "3" };
+ act = new String[] { "2", "4" };
+ assertTrue(Util.reportMemberDiffs(exp, act, sb));
+ assertEquals("unexpected [\"4\"] missing [\"1\", \"3\"]", sb.toString());
+
+ }
+ // public void testResourceStream() throws Exception {
+ // String path = PREFIX + ".one.mf";
+ // System.out.println(path);
+ // InputStream in = LOADER.getResourceAsStream(path);
+ // int i;
+ // while (-1 != (i = in.read())) {
+ // System.out.print((char) i);
+ // }
+ // System.out.println();
+ // }
+ // Map map = bundle.manifest.getEntries();
+ // for (Iterator iter = map.entrySet().iterator(); iter.hasNext();) {
+ // MapEntry entry = (MapEntry) iter.next();
+ // System.out.println("entry: " + entry);
+ // }
+ // System.out.println("main attributes");
+ // Attributes attributes = bundle.manifest.getMainAttributes();
+ // Set keys = attributes.keySet();
+ // for (Iterator iter = keys.iterator(); iter.hasNext();) {
+ // Object key = iter.next();
+ // System.out.println(" key " + key);
+ // System.out.println(" value " + attributes.getValue(key.toString()));
+ // }
+}