### Eclipse Workspace Patch 1.0 #P org.eclipse.ajdt.ui.tests Index: src/org/eclipse/ajdt/ui/tests/AllUITests.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.ajdt/AJDT_src/org.eclipse.ajdt.ui.tests/src/org/eclipse/ajdt/ui/tests/AllUITests.java,v retrieving revision 1.51.2.4 diff -u -r1.51.2.4 AllUITests.java --- src/org/eclipse/ajdt/ui/tests/AllUITests.java 3 Jul 2008 20:02:38 -0000 1.51.2.4 +++ src/org/eclipse/ajdt/ui/tests/AllUITests.java 11 Aug 2008 17:36:45 -0000 @@ -28,6 +28,7 @@ import org.eclipse.ajdt.ui.tests.builder.AdviceMarkersTest6; import org.eclipse.ajdt.ui.tests.builder.Bug128803Test; import org.eclipse.ajdt.ui.tests.builder.Bug151818Test; +import org.eclipse.ajdt.ui.tests.builder.Bug243376Test; import org.eclipse.ajdt.ui.tests.builder.BuildPathTests; import org.eclipse.ajdt.ui.tests.builder.BuilderTest; import org.eclipse.ajdt.ui.tests.builder.CustomMarkersTest; @@ -170,7 +171,8 @@ suite.addTest(new TestSuite(AdviceMarkersTest5.class)); suite.addTest(new TestSuite(AdviceMarkersTest6.class)); suite.addTest(new TestSuite(Bug128803Test.class)); - suite.addTest(new TestSuite(Bug151818Test.class)); + suite.addTest(new TestSuite(Bug151818Test.class)); + suite.addTest(new TestSuite(Bug243376Test.class)); suite.addTest(new TestSuite(BuilderTest.class)); suite.addTest(new TestSuite(BuildPathTests.class)); suite.addTest(new TestSuite(CustomMarkersTest.class)); Index: src/org/eclipse/ajdt/ui/tests/UITestCase.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.ajdt/AJDT_src/org.eclipse.ajdt.ui.tests/src/org/eclipse/ajdt/ui/tests/UITestCase.java,v retrieving revision 1.16.2.1 diff -u -r1.16.2.1 UITestCase.java --- src/org/eclipse/ajdt/ui/tests/UITestCase.java 3 Jul 2008 20:02:38 -0000 1.16.2.1 +++ src/org/eclipse/ajdt/ui/tests/UITestCase.java 11 Aug 2008 17:36:45 -0000 @@ -36,6 +36,9 @@ import org.eclipse.jface.action.IAction; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.text.TextViewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Event; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IEditorReference; import org.eclipse.ui.IViewReference; @@ -61,6 +64,7 @@ public abstract class UITestCase extends TestCase { public static final String TEST_PROJECTS_FOLDER = "/workspace"; //$NON-NLS-1$ + protected Display display = Display.getCurrent(); public UITestCase(String name) { super(name); @@ -325,19 +329,114 @@ return contents.toString(); } - protected static String getConsoleViewContents() { - ConsoleView cview = null; - IViewReference[] views = AspectJUIPlugin.getDefault().getWorkbench() - .getActiveWorkbenchWindow().getActivePage().getViewReferences(); - for (int i = 0; i < views.length; i++) { - if (views[i].getView(false) instanceof ConsoleView) { - cview = (ConsoleView) views[i].getView(false); - } - } - assertNotNull("Console view should be open", cview); //$NON-NLS-1$ - IOConsolePage page = (IOConsolePage) cview.getCurrentPage(); - TextViewer viewer = page.getViewer(); - return viewer.getDocument().get(); - } + protected static String getConsoleViewContents() { + ConsoleView cview = null; + IViewReference[] views = AspectJUIPlugin.getDefault().getWorkbench() + .getActiveWorkbenchWindow().getActivePage().getViewReferences(); + for (int i = 0; i < views.length; i++) { + if (views[i].getView(false) instanceof ConsoleView) { + cview = (ConsoleView) views[i].getView(false); + } + } + assertNotNull("Console view should be open", cview); //$NON-NLS-1$ + IOConsolePage page = (IOConsolePage) cview.getCurrentPage(); + TextViewer viewer = page.getViewer(); + return viewer.getDocument().get(); + } + + /** + * Post a key event (equivalent to posting a key down event then a key up + * event) + * + * @param c - + * the character to post + */ + protected void postKey(char c) { + postKeyDown(c); + postKeyUp(c); + } + + /** + * Post a key down event + * + * @param c - + * the character to post + */ + protected void postKeyDown(char c) { + Event event = new Event(); + event.type = SWT.KeyDown; + event.character = c; + display.post(event); + sleep(10); + } + + /** + * Post a key up event + * + * @param c - + * the character to post + */ + protected void postKeyUp(char c) { + Event event = new Event(); + event.type = SWT.KeyUp; + event.character = c; + display.post(event); + sleep(10); + } + + /** + * Post a key event (equivalent to posting a key down event then a key up + * event) + * + * @param keyCode - + * one of the key codes defined int he SWT class + */ + protected void postKey(int keyCode) { + postKeyDown(keyCode); + postKeyUp(keyCode); + } + + /** + * Post a key down event + * + * @param keyCode - + * one of the key codes defined int he SWT class + */ + protected void postKeyDown(int keyCode) { + Event event = new Event(); + event.type = SWT.KeyDown; + event.keyCode = keyCode; + display.post(event); + sleep(10); + } + + /** + * Post a key up event + * + * @param keyCode - + * one of the key codes defined int he SWT class + */ + protected void postKeyUp(int keyCode) { + Event event = new Event(); + event.type = SWT.KeyUp; + event.keyCode = keyCode; + display.post(event); + sleep(10); + } + + + protected void sleep() { + try { + Thread.sleep(2000); + } catch (InterruptedException e) { + } + } + + protected void sleep(int delay) { + try { + Thread.sleep(delay); + } catch (InterruptedException e) { + } + } } \ No newline at end of file Index: workspace/Project with Aspect Path/.project =================================================================== RCS file: workspace/Project with Aspect Path/.project diff -N workspace/Project with Aspect Path/.project --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/Project with Aspect Path/.project 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,18 @@ + + + Project with Aspect Path + + + + + + org.eclipse.ajdt.core.ajbuilder + + + + + + org.eclipse.ajdt.ui.ajnature + org.eclipse.jdt.core.javanature + + Index: workspace/Project with Aspect Path/bin/n/Nothing.class =================================================================== RCS file: workspace/Project with Aspect Path/bin/n/Nothing.class diff -N workspace/Project with Aspect Path/bin/n/Nothing.class --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/Project with Aspect Path/bin/n/Nothing.class 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,5 @@ +Êþº¾1 n/Nothingjava/lang/Object()VCode + LineNumberTableLocalVariableTablethis Ln/Nothing; +SourceFile Nothing.java!/*·± +  + Index: workspace/Project on Aspect Path/bin/m/Nothing.class =================================================================== RCS file: workspace/Project on Aspect Path/bin/m/Nothing.class diff -N workspace/Project on Aspect Path/bin/m/Nothing.class --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/Project on Aspect Path/bin/m/Nothing.class 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,5 @@ +Êþº¾1 m/Nothingjava/lang/Object()VCode + LineNumberTableLocalVariableTablethis Lm/Nothing; +SourceFile Nothing.java!/*·± +  + Index: workspace/Project on Aspect Path/src/m/AspectOnAspectPath.aj =================================================================== RCS file: workspace/Project on Aspect Path/src/m/AspectOnAspectPath.aj diff -N workspace/Project on Aspect Path/src/m/AspectOnAspectPath.aj --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/Project on Aspect Path/src/m/AspectOnAspectPath.aj 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,8 @@ +package m; + +public aspect AspectOnAspectPath { + + before() : execution(* *..main(String[])) { + System.out.println("Aspect has been woven!"); + } +} Index: workspace/Project with Aspect Path/src/n/Nothing.java =================================================================== RCS file: workspace/Project with Aspect Path/src/n/Nothing.java diff -N workspace/Project with Aspect Path/src/n/Nothing.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/Project with Aspect Path/src/n/Nothing.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,7 @@ +package n; + +public class Nothing { + public static void main(String[] args) { + + } +} Index: src/org/eclipse/ajdt/ui/tests/builder/Bug243376Test.java =================================================================== RCS file: src/org/eclipse/ajdt/ui/tests/builder/Bug243376Test.java diff -N src/org/eclipse/ajdt/ui/tests/builder/Bug243376Test.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/ajdt/ui/tests/builder/Bug243376Test.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,71 @@ +package org.eclipse.ajdt.ui.tests.builder; + +import java.io.IOException; + +import org.eclipse.ajdt.core.AspectJPlugin; +import org.eclipse.ajdt.internal.launching.AspectJApplicationLaunchShortcut; +import org.eclipse.ajdt.ui.tests.UITestCase; +import org.eclipse.ajdt.ui.tests.testutils.TestLogger; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IncrementalProjectBuilder; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.core.ILaunchManager; +import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor; +import org.eclipse.jface.text.IDocument; + + +public class Bug243376Test extends UITestCase { + + /** + * When a Project puts another project's out folder onto its aspect path, + * after a full build happens there is an autobuild of the dependent project. + * This is because the dependent project sees that the out folder has changed + * because of the full build and so the dependent project itself requires a full + * build. + * + * Up until AJDT 1.5.3, this has been the standard way to put projects on the + * aspect path, but this causes an unnecessary auto build. + * + * The way around this is to use project dependencies (added in AJDT 1.5.3). + * This test case tests to ensure that when a project dependency is on the + * aspect path, the unnecessary auto build does *not* occur. + */ + public void testNoAutoBuildAfterFullBuild() throws Exception { + + IProject hasAspectPath = createPredefinedProject("Project with Aspect Path"); //$NON-NLS-1$ + /* IProject onAspectPath = */ createPredefinedProject("Project on Aspect Path"); //$NON-NLS-1$ + + TestLogger testLog = new TestLogger(); + AspectJPlugin.getDefault().setAJLogger(testLog); + hasAspectPath.getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, null); + waitForJobsToComplete(); + + // open in editor and trigger something that would normally cause + // an incremental build if there was a class folder on the aspect path + IFile file = hasAspectPath.getFile("src/n/Nothing.java"); //$NON-NLS-1$ + JavaEditor editor = (JavaEditor) openFileInDefaultEditor(file, true); + editor.getViewer().getTextWidget().setText("fff"); //$NON-NLS-1$ + hasAspectPath.getWorkspace().build(IncrementalProjectBuilder.AUTO_BUILD, null); + editor.close(false); + + waitForJobsToComplete(); + + // check that there has been 2 full builds and no auto or incremental builds + assertEquals("Should have had 2 full builds", 2, testLog.numberOfEntriesForMessage("FULLBUILD")); //$NON-NLS-1$ //$NON-NLS-2$ + assertEquals("Should have had no auto builds", 0, testLog.numberOfEntriesForMessage("AUTOBUILD")); //$NON-NLS-1$ //$NON-NLS-2$ + assertEquals("Should have had no incremental builds", 0, testLog.numberOfEntriesForMessage("INCREMENTAL_BUILD")); //$NON-NLS-1$ //$NON-NLS-2$ + + // Ensure that the aspect has been properly applied + + // do launch + AspectJApplicationLaunchShortcut launcher = new AspectJApplicationLaunchShortcut(); + launcher.launch( + openFileInAspectJEditor( + file, true), + ILaunchManager.RUN_MODE); + waitForJobsToComplete(); + String console = getConsoleViewContents(); + assertEquals("Aspect has not been woven", "Aspect has been woven!\n", console); + } +} Index: workspace/Project on Aspect Path/.project =================================================================== RCS file: workspace/Project on Aspect Path/.project diff -N workspace/Project on Aspect Path/.project --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/Project on Aspect Path/.project 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,18 @@ + + + Project on Aspect Path + + + + + + org.eclipse.ajdt.core.ajbuilder + + + + + + org.eclipse.ajdt.ui.ajnature + org.eclipse.jdt.core.javanature + + Index: workspace/Project with Aspect Path/.classpath =================================================================== RCS file: workspace/Project with Aspect Path/.classpath diff -N workspace/Project with Aspect Path/.classpath --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/Project with Aspect Path/.classpath 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,12 @@ + + + + + + + + + + + + Index: workspace/Project on Aspect Path/.classpath =================================================================== RCS file: workspace/Project on Aspect Path/.classpath diff -N workspace/Project on Aspect Path/.classpath --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/Project on Aspect Path/.classpath 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,7 @@ + + + + + + + #P org.eclipse.ajdt.core Index: src/org/eclipse/ajdt/core/AspectJCorePreferences.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.ajdt/AJDT_src/org.eclipse.ajdt.core/src/org/eclipse/ajdt/core/AspectJCorePreferences.java,v retrieving revision 1.4.2.6 diff -u -r1.4.2.6 AspectJCorePreferences.java --- src/org/eclipse/ajdt/core/AspectJCorePreferences.java 7 Aug 2008 19:26:40 -0000 1.4.2.6 +++ src/org/eclipse/ajdt/core/AspectJCorePreferences.java 11 Aug 2008 17:36:47 -0000 @@ -432,6 +432,8 @@ if (requiredEntry.getEntryKind() == IClasspathEntry.CPE_SOURCE) { // always add source entries even if not explicitly exported + + // don't add the source folder itself, but instead add the outfolder IPath outputLocation = requiredEntry.getOutputLocation(); if (outputLocation != null) { // XXX Not sure what I should be doing with these @@ -440,11 +442,13 @@ IAccessRule[] rules = projEntry.getAccessRules(); IClasspathAttribute[] attributes = projEntry.getExtraAttributes(); - // don't add the source folder itself, but instead add the outfolder - IClasspathEntry outFolder = JavaCore.newLibraryEntry(outputLocation, - requiredEntry.getPath(), - requiredProj.getFullPath(), rules, attributes, projEntry.isExported()); - actualEntries.add(outFolder); + // only add the out folder if it already exists + if (requiredProj.getFolder(outputLocation.removeFirstSegments(1)).exists()) { + IClasspathEntry outFolder = JavaCore.newLibraryEntry(outputLocation, + requiredEntry.getPath(), + requiredProj.getFullPath(), rules, attributes, projEntry.isExported()); + actualEntries.add(outFolder); + } } } else if (requiredEntry.isExported()) { // must recur through this entry and add entries that it contains