Author: rob.stryker(a)jboss.com
Date: 2011-06-22 02:08:34 -0400 (Wed, 22 Jun 2011)
New Revision: 32273
Added:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/projectcreation/NewTargetedWebProjectTest.java
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/ServerRuntimeUtils.java
Log:
JBIDE-8718 test case
Added:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/projectcreation/NewTargetedWebProjectTest.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/projectcreation/NewTargetedWebProjectTest.java
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/projectcreation/NewTargetedWebProjectTest.java 2011-06-22
06:08:34 UTC (rev 32273)
@@ -0,0 +1,95 @@
+package org.jboss.ide.eclipse.as.test.projectcreation;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.TreeSet;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+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.IRuntime;
+import org.eclipse.wst.common.project.facet.core.runtime.RuntimeManager;
+import org.eclipse.wst.server.core.IServer;
+import org.jboss.ide.eclipse.as.test.ASTest;
+import org.jboss.ide.eclipse.as.test.util.ServerRuntimeUtils;
+import org.jboss.ide.eclipse.as.test.util.wtp.JavaEEFacetConstants;
+import org.jboss.ide.eclipse.as.test.util.wtp.OperationTestCase;
+import org.jboss.ide.eclipse.as.test.util.wtp.ProjectCreationUtil;
+import org.jboss.ide.eclipse.as.test.util.wtp.ProjectUtility;
+import org.jboss.tools.test.util.JobUtils;
+
+public class NewTargetedWebProjectTest extends TestCase {
+ final String MODULE_NAME = "newModulev2111";
+ final String CONTENT_DIR = "contentDirS";
+ private IServer server;
+ private IProject p;
+
+ // Test Commented Until Passing
+
+// public void testTargetedWebProjectErrorsJboss6() throws Exception {
+// server = ServerRuntimeUtils.create60Server();
+// p = createProject("org.jboss.ide.eclipse.as.runtime.60");
+// int markerSev = p.findMaxProblemSeverity(null, true, IResource.DEPTH_INFINITE);
+// assertTrue(markerSev != IMarker.SEVERITY_ERROR);
+// }
+
+ public void testTargetedWebProjectErrorsJboss7() throws Exception {
+ server = ServerRuntimeUtils.create70Server();
+ p = createProject("org.jboss.ide.eclipse.as.runtime.70");
+ int markerSev = p.findMaxProblemSeverity(null, true, IResource.DEPTH_INFINITE);
+ assertTrue(markerSev != IMarker.SEVERITY_ERROR);
+ }
+
+ protected IProject createProject(String rtId) throws Exception {
+ IDataModel dm = ProjectCreationUtil.getWebDataModel(MODULE_NAME, null, null, null,
null, JavaEEFacetConstants.WEB_24, false);
+ OperationTestCase.runAndVerify(dm);
+ p = ResourcesPlugin.getWorkspace().getRoot().getProject(MODULE_NAME);
+ assertTrue(p.exists());
+ assertNotNull(p);
+ assertTrue(p.exists());
+ setProjectRuntime(rtId);
+ IFile f = p.getFolder("src").getFile("Tiger.java");
+ f.create(getClassContents(), true, new NullProgressMonitor());
+ JobUtils.waitForIdle(2000);
+ return p;
+ }
+ protected void setProjectRuntime(String type) throws Exception {
+ IFacetedProject fp = ProjectFacetsManager.create(p);
+ IRuntime rt = fp.getPrimaryRuntime();
+ assertNull(rt);
+ Set<IRuntime> all = RuntimeManager.getRuntimes();
+ assertEquals(all.size(), 2);
+ Iterator<IRuntime> i = all.iterator();
+ IRuntime r1 = i.next();
+ if(!r1.getName().equals(type))
+ r1 = i.next();
+ Set<IRuntime> possible = new TreeSet<IRuntime>();
+ possible.add(r1);
+ fp.setTargetedRuntimes(possible, new NullProgressMonitor());
+ fp.setPrimaryRuntime(r1, new NullProgressMonitor());
+
+ assertNotNull(fp.getPrimaryRuntime());
+ }
+ protected InputStream getClassContents() {
+ String contents = "public class Tiger {\n}";
+ return new ByteArrayInputStream(contents.getBytes());
+ }
+ public void tearDown() throws Exception {
+ ServerRuntimeUtils.deleteAllServers();
+ ServerRuntimeUtils.deleteAllRuntimes();
+ ProjectUtility.deleteAllProjects();
+ ASTest.clearStateLocation();
+ }
+}
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/ServerRuntimeUtils.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/ServerRuntimeUtils.java 2011-06-22
05:14:14 UTC (rev 32272)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/ServerRuntimeUtils.java 2011-06-22
06:08:34 UTC (rev 32273)
@@ -159,9 +159,14 @@
return createServer(IJBossToolingConstants.AS_51, IJBossToolingConstants.SERVER_AS_51,
ASTest.JBOSS_AS_51_HOME, DEFAULT_CONFIG);
}
-// public static IServer create60Server() throws CoreException {
-// }
-
+ public static IServer create60Server() throws CoreException {
+ return createServer(IJBossToolingConstants.AS_60, IJBossToolingConstants.SERVER_AS_60,
ASTest.JBOSS_AS_60_HOME, DEFAULT_CONFIG);
+ }
+
+ public static IServer create70Server() throws CoreException {
+ return createServer(IJBossToolingConstants.AS_70, IJBossToolingConstants.SERVER_AS_70,
ASTest.JBOSS_AS_70_HOME, DEFAULT_CONFIG);
+ }
+
public static IServer createServer(String runtimeID, String serverID,
String location, String configuration) throws CoreException {
IRuntime runtime = RuntimeUtils.createRuntime(runtimeID, location, configuration);
@@ -199,14 +204,14 @@
public static void deleteAllRuntimes() throws CoreException {
// FIXME It doesn't harm to be commented, but location is null should be fixed
-// IRuntime[] runtimes = ServerCore.getRuntimes();
-// for( int i = 0; i < runtimes.length; i++ ) {
+ IRuntime[] runtimes = ServerCore.getRuntimes();
+ for( int i = 0; i < runtimes.length; i++ ) {
// assertNotNull("runtime " + runtimes[i].getName() + " has a null
location", runtimes[i].getLocation());
// if( mockedServers.isPrefixOf(runtimes[i].getLocation())) {
// FileUtil.completeDelete(runtimes[i].getLocation().toFile());
// }
-// runtimes[i].delete();
-// }
+ runtimes[i].delete();
+ }
}
Show replies by date