Bug 519167: [9] Create rtstubs9.jar for Java 9 test setup
added Java9ProjectTestSetup
Change-Id: I7b30b366d69ddb705976d333b02a32659164f3f4
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/Java9ProjectTestSetup.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/Java9ProjectTestSetup.java
new file mode 100644
index 0000000..7e3ecbd
--- /dev/null
+++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/core/Java9ProjectTestSetup.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2017 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.ui.tests.core;
+
+import org.eclipse.jdt.testplugin.JavaProjectHelper;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+
+import junit.framework.Test;
+
+public class Java9ProjectTestSetup extends ProjectTestSetup {
+
+ public static final String PROJECT_NAME9= "TestSetupProject9";
+
+ public static IJavaProject getProject() {
+ IProject project= ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME9);
+ return JavaCore.create(project);
+ }
+
+ public static IClasspathEntry[] getDefaultClasspath() throws CoreException {
+ IPath[] rtJarPath= JavaProjectHelper.findRtJar(JavaProjectHelper.RT_STUBS_9);
+ return new IClasspathEntry[] { JavaCore.newLibraryEntry(rtJarPath[0], rtJarPath[1], rtJarPath[2], true) };
+ }
+
+ public Java9ProjectTestSetup(Test test) {
+ super(test);
+ }
+
+ @Override
+ protected boolean projectExists() {
+ return getProject().exists();
+ }
+
+ @Override
+ protected IJavaProject createAndInitializeProject() throws CoreException {
+ IJavaProject javaProject= JavaProjectHelper.createJavaProject(PROJECT_NAME9, "bin");
+ javaProject.setRawClasspath(getDefaultClasspath(), null);
+ JavaProjectHelper.set9CompilerOptions(javaProject);
+ return javaProject;
+ }
+
+}