Source Code Cross Referenced for NewEmptyProjectWizardTest.java in  » IDE-Eclipse » jdt » org » eclipse » jdt » ui » tests » dialogs » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Eclipse » jdt » org.eclipse.jdt.ui.tests.dialogs 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*******************************************************************************
0002:         * Copyright (c) 2000, 2006 IBM Corporation and others.
0003:         * All rights reserved. This program and the accompanying materials
0004:         * are made available under the terms of the Eclipse Public License v1.0
0005:         * which accompanies this distribution, and is available at
0006:         * http://www.eclipse.org/legal/epl-v10.html
0007:         *
0008:         * Contributors:
0009:         *     IBM Corporation - initial API and implementation
0010:         *******************************************************************************/package org.eclipse.jdt.ui.tests.dialogs;
0011:
0012:        import java.io.IOException;
0013:        import java.lang.reflect.InvocationTargetException;
0014:
0015:        import org.eclipse.core.runtime.CoreException;
0016:        import org.eclipse.core.runtime.IPath;
0017:        import org.eclipse.core.runtime.Path;
0018:
0019:        import org.eclipse.core.resources.IFile;
0020:        import org.eclipse.core.resources.IFolder;
0021:
0022:        import org.eclipse.jdt.core.IClasspathEntry;
0023:        import org.eclipse.jdt.core.ICompilationUnit;
0024:        import org.eclipse.jdt.core.IJavaProject;
0025:        import org.eclipse.jdt.core.IPackageFragment;
0026:        import org.eclipse.jdt.core.IPackageFragmentRoot;
0027:        import org.eclipse.jdt.core.JavaModelException;
0028:
0029:        import org.eclipse.jdt.internal.corext.buildpath.ClasspathModifier;
0030:
0031:        import org.eclipse.jdt.ui.PreferenceConstants;
0032:
0033:        import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElement;
0034:        import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElementAttribute;
0035:        import org.eclipse.jdt.internal.ui.wizards.buildpaths.newsourcepage.BuildpathModifierAction;
0036:        import org.eclipse.jdt.internal.ui.wizards.buildpaths.newsourcepage.ClasspathModifierQueries;
0037:        import org.eclipse.jdt.internal.ui.wizards.buildpaths.newsourcepage.ClasspathModifierQueries.OutputFolderValidator;
0038:
0039:        import org.eclipse.jdt.testplugin.JavaProjectHelper;
0040:
0041:        public class NewEmptyProjectWizardTest extends NewProjectWizardTest {
0042:            private IPath defaultOutputFolder;
0043:            public static final Class THIS = NewEmptyProjectWizardTest.class;
0044:
0045:            public NewEmptyProjectWizardTest(String name) {
0046:                super (name);
0047:            }
0048:
0049:            protected void setUp() throws Exception {
0050:                fProject = fTestSetup.getWorkspaceProject();
0051:                defaultOutputFolder = fProject.getOutputLocation().append(
0052:                        PreferenceConstants.getPreferenceStore().getString(
0053:                                PreferenceConstants.SRCBIN_BINNAME));
0054:                testProjectIsOnClasspath(true);
0055:            }
0056:
0057:            public void testCreateNormalFolderOnProject() throws CoreException,
0058:                    InvocationTargetException, InterruptedException {
0059:                super .testCreateNormalFolderOnProject();
0060:                IFolder folder = getNormalFolderCreationQuery()
0061:                        .getCreatedFolder();
0062:                assertTrue(ClasspathModifier.isExcluded(folder, fProject));
0063:            }
0064:
0065:            public void testCreateSourceFolderOnProjectWithProjAsRoot()
0066:                    throws CoreException, InvocationTargetException,
0067:                    InterruptedException {
0068:                ClasspathModifierQueries.OutputFolderQuery outputFolderQuery = getOutputFolderQueryToKeepProjAsRoot();
0069:                ClasspathModifierQueries.ICreateFolderQuery folderQuery = getSourceFolderCreationQuery();
0070:                IPackageFragmentRoot root = (IPackageFragmentRoot) executeOperation(
0071:                        BuildpathModifierAction.CREATE_FOLDER, null,
0072:                        outputFolderQuery, null, folderQuery, null);
0073:
0074:                assertTrue(root.getUnderlyingResource().exists());
0075:                assertTrue(root.getElementName().equals(fSubFolder));
0076:                assertFalse(ClasspathModifier.getClasspathEntryFor(root
0077:                        .getPath(), fProject, IClasspathEntry.CPE_SOURCE) == null);
0078:                testProjectIsOnClasspath(true);
0079:                assertTrue(ClasspathModifier.isExcluded(fProject.getProject()
0080:                        .findMember(root.getPath().removeFirstSegments(1)),
0081:                        fProject));
0082:
0083:                validateClasspath();
0084:            }
0085:
0086:            public void testCreateSourceFolderOnProject() throws CoreException,
0087:                    InvocationTargetException, InterruptedException {
0088:                // ... and remove project as root
0089:                super .testCreateSourceFolderOnProject();
0090:                IFolder folder = getSourceFolderCreationQuery()
0091:                        .getCreatedFolder();
0092:                assertFalse(ClasspathModifier.getClasspathEntryFor(folder
0093:                        .getFullPath(), fProject, IClasspathEntry.CPE_SOURCE) == null);
0094:                testProjectIsOnClasspath(false);
0095:            }
0096:
0097:            public void testCreateSourceFolderOnFragRootWithProjAsRoot()
0098:                    throws CoreException, InvocationTargetException,
0099:                    InterruptedException {
0100:                ClasspathModifierQueries.OutputFolderQuery outputFolderQuery = getOutputFolderQueryToKeepProjAsRoot();
0101:                IPackageFragmentRoot parentRoot = (IPackageFragmentRoot) executeOperation(
0102:                        BuildpathModifierAction.ADD_SEL_SF_TO_BP,
0103:                        getFolderHandle(new Path(fNormalFolder)),
0104:                        outputFolderQuery, null, null, null);
0105:                assertTrue(parentRoot != null);
0106:                testProjectIsOnClasspath(true);
0107:                ClasspathModifierQueries.ICreateFolderQuery folderQuery = new ClasspathModifierQueries.ICreateFolderQuery() {
0108:
0109:                    public boolean doQuery() {
0110:                        return true;
0111:                    }
0112:
0113:                    public boolean isSourceFolder() {
0114:                        return true;
0115:                    }
0116:
0117:                    public IFolder getCreatedFolder() {
0118:                        return getFolderHandle(new Path(fNormalFolder)
0119:                                .append(fSubFolder));
0120:                    }
0121:
0122:                };
0123:                IPackageFragmentRoot root = (IPackageFragmentRoot) executeOperation(
0124:                        BuildpathModifierAction.CREATE_FOLDER, null,
0125:                        outputFolderQuery, null, folderQuery, null);
0126:                testProjectIsOnClasspath(true);
0127:                assertTrue(root.getUnderlyingResource().exists());
0128:                assertTrue(root.getParent().equals(fProject));
0129:                assertFalse(ClasspathModifier.getClasspathEntryFor(root
0130:                        .getPath(), fProject, IClasspathEntry.CPE_SOURCE) == null);
0131:
0132:                validateClasspath();
0133:            }
0134:
0135:            public void testCreateSourceFolderOnFragRoot()
0136:                    throws CoreException, InvocationTargetException,
0137:                    InterruptedException {
0138:                // ... and remove project as root
0139:                // first add a source folder, but keep project as root
0140:                ClasspathModifierQueries.OutputFolderQuery outputFolderQuery = getOutputFolderQueryToKeepProjAsRoot();
0141:                IPackageFragmentRoot parentRoot = (IPackageFragmentRoot) executeOperation(
0142:                        BuildpathModifierAction.ADD_SEL_SF_TO_BP,
0143:                        getFolderHandle(new Path(fNormalFolder)),
0144:                        outputFolderQuery, null, null, null);
0145:                testProjectIsOnClasspath(true);
0146:
0147:                // now create a child of this source folder and remove the project as root
0148:                outputFolderQuery = getOutputFolderQueryInternal(fProject
0149:                        .getPath()); // To be able to remove the project, we have to pretend that our 
0150:                // desired output location for the project is the project root itself, because the output location already changed when 
0151:                // executing adding to the buildpath (it is not possible to have a source folder if the output location is equal to the project folder).
0152:                ClasspathModifierQueries.ICreateFolderQuery folderQuery = new ClasspathModifierQueries.ICreateFolderQuery() {
0153:
0154:                    public boolean doQuery() {
0155:                        return true;
0156:                    }
0157:
0158:                    public boolean isSourceFolder() {
0159:                        return true;
0160:                    }
0161:
0162:                    public IFolder getCreatedFolder() {
0163:                        return getFolderHandle(new Path(fNormalFolder)
0164:                                .append(fSubFolder));
0165:                    }
0166:
0167:                };
0168:                IPackageFragmentRoot root = (IPackageFragmentRoot) executeOperation(
0169:                        BuildpathModifierAction.CREATE_FOLDER, null,
0170:                        outputFolderQuery, null, folderQuery, null);
0171:                assertTrue(root.getUnderlyingResource().exists());
0172:                assertTrue(root.getUnderlyingResource().getParent().equals(
0173:                        parentRoot.getUnderlyingResource()));
0174:                assertTrue(root.getParent().equals(fProject));
0175:                assertFalse(ClasspathModifier.getClasspathEntryFor(root
0176:                        .getPath(), fProject, IClasspathEntry.CPE_SOURCE) == null);
0177:                testProjectIsOnClasspath(false);
0178:
0179:                validateClasspath();
0180:            }
0181:
0182:            public void testCreateNormalFolderOnFragRootWithProjAsRoot()
0183:                    throws CoreException, InvocationTargetException,
0184:                    InterruptedException {
0185:                ClasspathModifierQueries.OutputFolderQuery outputFolderQuery = getOutputFolderQueryToKeepProjAsRoot();
0186:                IPackageFragmentRoot root = (IPackageFragmentRoot) executeOperation(
0187:                        BuildpathModifierAction.ADD_SEL_SF_TO_BP,
0188:                        getFolderHandle(new Path(fNormalFolder)),
0189:                        outputFolderQuery, null, null, null);
0190:                ClasspathModifierQueries.ICreateFolderQuery folderQuery = new ClasspathModifierQueries.ICreateFolderQuery() {
0191:
0192:                    public boolean doQuery() {
0193:                        return true;
0194:                    }
0195:
0196:                    public boolean isSourceFolder() {
0197:                        return false;
0198:                    }
0199:
0200:                    public IFolder getCreatedFolder() {
0201:                        return getFolderHandle(new Path(fNormalFolder)
0202:                                .append(fSubFolder));
0203:                    }
0204:
0205:                };
0206:                IFolder folder = (IFolder) executeOperation(
0207:                        BuildpathModifierAction.CREATE_FOLDER, null,
0208:                        outputFolderQuery, null, folderQuery, null);
0209:                assertTrue(folder.getParent().equals(
0210:                        root.getUnderlyingResource()));
0211:                testProjectIsOnClasspath(true);
0212:
0213:                validateClasspath();
0214:            }
0215:
0216:            public void testCreateSourceFolderOnFrag() throws CoreException,
0217:                    InvocationTargetException, InterruptedException {
0218:                // ... and remove project as root
0219:                final IPath srcPath = new Path("src");
0220:                ClasspathModifierQueries.OutputFolderQuery outputFolderQuery = getOutputFolderQueryToKeepProjAsRoot();
0221:                IPackageFragmentRoot parentRoot = (IPackageFragmentRoot) executeOperation(
0222:                        BuildpathModifierAction.ADD_SEL_SF_TO_BP,
0223:                        getFolderHandle(srcPath), outputFolderQuery, null,
0224:                        null, null);
0225:                IFolder fragmentFolder = getFolderHandle(srcPath
0226:                        .append(fNormalFolder));
0227:                assertTrue(fragmentFolder.getParent().equals(
0228:                        parentRoot.getUnderlyingResource()));
0229:                testProjectIsOnClasspath(true);
0230:
0231:                ClasspathModifierQueries.ICreateFolderQuery folderQuery = new ClasspathModifierQueries.ICreateFolderQuery() {
0232:
0233:                    public boolean doQuery() {
0234:                        return true;
0235:                    }
0236:
0237:                    public boolean isSourceFolder() {
0238:                        return true;
0239:                    }
0240:
0241:                    public IFolder getCreatedFolder() {
0242:                        return getFolderHandle(srcPath.append(fNormalFolder)
0243:                                .append(fSubFolder));
0244:                    }
0245:
0246:                };
0247:                IPackageFragmentRoot root = (IPackageFragmentRoot) executeOperation(
0248:                        BuildpathModifierAction.CREATE_FOLDER, null,
0249:                        getOutputFolderQueryInternal(fProject.getPath()), null,
0250:                        folderQuery, null);
0251:                assertTrue(root.getUnderlyingResource().exists());
0252:                assertTrue(root.getParent().equals(fProject));
0253:                assertTrue(root.getUnderlyingResource().getParent().equals(
0254:                        fragmentFolder));
0255:                testProjectIsOnClasspath(false);
0256:
0257:                validateClasspath();
0258:            }
0259:
0260:            public void testCreateSourceFolderOnFragWithProjAsRoot()
0261:                    throws CoreException, InvocationTargetException,
0262:                    InterruptedException {
0263:                super .testCreateSourceFolderOnFrag();
0264:                testProjectIsOnClasspath(false);
0265:            }
0266:
0267:            public void testCreateNormalFolderOnFrag() throws CoreException,
0268:                    InvocationTargetException, InterruptedException {
0269:                super .testCreateNormalFolderOnFrag();
0270:                testProjectIsOnClasspath(false);
0271:            }
0272:
0273:            public void testCreateNormalFolderOnFragWithProjAsRoot()
0274:                    throws CoreException, InvocationTargetException,
0275:                    InterruptedException {
0276:                final IPath srcPath = new Path("src");
0277:                ClasspathModifierQueries.OutputFolderQuery outputFolderQuery = getOutputFolderQueryToKeepProjAsRoot();
0278:                IPackageFragmentRoot parentRoot = (IPackageFragmentRoot) executeOperation(
0279:                        BuildpathModifierAction.ADD_SEL_SF_TO_BP,
0280:                        getFolderHandle(srcPath), outputFolderQuery, null,
0281:                        null, null);
0282:                IFolder fragmentFolder = getFolderHandle(srcPath
0283:                        .append(fNormalFolder));
0284:                assertTrue(fragmentFolder.getParent().equals(
0285:                        parentRoot.getUnderlyingResource()));
0286:                testProjectIsOnClasspath(true);
0287:
0288:                ClasspathModifierQueries.ICreateFolderQuery folderQuery = new ClasspathModifierQueries.ICreateFolderQuery() {
0289:
0290:                    public boolean doQuery() {
0291:                        return true;
0292:                    }
0293:
0294:                    public boolean isSourceFolder() {
0295:                        return false;
0296:                    }
0297:
0298:                    public IFolder getCreatedFolder() {
0299:                        return getFolderHandle(srcPath.append(fNormalFolder)
0300:                                .append(fSubFolder));
0301:                    }
0302:
0303:                };
0304:
0305:                IFolder folder = (IFolder) executeOperation(
0306:                        BuildpathModifierAction.CREATE_FOLDER, null,
0307:                        getOutputFolderQueryToKeepProjAsRoot(), null,
0308:                        folderQuery, null);
0309:                assertTrue(folder.getParent().equals(fragmentFolder));
0310:                testProjectIsOnClasspath(true);
0311:
0312:                validateClasspath();
0313:            }
0314:
0315:            // Test adding/removing to classpath
0316:            public void testAddProjectToCPAndKeepDefaultOutputLocation()
0317:                    throws CoreException, InvocationTargetException,
0318:                    InterruptedException {
0319:                // first we need to remove the project from the classpath
0320:                testRemoveProjectToCPAndKeepDefaultOutputLocation();
0321:
0322:                // then we add it again
0323:                IPath[] paths = getPaths();
0324:                assertFalse(contains(fProject.getPath(), paths, null));
0325:
0326:                IJavaProject project = (IJavaProject) executeOperation(
0327:                        BuildpathModifierAction.ADD_SEL_SF_TO_BP, fProject,
0328:                        getOutputFolderQueryInternal(fProject
0329:                                .getOutputLocation()), null, null, null);
0330:
0331:                paths = getPaths();
0332:                assertTrue(contains(fProject.getPath(), paths, null));
0333:                assertTrue(project.equals(fProject));
0334:
0335:                testProjectIsOnClasspath(true);
0336:
0337:                validateClasspath();
0338:            }
0339:
0340:            public void testAddNormalFolderToCP() throws JavaModelException,
0341:                    CoreException, InvocationTargetException,
0342:                    InterruptedException {
0343:                // ... and remove project as root
0344:                int numberOfEntries = fProject.getRawClasspath().length;
0345:
0346:                IPackageFragmentRoot root = addToClasspath(new Path(
0347:                        fNormalFolder));
0348:
0349:                int newNumberOfEntries = fProject.getRawClasspath().length;
0350:                // the number remains equal because we removed the project
0351:                // as root and added another src folder
0352:                assertTrue(numberOfEntries == newNumberOfEntries);
0353:                assertTrue(root.getParent().equals(fProject));
0354:                testProjectIsOnClasspath(false);
0355:
0356:                validateClasspath();
0357:            }
0358:
0359:            public void testAddNormalFolderToCPWithProjAsRoot()
0360:                    throws JavaModelException, CoreException,
0361:                    InvocationTargetException, InterruptedException {
0362:                int numberOfEntries = fProject.getRawClasspath().length;
0363:                IFolder folder = getFolderHandle(new Path(fNormalFolder));
0364:
0365:                IPath[] paths = getPaths();
0366:                assertFalse(contains(folder.getFullPath(), paths, null));
0367:                IPackageFragmentRoot root = (IPackageFragmentRoot) executeOperation(
0368:                        BuildpathModifierAction.ADD_SEL_SF_TO_BP, folder,
0369:                        getOutputFolderQueryToKeepProjAsRoot(), null, null,
0370:                        null);
0371:
0372:                paths = getPaths();
0373:                assertTrue(contains(folder.getFullPath(), getPaths(), null));
0374:
0375:                int newNumberOfEntries = fProject.getRawClasspath().length;
0376:                assertTrue(numberOfEntries + 1 == newNumberOfEntries);
0377:                assertTrue(root.getParent().equals(fProject));
0378:                testProjectIsOnClasspath(true);
0379:
0380:                validateClasspath();
0381:            }
0382:
0383:            public void testAddNestedNormalFolderToCP()
0384:                    throws JavaModelException, CoreException,
0385:                    InvocationTargetException, InterruptedException {
0386:                IFolder cpFolder = getFolderHandle(new Path(fNormalFolder));
0387:                IPackageFragmentRoot root = (IPackageFragmentRoot) executeOperation(
0388:                        BuildpathModifierAction.ADD_SEL_SF_TO_BP, cpFolder,
0389:                        getOutputFolderQueryToKeepProjAsRoot(), null, null,
0390:                        null);
0391:
0392:                IFolder folder = getFolderHandle(cpFolder
0393:                        .getProjectRelativePath().append(fSubFolder));
0394:                IPackageFragment fragment = root.getPackageFragment(folder
0395:                        .getName());
0396:
0397:                IClasspathEntry entry = root.getRawClasspathEntry();
0398:                int nrExcluded = entry.getExclusionPatterns().length;
0399:                folder = (IFolder) executeOperation(
0400:                        BuildpathModifierAction.EXCLUDE, fragment, null, null,
0401:                        null, null);
0402:                assertTrue(folder.getFullPath().equals(fragment.getPath()));
0403:
0404:                entry = root.getRawClasspathEntry();
0405:                IPath[] exclusionPatterns = entry.getExclusionPatterns();
0406:                assertTrue(nrExcluded + 1 == exclusionPatterns.length);
0407:                assertTrue(contains(new Path(fragment.getElementName()),
0408:                        exclusionPatterns, null));
0409:
0410:                IPackageFragmentRoot newRoot = (IPackageFragmentRoot) executeOperation(
0411:                        BuildpathModifierAction.ADD_SEL_SF_TO_BP, folder,
0412:                        getOutputFolderQueryInternal(defaultOutputFolder),
0413:                        null, null, null);
0414:                assertTrue(newRoot.getPath().equals(folder.getFullPath()));
0415:
0416:                entry = root.getRawClasspathEntry();
0417:                assertTrue(contains(new Path(folder.getName()), entry
0418:                        .getExclusionPatterns(), null));
0419:                assertFalse(ClasspathModifier.getClasspathEntryFor(folder
0420:                        .getFullPath(), fProject, IClasspathEntry.CPE_SOURCE) == null);
0421:                testProjectIsOnClasspath(true);
0422:
0423:                validateClasspath();
0424:            }
0425:
0426:            public void testAddNestedNormalFolderToCPWithProjAsRoot()
0427:                    throws JavaModelException, CoreException,
0428:                    InvocationTargetException, InterruptedException {
0429:                // ... and remove project as root
0430:                IFolder cpFolder = getFolderHandle(new Path(fNormalFolder));
0431:                IPackageFragmentRoot root = (IPackageFragmentRoot) executeOperation(
0432:                        BuildpathModifierAction.ADD_SEL_SF_TO_BP, cpFolder,
0433:                        getOutputFolderQueryToKeepProjAsRoot(), null, null,
0434:                        null);
0435:
0436:                IFolder folder = getFolderHandle(cpFolder
0437:                        .getProjectRelativePath().append(fSubFolder));
0438:                IPackageFragment fragment = root.getPackageFragment(folder
0439:                        .getName());
0440:
0441:                IClasspathEntry entry = root.getRawClasspathEntry();
0442:                int nrExcluded = entry.getExclusionPatterns().length;
0443:                executeOperation(BuildpathModifierAction.EXCLUDE, fragment,
0444:                        null, null, null, null);
0445:
0446:                entry = root.getRawClasspathEntry();
0447:                IPath[] exclusionPatterns = entry.getExclusionPatterns();
0448:                assertTrue(nrExcluded + 1 == exclusionPatterns.length);
0449:                assertTrue(contains(new Path(fragment.getElementName()),
0450:                        exclusionPatterns, null));
0451:
0452:                executeOperation(BuildpathModifierAction.ADD_SEL_SF_TO_BP,
0453:                        folder,
0454:                        getOutputFolderQueryInternal(fProject.getPath()), null,
0455:                        null, null);
0456:
0457:                entry = root.getRawClasspathEntry();
0458:                assertTrue(contains(new Path(folder.getName()), entry
0459:                        .getExclusionPatterns(), null));
0460:                assertFalse(ClasspathModifier.getClasspathEntryFor(folder
0461:                        .getFullPath(), fProject, IClasspathEntry.CPE_SOURCE) == null);
0462:                testProjectIsOnClasspath(false);
0463:
0464:                validateClasspath();
0465:            }
0466:
0467:            public void testAddPackageToCP() throws JavaModelException,
0468:                    CoreException, InvocationTargetException,
0469:                    InterruptedException {
0470:                // ... and remove project as root
0471:                IPackageFragmentRoot parentRoot = createFragmentRootAndKeepProjAsRoot();
0472:                getFolderHandle(parentRoot.getPath().removeFirstSegments(1)
0473:                        .append(fSubFolder)); // because add to buildpath requires the fragments underlying resource to exist
0474:                IPackageFragment fragment = parentRoot
0475:                        .getPackageFragment(fSubFolder);
0476:                IClasspathEntry entry = parentRoot.getRawClasspathEntry();
0477:
0478:                int nrExclusions = entry.getExclusionPatterns().length;
0479:                assertFalse(contains(new Path(fragment.getElementName()), entry
0480:                        .getExclusionPatterns(), null));
0481:
0482:                IPackageFragmentRoot root = (IPackageFragmentRoot) executeOperation(
0483:                        BuildpathModifierAction.ADD_SEL_SF_TO_BP, fragment,
0484:                        getOutputFolderQueryInternal(fProject.getPath()), null,
0485:                        null, null);
0486:
0487:                entry = parentRoot.getRawClasspathEntry();
0488:                assertTrue(contains(new Path(fragment.getElementName()), entry
0489:                        .getExclusionPatterns(), null));
0490:                assertTrue(entry.getExclusionPatterns().length - 1 == nrExclusions);
0491:                assertTrue(root.getParent().equals(fProject));
0492:                testProjectIsOnClasspath(false);
0493:
0494:                validateClasspath();
0495:            }
0496:
0497:            public void testAddPackageToCPWithProjAsRoot()
0498:                    throws JavaModelException, CoreException,
0499:                    InvocationTargetException, InterruptedException {
0500:                IPackageFragmentRoot parentRoot = createFragmentRootAndKeepProjAsRoot();
0501:                getFolderHandle(parentRoot.getPath().removeFirstSegments(1)
0502:                        .append(fSubFolder)); // because add to buildpath requires the fragments underlying resource to exist
0503:                IPackageFragment fragment = parentRoot
0504:                        .getPackageFragment(fSubFolder);
0505:                IClasspathEntry entry = parentRoot.getRawClasspathEntry();
0506:
0507:                int nrExclusions = entry.getExclusionPatterns().length;
0508:                assertFalse(contains(new Path(fragment.getElementName()), entry
0509:                        .getExclusionPatterns(), null));
0510:
0511:                IPackageFragmentRoot root = (IPackageFragmentRoot) executeOperation(
0512:                        BuildpathModifierAction.ADD_SEL_SF_TO_BP, fragment,
0513:                        getOutputFolderQueryToKeepProjAsRoot(), null, null,
0514:                        null);
0515:
0516:                entry = parentRoot.getRawClasspathEntry();
0517:                assertTrue(contains(new Path(fragment.getElementName()), entry
0518:                        .getExclusionPatterns(), null));
0519:                assertTrue(entry.getExclusionPatterns().length - 1 == nrExclusions);
0520:                assertTrue(root.getParent().equals(fProject));
0521:                testProjectIsOnClasspath(true);
0522:
0523:                validateClasspath();
0524:            }
0525:
0526:            // TODO refine + tests for project as root
0527:            public void testAddJarFileToCP() throws InvocationTargetException,
0528:                    InterruptedException, CoreException, IOException {
0529:                super .testAddJarFileToCP();
0530:                testProjectIsOnClasspath(false);
0531:            }
0532:
0533:            public void testAddJarFileToCPWithProjAsRoot()
0534:                    throws InvocationTargetException, InterruptedException,
0535:                    CoreException {
0536:                // create root parent for jar file
0537:                IPackageFragmentRoot parentRoot = createFragmentRootAndKeepProjAsRoot();
0538:                IPath libraryPath = parentRoot.getPath().append("archive.jar");
0539:                IPackageFragmentRoot root = JavaProjectHelper.addLibrary(
0540:                        fProject, libraryPath);
0541:                assertFalse(ClasspathModifier.getClasspathEntryFor(root
0542:                        .getPath(), fProject, IClasspathEntry.CPE_LIBRARY) == null);
0543:
0544:                // after creation, the jar file is on the buildpath --> remove it first
0545:                IFile jarFile = (IFile) executeOperation(
0546:                        BuildpathModifierAction.REMOVE_FROM_BP, root, null,
0547:                        null, null, null);
0548:                jarFile.create(null, false, null); // underlying resource must exist --> create
0549:                assertTrue(jarFile.getFileExtension().equals("jar"));
0550:                assertTrue(ClasspathModifier.isArchive(jarFile, fProject));
0551:                assertTrue(ClasspathModifier.getClasspathEntryFor(jarFile
0552:                        .getFullPath(), fProject, IClasspathEntry.CPE_LIBRARY) == null);
0553:
0554:                // now it can be added and tested
0555:                root = (IPackageFragmentRoot) executeOperation(
0556:                        BuildpathModifierAction.ADD_SEL_LIB_TO_BP, jarFile,
0557:                        null, null, null, null);
0558:                assertFalse(ClasspathModifier.getClasspathEntryFor(root
0559:                        .getPath(), fProject, IClasspathEntry.CPE_LIBRARY) == null);
0560:                testProjectIsOnClasspath(true);
0561:
0562:                validateClasspath();
0563:            }
0564:
0565:            public void testAddJarFileToCPWithProjAsRootAndParent()
0566:                    throws InvocationTargetException, InterruptedException,
0567:                    CoreException {
0568:                // create root parent for jar file
0569:                IPackageFragmentRoot parentRoot = ClasspathModifier
0570:                        .getFragmentRoot(fProject.getUnderlyingResource(),
0571:                                fProject, null);
0572:                IPath libraryPath = parentRoot.getPath().append("archive.jar");
0573:                IPackageFragmentRoot root = JavaProjectHelper.addLibrary(
0574:                        fProject, libraryPath);
0575:                assertFalse(ClasspathModifier.getClasspathEntryFor(root
0576:                        .getPath(), fProject, IClasspathEntry.CPE_LIBRARY) == null);
0577:                assertTrue(root.getParent().equals(fProject));
0578:
0579:                // after creation, the jar file is on the buildpath --> remove it first
0580:                IFile jarFile = (IFile) executeOperation(
0581:                        BuildpathModifierAction.REMOVE_FROM_BP, root, null,
0582:                        null, null, null);
0583:                jarFile.create(null, false, null); // underlying resource must exist --> create
0584:                assertTrue(jarFile.getFileExtension().equals("jar"));
0585:                assertTrue(ClasspathModifier.isArchive(jarFile, fProject));
0586:                assertTrue(ClasspathModifier.getClasspathEntryFor(jarFile
0587:                        .getFullPath(), fProject, IClasspathEntry.CPE_LIBRARY) == null);
0588:
0589:                // now it can be added and tested
0590:                root = (IPackageFragmentRoot) executeOperation(
0591:                        BuildpathModifierAction.ADD_SEL_LIB_TO_BP, jarFile,
0592:                        null, null, null, null);
0593:                assertFalse(ClasspathModifier.getClasspathEntryFor(root
0594:                        .getPath(), fProject, IClasspathEntry.CPE_LIBRARY) == null);
0595:                //testProjectIsOnClasspath(true);
0596:
0597:                validateClasspath();
0598:            }
0599:
0600:            public void testAddJarFileToCPWithProjWithProjAsParentButRemovedAsRoot()
0601:                    throws InvocationTargetException, InterruptedException,
0602:                    CoreException {
0603:                // create root parent for jar file
0604:                IPackageFragmentRoot parentRoot = ClasspathModifier
0605:                        .getFragmentRoot(fProject.getUnderlyingResource(),
0606:                                fProject, null);
0607:                IPath libraryPath = parentRoot.getPath().append("archive.jar");
0608:                IPackageFragmentRoot root = JavaProjectHelper.addLibrary(
0609:                        fProject, libraryPath);
0610:                assertFalse(ClasspathModifier.getClasspathEntryFor(root
0611:                        .getPath(), fProject, IClasspathEntry.CPE_LIBRARY) == null);
0612:                assertTrue(root.getParent().equals(fProject));
0613:
0614:                // after creation, the jar file is on the buildpath --> remove it first
0615:                IFile jarFile = (IFile) executeOperation(
0616:                        BuildpathModifierAction.REMOVE_FROM_BP, root, null,
0617:                        null, null, null);
0618:                jarFile.create(null, false, null); // underlying resource must exist --> create
0619:                assertTrue(jarFile.getFileExtension().equals("jar"));
0620:                assertTrue(ClasspathModifier.isArchive(jarFile, fProject));
0621:                assertTrue(ClasspathModifier.getClasspathEntryFor(jarFile
0622:                        .getFullPath(), fProject, IClasspathEntry.CPE_LIBRARY) == null);
0623:
0624:                // now it can be added and tested
0625:                root = (IPackageFragmentRoot) executeOperation(
0626:                        BuildpathModifierAction.ADD_SEL_LIB_TO_BP, jarFile,
0627:                        null, null, null, null);
0628:                assertFalse(ClasspathModifier.getClasspathEntryFor(root
0629:                        .getPath(), fProject, IClasspathEntry.CPE_LIBRARY) == null);
0630:                //testProjectIsOnClasspath(false);
0631:
0632:                validateClasspath();
0633:            }
0634:
0635:            public void testAddZipFileToCP() throws InvocationTargetException,
0636:                    InterruptedException, CoreException {
0637:                super .testAddZipFileToCP();
0638:                testProjectIsOnClasspath(false);
0639:            }
0640:
0641:            public void testAddZipFileToCPWithProjAsRoot()
0642:                    throws InvocationTargetException, InterruptedException,
0643:                    CoreException {
0644:                // create root parent for jar file
0645:                IPackageFragmentRoot parentRoot = createFragmentRootAndKeepProjAsRoot();
0646:                IPath libraryPath = parentRoot.getPath().append("archive.zip");
0647:                IPackageFragmentRoot root = JavaProjectHelper.addLibrary(
0648:                        fProject, libraryPath);
0649:                assertFalse(ClasspathModifier.getClasspathEntryFor(root
0650:                        .getPath(), fProject, IClasspathEntry.CPE_LIBRARY) == null);
0651:
0652:                // after creation, the jar file is on the buildpath --> remove it first
0653:                IFile jarFile = (IFile) executeOperation(
0654:                        BuildpathModifierAction.REMOVE_FROM_BP, root, null,
0655:                        null, null, null);
0656:                jarFile.create(null, false, null); // underlying resource must exist --> create
0657:                assertTrue(jarFile.getFileExtension().equals("zip"));
0658:                assertTrue(ClasspathModifier.isArchive(jarFile, fProject));
0659:                assertTrue(ClasspathModifier.getClasspathEntryFor(jarFile
0660:                        .getFullPath(), fProject, IClasspathEntry.CPE_LIBRARY) == null);
0661:
0662:                // now it can be added and tested
0663:                root = (IPackageFragmentRoot) executeOperation(
0664:                        BuildpathModifierAction.ADD_SEL_LIB_TO_BP, jarFile,
0665:                        null, null, null, null);
0666:                assertFalse(ClasspathModifier.getClasspathEntryFor(root
0667:                        .getPath(), fProject, IClasspathEntry.CPE_LIBRARY) == null);
0668:                testProjectIsOnClasspath(true);
0669:
0670:                validateClasspath();
0671:            }
0672:
0673:            public void testAddZipFileToCPWithProjAsRootAndParent()
0674:                    throws InvocationTargetException, InterruptedException,
0675:                    CoreException {
0676:                // create root parent for jar file
0677:                IPackageFragmentRoot parentRoot = ClasspathModifier
0678:                        .getFragmentRoot(fProject.getUnderlyingResource(),
0679:                                fProject, null);
0680:                IPath libraryPath = parentRoot.getPath().append("archive.zip");
0681:                IPackageFragmentRoot root = JavaProjectHelper.addLibrary(
0682:                        fProject, libraryPath);
0683:                assertFalse(ClasspathModifier.getClasspathEntryFor(root
0684:                        .getPath(), fProject, IClasspathEntry.CPE_LIBRARY) == null);
0685:                assertTrue(root.getParent().equals(fProject));
0686:
0687:                // after creation, the jar file is on the buildpath --> remove it first
0688:                IFile jarFile = (IFile) executeOperation(
0689:                        BuildpathModifierAction.REMOVE_FROM_BP, root, null,
0690:                        null, null, null);
0691:                jarFile.create(null, false, null); // underlying resource must exist --> create
0692:                assertTrue(jarFile.getFileExtension().equals("zip"));
0693:                assertTrue(ClasspathModifier.isArchive(jarFile, fProject));
0694:                assertTrue(ClasspathModifier.getClasspathEntryFor(jarFile
0695:                        .getFullPath(), fProject, IClasspathEntry.CPE_LIBRARY) == null);
0696:
0697:                // now it can be added and tested
0698:                root = (IPackageFragmentRoot) executeOperation(
0699:                        BuildpathModifierAction.ADD_SEL_LIB_TO_BP, jarFile,
0700:                        null, null, null, null);
0701:                assertFalse(ClasspathModifier.getClasspathEntryFor(root
0702:                        .getPath(), fProject, IClasspathEntry.CPE_LIBRARY) == null);
0703:                testProjectIsOnClasspath(true);
0704:
0705:                validateClasspath();
0706:            }
0707:
0708:            public void testAddZipFileToCPWithProjWithProjAsParentButRemovedAsRoot()
0709:                    throws InvocationTargetException, InterruptedException,
0710:                    CoreException {
0711:                // create root parent for jar file
0712:                IPackageFragmentRoot parentRoot = ClasspathModifier
0713:                        .getFragmentRoot(fProject.getUnderlyingResource(),
0714:                                fProject, null);
0715:                IPath libraryPath = parentRoot.getPath().append("archive.zip");
0716:                IPackageFragmentRoot root = JavaProjectHelper.addLibrary(
0717:                        fProject, libraryPath);
0718:                assertFalse(ClasspathModifier.getClasspathEntryFor(root
0719:                        .getPath(), fProject, IClasspathEntry.CPE_LIBRARY) == null);
0720:                assertTrue(root.getParent().equals(fProject));
0721:
0722:                // after creation, the jar file is on the buildpath --> remove it first
0723:                IFile jarFile = (IFile) executeOperation(
0724:                        BuildpathModifierAction.REMOVE_FROM_BP, root, null,
0725:                        null, null, null);
0726:                jarFile.create(null, false, null); // underlying resource must exist --> create
0727:                assertTrue(jarFile.getFileExtension().equals("zip"));
0728:                assertTrue(ClasspathModifier.isArchive(jarFile, fProject));
0729:                assertTrue(ClasspathModifier.getClasspathEntryFor(jarFile
0730:                        .getFullPath(), fProject, IClasspathEntry.CPE_LIBRARY) == null);
0731:
0732:                // now it can be added and tested
0733:                root = (IPackageFragmentRoot) executeOperation(
0734:                        BuildpathModifierAction.ADD_SEL_LIB_TO_BP, jarFile,
0735:                        null, null, null, null);
0736:                assertFalse(ClasspathModifier.getClasspathEntryFor(root
0737:                        .getPath(), fProject, IClasspathEntry.CPE_LIBRARY) == null);
0738:                //testProjectIsOnClasspath(false);
0739:
0740:                validateClasspath();
0741:            }
0742:
0743:            public void testAddJREToCP() throws InvocationTargetException,
0744:                    InterruptedException, CoreException {
0745:                super .testAddJREToCP();
0746:                testProjectIsOnClasspath(true);
0747:            }
0748:
0749:            public void testAddIncludedPackageToCP() throws JavaModelException,
0750:                    CoreException, InvocationTargetException,
0751:                    InterruptedException {
0752:                // ... and remove project as root
0753:                IPackageFragmentRoot parentRoot = includePackageAndKeepProjAsRoot();
0754:                IPackageFragment fragment = parentRoot
0755:                        .getPackageFragment(fSubFolder);
0756:
0757:                IClasspathEntry entry = parentRoot.getRawClasspathEntry();
0758:
0759:                int nrInclusions = entry.getInclusionPatterns().length;
0760:                int nrExclusions = entry.getExclusionPatterns().length;
0761:                assertTrue(contains(new Path(fragment.getElementName()), entry
0762:                        .getInclusionPatterns(), null));
0763:                assertFalse(contains(new Path(fragment.getElementName()), entry
0764:                        .getExclusionPatterns(), null));
0765:
0766:                IPackageFragmentRoot root = (IPackageFragmentRoot) executeOperation(
0767:                        BuildpathModifierAction.ADD_SEL_SF_TO_BP, fragment,
0768:                        getOutputFolderQueryInternal(fProject.getPath()), null,
0769:                        null, null);
0770:
0771:                entry = parentRoot.getRawClasspathEntry();
0772:                assertFalse(contains(new Path(root.getElementName()), entry
0773:                        .getInclusionPatterns(), null));
0774:                assertTrue(contains(new Path(root.getElementName()), entry
0775:                        .getExclusionPatterns(), null));
0776:                assertTrue(entry.getInclusionPatterns().length + 1 == nrInclusions);
0777:                assertTrue(entry.getExclusionPatterns().length - 1 == nrExclusions);
0778:                assertTrue(root.getParent().equals(fProject));
0779:                testProjectIsOnClasspath(false);
0780:
0781:                validateClasspath();
0782:            }
0783:
0784:            public void testAddIncludedPackageToCPWithProjAsRoot()
0785:                    throws JavaModelException, CoreException,
0786:                    InvocationTargetException, InterruptedException {
0787:                IPackageFragmentRoot parentRoot = includePackageAndKeepProjAsRoot();
0788:                IPackageFragment fragment = parentRoot
0789:                        .getPackageFragment(fSubFolder);
0790:
0791:                IClasspathEntry entry = parentRoot.getRawClasspathEntry();
0792:
0793:                int nrInclusions = entry.getInclusionPatterns().length;
0794:                int nrExclusions = entry.getExclusionPatterns().length;
0795:                assertTrue(contains(new Path(fragment.getElementName()), entry
0796:                        .getInclusionPatterns(), null));
0797:                assertFalse(contains(new Path(fragment.getElementName()), entry
0798:                        .getExclusionPatterns(), null));
0799:
0800:                IPackageFragmentRoot root = (IPackageFragmentRoot) executeOperation(
0801:                        BuildpathModifierAction.ADD_SEL_SF_TO_BP, fragment,
0802:                        getOutputFolderQueryToKeepProjAsRoot(), null, null,
0803:                        null);
0804:
0805:                entry = parentRoot.getRawClasspathEntry();
0806:                assertFalse(contains(new Path(root.getElementName()), entry
0807:                        .getInclusionPatterns(), null));
0808:                assertTrue(contains(new Path(root.getElementName()), entry
0809:                        .getExclusionPatterns(), null));
0810:                assertTrue(entry.getInclusionPatterns().length + 1 == nrInclusions);
0811:                assertTrue(entry.getExclusionPatterns().length - 1 == nrExclusions);
0812:                assertTrue(root.getParent().equals(fProject));
0813:                testProjectIsOnClasspath(true);
0814:
0815:                validateClasspath();
0816:            }
0817:
0818:            public void testAddExcludedPackageToCP() throws JavaModelException,
0819:                    CoreException, InvocationTargetException,
0820:                    InterruptedException {
0821:                // ... and remove project as root
0822:                IPackageFragmentRoot parentRoot = excludePackageAndKeepProjAsRoot();
0823:                IPackageFragment fragment = parentRoot
0824:                        .getPackageFragment(fSubFolder);
0825:
0826:                IClasspathEntry entry = parentRoot.getRawClasspathEntry();
0827:                assertTrue(contains(new Path(fragment.getElementName()), entry
0828:                        .getExclusionPatterns(), null));
0829:
0830:                IPath[] paths = getPaths();
0831:                assertFalse(contains(fragment.getPath(), paths, null));
0832:
0833:                IPackageFragmentRoot root = (IPackageFragmentRoot) executeOperation(
0834:                        BuildpathModifierAction.ADD_SEL_SF_TO_BP, fragment,
0835:                        getOutputFolderQueryInternal(fProject.getPath()), null,
0836:                        null, null);
0837:
0838:                paths = getPaths();
0839:                assertTrue(contains(fragment.getPath(), paths, null));
0840:
0841:                parentRoot = fProject.findPackageFragmentRoot(parentRoot
0842:                        .getPath());
0843:                entry = parentRoot.getRawClasspathEntry();
0844:
0845:                assertTrue(contains(new Path(root.getElementName()), entry
0846:                        .getExclusionPatterns(), null));
0847:                testProjectIsOnClasspath(false);
0848:
0849:                validateClasspath();
0850:            }
0851:
0852:            public void testAddExcludedPackageToCPWithProjAsRoot()
0853:                    throws JavaModelException, CoreException,
0854:                    InvocationTargetException, InterruptedException {
0855:                IPackageFragmentRoot parentRoot = excludePackageAndKeepProjAsRoot();
0856:                IPackageFragment fragment = parentRoot
0857:                        .getPackageFragment(fSubFolder);
0858:
0859:                IClasspathEntry entry = parentRoot.getRawClasspathEntry();
0860:                assertTrue(contains(new Path(fragment.getElementName()), entry
0861:                        .getExclusionPatterns(), null));
0862:
0863:                IPackageFragmentRoot root = (IPackageFragmentRoot) executeOperation(
0864:                        BuildpathModifierAction.ADD_SEL_SF_TO_BP, fragment,
0865:                        getOutputFolderQueryToKeepProjAsRoot(), null, null,
0866:                        null);
0867:
0868:                parentRoot = fProject.findPackageFragmentRoot(parentRoot
0869:                        .getPath());
0870:                entry = parentRoot.getRawClasspathEntry();
0871:
0872:                assertTrue(contains(new Path(root.getElementName()), entry
0873:                        .getExclusionPatterns(), null));
0874:                testProjectIsOnClasspath(true);
0875:
0876:                validateClasspath();
0877:            }
0878:
0879:            public void testRemoveProjectToCPAndKeepDefaultOutputLocation()
0880:                    throws CoreException, InvocationTargetException,
0881:                    InterruptedException {
0882:                executeOperation(BuildpathModifierAction.REMOVE_FROM_BP,
0883:                        fProject, null, null, null, null);
0884:                testProjectIsOnClasspath(false);
0885:
0886:                validateClasspath();
0887:            }
0888:
0889:            public void testRemoveFromCP() throws JavaModelException,
0890:                    CoreException, InvocationTargetException,
0891:                    InterruptedException {
0892:                // project is not root
0893:                // add folder
0894:                int before = fProject.getRawClasspath().length;
0895:                IFolder folder = getFolderHandle(new Path(fNormalFolder));
0896:                IPackageFragmentRoot root = addToClasspath(new Path(
0897:                        fNormalFolder));
0898:
0899:                // and remove it
0900:
0901:                executeOperation(BuildpathModifierAction.REMOVE_FROM_BP, root,
0902:                        null, null, null, null);
0903:                assertFalse(contains(folder.getFullPath(), getPaths(), null));
0904:                int after = fProject.getRawClasspath().length;
0905:                assertTrue(before - 1 == after);
0906:                // the minus one is correct because:
0907:                // first the project was the root and had an cp entry
0908:                // then a src folder was added and the cp entry from the
0909:                // project was removed.
0910:                // at last, the entry for the folder was removed.
0911:                // It follows that the number of cp entries has decreased by one
0912:
0913:                validateClasspath();
0914:                testProjectIsOnClasspath(false);
0915:            }
0916:
0917:            public void testRemoveFromCPWithProjAsRoot()
0918:                    throws JavaModelException, CoreException,
0919:                    InvocationTargetException, InterruptedException {
0920:                // add folder
0921:                int before = fProject.getRawClasspath().length;
0922:                IPackageFragmentRoot root = createFragmentRootAndKeepProjAsRoot();
0923:
0924:                // and remove it
0925:                IFolder folder = (IFolder) executeOperation(
0926:                        BuildpathModifierAction.REMOVE_FROM_BP, root, null,
0927:                        null, null, null);
0928:                assertFalse(contains(folder.getFullPath(), getPaths(), null));
0929:                int after = fProject.getRawClasspath().length;
0930:                assertTrue(before == after);
0931:                testProjectIsOnClasspath(true);
0932:
0933:                validateClasspath();
0934:            }
0935:
0936:            public void testRemoveZipFileFromCP()
0937:                    throws InvocationTargetException, InterruptedException,
0938:                    CoreException {
0939:                super .testRemoveZipFileFromCP();
0940:                testProjectIsOnClasspath(false);
0941:            }
0942:
0943:            public void testRemoveJarFileFromCP()
0944:                    throws InvocationTargetException, InterruptedException,
0945:                    CoreException, IOException {
0946:                super .testRemoveJarFileFromCP();
0947:                testProjectIsOnClasspath(false);
0948:            }
0949:
0950:            public void testRemoveJREFromCP() throws InvocationTargetException,
0951:                    InterruptedException, CoreException {
0952:                super .testRemoveJREFromCP();
0953:                testProjectIsOnClasspath(true);
0954:            }
0955:
0956:            // Test include, exclude, uninclude, unexclude, ...
0957:
0958:            // Note that include and exclude does not have any impact whether
0959:            // the project is on the classpath or not as long as the included/excluded
0960:            // element was not a direct child of the project!
0961:            // So the default testing is done by the super class while we have to
0962:            // test only these special cases.
0963:            public void testIncludePackageOnProject()
0964:                    throws JavaModelException, InvocationTargetException,
0965:                    InterruptedException {
0966:                IPackageFragment fragment = createFragmentOnProject();
0967:                IPackageFragmentRoot root = getProjectRoot(fragment
0968:                        .getUnderlyingResource());
0969:
0970:                assertFalse(contains(fragment.getPath().removeFirstSegments(1),
0971:                        root.getRawClasspathEntry().getInclusionPatterns(),
0972:                        null));
0973:                fragment = (IPackageFragment) executeOperation(
0974:                        BuildpathModifierAction.INCLUDE, fragment, null, null,
0975:                        null, null);
0976:                assertTrue(contains(fragment.getPath().removeFirstSegments(1),
0977:                        root.getRawClasspathEntry().getInclusionPatterns(),
0978:                        null));
0979:                testProjectIsOnClasspath(true);
0980:
0981:                validateClasspath();
0982:            }
0983:
0984:            public void testExcludePackageOnProject()
0985:                    throws JavaModelException, InvocationTargetException,
0986:                    InterruptedException {
0987:                IPackageFragment fragment = createFragmentOnProject();
0988:                IPackageFragmentRoot root = getProjectRoot(fragment
0989:                        .getUnderlyingResource());
0990:
0991:                assertFalse(contains(fragment.getPath().removeFirstSegments(1),
0992:                        root.getRawClasspathEntry().getExclusionPatterns(),
0993:                        null));
0994:                IFolder excludedFolder = (IFolder) executeOperation(
0995:                        BuildpathModifierAction.EXCLUDE, fragment, null, null,
0996:                        null, null);
0997:                assertTrue(contains(excludedFolder.getProjectRelativePath(),
0998:                        root.getRawClasspathEntry().getExclusionPatterns(),
0999:                        null));
1000:                testProjectIsOnClasspath(true);
1001:
1002:                validateClasspath();
1003:            }
1004:
1005:            public void testExcludeIncludedPackageOnProject()
1006:                    throws JavaModelException, InvocationTargetException,
1007:                    InterruptedException {
1008:                IPackageFragment fragment = createFragmentOnProject();
1009:                IPackageFragmentRoot root = getProjectRoot(fragment
1010:                        .getUnderlyingResource());
1011:
1012:                // include
1013:                assertFalse(contains(fragment.getPath().removeFirstSegments(1),
1014:                        root.getRawClasspathEntry().getInclusionPatterns(),
1015:                        null));
1016:                fragment = (IPackageFragment) executeOperation(
1017:                        BuildpathModifierAction.INCLUDE, fragment, null, null,
1018:                        null, null);
1019:                assertTrue(contains(fragment.getPath().removeFirstSegments(1),
1020:                        root.getRawClasspathEntry().getInclusionPatterns(),
1021:                        null));
1022:
1023:                IClasspathEntry entry = root.getRawClasspathEntry();
1024:                int nrIncluded = entry.getInclusionPatterns().length;
1025:                int nrExcluded = entry.getExclusionPatterns().length;
1026:
1027:                // exclude
1028:                assertFalse(contains(fragment.getPath().removeFirstSegments(1),
1029:                        root.getRawClasspathEntry().getExclusionPatterns(),
1030:                        null));
1031:                IFolder excludedFolder = (IFolder) executeOperation(
1032:                        BuildpathModifierAction.EXCLUDE, fragment, null, null,
1033:                        null, null);
1034:                assertTrue(contains(excludedFolder.getProjectRelativePath(),
1035:                        root.getRawClasspathEntry().getExclusionPatterns(),
1036:                        null));
1037:                assertFalse(contains(fragment.getPath().removeFirstSegments(1),
1038:                        root.getRawClasspathEntry().getInclusionPatterns(),
1039:                        null));
1040:
1041:                assertTrue(root.getRawClasspathEntry().getInclusionPatterns().length + 1 == nrIncluded);
1042:                assertTrue(root.getRawClasspathEntry().getExclusionPatterns().length - 1 == nrExcluded);
1043:                testProjectIsOnClasspath(true);
1044:
1045:                validateClasspath();
1046:            }
1047:
1048:            public void testIncludeExcludedFolderOnProject()
1049:                    throws JavaModelException, CoreException,
1050:                    InvocationTargetException, InterruptedException {
1051:                IPackageFragment fragment = createFragmentOnProject();
1052:                IPackageFragmentRoot root = getProjectRoot(fragment
1053:                        .getUnderlyingResource());
1054:
1055:                // exclude
1056:                assertFalse(contains(fragment.getPath().removeFirstSegments(1),
1057:                        root.getRawClasspathEntry().getExclusionPatterns(),
1058:                        null));
1059:                IFolder excludedFolder = (IFolder) executeOperation(
1060:                        BuildpathModifierAction.EXCLUDE, fragment, null, null,
1061:                        null, null);
1062:                assertTrue(contains(excludedFolder.getProjectRelativePath(),
1063:                        root.getRawClasspathEntry().getExclusionPatterns(),
1064:                        null));
1065:
1066:                IClasspathEntry entry = root.getRawClasspathEntry();
1067:                int nrIncluded = entry.getInclusionPatterns().length;
1068:                int nrExcluded = entry.getExclusionPatterns().length;
1069:
1070:                // include
1071:                assertFalse(contains(fragment.getPath().removeFirstSegments(1),
1072:                        root.getRawClasspathEntry().getInclusionPatterns(),
1073:                        null));
1074:                fragment = (IPackageFragment) executeOperation(
1075:                        BuildpathModifierAction.INCLUDE, excludedFolder, null,
1076:                        null, null, null);
1077:                assertTrue(contains(fragment.getPath().removeFirstSegments(1),
1078:                        root.getRawClasspathEntry().getInclusionPatterns(),
1079:                        null));
1080:                assertFalse(contains(fragment.getPath().removeFirstSegments(1),
1081:                        root.getRawClasspathEntry().getExclusionPatterns(),
1082:                        null));
1083:
1084:                assertTrue(root.getRawClasspathEntry().getInclusionPatterns().length - 1 == nrIncluded);
1085:                assertTrue(root.getRawClasspathEntry().getExclusionPatterns().length + 1 == nrExcluded);
1086:                testProjectIsOnClasspath(true);
1087:
1088:                validateClasspath();
1089:            }
1090:
1091:            public void testRemoveInclusionOnProject()
1092:                    throws JavaModelException, InvocationTargetException,
1093:                    InterruptedException {
1094:                IPackageFragment fragment = createFragmentOnProject();
1095:                IPackageFragmentRoot root = getProjectRoot(fragment
1096:                        .getUnderlyingResource());
1097:
1098:                assertFalse(contains(fragment.getPath().removeFirstSegments(1),
1099:                        root.getRawClasspathEntry().getInclusionPatterns(),
1100:                        null));
1101:                fragment = (IPackageFragment) executeOperation(
1102:                        BuildpathModifierAction.INCLUDE, fragment, null, null,
1103:                        null, null);
1104:                assertTrue(contains(fragment.getPath().removeFirstSegments(1),
1105:                        root.getRawClasspathEntry().getInclusionPatterns(),
1106:                        null));
1107:
1108:                // remove inclusion
1109:                fragment = (IPackageFragment) executeOperation(
1110:                        BuildpathModifierAction.UNINCLUDE, fragment, null,
1111:                        null, null, null);
1112:                assertFalse(contains(fragment.getPath().removeFirstSegments(1),
1113:                        root.getRawClasspathEntry().getInclusionPatterns(),
1114:                        null));
1115:                testProjectIsOnClasspath(true);
1116:
1117:                validateClasspath();
1118:            }
1119:
1120:            public void testRemoveExclusionOnProject()
1121:                    throws JavaModelException, InvocationTargetException,
1122:                    InterruptedException {
1123:                IPackageFragment fragment = createFragmentOnProject();
1124:                IPackageFragmentRoot root = getProjectRoot(fragment
1125:                        .getUnderlyingResource());
1126:
1127:                assertFalse(contains(fragment.getPath().removeFirstSegments(1),
1128:                        root.getRawClasspathEntry().getExclusionPatterns(),
1129:                        null));
1130:                IFolder excludedFolder = (IFolder) executeOperation(
1131:                        BuildpathModifierAction.EXCLUDE, fragment, null, null,
1132:                        null, null);
1133:                assertTrue(contains(excludedFolder.getProjectRelativePath(),
1134:                        root.getRawClasspathEntry().getExclusionPatterns(),
1135:                        null));
1136:
1137:                // remove exclusion
1138:                fragment = (IPackageFragment) executeOperation(
1139:                        BuildpathModifierAction.UNEXCLUDE, excludedFolder,
1140:                        null, null, null, null);
1141:                assertFalse(contains(fragment.getPath().removeFirstSegments(1),
1142:                        root.getRawClasspathEntry().getExclusionPatterns(),
1143:                        null));
1144:                testProjectIsOnClasspath(true);
1145:
1146:                validateClasspath();
1147:            }
1148:
1149:            public void testEditFiltersOnProject() throws JavaModelException,
1150:                    InvocationTargetException, InterruptedException {
1151:                IPackageFragmentRoot root = getProjectRoot(fProject
1152:                        .getUnderlyingResource());
1153:                final IPackageFragment includedPackage = root
1154:                        .getPackageFragment(fSubFolder);
1155:                final IPackageFragment excludedPackage = root
1156:                        .getPackageFragment(fSubFolder + "2");
1157:
1158:                assertFalse(contains(new Path(includedPackage.getElementName())
1159:                        .addTrailingSeparator(), root.getRawClasspathEntry()
1160:                        .getInclusionPatterns(), null));
1161:                assertFalse(contains(new Path(excludedPackage.getElementName())
1162:                        .addTrailingSeparator(), root.getRawClasspathEntry()
1163:                        .getExclusionPatterns(), null));
1164:
1165:                ClasspathModifierQueries.IInclusionExclusionQuery query = new ClasspathModifierQueries.IInclusionExclusionQuery() {
1166:
1167:                    public boolean doQuery(CPListElement element,
1168:                            boolean focusOnExcluded) {
1169:                        return true;
1170:                    }
1171:
1172:                    public IPath[] getInclusionPattern() {
1173:                        return new IPath[] { new Path(includedPackage
1174:                                .getElementName()).addTrailingSeparator() };
1175:                    }
1176:
1177:                    public IPath[] getExclusionPattern() {
1178:                        return new IPath[] { new Path(excludedPackage
1179:                                .getElementName()).addTrailingSeparator() };
1180:                    }
1181:
1182:                };
1183:                IJavaProject jProject = (IJavaProject) executeOperation(
1184:                        BuildpathModifierAction.EDIT_FILTERS, fProject, null,
1185:                        null, null, query);
1186:                assertTrue(jProject.equals(fProject));
1187:
1188:                root = getProjectRoot(fProject.getUnderlyingResource());
1189:                assertTrue(contains(new Path(includedPackage.getElementName())
1190:                        .addTrailingSeparator(), root.getRawClasspathEntry()
1191:                        .getInclusionPatterns(), null));
1192:                assertTrue(contains(new Path(excludedPackage.getElementName())
1193:                        .addTrailingSeparator(), root.getRawClasspathEntry()
1194:                        .getExclusionPatterns(), null));
1195:
1196:                validateClasspath();
1197:            }
1198:
1199:            public void testResetFiltersOnProject() throws CoreException,
1200:                    InvocationTargetException, InterruptedException {
1201:                IPackageFragmentRoot root = createFragmentRootAndKeepProjAsRoot();
1202:
1203:                IPackageFragment includedPackage = root
1204:                        .getPackageFragment(fSubFolder);
1205:                IPackageFragment excludedPackage = root
1206:                        .getPackageFragment(fSubFolder + "2");
1207:                IFolder subSrcFolder = getFolderHandle(root.getPath()
1208:                        .removeFirstSegments(1).append(fSubFolder + "3"));
1209:
1210:                executeOperation(BuildpathModifierAction.INCLUDE,
1211:                        includedPackage, null, null, null, null);
1212:                executeOperation(BuildpathModifierAction.INCLUDE,
1213:                        excludedPackage, null, null, null, null);
1214:                executeOperation(BuildpathModifierAction.ADD_SEL_SF_TO_BP,
1215:                        subSrcFolder, getOutputFolderQueryToKeepProjAsRoot(),
1216:                        null, null, null);
1217:                int numberOnCP = fProject.getRawClasspath().length;
1218:
1219:                executeOperation(BuildpathModifierAction.RESET, root, null,
1220:                        null, null, null);
1221:
1222:                IPackageFragmentRoot projectRoot = getProjectRoot(fProject
1223:                        .getUnderlyingResource());
1224:                IClasspathEntry entry = projectRoot.getRawClasspathEntry();
1225:                assertTrue(entry.getInclusionPatterns().length == 0);
1226:                // one has to be left because it is a source folder
1227:                assertTrue(entry.getExclusionPatterns().length == 1);
1228:                assertTrue(contains(root.getPath(), getPaths(), null));
1229:                assertTrue(contains(subSrcFolder.getFullPath(), getPaths(),
1230:                        null));
1231:                assertTrue(fProject.getRawClasspath().length == numberOnCP);
1232:                testProjectIsOnClasspath(true);
1233:
1234:                validateClasspath();
1235:            }
1236:
1237:            // Test output folder manipulations (create, edit, reset)
1238:            public void testCreateOutputFolder() throws JavaModelException,
1239:                    CoreException, InvocationTargetException,
1240:                    InterruptedException {
1241:                IPath oldOutputPath = fProject.getPath();
1242:                IPath newOutputPath = oldOutputPath.append(PreferenceConstants
1243:                        .getPreferenceStore().getString(
1244:                                PreferenceConstants.SRCBIN_BINNAME)
1245:                        + "2");
1246:                createOutputFolder(newOutputPath);
1247:                testProjectIsOnClasspath(false);
1248:
1249:                validateClasspath();
1250:            }
1251:
1252:            public void testCreateOutputFolderWithProjAsRootCancel()
1253:                    throws JavaModelException, CoreException,
1254:                    InvocationTargetException, InterruptedException {
1255:                // Creation of the output folder is cancelled
1256:                IPath oldOutputPath = fProject.getPath();
1257:                IPath newOutputPath = oldOutputPath.append(PreferenceConstants
1258:                        .getPreferenceStore().getString(
1259:                                PreferenceConstants.SRCBIN_BINNAME)
1260:                        + "2");
1261:                IPackageFragmentRoot root = createFragmentRootAndKeepProjAsRoot();
1262:
1263:                IFolder outputFolder = fProject.getProject().getFolder(
1264:                        newOutputPath);
1265:                assertFalse(outputFolder.exists());
1266:
1267:                ClasspathModifierQueries.IOutputLocationQuery query = new ClasspathModifierQueries.IOutputLocationQuery() {
1268:
1269:                    public boolean doQuery(CPListElement element) {
1270:                        return false; // cancel
1271:                    }
1272:
1273:                    public IPath getOutputLocation() {
1274:                        // not important here
1275:                        return null;
1276:                    }
1277:
1278:                    public ClasspathModifierQueries.OutputFolderQuery getOutputFolderQuery(
1279:                            IPath path) {
1280:                        return new ClasspathModifierQueries.OutputFolderQuery(
1281:                                null) {
1282:
1283:                            public boolean doQuery(boolean b,
1284:                                    OutputFolderValidator validator,
1285:                                    IJavaProject project) {
1286:                                return false;
1287:                            }
1288:
1289:                            public IPath getOutputLocation() {
1290:                                return null;
1291:                            }
1292:
1293:                            public boolean removeProjectFromClasspath() {
1294:                                return true;
1295:                            }
1296:
1297:                        };
1298:                    }
1299:
1300:                };
1301:                CPListElementAttribute outputAttribute = (CPListElementAttribute) executeOperation(
1302:                        BuildpathModifierAction.CREATE_OUTPUT, root, null,
1303:                        query, null, null);
1304:                assertTrue(outputAttribute == null);
1305:                testProjectIsOnClasspath(true);
1306:
1307:                validateClasspath();
1308:            }
1309:
1310:            public void testCreateOutputFolderWithProjAsRoot()
1311:                    throws JavaModelException, CoreException,
1312:                    InvocationTargetException, InterruptedException {
1313:                // Creation of the output folder is accepted and project is removed as root
1314:                IPath oldOutputPath = fProject.getPath();
1315:                IPath newOutputPath = oldOutputPath.append(PreferenceConstants
1316:                        .getPreferenceStore().getString(
1317:                                PreferenceConstants.SRCBIN_BINNAME)
1318:                        + "2");
1319:                IPackageFragmentRoot root = createFragmentRootAndKeepProjAsRoot();
1320:
1321:                IFolder outputFolder = fProject.getProject().getFolder(
1322:                        newOutputPath);
1323:                assertFalse(outputFolder.exists());
1324:
1325:                ClasspathModifierQueries.IOutputLocationQuery query = getOutputLocationQuery();
1326:                CPListElementAttribute outputAttribute = (CPListElementAttribute) executeOperation(
1327:                        BuildpathModifierAction.CREATE_OUTPUT, root, null,
1328:                        query, null, null);
1329:                root = fProject.findPackageFragmentRoot(root.getPath());
1330:                CPListElement elem = CPListElement.createFromExisting(root
1331:                        .getRawClasspathEntry(), fProject);
1332:
1333:                assertTrue(((IPath) outputAttribute.getValue())
1334:                        .equals(newOutputPath));
1335:                assertTrue(((IPath) outputAttribute.getValue()).equals(elem
1336:                        .getAttribute(CPListElement.OUTPUT)));
1337:                testProjectIsOnClasspath(true); // the project has still a classpath entry, but the output location has changed
1338:                assertFalse(fProject.getOutputLocation().equals(
1339:                        fProject.getPath()));
1340:
1341:                validateClasspath();
1342:            }
1343:
1344:            public void testEditOutputFolder() throws JavaModelException,
1345:                    CoreException, InvocationTargetException,
1346:                    InterruptedException {
1347:                // ... and remove project as root
1348:                IPackageFragmentRoot root = createFragmentRootAndKeepProjAsRoot();
1349:                IPath oldOutputPath = fProject.getPath();
1350:                CPListElement elem = CPListElement.createFromExisting(root
1351:                        .getRawClasspathEntry(), fProject);
1352:                CPListElementAttribute outputFolder = new CPListElementAttribute(
1353:                        elem, CPListElement.OUTPUT, elem
1354:                                .getAttribute(CPListElement.OUTPUT), true);
1355:
1356:                final IPath editedOutputPath = oldOutputPath
1357:                        .append(PreferenceConstants.getPreferenceStore()
1358:                                .getString(PreferenceConstants.SRCBIN_BINNAME)
1359:                                + "3");
1360:                ClasspathModifierQueries.IOutputLocationQuery query = new ClasspathModifierQueries.IOutputLocationQuery() {
1361:
1362:                    public boolean doQuery(CPListElement element) {
1363:                        return true;
1364:                    }
1365:
1366:                    public IPath getOutputLocation() {
1367:                        return editedOutputPath;
1368:                    }
1369:
1370:                    public ClasspathModifierQueries.OutputFolderQuery getOutputFolderQuery(
1371:                            IPath path) throws JavaModelException {
1372:                        return NewEmptyProjectWizardTest.this 
1373:                                .getOutputFolderQueryInternal(defaultOutputFolder);
1374:                    }
1375:                };
1376:                outputFolder = (CPListElementAttribute) executeOperation(
1377:                        BuildpathModifierAction.EDIT_OUTPUT, outputFolder,
1378:                        null, query, null, null);
1379:                root = fProject.findPackageFragmentRoot(root.getPath());
1380:                elem = CPListElement.createFromExisting(root
1381:                        .getRawClasspathEntry(), fProject);
1382:
1383:                assertTrue(((IPath) outputFolder.getValue())
1384:                        .equals(editedOutputPath));
1385:                assertTrue(((IPath) outputFolder.getValue()).equals(elem
1386:                        .getAttribute(CPListElement.OUTPUT)));
1387:                testProjectIsOnClasspath(true);
1388:                assertFalse(fProject.getOutputLocation().equals(
1389:                        fProject.getPath()));
1390:
1391:                validateClasspath();
1392:            }
1393:
1394:            public void testEditOutputFolderWithProjAsRoot()
1395:                    throws JavaModelException, CoreException,
1396:                    InvocationTargetException, InterruptedException {
1397:                // Editing of the output folder is cancelled
1398:                IPackageFragmentRoot root = createFragmentRootAndKeepProjAsRoot();
1399:                IPath oldOutputPath = fProject.getPath();
1400:                CPListElement elem = CPListElement.createFromExisting(root
1401:                        .getRawClasspathEntry(), fProject);
1402:                CPListElementAttribute outputFolder = new CPListElementAttribute(
1403:                        elem, CPListElement.OUTPUT, elem
1404:                                .getAttribute(CPListElement.OUTPUT), true);
1405:
1406:                final IPath editedOutputPath = oldOutputPath
1407:                        .append(PreferenceConstants.getPreferenceStore()
1408:                                .getString(PreferenceConstants.SRCBIN_BINNAME)
1409:                                + "3");
1410:                ClasspathModifierQueries.IOutputLocationQuery query = new ClasspathModifierQueries.IOutputLocationQuery() {
1411:
1412:                    public boolean doQuery(CPListElement element) {
1413:                        return false; // cancel the operation
1414:                    }
1415:
1416:                    public IPath getOutputLocation() {
1417:                        return editedOutputPath;
1418:                    }
1419:
1420:                    public ClasspathModifierQueries.OutputFolderQuery getOutputFolderQuery(
1421:                            IPath path) {
1422:                        return new ClasspathModifierQueries.OutputFolderQuery(
1423:                                null) {
1424:
1425:                            public boolean doQuery(boolean b,
1426:                                    OutputFolderValidator validator,
1427:                                    IJavaProject project) {
1428:                                // cancel the operation
1429:                                return false;
1430:                            }
1431:
1432:                            public IPath getOutputLocation() {
1433:                                return null;
1434:                            }
1435:
1436:                            public boolean removeProjectFromClasspath() {
1437:                                return true;
1438:                            }
1439:
1440:                        };
1441:                    }
1442:                };
1443:                outputFolder = (CPListElementAttribute) executeOperation(
1444:                        BuildpathModifierAction.EDIT_OUTPUT, outputFolder,
1445:                        null, query, null, null);
1446:                assertTrue(outputFolder == null);
1447:                testProjectIsOnClasspath(true);
1448:
1449:                validateClasspath();
1450:            }
1451:
1452:            public void testEditOutputFolderWithNullReturn()
1453:                    throws JavaModelException, CoreException,
1454:                    InvocationTargetException, InterruptedException {
1455:                // here we have to set the future output folder to /WorkspaceProject/bin2 because
1456:                // createOutputFolder() adds a new source folder to the project and removes the project as root
1457:                // therefore the default output for the project changes to .../bin and editing changes it again to
1458:                // .../bin2.
1459:                final CPListElementAttribute attribute = createOutputFolder(fProject
1460:                        .getOutputLocation().append("bin2"));
1461:                IPackageFragmentRoot root = fProject
1462:                        .findPackageFragmentRoot(fProject.getPath().append(
1463:                                fNormalFolder));
1464:
1465:                assertTrue(root.getRawClasspathEntry().getOutputLocation() != null);
1466:
1467:                ClasspathModifierQueries.IOutputLocationQuery query = new ClasspathModifierQueries.IOutputLocationQuery() {
1468:
1469:                    public boolean doQuery(CPListElement element) {
1470:                        return true;
1471:                    }
1472:
1473:                    public IPath getOutputLocation() {
1474:                        return null;
1475:                    }
1476:
1477:                    public ClasspathModifierQueries.OutputFolderQuery getOutputFolderQuery(
1478:                            IPath path) throws JavaModelException {
1479:                        return getOutputFolderQueryInternal(defaultOutputFolder);
1480:                    }
1481:                };
1482:                CPListElementAttribute newAttribute = (CPListElementAttribute) executeOperation(
1483:                        BuildpathModifierAction.EDIT_OUTPUT, attribute, null,
1484:                        query, null, null);
1485:
1486:                assertTrue(root.getRawClasspathEntry().getOutputLocation() == null);
1487:                assertTrue(newAttribute.getValue() == null);
1488:
1489:                validateClasspath();
1490:            }
1491:
1492:            public void testEditOutputFolderWithNullReturnAndProjAsRoot()
1493:                    throws JavaModelException, CoreException,
1494:                    InvocationTargetException, InterruptedException {
1495:                IPackageFragmentRoot root = createFragmentRootAndKeepProjAsRoot();
1496:                final IPath path = fProject.getPath().append("bin2");
1497:                ClasspathModifierQueries.IOutputLocationQuery query = new ClasspathModifierQueries.IOutputLocationQuery() {
1498:                    public boolean doQuery(CPListElement element) {
1499:                        return true;
1500:                    }
1501:
1502:                    public IPath getOutputLocation() {
1503:                        return path;
1504:                    }
1505:
1506:                    public ClasspathModifierQueries.OutputFolderQuery getOutputFolderQuery(
1507:                            IPath path2) throws JavaModelException {
1508:                        return getOutputFolderQueryInternal(defaultOutputFolder);
1509:                    }
1510:                };
1511:                CPListElementAttribute attribute = (CPListElementAttribute) executeOperation(
1512:                        BuildpathModifierAction.CREATE_OUTPUT, root, null,
1513:                        query, null, null);
1514:
1515:                root = fProject.findPackageFragmentRoot(root.getPath());
1516:                assertTrue(root.getRawClasspathEntry().getOutputLocation()
1517:                        .equals(path));
1518:                assertTrue(fProject.getOutputLocation().segmentCount() > 1);
1519:
1520:                query = new ClasspathModifierQueries.IOutputLocationQuery() {
1521:
1522:                    public boolean doQuery(CPListElement element) {
1523:                        return true;
1524:                    }
1525:
1526:                    public IPath getOutputLocation() {
1527:                        return null;
1528:                    }
1529:
1530:                    public ClasspathModifierQueries.OutputFolderQuery getOutputFolderQuery(
1531:                            IPath path2) throws JavaModelException {
1532:                        return getOutputFolderQueryToKeepProjAsRoot();
1533:                    }
1534:                };
1535:                CPListElementAttribute newAttribute = (CPListElementAttribute) executeOperation(
1536:                        BuildpathModifierAction.EDIT_OUTPUT, attribute, null,
1537:                        query, null, null);
1538:
1539:                assertTrue(root.getRawClasspathEntry().getOutputLocation() == null);
1540:                assertTrue(newAttribute.getValue() == null);
1541:                testProjectIsOnClasspath(true);
1542:
1543:                validateClasspath();
1544:            }
1545:
1546:            public void testResetOutputFolder() throws JavaModelException,
1547:                    CoreException, InvocationTargetException,
1548:                    InterruptedException {
1549:                IPath oldOutputPath = fProject.getPath();
1550:                IPath newOutputPath = oldOutputPath.append(PreferenceConstants
1551:                        .getPreferenceStore().getString(
1552:                                PreferenceConstants.SRCBIN_BINNAME)
1553:                        + "2");
1554:                CPListElementAttribute outputFolder = createOutputFolder(newOutputPath);
1555:                outputFolder = (CPListElementAttribute) executeOperation(
1556:                        BuildpathModifierAction.RESET, outputFolder, null,
1557:                        null, null, null);
1558:                assertTrue(outputFolder.getValue() == null);
1559:                testProjectIsOnClasspath(false);
1560:
1561:                validateClasspath();
1562:            }
1563:
1564:            // Test file manipulations (include, exclude, ...)
1565:            // Note that include and exclude does not have any impact whether
1566:            // the project is on the classpath or not as long as the included/excluded
1567:            // element was not a direct child of the project!
1568:            // So the default testing is done by the super class while we have to
1569:            // test only these special cases for files.
1570:            public void testIncludeFileOnProject() throws JavaModelException,
1571:                    InvocationTargetException, InterruptedException {
1572:                IPackageFragmentRoot projectRoot = getProjectRoot(fProject
1573:                        .getCorrespondingResource());
1574:                IPackageFragment fragment = projectRoot.createPackageFragment(
1575:                        "", false, null);
1576:                ICompilationUnit cu = createICompilationUnit("C", fragment);
1577:
1578:                assertTrue(projectRoot.getRawClasspathEntry()
1579:                        .getInclusionPatterns().length == 0);
1580:
1581:                cu = (ICompilationUnit) executeOperation(
1582:                        BuildpathModifierAction.INCLUDE, cu, null, null, null,
1583:                        null);
1584:
1585:                assertTrue(contains(cu.getPath().removeFirstSegments(1),
1586:                        projectRoot.getRawClasspathEntry()
1587:                                .getInclusionPatterns(), null));
1588:                testProjectIsOnClasspath(true);
1589:
1590:                validateClasspath();
1591:            }
1592:
1593:            public void testExcludeFileOnProject() throws JavaModelException,
1594:                    InvocationTargetException, InterruptedException {
1595:                IPackageFragmentRoot projectRoot = getProjectRoot(fProject
1596:                        .getCorrespondingResource());
1597:                IPackageFragment fragment = projectRoot.createPackageFragment(
1598:                        "", false, null);
1599:                ICompilationUnit cu = createICompilationUnit("C", fragment);
1600:
1601:                assertTrue(projectRoot.getRawClasspathEntry()
1602:                        .getExclusionPatterns().length == 0);
1603:
1604:                IFile excludedFile = (IFile) executeOperation(
1605:                        BuildpathModifierAction.EXCLUDE, cu, null, null, null,
1606:                        null);
1607:
1608:                assertTrue(contains(excludedFile.getFullPath()
1609:                        .removeFirstSegments(1), projectRoot
1610:                        .getRawClasspathEntry().getExclusionPatterns(), null));
1611:                testProjectIsOnClasspath(true);
1612:
1613:                validateClasspath();
1614:            }
1615:
1616:            public void testIncludeExcludedFileOnProject()
1617:                    throws JavaModelException, InvocationTargetException,
1618:                    InterruptedException {
1619:                IPackageFragmentRoot projectRoot = getProjectRoot(fProject
1620:                        .getCorrespondingResource());
1621:                IPackageFragment fragment = projectRoot.createPackageFragment(
1622:                        "", false, null);
1623:                ICompilationUnit cu = createICompilationUnit("C", fragment);
1624:
1625:                assertTrue(projectRoot.getRawClasspathEntry()
1626:                        .getInclusionPatterns().length == 0);
1627:                assertTrue(projectRoot.getRawClasspathEntry()
1628:                        .getExclusionPatterns().length == 0);
1629:
1630:                IFile excludedFile = (IFile) executeOperation(
1631:                        BuildpathModifierAction.EXCLUDE, cu, null, null, null,
1632:                        null);
1633:
1634:                assertTrue(projectRoot.getRawClasspathEntry()
1635:                        .getInclusionPatterns().length == 0);
1636:                assertTrue(contains(excludedFile.getFullPath()
1637:                        .removeFirstSegments(1), projectRoot
1638:                        .getRawClasspathEntry().getExclusionPatterns(), null));
1639:
1640:                cu = (ICompilationUnit) executeOperation(
1641:                        BuildpathModifierAction.INCLUDE, excludedFile, null,
1642:                        null, null, null);
1643:
1644:                assertTrue(projectRoot.getRawClasspathEntry()
1645:                        .getExclusionPatterns().length == 0);
1646:                assertTrue(contains(cu.getPath().removeFirstSegments(1),
1647:                        projectRoot.getRawClasspathEntry()
1648:                                .getInclusionPatterns(), null));
1649:                testProjectIsOnClasspath(true);
1650:
1651:                validateClasspath();
1652:            }
1653:
1654:            public void testExcludeIncludedFileOnProject()
1655:                    throws JavaModelException, InvocationTargetException,
1656:                    InterruptedException {
1657:                IPackageFragmentRoot projectRoot = getProjectRoot(fProject
1658:                        .getCorrespondingResource());
1659:                IPackageFragment fragment = projectRoot.createPackageFragment(
1660:                        "", false, null);
1661:                ICompilationUnit cu = createICompilationUnit("C", fragment);
1662:
1663:                assertTrue(projectRoot.getRawClasspathEntry()
1664:                        .getInclusionPatterns().length == 0);
1665:                assertTrue(projectRoot.getRawClasspathEntry()
1666:                        .getExclusionPatterns().length == 0);
1667:
1668:                cu = (ICompilationUnit) executeOperation(
1669:                        BuildpathModifierAction.INCLUDE, cu, null, null, null,
1670:                        null);
1671:
1672:                assertTrue(projectRoot.getRawClasspathEntry()
1673:                        .getExclusionPatterns().length == 0);
1674:                assertTrue(contains(cu.getPath().removeFirstSegments(1),
1675:                        projectRoot.getRawClasspathEntry()
1676:                                .getInclusionPatterns(), null));
1677:
1678:                IFile excludedFile = (IFile) executeOperation(
1679:                        BuildpathModifierAction.EXCLUDE, cu, null, null, null,
1680:                        null);
1681:
1682:                assertTrue(projectRoot.getRawClasspathEntry()
1683:                        .getInclusionPatterns().length == 0);
1684:                assertTrue(contains(excludedFile.getFullPath()
1685:                        .removeFirstSegments(1), projectRoot
1686:                        .getRawClasspathEntry().getExclusionPatterns(), null));
1687:                testProjectIsOnClasspath(true);
1688:
1689:                validateClasspath();
1690:            }
1691:
1692:            public void testUnincludeFileOnProject() throws JavaModelException,
1693:                    InvocationTargetException, InterruptedException {
1694:                IPackageFragmentRoot projectRoot = getProjectRoot(fProject
1695:                        .getCorrespondingResource());
1696:                IPackageFragment fragment = projectRoot.createPackageFragment(
1697:                        "", false, null);
1698:                ICompilationUnit cu = createICompilationUnit("C", fragment);
1699:
1700:                assertTrue(projectRoot.getRawClasspathEntry()
1701:                        .getInclusionPatterns().length == 0);
1702:                cu = (ICompilationUnit) executeOperation(
1703:                        BuildpathModifierAction.INCLUDE, cu, null, null, null,
1704:                        null);
1705:                assertTrue(contains(cu.getPath().removeFirstSegments(1),
1706:                        projectRoot.getRawClasspathEntry()
1707:                                .getInclusionPatterns(), null));
1708:
1709:                cu = (ICompilationUnit) executeOperation(
1710:                        BuildpathModifierAction.UNINCLUDE, cu, null, null,
1711:                        null, null);
1712:
1713:                assertFalse(contains(cu.getPath().removeFirstSegments(1),
1714:                        projectRoot.getRawClasspathEntry()
1715:                                .getInclusionPatterns(), null));
1716:                testProjectIsOnClasspath(true);
1717:
1718:                validateClasspath();
1719:            }
1720:
1721:            public void testUnexcludeFileOnProject() throws JavaModelException,
1722:                    InvocationTargetException, InterruptedException {
1723:                IPackageFragmentRoot projectRoot = getProjectRoot(fProject
1724:                        .getCorrespondingResource());
1725:                IPackageFragment fragment = projectRoot.createPackageFragment(
1726:                        "", false, null);
1727:                ICompilationUnit cu = createICompilationUnit("C", fragment);
1728:
1729:                assertTrue(projectRoot.getRawClasspathEntry()
1730:                        .getExclusionPatterns().length == 0);
1731:                IFile excludedFile = (IFile) executeOperation(
1732:                        BuildpathModifierAction.EXCLUDE, cu, null, null, null,
1733:                        null);
1734:                assertTrue(contains(excludedFile.getFullPath()
1735:                        .removeFirstSegments(1), projectRoot
1736:                        .getRawClasspathEntry().getExclusionPatterns(), null));
1737:
1738:                cu = (ICompilationUnit) executeOperation(
1739:                        BuildpathModifierAction.UNEXCLUDE, excludedFile, null,
1740:                        null, null, null);
1741:                assertFalse(contains(excludedFile.getFullPath()
1742:                        .removeFirstSegments(1), projectRoot
1743:                        .getRawClasspathEntry().getExclusionPatterns(), null));
1744:
1745:                validateClasspath();
1746:            }
1747:
1748:            public void testIncludeFileWithIncludedFragment()
1749:                    throws JavaModelException, InvocationTargetException,
1750:                    InterruptedException {
1751:                IPackageFragmentRoot projectRoot = getProjectRoot(fProject
1752:                        .getCorrespondingResource());
1753:                IPackageFragment fragment = createFragmentOnProject();
1754:                IPackageFragmentRoot root = getProjectRoot(fragment
1755:                        .getUnderlyingResource());
1756:
1757:                // first include the fragment
1758:                assertTrue(projectRoot.getRawClasspathEntry()
1759:                        .getInclusionPatterns().length == 0);
1760:                assertFalse(contains(fragment.getPath().removeFirstSegments(1),
1761:                        root.getRawClasspathEntry().getInclusionPatterns(),
1762:                        null));
1763:                fragment = (IPackageFragment) executeOperation(
1764:                        BuildpathModifierAction.INCLUDE, fragment, null, null,
1765:                        null, null);
1766:                assertTrue(contains(fragment.getPath().removeFirstSegments(1),
1767:                        root.getRawClasspathEntry().getInclusionPatterns(),
1768:                        null));
1769:
1770:                // then include the file
1771:                IPackageFragment defaultFragment = projectRoot
1772:                        .createPackageFragment("", false, null);
1773:                ICompilationUnit cu = createICompilationUnit("C",
1774:                        defaultFragment);
1775:
1776:                assertTrue(projectRoot.getRawClasspathEntry()
1777:                        .getInclusionPatterns().length == 1);
1778:                cu = (ICompilationUnit) executeOperation(
1779:                        BuildpathModifierAction.INCLUDE, cu, null, null, null,
1780:                        null);
1781:                assertTrue(contains(cu.getPath().removeFirstSegments(1),
1782:                        projectRoot.getRawClasspathEntry()
1783:                                .getInclusionPatterns(), null));
1784:                assertTrue(projectRoot.getRawClasspathEntry()
1785:                        .getInclusionPatterns().length == 2);
1786:
1787:                testProjectIsOnClasspath(true);
1788:
1789:                validateClasspath();
1790:            }
1791:
1792:            public void testExcludeIncludedFileWithIncludedFragment()
1793:                    throws JavaModelException, InvocationTargetException,
1794:                    InterruptedException {
1795:                // Important here is that the return value must be of type IFile and not
1796:                // ICompilation unit because the fragment is still included
1797:                IPackageFragmentRoot projectRoot = getProjectRoot(fProject
1798:                        .getCorrespondingResource());
1799:                IPackageFragment fragment = createFragmentOnProject();
1800:                IPackageFragmentRoot root = getProjectRoot(fragment
1801:                        .getUnderlyingResource());
1802:
1803:                // first include the fragment
1804:                assertTrue(projectRoot.getRawClasspathEntry()
1805:                        .getInclusionPatterns().length == 0);
1806:                assertFalse(contains(fragment.getPath().removeFirstSegments(1),
1807:                        root.getRawClasspathEntry().getInclusionPatterns(),
1808:                        null));
1809:                fragment = (IPackageFragment) executeOperation(
1810:                        BuildpathModifierAction.INCLUDE, fragment, null, null,
1811:                        null, null);
1812:                assertTrue(contains(fragment.getPath().removeFirstSegments(1),
1813:                        root.getRawClasspathEntry().getInclusionPatterns(),
1814:                        null));
1815:
1816:                // then include the file
1817:                IPackageFragment defaultFragment = projectRoot
1818:                        .createPackageFragment("", false, null);
1819:                ICompilationUnit cu = createICompilationUnit("C",
1820:                        defaultFragment);
1821:
1822:                assertTrue(projectRoot.getRawClasspathEntry()
1823:                        .getInclusionPatterns().length == 1);
1824:                cu = (ICompilationUnit) executeOperation(
1825:                        BuildpathModifierAction.INCLUDE, cu, null, null, null,
1826:                        null);
1827:                assertTrue(contains(cu.getPath().removeFirstSegments(1),
1828:                        projectRoot.getRawClasspathEntry()
1829:                                .getInclusionPatterns(), null));
1830:                assertTrue(projectRoot.getRawClasspathEntry()
1831:                        .getInclusionPatterns().length == 2);
1832:
1833:                // exclude the file
1834:                IFile excludedFile = (IFile) executeOperation(
1835:                        BuildpathModifierAction.EXCLUDE, cu, null, null, null,
1836:                        null);
1837:                assertTrue(projectRoot.getRawClasspathEntry()
1838:                        .getInclusionPatterns().length == 1);
1839:                assertFalse(contains(excludedFile.getProjectRelativePath(),
1840:                        projectRoot.getRawClasspathEntry()
1841:                                .getInclusionPatterns(), null));
1842:                assertTrue(contains(excludedFile.getProjectRelativePath(),
1843:                        projectRoot.getRawClasspathEntry()
1844:                                .getExclusionPatterns(), null));
1845:
1846:                testProjectIsOnClasspath(true);
1847:
1848:                validateClasspath();
1849:            }
1850:
1851:            public void testUnincludeIncludedFileWithIncludedFragment()
1852:                    throws JavaModelException, InvocationTargetException,
1853:                    InterruptedException {
1854:                // Important here is that the return value must be of type IFile and not
1855:                // ICompilation unit because the fragment is still included
1856:                IPackageFragmentRoot projectRoot = getProjectRoot(fProject
1857:                        .getCorrespondingResource());
1858:                IPackageFragment fragment = createFragmentOnProject();
1859:                IPackageFragmentRoot root = getProjectRoot(fragment
1860:                        .getUnderlyingResource());
1861:
1862:                // first include the fragment
1863:                assertTrue(projectRoot.getRawClasspathEntry()
1864:                        .getInclusionPatterns().length == 0);
1865:                assertFalse(contains(fragment.getPath().removeFirstSegments(1),
1866:                        root.getRawClasspathEntry().getInclusionPatterns(),
1867:                        null));
1868:                fragment = (IPackageFragment) executeOperation(
1869:                        BuildpathModifierAction.INCLUDE, fragment, null, null,
1870:                        null, null);
1871:                assertTrue(contains(fragment.getPath().removeFirstSegments(1),
1872:                        root.getRawClasspathEntry().getInclusionPatterns(),
1873:                        null));
1874:
1875:                // then include the file
1876:                IPackageFragment defaultFragment = projectRoot
1877:                        .createPackageFragment("", false, null);
1878:                ICompilationUnit cu = createICompilationUnit("C",
1879:                        defaultFragment);
1880:
1881:                assertTrue(projectRoot.getRawClasspathEntry()
1882:                        .getInclusionPatterns().length == 1);
1883:                cu = (ICompilationUnit) executeOperation(
1884:                        BuildpathModifierAction.INCLUDE, cu, null, null, null,
1885:                        null);
1886:                assertTrue(contains(cu.getPath().removeFirstSegments(1),
1887:                        projectRoot.getRawClasspathEntry()
1888:                                .getInclusionPatterns(), null));
1889:                assertTrue(projectRoot.getRawClasspathEntry()
1890:                        .getInclusionPatterns().length == 2);
1891:
1892:                // uninclude the file
1893:                IFile file = (IFile) executeOperation(
1894:                        BuildpathModifierAction.UNINCLUDE, cu, null, null,
1895:                        null, null);
1896:                assertTrue(projectRoot.getRawClasspathEntry()
1897:                        .getInclusionPatterns().length == 1);
1898:                assertFalse(contains(file.getProjectRelativePath(), projectRoot
1899:                        .getRawClasspathEntry().getInclusionPatterns(), null));
1900:                assertTrue(projectRoot.getRawClasspathEntry()
1901:                        .getExclusionPatterns().length == 0);
1902:
1903:                testProjectIsOnClasspath(true);
1904:
1905:                validateClasspath();
1906:            }
1907:
1908:            protected IPackageFragmentRoot createFragmentRootAndKeepProjAsRoot()
1909:                    throws CoreException, InvocationTargetException,
1910:                    InterruptedException {
1911:                ClasspathModifierQueries.ICreateFolderQuery folderQuery = new ClasspathModifierQueries.ICreateFolderQuery() {
1912:
1913:                    public boolean doQuery() {
1914:                        return true;
1915:                    }
1916:
1917:                    public boolean isSourceFolder() {
1918:                        return true;
1919:                    }
1920:
1921:                    public IFolder getCreatedFolder() {
1922:                        return getFolderHandle(new Path(fSubFolder));
1923:                    }
1924:
1925:                };
1926:                IPackageFragmentRoot root = (IPackageFragmentRoot) executeOperation(
1927:                        BuildpathModifierAction.CREATE_FOLDER, null,
1928:                        getOutputFolderQueryToKeepProjAsRoot(), null,
1929:                        folderQuery, null);
1930:                return root;
1931:            }
1932:
1933:            protected IPackageFragment createFragmentOnProject()
1934:                    throws JavaModelException {
1935:                IFolder fragmentFolder = getFolderHandle(new Path(fNormalFolder));
1936:                IPackageFragmentRoot root = getProjectRoot(fragmentFolder);
1937:                IPackageFragment fragment = root
1938:                        .getPackageFragment(fragmentFolder.getName());
1939:                assertTrue(fragment.exists());
1940:                return fragment;
1941:            }
1942:
1943:            protected IPackageFragmentRoot includePackageAndKeepProjAsRoot()
1944:                    throws CoreException, InvocationTargetException,
1945:                    InterruptedException {
1946:                IPackageFragmentRoot root = createFragmentRootAndKeepProjAsRoot();
1947:
1948:                IFolder folder = getFolderHandle(root.getPath()
1949:                        .removeFirstSegments(1).append(fSubFolder));
1950:
1951:                IClasspathEntry entry = root.getRawClasspathEntry();
1952:                int before = entry.getInclusionPatterns().length;
1953:
1954:                // include
1955:                executeOperation(BuildpathModifierAction.INCLUDE, folder, null,
1956:                        null, null, null);
1957:
1958:                entry = root.getRawClasspathEntry();
1959:                IPath[] inclusionPatterns = entry.getInclusionPatterns();
1960:                int after = inclusionPatterns.length;
1961:                assertTrue(contains(new Path(folder.getName()),
1962:                        inclusionPatterns, null));
1963:                assertTrue(before + 1 == after);
1964:                return root;
1965:            }
1966:
1967:            protected IPackageFragmentRoot excludePackageAndKeepProjAsRoot()
1968:                    throws CoreException, InvocationTargetException,
1969:                    InterruptedException {
1970:                IPackageFragmentRoot root = createFragmentRootAndKeepProjAsRoot();
1971:
1972:                IFolder folder = getFolderHandle(root.getPath()
1973:                        .removeFirstSegments(1).append(fSubFolder));
1974:
1975:                IClasspathEntry entry = root.getRawClasspathEntry();
1976:                int before = entry.getExclusionPatterns().length;
1977:
1978:                // include
1979:                folder = (IFolder) executeOperation(
1980:                        BuildpathModifierAction.EXCLUDE, root
1981:                                .getPackageFragment(folder.getName()), null,
1982:                        null, null, null);
1983:
1984:                entry = root.getRawClasspathEntry();
1985:                IPath[] exclusionPatterns = entry.getExclusionPatterns();
1986:                int after = exclusionPatterns.length;
1987:                assertTrue(contains(new Path(folder.getName()),
1988:                        exclusionPatterns, null));
1989:                assertTrue(before + 1 == after);
1990:                return root;
1991:            }
1992:
1993:            protected ClasspathModifierQueries.OutputFolderQuery getOutputFolderQueryToKeepProjAsRoot()
1994:                    throws JavaModelException {
1995:                return new ClasspathModifierQueries.OutputFolderQuery(
1996:                        defaultOutputFolder) {
1997:                    public boolean doQuery(boolean b,
1998:                            OutputFolderValidator validator,
1999:                            IJavaProject project) {
2000:                        return true;
2001:                    }
2002:
2003:                    public IPath getOutputLocation() {
2004:                        return defaultOutputFolder;
2005:                    }
2006:
2007:                    public boolean removeProjectFromClasspath() {
2008:                        return false;
2009:                    }
2010:                };
2011:            }
2012:
2013:            protected void testProjectIsOnClasspath(boolean isOnClasspath)
2014:                    throws JavaModelException {
2015:                assertTrue((ClasspathModifier.getClasspathEntryFor(fProject
2016:                        .getPath(), fProject, IClasspathEntry.CPE_SOURCE) != null) == isOnClasspath);
2017:            }
2018:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.