public class AbstractMultiProjectIncrementalAjdeInteractionTestbed extends AjdeInteractionTestbed {
- public static boolean VERBOSE = false;
-
public static void dumptree(IProgramElement node, int indent) {
for (int i = 0; i < indent; i++) {
System.out.print(" ");
protected void setUp() throws Exception {
super.setUp();
- AjdeInteractionTestbed.VERBOSE = VERBOSE;
AjState.FORCE_INCREMENTAL_DURING_TESTING = true;
}
public void build(String projectName) {
constructUpToDateLstFile(projectName, "build.lst");
doBuild(projectName);
- if (AjdeInteractionTestbed.VERBOSE)
+ if (AjdeInteractionTestbed.VERBOSE) {
printBuildReport(projectName);
+ }
}
public int getRelationshipCount(String project) {
public void fullBuild(String projectName) {
constructUpToDateLstFile(projectName, "build.lst");
doFullBuild(projectName);
- if (AjdeInteractionTestbed.VERBOSE)
+ if (AjdeInteractionTestbed.VERBOSE) {
printBuildReport(projectName);
+ }
}
private void constructUpToDateLstFile(String pname, String configname) {
private void collectUpFiles(File location, File base, List<String> collectionPoint) {
String contents[] = location.list();
- if (contents == null)
+ if (contents == null) {
return;
+ }
for (String string : contents) {
File f = new File(location, string);
if (f.isDirectory()) {
try {
fileFound = f.getCanonicalPath();
String toRemove = base.getCanonicalPath();
- if (!fileFound.startsWith(toRemove))
+ if (!fileFound.startsWith(toRemove)) {
throw new RuntimeException("eh? " + fileFound + " " + toRemove);
+ }
collectionPoint.add(fileFound.substring(toRemove.length() + 1));// +1 captures extra separator
} catch (IOException e) {
e.printStackTrace();
File projectSrc = new File(testdataSrcDir + File.separatorChar + projectName + File.separatorChar + overlayDirectory);
File destination = new File(getWorkingDir(), projectName);
- if (AjdeInteractionTestbed.VERBOSE)
+ if (AjdeInteractionTestbed.VERBOSE) {
System.out.println("Altering project " + projectName);
+ }
copy(projectSrc, destination);
}
*/
protected void copy(File from, File to) {
String contents[] = from.list();
- if (contents == null)
+ if (contents == null) {
return;
+ }
for (String string : contents) {
File f = new File(from, string);
File t = new File(to, string);
public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementalAjdeInteractionTestbed {
public void testIncremental_344326() throws Exception {
- AjdeInteractionTestbed.VERBOSE = true;
String p = "pr344326";
initialiseProject(p);
build(p);
}
public void testIncrementalITDInners3() throws Exception {
- AjdeInteractionTestbed.VERBOSE = true;
String p = "prInner3";
initialiseProject(p);
build(p);
// found whilst looking at 322446 hence that is the testdata name
public void testAspectInheritance_322664() throws Exception {
- AjdeInteractionTestbed.VERBOSE = true;
String p = "pr322446_3";
initialiseProject(p);
build(p);
}
public void testPR265729() {
- AjdeInteractionTestbed.VERBOSE = true;
String lib = "pr265729_lib";
initialiseProject(lib);
// addClasspathEntryChanged(lib, getProjectRelativePath(p1,
// @see AsmRelationshipProvider.createIntertypeDeclaredChild()
List<char[]> ptypes = binaryITDM.getParameterTypes();
- assertEquals("int", new String((char[]) ptypes.get(0)));
- assertEquals("java.util.List", new String((char[]) ptypes.get(1)));
- assertEquals("java.io.Serializable", new String((char[]) ptypes.get(2)));
+ assertEquals("int", new String(ptypes.get(0)));
+ assertEquals("java.util.List", new String(ptypes.get(1)));
+ assertEquals("java.io.Serializable", new String(ptypes.get(2)));
// param names not set
// List pnames = binaryITDM.getParameterNames();
}
public void testXmlConfiguredProject() {
- AjdeInteractionTestbed.VERBOSE = true;
String p = "xmlone";
initialiseProject(p);
configureNonStandardCompileOptions(p, "-showWeaveInfo");// -xmlConfigured");
List<String> targets = ir.getTargets();
assertEquals(1, targets.size());
System.out.println(targets.get(0));
- String handle = (String) targets.get(0);
+ String handle = targets.get(0);
assertEquals("Expected the handle for the code node inside the constructor decl",
"=261380<test{C.java[C~C?constructor-call(void test.C.<init>())", handle);
}
checkWasntFullBuild();
List<IMessage> msgs = getErrorMessages(p);
assertEquals("error message should be 'The type C is already defined' ", "The type C is already defined",
- ((IMessage) msgs.get(0)).getMessage());
+ msgs.get(0).getMessage());
alter("PR148285_2", "inc2"); // type C in A.aj is commented out
build("PR148285_2");
checkWasntFullBuild();
// class C {}
public void testITDFQNames_pr252702() {
String p = "itdfq";
- AjdeInteractionTestbed.VERBOSE = true;
initialiseProject(p);
build(p);
AsmManager model = getModelFor(p);
}
public void testNPEIncremental_pr262218() {
- AjdeInteractionTestbed.VERBOSE = true;
String p = "pr262218";
initialiseProject(p);
build(p);
}
public void testDeclareAnnotationNPE_298504() {
- AjdeInteractionTestbed.VERBOSE = true;
String p = "pr298504";
initialiseProject(p);
build(p);
}
public void testIncrementalAnnoStyle_pr286341() {
- AjdeInteractionTestbed.VERBOSE = true;
String base = "pr286341_base";
initialiseProject(base);
build(base);
}
public void testBuildingBrokenCode_pr263323() {
- AjdeInteractionTestbed.VERBOSE = true;
String p = "brokenCode";
initialiseProject(p);
build(p);
*/
public void testItdProb() {
- AjdeInteractionTestbed.VERBOSE = true;
String p = "itdprob";
initialiseProject(p);
build(p);
public void testIncrementalBuildsWithItds_pr259528() {
String p = "pr259528";
- AjdeInteractionTestbed.VERBOSE = true;
initialiseProject(p);
build(p);
checkWasFullBuild();
List<IProgramElement> kids = start.getChildren();
if (kids != null) {
for (IProgramElement kid : kids) {
- IProgramElement found = getChild((IProgramElement) kid, name);
+ IProgramElement found = getChild(kid, name);
if (found != null) {
return found;
}
ZipFile zf = new ZipFile("c:/jvms/jdk1.6.0_06/jre/lib/rt.jar");
Enumeration<? extends ZipEntry> e = zf.entries();
while (e.hasMoreElements()) {
- ZipEntry ze = (ZipEntry) e.nextElement();
+ ZipEntry ze = e.nextElement();
String n = ze.getName();
if (n.endsWith(".class")) {
n = n.replace('/', '.');
checkWasFullBuild();
int l = AjdeInteractionTestbed.MyStateListener.detectedDeletions.size();
assertTrue("Expected one deleted file to be noticed, but detected: " + l, l == 1);
- String name = (String) AjdeInteractionTestbed.MyStateListener.detectedDeletions.get(0);
+ String name = AjdeInteractionTestbed.MyStateListener.detectedDeletions.get(0);
assertTrue("Should end with C2.java but is " + name, name.endsWith("C2.java"));
}
checkWasFullBuild();
int l = AjdeInteractionTestbed.MyStateListener.detectedDeletions.size();
assertTrue("Expected one deleted file to be noticed, but detected: " + l, l == 1);
- String name = (String) AjdeInteractionTestbed.MyStateListener.detectedDeletions.get(0);
+ String name = AjdeInteractionTestbed.MyStateListener.detectedDeletions.get(0);
assertTrue("Should end with C2.java but is " + name, name.endsWith("C2.java"));
}
List<IMessage> errors = getErrorMessages("PR119882");
assertTrue("Should be at least one error, but got none", errors.size() == 1);
assertEquals("error message should be 'i cannot be resolved to a variable' ", "i cannot be resolved to a variable",
- ((IMessage) errors.get(0)).getMessage());
+ errors.get(0).getMessage());
alter("PR119882", "inc2");
build("PR119882");
assertTrue("There should be no exceptions handled:\n" + getCompilerErrorMessages("PR119882"),
getCompilerErrorMessages("PR119882").isEmpty());
assertEquals("error message should be 'i cannot be resolved to a variable' ", "i cannot be resolved to a variable",
- ((IMessage) errors.get(0)).getMessage());
+ errors.get(0).getMessage());
}
List<IMessage> secondBuildMessages = getWeavingMessages("pr128655");
// check they are the same
for (int i = 0; i < firstBuildMessages.size(); i++) {
- IMessage m1 = (IMessage) firstBuildMessages.get(i);
- IMessage m2 = (IMessage) secondBuildMessages.get(i);
+ IMessage m1 = firstBuildMessages.get(i);
+ IMessage m2 = secondBuildMessages.get(i);
if (!m1.toString().equals(m2.toString())) {
System.err.println("Message during first build was: " + m1);
System.err.println("Message during second build was: " + m1);
List<IMessage> secondBuildMessages = getWeavingMessages("pr128655_2");
// check they are the same
for (int i = 0; i < firstBuildMessages.size(); i++) {
- IMessage m1 = (IMessage) firstBuildMessages.get(i);
- IMessage m2 = (IMessage) secondBuildMessages.get(i);
+ IMessage m1 = firstBuildMessages.get(i);
+ IMessage m2 = secondBuildMessages.get(i);
if (!m1.toString().equals(m2.toString())) {
System.err.println("Message during first build was: " + m1);
System.err.println("Message during second build was: " + m1);
}
public void testIncrementalIntelligence_Scenario01() {
- AjdeInteractionTestbed.VERBOSE = true;
initialiseProject("Project1");
initialiseProject("Project2");
configureNewProjectDependency("Project2", "Project1");
assertTrue("There should be no errors:\n" + errors, errors.isEmpty());
} else {
String expectedError = "Java 6.0 compliance level is unsupported";
- String found = ((IMessage) errors.get(0)).getMessage();
+ String found = errors.get(0).getMessage();
assertEquals("Expected 'Java 6.0 compliance level is unsupported'" + " error message but found " + found,
expectedError, found);
// This is because the 'Java 6.0 compliance' error is an 'error'
assertTrue("There should be no errors:\n" + errors, errors.isEmpty());
} else {
String expectedError = "Java 6.0 compliance level is unsupported";
- String found = ((IMessage) errors.get(0)).getMessage();
+ String found = errors.get(0).getMessage();
assertEquals("Expected 'Java 6.0 compliance level is unsupported'" + " error message but found " + found,
expectedError, found);
// This is because the 'Java 6.0 compliance' error is an 'error'
assertTrue("There should be no errros:\n" + errors, errors.isEmpty());
} else {
String expectedError = "Java 6.0 compliance level is unsupported";
- String found = ((IMessage) errors.get(0)).getMessage();
+ String found = errors.get(0).getMessage();
assertEquals("Expected 'Java 6.0 compliance level is unsupported'" + " error message but found " + found,
expectedError, found);
// This is because the 'Java 6.0 compliance' error is an 'error'
// warning about cant change parents of Object is fine
public void testInpathHandles_271201() throws Exception {
- AjdeInteractionTestbed.VERBOSE = true;
String p = "inpathHandles";
initialiseProject(p);
// warning about cant change parents of Object is fine
public void testInpathHandles_IncrementalCompilation_271201() throws Exception {
- AjdeInteractionTestbed.VERBOSE = true;
String p = "inpathHandles";
initialiseProject(p);
}
public void testInpathHandles_WithInpathMap_271201() throws Exception {
- AjdeInteractionTestbed.VERBOSE = true;
String p = "inpathHandles";
initialiseProject(p);
}
public void testInpathHandles_IncrementalCompilation_RemovingInpathEntries_271201() throws Exception {
- AjdeInteractionTestbed.VERBOSE = true;
String p = "inpathHandles2";
initialiseProject(p);
private IProgramElement getFirstRelatedElement(AsmManager model, IProgramElement programElement) {
List<String> rels = getRelatedElements(model, programElement, 1);
- return model.getHierarchy().findElementForHandle((String) rels.get(0));
+ return model.getHierarchy().findElementForHandle(rels.get(0));
}
private List<String> getRelatedElements(AsmManager model, IProgramElement advice) {