use of org.eclipse.jdt.core.IPackageFragmentRoot in project che by eclipse.
the class ImportOrganizeTest method testAnnotationImports2.
@Test
public void testAnnotationImports2() throws Exception {
IPackageFragmentRoot sourceFolder = JavaProjectHelper.addSourceContainer(fJProject1, "src");
IPackageFragment pack0 = sourceFolder.createPackageFragment("pack0", false, null);
StringBuffer buf = new StringBuffer();
buf.append("package pack0;\n");
buf.append("public @interface MyAnnot1 {\n");
buf.append("}\n");
pack0.createCompilationUnit("MyAnnot1.java", buf.toString(), false, null);
buf = new StringBuffer();
buf.append("package pack0;\n");
buf.append("public @interface MyAnnot2 {\n");
buf.append(" char value();\n");
buf.append("}\n");
pack0.createCompilationUnit("MyAnnot2.java", buf.toString(), false, null);
IPackageFragment pack1 = sourceFolder.createPackageFragment("pack1", false, null);
buf = new StringBuffer();
buf.append("package pack1;\n");
buf.append("\n");
buf.append("@MyAnnot1()\n");
buf.append("@MyAnnot2(File.separatorChar)\n");
buf.append("public @interface Test2 {\n");
buf.append("}\n");
ICompilationUnit cu = pack1.createCompilationUnit("Test2.java", buf.toString(), false, null);
String[] order = new String[] {};
IChooseImportQuery query = createQuery("MyClass", new String[] {}, new int[] {});
OrganizeImportsOperation op = createOperation(cu, order, 99, false, true, true, query);
op.run(null);
buf = new StringBuffer();
buf.append("package pack1;\n");
buf.append("\n");
buf.append("import java.io.File;\n");
buf.append("\n");
buf.append("import pack0.MyAnnot1;\n");
buf.append("import pack0.MyAnnot2;\n");
buf.append("\n");
buf.append("@MyAnnot1()\n");
buf.append("@MyAnnot2(File.separatorChar)\n");
buf.append("public @interface Test2 {\n");
buf.append("}\n");
assertEqualString(cu.getSource(), buf.toString());
}
use of org.eclipse.jdt.core.IPackageFragmentRoot in project che by eclipse.
the class JarNavigationTest method testSortJarEntries.
@Test
public void testSortJarEntries() throws Exception {
String javaHome = getClass().getResource("/temp").getPath() + "/ws/test/gwt-user.jar";
IPackageFragmentRoot root = project.getPackageFragmentRoot(new File(javaHome).getPath());
List<JarEntry> content = navigation.getPackageFragmentRootContent(project, root.hashCode());
assertThat(content).isNotNull().isNotEmpty().onProperty("name").containsSequence("about_files", "com.google", "javax", "org", "META-INF", "about.html", "plugin.properties");
}
use of org.eclipse.jdt.core.IPackageFragmentRoot in project che by eclipse.
the class JarNavigationTest method testGetFileBypath.
@Test
public void testGetFileBypath() throws Exception {
String javaHome = getClass().getResource("/temp").getPath() + "/ws/test/gwt-user.jar";
IPackageFragmentRoot root = project.getPackageFragmentRoot(new File(javaHome).getPath());
JarEntry entry = navigation.getEntry(project, root.hashCode(), "/com/google/gwt/user/User.gwt.xml");
assertThat(entry).isNotNull();
assertThat(entry.getType()).isEqualTo(JarEntry.JarEntryType.FILE);
assertThat(entry.getPath()).isEqualTo("/com/google/gwt/user/User.gwt.xml");
assertThat(entry.getName()).isEqualTo("User.gwt.xml");
}
use of org.eclipse.jdt.core.IPackageFragmentRoot in project che by eclipse.
the class JarNavigationTest method testPackageCollapsing.
@Test
public void testPackageCollapsing() throws Exception {
String javaHome = System.getProperty("java.home") + "/lib/rt.jar";
IPackageFragmentRoot root = project.getPackageFragmentRoot(new File(javaHome).getPath());
List<JarEntry> rootContent = navigation.getChildren(project, root.hashCode(), "org");
assertThat(rootContent).isNotNull().isNotEmpty().onProperty("name").contains("omg", "w3c.dom", "xml.sax");
}
use of org.eclipse.jdt.core.IPackageFragmentRoot in project che by eclipse.
the class JarNavigationTest method testNonJavaFileContent.
@Test
public void testNonJavaFileContent() throws Exception {
String javaHome = System.getProperty("java.home") + "/lib/ext/zipfs.jar";
IPackageFragmentRoot root = project.getPackageFragmentRoot(new File(javaHome).getPath());
ClassContent content = navigation.getContent(project, root.hashCode(), "/META-INF/services/java.nio.file.spi.FileSystemProvider");
assertThat(content.getContent()).isNotNull().isNotEmpty().contains("");
}
Aggregations