List of usage examples for org.eclipse.jdt.core IJavaProject findPackageFragmentRoot
IPackageFragmentRoot findPackageFragmentRoot(IPath path) throws JavaModelException;
null
if one does not exist. From source file:org.eclipse.pde.api.tools.model.tests.ApiFilterStoreTests.java
License:Open Source License
@Override protected void setUp() throws Exception { createProject(TESTING_PLUGIN_PROJECT_NAME, null); File projectSrc = SRC_LOC.toFile(); assertTrue("the filter source dir must exist", projectSrc.exists()); //$NON-NLS-1$ assertTrue("the filter source dir must be a directory", projectSrc.isDirectory()); //$NON-NLS-1$ IJavaProject project = getTestingJavaProject(TESTING_PLUGIN_PROJECT_NAME); IPackageFragmentRoot srcroot = project .findPackageFragmentRoot(project.getProject().getFullPath().append("src")); //$NON-NLS-1$ assertNotNull("the default src root must exist", srcroot); //$NON-NLS-1$ FileUtils.importFileFromDirectory(projectSrc, srcroot.getPath(), new NullProgressMonitor()); // Import the test .api_filters file File xmlsrc = XML_LOC.append(".api_filters").toFile(); //$NON-NLS-1$ assertTrue("the filter xml dir must exist", xmlsrc.exists()); //$NON-NLS-1$ assertTrue("the filter xml dir must be a file", !xmlsrc.isDirectory()); //$NON-NLS-1$ assertNotNull("no project", project); //$NON-NLS-1$ IProject project2 = project.getProject(); IPath settings = project2.getFullPath().append(".settings"); //$NON-NLS-1$ FileUtils.importFileFromDirectory(xmlsrc, settings, new NullProgressMonitor()); IResource filters = project2.findMember("/.settings/.api_filters", true); //$NON-NLS-1$ assertNotNull("the .api_filters file must exist in the testing project", filters); //$NON-NLS-1$ }
From source file:org.eclipse.pde.api.tools.model.tests.FilterStoreTests.java
License:Open Source License
@Override protected void setUp() throws Exception { createProject(TESTING_PLUGIN_PROJECT_NAME, null); File projectSrc = SRC_LOC.toFile(); assertTrue("the filter source dir must exist", projectSrc.exists()); //$NON-NLS-1$ assertTrue(";the filter source dir must be a directory", projectSrc.isDirectory()); //$NON-NLS-1$ IJavaProject project = getTestingJavaProject(TESTING_PLUGIN_PROJECT_NAME); IPackageFragmentRoot srcroot = project .findPackageFragmentRoot(project.getProject().getFullPath().append("src")); //$NON-NLS-1$ assertNotNull("the default src root must exist", srcroot); //$NON-NLS-1$ FileUtils.importFileFromDirectory(projectSrc, srcroot.getPath(), new NullProgressMonitor()); // Import the test .api_filters file File xmlsrc = XML_LOC.append(".api_filters").toFile(); //$NON-NLS-1$ assertTrue("the filter xml dir must exist", xmlsrc.exists()); //$NON-NLS-1$ assertTrue("the filter xml dir must be a file", !xmlsrc.isDirectory()); //$NON-NLS-1$ assertNotNull("no project", project); //$NON-NLS-1$ IProject project2 = project.getProject(); IPath settings = project2.getFullPath().append(".settings"); //$NON-NLS-1$ FileUtils.importFileFromDirectory(xmlsrc, settings, new NullProgressMonitor()); IResource filters = project2.findMember("/.settings/.api_filters", true); //$NON-NLS-1$ assertNotNull("the .api_filters file must exist in the testing project", filters); //$NON-NLS-1$ }
From source file:org.eclipse.pde.api.tools.util.tests.ApiBaselineManagerTests.java
License:Open Source License
/** * Adds the package with the given name to the given package fragment root * /*from ww w. j a v a 2s . co m*/ * @param the project to add the package to * @param srcroot the absolute path to the package fragment root to add the * new package to * @param packagename the name of the new package * @return the new {@link IPackageFragment} or <code>null</code> */ public IPackageFragment assertTestPackage(IJavaProject project, IPath srcroot, String packagename) throws JavaModelException { IPackageFragment fragment = null; IPackageFragmentRoot root = project.findPackageFragmentRoot(srcroot); assertNotNull("the 'src' package fragment root must exist", root); //$NON-NLS-1$ fragment = root.createPackageFragment(packagename, true, new NullProgressMonitor()); assertNotNull("the new package '" + packagename + "' should have been created", fragment); //$NON-NLS-1$ //$NON-NLS-2$ return fragment; }
From source file:org.eclipse.pde.api.tools.util.tests.ApiBaselineManagerTests.java
License:Open Source License
/** * Tests that adding a source file to an API aware project causes the * workspace description to be updated This test adds * <code>a.b.c.TestClass1</code> to the plug-in project *//*from ww w . j a va 2s . co m*/ public void testWPUpdateSourceAdded() throws Exception { IJavaProject project = getTestingProject(); assertNotNull("The testing project must exist", project); //$NON-NLS-1$ IPackageFragmentRoot root = project.findPackageFragmentRoot( new Path(project.getElementName()).append(ProjectUtils.SRC_FOLDER).makeAbsolute().makeAbsolute()); assertNotNull("the 'src' package fragment root must exist", root); //$NON-NLS-1$ assertTestSource(root, TESTING_PACKAGE, "TestClass1"); //$NON-NLS-1$ assertSourceResctriction(TESTING_PACKAGE, "TestClass1", RestrictionModifiers.NO_INSTANTIATE); //$NON-NLS-1$ }
From source file:org.eclipse.pde.api.tools.util.tests.ApiBaselineManagerTests.java
License:Open Source License
/** * Tests that removing a source file from an API aware project causes the * workspace description to be updated// w ww.j av a2 s. c o m */ public void testWPUpdateSourceRemoved() throws Exception { IJavaProject project = getTestingProject(); assertNotNull("The testing project must exist", project); //$NON-NLS-1$ IPackageFragmentRoot root = project.findPackageFragmentRoot( new Path(project.getElementName()).append(ProjectUtils.SRC_FOLDER).makeAbsolute()); assertNotNull("the 'src' package fragment root must exist", root); //$NON-NLS-1$ assertTestSource(root, TESTING_PACKAGE, "TestClass1"); //$NON-NLS-1$ IJavaElement element = project.findElement(new Path("a/b/c/TestClass1.java")); //$NON-NLS-1$ assertNotNull("the class a.b.c.TestClass1 must exist in the project", element); //$NON-NLS-1$ element.getResource().delete(true, new NullProgressMonitor()); IApiDescription desc = getTestProjectApiDescription(); assertNotNull("the testing project api description must exist", desc); //$NON-NLS-1$ IApiAnnotations annot = desc.resolveAnnotations(Factory.typeDescriptor("a.b.c.TestClass1")); //$NON-NLS-1$ assertNull("the annotations for a.b.c.TestClass1 should no longer be present", annot); //$NON-NLS-1$ }
From source file:org.eclipse.pde.api.tools.util.tests.ApiBaselineManagerTests.java
License:Open Source License
/** * Tests that making Javadoc changes to the source file TestClass2 cause the * workspace baseline to be updated./*from www.j a va 2 s . c o m*/ * * This test adds a @noinstantiate tag to the source file TestClass2 */ public void testWPUpdateSourceTypeChanged() throws Exception { IJavaProject project = getTestingProject(); assertNotNull("The testing project must exist", project); //$NON-NLS-1$ IPackageFragmentRoot root = project.findPackageFragmentRoot( new Path(project.getElementName()).append(ProjectUtils.SRC_FOLDER).makeAbsolute()); assertNotNull("the 'src' package fragment root must exist", root); //$NON-NLS-1$ NullProgressMonitor monitor = new NullProgressMonitor(); IPackageFragment fragment = root.getPackageFragment("a.b.c"); //$NON-NLS-1$ FileUtils.importFileFromDirectory(SRC_LOC.append("TestClass2.java").toFile(), fragment.getPath(), monitor); //$NON-NLS-1$ ICompilationUnit element = (ICompilationUnit) project.findElement(new Path("a/b/c/TestClass2.java")); //$NON-NLS-1$ assertNotNull("TestClass2 must exist in the test project", element); //$NON-NLS-1$ updateTagInSource(element, "TestClass2", null, "@noinstantiate", false); //$NON-NLS-1$ //$NON-NLS-2$ IApiDescription desc = getTestProjectApiDescription(); assertNotNull("the testing project api description must exist", desc); //$NON-NLS-1$ IApiAnnotations annot = desc.resolveAnnotations(Factory.typeDescriptor("a.b.c.TestClass2")); //$NON-NLS-1$ assertNotNull("the annotations for a.b.c.TestClass2 cannot be null", annot); //$NON-NLS-1$ assertTrue("there must be a noinstantiate setting for TestClass2", //$NON-NLS-1$ (annot.getRestrictions() & RestrictionModifiers.NO_INSTANTIATE) != 0); assertTrue("there must be a noextend setting for TestClass2", //$NON-NLS-1$ (annot.getRestrictions() & RestrictionModifiers.NO_EXTEND) != 0); }
From source file:org.eclipse.pde.api.tools.util.tests.ApiBaselineManagerTests.java
License:Open Source License
/** * Tests that tags updated on an inner type are updated in the workspace * description./*from w w w. j a v a 2 s . c o m*/ * * This test adds a @noinstantiate tag to an inner class in TestClass3 */ public void testWPUpdateSourceInnerTypeChanged() throws Exception { IJavaProject project = getTestingProject(); assertNotNull("The testing project must exist", project); //$NON-NLS-1$ IPackageFragmentRoot root = project.findPackageFragmentRoot( new Path(project.getElementName()).append(ProjectUtils.SRC_FOLDER).makeAbsolute()); assertNotNull("the 'src' package fragment root must exist", root); //$NON-NLS-1$ assertTestSource(root, TESTING_PACKAGE, "TestClass3"); //$NON-NLS-1$ ICompilationUnit element = (ICompilationUnit) project.findElement(new Path("a/b/c/TestClass3.java")); //$NON-NLS-1$ assertNotNull("TestClass3 must exist in the test project", element); //$NON-NLS-1$ updateTagInSource(element, "InnerTestClass3", null, "@noinstantiate", false); //$NON-NLS-1$ //$NON-NLS-2$ IApiDescription desc = getTestProjectApiDescription(); assertNotNull("the testing project api description must exist", desc); //$NON-NLS-1$ IApiAnnotations annot = desc.resolveAnnotations(Factory.typeDescriptor("a.b.c.TestClass3$InnerTestClass3")); //$NON-NLS-1$ assertNotNull("the annotations for a.b.c.TestClass3$InnerTestClass3 cannot be null", annot); //$NON-NLS-1$ assertFalse("there must not be a noinstantiate setting for TestClass3$InnerTestClass3", //$NON-NLS-1$ (annot.getRestrictions() & RestrictionModifiers.NO_INSTANTIATE) != 0); assertFalse("there must not be a noextend setting for TestClass3$InnerTestClass3", //$NON-NLS-1$ (annot.getRestrictions() & RestrictionModifiers.NO_EXTEND) != 0); }
From source file:org.eclipse.pde.api.tools.util.tests.ApiBaselineManagerTests.java
License:Open Source License
/** * Tests that changing the javadoc for a method updates the workspace * baseline/*from w ww .j av a2 s. c o m*/ * * This test adds a @noextend tag to the method foo() in TestClass1 */ public void testWPUpdateSourceMethodChanged() throws Exception { IJavaProject project = getTestingProject(); assertNotNull("The testing project must exist", project); //$NON-NLS-1$ IPackageFragmentRoot root = project.findPackageFragmentRoot( new Path(project.getElementName()).append(ProjectUtils.SRC_FOLDER).makeAbsolute()); assertNotNull("the 'src' package fragment root must exist", root); //$NON-NLS-1$ assertTestSource(root, TESTING_PACKAGE, "TestClass1"); //$NON-NLS-1$ ICompilationUnit element = (ICompilationUnit) project.findElement(new Path("a/b/c/TestClass1.java")); //$NON-NLS-1$ assertNotNull("TestClass1 must exist in the test project", element); //$NON-NLS-1$ updateTagInSource(element, "foo", "()V", "@nooverride", false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ IApiDescription desc = getTestProjectApiDescription(); assertNotNull("the testing project api description must exist", desc); //$NON-NLS-1$ IApiAnnotations annot = desc.resolveAnnotations(Factory.methodDescriptor("a.b.c.TestClass1", "foo", "()V")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ assertNotNull("the annotations for foo() cannot be null", annot); //$NON-NLS-1$ assertTrue("there must be a nooverride setting for foo()", //$NON-NLS-1$ (annot.getRestrictions() & RestrictionModifiers.NO_OVERRIDE) != 0); }
From source file:org.eclipse.pde.api.tools.util.tests.ApiBaselineManagerTests.java
License:Open Source License
/** * Tests that changing the javadoc for a field updates the workspace * baseline/*from w ww .ja v a 2s . com*/ * * This test adds a @noextend tag to the field 'field' in TestField9 */ public void testWPUpdateSourceFieldChanged() throws Exception { IJavaProject project = getTestingProject(); assertNotNull("The testing project must exist", project); //$NON-NLS-1$ IPackageFragmentRoot root = project.findPackageFragmentRoot( new Path(project.getElementName()).append(ProjectUtils.SRC_FOLDER).makeAbsolute()); assertNotNull("the 'src' package fragment root must exist", root); //$NON-NLS-1$ assertTestSource(root, TESTING_PACKAGE, "TestField9"); //$NON-NLS-1$ ICompilationUnit element = (ICompilationUnit) project.findElement(new Path("a/b/c/TestField9.java")); //$NON-NLS-1$ assertNotNull("TestField9 must exist in the test project", element); //$NON-NLS-1$ updateTagInSource(element, "field", null, "@noreference", false); //$NON-NLS-1$ //$NON-NLS-2$ IApiDescription desc = getTestProjectApiDescription(); assertNotNull("the testing project api description must exist", desc); //$NON-NLS-1$ IApiAnnotations annot = desc.resolveAnnotations(Factory.fieldDescriptor("a.b.c.TestField9", "field")); //$NON-NLS-1$ //$NON-NLS-2$ assertNotNull("the annotations for 'field' cannot be null", annot); //$NON-NLS-1$ assertTrue("there must be a noreference setting for 'field'", //$NON-NLS-1$ (annot.getRestrictions() & RestrictionModifiers.NO_REFERENCE) != 0); }
From source file:org.eclipse.pde.api.tools.util.tests.ApiBaselineManagerTests.java
License:Open Source License
/** * Tests that removing a tag from a method updates the workspace baseline * /* ww w . j a v a 2s . c om*/ * This test removes a @noextend tag to the method foo() in TestClass1 */ public void testWPUpdateSourceMethodRemoveTag() throws Exception { IJavaProject project = getTestingProject(); assertNotNull("The testing project must exist", project); //$NON-NLS-1$ IPackageFragmentRoot root = project.findPackageFragmentRoot( new Path(project.getElementName()).append(ProjectUtils.SRC_FOLDER).makeAbsolute()); assertNotNull("the 'src' package fragment root must exist", root); //$NON-NLS-1$ assertTestSource(root, TESTING_PACKAGE, "TestClass1"); //$NON-NLS-1$ ICompilationUnit element = (ICompilationUnit) project.findElement(new Path("a/b/c/TestClass1.java")); //$NON-NLS-1$ assertNotNull("TestClass1 must exist in the test project", element); //$NON-NLS-1$ updateTagInSource(element, "foo", "()V", "@nooverride", true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ IApiDescription desc = getTestProjectApiDescription(); assertNotNull("the testing project api description must exist", desc); //$NON-NLS-1$ IApiAnnotations annot = desc.resolveAnnotations(Factory.methodDescriptor("a.b.c.TestClass1", "foo", "()V")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ assertNotNull("the annotations for foo() cannot be null", annot); //$NON-NLS-1$ assertTrue("there must be no restrictions for foo()", annot.getRestrictions() == 0); //$NON-NLS-1$ }