Example usage for org.eclipse.jdt.internal.core UserLibraryClasspathContainerInitializer UserLibraryClasspathContainerInitializer

List of usage examples for org.eclipse.jdt.internal.core UserLibraryClasspathContainerInitializer UserLibraryClasspathContainerInitializer

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.core UserLibraryClasspathContainerInitializer UserLibraryClasspathContainerInitializer.

Prototype

UserLibraryClasspathContainerInitializer

Source Link

Usage

From source file:org.eclipse.ajdt.ui.tests.builder.BuildPathTests.java

License:Open Source License

public void testInpath() throws Exception {

    // create container
    IPath containerPath = new Path("org.eclipse.jdt.USER_LIBRARY/Aspect_Path_Lib"); //$NON-NLS-1$
    IJavaProject inpathJProj = JavaCore.create(hasInpath);
    IClasspathContainer containerHint = new IClasspathContainer() {
        public IPath getPath() {
            return new Path("org.eclipse.jdt.USER_LIBRARY/Aspect_Path_Lib"); //$NON-NLS-1$
        }/*from   w  w w . j ava 2  s  .  c om*/

        public int getKind() {
            return IClasspathContainer.K_APPLICATION;
        }

        public String getDescription() {
            return ""; //$NON-NLS-1$
        }

        public IClasspathEntry[] getClasspathEntries() {
            return new IClasspathEntry[] {
                    JavaCore.newLibraryEntry(containerProj.getLocation().append("container.jar"), null, null) }; //$NON-NLS-1$
        }

    };
    UserLibraryClasspathContainerInitializer initializer = new UserLibraryClasspathContainerInitializer();
    initializer.initialize(containerPath, inpathJProj);
    initializer.requestClasspathContainerUpdate(containerPath, inpathJProj, containerHint);
    waitForJobsToComplete();
    hasInpath.getProject().build(IncrementalProjectBuilder.FULL_BUILD, null);

    waitForJobsToComplete();

    // do launch
    AspectJApplicationLaunchShortcut launcher = new AspectJApplicationLaunchShortcut();
    launcher.launch(openFileInAspectJEditor(hasInpath.getFile("src/aspects/AdviseClassOnInpath.aj"), true), //$NON-NLS-1$
            ILaunchManager.RUN_MODE);
    waitForJobsToComplete();
    String console = getConsoleViewContents();
    String exp = "advised container!"; //$NON-NLS-1$
    assertTrue("Did not find expected string '" + exp + "' in console output:\n" + console, //$NON-NLS-1$//$NON-NLS-2$
            console.indexOf(exp) != -1);
    exp = "advised project!";//$NON-NLS-1$
    assertTrue("Did not find expected string '" + exp + "' in console output:\n" + console, //$NON-NLS-1$//$NON-NLS-2$
            console.indexOf(exp) != -1);
    exp = "advised variable!";//$NON-NLS-1$
    assertTrue("Did not find expected string '" + exp + "' in console output:\n" + console, //$NON-NLS-1$//$NON-NLS-2$
            console.indexOf(exp) != -1);
    exp = "advised jar!";//$NON-NLS-1$
    assertTrue("Did not find expected string '" + exp + "' in console output:\n" + console, //$NON-NLS-1$//$NON-NLS-2$
            console.indexOf(exp) != -1);
}

From source file:org.eclipse.ajdt.ui.tests.builder.BuildPathTests.java

License:Open Source License

public void testAspectPath() throws Exception {
    // Ignore these tests on Linux because not passing
    if (System.getProperty("os.name").equals("Linux")) {
        return;/*from   ww  w . j ava  2s .  c o  m*/
    }

    // create container
    IPath containerPath = new Path("org.eclipse.jdt.USER_LIBRARY/Aspect_Path_Lib"); //$NON-NLS-1$
    IJavaProject aspectpathJProj = JavaCore.create(hasAspectpath);
    IClasspathContainer containerHint = new IClasspathContainer() {
        public IPath getPath() {
            return new Path("org.eclipse.jdt.USER_LIBRARY/Aspect_Path_Lib"); //$NON-NLS-1$
        }

        public int getKind() {
            return IClasspathContainer.K_APPLICATION;
        }

        public String getDescription() {
            return ""; //$NON-NLS-1$
        }

        public IClasspathEntry[] getClasspathEntries() {
            return new IClasspathEntry[] {
                    JavaCore.newLibraryEntry(containerProj.getLocation().append("container.jar"), null, null) }; //$NON-NLS-1$
        }
    };
    UserLibraryClasspathContainerInitializer initializer = new UserLibraryClasspathContainerInitializer();
    initializer.initialize(containerPath, aspectpathJProj);
    initializer.requestClasspathContainerUpdate(containerPath, aspectpathJProj, containerHint);

    waitForJobsToComplete();

    hasAspectpath.getProject().build(IncrementalProjectBuilder.FULL_BUILD, null);

    // do launch
    AspectJApplicationLaunchShortcut launcher = new AspectJApplicationLaunchShortcut();
    launcher.launch(openFileInAspectJEditor(hasAspectpath.getFile("src/main/Main.java"), true), //$NON-NLS-1$
            ILaunchManager.RUN_MODE);
    waitForJobsToComplete();
    String console = getConsoleViewContents();
    String exp = "from project aspect"; //$NON-NLS-1$
    assertTrue("Did not find expected string '" + exp + "' in console output:\n" + console, //$NON-NLS-1$//$NON-NLS-2$
            console.indexOf(exp) != -1);
    exp = "from jar aspect"; //$NON-NLS-1$
    assertTrue("Did not find expected string '" + exp + "' in console output:\n" + console, //$NON-NLS-1$//$NON-NLS-2$
            console.indexOf(exp) != -1);
    exp = "from variable aspect"; //$NON-NLS-1$
    assertTrue("Did not find expected string '" + exp + "' in console output:\n" + console, //$NON-NLS-1$//$NON-NLS-2$
            console.indexOf(exp) != -1);
    exp = "from container aspect"; //$NON-NLS-1$
    assertTrue("Did not find expected string '" + exp + "' in console output:\n" + console, //$NON-NLS-1$//$NON-NLS-2$
            console.indexOf(exp) != -1);
}