+++ /dev/null
-
\ No newline at end of file
--- /dev/null
+
\ No newline at end of file
if (configFile.exists() && configFile.isFile()) {
args = new String[] { "@" + configFile.getAbsolutePath() };
} else {
- List<String> l = compilerConfig.getProjectSourceFiles();
- if (l == null) {
+ List<String> projectSourceFiles = compilerConfig.getProjectSourceFiles();
+ if (projectSourceFiles == null) {
return null;
}
+ List<String> l = new ArrayList<>();
+ l.addAll(projectSourceFiles);
// If the processor options are specified build the command line options for the JDT compiler to see
String processor = compilerConfig.getProcessor();
if (processor != null && processor.length() != 0) {
l.add("-processorpath");
l.add(processorPath);
}
+ if (compilerConfig.getOutputLocationManager() != null &&
+ compilerConfig.getOutputLocationManager().getDefaultOutputLocation() != null) {
+ l.add("-d");
+ l.add(compilerConfig.getOutputLocationManager().getDefaultOutputLocation().toString());
+ }
List<String> xmlfiles = compilerConfig.getProjectXmlConfigFiles();
if (xmlfiles != null && !xmlfiles.isEmpty()) {
args = new String[l.size() + xmlfiles.size() + 1];
// TODO speedup
int p = 0;
for (int i = 0; i < l.size(); i++) {
- args[p++] = (String) l.get(i);
+ args[p++] = l.get(i);
}
for (int i = 0; i < xmlfiles.size(); i++) {
- args[p++] = (String) xmlfiles.get(i);
+ args[p++] = xmlfiles.get(i);
}
args[p++] = "-xmlConfigured";
} else {
- args = (String[]) l.toArray(new String[l.size()]);
+ args = l.toArray(new String[l.size()]);
}
}
// Process the JAVA OPTIONS MAP
Map<String,String> jom = compilerConfig.getJavaOptionsMap();
if (jom != null) {
- String version = (String) jom.get(CompilerOptions.OPTION_Compliance);
+ String version = jom.get(CompilerOptions.OPTION_Compliance);
if (version != null && !version.equals(CompilerOptions.VERSION_1_4)) {
config.setBehaveInJava5Way(true);
}
} else {
tokens.addAll(tokenizeString(nonStdOptions));
}
- String[] args = (String[]) tokens.toArray(new String[] {});
+ String[] args = tokens.toArray(new String[] {});
// set the non-standard options in an alternate build config
// (we don't want to lose the settings we already have)
private File classOutputLoc;
private File resourceOutputLoc;
private List<File> allOutputLocations;
- private Map inpathMap = Collections.EMPTY_MAP;
+ private Map<File,String> inpathMap = Collections.emptyMap();
public TestOutputLocationManager(String testProjectPath) {
this.testProjectOutputPath = testProjectPath + File.separator + "bin";
}
- public TestOutputLocationManager(String string, Map inpathMap) {
+ public TestOutputLocationManager(String string, Map<File,String> inpathMap) {
this(string);
this.inpathMap = inpathMap;
}
+ @Override
public File getOutputLocationForClass(File compilationUnit) {
initLocations();
return classOutputLoc;
}
+ @Override
public File getOutputLocationForResource(File resource) {
initLocations();
return resourceOutputLoc;
}
- public Map getInpathMap() {
+ @Override
+ public Map<File,String> getInpathMap() {
return inpathMap;
}
resourceOutputLoc = f;
}
+ @Override
public List<File> getAllOutputLocations() {
if (allOutputLocations == null) {
allOutputLocations = new ArrayList<File>();
return allOutputLocations;
}
+ @Override
public File getDefaultOutputLocation() {
initLocations();
return classOutputLoc;
}
}
+ @Override
public String getSourceFolderForFile(File sourceFile) {
return null;
}
+ @Override
public void reportFileWrite(String outputfile, int filetype) {
}
+ @Override
public void reportFileRemove(String outputfile, int filetype) {
}
+ @Override
public int discoverChangesSince(File dir, long buildtime) {
// TODO Auto-generated method stub
return 0;
private TestCompilerConfiguration compilerConfig;
private AjdeCoreBuildManager ajdeBuildManager;
+ @Override
protected void setUp() throws Exception {
super.setUp();
initialiseProject("SimpleProject");
compilerConfig = (TestCompilerConfiguration) getCompiler().getCompilerConfiguration();
}
+ @Override
protected void tearDown() throws Exception {
super.tearDown();
ajdeBuildManager = null;
Map<String,String> options = JavaOptions.getDefaultJavaOptions();
options.put(JavaOptions.WARN_DEPRECATION, JavaOptions.WARNING);
compilerConfig.setJavaOptions(options);
- Map found = genAjBuildConfig().getOptions().getMap();
- String warning = (String) found.get(JavaOptions.WARN_DEPRECATION);
+ Map<String,String> found = genAjBuildConfig().getOptions().getMap();
+ String warning = found.get(JavaOptions.WARN_DEPRECATION);
assertEquals("expected to be warning on deprecation but found setting " + " was " + warning, JavaOptions.WARNING, warning);
}
for (Iterator<String> i = found.keySet().iterator(); i.hasNext();) {
String resource = i.next();
assertEquals("expected to find resource with name newFile.txt but " + "found " + resource, "newFile.txt", resource);
- File from = (File) buildConfig.getSourcePathResources().get(resource);
+ File from = buildConfig.getSourcePathResources().get(resource);
assertEquals("expected to find resource with file " + getWorkingDir() + "but found " + from, getWorkingDir(), from);
}
}
List<String> found = genAjBuildConfig().getClasspath();
StringBuffer sb = new StringBuffer();
for (Iterator<String> iterator = found.iterator(); iterator.hasNext();) {
- String name = (String) iterator.next();
+ String name = iterator.next();
sb.append(name);
if (iterator.hasNext()) {
sb.append(File.pathSeparator);
public void testProjectSourceFiles() throws IOException {
String f = getAbsoluteProjectDir() + File.separator + "C.java";
- List files = new ArrayList();
+ List<String> files = new ArrayList<>();
files.add(f);
compilerConfig.setProjectSourceFiles(files);
AjBuildConfig buildConfig = genAjBuildConfig();
- String found = ((File) buildConfig.getFiles().get(0)).getCanonicalPath();// AbsolutePath();
+ String found = buildConfig.getFiles().get(0).getCanonicalPath();// AbsolutePath();
assertEquals("expected source file " + f + ", but found " + found, f, found);
}
public class InpathTests extends AjdeCoreTestCase {
public static final FileFilter aspectjResourceFileFilter = new FileFilter() {
+ @Override
public boolean accept(File pathname) {
String name = pathname.getName().toLowerCase();
return (!name.endsWith(".class") && !name.endsWith(".java") && !name.endsWith(".aj"));
private TestMessageHandler handler;
private TestCompilerConfiguration compilerConfig;
+ @Override
protected void setUp() throws Exception {
super.setUp();
initialiseProject("InpathTest");
compilerConfig = (TestCompilerConfiguration) getCompiler().getCompilerConfiguration();
}
+ @Override
protected void tearDown() throws Exception {
super.tearDown();
handler = null;
* Ensure -outjar contains all non-Java resouces from source and injars
*/
public void compareSourceToOutjar(String indirName, File outjarFile) {
- HashSet resources = new HashSet();
+ HashSet<String> resources = new HashSet<>();
listSourceResources(indirName, resources);
try {
/*
* Ensure bin contains all non-Java resouces from source and injars
*/
- public void compareIndirToBin(File indirFile, String sourceDir, String outdirName, Set expectedOutdirContents) {
+ public void compareIndirToBin(File indirFile, String sourceDir, String outdirName, Set<String> expectedOutdirContents) {
// byte[] inManifest = null;
assertTrue("Missing resources: " + expectedOutdirContents.toString(), expectedOutdirContents.isEmpty());
}
- private void listSourceResources(String indirName, Set resources) {
+ private void listSourceResources(String indirName, Set<String> resources) {
File srcBase = openFile(indirName);
File[] fromResources = FileUtil.listFiles(srcBase, aspectjResourceFileFilter);
for (int i = 0; i < fromResources.length; i++) {
private String[] config2 = new String[] { "src" + File.separator + "aspects" + File.separator + "Logging.java" };
+ @Override
protected void setUp() throws Exception {
super.setUp();
initialiseProject(PROJECT_DIR);
compilerConfig = (TestCompilerConfiguration) getCompiler().getCompilerConfiguration();
}
+ @Override
protected void tearDown() throws Exception {
super.tearDown();
handler = null;
doBuild(true);
assertFalse("Expected compiler errors or warnings but didn't find any", handler.getMessages().isEmpty());
- List msgs = handler.getMessages();
+ List<TestMessageHandler.TestMessage> msgs = handler.getMessages();
String exp = "duplicate resource: ";
- String found = ((TestMessageHandler.TestMessage) msgs.get(0)).getContainedMessage().getMessage();
+ String found = msgs.get(0).getContainedMessage().getMessage();
assertTrue("Expected message to start with 'duplicate resource:' but found" + " message " + found, found.startsWith(exp));
compareJars(injar1, "src", outjar);
}
File binBase = openFile(outdirName);
File[] toResources = FileUtil.listFiles(binBase, aspectjResourceFileFilter);
- HashSet resources = new HashSet();
+ HashSet<String> resources = new HashSet<>();
listSourceResources(indirName, resources);
for (int i = 0; i < toResources.length; i++) {
assertTrue("Missing resources: " + resources.toString(), resources.isEmpty());
}
- private void listSourceResources(String indirName, Set resources) {
+ private void listSourceResources(String indirName, Set<String> resources) {
File srcBase = openFile(indirName);
File[] fromResources = FileUtil.listFiles(srcBase, aspectjResourceFileFilter);
for (int i = 0; i < fromResources.length; i++) {
}
public static final FileFilter aspectjResourceFileFilter = new FileFilter() {
+ @Override
public boolean accept(File pathname) {
String name = pathname.getName().toLowerCase();
boolean isCVSRelated = name.indexOf("/cvs/") != -1;
*/
public void compareJars(File injarFile, String indirName, File outjarFile) {
- HashSet resources = new HashSet();
+ HashSet<String> resources = new HashSet<>();
try {
assertTrue(
* Ensure -outjar conatins all non-Java resouces from source and injars
*/
public void compareSourceToOutjar(String indirName, File outjarFile) {
- HashSet resources = new HashSet();
+ HashSet<String> resources = new HashSet<>();
listSourceResources(indirName, resources);
try {
*/
public void compareInjarsToBin(File injarFile, String indirName, String outdirName) {
- HashSet resources = new HashSet();
+ HashSet<String> resources = new HashSet<>();
try {
byte[] inManifest = listJarResources(injarFile, resources, false);
* @param wantDirectories should any directories found in the jar be included
* @return the byte data for any discovered manifest
*/
- private byte[] listJarResources(File injarFile, Set resources, boolean wantDirectories) {
+ private byte[] listJarResources(File injarFile, Set<String> resources, boolean wantDirectories) {
byte[] manifest = null;
try {
private TestMessageHandler handler;
private TestCompilerConfiguration compilerConfig;
+ @Override
protected void setUp() throws Exception {
super.setUp();
initialiseProject("ReweavableTest");
compilerConfig = (TestCompilerConfiguration) getCompiler().getCompilerConfiguration();
}
+ @Override
protected void tearDown() throws Exception {
super.tearDown();
handler = null;
if (debugTests)
System.out.println("\ntestReweavableSimpleCompile: Building with Reweavable2.lst");
- Set paths = new HashSet();
+ Set<File> paths = new HashSet<>();
paths.add(openFile(binDir));
compilerConfig.setInpath(paths);
String[] newFiles = new String[] { "SecondAspect.aj" };
if (debugTests)
System.out.println("\ntestForReweavableSimpleErrorCompile: Building with Reweavable2.lst");
- Set paths = new HashSet();
+ Set<File> paths = new HashSet<>();
paths.add(openFile(binDir));
compilerConfig.setInpath(paths);
String[] newFiles = new String[] { "SecondAspect.aj" };
if (debugTests)
System.out.println("\ntestErrorScenario2: Building with TJP2.lst");
- Set paths = new HashSet();
+ Set<File> paths = new HashSet<>();
paths.add(openFile(binDir));
compilerConfig.setInpath(paths);
- compilerConfig.setProjectSourceFiles(new ArrayList());
+ compilerConfig.setProjectSourceFiles(new ArrayList<String>());
doBuild(true);
String expMessage = "aspect tjp.GetInfo cannot be found when reweaving tjp.Demo";
if (debugTests)
System.out.println("\ntestWorkingScenario2: Building with TJP2.lst");
- Set paths = new HashSet();
+ Set<File> paths = new HashSet<>();
paths.add(openFile(binDir));
compilerConfig.setInpath(paths);
- compilerConfig.setProjectSourceFiles(new ArrayList());
+ compilerConfig.setProjectSourceFiles(new ArrayList<String>());
doBuild(true);
String expMessage = "successfully verified type tjp.GetInfo exists";
private TestMessageHandler handler;
private TestCompilerConfiguration compilerConfig;
+ @Override
protected void setUp() throws Exception {
super.setUp();
initialiseProject(PROJECT_DIR);
compilerConfig.setNonStandardOptions("-showWeaveInfo");
}
+ @Override
protected void tearDown() throws Exception {
super.tearDown();
handler = null;
public void testWeaveMessagesBinaryITDNoDebugInfo() {
if (debugTests)
System.out.println("\ntestWeaveMessagesBinaryITD: Simple.jar + AspectITD.jar");
- Set inpath = new HashSet();
+ Set<File> inpath = new HashSet<>();
inpath.add(openFile("Simple_nodebug.jar"));
compilerConfig.setInpath(inpath);
- Set aspectpath = new HashSet();
+ Set<File> aspectpath = new HashSet<>();
aspectpath.add(openFile("AspectITD_nodebug.jar"));
compilerConfig.setAspectPath(aspectpath);
doBuild();
* Compare weaving messages with what is in the file
*/
private void compareWeaveMessages(File f) {
- List fileContents = new ArrayList();
+ List<String> fileContents = new ArrayList<>();
BufferedReader fr;
try {
// Load the file in
String line = null;
while ((line = fr.readLine()) != null)
fileContents.add(line);
- List originalFileContents = new ArrayList();
+ List<String> originalFileContents = new ArrayList<>();
originalFileContents.addAll(fileContents);
// See if the messages match
int msgCount = 0;
- List l = handler.getMessages();
- for (Iterator iter = l.iterator(); iter.hasNext();) {
- IMessage msg = ((TestMessageHandler.TestMessage) iter.next()).getContainedMessage();
+ List<TestMessageHandler.TestMessage> l = handler.getMessages();
+ for (Iterator<TestMessageHandler.TestMessage> iter = l.iterator(); iter.hasNext();) {
+ IMessage msg = iter.next().getContainedMessage();
if (debugTests)
System.out.println("Looking at [" + msg + "]");
if (msg.getKind().equals(IMessage.WEAVEINFO)) {
}
}
- private String stringify(List l) {
+ private String stringify(List<String> l) {
StringBuffer result = new StringBuffer();
- for (Iterator iter = l.iterator(); iter.hasNext();) {
- String str = (String) iter.next();
+ for (String str: l) {
result.append(str);
result.append("\n");
}
FileWriter fw;
try {
fw = new FileWriter(f);
- List l = handler.getMessages();
- for (Iterator iter = l.iterator(); iter.hasNext();) {
- IMessage msg = ((TestMessageHandler.TestMessage) iter.next()).getContainedMessage();
+ List<TestMessageHandler.TestMessage> l = handler.getMessages();
+ for (Iterator<TestMessageHandler.TestMessage> iter = l.iterator(); iter.hasNext();) {
+ IMessage msg = iter.next().getContainedMessage();
if (msg.getKind().equals(IMessage.WEAVEINFO)) {
fw.write(msg.getMessage() + "\n");
}
}
private void setRunIn15Mode() {
- Map m = new Hashtable();
+ Map<String, String> m = new Hashtable<>();
m.put(JavaOptions.COMPLIANCE_LEVEL, JavaOptions.VERSION_15);
m.put(JavaOptions.SOURCE_COMPATIBILITY_LEVEL, JavaOptions.VERSION_15);
m.put(JavaOptions.TARGET_COMPATIBILITY_LEVEL, JavaOptions.VERSION_15);
private TestCompilerConfiguration compilerConfig;
+ @Override
protected void setUp() throws Exception {
super.setUp();
initialiseProject("coverage");
manager = AsmManager.lastActiveStructureModel;
}
+ @Override
protected void tearDown() throws Exception {
super.tearDown();
compilerConfig = null;
assertNotNull(dp);
/* List relations = */manager.getRelationshipMap().get(dp);
- List rels = manager.getRelationshipMap().get(dp);
+ List<IRelationship> rels = manager.getRelationshipMap().get(dp);
assertTrue(rels.size() > 0);
// assertTrue(rel.getTargets().size() > 0);
assertNotNull(beforeExecNode);
IRelationship rel = manager.getRelationshipMap().get(beforeExecNode, IRelationship.Kind.DECLARE, forwardRelName);
assertTrue(rel.getTargets().size() > 0);
- String handle = (String) rel.getTargets().get(0);
+ String handle = rel.getTargets().get(0);
assertEquals(manager.getHierarchy().findElementForHandle(handle).toString(), to);
IProgramElement clazz = manager.getHierarchy().findElementForType(null, toType);
IProgramElement setNode = manager.getHierarchy().findElementForLabel(clazz, IProgramElement.Kind.CODE, set);
assertNotNull(setNode);
IRelationship rel2 = manager.getRelationshipMap().get(setNode, IRelationship.Kind.DECLARE, backRelName);
- String handle2 = (String) rel2.getTargets().get(0);
+ String handle2 = rel2.getTargets().get(0);
assertEquals(manager.getHierarchy().findElementForHandle(handle2).toString(), from);
}
assertNotNull(beforeExecNode);
IRelationship rel = manager.getRelationshipMap().get(beforeExecNode, IRelationship.Kind.ADVICE, relName);
for (Iterator<String> it = rel.getTargets().iterator(); it.hasNext();) {
- String currHandle = (String) it.next();
+ String currHandle = it.next();
if (manager.getHierarchy().findElementForHandle(currHandle).toLabelString().equals(to))
return;
}
.findElementForLabel(aspect, IProgramElement.Kind.ADVICE, beforeExec);
assertNotNull(beforeExecNode);
IRelationship rel = manager.getRelationshipMap().get(beforeExecNode, IRelationship.Kind.ADVICE, forwardRelName);
- String handle = (String) rel.getTargets().get(0);
+ String handle = rel.getTargets().get(0);
assertEquals(manager.getHierarchy().findElementForHandle(handle).toString(), to);
IProgramElement clazz = manager.getHierarchy().findElementForType(null, toType);
IProgramElement setNode = manager.getHierarchy().findElementForLabel(clazz, IProgramElement.Kind.METHOD, set);
assertNotNull(setNode);
IRelationship rel2 = manager.getRelationshipMap().get(setNode, IRelationship.Kind.ADVICE, backRelName);
- String handle2 = (String) rel2.getTargets().get(0);
+ String handle2 = rel2.getTargets().get(0);
assertEquals(manager.getHierarchy().findElementForHandle(handle2).toString(), from);
}
IProgramElement fromNode = manager.getHierarchy().findElementForLabel(aspect, declareKind, beforeExec);
assertNotNull(fromNode);
IRelationship rel = manager.getRelationshipMap().get(fromNode, IRelationship.Kind.DECLARE_INTER_TYPE, forwardRelName);
- String handle = (String) rel.getTargets().get(0);
+ String handle = rel.getTargets().get(0);
assertEquals(manager.getHierarchy().findElementForHandle(handle).toString(), to);
IProgramElement clazz = manager.getHierarchy().findElementForType(null, toType);
IRelationship rel2 = manager.getRelationshipMap().get(clazz, IRelationship.Kind.DECLARE_INTER_TYPE, backRelName);
// String handle2 = (String)rel2.getTargets().get(0);
for (Iterator<String> it = rel2.getTargets().iterator(); it.hasNext();) {
- String currHandle = (String) it.next();
+ String currHandle = it.next();
if (manager.getHierarchy().findElementForHandle(currHandle).toLabelString().equals(from))
return;
}
private TestMessageHandler handler;
private TestCompilerConfiguration compilerConfig;
+ @Override
protected void setUp() throws Exception {
super.setUp();
initialiseProject("coverage");
assertTrue("Expected no compiler errors but found " + handler.getErrors(), handler.getErrors().isEmpty());
}
+ @Override
protected void tearDown() throws Exception {
super.tearDown();
handler = null;
}
public void testInterfaceIsSameInBoth() {
- AsmManager asm = AsmManager.createNewStructureModel(Collections.EMPTY_MAP);
+ AsmManager asm = AsmManager.createNewStructureModel(Collections.<File,String>emptyMap());
asm.readStructureModel(getAbsoluteProjectDir());
IHierarchy model = asm.getHierarchy();
}
public void testModelIsSamePreAndPostBuild() {
- AsmManager asm = AsmManager.createNewStructureModel(Collections.EMPTY_MAP);
+ AsmManager asm = AsmManager.createNewStructureModel(Collections.<File,String>emptyMap());
asm.readStructureModel(getAbsoluteProjectDir());
// AsmManager.getDefault().readStructureModel(getAbsoluteProjectDir());
IHierarchy model = asm.getHierarchy();
assertTrue("model exists", model != null);
- final List preBuildKinds = new ArrayList();
+ final List<IProgramElement.Kind> preBuildKinds = new ArrayList<>();
HierarchyWalker walker = new HierarchyWalker() {
+ @Override
public void preProcess(IProgramElement node) {
preBuildKinds.add(node.getKind());
}
doBuild();
assertTrue("Expected no compiler errors but found " + handler.getErrors(), handler.getErrors().isEmpty());
- final List postBuildKinds = new ArrayList();
+ final List<IProgramElement.Kind> postBuildKinds = new ArrayList<>();
HierarchyWalker walker2 = new HierarchyWalker() {
+ @Override
public void preProcess(IProgramElement node) {
postBuildKinds.add(node.getKind());
}