@@ -22,6 +22,7 @@ import java.util.Set; | |||
import org.aspectj.tools.ajc.AjcTests; | |||
import org.aspectj.util.FileUtil; | |||
import org.aspectj.util.LangUtil; | |||
/** | |||
* Test implementation of ICompilerConfiguration. Allows users to configure the settings via setter methods. By default returns null | |||
@@ -58,8 +59,15 @@ public class TestCompilerConfiguration implements ICompilerConfiguration { | |||
} | |||
public String getClasspath() { | |||
return projectPath + File.pathSeparator + System.getProperty("sun.boot.class.path") + File.pathSeparator | |||
+ AjcTests.aspectjrtClasspath(); | |||
StringBuilder classpath = new StringBuilder(); | |||
classpath.append(projectPath); | |||
if (LangUtil.is19VMOrGreater()) { | |||
classpath.append(File.pathSeparator).append(LangUtil.getJrtFsFilePath()); | |||
} else { | |||
classpath.append(File.pathSeparator).append(System.getProperty("sun.boot.class.path")); | |||
} | |||
classpath.append(File.pathSeparator).append(AjcTests.aspectjrtClasspath()); | |||
return classpath.toString(); | |||
} | |||
public Set<File> getInpath() { |
@@ -19,6 +19,7 @@ import junit.framework.AssertionFailedError; | |||
import junit.framework.TestCase; | |||
import org.aspectj.tools.ajc.Ajc; | |||
import org.aspectj.util.LangUtil; | |||
/** | |||
* This class is the super class of all Ajdoc tests. It creates a sandbox directory and provides utility methods for copying over | |||
@@ -202,7 +203,12 @@ public class AjdocTestCase extends TestCase { | |||
args[1] = "-source"; | |||
args[2] = sourceLevel; | |||
args[3] = "-classpath"; | |||
args[4] = AjdocTests.ASPECTJRT_PATH.getPath(); | |||
StringBuilder classpath = new StringBuilder(); | |||
if (LangUtil.is19VMOrGreater()) { | |||
classpath.append(LangUtil.getJrtFsFilePath()).append(File.pathSeparator); | |||
} | |||
classpath.append(AjdocTests.ASPECTJRT_PATH.getPath()); | |||
args[4] = classpath.toString(); | |||
args[5] = "-d"; | |||
args[6] = getAbsolutePathOutdir(); | |||
// args[7] = "-Xset:minimalModel=false"; |
@@ -22,6 +22,7 @@ import org.aspectj.ajdt.ajc.AjdtCommand; | |||
import org.aspectj.bridge.ICommand; | |||
//import org.aspectj.bridge.IMessage; | |||
import org.aspectj.bridge.MessageHandler; | |||
import org.aspectj.util.LangUtil; | |||
/** | |||
* @author hugunin | |||
@@ -71,6 +72,7 @@ public class BasicCommandTestCase extends CommandTestCase { | |||
public void testThisAndModifiers() { | |||
checkCompile("src1/ThisAndModifiers.java", NO_ERRORS); | |||
} | |||
public void testDeclares() { | |||
checkCompile("src1/Declares.java", new int[] {2}); | |||
} | |||
@@ -98,7 +100,10 @@ public class BasicCommandTestCase extends CommandTestCase { | |||
args.add(getSandboxName()); | |||
args.add("-classpath"); | |||
args.add(getRuntimeClasspath() + File.pathSeparator + "../lib/junit/junit.jar;../testing-client/bin"); | |||
StringBuilder classpath = new StringBuilder(); | |||
classpath.append(getRuntimeClasspath()); | |||
classpath.append(File.pathSeparator).append("../lib/junit/junit.jar;../testing-client/bin"); | |||
args.add(classpath.toString()); | |||
args.add("-Xlint:error"); | |||
args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/Xlint.java"); | |||
@@ -31,6 +31,7 @@ import org.aspectj.bridge.MessageHandler; | |||
import org.aspectj.testing.util.TestUtil; | |||
import org.aspectj.tools.ajc.Ajc; | |||
import org.aspectj.tools.ajc.AjcTests; | |||
import org.aspectj.util.LangUtil; | |||
import org.aspectj.weaver.bcel.LazyClassGen; | |||
public abstract class CommandTestCase extends TestCase { | |||
@@ -175,7 +176,12 @@ public abstract class CommandTestCase extends TestCase { | |||
/** get the location of the org.aspectj.lang & runtime classes */ | |||
protected static String getRuntimeClasspath() { | |||
return AjcTests.aspectjrtClasspath(); | |||
StringBuilder classpath = new StringBuilder(); | |||
if (LangUtil.is19VMOrGreater()) { | |||
classpath.append(LangUtil.getJrtFsFilePath()).append(File.pathSeparator); | |||
} | |||
classpath.append(AjcTests.aspectjrtClasspath()); | |||
return classpath.toString(); | |||
} | |||
protected String getSandboxName() { |
@@ -35,6 +35,7 @@ import junit.framework.TestCase; | |||
import org.aspectj.bridge.IMessage; | |||
import org.aspectj.bridge.ISourceLocation; | |||
import org.aspectj.testing.util.TestUtil; | |||
import org.aspectj.util.LangUtil; | |||
/** | |||
* A TestCase class that acts as the superclass for all test cases wishing to drive the ajc compiler. | |||
@@ -610,13 +611,11 @@ public class AjcTestCase extends TestCase { | |||
getAnyJars(ajc.getSandboxDirectory(), cp); | |||
URLClassLoader sandboxLoader; | |||
URLClassLoader testLoader = (URLClassLoader) getClass().getClassLoader(); | |||
ClassLoader parentLoader = testLoader.getParent(); | |||
ClassLoader parentLoader = getClass().getClassLoader().getParent(); | |||
/* Sandbox -> AspectJ -> Extension -> Bootstrap */ | |||
if ( !useFullLTW && useLTW) { | |||
URLClassLoader testLoader = (URLClassLoader) getClass().getClassLoader(); | |||
/* | |||
* Create a new AspectJ class loader using the existing test CLASSPATH and any missing Java 5 projects | |||
*/ | |||
@@ -851,38 +850,46 @@ public class AjcTestCase extends TestCase { | |||
* @param args the String[] args to fix up | |||
* @return the String[] args to use | |||
*/ | |||
protected String[] fixupArgs(String[] args) { | |||
if (null == args) { | |||
return null; | |||
} | |||
int cpIndex = -1; | |||
boolean hasruntime = false; | |||
for (int i = 0; i < args.length - 1; i++) { | |||
args[i] = adaptToPlatform(args[i]); | |||
if ("-classpath".equals(args[i])) { | |||
cpIndex = i; | |||
args[i + 1] = substituteSandbox(args[i + 1]); | |||
String next = args[i + 1]; | |||
hasruntime = ((null != next) && (-1 != next.indexOf("aspectjrt.jar"))); | |||
} | |||
} | |||
if (-1 == cpIndex) { | |||
String[] newargs = new String[args.length + 2]; | |||
newargs[0] = "-classpath"; | |||
newargs[1] = TestUtil.aspectjrtPath().getPath(); | |||
System.arraycopy(args, 0, newargs, 2, args.length); | |||
args = newargs; | |||
} else { | |||
if (!hasruntime) { | |||
cpIndex++; | |||
String[] newargs = new String[args.length]; | |||
System.arraycopy(args, 0, newargs, 0, args.length); | |||
newargs[cpIndex] = args[cpIndex] + File.pathSeparator + TestUtil.aspectjrtPath().getPath(); | |||
args = newargs; | |||
} | |||
} | |||
return args; | |||
} | |||
protected String[] fixupArgs(String[] args) { | |||
if (null == args) { | |||
return null; | |||
} | |||
int cpIndex = -1; | |||
boolean hasruntime = false; | |||
for (int i = 0; i < args.length - 1; i++) { | |||
args[i] = adaptToPlatform(args[i]); | |||
if ("-classpath".equals(args[i])) { | |||
cpIndex = i; | |||
args[i + 1] = substituteSandbox(args[i + 1]); | |||
String next = args[i + 1]; | |||
hasruntime = ((null != next) && (-1 != next.indexOf("aspectjrt.jar"))); | |||
} | |||
} | |||
if (-1 == cpIndex) { | |||
String[] newargs = new String[args.length + 2]; | |||
newargs[0] = "-classpath"; | |||
newargs[1] = TestUtil.aspectjrtPath().getPath(); | |||
System.arraycopy(args, 0, newargs, 2, args.length); | |||
args = newargs; | |||
cpIndex = 1; | |||
} else { | |||
if (!hasruntime) { | |||
cpIndex++; | |||
String[] newargs = new String[args.length]; | |||
System.arraycopy(args, 0, newargs, 0, args.length); | |||
newargs[cpIndex] = args[cpIndex] + File.pathSeparator + TestUtil.aspectjrtPath().getPath(); | |||
args = newargs; | |||
} | |||
} | |||
boolean needsJRTFS = LangUtil.is19VMOrGreater(); | |||
if (needsJRTFS) { | |||
if (args[cpIndex].indexOf(LangUtil.JRT_FS) == -1) { | |||
String jrtfsPath = LangUtil.getJrtFsFilePath(); | |||
args[cpIndex] = jrtfsPath + File.pathSeparator + args[cpIndex]; | |||
} | |||
} | |||
return args; | |||
} | |||
private String adaptToPlatform(String s) { | |||
String ret = s.replace(';', File.pathSeparatorChar); |
@@ -18,6 +18,7 @@ import org.aspectj.bridge.MessageHandler; | |||
import org.aspectj.bridge.MessageUtil; | |||
import org.aspectj.testing.harness.bridge.AbstractRunSpec; | |||
import org.aspectj.testing.harness.bridge.AjcTest; | |||
import org.aspectj.testing.harness.bridge.IRunSpec; | |||
import org.aspectj.testing.run.IRunStatus; | |||
import org.aspectj.testing.run.RunValidator; | |||
import org.aspectj.testing.util.BridgeUtil; | |||
@@ -298,7 +299,7 @@ public class HarnessSelectionTest extends TestCase { | |||
runtime.setOptions(options); | |||
AjcTest.Suite.Spec spec = getSpec(suiteFile); | |||
assertNotNull(spec); | |||
ArrayList kids = spec.getChildren(); | |||
ArrayList<IRunSpec> kids = spec.getChildren(); | |||
assertNotNull(kids); | |||
if ((suiteFile == SELECT) && (17 != kids.size())) { | |||
assertTrue("expected 17 kids, got " + kids.size(), false); |
@@ -44,7 +44,12 @@ public class AjcTaskCompileCommandTest extends TestCase { | |||
list.add("-d"); | |||
list.add(getClassesDir().getAbsolutePath()); | |||
list.add("-classpath"); | |||
list.add(Globals.F_aspectjrt_jar.getAbsolutePath()); | |||
StringBuilder classpath = new StringBuilder(); | |||
classpath.append(Globals.F_aspectjrt_jar.getAbsolutePath()); | |||
if (LangUtil.is19VMOrGreater()) { | |||
classpath.append(File.pathSeparator).append(LangUtil.getJrtFsFilePath()); | |||
} | |||
list.add(classpath.toString()); | |||
} | |||
static boolean doWait(IMessageHolder holder, int seconds, int timeout) { |