Example usage for org.eclipse.jdt.core.tests.util Util getJavaClassLibs

List of usage examples for org.eclipse.jdt.core.tests.util Util getJavaClassLibs

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.tests.util Util getJavaClassLibs.

Prototype

public static String[] getJavaClassLibs() 

Source Link

Document

Search the user hard-drive for a Java class library.

Usage

From source file:org.codehaus.groovy.eclipse.codeassist.tests.CompletionTestCase.java

License:Open Source License

protected IPath createGenericProject() throws Exception {
    if (genericProjectExists()) {
        return env.getProject("Project").getFullPath();
    }/* ww  w  .  j  ava  2s  . c o m*/
    IPath projectPath = env.addProject("Project", "1.5"); //$NON-NLS-1$
    // remove old package fragment root so that names don't collide
    env.removePackageFragmentRoot(projectPath, ""); //$NON-NLS-1$
    env.addExternalJars(projectPath, Util.getJavaClassLibs());
    env.addGroovyNature("Project");
    env.addGroovyJars(projectPath);
    fullBuild(projectPath);
    env.addPackageFragmentRoot(projectPath, "src"); //$NON-NLS-1$
    env.setOutputFolder(projectPath, "bin"); //$NON-NLS-1$
    return projectPath;
}

From source file:org.codehaus.groovy.eclipse.codebrowsing.tests.BrowsingTestCase.java

License:Open Source License

protected IPath createGenericProject() throws Exception {
    IPath projectPath;/*from w w w.  j  a  v  a2s  .co m*/
    if (!ResourcesPlugin.getWorkspace().getRoot().getProject("Project").exists()) {
        projectPath = env.addProject("Project", "1.5"); //$NON-NLS-1$
        // remove old package fragment root so that names don't collide
        env.removePackageFragmentRoot(projectPath, ""); //$NON-NLS-1$
        env.addExternalJars(projectPath, Util.getJavaClassLibs());
        env.addGroovyNature("Project");
        env.addGroovyJars(projectPath);
        fullBuild(projectPath);
        env.addPackageFragmentRoot(projectPath, "src"); //$NON-NLS-1$
        env.setOutputFolder(projectPath, "bin"); //$NON-NLS-1$
    } else {
        projectPath = env.getJavaProject("Project").getPath();
    }
    return projectPath;
}

From source file:org.codehaus.groovy.eclipse.junit.test.JUnitTestCase.java

License:Open Source License

protected IPath createGenericProject() throws Exception {
    IPath projectPath = env.addProject("Project", "1.5"); //$NON-NLS-1$ //$NON-NLS-2$
    // remove old package fragment root so that names don't collide
    env.removePackageFragmentRoot(projectPath, ""); //$NON-NLS-1$
    env.addGroovyNature("Project");
    env.addExternalJars(projectPath, Util.getJavaClassLibs());
    env.addJUnitJar(projectPath);// w  w w  .ja  v  a  2 s .  c  o m
    env.addPackageFragmentRoot(projectPath, "src"); //$NON-NLS-1$
    env.setOutputFolder(projectPath, "bin"); //$NON-NLS-1$
    env.addGroovyJars(projectPath);
    fullBuild(projectPath);
    return projectPath;
}

From source file:org.eclipse.objectteams.otdt.test.builder.CompilationOrderTests.java

License:Open Source License

@SuppressWarnings("nls")
public void test177otjd5f() throws JavaModelException {
    System.out.println("***** test177otjd5f() *****");
    IPath projectPath = env.addProject("Project", "1.5");
    env.addExternalJars(projectPath, Util.getJavaClassLibs());
    env.addExternalJar(projectPath, ClasspathUtil.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", "ATeam", "package p;   \n"
            + "public team class ATeam {   protected class R implements IConfined {} public IConfined getR() { return new R(); } }");

    env.addClass(root, "p", "M",
            "package p;   \n" + "public class M {\n" + "   @SuppressWarnings(\"unused\")\n"
                    + "   void foo() {\n" + "       final ATeam t = new ATeam();\n"
                    + "       IConfined<@t> ic = t.getR();\n" + "   }\n" + "}");

    fullBuild(projectPath);//from   w  w w  .  j a  v a  2 s.c  o m
    expectingNoProblems();
}

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 www  . j ava 2s .  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);//from  w  ww  .  j  av a  2  s  .  co m
    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);/*from w  w  w .  j  a  v a 2 s . 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);//www .java2 s  .  co 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);/*from w ww. j  a v a2 s . com*/
    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);/*  ww w  .  j a va  2 s. c  o  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();
}