package org.aspectj.ajdt.ajc;
+import java.io.File;
+
import junit.framework.*;
public class AjdtAjcTests extends TestCase {
+ public static final String TESTDATA_PATH
+ = "../org.aspectj.ajdt.core/testdata";
+ public static final File TESTDATA_DIR = new File(TESTDATA_PATH);
+
public static Test suite() {
TestSuite suite = new TestSuite(AjdtAjcTests.class.getName());
//$JUnit-BEGIN$
outputWriter.flushBuffer();
config = command.genBuildConfig(
- new String[] { "-incremental", "-sourceroots", "testdata/src1" },
+ new String[] { "-incremental", "-sourceroots",
+ AjdtAjcTests.TESTDATA_PATH + "/src1" },
counter);
assertTrue(
public class BuildArgParserTestCase extends TestCase {
private BuildArgParser parser = new BuildArgParser();
- private static final String TEST_DIR = "testdata" + File.separator + "ajc" + File.separator;
+ private static final String TEST_DIR = AjdtAjcTests.TESTDATA_PATH + File.separator + "ajc" + File.separator;
private MessageWriter messageWriter = new MessageWriter(new PrintWriter(System.out), false);
public BuildArgParserTestCase(String name) {
}
public void testAspectpath() throws InvalidInputException {
- final String SOURCE_JAR = "testdata/testclasses.jar";
- final String SOURCE_JARS = "testdata/testclasses.jar" + File.pathSeparator
+ final String SOURCE_JAR = AjdtAjcTests.TESTDATA_PATH + "/testclasses.jar";
+ final String SOURCE_JARS = AjdtAjcTests.TESTDATA_PATH + "/testclasses.jar" + File.pathSeparator
+ "../weaver/testdata/tracing.jar" + File.pathSeparator
+ "../weaver/testdata/dummyAspect.jar";
AjBuildConfig config = parser.genBuildConfig(new String[] {
}
public void testInJars() throws InvalidInputException {
- final String SOURCE_JAR = "testdata/testclasses.jar";
- final String SOURCE_JARS = "testdata/testclasses.jar" + File.pathSeparator
+ final String SOURCE_JAR = AjdtAjcTests.TESTDATA_PATH + "/testclasses.jar";
+ final String SOURCE_JARS = AjdtAjcTests.TESTDATA_PATH + "/testclasses.jar" + File.pathSeparator
+ "../weaver/testdata/tracing.jar" + File.pathSeparator
+ "../weaver/testdata/dummyAspect.jar";
AjBuildConfig config = parser.genBuildConfig(new String[] {
}
public void testBadInJars() throws InvalidInputException {
- final String SOURCE_JARS = "testdata/testclasses.jar" + File.pathSeparator + "b.far" + File.pathSeparator + "c.jar";
+ final String SOURCE_JARS = AjdtAjcTests.TESTDATA_PATH + "/testclasses.jar" + File.pathSeparator + "b.far" + File.pathSeparator + "c.jar";
AjBuildConfig config = parser.genBuildConfig(new String[] {
"-injars", SOURCE_JARS },
messageWriter);
assertTrue("size: " + config.getInJars().size(), config.getInJars().size() == 1);
}
- public void testMultipleSourceRoots() throws InvalidInputException {
- final String SRCROOT_1 = "testdata/src1/p1";
- final String SRCROOT_2 = "testdata/ajc";
+ public void testMultipleSourceRoots() throws InvalidInputException, IOException {
+ final String SRCROOT_1 = AjdtAjcTests.TESTDATA_PATH + "/src1/p1";
+ final String SRCROOT_2 = AjdtAjcTests.TESTDATA_PATH + "/ajc";
AjBuildConfig config = parser.genBuildConfig(new String[] {
"-sourceroots", SRCROOT_1 + File.pathSeparator + SRCROOT_2 },
messageWriter);
assertEquals(getCanonicalPath(new File(SRCROOT_1)), ((File)config.getSourceRoots().get(0)).getAbsolutePath());
Collection expectedFiles = Arrays.asList(new File[] {
- new File(SRCROOT_1+File.separator+"A.java").getAbsoluteFile(),
- new File(SRCROOT_1+File.separator+"Foo.java").getAbsoluteFile(),
- new File(SRCROOT_2+File.separator+"A.java").getAbsoluteFile(),
- new File(SRCROOT_2+File.separator+"B.java").getAbsoluteFile(),
- new File(SRCROOT_2+File.separator+"X.aj").getAbsoluteFile(),
- new File(SRCROOT_2+File.separator+"Y.aj").getAbsoluteFile(),
- new File(SRCROOT_2+File.separator+"pkg"+File.separator+"Hello.java").getAbsoluteFile(),
+ new File(SRCROOT_1+File.separator+"A.java").getCanonicalFile(),
+ new File(SRCROOT_1+File.separator+"Foo.java").getCanonicalFile(),
+ new File(SRCROOT_2+File.separator+"A.java").getCanonicalFile(),
+ new File(SRCROOT_2+File.separator+"B.java").getCanonicalFile(),
+ new File(SRCROOT_2+File.separator+"X.aj").getCanonicalFile(),
+ new File(SRCROOT_2+File.separator+"Y.aj").getCanonicalFile(),
+ new File(SRCROOT_2+File.separator+"pkg"+File.separator+"Hello.java").getCanonicalFile(),
});
//System.out.println(config.getFiles());
return ret;
}
- public void testSourceRootDir() throws InvalidInputException {
- final String SRCROOT = "testdata/ajc";
+ public void testSourceRootDir() throws InvalidInputException, IOException {
+ final String SRCROOT = AjdtAjcTests.TESTDATA_PATH + "/ajc";
AjBuildConfig config = parser.genBuildConfig(new String[] {
"-sourceroots", SRCROOT },
messageWriter);
assertEquals(getCanonicalPath(new File(SRCROOT)), ((File)config.getSourceRoots().get(0)).getAbsolutePath());
Collection expectedFiles = Arrays.asList(new File[] {
- new File(SRCROOT+File.separator+"A.java").getAbsoluteFile(),
- new File(SRCROOT+File.separator+"B.java").getAbsoluteFile(),
- new File(SRCROOT+File.separator+"X.aj").getAbsoluteFile(),
- new File(SRCROOT+File.separator+"Y.aj").getAbsoluteFile(),
- new File(SRCROOT+File.separator+"pkg"+File.separator+"Hello.java").getAbsoluteFile(),
+ new File(SRCROOT+File.separator+"A.java").getCanonicalFile(),
+ new File(SRCROOT+File.separator+"B.java").getCanonicalFile(),
+ new File(SRCROOT+File.separator+"X.aj").getCanonicalFile(),
+ new File(SRCROOT+File.separator+"Y.aj").getCanonicalFile(),
+ new File(SRCROOT+File.separator+"pkg"+File.separator+"Hello.java").getCanonicalFile(),
});
//System.out.println(config.getFiles());
public void testBadSourceRootDir() throws InvalidInputException {
AjBuildConfig config = parser.genBuildConfig(new String[] {
"-sourceroots",
- "testdata/mumbleDoesNotExist;testdata/ajc" },
+ AjdtAjcTests.TESTDATA_PATH + "/mumbleDoesNotExist;"
+ + AjdtAjcTests.TESTDATA_PATH + "/ajc" },
messageWriter);
assertTrue(config.getSourceRoots().toString(), config.getSourceRoots().size() == 1);
}
//??? we've decided not to make this an error
- public void testSourceRootDirWithFiles() throws InvalidInputException {
- final String SRCROOT = "testdata/ajc/pkg";
+ public void testSourceRootDirWithFiles() throws InvalidInputException, IOException {
+ final String SRCROOT = AjdtAjcTests.TESTDATA_PATH + "/ajc/pkg";
AjBuildConfig config = parser.genBuildConfig(new String[] {
- "-sourceroots", SRCROOT, "testdata/src1/A.java"},
+ "-sourceroots", SRCROOT, AjdtAjcTests.TESTDATA_PATH + "/src1/A.java"},
messageWriter);
assertEquals(getCanonicalPath(new File(SRCROOT)), ((File)config.getSourceRoots().get(0)).getAbsolutePath());
Collection expectedFiles = Arrays.asList(new File[] {
- new File(SRCROOT+File.separator+"Hello.java").getAbsoluteFile(),
- new File("testdata"+File.separator+"src1"+File.separator+"A.java").getAbsoluteFile(),
+ new File(SRCROOT+File.separator+"Hello.java").getCanonicalFile(),
+ new File(AjdtAjcTests.TESTDATA_PATH +File.separator+"src1"+File.separator+"A.java").getCanonicalFile(),
});
TestUtil.assertSetEquals(expectedFiles, config.getFiles());
}
public void testExtDirs() throws InvalidInputException {
- final String DIR = "testdata";
+ final String DIR = AjdtAjcTests.TESTDATA_PATH;
AjBuildConfig config = parser.genBuildConfig(new String[] {
"-extdirs", DIR },
messageWriter);
}
public void testOutputJar() throws InvalidInputException {
- final String OUT_JAR = "testdata/testclasses.jar";
+ final String OUT_JAR = AjdtAjcTests.TESTDATA_PATH + "/testclasses.jar";
AjBuildConfig config = parser.genBuildConfig(new String[] {
"-outjar", OUT_JAR },
assertEquals(
getCanonicalPath(new File(OUT_JAR)),config.getOutputJar().getAbsolutePath());
- File nonExistingJar = new File("testdata/mumbleDoesNotExist.jar");
+ File nonExistingJar = new File(AjdtAjcTests.TESTDATA_PATH + "/mumbleDoesNotExist.jar");
config = parser.genBuildConfig(new String[] {
"-outjar", nonExistingJar.getAbsolutePath() },
messageWriter);
}
public void testXlintfile() throws InvalidInputException {
- String lintFile = "testdata/lintspec.properties";
+ String lintFile = AjdtAjcTests.TESTDATA_PATH + "/lintspec.properties";
String badLintFile = "lint.props";
AjBuildConfig config = parser.genBuildConfig(new String[] {"-Xlintfile", lintFile}, messageWriter);
assertTrue(new File(lintFile).exists());
List resultList = config.getFiles();
assertTrue("correct number of files", resultList.size() == 2);
- assertTrue(resultList.toString() + new File(TEST_DIR + SOURCE_PATH_1).getAbsoluteFile(),
- resultList.contains(new File(TEST_DIR + SOURCE_PATH_1).getAbsoluteFile()));
+ assertTrue(resultList.toString() + new File(TEST_DIR + SOURCE_PATH_1).getCanonicalFile(),
+ resultList.contains(new File(TEST_DIR + SOURCE_PATH_1).getCanonicalFile()));
assertTrue(resultList.toString() + SOURCE_PATH_2,
- resultList.contains(new File(TEST_DIR + SOURCE_PATH_2).getAbsoluteFile()));
+ resultList.contains(new File(TEST_DIR + SOURCE_PATH_2).getCanonicalFile()));
}
import java.util.Arrays;
import java.util.List;
+import org.aspectj.ajdt.ajc.*;
import org.aspectj.ajdt.ajc.AjdtCommand;
import org.aspectj.bridge.ICommand;
import org.aspectj.bridge.IMessage;
args.add("-classpath");
args.add(getRuntimeClasspath() + File.pathSeparator +\r "../lib/junit/junit.jar;../testing-client/bin");
args.add("-Xlint:error");
- args.add("testdata/src1/Xlint.java");
+ args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/Xlint.java");
runCompiler(args, new int[] {2});
}
args.add("-classpath");
args.add(getRuntimeClasspath() + File.pathSeparator +\r "../lib/junit/junit.jar;../testing-client/bin;not_found_anywhere.jar");
- args.add("testdata/src1/ThisAndModifiers.java");
+ args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/ThisAndModifiers.java");
ICommand command = new AjdtCommand();
MessageHandler myHandler = new MessageHandler();
args.add("-classpath");
args.add("../lib/junit/junit.jar;../testing-client/bin");
- args.add("testdata/src1/ThisAndModifiers.java");
+ args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/ThisAndModifiers.java");
ICommand command = new AjdtCommand();
MessageHandler myHandler = new MessageHandler();
args.add(getRuntimeClasspath() + File.pathSeparator +
"../lib/junit/junit.jar;../testing-client/bin");
- File f1 = new File("testdata/src1/p1/Foo.class");
- File f2 = new File("testdata/src1/WrongPackage.class");
- File f3 = new File("testdata/src1/WrongPackage$1.class");
+ File f1 = new File(AjdtAjcTests.TESTDATA_PATH + "/src1/p1/Foo.class");
+ File f2 = new File(AjdtAjcTests.TESTDATA_PATH + "/src1/WrongPackage.class");
+ File f3 = new File(AjdtAjcTests.TESTDATA_PATH + "/src1/WrongPackage$1.class");
if (f1.exists()) f1.delete();
if (f2.exists()) f2.delete();
if (f3.exists()) f3.delete();
- args.add("testdata/src1/p1/Foo.java");
- args.add("testdata/src1/WrongPackage.java");
+ args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/p1/Foo.java");
+ args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/WrongPackage.java");
runCompiler(args, NO_ERRORS);
args.add(getRuntimeClasspath() + File.pathSeparator +
"../lib/junit/junit.jar;../testing-client/bin");
- args.add("testdata/src1/SizeIssuesAspect.java");
- args.add("testdata/src1/SizeIssues.java");
+ args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/SizeIssuesAspect.java");
+ args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/SizeIssues.java");
runCompiler(args, NO_ERRORS);
long size = f1.length();
import java.util.*;
import java.util.ArrayList;
+import org.aspectj.ajdt.ajc.AjdtAjcTests;
+
public class BcweaverJarMaker {
public BcweaverJarMaker() {
args.add("../runtime/bin" + File.pathSeparator +
System.getProperty("aspectjrt.path"));
- args.add("testdata/src1/Trace.java");
- args.add("testdata/src1/MyTrace.java");
+ args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/Trace.java");
+ args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/MyTrace.java");
CommandTestCase.runCompiler(args, CommandTestCase.NO_ERRORS);
}
args.add("../runtime/bin" + File.pathSeparator +
System.getProperty("aspectjrt.path"));
- args.add("testdata/src1/trace/MegaTrace.java");
- args.add("testdata/src1/trace/ExecTrace.java");
+ args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/trace/MegaTrace.java");
+ args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/trace/ExecTrace.java");
CommandTestCase.runCompiler(args, CommandTestCase.NO_ERRORS);
}
args.add("../runtime/bin" + File.pathSeparator +
System.getProperty("aspectjrt.path"));
- args.add("testdata/src1/trace/MegaTrace.java");
- args.add("testdata/src1/trace/ObviousTraceNothing.java");
+ args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/trace/MegaTrace.java");
+ args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/trace/ObviousTraceNothing.java");
CommandTestCase.runCompiler(args, CommandTestCase.NO_ERRORS);
}
args.add("../runtime/bin" + File.pathSeparator +
System.getProperty("aspectjrt.path"));
- args.add("testdata/src1/trace/MegaTrace.java");
- args.add("testdata/src1/trace/HardTraceNothing.java");
+ args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/trace/MegaTrace.java");
+ args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/trace/HardTraceNothing.java");
CommandTestCase.runCompiler(args, CommandTestCase.NO_ERRORS);
}
args.add("../runtime/bin" + File.pathSeparator +
System.getProperty("aspectjrt.path"));
- args.add("testdata/src1/trace/MegaTrace.java");
- args.add("testdata/src1/trace/ExecTrace.java");
+ args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/trace/MegaTrace.java");
+ args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/trace/ExecTrace.java");
CommandTestCase.runCompiler(args, CommandTestCase.NO_ERRORS);
}
args.add("../runtime/bin" + File.pathSeparator +
System.getProperty("aspectjrt.path"));
- args.add("testdata/src1/DummyAspect.java");
+ args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/DummyAspect.java");
CommandTestCase.runCompiler(args, CommandTestCase.NO_ERRORS);
}
import java.util.ArrayList;
import java.util.List;
+import org.aspectj.ajdt.ajc.AjdtAjcTests;
import org.aspectj.testing.util.TestUtil;
args.add("-d");
args.add("out");
- args.add("testdata/src1/binary/lib/ConcreteA.aj");
- args.add("testdata/src1/binary/lib/AbstractA.aj");
+ args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/binary/lib/ConcreteA.aj");
+ args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/binary/lib/AbstractA.aj");
CommandTestCase.runCompiler(args, CommandTestCase.NO_ERRORS);
args.add("-d");
args.add("out");
- args.add("testdata/src1/binary/client/Client.java");
- args.add("testdata/src1/binary/client/Client1.java");
+ args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/binary/client/Client.java");
+ args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/binary/client/Client1.java");
CommandTestCase.runCompiler(args, CommandTestCase.NO_ERRORS);
args.add("-d");
args.add("out");
- args.add("testdata/src1/binary/client/MyAspect.aj");
- args.add("testdata/src1/binary/client/Client1.java");
+ args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/binary/client/MyAspect.aj");
+ args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/binary/client/Client1.java");
CommandTestCase.runCompiler(args, CommandTestCase.NO_ERRORS);
args.add("-d");
args.add("out");
- args.add("testdata/src1/binary/client/MyAspect1.aj");
- args.add("testdata/src1/binary/client/Client1.java");
+ args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/binary/client/MyAspect1.aj");
+ args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/binary/client/Client1.java");
CommandTestCase.runCompiler(args, new int[] {24, 30});
args.add("-d");
args.add("out");
- args.add("testdata/src1/binary/client/Client1.java");
+ args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/binary/client/Client1.java");
CommandTestCase.runCompiler(args, new int[] {15, 17, 22});
args.add("-d");
args.add("out");
- args.add("testdata/src1/binary/client/MyAspect.aj");
- args.add("testdata/src1/binary/client/Client1.java");
+ args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/binary/client/MyAspect.aj");
+ args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/binary/client/Client1.java");
CommandTestCase.runCompiler(args, CommandTestCase.NO_ERRORS);
}
package org.aspectj.ajdt.internal.compiler.batch;
+import org.aspectj.ajdt.ajc.*;
import org.aspectj.ajdt.ajc.AjdtCommand;
import org.aspectj.bridge.ICommand;
import org.aspectj.bridge.IMessage;
args.add("-g"); //XXX need this to get sourcefile and line numbers, shouldn't
- args.add("testdata/" + source);
+ args.add(AjdtAjcTests.TESTDATA_PATH + "/" + source);
runCompiler(args, expectedErrors);
}
args.add("-classpath");
args.add(getRuntimeClasspath());
- args.add("testdata/" + source);
+ args.add(AjdtAjcTests.TESTDATA_PATH + "/" + source);
ICommand compiler = runCompiler(args, NO_ERRORS);
Thread.sleep(100);
}
public static void printGenerated(String path, String name) throws IOException {
- String fullpath = "testdata/" + path;
+ String fullpath = AjdtAjcTests.TESTDATA_PATH + "/" + path;
LazyClassGen.disassemble(fullpath, name, System.out);
}
package org.aspectj.ajdt.internal.core.builder;
+import EajcModuleTests;
+
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import junit.framework.TestCase;
+import org.aspectj.ajdt.ajc.*;
import org.aspectj.ajdt.ajc.BuildArgParser;
import org.aspectj.asm.AsmManager;
import org.aspectj.bridge.IMessage;
private StreamPrintWriter outputWriter = new StreamPrintWriter(new PrintWriter(System.out));
private MessageWriter messageWriter = new MessageWriter(outputWriter, false);
- public static File source1 = new File("testdata/src1/A.java");
- public static File source2 = new File("testdata/src1/Hello.java");
- public static File source3 = new File("testdata/src1/X.java");
+ public static File source1 = new File(AjdtAjcTests.TESTDATA_DIR, "src1/A.java");
+ public static File source2 = new File(AjdtAjcTests.TESTDATA_DIR, "src1/Hello.java");
+ public static File source3 = new File(AjdtAjcTests.TESTDATA_DIR, "src1/X.java");
/**
"-d", "out",
"-classpath",
javaClassPath,
- "testdata/src1/A.java",
-// "testdata/src1/Hello.java",
+ AjdtAjcTests.TESTDATA_PATH
+ + "/src1/A.java",
+// EajcModuleTests.TESTDATA_PATH + "/src1/Hello.java",
}, messageWriter);
String err = parser.getOtherMessages(true);
assertTrue(err, null == err);