Author: rob.stryker(a)jboss.com
Date: 2008-01-30 21:04:50 -0500 (Wed, 30 Jan 2008)
New Revision: 6042
Added:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/classpath/test/JBIDE1657Test.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/ProjectRuntimeUtil.java
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.test/projects/basicwebproject/.classpath
trunk/as/tests/org.jboss.ide.eclipse.as.test/projects/basicwebproject/.settings/org.eclipse.jst.common.project.facet.core.prefs
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/classpath/test/ASClasspathTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/ASTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/ASTestSuite.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/server/StartupShutdownTest.java
Log:
In proigress / transition. lots of changes. more to follow
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.test/projects/basicwebproject/.classpath
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/projects/basicwebproject/.classpath 2008-01-30
20:59:43 UTC (rev 6041)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/projects/basicwebproject/.classpath 2008-01-31
02:04:50 UTC (rev 6042)
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
- <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.5.0_12"/>
<classpathentry kind="con"
path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry kind="output" path="build/classes"/>
</classpath>
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.test/projects/basicwebproject/.settings/org.eclipse.jst.common.project.facet.core.prefs
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/projects/basicwebproject/.settings/org.eclipse.jst.common.project.facet.core.prefs 2008-01-30
20:59:43 UTC (rev 6041)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/projects/basicwebproject/.settings/org.eclipse.jst.common.project.facet.core.prefs 2008-01-31
02:04:50 UTC (rev 6042)
@@ -1,3 +1,2 @@
#Mon Aug 27 15:45:43 CEST 2007
-classpath.helper/org.eclipse.jdt.launching.JRE_CONTAINER\:\:org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType\:\:jdk1.5.0_12/owners=jst.java\:5.0
eclipse.preferences.version=1
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/classpath/test/ASClasspathTest.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/classpath/test/ASClasspathTest.java 2008-01-30
20:59:43 UTC (rev 6041)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/classpath/test/ASClasspathTest.java 2008-01-31
02:04:50 UTC (rev 6042)
@@ -1,57 +1,23 @@
package org.jboss.ide.eclipse.as.classpath.test;
-import java.util.HashSet;
-
import junit.framework.TestCase;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
-import org.eclipse.jdt.core.IClasspathContainer;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.wst.common.project.facet.core.IFacetedProject;
-import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
-import org.eclipse.wst.common.project.facet.core.runtime.RuntimeManager;
import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.IRuntimeType;
import org.eclipse.wst.server.core.IRuntimeWorkingCopy;
import org.eclipse.wst.server.core.ServerUtil;
-import org.eclipse.wst.server.core.internal.RuntimeWorkingCopy;
-import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
-import org.jboss.tools.common.test.util.TestProjectProvider;
+import org.jboss.ide.eclipse.as.test.ASTest;
public class ASClasspathTest extends TestCase {
-
-
- private static final String ORG_JBOSS_IDE_ECLIPSE_AS_RUNTIME_42 =
"org.jboss.ide.eclipse.as.runtime.42";
-
- private static final String JBOSS_AS_HOME =
System.getProperty("jbosstools.test.jboss.home",
"/home/max/rhdevstudio/jboss-eap/jboss-as");
-
- private TestProjectProvider provider;
- private IProject project;
-
- protected void setUp() throws Exception {
- provider = new TestProjectProvider("org.jboss.ide.eclipse.as.test", null,
"basicwebproject", true);
- project = provider.getProject();
- project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
- }
-
-
//
https://bugs.eclipse.org/bugs/show_bug.cgi?id=201340
// skipped since reported issue and always failing
public void skip_testDoubleCreateEclipseBug201340() throws CoreException {
-
- createGenericRuntime("org.eclipse.jst.server.tomcat.runtime.55");
-
- createGenericRuntime(ORG_JBOSS_IDE_ECLIPSE_AS_RUNTIME_42);
-
-
+ createGenericRuntime(ASTest.TOMCAT_RUNTIME_55);
+ createGenericRuntime(ASTest.JBOSS_RUNTIME_42);
}
private IRuntime[] createGenericRuntime(String runtimeId) throws CoreException {
@@ -71,94 +37,15 @@
assertFalse("Why are two different runtimes " + runtimeId + " created
with the same ID ?!", savedRuntime.getId().equals(secondSavedRuntime.getId()));
return new IRuntime[] { savedRuntime, secondSavedRuntime };
}
- public void testCreateBrokenServer() throws CoreException {
- IRuntimeType[] runtimeTypes = ServerUtil.getRuntimeTypes(null,null,
ORG_JBOSS_IDE_ECLIPSE_AS_RUNTIME_42);
+ public void testCreateBrokenServer() throws CoreException {
+ IRuntimeType[] runtimeTypes = ServerUtil.getRuntimeTypes(null,null,
ASTest.JBOSS_RUNTIME_42);
assertEquals("expects only one runtime type for jboss 4.2",
runtimeTypes.length, 1);
-
IRuntimeType runtimeType = runtimeTypes[0];
-
IRuntimeWorkingCopy jbossRuntime = runtimeType.createRuntime(null, new
NullProgressMonitor());
-
IRuntime savedRuntime = jbossRuntime.save(true, new NullProgressMonitor());
-
assertEquals("Neither vm install nor configuration is set - should not be able to
validate",savedRuntime.validate(null).getSeverity(), Status.ERROR);
-
-
}
- // see JBIDE-1355 why this is skipped
- public void skip_testClasspathAvailable() throws CoreException {
- // Weirdness: If this method is the only to run everything works as expected.
-
- IJavaProject javaProject = JavaCore.create(project);
- assertTrue(javaProject.exists());
-
- String id = "cp-runtime";
- IRuntime createdRuntime = createRuntime(id);
- setTargetRuntime(createdRuntime, project);
-
- //assertEquals(createdRuntime.getId(), "cp-runtime");
-
-
-
- IClasspathEntry paths[] = javaProject.getRawClasspath();
- boolean found = false;
- for (int i = 0; i < paths.length; i++) {
- IClasspathEntry classpathEntry = paths[i];
-
- if(classpathEntry.getPath().toString().equals("org.jboss.ide.eclipse.as.classpath.core.runtime.ProjectRuntimeInitializer/"
+ id)) {
- IClasspathContainer container =
JavaCore.getClasspathContainer(classpathEntry.getPath(), javaProject);
- assertEquals("container not returning userclasses!", container.getKind(),
container.K_APPLICATION);
- found = true;
- }
- }
- assertTrue("could not find jboss as specific entry in raw classpath",
found);
-
- IClasspathEntry[] resolvedClasspath = javaProject.getResolvedClasspath(false);
-
- boolean jsfFound = false;
- for (int i = 0; i < resolvedClasspath.length; i++) {
- IClasspathEntry classpathEntry = resolvedClasspath[i];
- if(classpathEntry.getPath().toString().contains("jsf")) {
- System.out.println(classpathEntry);
- jsfFound = true;
- }
-
- }
- assertTrue("jsf lib not found!", jsfFound);
-
-
- }
- private void setTargetRuntime(IRuntime runtime, IProject theProject) throws
CoreException {
-
- final org.eclipse.wst.common.project.facet.core.runtime.IRuntime facetRuntime =
RuntimeManager.getRuntime(runtime.getId());
-
- assertNotNull("bridged facet runtime not found", facetRuntime);
-
- IFacetedProject facetedProject = ProjectFacetsManager.create(theProject);
-
- facetedProject.setTargetedRuntimes(new
HashSet<org.eclipse.wst.common.project.facet.core.runtime.IRuntime>() { {
this.add(facetRuntime);}}, null);
- facetedProject.setPrimaryRuntime(facetRuntime, null);
-
- }
-
- private IRuntime createRuntime(String runtimeName) throws CoreException {
- IRuntimeType[] runtimeTypes = ServerUtil.getRuntimeTypes(null,null,
ORG_JBOSS_IDE_ECLIPSE_AS_RUNTIME_42);
- assertEquals("expects only one runtime type for jboss 4.2",
runtimeTypes.length, 1);
-
- IRuntimeType runtimeType = runtimeTypes[0];
-
- RuntimeWorkingCopy jbossRuntime =
(RuntimeWorkingCopy)runtimeType.createRuntime(runtimeName, new NullProgressMonitor());
-
- jbossRuntime.setLocation(new Path(JBOSS_AS_HOME));
- jbossRuntime.setAttribute(IJBossServerRuntime.PROPERTY_CONFIGURATION_NAME,
"default");
- IRuntime savedRuntime = jbossRuntime.save(true, new NullProgressMonitor());
-
- assertEquals(savedRuntime.validate(null).getCode(), Status.OK);
-
- return savedRuntime;
- }
-
}
Added:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/classpath/test/JBIDE1657Test.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/classpath/test/JBIDE1657Test.java
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/classpath/test/JBIDE1657Test.java 2008-01-31
02:04:50 UTC (rev 6042)
@@ -0,0 +1,94 @@
+package org.jboss.ide.eclipse.as.classpath.test;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.wst.server.core.IRuntime;
+import org.jboss.ide.eclipse.as.test.ASTest;
+import org.jboss.ide.eclipse.as.test.util.ProjectRuntimeUtil;
+import org.jboss.tools.common.test.util.TestProjectProvider;
+
+public class JBIDE1657Test extends TestCase {
+ private TestProjectProvider provider;
+ private IProject project;
+
+ protected void setUp() throws Exception {
+ provider = new TestProjectProvider("org.jboss.ide.eclipse.as.test", null,
"basicwebproject", true);
+ project = provider.getProject();
+ project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+ }
+
+ protected void tearDown() throws Exception {
+ provider.dispose();
+ }
+
+ public void testJBIDE1657() {
+ try {
+ IJavaProject jp = JavaCore.create(project);
+ verifyInitialClasspathEntries(jp);
+
+ // lets try a runtime
+ IRuntime createdRuntime = ProjectRuntimeUtil.createRuntime("runtime1",
ASTest.JBOSS_RUNTIME_42, ASTest.JBOSS_AS_HOME);
+ ProjectRuntimeUtil.setTargetRuntime(createdRuntime, project);
+ verifyPostRuntimeCPE(jp);
+
+ ProjectRuntimeUtil.clearRuntime(project);
+ verifyInitialClasspathEntries(jp);
+
+ } catch( JavaModelException jme ) {
+ jme.printStackTrace();
+ fail(jme.getMessage());
+ } catch( CoreException ce ) {
+ ce.printStackTrace();
+ fail(ce.getMessage());
+ }
+ }
+
+ protected void verifyPostRuntimeCPE(IJavaProject jp) throws CoreException {
+ IClasspathEntry[] entries = jp.getRawClasspath();
+ assertEquals(3, entries.length);
+ String[] acceptable = new String[] {
"org.eclipse.jst.server.core.container",
+ "basicwebproject", "org.eclipse.jst.j2ee.internal.web.container"
};
+ verifyClasspathEntries(entries, acceptable);
+ }
+
+ protected void verifyInitialClasspathEntries(IJavaProject jp) throws CoreException {
+ IClasspathEntry[] entries = jp.getRawClasspath();
+ assertEquals(2, entries.length);
+
+ // TODO: Currently fails because the JRE is not bound. This must be changed.
+ //IClasspathEntry[] resolved = jp.getResolvedClasspath(false);
+
+ String[] acceptable = new String[] {
"org.eclipse.jst.j2ee.internal.web.container",
+ "basicwebproject"};
+ verifyClasspathEntries(entries, acceptable);
+ }
+
+ protected void verifyClasspathEntries(IClasspathEntry[] entries, String[]
acceptablePrefixes) {
+ ArrayList list = new ArrayList(Arrays.asList(acceptablePrefixes));
+ for( int i = 0; i < entries.length; i++ ) {
+ if( list.contains(entries[i].getPath().segment(0)))
+ list.remove(entries[i].getPath().segment(0));
+ else
+ fail("classpath contains unexpected entry: " + entries[i].getPath());
+ }
+
+ if( list.size() > 0 ) {
+ String tmp = "Expected enties not found: ";
+ for( int i = 0; i < list.size(); i++ ) {
+ tmp += list.get(i) + ", ";
+ }
+ fail(tmp.substring(0, tmp.length() - 2));
+ }
+ }
+}
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/ASTest.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/ASTest.java 2008-01-30
20:59:43 UTC (rev 6041)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/ASTest.java 2008-01-31
02:04:50 UTC (rev 6042)
@@ -47,4 +47,19 @@
return plugin;
}
+
+
+ // set some constants for wide-use
+ public static final String TOMCAT_RUNTIME_55 =
"org.eclipse.jst.server.tomcat.runtime.55";
+ public static final String JBOSS_RUNTIME_32 =
"org.jboss.ide.eclipse.as.runtime.32";
+ public static final String JBOSS_RUNTIME_40 =
"org.jboss.ide.eclipse.as.runtime.40";
+ public static final String JBOSS_RUNTIME_42 =
"org.jboss.ide.eclipse.as.runtime.42";
+ public static final String JBOSS_SERVER_32 = "org.jboss.ide.eclipse.as.32";
+ public static final String JBOSS_SERVER_40 = "org.jboss.ide.eclipse.as.40";
+ public static final String JBOSS_SERVER_42 = "org.jboss.ide.eclipse.as.42";
+ public static final String JBOSS_AS_32_HOME =
System.getProperty("jbosstools.test.jboss.home.3.2",
"C:\\apps\\jboss\\jboss-3.2.8.SP1\\");
+ public static final String JBOSS_AS_40_HOME =
System.getProperty("jbosstools.test.jboss.home.4.0",
"C:\\apps\\jboss\\jboss-4.0.5.GA\\");
+ public static final String JBOSS_AS_42_HOME =
System.getProperty("jbosstools.test.jboss.home.4.2",
"C:\\apps\\jboss\\jboss-4.2.1.GA\\");
+
+ public static final String JBOSS_AS_HOME =
System.getProperty("jbosstools.test.jboss.home", JBOSS_AS_42_HOME);
}
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/ASTestSuite.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/ASTestSuite.java 2008-01-30
20:59:43 UTC (rev 6041)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/ASTestSuite.java 2008-01-31
02:04:50 UTC (rev 6042)
@@ -1,6 +1,7 @@
package org.jboss.ide.eclipse.as.test;
import org.jboss.ide.eclipse.as.classpath.test.ASClasspathTest;
+import org.jboss.ide.eclipse.as.classpath.test.JBIDE1657Test;
import org.jboss.ide.eclipse.as.classpath.test.JEEClasspathContainerTest;
import junit.framework.Test;
@@ -8,10 +9,11 @@
public class ASTestSuite extends TestSuite {
public static Test suite() {
- TestSuite suite = new TestSuite("Archives Tests");
+ TestSuite suite = new TestSuite("ASTools Test Suite");
suite.addTestSuite(ASClasspathTest.class);
suite.addTestSuite(JEEClasspathContainerTest.class);
+ suite.addTestSuite(JBIDE1657Test.class);
return suite;
}
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/server/StartupShutdownTest.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/server/StartupShutdownTest.java 2008-01-30
20:59:43 UTC (rev 6041)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/server/StartupShutdownTest.java 2008-01-31
02:04:50 UTC (rev 6042)
@@ -31,6 +31,7 @@
import org.eclipse.wst.server.core.internal.RuntimeWorkingCopy;
import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
import org.jboss.ide.eclipse.as.core.server.internal.JBossServerBehavior;
+import org.jboss.ide.eclipse.as.test.ASTest;
/**
* These tests are for a simple startup / shutdown of a basic,
@@ -41,15 +42,6 @@
*
*/
public class StartupShutdownTest extends TestCase {
- private static final String RUNTIME_32 =
"org.jboss.ide.eclipse.as.runtime.32";
- private static final String RUNTIME_40 =
"org.jboss.ide.eclipse.as.runtime.40";
- private static final String RUNTIME_42 =
"org.jboss.ide.eclipse.as.runtime.42";
- private static final String SERVER_32 = "org.jboss.ide.eclipse.as.32";
- private static final String SERVER_40 = "org.jboss.ide.eclipse.as.40";
- private static final String SERVER_42 = "org.jboss.ide.eclipse.as.42";
- private static final String JBOSS_AS_32_HOME =
System.getProperty("jbosstools.test.jboss.home.3.2",
"C:\\apps\\jboss\\jboss-3.2.8.SP1\\");
- private static final String JBOSS_AS_40_HOME =
System.getProperty("jbosstools.test.jboss.home.4.0",
"C:\\apps\\jboss\\jboss-4.0.5.GA\\");
- private static final String JBOSS_AS_42_HOME =
System.getProperty("jbosstools.test.jboss.home.4.2",
"C:\\apps\\jboss\\jboss-4.2.1.GA\\");
protected static final IVMInstall VM_INSTALL = JavaRuntime.getDefaultVMInstall();
protected static final String DEFAULT_CONFIG = "default";
@@ -64,11 +56,11 @@
public void setUp() {
try {
if( getName().equals("test32"))
- createServer(RUNTIME_32, SERVER_32, JBOSS_AS_32_HOME, DEFAULT_CONFIG);
+ createServer(ASTest.JBOSS_RUNTIME_32, ASTest.JBOSS_SERVER_32,
ASTest.JBOSS_AS_32_HOME, DEFAULT_CONFIG);
else if( getName().equals("test40"))
- createServer(RUNTIME_40, SERVER_40, JBOSS_AS_40_HOME, DEFAULT_CONFIG);
+ createServer(ASTest.JBOSS_RUNTIME_40, ASTest.JBOSS_SERVER_40,
ASTest.JBOSS_AS_40_HOME, DEFAULT_CONFIG);
else if( getName().equals("test42"))
- createServer(RUNTIME_42, SERVER_42, JBOSS_AS_42_HOME, DEFAULT_CONFIG);
+ createServer(ASTest.JBOSS_RUNTIME_42, ASTest.JBOSS_SERVER_42,
ASTest.JBOSS_AS_42_HOME, DEFAULT_CONFIG);
// first thing's first. Let's add a server state listener
stateListener = new ServerStateListener();
Added:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/ProjectRuntimeUtil.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/ProjectRuntimeUtil.java
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/ProjectRuntimeUtil.java 2008-01-31
02:04:50 UTC (rev 6042)
@@ -0,0 +1,54 @@
+package org.jboss.ide.eclipse.as.test.util;
+
+import java.util.Collections;
+import java.util.HashSet;
+
+import junit.framework.Assert;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+import org.eclipse.wst.common.project.facet.core.runtime.RuntimeManager;
+import org.eclipse.wst.server.core.IRuntime;
+import org.eclipse.wst.server.core.IRuntimeType;
+import org.eclipse.wst.server.core.ServerUtil;
+import org.eclipse.wst.server.core.internal.RuntimeWorkingCopy;
+import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
+
+public class ProjectRuntimeUtil extends Assert {
+
+ public static void clearRuntime(IProject theProject) throws CoreException {
+ IFacetedProject facetedProject = ProjectFacetsManager.create(theProject);
+ facetedProject.setTargetedRuntimes(new
HashSet<org.eclipse.wst.common.project.facet.core.runtime.IRuntime>(), null);
+ facetedProject.setTargetedRuntimes(Collections.EMPTY_SET, new NullProgressMonitor());
+ }
+
+ public static void setTargetRuntime(IRuntime runtime, IProject theProject) throws
CoreException {
+ final org.eclipse.wst.common.project.facet.core.runtime.IRuntime facetRuntime =
RuntimeManager.getRuntime(runtime.getId());
+ assertNotNull("bridged facet runtime not found", facetRuntime);
+ IFacetedProject facetedProject = ProjectFacetsManager.create(theProject);
+ facetedProject.setTargetedRuntimes(new
HashSet<org.eclipse.wst.common.project.facet.core.runtime.IRuntime>() { {
this.add(facetRuntime);}}, null);
+ facetedProject.setPrimaryRuntime(facetRuntime, null);
+ }
+
+ public static IRuntime createRuntime(String runtimeName, String runtimeTypeId, String
asHome) throws CoreException {
+ return createRuntime(runtimeName, runtimeTypeId, asHome, "default");
+ }
+
+ public static IRuntime createRuntime(String runtimeName, String runtimeTypeId, String
asHome, String configuration) throws CoreException {
+ IRuntimeType[] runtimeTypes = ServerUtil.getRuntimeTypes(null,null, runtimeTypeId);
+ assertEquals("expects only one runtime type for jboss 4.2",
runtimeTypes.length, 1);
+ IRuntimeType runtimeType = runtimeTypes[0];
+ RuntimeWorkingCopy jbossRuntime =
(RuntimeWorkingCopy)runtimeType.createRuntime(runtimeName, new NullProgressMonitor());
+ jbossRuntime.setLocation(new Path(asHome));
+ jbossRuntime.setAttribute(IJBossServerRuntime.PROPERTY_CONFIGURATION_NAME,
configuration);
+ IRuntime savedRuntime = jbossRuntime.save(true, new NullProgressMonitor());
+ assertEquals(savedRuntime.validate(null).getCode(), Status.OK);
+ return savedRuntime;
+ }
+
+}