List of usage examples for org.eclipse.jdt.core.tests.builder Problem Problem
public Problem(String location, String message, IPath resourcePath, int start, int end, int categoryId, int severity)
From source file:org.eclipse.objectteams.otdt.test.builder.CompilationOrderTests.java
License:Open Source License
@SuppressWarnings("nls") public void testMissingOTRE() throws JavaModelException { System.out.println("***** testMissingOTRE() *****"); IPath projectPath = env.addProject("Project", "1.5"); // don't abort when detecting the build path error // (otherwise other errors would be expunged). env.getJavaProject(projectPath).setOption(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH, JavaCore.ERROR); env.addExternalJars(projectPath, Util.getJavaClassLibs()); // don't: env.addExternalJar(projectPath, OTRE_JAR_PATH); // remove old package fragment root so that names don't collide env.removePackageFragmentRoot(projectPath, ""); IPath root = env.addPackageFragmentRoot(projectPath, "src"); env.setOutputFolder(projectPath, "bin"); IPath ateam = env.addClass(root, "p", "ATeam", "package p; \n" + "public team class ATeam { ATeam() { super(); } }"); fullBuild(projectPath);/*from w w w . j ava2 s .c o m*/ expectingProblemsFor(ateam); expectingOnlySpecificProblemsFor(ateam, new Problem[] { new Problem("", "The type org.objectteams.Team cannot be resolved. It is indirectly referenced from required .class files", ateam, 30, 35, CategorizedProblem.CAT_BUILDPATH, IMarker.SEVERITY_ERROR), new Problem("", "The constructor Team() is undefined", ateam, 48, 56, CategorizedProblem.CAT_MEMBER, IMarker.SEVERITY_ERROR) }); }
From source file:org.eclipse.objectteams.otdt.test.builder.IncrementalTests.java
License:Open Source License
public void testRemoveTeamType() throws JavaModelException { System.out.println("***** testRemoveTeamType() *****"); IPath projectPath = env.addProject("Project", "1.5"); env.addExternalJars(projectPath, Util.getJavaClassLibs()); env.addExternalJar(projectPath, getOTREPath(this.weavingScheme)); // remove old package fragment root so that names don't collide env.removePackageFragmentRoot(projectPath, ""); IPath root = env.addPackageFragmentRoot(projectPath, "src"); env.setOutputFolder(projectPath, "bin"); env.addClass(root, "p", "AA", "package p; \n" + "public team class AA { }"); IPath pathToAB = env.addClass(root, "p.AA", "R", "team package p.AA; \n" + " protected class R {}"); fullBuild(projectPath);/* www . jav a2 s . c om*/ expectingNoProblems(); /* Remove team AA */ env.removeClass(env.getPackagePath(root, "p"), "AA"); /* build must detect, that R - although unchanged - becomes invalid. */ incrementalBuild(projectPath); expectingProblemsFor(pathToAB); expectingSpecificProblemFor(pathToAB, new Problem("", "Enclosing team p.AA not found for role file R (OTJLD 1.2.5(c)).", pathToAB, 13, 17, CategorizedProblem.CAT_TYPE, IMarker.SEVERITY_ERROR)); /* Restore team AA */ env.addClass(root, "p", "AA", "package p; \n" + "public team class AA {}"); incrementalBuild(projectPath); expectingNoProblems(); }
From source file:org.eclipse.objectteams.otdt.test.builder.IncrementalTests.java
License:Open Source License
public void testRemoveRoleType() throws JavaModelException { System.out.println("***** testRemoveRoleType() *****"); IPath projectPath = env.addProject("Project", "1.5"); env.addExternalJars(projectPath, Util.getJavaClassLibs()); env.addExternalJar(projectPath, getOTREPath(this.weavingScheme)); // remove old package fragment root so that names don't collide env.removePackageFragmentRoot(projectPath, ""); IPath root = env.addPackageFragmentRoot(projectPath, "src"); env.setOutputFolder(projectPath, "bin"); env.addClass(root, "p", "AA", "package p; \n" + "public team class AA { \n" + " protected class RA {}}"); IPath pathToAB = env.addClass(root, "p", "AB", "package p; \n" + "public team class AB extends AA {" + " protected class RB extends RA {} }"); fullBuild(projectPath);// w w w . j a va2s . c o m expectingNoProblems(); /* Remove role AA.RA */ env.addClass(root, "p", "AA", "package p; \n" + "public team class AA {}"); /* build must detect, that AB - although unchanged - becomes invalid. */ incrementalBuild(projectPath); expectingProblemsFor(pathToAB); expectingSpecificProblemFor(pathToAB, new Problem("", "RA cannot be resolved to a type", pathToAB, 75, 77, CategorizedProblem.CAT_TYPE, IMarker.SEVERITY_ERROR)); /* Restore role AA.RA */ env.addClass(root, "p", "AA", "package p; \n" + "public team class AA { \n" + " public class RA {}}"); incrementalBuild(projectPath); expectingNoProblems(); }
From source file:org.eclipse.objectteams.otdt.test.builder.IncrementalTests.java
License:Open Source License
public void testRemoveRoleFile() throws JavaModelException { System.out.println("***** testRemoveRoleFile() *****"); IPath projectPath = env.addProject("Project", "1.5"); env.addExternalJars(projectPath, Util.getJavaClassLibs()); env.addExternalJar(projectPath, getOTREPath(this.weavingScheme)); // remove old package fragment root so that names don't collide env.removePackageFragmentRoot(projectPath, ""); IPath root = env.addPackageFragmentRoot(projectPath, "src"); env.setOutputFolder(projectPath, "bin"); env.addClass(root, "p", "Outer", "package p; \n" + "public team class Outer {}"); IPath pathToNested = env.addClass(root, "p/Outer", "Nested", "team package p.Outer;\n" + "protected team class Nested {}"); IPath pathToOuterSub = env.addClass(root, "p", "OuterSub", "package p; \n" + "public team class OuterSub extends Outer {\n" + " Nested aRole;\n" + "}"); fullBuild(projectPath);/*from w w w . j a v a 2 s. c o m*/ expectingNoProblems(); /* Remove role Outer.Nested */ env.removeFile(pathToNested); /* build must detect, that AB - although unchanged - becomes invalid -- but no further errors/exceptions */ incrementalBuild(projectPath); expectingProblemsFor(pathToOuterSub); expectingSpecificProblemFor(pathToOuterSub, new Problem("", "Nested cannot be resolved to a type", pathToOuterSub, 58, 64, CategorizedProblem.CAT_TYPE, IMarker.SEVERITY_ERROR)); }
From source file:org.eclipse.objectteams.otdt.test.builder.IncrementalTests.java
License:Open Source License
public void testRemoveRoleMethod() throws JavaModelException { System.out.println("***** testRemoveRoleMethod() *****"); IPath projectPath = env.addProject("Project", "1.5"); env.addExternalJars(projectPath, Util.getJavaClassLibs()); env.addExternalJar(projectPath, getOTREPath(this.weavingScheme)); // remove old package fragment root so that names don't collide env.removePackageFragmentRoot(projectPath, ""); IPath root = env.addPackageFragmentRoot(projectPath, "src"); env.setOutputFolder(projectPath, "bin"); env.addClass(root, "p", "AA", "package p; \n" + "public team class AA { \n" + " public class RA { \n" + " public void foo() {}\n" + "}}"); env.addClass(root, "p", "AB", "package p; \n" + "public team class AB extends AA {" + " protected class RB extends RA {} }"); fullBuild(projectPath);/* ww w . java 2 s . c o m*/ expectingNoProblems(); /* Remove role method AA.RA.foo */ env.addClass(root, "p", "AA", "package p; \n" + "public team class AA { \n" + " public class RA {}}"); /* add a class referencing AB.RA */ IPath pathToM = env.addClass(root, "p", "M", "package p; \n" + "public class M { \n" + " void test() {\n" + " new AB().new RA().foo();\n" + "}}"); /* build must detect, that the use of AB - although AB is unchanged - becomes invalid. */ incrementalBuild(projectPath); expectingProblemsFor(pathToM); expectingSpecificProblemFor(pathToM, new Problem("", "The method foo() is undefined for the type RA<@tthis[AB]>", pathToM, 68, 71, CategorizedProblem.CAT_MEMBER, IMarker.SEVERITY_ERROR)); /* Restore method AA.RA.foo */ env.addClass(root, "p", "AA", "package p; \n" + "public team class AA { \n" + " public class RA { \n" + " public void foo() {}\n" + "}}"); incrementalBuild(projectPath); expectingNoProblems(); }
From source file:org.eclipse.objectteams.otdt.test.builder.IncrementalTests.java
License:Open Source License
public void testModifyTSuperRole1() throws JavaModelException { System.out.println("***** testModifyTSuperRole1() *****"); IPath projectPath = env.addProject("Project", "1.5"); env.addExternalJars(projectPath, Util.getJavaClassLibs()); env.addExternalJar(projectPath, getOTREPath(this.weavingScheme)); // remove old package fragment root so that names don't collide env.removePackageFragmentRoot(projectPath, ""); IPath root = env.addPackageFragmentRoot(projectPath, "src"); env.setOutputFolder(projectPath, "bin"); env.addClass(root, "p", "AA", "package p; \n" + "public team class AA { \n" + " protected class R {\n" + " void bar() { }\n" + "}}"); IPath pathToAB = env.addClass(root, "p", "AB", "package p; \n" + "public team class AB extends AA {\n" + " protected class R {\n" + " void foo() { this.bar(); }\n" + "} }"); fullBuild(projectPath);/*from w ww . ja v a 2 s. co m*/ expectingNoProblems(); /* Remove method AA.R.bar() */ env.addClass(root, "p", "AA", "package p; \n" + "public team class AA {\n" + " protected class R {}\n" + "}"); /* build must detect, that AB - although unchanged - becomes invalid through a self-call. */ incrementalBuild(projectPath); expectingProblemsFor(pathToAB); expectingSpecificProblemFor(pathToAB, new Problem("", "The method bar() is undefined for the type AB.R", pathToAB, 94, 97, CategorizedProblem.CAT_MEMBER, IMarker.SEVERITY_ERROR)); /* Restore method AA.R.bar */ env.addClass(root, "p", "AA", "package p; \n" + "public team class AA { \n" + " protected class R {\n" + " void bar() { }\n" + "}}"); incrementalBuild(projectPath); expectingNoProblems(); }
From source file:org.eclipse.objectteams.otdt.test.builder.IncrementalTests.java
License:Open Source License
public void testRemoveBoundBaseMethod() throws JavaModelException { System.out.println("***** testRemoveBoundBaseMethod() *****"); IPath projectPath = env.addProject("Project", "1.5"); env.addExternalJars(projectPath, Util.getJavaClassLibs()); env.addExternalJar(projectPath, getOTREPath(this.weavingScheme)); // remove old package fragment root so that names don't collide env.removePackageFragmentRoot(projectPath, ""); IPath root = env.addPackageFragmentRoot(projectPath, "src"); env.setOutputFolder(projectPath, "bin"); env.addClass(root, "p0", "Base", "package p0; \n" + "public class Base { \n" + " public void foo() {}\n" + "}"); IPath pathToT1 = env.addClass(root, "p", "T1", "package p; \n" + "import base p0.Base;\n" + "public team class T1 { \n" + " protected class R playedBy Base {\n" + " void bar() { } \n" + " bar <- after foo;\n" + " }\n" + "}"); fullBuild(projectPath);//w w w . j a v a 2 s .c o m expectingNoProblems(); // remove foo(): env.addClass(root, "p0", "Base", "package p0; \n" + "public class Base { \n" + "}"); env.addClass(root, "p", "T2", "package p; \n" + "public team class T2 extends T1 {}"); // must detect, that callin binding in T1 is now invalid incrementalBuild(projectPath); expectingProblemsFor(pathToT1); expectingSpecificProblemFor(pathToT1, new Problem("", "No method foo found in type p0.Base to resolve method designator (OTJLD 4.1(c)).", pathToT1, 137, 140, CategorizedProblem.CAT_MEMBER, IMarker.SEVERITY_ERROR)); // restore: env.addClass(root, "p0", "Base", "package p0; \n" + "public class Base { \n" + " public void foo() {}\n" + "}"); fullBuild(projectPath); expectingNoProblems(); }
From source file:org.eclipse.objectteams.otdt.test.builder.MultipleCallinsWarningTest.java
License:Open Source License
public void testMultipleCallinsDifferentTeams1() throws JavaModelException { System.out.println("***** testMultipleCallinsDifferentTeams1() *****"); IPath pathToBase = env.addClass(this.root, "p", "MyBase", "package p;" + NL + "public class MyBase " + NL + "{ " + NL + " public void baseMethod(){}" + NL + "} "); env.addClass(this.root, "p1", "MyTeam1", "package p1;" + NL + "import base p.MyBase;\n" + NL + "public team class MyTeam1 " + NL + "{ " + NL + " protected class MyRole playedBy MyBase " + NL + " { " + NL + " public void role1Method() {}" + NL + " role1Method <- after baseMethod; " + NL + " } " + NL + "}"); env.addClass(this.root, "p2", "MyTeam2", "package p2;" + NL + "import base p.MyBase;\n" + NL + "public team class MyTeam2 " + NL + "{ " + NL + " protected class MyRole playedBy MyBase " + NL + " { " + NL + " public void role2Method() {}" + NL + " role2Method <- after baseMethod; " + NL + " } " + NL + "}"); fullBuild(projectPath);/*from w w w .j a va2 s . c om*/ expectingProblemsFor(pathToBase); Problem expectedProblem = new Problem("", "Multiple callin bindings are affecting method baseMethod() (perform full build to recompute).", pathToBase, 51, 61, -1/*category*/, IMarker.SEVERITY_WARNING); expectingSpecificProblemFor(pathToBase, expectedProblem); }
From source file:org.eclipse.objectteams.otdt.test.builder.OTEquinoxBuilderTests.java
License:Open Source License
public void testBaseImportNoAspectBinding() throws CoreException, IOException { IJavaProject trac18b = fileManager.setUpJavaProject("Trac18b"); env.addProject(trac18b.getProject()); IJavaProject aspectPlugin = fileManager.setUpJavaProject("MissingAspectBinding"); aspectPlugin.setOption("org.eclipse.objectteams.otdt.compiler.problem.binding_conventions", "error"); env.addProject(aspectPlugin.getProject()); fullBuild();//from ww w.j a v a2 s.c o m expectingNoProblemsFor(trac18b.getPath()); expectingOnlySpecificProblemsFor(aspectPlugin.getPath(), new Problem[] { new Problem("", "Illegal base import: no aspect binding declared for team MissingAspectBindingTeam or any nested team (OT/Equinox).", aspectPlugin.getPath().append(new Path("src/MissingAspectBindingTeam.java")), 12, 34, CategorizedProblem.CAT_CODE_STYLE, IMarker.SEVERITY_ERROR) }); // now fix it: fileManager.replaceWorkspaceFile("MissingAspectBinding/plugin-corrected.xml", aspectPlugin, "plugin.xml"); incrementalBuild(); expectingNoProblemsFor(trac18b.getPath()); expectingNoProblemsFor(aspectPlugin.getPath()); }
From source file:org.eclipse.objectteams.otdt.test.builder.OTEquinoxBuilderTests.java
License:Open Source License
public void testWrongBaseImport1() throws CoreException, IOException { IJavaProject trac18b = fileManager.setUpJavaProject("Trac18b"); env.addProject(trac18b.getProject()); IJavaProject aspectPlugin = fileManager.setUpJavaProject("WrongBaseImport1"); aspectPlugin.setOption("org.eclipse.objectteams.otdt.compiler.problem.binding_conventions", "error"); env.addProject(aspectPlugin.getProject()); fullBuild();/* w ww . j ava 2s . c o m*/ expectingNoProblemsFor(trac18b.getPath()); expectingOnlySpecificProblemsFor(aspectPlugin.getPath(), new Problem[] { new Problem("", "Illegal base import: this package is not provided by the declared base plug-in(s) Trac18b (OT/Equinox).", aspectPlugin.getPath().append(new Path("src/WrongBaseImportTeam1.java")), 12, 63, CategorizedProblem.CAT_CODE_STYLE, IMarker.SEVERITY_ERROR) }); }