From cbc4553d7af7b36d2acc97c7c78e631d3fd4e42f Mon Sep 17 00:00:00 2001 From: aclement Date: Fri, 17 Jun 2011 21:02:28 +0000 Subject: [PATCH] when demotion is happening we also need to put the jar on the classpath! --- .../org/aspectj/weaver/bcel/ZipTestCase.java | 84 ++++++++----------- 1 file changed, 37 insertions(+), 47 deletions(-) diff --git a/weaver/testsrc/org/aspectj/weaver/bcel/ZipTestCase.java b/weaver/testsrc/org/aspectj/weaver/bcel/ZipTestCase.java index 3f63a1f22..eb73dac9f 100644 --- a/weaver/testsrc/org/aspectj/weaver/bcel/ZipTestCase.java +++ b/weaver/testsrc/org/aspectj/weaver/bcel/ZipTestCase.java @@ -10,122 +10,112 @@ * PARC initial implementation * ******************************************************************/ - package org.aspectj.weaver.bcel; -import java.io.*; +import java.io.File; +import java.io.IOException; import java.util.Collection; -import org.aspectj.weaver.BcweaverTests; - import junit.framework.TestCase; +import org.aspectj.weaver.BcweaverTests; + public class ZipTestCase extends TestCase { - File outDir; + File outDir; /** * Constructor for ZipTestCase. + * * @param arg0 */ public ZipTestCase(String arg0) { super(arg0); } - public void setUp() { - outDir = BcweaverTests.getOutdir(); - } - - public void tearDown() { - BcweaverTests.removeOutDir(); - outDir = null; - } - - + public void setUp() { + outDir = BcweaverTests.getOutdir(); + } + + public void tearDown() { + BcweaverTests.removeOutDir(); + outDir = null; + } + public void zipTest(String fileName, String aspectjar) throws IOException { zipTest(fileName, aspectjar, false); } - + public void zipTest(String fileName, String aspectjar, boolean isInJar) throws IOException { File inFile = new File(fileName); File outFile = new File(outDir, inFile.getName()); - - BcelWorld world = new BcelWorld(); - //BcelWeaver weaver1 = new BcelWeaver(world); BcelWeaver weaver = new BcelWeaver(world); - + long startTime = System.currentTimeMillis(); // ensure that a fast cpu doesn't complete file write within 1000ms of start try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); - } - weaver.addJarFile(inFile, new File("."),false); + } + + weaver.addJarFile(inFile, new File("."), false); + if (aspectjar != null) { if (isInJar) { - weaver.addJarFile(new File(aspectjar), new File("."),false); + weaver.addJarFile(new File(aspectjar), new File("."), false); } else { weaver.addLibraryJarFile(new File(aspectjar)); + world.addPath(new File(aspectjar).toString()); } } - weaver.addLibraryJarFile(new File(BcweaverTests.TESTDATA_PATH + "/Regex.jar")); //??? - - - Collection woven = weaver.weave(outFile); + weaver.addLibraryJarFile(new File(BcweaverTests.TESTDATA_PATH + "/Regex.jar")); // ??? + world.addPath(new File(BcweaverTests.TESTDATA_PATH + "/Regex.jar").getPath()); + + Collection woven = weaver.weave(outFile); long stopTime = System.currentTimeMillis(); - - - System.out.println("handled " + woven.size() + " entries, in " + - (stopTime-startTime)/1000. + " seconds"); + + System.out.println("handled " + woven.size() + " entries, in " + (stopTime - startTime) / 1000. + " seconds"); // last mod times on linux (at least) are only accurate to the second. // with fast disks and a fast cpu the following test can fail if the write completes less than // 1000 milliseconds after the start of the test, hence the 1000ms delay added above. assertTrue(outFile.lastModified() > startTime); - } - + } + public void testSmall() throws IOException { zipTest(BcweaverTests.TESTDATA_PATH + "/Regex.jar", null); } public void testSmallWithAspects() throws IOException { System.out.println("could take 4 seconds..."); - zipTest(BcweaverTests.TESTDATA_PATH + "/Regex.jar", - BcweaverTests.TESTDATA_PATH + "/megatrace.jar"); + zipTest(BcweaverTests.TESTDATA_PATH + "/Regex.jar", BcweaverTests.TESTDATA_PATH + "/megatrace.jar"); } public void testSmallWithAspectsNoWeave() throws IOException { System.out.println("could take 4 seconds..."); - zipTest(BcweaverTests.TESTDATA_PATH + "/Regex.jar", - BcweaverTests.TESTDATA_PATH + "/megatraceNoweave.jar", true); + zipTest(BcweaverTests.TESTDATA_PATH + "/Regex.jar", BcweaverTests.TESTDATA_PATH + "/megatraceNoweave.jar", true); } - public void testBig() throws IOException { System.out.println("could take 4 seconds..."); zipTest("../lib/bcel/bcel.jar", null); } - - + public void testBigWithEasyNoTrace() throws IOException { System.out.println("could take 4 seconds..."); - zipTest("../lib/bcel/bcel.jar", - BcweaverTests.TESTDATA_PATH + "/megatrace0easy.jar"); + zipTest("../lib/bcel/bcel.jar", BcweaverTests.TESTDATA_PATH + "/megatrace0easy.jar"); } // this is something we test every now and again. public void xtestBigWithHardNoTrace() throws IOException { System.out.println("could take 24 seconds..."); - zipTest("../lib/bcel/bcel.jar", - BcweaverTests.TESTDATA_PATH + "/megatrace0hard.jar"); + zipTest("../lib/bcel/bcel.jar", BcweaverTests.TESTDATA_PATH + "/megatrace0hard.jar"); } - public void xtestBigWithAspects() throws IOException { System.out.println("could take 40 seconds..."); - zipTest("../lib/bcel/bcel.jar", - BcweaverTests.TESTDATA_PATH + "/megatrace.jar"); + zipTest("../lib/bcel/bcel.jar", BcweaverTests.TESTDATA_PATH + "/megatrace.jar"); } } -- 2.39.5