diff options
author | Jay Arthanareeswaran | 2017-04-20 14:22:19 +0000 |
---|---|---|
committer | Jay Arthanareeswaran | 2018-02-14 08:44:47 +0000 |
commit | 188fa56efe8177767cc56dcd855b230ba7fb1280 (patch) | |
tree | 582727e635772b9926154af1d9b8a589bf5718a5 | |
parent | 1e07a149262601f724e34444775f518eaaad79c5 (diff) | |
download | eclipse.jdt.core-188fa56efe8177767cc56dcd855b230ba7fb1280.tar.gz eclipse.jdt.core-188fa56efe8177767cc56dcd855b230ba7fb1280.tar.xz eclipse.jdt.core-188fa56efe8177767cc56dcd855b230ba7fb1280.zip |
Bug 490103 - Fix test issues
Change-Id: I21a0946de106da74bde0c73472eaf21d5fad6b64
Signed-off-by: Jay Arthanareeswaran <jarthana@in.ibm.com>
8 files changed, 25 insertions, 90 deletions
diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/TestingEnvironment.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/TestingEnvironment.java index 5df235e95f..c2ccd230ec 100644 --- a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/TestingEnvironment.java +++ b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/TestingEnvironment.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2017 IBM Corporation and others. + * Copyright (c) 2000, 2018 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -298,7 +298,11 @@ public void addClassFolder(IPath projectPath, IPath classFolderPath, boolean isE for (int i = 0, max = jars.length; i < max; i++) { String jar = jars[i]; if (JavaModelManager.isJrtInstallation(jar) || jar.endsWith("jrt-fs.jar")) { - addEntry(projectPath, JavaCore.newJrtEntry(new Path(jar), null, null, null, null, isExported)); + IPath path = new Path(jar); + if (jar.endsWith("jrt-fs.jar")) { + path = path.removeLastSegments(2); + } + addEntry(projectPath, JavaCore.newJrtEntry(path, null, null, null, null, isExported)); } else { addEntry(projectPath, JavaCore.newLibraryEntry(new Path(jar), null, null, isExported)); } diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java index 9af91dac31..d7b6fbad77 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java @@ -1772,8 +1772,12 @@ public abstract class AbstractJavaModelTests extends SuiteOfTestCases { new IClasspathAttribute[0], false); } else if (JavaModelManager.isJrtInstallation((new Path(lib)).toString()) || lib.endsWith("jrt-fs.jar")) { + Path path = new Path(lib); + if (lib.endsWith("jrt-fs.jar")) { + path.removeLastSegments(2); + } entries[sourceLength+i] = JavaCore.newJrtEntry( - new Path(lib), + path, null, null, ClasspathEntry.getAccessRules(accessibleFiles, nonAccessibleFiles), @@ -3295,7 +3299,7 @@ public abstract class AbstractJavaModelTests extends SuiteOfTestCases { } protected IPath getJRE9Path() { - return new Path(System.getProperty("java.home") + "/lib/jrt-fs.jar"); + return new Path(System.getProperty("java.home")); } /** diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ExternalAnnotations18Test.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ExternalAnnotations18Test.java index 7c750e26ce..c4a944c6a7 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ExternalAnnotations18Test.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ExternalAnnotations18Test.java @@ -95,13 +95,17 @@ public class ExternalAnnotations18Test extends ModifyingResourceTests { IClasspathAttribute[] extraAttributes; if (jars.length == 1 && (jars[0].endsWith("jrt-fs.jar") || JavaModelManager.isJrtInstallation(jars[0]))) { + IPath jar = new Path(jars[0]); + if (jar.lastSegment().equals("jrt-fs.jar")) { + jar.removeLastSegments(2); + } if (RT_JAR_ANNOTATION_PATH != null) { extraAttributes = externalAnnotationExtraAttributes(RT_JAR_ANNOTATION_PATH); } else { extraAttributes = ClasspathEntry.NO_EXTRA_ATTRIBUTES; } extraAttributes = externalAnnotationExtraAttributes(RT_JAR_ANNOTATION_PATH); - entries[0] = JavaCore.newJrtEntry((new Path(jars[0])).removeLastSegments(2), null, null, + entries[0] = JavaCore.newJrtEntry((jar).removeLastSegments(2), null, null, ClasspathEntry.NO_ACCESS_RULES, extraAttributes, false/*not exported*/); } else { for (int i = 0; i < jars.length; i++) { diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/Java9ElementTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/Java9ElementTests.java index d4f9ce2f20..e6ac072ced 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/Java9ElementTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/Java9ElementTests.java @@ -1578,9 +1578,9 @@ public class Java9ElementTests extends AbstractJavaModelTests { IClasspathEntry[] rawClasspath = project1.getRawClasspath(); IPath jdkRootPath = null; for (int i = 0; i < rawClasspath.length; i++) { - IPath path = rawClasspath[i].getPath(); - if (path.lastSegment().equals("jrt-fs.jar")) { - jdkRootPath = path.removeLastSegments(2); + if (rawClasspath[i].getEntryKind() == IClasspathEntry.CPE_JRT_SYSTEM) { + IPath path = rawClasspath[i].getPath(); + jdkRootPath = path; path = jdkRootPath.append("jmods").append("java.base.jmod"); IClasspathEntry newEntry = JavaCore.newLibraryEntry(path, rawClasspath[i].getSourceAttachmentPath(), new Path("java.base")); rawClasspath[i] = newEntry; @@ -1695,7 +1695,7 @@ public class Java9ElementTests extends AbstractJavaModelTests { finally { deleteProject("Java9Elements"); } - } + } public void testIsOnClasspath2() throws CoreException { try { IJavaProject project1 = createJavaProject("Java9Elements", new String[] {"src"}, new String[] {"JCL19_LIB"}, "bin", "9"); diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java index 1fa7b72b0c..c3c7911bd0 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaProjectTests.java @@ -3040,80 +3040,4 @@ public void testBug522554_3() throws CoreException { deleteProject(prj); } } -// module patching -public void testBug522554_4() throws CoreException { - if (!isJRE9) return; - IJavaProject prj = null; - try { - IClasspathAttribute[] jreAttributes = { - JavaCore.newClasspathAttribute(IClasspathAttribute.PATCH_MODULE, "java.activation"), - JavaCore.newClasspathAttribute(IClasspathAttribute.LIMIT_MODULES, "java.se,jdk.security.auth,jdk.security.jgss,jdk.net,java.activation") - }; - prj = createJava9ProjectWithJREAttributes("mod1", new String[] {"src" }, jreAttributes); - createFolder("/mod1/src/modify"); - createFile("/mod1/src/modify/Test.java", - "package modify;\n" + - "\n" + - "import com.sun.activation.registries.*; \n" + - "\n" + - "public class Test {\n" + - " LogSupport logger;\n" + - "}\n"); - prj.getProject().getWorkspace().build(IncrementalProjectBuilder.AUTO_BUILD, null); - IMarker[] markers = prj.getProject().findMarkers(null, true, IResource.DEPTH_INFINITE); - assertMarkers("Unexpected markers", "", markers); - - IClasspathEntry systemLibrary = prj.getRawClasspath()[1]; - assertEquals("Should be system library", getJRE9Path(), systemLibrary.getPath()); - String argLine = JavaModelAccess.getModuleCLIOptions(prj, systemLibrary); - String projectLoc = prj.getProject().getLocation().toOSString(); - assertEquals("Unexpected CLI options", - "--patch-module java.activation="+projectLoc+File.separator+"bin " + - "--limit-modules java.activation,java.se,jdk.net,jdk.security.auth,jdk.security.jgss", - argLine); - } finally { - if (prj != null) - deleteProject(prj); - } -} -// module patching - multiple output locations -public void testBug522554_5() throws CoreException { - if (!isJRE9) return; - IJavaProject prj = null; - try { - IClasspathAttribute[] jreAttributes = { - JavaCore.newClasspathAttribute(IClasspathAttribute.PATCH_MODULE, "java.activation"), - }; - prj = createJava9ProjectWithJREAttributes("mod1", new String[] {"src" }, jreAttributes); - createFolder("/mod1/src2"); - createFolder("/mod1/bin2"); - addClasspathEntry(prj, JavaCore.newSourceEntry(new Path("/mod1/src2"), null, new Path("/mod1/bin2"))); - createFolder("/mod1/src/modify"); - createFile("/mod1/src/modify/Test.java", - "package modify;\n" + - "\n" + - "import com.sun.activation.registries.*; \n" + - "\n" + - "public class Test {\n" + - " LogSupport logger;\n" + - "}\n"); - prj.getProject().getWorkspace().build(IncrementalProjectBuilder.AUTO_BUILD, null); - IMarker[] markers = prj.getProject().findMarkers(null, true, IResource.DEPTH_INFINITE); - assertMarkers("Unexpected markers", "", markers); - - IClasspathEntry systemLibrary = prj.getRawClasspath()[1]; - assertEquals("Should be system library", getJRE9Path(), systemLibrary.getPath()); - String argLine = JavaModelAccess.getModuleCLIOptions(prj, systemLibrary); - String projectLoc = prj.getProject().getLocation().toOSString(); - assertEquals("Unexpected CLI options", - "--patch-module java.activation="+projectLoc+File.separator+"bin"+File.pathSeparator+projectLoc+File.separator+"bin2", - argLine); - } finally { - if (prj != null) - deleteProject(prj); - } -} -protected IPath getJRE9Path() { - return new Path(System.getProperty("java.home")); -} } diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java index e9d814eaee..dbf71b1d82 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java @@ -2672,9 +2672,8 @@ public class ModuleBuilderTests extends ModifyingResourceTests { IClasspathEntry[] newClasspath = new IClasspathEntry[rawClasspath.length + 1]; IClasspathEntry desktop = null; for (int i = 0; i < rawClasspath.length; i++) { - IPath path = rawClasspath[i].getPath(); - if (path.lastSegment().equals("jrt-fs.jar")) { - path = path.removeLastSegments(2).append("jmods").append("java.base.jmod"); + if (rawClasspath[i].getEntryKind() == IClasspathEntry.CPE_JRT_SYSTEM) { + IPath path = rawClasspath[i].getPath().append("jmods").append("java.base.jmod"); IClasspathAttribute[] attributes = { JavaCore.newClasspathAttribute(IClasspathAttribute.MODULE, "true") }; IClasspathEntry newEntry = JavaCore.newLibraryEntry(path, rawClasspath[i].getSourceAttachmentPath(), diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleOptionsTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleOptionsTests.java index 543dcc7a62..adec6a5fc2 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleOptionsTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleOptionsTests.java @@ -697,7 +697,7 @@ public class ModuleOptionsTests extends ModifyingResourceTests { IClasspathEntry[] newEntries= Arrays.copyOf(oldClasspath, nEntries); for (int i = 0; i < newEntries.length; i++) { if (newEntries[i].getPath().equals(getJRE9Path())) { - newEntries[i] = JavaCore.newLibraryEntry(getJRE9Path(), newEntries[i].getSourceAttachmentPath(), null, null, attributes, false); + newEntries[i] = JavaCore.newJrtEntry(getJRE9Path(), newEntries[i].getSourceAttachmentPath(), null, null, attributes, false); break; } } diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java index 4ba351ac7e..bdff8307b0 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ReconcilerTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2017 IBM Corporation and others. + * Copyright (c) 2000, 2018 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at |