From a46d7f1cfdf9828116cdd1b065dde35bd5f06cb6 Mon Sep 17 00:00:00 2001 From: Andy Clement Date: Mon, 28 Jan 2019 12:54:05 -0800 Subject: [PATCH] mavenizing loadtime - wip --- loadtime/pom.xml | 5 ++ .../loadtime/WeavingURLClassLoader.java | 3 +- .../aspectj/loadtime/LoadtimeModuleTests.java | 47 ------------------- .../weaver/loadtime/JRockitAgentTest.java | 5 ++ .../loadtime/WeavingURLClassLoaderTest.java | 30 ++++++------ .../aspectj/weaver/loadtime/test/simple.xml | 0 .../weaver/loadtime/test/simpleWithDtd.xml | 0 7 files changed, 28 insertions(+), 62 deletions(-) delete mode 100644 loadtime/src/test/java/org/aspectj/loadtime/LoadtimeModuleTests.java rename loadtime/src/test/{java => resources}/org/aspectj/weaver/loadtime/test/simple.xml (100%) rename loadtime/src/test/{java => resources}/org/aspectj/weaver/loadtime/test/simpleWithDtd.xml (100%) diff --git a/loadtime/pom.xml b/loadtime/pom.xml index 2d2a608e7..da12d06c4 100644 --- a/loadtime/pom.xml +++ b/loadtime/pom.xml @@ -25,6 +25,11 @@ bridge ${project.version} + + org.aspectj + runtime + ${project.version} + org.aspectj util diff --git a/loadtime/src/main/java/org/aspectj/weaver/loadtime/WeavingURLClassLoader.java b/loadtime/src/main/java/org/aspectj/weaver/loadtime/WeavingURLClassLoader.java index f6b013373..f1a286ee9 100644 --- a/loadtime/src/main/java/org/aspectj/weaver/loadtime/WeavingURLClassLoader.java +++ b/loadtime/src/main/java/org/aspectj/weaver/loadtime/WeavingURLClassLoader.java @@ -64,7 +64,8 @@ public class WeavingURLClassLoader extends ExtensibleURLClassLoader implements W public WeavingURLClassLoader(URL[] classURLs, URL[] aspectURLs, ClassLoader parent) { super(classURLs, parent); - // System.out.println("> WeavingURLClassLoader.WeavingURLClassLoader() classURLs=" + Arrays.asList(classURLs)); +// System.out.println(">WIB WeavingURLClassLoader.WeavingURLClassLoader() classURLs=" + Arrays.asList(classURLs)); +// System.out.println(">WIB WeavingURLClassLoader.WeavingURLClassLoader() aspectURLs=" + Arrays.asList(aspectURLs)); this.aspectURLs = aspectURLs; /* diff --git a/loadtime/src/test/java/org/aspectj/loadtime/LoadtimeModuleTests.java b/loadtime/src/test/java/org/aspectj/loadtime/LoadtimeModuleTests.java deleted file mode 100644 index f325ad804..000000000 --- a/loadtime/src/test/java/org/aspectj/loadtime/LoadtimeModuleTests.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.aspectj.loadtime; - -/******************************************************************************* - * 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: - * Alexandre Vasseur initial implementation - *******************************************************************************/ - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; -import junit.textui.TestRunner; - -import org.aspectj.weaver.loadtime.AjTest; -import org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptorTest; -import org.aspectj.weaver.loadtime.WeavingContextTest; -import org.aspectj.weaver.loadtime.WeavingURLClassLoaderTest; -import org.aspectj.weaver.loadtime.test.DocumentParserTest; - -/** - * @author Alexandre Vasseur - */ -public class LoadtimeModuleTests extends TestCase { - - public static Test suite() { - TestSuite suite = new TestSuite(LoadtimeModuleTests.class.getName()); - - suite.addTestSuite(DocumentParserTest.class); - suite.addTestSuite(AjTest.class); - suite.addTestSuite(ClassLoaderWeavingAdaptorTest.class); - // suite.addTestSuite(JRockitAgentTest.class); - suite.addTestSuite(WeavingContextTest.class); - suite.addTestSuite(WeavingURLClassLoaderTest.class); - return suite; - } - - public static void main(String args[]) throws Throwable { - TestRunner.run(suite()); - } - -} diff --git a/loadtime/src/test/java/org/aspectj/weaver/loadtime/JRockitAgentTest.java b/loadtime/src/test/java/org/aspectj/weaver/loadtime/JRockitAgentTest.java index 133387cf4..b13ebe421 100644 --- a/loadtime/src/test/java/org/aspectj/weaver/loadtime/JRockitAgentTest.java +++ b/loadtime/src/test/java/org/aspectj/weaver/loadtime/JRockitAgentTest.java @@ -24,6 +24,8 @@ import java.util.List; import java.util.jar.JarFile; import java.util.zip.ZipEntry; +import org.aspectj.util.FileUtil; + import junit.framework.TestCase; import com.bea.jvm.ClassPreProcessor; @@ -52,6 +54,9 @@ public class JRockitAgentTest extends TestCase { public void testJrockitRecursionProtection() { URLClassLoader thisLoader = (URLClassLoader) getClass().getClassLoader(); + URL jrockit = FileUtil.getFileURL(new File("../lib/ext/jrockit/jrockit.jar")); + URL[] urls = new URL[] {jrockit}; + thisLoader = new URLClassLoader(urls, thisLoader); ClassLoader contextLoader = Thread.currentThread().getContextClassLoader(); try { diff --git a/loadtime/src/test/java/org/aspectj/weaver/loadtime/WeavingURLClassLoaderTest.java b/loadtime/src/test/java/org/aspectj/weaver/loadtime/WeavingURLClassLoaderTest.java index 187de37ba..2af64a5f6 100644 --- a/loadtime/src/test/java/org/aspectj/weaver/loadtime/WeavingURLClassLoaderTest.java +++ b/loadtime/src/test/java/org/aspectj/weaver/loadtime/WeavingURLClassLoaderTest.java @@ -24,7 +24,6 @@ import junit.framework.TestCase; import org.aspectj.bridge.AbortException; import org.aspectj.testing.util.TestUtil.TestError; import org.aspectj.util.FileUtil; -import org.aspectj.weaver.BcweaverTests; import org.aspectj.weaver.tools.WeavingAdaptor; /** @@ -32,18 +31,20 @@ import org.aspectj.weaver.tools.WeavingAdaptor; * */ public class WeavingURLClassLoaderTest extends TestCase { - - private final static String ASPECTJRT = "../runtime/bin"; - private final static String CLASSES_JAR = BcweaverTests.TESTDATA_PATH + "/ltw-classes.jar"; - private final static String WOVEN_JAR = BcweaverTests.TESTDATA_PATH + "/ltw-woven.jar"; - private final static String JUNK_JAR = BcweaverTests.TESTDATA_PATH + "/ltw-junk.jar"; - private final static String ADVICE_ASPECTS = BcweaverTests.TESTDATA_PATH + "/ltw-aspects.jar"; - private final static String DW_ADVICE_ASPECTS = BcweaverTests.TESTDATA_PATH + "/ltw-dwaspects.jar"; - private final static String DE_ADVICE_ASPECTS = BcweaverTests.TESTDATA_PATH + "/ltw-deaspects.jar"; - private final static String AROUNDCLOSURE_ASPECTS = BcweaverTests.TESTDATA_PATH + "/ltw-acaspects.jar"; - private final static String ITD_ASPECTS = BcweaverTests.TESTDATA_PATH + "/ltw-itdaspects.jar"; - private final static String PER_ASPECTS = BcweaverTests.TESTDATA_PATH + "/ltw-peraspects.jar"; - private final static String TEST_BASE = BcweaverTests.TESTDATA_PATH + "/WeavingURLClassLoaderTest/builtLibs"; + + private final static String TESTDATA_PATH = "../weaver/testdata"; + + private final static String ASPECTJRT = "../runtime/target/classes"; + private final static String CLASSES_JAR = TESTDATA_PATH + "/ltw-classes.jar"; + private final static String WOVEN_JAR = TESTDATA_PATH + "/ltw-woven.jar"; + private final static String JUNK_JAR = TESTDATA_PATH + "/ltw-junk.jar"; + private final static String ADVICE_ASPECTS = TESTDATA_PATH + "/ltw-aspects.jar"; + private final static String DW_ADVICE_ASPECTS = TESTDATA_PATH + "/ltw-dwaspects.jar"; + private final static String DE_ADVICE_ASPECTS = TESTDATA_PATH + "/ltw-deaspects.jar"; + private final static String AROUNDCLOSURE_ASPECTS = TESTDATA_PATH + "/ltw-acaspects.jar"; + private final static String ITD_ASPECTS = TESTDATA_PATH + "/ltw-itdaspects.jar"; + private final static String PER_ASPECTS = TESTDATA_PATH + "/ltw-peraspects.jar"; + private final static String TEST_BASE = TESTDATA_PATH + "/WeavingURLClassLoaderTest/builtLibs"; private final static String NULL = "null"; @@ -347,7 +348,8 @@ public class WeavingURLClassLoaderTest extends TestCase { * Aspects on ASPECTPATH but missing from CLASSPATH */ public void testIncompletePath() { - setSystemProperty(WeavingURLClassLoader.WEAVING_ASPECT_PATH, ADVICE_ASPECTS); + URL aspectjrt = FileUtil.getFileURL(new File(ASPECTJRT)); + setSystemProperty(WeavingURLClassLoader.WEAVING_ASPECT_PATH, ADVICE_ASPECTS+File.pathSeparator+aspectjrt.toString()); setSystemProperty(WeavingURLClassLoader.WEAVING_CLASS_PATH, CLASSES_JAR); WeavingURLClassLoader loader = new WeavingURLClassLoader(getClass().getClassLoader()); diff --git a/loadtime/src/test/java/org/aspectj/weaver/loadtime/test/simple.xml b/loadtime/src/test/resources/org/aspectj/weaver/loadtime/test/simple.xml similarity index 100% rename from loadtime/src/test/java/org/aspectj/weaver/loadtime/test/simple.xml rename to loadtime/src/test/resources/org/aspectj/weaver/loadtime/test/simple.xml diff --git a/loadtime/src/test/java/org/aspectj/weaver/loadtime/test/simpleWithDtd.xml b/loadtime/src/test/resources/org/aspectj/weaver/loadtime/test/simpleWithDtd.xml similarity index 100% rename from loadtime/src/test/java/org/aspectj/weaver/loadtime/test/simpleWithDtd.xml rename to loadtime/src/test/resources/org/aspectj/weaver/loadtime/test/simpleWithDtd.xml -- 2.39.5