Author: rob.stryker(a)jboss.com
Date: 2009-11-12 20:47:10 -0500 (Thu, 12 Nov 2009)
New Revision: 18677
Added:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/projectcreation/
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/projectcreation/TestEar5WithJBossRuntime.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/JSTDeploymentTester.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/SingleFileDeploymentTester.java
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/wtp/
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/wtp/JavaEEFacetConstants.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/wtp/OperationTestCase.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/wtp/PostBuildListener.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/wtp/ProjectCreationUtil.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/wtp/ProjectUtility.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/wtp/TaskViewUtility.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl/PublishCopyUtil.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/IJBossToolingConstants.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/META-INF/MANIFEST.MF
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/PreReqTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/classpath/JBIDE1657Test.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/classpath/ProjectRuntimeTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/classpath/RuntimeServerModelTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/JBIDE4184Test.java
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/util/ProjectRuntimeUtil.java
Log:
Some new tests
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl/PublishCopyUtil.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl/PublishCopyUtil.java 2009-11-13
00:47:20 UTC (rev 18676)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl/PublishCopyUtil.java 2009-11-13
01:47:10 UTC (rev 18677)
@@ -514,6 +514,7 @@
* @return a possibly-empty array of error and warning status
*/
public IStatus[] publishFull(IModuleResource[] resources, IProgressMonitor monitor)
throws CoreException {
+ handler.makeDirectoryIfRequired(new Path("/"), monitor); //$NON-NLS-1$
return publishFull(resources, new Path("/"), monitor); //$NON-NLS-1$
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/IJBossToolingConstants.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/IJBossToolingConstants.java 2009-11-13
00:47:20 UTC (rev 18676)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/util/IJBossToolingConstants.java 2009-11-13
01:47:10 UTC (rev 18677)
@@ -23,6 +23,16 @@
public static final String EAP_43 = "org.jboss.ide.eclipse.as.runtime.eap.43";
//$NON-NLS-1$
public static final String EAP_50 = "org.jboss.ide.eclipse.as.runtime.eap.50";
//$NON-NLS-1$
+ public static final String SERVER_AS_32 = "org.jboss.ide.eclipse.as.32";
//$NON-NLS-1$
+ public static final String SERVER_AS_40 = "org.jboss.ide.eclipse.as.40";
//$NON-NLS-1$
+ public static final String SERVER_AS_42 = "org.jboss.ide.eclipse.as.42";
//$NON-NLS-1$
+ public static final String SERVER_AS_50 = "org.jboss.ide.eclipse.as.50";
//$NON-NLS-1$
+ public static final String SERVER_AS_51 = "org.jboss.ide.eclipse.as.51";
//$NON-NLS-1$
+ public static final String SERVER_EAP_43 = "org.jboss.ide.eclipse.as.eap.43";
//$NON-NLS-1$
+ public static final String SERVER_EAP_50 = "org.jboss.ide.eclipse.as.eap.50";
//$NON-NLS-1$
+
+
+
/* Version Strings */
public static final String V3_0 = "3.0"; //$NON-NLS-1$
public static final String V3_2 = "3.2"; //$NON-NLS-1$
Modified: trunk/as/tests/org.jboss.ide.eclipse.as.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.test/META-INF/MANIFEST.MF 2009-11-13 00:47:20
UTC (rev 18676)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.test/META-INF/MANIFEST.MF 2009-11-13 01:47:10
UTC (rev 18677)
@@ -20,7 +20,22 @@
org.eclipse.jst.server.core;bundle-version="1.1.0",
org.jboss.tools.jmx.core.test,
org.jboss.ide.eclipse.as.ui;bundle-version="1.0.0",
- org.eclipse.ui.navigator;bundle-version="3.3.101"
+ org.eclipse.ui.navigator;bundle-version="3.3.101",
+ org.eclipse.jst.common.frameworks;bundle-version="1.1.300",
+ org.eclipse.jst.j2ee;bundle-version="1.1.301",
+ org.eclipse.jst.j2ee.core;bundle-version="1.1.301",
+ org.eclipse.jst.j2ee.ejb;bundle-version="1.1.300",
+ org.eclipse.jst.j2ee.jca;bundle-version="1.1.300",
+ org.eclipse.jst.jee.ejb;bundle-version="1.0.201",
+ org.eclipse.jst.jee.web;bundle-version="1.0.200",
+ org.eclipse.wst.common.emf;bundle-version="1.1.301",
+ org.eclipse.wst.common.emfworkbench.integration;bundle-version="1.1.301",
+ org.eclipse.wst.common.core;bundle-version="1.1.201",
+ org.eclipse.wst.common.frameworks;bundle-version="1.1.300",
+ org.eclipse.wst.validation;bundle-version="1.2.102",
+ org.eclipse.jem.util;bundle-version="2.0.200",
+ org.eclipse.jst.j2ee.web;bundle-version="1.1.301",
+ org.jboss.tools.tests;bundle-version="2.0.0"
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: jbossastest.jar
Bundle-Vendor: %Bundle-Vendor.0
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 2009-11-13
00:47:20 UTC (rev 18676)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/ASTest.java 2009-11-13
01:47:10 UTC (rev 18677)
@@ -22,6 +22,7 @@
package org.jboss.ide.eclipse.as.test;
import org.eclipse.core.runtime.Plugin;
+import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
import org.osgi.framework.BundleContext;
/**
@@ -72,15 +73,12 @@
// 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_50_HOME =
System.getProperty("jbosstools.test.jboss.home.5.0",
"C:\\apps\\jboss\\jboss-5.0.0.GA\\");
+ public static final String JBOSS_AS_51_HOME =
System.getProperty("jbosstools.test.jboss.home.5.1",
"C:\\apps\\jboss\\jboss-5.1.0.GA\\");
+ public static final String JBOSS_AS_52_HOME =
System.getProperty("jbosstools.test.jboss.home.5.2",
"C:\\apps\\jboss\\jboss-5.2.0.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 2009-11-13
00:47:20 UTC (rev 18676)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/ASTestSuite.java 2009-11-13
01:47:10 UTC (rev 18677)
@@ -28,9 +28,12 @@
import org.jboss.ide.eclipse.as.test.classpath.JEEClasspathContainerTest;
import org.jboss.ide.eclipse.as.test.classpath.ProjectRuntimeTest;
import org.jboss.ide.eclipse.as.test.classpath.RuntimeServerModelTest;
+import org.jboss.ide.eclipse.as.test.projectcreation.TestEar5WithJBossRuntime;
import org.jboss.ide.eclipse.as.test.publishing.JBIDE2512aTest;
import org.jboss.ide.eclipse.as.test.publishing.JBIDE2512bTest;
import org.jboss.ide.eclipse.as.test.publishing.JBIDE4184Test;
+import org.jboss.ide.eclipse.as.test.publishing.v2.JSTDeploymentTester;
+import org.jboss.ide.eclipse.as.test.publishing.v2.SingleFileDeploymentTester;
public class ASTestSuite extends TestSuite {
public static Test suite() {
@@ -43,6 +46,9 @@
suite.addTestSuite(JBIDE2512aTest.class);
suite.addTestSuite(JBIDE2512bTest.class);
suite.addTestSuite(JBIDE4184Test.class);
+ suite.addTestSuite(TestEar5WithJBossRuntime.class);
+ suite.addTestSuite(JSTDeploymentTester.class);
+ suite.addTestSuite(SingleFileDeploymentTester.class);
return suite;
}
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/PreReqTest.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/PreReqTest.java 2009-11-13
00:47:20 UTC (rev 18676)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/PreReqTest.java 2009-11-13
01:47:10 UTC (rev 18677)
@@ -28,6 +28,7 @@
import org.eclipse.wst.server.core.IRuntimeType;
import org.eclipse.wst.server.core.IServerType;
import org.eclipse.wst.server.core.ServerCore;
+import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
/**
* This class will test whether all of the pre-req
@@ -67,30 +68,46 @@
*/
public void testRuntime32Found() {
- _testRuntime(ASTest.JBOSS_RUNTIME_32);
+ _testRuntime(IJBossToolingConstants.AS_32);
}
public void testRuntime40Found() {
- _testRuntime(ASTest.JBOSS_RUNTIME_40);
+ _testRuntime(IJBossToolingConstants.AS_40);
}
public void testRuntime42Found() {
- _testRuntime(ASTest.JBOSS_RUNTIME_42);
+ _testRuntime(IJBossToolingConstants.AS_42);
}
-
+
+ public void testRuntime50Found() {
+ _testRuntime(IJBossToolingConstants.AS_50);
+ }
+
+ public void testRuntime51Found() {
+ _testRuntime(IJBossToolingConstants.AS_51);
+ }
+
public void testServer32Found() {
- _testServer(ASTest.JBOSS_SERVER_32);
+ _testServer(IJBossToolingConstants.SERVER_AS_32);
}
public void testServer40Found() {
- _testServer(ASTest.JBOSS_SERVER_40);
+ _testServer(IJBossToolingConstants.SERVER_AS_40);
}
public void testServer42Found() {
- _testServer(ASTest.JBOSS_SERVER_42);
+ _testServer(IJBossToolingConstants.SERVER_AS_42);
}
+
+ public void testServer50Found() {
+ _testServer(IJBossToolingConstants.SERVER_AS_50);
+ }
+ public void testServer51Found() {
+ _testServer(IJBossToolingConstants.SERVER_AS_51);
+ }
+
public void _testRuntime(String typeId) {
IRuntimeType rt = ServerCore.findRuntimeType(typeId);
if( rt == null )
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/classpath/JBIDE1657Test.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/classpath/JBIDE1657Test.java 2009-11-13
00:47:20 UTC (rev 18676)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/classpath/JBIDE1657Test.java 2009-11-13
01:47:10 UTC (rev 18677)
@@ -33,6 +33,7 @@
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.wst.server.core.IRuntime;
+import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
import org.jboss.ide.eclipse.as.test.ASTest;
import org.jboss.ide.eclipse.as.test.util.ProjectRuntimeUtil;
import org.jboss.tools.jmx.core.test.util.TestProjectProvider;
@@ -64,7 +65,8 @@
IJavaProject jp = JavaCore.create(project);
// lets try a runtime
- IRuntime createdRuntime = ProjectRuntimeUtil.createRuntime("runtime1",
ASTest.JBOSS_RUNTIME_42, ASTest.JBOSS_AS_HOME);
+ IRuntime createdRuntime = ProjectRuntimeUtil.createRuntime("runtime1",
+ IJBossToolingConstants.AS_42, ASTest.JBOSS_AS_HOME);
ProjectRuntimeUtil.setTargetRuntime(createdRuntime, project);
IClasspathEntry[] raw1 = jp.getRawClasspath();
IClasspathEntry[] resolved1 = jp.getResolvedClasspath(false);
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/classpath/ProjectRuntimeTest.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/classpath/ProjectRuntimeTest.java 2009-11-13
00:47:20 UTC (rev 18676)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/classpath/ProjectRuntimeTest.java 2009-11-13
01:47:10 UTC (rev 18677)
@@ -35,6 +35,7 @@
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.core.util.IJBossToolingConstants;
import org.jboss.ide.eclipse.as.test.ASTest;
import org.jboss.ide.eclipse.as.test.util.ProjectRuntimeUtil;
import org.jboss.tools.jmx.core.test.util.TestProjectProvider;
@@ -59,7 +60,8 @@
verifyInitialClasspathEntries(jp);
// lets try a runtime
- IRuntime createdRuntime = ProjectRuntimeUtil.createRuntime("runtime1",
ASTest.JBOSS_RUNTIME_42, ASTest.JBOSS_AS_HOME);
+ IRuntime createdRuntime = ProjectRuntimeUtil.createRuntime("runtime1",
+ IJBossToolingConstants.AS_42, ASTest.JBOSS_AS_HOME);
ProjectRuntimeUtil.setTargetRuntime(createdRuntime, project);
verifyPostRuntimeCPE(jp);
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/classpath/RuntimeServerModelTest.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/classpath/RuntimeServerModelTest.java 2009-11-13
00:47:20 UTC (rev 18676)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/classpath/RuntimeServerModelTest.java 2009-11-13
01:47:10 UTC (rev 18677)
@@ -30,6 +30,7 @@
import org.eclipse.wst.server.core.IRuntimeType;
import org.eclipse.wst.server.core.IRuntimeWorkingCopy;
import org.eclipse.wst.server.core.ServerUtil;
+import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
import org.jboss.ide.eclipse.as.test.ASTest;
public class RuntimeServerModelTest extends TestCase {
@@ -38,7 +39,7 @@
// skipped since reported issue and always failing
public void skip_testDoubleCreateEclipseBug201340() throws CoreException {
createGenericRuntime(ASTest.TOMCAT_RUNTIME_55);
- createGenericRuntime(ASTest.JBOSS_RUNTIME_42);
+ createGenericRuntime(IJBossToolingConstants.AS_42);
}
private IRuntime[] createGenericRuntime(String runtimeId) throws CoreException {
@@ -60,7 +61,7 @@
}
public void testCreateBrokenRuntime() throws CoreException {
- IRuntimeType[] runtimeTypes = ServerUtil.getRuntimeTypes(null,null,
ASTest.JBOSS_RUNTIME_42);
+ IRuntimeType[] runtimeTypes = ServerUtil.getRuntimeTypes(null,null,
IJBossToolingConstants.AS_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());
Added:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/projectcreation/TestEar5WithJBossRuntime.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/projectcreation/TestEar5WithJBossRuntime.java
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/projectcreation/TestEar5WithJBossRuntime.java 2009-11-13
01:47:10 UTC (rev 18677)
@@ -0,0 +1,78 @@
+package org.jboss.ide.eclipse.as.test.projectcreation;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Path;
+import
org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.project.facet.core.runtime.RuntimeManager;
+import org.eclipse.wst.server.core.IServer;
+import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
+import org.jboss.ide.eclipse.as.test.ASTest;
+import org.jboss.ide.eclipse.as.test.util.ProjectRuntimeUtil;
+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;
+
+/**
+ * This class tests the requirement that ear projects with a
+ * JBoss runtime < 5.0 are forced to create an application.xml.
+ * @author rob
+ *
+ */
+
+public class TestEar5WithJBossRuntime extends TestCase {
+ public void testEar5WithJBoss42() throws Exception {
+ IServer server = ServerRuntimeUtils.createServer(IJBossToolingConstants.AS_42,
+ IJBossToolingConstants.SERVER_AS_42, ASTest.JBOSS_AS_42_HOME,
ServerRuntimeUtils.DEFAULT_CONFIG);
+ IDataModel dm = ProjectCreationUtil.getEARDataModel("newModule",
"contentDirS", null, null, JavaEEFacetConstants.EAR_5, false);
+ dm.setProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME,
RuntimeManager.getRuntime(server.getRuntime().getId()));
+ OperationTestCase.runAndVerify(dm);
+ IProject p =
ResourcesPlugin.getWorkspace().getRoot().getProject("newModule");
+ assertTrue(p.exists());
+ assertNotNull(ProjectRuntimeUtil.getRuntime(p));
+ IFile f = p.getFile(new
Path("contentDirS").append("META-INF").append("application.xml"));
+ assertTrue(f.exists());
+ ProjectUtility.deleteAllProjects();
+ ServerRuntimeUtils.deleteAllServers();
+ ServerRuntimeUtils.deleteAllRuntimes();
+ }
+
+ public void testEar5WithJBoss50() throws Exception {
+ IServer server = ServerRuntimeUtils.createServer(IJBossToolingConstants.AS_50,
+ IJBossToolingConstants.SERVER_AS_50, ASTest.JBOSS_AS_50_HOME,
ServerRuntimeUtils.DEFAULT_CONFIG);
+ IDataModel dm = ProjectCreationUtil.getEARDataModel("newModule2",
"contentDirS", null, null, JavaEEFacetConstants.EAR_5, false);
+ dm.setProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME,
RuntimeManager.getRuntime(server.getRuntime().getId()));
+ OperationTestCase.runAndVerify(dm);
+ IProject p =
ResourcesPlugin.getWorkspace().getRoot().getProject("newModule2");
+ assertTrue(p.exists());
+ assertNotNull(ProjectRuntimeUtil.getRuntime(p));
+ IFile f = p.getFile(new
Path("contentDirS").append("META-INF").append("application.xml"));
+ assertFalse(f.exists());
+ ProjectUtility.deleteAllProjects();
+ ServerRuntimeUtils.deleteAllServers();
+ ServerRuntimeUtils.deleteAllRuntimes();
+ }
+
+ public void testEar5WithJBoss51() throws Exception {
+ IServer server = ServerRuntimeUtils.createServer(IJBossToolingConstants.AS_51,
+ IJBossToolingConstants.SERVER_AS_51, ASTest.JBOSS_AS_51_HOME,
ServerRuntimeUtils.DEFAULT_CONFIG);
+ IDataModel dm = ProjectCreationUtil.getEARDataModel("newModule3",
"contentDirS", null, null, JavaEEFacetConstants.EAR_5, false);
+ dm.setProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME,
RuntimeManager.getRuntime(server.getRuntime().getId()));
+ OperationTestCase.runAndVerify(dm);
+ IProject p =
ResourcesPlugin.getWorkspace().getRoot().getProject("newModule3");
+ assertTrue(p.exists());
+ assertNotNull(ProjectRuntimeUtil.getRuntime(p));
+ IFile f = p.getFile(new
Path("contentDirS").append("META-INF").append("application.xml"));
+ assertFalse(f.exists());
+ ProjectUtility.deleteAllProjects();
+ ServerRuntimeUtils.deleteAllServers();
+ ServerRuntimeUtils.deleteAllRuntimes();
+ }
+
+}
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/JBIDE4184Test.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/JBIDE4184Test.java 2009-11-13
00:47:20 UTC (rev 18676)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/JBIDE4184Test.java 2009-11-13
01:47:10 UTC (rev 18677)
@@ -14,6 +14,7 @@
import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
import org.jboss.ide.eclipse.as.core.server.IJBossServerConstants;
import org.jboss.ide.eclipse.as.core.util.FileUtil;
+import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
import org.jboss.ide.eclipse.as.test.ASTest;
import org.jboss.ide.eclipse.as.test.server.StartupShutdownTest;
@@ -27,8 +28,9 @@
if( tmpPath.toFile().exists())
FileUtil.safeDelete(tmpPath.toFile());
assertFalse(tmpPath.toFile().exists());
- server = StartupShutdownTest.createServer(ASTest.JBOSS_RUNTIME_42,
ASTest.JBOSS_SERVER_42, ASTest.JBOSS_AS_42_HOME,
- StartupShutdownTest.DEFAULT_CONFIG);
+ server = StartupShutdownTest.createServer(
+ IJBossToolingConstants.AS_42, IJBossToolingConstants.SERVER_AS_42,
+ ASTest.JBOSS_AS_42_HOME, StartupShutdownTest.DEFAULT_CONFIG);
} catch( CoreException ce) {
fail(ce.getMessage());
}
Added:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/JSTDeploymentTester.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/JSTDeploymentTester.java
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/JSTDeploymentTester.java 2009-11-13
01:47:10 UTC (rev 18677)
@@ -0,0 +1,250 @@
+package org.jboss.ide.eclipse.as.test.publishing.v2;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStream;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.server.core.IModule;
+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.IServer;
+import org.eclipse.wst.server.core.IServerType;
+import org.eclipse.wst.server.core.IServerWorkingCopy;
+import org.eclipse.wst.server.core.ServerCore;
+import org.eclipse.wst.server.core.ServerUtil;
+import org.eclipse.wst.server.core.internal.ServerWorkingCopy;
+import org.jboss.ide.eclipse.as.core.ExtensionManager;
+import org.jboss.ide.eclipse.as.core.publishers.JstPublisher;
+import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
+import org.jboss.ide.eclipse.as.core.server.IJBossServerPublisher;
+import org.jboss.ide.eclipse.as.core.server.internal.DeployableServer;
+import org.jboss.ide.eclipse.as.core.util.FileUtil;
+import org.jboss.ide.eclipse.as.core.util.ServerConverter;
+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 JSTDeploymentTester extends TestCase {
+
+ IProject project;
+ IServer server;
+ final String MODULE_NAME = "newModule";
+ final String CONTENT_DIR = "contentDirS";
+ final String TEXT_FILE = "test.txt";
+ final IPath CONTENT_TEXT_FILE = new Path(CONTENT_DIR).append(TEXT_FILE);
+ public void setUp() throws Exception {
+ project = createProject();
+ server = createServer();
+ }
+
+ public void tearDown() throws Exception {
+ ServerRuntimeUtils.deleteAllServers();
+ ServerRuntimeUtils.deleteAllRuntimes();
+ ProjectUtility.deleteAllProjects();
+ clearStateLocation();
+ }
+
+ protected IProject createProject() throws Exception {
+ IDataModel dm = ProjectCreationUtil.getEARDataModel(MODULE_NAME, CONTENT_DIR, null,
null, JavaEEFacetConstants.EAR_5, false);
+ OperationTestCase.runAndVerify(dm);
+ IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject(MODULE_NAME);
+ assertTrue(p.exists());
+ return p;
+ }
+
+ protected IServer createServer() throws CoreException {
+ IPath state = ASTest.getDefault().getStateLocation();
+ IPath deploy = state.append("testDeployments").append("deploy");
+ IPath tmpDeploy =
state.append("testDeployments").append("tmpDeploy");
+ return createServer(deploy.toOSString(), tmpDeploy.toOSString());
+ }
+
+ protected void clearStateLocation() {
+ IPath state = ASTest.getDefault().getStateLocation();
+ if( state.toFile().exists()) {
+ File[] children = state.toFile().listFiles();
+ for( int i = 0; i < children.length; i++ ) {
+ FileUtil.safeDelete(children[i]);
+ }
+ }
+ }
+
+ protected String getDeployRoot(IServer server) {
+ IDeployableServer ds = ServerConverter.getDeployableServer(server);
+ return ds.getDeployFolder();
+ }
+
+ protected IServer createServer(String deployLocation, String tempDeployLocation) throws
CoreException {
+ IRuntimeType rt =
ServerCore.findRuntimeType("org.jboss.ide.eclipse.as.runtime.stripped");
+ IRuntimeWorkingCopy wc = rt.createRuntime("testRuntime", null);
+ IRuntime runtime = wc.save(true, null);
+ IServerType st =
ServerCore.findServerType("org.jboss.ide.eclipse.as.systemCopyServer");
+ ServerWorkingCopy swc = (ServerWorkingCopy) st.createServer("testServer",
null, null);
+ swc.setServerConfiguration(null);
+ swc.setName("testServer");
+ swc.setRuntime(runtime);
+ swc.setAttribute(DeployableServer.DEPLOY_DIRECTORY, deployLocation);
+ swc.setAttribute(DeployableServer.TEMP_DEPLOY_DIRECTORY, tempDeployLocation);
+ IServer server = swc.save(true, null);
+ return server;
+ }
+
+ protected IStatus publish() throws CoreException {
+ return server.publish(IServer.PUBLISH_INCREMENTAL, new NullProgressMonitor());
+ }
+
+ protected void addModule(IModule module) throws CoreException {
+ IServerWorkingCopy copy = server.createWorkingCopy();
+ copy.modifyModules(new IModule[]{module}, new IModule[0], new NullProgressMonitor());
+ server = copy.save(false, new NullProgressMonitor());
+ }
+
+ protected void removeModule(IModule module) throws CoreException {
+ IServerWorkingCopy copy = server.createWorkingCopy();
+ copy.modifyModules(new IModule[]{}, new IModule[] {module}, new
NullProgressMonitor());
+ server = copy.save(false, new NullProgressMonitor());
+ }
+
+ protected void verifyJSTPublisher(IModule[] module) {
+ IJBossServerPublisher publisher = ExtensionManager
+ .getDefault().getPublisher(server, module, "local");
+ assertTrue(publisher instanceof JstPublisher);
+ }
+
+ public int countFiles(File root) {
+ int count = 0;
+ if( !root.isDirectory() )
+ return 1;
+ File[] children = root.listFiles();
+ for( int i = 0; i < children.length; i++ )
+ count += countFiles(children[i]);
+ return count;
+ }
+
+ public int countAllResources(File root) {
+ int count = 0;
+ if( !root.isDirectory() )
+ return 1;
+ File[] children = root.listFiles();
+ for( int i = 0; i < children.length; i++ )
+ count += countFiles(children[i]);
+ return 1 + count;
+ }
+
+
+
+ protected void setContents(IFile file, int val) throws IOException , CoreException{
+ setContents(file, "" + val);
+ }
+
+ protected void setContents(IFile file, String val) throws IOException , CoreException{
+ if( !file.exists())
+ file.create(new ByteArrayInputStream((val).getBytes()), false, null);
+ else
+ file.setContents(new ByteArrayInputStream((val).getBytes()), false, false, new
NullProgressMonitor());
+ try {
+ Thread.sleep(2000);
+ } catch( InterruptedException ie) {}
+ JobUtils.waitForIdle();
+ }
+
+ protected void assertContents(IFile file, int val) throws IOException, CoreException {
+ assertContents(file, "" + val);
+ }
+
+ protected void assertContents(IFile file, String val) throws IOException, CoreException
{
+ String contents = getContents(file);
+ assertEquals(val, contents);
+ }
+
+ protected void assertContents(File file, int val) throws IOException, CoreException {
+ assertContents(file, val);
+ }
+
+ protected void assertContents(File file, String val) throws IOException, CoreException
{
+ String contents = getContents(file);
+ assertEquals(val, contents);
+ }
+
+ protected String getContents(IFile file) throws IOException, CoreException {
+ BufferedInputStream bis = new BufferedInputStream(file.getContents());
+ int l = (int)file.getLocation().toFile().length();
+ byte[] bs = new byte[l];
+ l = bis.read(bs, 0, l);
+ bis.close();
+ return new String(bs);
+ }
+
+ public static byte[] getBytesFromFile(File file) throws IOException {
+ InputStream is = new FileInputStream(file);
+ byte[] bytes = new byte[(int)file.length()];
+ int offset = 0;
+ int numRead = 0;
+ while (offset < bytes.length
+ && (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0)
{
+ offset += numRead;
+ }
+ is.close();
+ return bytes;
+ }
+
+ static public String getContents(File aFile) throws IOException {
+ return new String(getBytesFromFile(aFile));
+ }
+
+
+ public void testMain() throws CoreException, IOException {
+ IModule mod = ServerUtil.getModule(project);
+ IModule[] module = new IModule[] { mod };
+ verifyJSTPublisher(module);
+ addModule(mod);
+ publish();
+ IPath deployRoot = new Path(getDeployRoot(server));
+ IPath rootFolder = deployRoot.append(MODULE_NAME + ".ear");
+ assertTrue(rootFolder.toFile().exists());
+ assertTrue(countFiles(rootFolder.toFile()) == 0);
+ assertTrue(countAllResources(rootFolder.toFile()) == 1);
+ IFile textFile = project.getFile(CONTENT_TEXT_FILE);
+ setContents(textFile, 0);
+ assertEquals(countFiles(rootFolder.toFile()), 0);
+ assertTrue(countAllResources(rootFolder.toFile()) == 1);
+ publish();
+ assertEquals(countFiles(rootFolder.toFile()), 1);
+ assertTrue(countAllResources(rootFolder.toFile()) == 2);
+ assertContents(rootFolder.append(TEXT_FILE).toFile(), 0);
+ setContents(textFile, 1);
+ publish();
+ assertContents(rootFolder.append(TEXT_FILE).toFile(), 1);
+ textFile.delete(true, null);
+ assertEquals(countFiles(rootFolder.toFile()), 1);
+ assertTrue(countAllResources(rootFolder.toFile()) == 2);
+ publish();
+ assertEquals(countFiles(rootFolder.toFile()), 0);
+ assertTrue(countAllResources(rootFolder.toFile()) == 1);
+ removeModule(mod);
+ assertTrue(rootFolder.toFile().exists());
+ publish();
+ assertFalse(rootFolder.toFile().exists());
+ }
+}
Added:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/SingleFileDeploymentTester.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/SingleFileDeploymentTester.java
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/SingleFileDeploymentTester.java 2009-11-13
01:47:10 UTC (rev 18677)
@@ -0,0 +1,61 @@
+package org.jboss.ide.eclipse.as.test.publishing.v2;
+
+import java.io.IOException;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.wst.server.core.IModule;
+import org.jboss.ide.eclipse.as.core.ExtensionManager;
+import org.jboss.ide.eclipse.as.core.modules.SingleDeployableFactory;
+import org.jboss.ide.eclipse.as.core.publishers.SingleFilePublisher;
+import org.jboss.ide.eclipse.as.core.server.IJBossServerPublisher;
+
+public class SingleFileDeploymentTester extends JSTDeploymentTester {
+ public void testMain() throws CoreException, IOException {
+ IFile file = createXMLFile();
+ IModule[] mods = SingleDeployableFactory.getFactory().getModules();
+ assertEquals(mods.length, 0);
+ SingleDeployableFactory.makeDeployable(file);
+ mods = SingleDeployableFactory.getFactory().getModules();
+ assertEquals(mods.length, 1);
+ verifyPublisher(mods[0]);
+ addModule(mods[0]);
+ IPath deployRoot = new Path(getDeployRoot(server));
+ deployRoot.toFile().mkdirs();
+ assertEquals(countFiles(deployRoot.toFile()), 0);
+ assertEquals(countAllResources(deployRoot.toFile()), 1);
+ publish();
+ assertEquals(countFiles(deployRoot.toFile()), 1);
+ assertEquals(countAllResources(deployRoot.toFile()), 2);
+ assertContents(deployRoot.append("test.xml").toFile(),
+ "<test>done</test>");
+ setContents(file, "<test>done2</test>");
+ assertContents(deployRoot.append("test.xml").toFile(),
+ "<test>done</test>");
+ publish();
+ assertContents(deployRoot.append("test.xml").toFile(),
+ "<test>done2</test>");
+ removeModule(mods[0]);
+ assertContents(deployRoot.append("test.xml").toFile(),
+ "<test>done2</test>");
+ assertEquals(countAllResources(deployRoot.toFile()), 2);
+ publish();
+ assertFalse(deployRoot.append("test.xml").toFile().exists());
+ assertEquals(countAllResources(deployRoot.toFile()), 1);
+ }
+
+ protected void verifyPublisher(IModule module) {
+ IModule[] mod = new IModule[] { module };
+ IJBossServerPublisher publisher = ExtensionManager
+ .getDefault().getPublisher(server, mod, "local");
+ assertTrue(publisher instanceof SingleFilePublisher);
+ }
+
+ protected IFile createXMLFile() throws CoreException, IOException {
+ IFile xmlFile = project.getFile("test.xml");
+ setContents(xmlFile, "<test>done</test>");
+ return xmlFile;
+ }
+}
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 2009-11-13
00:47:20 UTC (rev 18676)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/server/StartupShutdownTest.java 2009-11-13
01:47:10 UTC (rev 18677)
@@ -25,34 +25,22 @@
import java.util.Date;
import junit.framework.AssertionFailedError;
-import junit.framework.TestCase;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.core.IStreamListener;
import org.eclipse.debug.core.model.IStreamMonitor;
-import org.eclipse.jdt.launching.IVMInstall;
-import org.eclipse.jdt.launching.JavaRuntime;
import org.eclipse.swt.SWTException;
import org.eclipse.swt.widgets.Display;
-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.IServer;
import org.eclipse.wst.server.core.IServerListener;
-import org.eclipse.wst.server.core.IServerType;
-import org.eclipse.wst.server.core.IServerWorkingCopy;
-import org.eclipse.wst.server.core.ServerCore;
import org.eclipse.wst.server.core.ServerEvent;
-import org.eclipse.wst.server.core.ServerUtil;
import org.eclipse.wst.server.core.IServer.IOperationListener;
-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.core.util.IJBossToolingConstants;
import org.jboss.ide.eclipse.as.test.ASTest;
+import org.jboss.ide.eclipse.as.test.util.ServerRuntimeUtils;
/**
* These tests are for a simple startup / shutdown of a basic,
@@ -62,10 +50,7 @@
* @author Rob Stryker
*
*/
-public class StartupShutdownTest extends TestCase {
-
- public static final IVMInstall VM_INSTALL = JavaRuntime.getDefaultVMInstall();
- public static final String DEFAULT_CONFIG = "default";
+public class StartupShutdownTest extends ServerRuntimeUtils {
public static final int DEFAULT_STARTUP_TIME = 150000;
public static final int DEFAULT_SHUTDOWN_TIME = 90000;
@@ -76,11 +61,15 @@
public void setUp() {
try {
if( getName().equals("test32"))
- createServer(ASTest.JBOSS_RUNTIME_32, ASTest.JBOSS_SERVER_32,
ASTest.JBOSS_AS_32_HOME, DEFAULT_CONFIG);
+ currentServer = createServer(IJBossToolingConstants.AS_32,
IJBossToolingConstants.SERVER_AS_32, ASTest.JBOSS_AS_32_HOME, DEFAULT_CONFIG);
else if( getName().equals("test40"))
- createServer(ASTest.JBOSS_RUNTIME_40, ASTest.JBOSS_SERVER_40,
ASTest.JBOSS_AS_40_HOME, DEFAULT_CONFIG);
+ currentServer = createServer(IJBossToolingConstants.AS_40,
IJBossToolingConstants.SERVER_AS_40, ASTest.JBOSS_AS_40_HOME, DEFAULT_CONFIG);
else if( getName().equals("test42"))
- createServer(ASTest.JBOSS_RUNTIME_42, ASTest.JBOSS_SERVER_42,
ASTest.JBOSS_AS_42_HOME, DEFAULT_CONFIG);
+ currentServer = createServer(IJBossToolingConstants.AS_42,
IJBossToolingConstants.SERVER_AS_42, ASTest.JBOSS_AS_42_HOME, DEFAULT_CONFIG);
+ else if( getName().equals("test50"))
+ currentServer = createServer(IJBossToolingConstants.AS_50,
IJBossToolingConstants.SERVER_AS_50, ASTest.JBOSS_AS_50_HOME, DEFAULT_CONFIG);
+ else if( getName().equals("test51"))
+ currentServer = createServer(IJBossToolingConstants.AS_51,
IJBossToolingConstants.SERVER_AS_51, ASTest.JBOSS_AS_51_HOME, DEFAULT_CONFIG);
// first thing's first. Let's add a server state listener
stateListener = new ServerStateListener();
@@ -103,40 +92,7 @@
- public static IServer createServer(String runtimeID, String serverID,
- String location, String configuration) throws CoreException {
- // if file doesnt exist, abort immediately.
- assertTrue(new Path(location).toFile().exists());
-
- IRuntime currentRuntime = createRuntime(runtimeID, location, configuration);
- IServerType serverType = ServerCore.findServerType(serverID);
- IServerWorkingCopy serverWC = serverType.createServer(null, null, new
NullProgressMonitor());
- serverWC.setRuntime(currentRuntime);
- serverWC.setName(serverID);
- serverWC.setServerConfiguration(null);
- return serverWC.save(true, new NullProgressMonitor());
- }
-
- private static IRuntime createRuntime(String runtimeId, String homeDir, String config)
throws CoreException {
- IRuntimeType[] runtimeTypes = ServerUtil.getRuntimeTypes(null,null, runtimeId);
- assertEquals("expects only one runtime type", runtimeTypes.length, 1);
- IRuntimeType runtimeType = runtimeTypes[0];
- IRuntimeWorkingCopy runtimeWC = runtimeType.createRuntime(null, new
NullProgressMonitor());
- runtimeWC.setName(runtimeId);
- runtimeWC.setLocation(new Path(homeDir));
- ((RuntimeWorkingCopy) runtimeWC).setAttribute(
- IJBossServerRuntime.PROPERTY_VM_ID, VM_INSTALL.getId());
- ((RuntimeWorkingCopy) runtimeWC).setAttribute(
- IJBossServerRuntime.PROPERTY_VM_TYPE_ID, VM_INSTALL
- .getVMInstallType().getId());
- ((RuntimeWorkingCopy) runtimeWC).setAttribute(
- IJBossServerRuntime.PROPERTY_CONFIGURATION_NAME, config);
-
- IRuntime savedRuntime = runtimeWC.save(true, new NullProgressMonitor());
- return savedRuntime;
- }
-
public class StatusWrapper {
protected IStatus status;
public IStatus getStatus() { return this.status; }
@@ -147,16 +103,26 @@
startup();
shutdown();
}
-
- public void test40() {
- startup();
- shutdown();
- }
-
- public void test42() {
- startup();
- shutdown();
- }
+//
+// public void test40() {
+// startup();
+// shutdown();
+// }
+//
+// public void test42() {
+// startup();
+// shutdown();
+// }
+//
+// public void test50() {
+// startup();
+// shutdown();
+// }
+//
+// public void test51() {
+// startup();
+// shutdown();
+// }
protected class ServerStateListener implements IServerListener {
private ArrayList stateChanges;
@@ -231,6 +197,7 @@
try {
assertTrue("Startup has taken longer than what is expected for a default
startup", finishTime >= new Date().getTime());
assertNotNull("Startup never finished", opWrapper.getStatus());
+ assertFalse("Startup failed", opWrapper.getStatus().getSeverity() ==
IStatus.ERROR);
assertFalse("Startup had System.error output", streamListener.hasError());
} catch( AssertionFailedError afe ) {
// cleanup
@@ -238,7 +205,8 @@
// rethrow
throw afe;
}
- getStreamMonitor().removeListener(streamListener);
+ if( getStreamMonitor() != null )
+ getStreamMonitor().removeListener(streamListener);
}
Modified:
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 2009-11-13
00:47:20 UTC (rev 18676)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/ProjectRuntimeUtil.java 2009-11-13
01:47:10 UTC (rev 18677)
@@ -42,12 +42,17 @@
public class ProjectRuntimeUtil extends Assert {
+ public static org.eclipse.wst.common.project.facet.core.runtime.IRuntime
getRuntime(IProject theProject) throws CoreException {
+ IFacetedProject facetedProject = ProjectFacetsManager.create(theProject);
+ return facetedProject.getPrimaryRuntime();
+ }
+
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);
Added:
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
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/ServerRuntimeUtils.java 2009-11-13
01:47:10 UTC (rev 18677)
@@ -0,0 +1,76 @@
+package org.jboss.ide.eclipse.as.test.util;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.launching.IVMInstall;
+import org.eclipse.jdt.launching.JavaRuntime;
+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.IServer;
+import org.eclipse.wst.server.core.IServerType;
+import org.eclipse.wst.server.core.IServerWorkingCopy;
+import org.eclipse.wst.server.core.ServerCore;
+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 junit.framework.TestCase;
+
+public class ServerRuntimeUtils extends TestCase {
+ public static final IVMInstall VM_INSTALL = JavaRuntime.getDefaultVMInstall();
+ public static final String DEFAULT_CONFIG = "default";
+
+ public static IServer createServer(String runtimeID, String serverID,
+ String location, String configuration) throws CoreException {
+ // if file doesnt exist, abort immediately.
+ assertTrue(new Path(location).toFile().exists());
+
+ IRuntime currentRuntime = createRuntime(runtimeID, location,
+ configuration);
+ IServerType serverType = ServerCore.findServerType(serverID);
+ IServerWorkingCopy serverWC = serverType.createServer(null, null,
+ new NullProgressMonitor());
+ serverWC.setRuntime(currentRuntime);
+ serverWC.setName(serverID);
+ serverWC.setServerConfiguration(null);
+ return serverWC.save(true, new NullProgressMonitor());
+ }
+
+ public static IRuntime createRuntime(String runtimeId, String homeDir,
+ String config) throws CoreException {
+ IRuntimeType[] runtimeTypes = ServerUtil.getRuntimeTypes(null, null,
+ runtimeId);
+ assertEquals("expects only one runtime type", runtimeTypes.length, 1);
+ IRuntimeType runtimeType = runtimeTypes[0];
+ IRuntimeWorkingCopy runtimeWC = runtimeType.createRuntime(null,
+ new NullProgressMonitor());
+ runtimeWC.setName(runtimeId);
+ runtimeWC.setLocation(new Path(homeDir));
+ ((RuntimeWorkingCopy) runtimeWC).setAttribute(
+ IJBossServerRuntime.PROPERTY_VM_ID, VM_INSTALL.getId());
+ ((RuntimeWorkingCopy) runtimeWC).setAttribute(
+ IJBossServerRuntime.PROPERTY_VM_TYPE_ID, VM_INSTALL
+ .getVMInstallType().getId());
+ ((RuntimeWorkingCopy) runtimeWC).setAttribute(
+ IJBossServerRuntime.PROPERTY_CONFIGURATION_NAME, config);
+
+ IRuntime savedRuntime = runtimeWC.save(true, new NullProgressMonitor());
+ return savedRuntime;
+ }
+
+ public static void deleteAllServers() throws CoreException {
+ IServer[] servers = ServerCore.getServers();
+ for( int i = 0; i < servers.length; i++ ) {
+ servers[i].delete();
+ }
+ }
+
+ public static void deleteAllRuntimes() throws CoreException {
+ IRuntime[] runtimes = ServerCore.getRuntimes();
+ for( int i = 0; i < runtimes.length; i++ ) {
+ runtimes[i].delete();
+ }
+ }
+}
Added:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/wtp/JavaEEFacetConstants.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/wtp/JavaEEFacetConstants.java
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/wtp/JavaEEFacetConstants.java 2009-11-13
01:47:10 UTC (rev 18677)
@@ -0,0 +1,48 @@
+package org.jboss.ide.eclipse.as.test.util.wtp;
+
+import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants;
+import org.eclipse.wst.common.project.facet.core.IProjectFacet;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+
+public class JavaEEFacetConstants {
+
+ public static final IProjectFacet APP_CLIENT_FACET =
ProjectFacetsManager.getProjectFacet(IModuleConstants.JST_APPCLIENT_MODULE);
//$NON-NLS-1$
+ public static final IProjectFacetVersion APP_CLIENT_12 =
APP_CLIENT_FACET.getVersion("1.2"); //$NON-NLS-1$
+ public static final IProjectFacetVersion APP_CLIENT_13 =
APP_CLIENT_FACET.getVersion("1.3"); //$NON-NLS-1$
+ public static final IProjectFacetVersion APP_CLIENT_14 =
APP_CLIENT_FACET.getVersion("1.4"); //$NON-NLS-1$
+ public static final IProjectFacetVersion APP_CLIENT_5 =
APP_CLIENT_FACET.getVersion("5.0"); //$NON-NLS-1$
+ //public static final IProjectFacetVersion APP_CLIENT_6 =
APP_CLIENT_FACET.getVersion("6.0"); //$NON-NLS-1$
+
+ public static final IProjectFacet EJB_FACET =
ProjectFacetsManager.getProjectFacet(IModuleConstants.JST_EJB_MODULE); //$NON-NLS-1$
+ public static final IProjectFacetVersion EJB_11 = EJB_FACET.getVersion("1.1");
//$NON-NLS-1$
+ public static final IProjectFacetVersion EJB_2 = EJB_FACET.getVersion("2.0");
//$NON-NLS-1$
+ public static final IProjectFacetVersion EJB_21 = EJB_FACET.getVersion("2.1");
//$NON-NLS-1$
+ public static final IProjectFacetVersion EJB_3 = EJB_FACET.getVersion("3.0");
//$NON-NLS-1$
+ //public static final IProjectFacetVersion EJB_31 =
EJB_FACET.getVersion("3.1"); //$NON-NLS-1$
+
+ public static final IProjectFacet WEB_FACET =
ProjectFacetsManager.getProjectFacet(IModuleConstants.JST_WEB_MODULE); //$NON-NLS-1$
+ public static final IProjectFacetVersion WEB_22 = WEB_FACET.getVersion("2.2");
//$NON-NLS-1$
+ public static final IProjectFacetVersion WEB_23 = WEB_FACET.getVersion("2.3");
//$NON-NLS-1$
+ public static final IProjectFacetVersion WEB_24 = WEB_FACET.getVersion("2.4");
//$NON-NLS-1$
+ public static final IProjectFacetVersion WEB_25 = WEB_FACET.getVersion("2.5");
//$NON-NLS-1$
+ //public static final IProjectFacetVersion WEB_30 =
WEB_FACET.getVersion("3.0"); //$NON-NLS-1$
+
+ public static final IProjectFacet CONNECTOR_FACET =
ProjectFacetsManager.getProjectFacet(IModuleConstants.JST_CONNECTOR_MODULE);
//$NON-NLS-1$
+ public static final IProjectFacetVersion CONNECTOR_1 =
CONNECTOR_FACET.getVersion("1.0"); //$NON-NLS-1$
+ public static final IProjectFacetVersion CONNECTOR_15 =
CONNECTOR_FACET.getVersion("1.5"); //$NON-NLS-1$
+ //public static final IProjectFacetVersion CONNECTOR_16 =
CONNECTOR_FACET.getVersion("1.6"); //$NON-NLS-1$
+
+ public static final IProjectFacet EAR_FACET =
ProjectFacetsManager.getProjectFacet(IModuleConstants.JST_EAR_MODULE); //$NON-NLS-1$
+ public static final IProjectFacetVersion EAR_12 = EAR_FACET.getVersion("1.2");
//$NON-NLS-1$
+ public static final IProjectFacetVersion EAR_13 = EAR_FACET.getVersion("1.3");
//$NON-NLS-1$
+ public static final IProjectFacetVersion EAR_14 = EAR_FACET.getVersion("1.4");
//$NON-NLS-1$
+ public static final IProjectFacetVersion EAR_5 = EAR_FACET.getVersion("5.0");
//$NON-NLS-1$
+ //public static final IProjectFacetVersion EAR_6 =
EAR_FACET.getVersion("6.0"); //$NON-NLS-1$
+
+ public static final IProjectFacet JAVA_FACET =
ProjectFacetsManager.getProjectFacet(IModuleConstants.JST_JAVA); //$NON-NLS-1$
+ public static final IProjectFacetVersion JAVA_13 =
JAVA_FACET.getVersion("1.3"); //$NON-NLS-1$
+ public static final IProjectFacetVersion JAVA_14 =
JAVA_FACET.getVersion("1.4"); //$NON-NLS-1$
+ public static final IProjectFacetVersion JAVA_5 =
JAVA_FACET.getVersion("5.0"); //$NON-NLS-1$
+ //public static final IProjectFacetVersion JAVA_6 =
JAVA_FACET.getVersion("6.0"); //$NON-NLS-1$
+}
Added:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/wtp/OperationTestCase.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/wtp/OperationTestCase.java
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/wtp/OperationTestCase.java 2009-11-13
01:47:10 UTC (rev 18677)
@@ -0,0 +1,267 @@
+package org.jboss.ide.eclipse.as.test.util.wtp;
+
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IWorkspaceDescription;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import
org.eclipse.wst.common.frameworks.internal.datamodel.IWorkspaceRunnableWithStatus;
+import org.eclipse.wst.common.internal.emf.resource.RendererFactory;
+import org.eclipse.wst.validation.internal.operations.ValidationBuilder;
+
+
+/**
+ * @author jsholl
+ * @author itewk
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public abstract class OperationTestCase extends TestCase {
+
+ public static final String VALIDATOR_JOB_FAMILY = "validators";
+ public static String fileSep = System.getProperty("file.separator");
//$NON-NLS-1$
+ public static IStatus OK_STATUS = new Status(IStatus.OK,
"org.eclipse.jem.util", 0, "OK", null); //$NON-NLS-1$ //$NON-NLS-2$
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ try{
+ deleteAllProjects();
+ } finally {
+ RendererFactory.getDefaultRendererFactory().setValidating(false);
+ }
+ }
+
+ public static void deleteAllProjects() {
+ try {
+ waitOnJobs();
+ } catch (InterruptedException e1) {
+
+ }
+ IWorkspaceRunnableWithStatus workspaceRunnable = new IWorkspaceRunnableWithStatus(null)
{
+ public void run(IProgressMonitor pm) throws CoreException {
+ try {
+ ProjectUtility.deleteAllProjects();
+ } catch (Exception e) {
+ }
+ }
+ };
+ try {
+ ResourcesPlugin.getWorkspace().run(workspaceRunnable, null);
+ } catch (CoreException e) {
+
+ }
+ }
+
+ public OperationTestCase() {
+ super("OperationsTestCase"); //$NON-NLS-1$
+ }
+
+ public OperationTestCase(String name) {
+ super(name);
+ }
+
+ public static void runAndVerify(IDataModel dataModel) throws Exception {
+ OperationTestCase.runAndVerify(dataModel, true, true);
+ }
+ public static void runDataModel(IDataModel dataModel) throws Exception {
+ OperationTestCase.runDataModel(dataModel, true, true);
+ }
+
+ public static void runDataModel(IDataModel dataModel, boolean checkTasks, boolean
checkLog) throws Exception {
+ OperationTestCase.runDataModel(dataModel, checkTasks, checkLog, null, true, false);
+ }
+
+ public static void runAndVerify(IDataModel dataModel, boolean checkTasks, boolean
checkLog) throws Exception {
+ runAndVerify(dataModel, checkTasks, checkLog, null, true, false);
+ }
+
+ public static void runAndVerify(IDataModel dataModel, boolean checkTasks, boolean
checkLog, boolean waitForBuildToComplete) throws Exception {
+ runAndVerify(dataModel, checkTasks, checkLog, null, true, waitForBuildToComplete);
+ }
+
+ public static void runAndVerify(IDataModel dataModel, boolean checkTasks, boolean
checkLog, List errorOKList, boolean reportIfExpectedErrorNotFound) throws Exception {
+ runAndVerify(dataModel, checkTasks, checkLog, errorOKList,
reportIfExpectedErrorNotFound, false);
+ }
+
+ public static void runAndVerify(IDataModel dataModel, boolean checkTasks, boolean
checkLog, List errorOKList, boolean reportIfExpectedErrorNotFound, boolean
waitForBuildToComplete) throws Exception {
+ runAndVerify(dataModel, checkTasks, checkLog, errorOKList,
reportIfExpectedErrorNotFound, waitForBuildToComplete, false);
+ }
+
+ public static void runDataModel(IDataModel dataModel, boolean checkTasks, boolean
checkLog, List errorOKList, boolean reportIfExpectedErrorNotFound, boolean
waitForBuildToComplete) throws Exception {
+ runDataModel(dataModel, checkTasks, checkLog, errorOKList,
reportIfExpectedErrorNotFound, waitForBuildToComplete, false);
+ }
+
+ /**
+ * Guaranteed to close the dataModel
+ *
+ * @param dataModel
+ * @throws Exception
+ */
+ public static void runAndVerify(IDataModel dataModel, boolean checkTasks, boolean
checkLog, List errorOKList, boolean reportIfExpectedErrorNotFound, boolean
waitForBuildToComplete, boolean removeAllSameTypesOfErrors) throws Exception {
+ PostBuildListener listener = null;
+ IWorkspaceDescription desc = null;
+ try {
+ if (waitForBuildToComplete) {
+ listener = new PostBuildListener();
+ desc = ResourcesPlugin.getWorkspace().getDescription();
+ desc.setAutoBuilding(false);
+ ResourcesPlugin.getWorkspace().setDescription(desc);
+ ResourcesPlugin.getWorkspace().addResourceChangeListener(listener,
IResourceChangeEvent.POST_BUILD);
+ }
+
+ //deal with weather to fail on logged statuses or not
+ //BaseTestCase.failOnLoggedStatus(checkLog);
+
+ IStatus operationStatus = dataModel.getDefaultOperation().execute(new
NullProgressMonitor(), null);
+
+ if (waitForBuildToComplete) {
+ desc.setAutoBuilding(true);
+ ResourcesPlugin.getWorkspace().setDescription(desc);
+ while (!listener.isBuildComplete()) {
+ Thread.sleep(3000);// do nothing till all the jobs are completed
+ }
+ }
+
+ // bug 173933 - runAndVerify() fails to check return IStatus
+ if (operationStatus.getSeverity() == IStatus.ERROR) {
+ Throwable throwable = operationStatus.getException();
+ String throwableStr = null;
+ if(throwable != null){
+ throwable.printStackTrace();
+ throwableStr = getStackTrace(throwable);
+ }
+ if(throwableStr == null){
+ throwableStr = "no message";
+ }
+ Assert.fail(operationStatus.getMessage()+"\n caused by:
"+throwableStr);
+ }
+
+ /*//Verifiers don't exist
+ //run data model verifications
+ DataModelVerifierFactory verifierFactory = DataModelVerifierFactory.getInstance();
+ DataModelVerifier verifier = verifierFactory.createVerifier(dataModel);
+ verifier.verify(dataModel);
+
+ if (checkTasks && (errorOKList == null || errorOKList.isEmpty())) {
+ checkTasksList();
+ } else if (checkTasks && errorOKList != null &&
!errorOKList.isEmpty()) {
+ TaskViewUtility.verifyErrors(errorOKList, reportIfExpectedErrorNotFound,
removeAllSameTypesOfErrors);
+ }
+ */
+ } finally {
+ if (listener != null)
+ ResourcesPlugin.getWorkspace().removeResourceChangeListener(listener);
+ dataModel.dispose();
+ }
+ }
+
+ public static String getStackTrace(Throwable throwable){
+ StringBuffer buffer = new StringBuffer(throwable.toString()+"\n");
+ StackTraceElement[] stack = throwable.getStackTrace();
+ for (int i=0; i<stack.length; i++)
+ buffer.append("\tat " + stack[i]+"\n");
+
+ StackTraceElement[] parentStack = stack;
+ throwable = throwable.getCause();
+ while (throwable != null) {
+ buffer.append("Caused by: ");
+ buffer.append(throwable);
+ buffer.append("\n");
+ StackTraceElement[] currentStack = throwable.getStackTrace();
+ parentStack = currentStack;
+ throwable = throwable.getCause();
+ }
+ return buffer.toString();
+ }
+ /**
+ * Guaranteed to close the dataModel
+ *
+ * @param dataModel
+ * @throws Exception
+ */
+ public static void runDataModel(IDataModel dataModel, boolean checkTasks, boolean
checkLog, List errorOKList, boolean reportIfExpectedErrorNotFound, boolean
waitForBuildToComplete, boolean removeAllSameTypesOfErrors) throws Exception {
+ PostBuildListener listener = null;
+ IWorkspaceDescription desc = null;
+ try {
+ if (waitForBuildToComplete) {
+ listener = new PostBuildListener();
+ desc = ResourcesPlugin.getWorkspace().getDescription();
+ desc.setAutoBuilding(false);
+ ResourcesPlugin.getWorkspace().setDescription(desc);
+ ResourcesPlugin.getWorkspace().addResourceChangeListener(listener,
IResourceChangeEvent.POST_BUILD);
+ }
+
+ //deal with weather to fail on logged statuses or not
+ //BaseTestCase.failOnLoggedStatus(checkLog);
+
+ dataModel.getDefaultOperation().execute(new NullProgressMonitor(), null);
+
+ if (waitForBuildToComplete) {
+ desc.setAutoBuilding(true);
+ ResourcesPlugin.getWorkspace().setDescription(desc);
+ while (!listener.isBuildComplete()) {
+ Thread.sleep(3000);// do nothing till all the jobs are completeled
+ }
+ }
+ if (checkTasks && (errorOKList == null || errorOKList.isEmpty())) {
+ checkTasksList();
+ } else if (checkTasks && errorOKList != null &&
!errorOKList.isEmpty()) {
+ TaskViewUtility.verifyErrors(errorOKList, reportIfExpectedErrorNotFound,
removeAllSameTypesOfErrors);
+ }
+
+ } finally {
+ if (listener != null)
+ ResourcesPlugin.getWorkspace().removeResourceChangeListener(listener);
+ dataModel.dispose();
+ }
+ }
+
+
+ protected static void checkTasksList() {
+ //TaskViewUtility.verifyNoErrors();
+ }
+
+ public static void verifyValidDataModel(IDataModel dataModel) {
+ IStatus status = dataModel.validate();
+
+ if (!status.isOK() && status.getSeverity() == IStatus.ERROR) {
+ Assert.assertTrue("DataModel is invalid operation will not run:" +
status.toString(), false); //$NON-NLS-1$
+ }
+ }
+
+ public static void verifyInvalidDataModel(IDataModel dataModel) {
+ IStatus status = dataModel.validate();
+ if (status.isOK()) {
+ Assert.assertTrue("DataModel should be invalid:" + status.getMessage(),
false); //$NON-NLS-1$
+ }
+ }
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ // Wait for all validation jobs to end before ending test....
+ waitOnJobs();
+
+ }
+
+ public static void waitOnJobs() throws InterruptedException {
+ IProject[] projects = ProjectUtility.getAllProjects();
+ for (int i = 0; i < projects.length; i++) {
+ IProject project = projects[i];
+ Job.getJobManager().join(project.getName() + VALIDATOR_JOB_FAMILY,null);
+ }
+ Job.getJobManager().join(ResourcesPlugin.FAMILY_MANUAL_BUILD,null);
+ Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD,null);
+ Job.getJobManager().join(ValidationBuilder.FAMILY_VALIDATION_JOB,null);
+ }
+}
Added:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/wtp/PostBuildListener.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/wtp/PostBuildListener.java
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/wtp/PostBuildListener.java 2009-11-13
01:47:10 UTC (rev 18677)
@@ -0,0 +1,24 @@
+package org.jboss.ide.eclipse.as.test.util.wtp;
+
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+
+public class PostBuildListener implements IResourceChangeListener {
+ private boolean buildComplete = false;
+ /* (non-Javadoc)
+ * @see
org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
+ */
+ public void resourceChanged(IResourceChangeEvent event) {
+ if (event.getType() == IResourceChangeEvent.POST_BUILD){
+ buildComplete = true;
+ }
+ }
+
+ public boolean isBuildComplete() {
+ return buildComplete;
+ }
+
+ public void testComplete() {
+ buildComplete = false;
+ }
+}
\ No newline at end of file
Added:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/wtp/ProjectCreationUtil.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/wtp/ProjectCreationUtil.java
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/wtp/ProjectCreationUtil.java 2009-11-13
01:47:10 UTC (rev 18677)
@@ -0,0 +1,425 @@
+package org.jboss.ide.eclipse.as.test.util.wtp;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import
org.eclipse.jst.j2ee.applicationclient.internal.creation.AppClientFacetProjectCreationDataModelProvider;
+import org.eclipse.jst.j2ee.earcreation.IEarFacetInstallDataModelProperties;
+import org.eclipse.jst.j2ee.ejb.project.operations.IEjbFacetInstallDataModelProperties;
+import
org.eclipse.jst.j2ee.internal.ejb.project.operations.EjbFacetProjectCreationDataModelProvider;
+import
org.eclipse.jst.j2ee.internal.project.facet.EARFacetProjectCreationDataModelProvider;
+import
org.eclipse.jst.j2ee.internal.web.archive.operations.WebFacetProjectCreationDataModelProvider;
+import
org.eclipse.jst.j2ee.jca.project.facet.ConnectorFacetProjectCreationDataModelProvider;
+import org.eclipse.jst.j2ee.jca.project.facet.IConnectorFacetInstallDataModelProperties;
+import org.eclipse.jst.j2ee.project.JavaEEProjectUtilities;
+import org.eclipse.jst.j2ee.project.facet.IAppClientFacetInstallDataModelProperties;
+import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetConstants;
+import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetInstallDataModelProperties;
+import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetProjectCreationDataModelProperties;
+import org.eclipse.jst.j2ee.project.facet.IJ2EEModuleFacetInstallDataModelProperties;
+import org.eclipse.jst.j2ee.web.project.facet.IWebFacetInstallDataModelProperties;
+import
org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties;
+import
org.eclipse.wst.common.componentcore.datamodel.properties.IFacetInstallDataModelProperties;
+import
org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties;
+import
org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties.FacetDataModelMap;
+import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+
+public class ProjectCreationUtil {
+ static {
+ try {
+ } catch(Throwable t) {
+ t.printStackTrace();
+ }
+
+ }
+
+ private static final String APP_CLIENT_PROJ_12 = "myAppClient_12";
+ private static final String APP_CLIENT_PROJ_13 = "myAppClient_13";
+ private static final String APP_CLIENT_PROJ_14 = "myAppClient_14";
+ private static final String APP_CLIENT_PROJ_5 = "myAppClient_5";
+
+ private static final String EJB_PROJ_11 = "myEJB_11";
+ private static final String EJB_PROJ_2 = "myEJB_2";
+ private static final String EJB_PROJ_21 = "myEJB_21";
+ private static final String EJB_PROJ_3 = "myEJB_3";
+
+ private static final String WEB_PROJ_22 = "myWeb_22";
+ private static final String WEB_PROJ_23 = "myWeb_23";
+ private static final String WEB_PROJ_24 = "myWeb_24";
+ private static final String WEB_PROJ_25 = "myWeb_25";
+
+ private static final String CONNECTOR_PROJ_1 = "myConnector_1";
+ private static final String CONNECTOR_PROJ_15 = "myConnector_15";
+
+ /**
+ * Creates and returns an Connector Data Model with the given name and of the given
version.
+ * If earName is not null then Connector will be added to the EAR with earName.
+ * Can also specify none default source folder
+ *
+ * @param projName name of the project to create
+ * @param earName name of the EAR to add the project too, if NULL then don't add
to an EAR
+ * @param sourceFolder name of the source folder to use, if NULL then use default
+ * @param version version of Application Client to use
+ * @return a Connector Model with the appropriate properties set
+ */
+ public static IDataModel getConnectorDataModel(String projName, String earName,
String sourceFolder, IProjectFacetVersion version){
+ IDataModel dm = DataModelFactory.createDataModel(new
ConnectorFacetProjectCreationDataModelProvider());
+ dm.setProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME,
projName);
+
+ if(earName != null) {
+ dm.setProperty(IJ2EEFacetProjectCreationDataModelProperties.ADD_TO_EAR, true);
+ dm.setProperty(IJ2EEFacetProjectCreationDataModelProperties.EAR_PROJECT_NAME,
earName);
+ } else {
+ dm.setProperty(IJ2EEFacetProjectCreationDataModelProperties.ADD_TO_EAR, false);
+ }
+
+ FacetDataModelMap facetMap = (FacetDataModelMap)
dm.getProperty(IFacetProjectCreationDataModelProperties.FACET_DM_MAP);
+ IDataModel facetModel = facetMap.getFacetDataModel(IJ2EEFacetConstants.JCA);
+ facetModel.setProperty(IFacetDataModelProperties.FACET_VERSION, version);
+
+ if(sourceFolder != null) {
+ facetModel.setProperty(IConnectorFacetInstallDataModelProperties.CONFIG_FOLDER,
sourceFolder);
+ }
+
+ //be sure to use Java5 with JEE5
+ if(version == JavaEEFacetConstants.CONNECTOR_15){
+ IDataModel javaFacetModel =
facetMap.getFacetDataModel(IJ2EEFacetConstants.JAVA);
+ javaFacetModel.setProperty(IFacetDataModelProperties.FACET_VERSION,
JavaEEFacetConstants.JAVA_5);
+ }
+
+ return dm;
+ }
+
+ /**
+ * Creates and returns an EJB Data Model with the given name and of the given
version.
+ * Can also set the clientName to be different then the default.
+ * If earName is not null then AppClient will be added to the EAR with earName, and
if appropriate
+ * with or without a deployment descriptor.
+ *
+ * @param projName name of the project to create
+ * @param clientName name of client jar to create, if NULL or earName is NULL then
don't create one
+ * @param clientSourceFolder source folder for client, use default if value is NULL,
ignored if clientName is NULL
+ * @param earName name of the EAR to add the project too, if NULL then don't add
to an EAR
+ * @param version version of EJB to use
+ * @param createDD only used if version is JEE5, if true then create DD else
don't
+ * @return an EJB Model with the appropriate properties set
+ */
+ public static IDataModel getEJBDataModel(String projName, String clientName, String
clientSourceFolder, String earName, IProjectFacetVersion version, boolean createDD) {
+ IDataModel dm = DataModelFactory.createDataModel(new
EjbFacetProjectCreationDataModelProvider());
+ dm.setProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME,
projName);
+
+ FacetDataModelMap facetMap = (FacetDataModelMap)
dm.getProperty(IFacetProjectCreationDataModelProperties.FACET_DM_MAP);
+ IDataModel facetModel = facetMap.getFacetDataModel(IJ2EEFacetConstants.EJB);
+ facetModel.setProperty(IFacetDataModelProperties.FACET_VERSION, version);
+
+ if(earName != null) {
+ dm.setProperty(IJ2EEFacetProjectCreationDataModelProperties.ADD_TO_EAR, true);
+ dm.setProperty(IJ2EEFacetProjectCreationDataModelProperties.EAR_PROJECT_NAME,
earName);
+
+ //only create client if given a client name, and is added to EAR
+ if(clientName != null) {
+ facetModel.setBooleanProperty(IEjbFacetInstallDataModelProperties.CREATE_CLIENT,
true);
+ facetModel.setStringProperty(IEjbFacetInstallDataModelProperties.CLIENT_NAME,
clientName);
+
+ //use default source folder unless different name is given
+ if(clientSourceFolder != null) {
+
facetModel.setStringProperty(IEjbFacetInstallDataModelProperties.CLIENT_SOURCE_FOLDER,
clientSourceFolder);
+ }
+ }
+ } else {
+ dm.setProperty(IJ2EEFacetProjectCreationDataModelProperties.ADD_TO_EAR, false);
+ }
+
+ facetModel.setBooleanProperty(IJ2EEFacetInstallDataModelProperties.GENERATE_DD,
createDD);
+
+// if(version.equals(JavaEEFacetConstants.EJB_31))
+// {
+// IDataModel javaFacetModel =
facetMap.getFacetDataModel(IJ2EEFacetConstants.JAVA);
+// javaFacetModel.setProperty(IFacetDataModelProperties.FACET_VERSION,
JavaEEFacetConstants.JAVA_6);
+// }
+// else{
+ IDataModel javaFacetModel = facetMap.getFacetDataModel(IJ2EEFacetConstants.JAVA);
+ javaFacetModel.setProperty(IFacetDataModelProperties.FACET_VERSION,
JavaEEFacetConstants.JAVA_5);
+// }
+
+
+ return dm;
+ }
+
+ /**
+ * Creates and returns an EJB Data Model with the given name and of the given
version.
+ * Can also set the clientName to be different then the default, or choose not to
have a client.
+ * If earName is not null then AppClient will be added to the EAR with earName, and
if appropriate
+ * with or without a deployment descriptor.
+ *
+ * Created so EJB's could be created without clients.
+ *
+ * @param projName name of the project to create
+ * @param clientName name of client jar to create, if NULL or earName is NULL then
don't create one
+ * @param clientSourceFolder source folder for client, use default if value is NULL,
ignored if clientName is NULL
+ * @param earName name of the EAR to add the project too, if NULL then don't add
to an EAR
+ * @param version version of EJB to use
+ * @param createClient if True and earName not NULL then create with client, else
dont
+ * @param createDD only used if version is JEE5, if true then create DD else
don't
+ * @return an EJB Model with the appropriate properties set
+ */
+ public static IDataModel getEJBDataModel(String projName, String clientName, String
clientSourceFolder, String earName, IProjectFacetVersion version, boolean createCleint,
boolean createDD) {
+ IDataModel dm = getEJBDataModel(projName, clientName, clientSourceFolder, earName,
version, createDD);
+
+ FacetDataModelMap facetMap = (FacetDataModelMap)
dm.getProperty(IFacetProjectCreationDataModelProperties.FACET_DM_MAP);
+ IDataModel facetModel = facetMap.getFacetDataModel(IJ2EEFacetConstants.EJB);
+ facetModel.setBooleanProperty(IEjbFacetInstallDataModelProperties.CREATE_CLIENT,
createCleint);
+
+ return dm;
+ }
+
+ /**
+ * Creates and returns an Application Client Data Model with the given name and of
the given version.
+ * If earName is not null then AppClient will be added to the EAR with earName, and
if appropriate
+ * with or without a deployment descriptor.
+ *
+ * @param projName name of the project to create
+ * @param earName name of the ear to add the project too, if NULL then don't add
to an EAR
+ * @param version version of Application Client to use
+ * @param createDefaultMainClass if true then create default main class, else
don't
+ * @param createDD only used if version is JEE5, if true then create DD else
don't
+ * @return an Application Data Model with the appropriate properties set
+ */
+ public static IDataModel getAppClientCreationDataModel(String projName, String
earName, IProjectFacetVersion version, boolean createDefaultMainClass, boolean createDD){
+ IDataModel dm = DataModelFactory.createDataModel(new
AppClientFacetProjectCreationDataModelProvider());
+ dm.setProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME,
projName);
+
+ if(earName != null) {
+ dm.setProperty(IJ2EEFacetProjectCreationDataModelProperties.ADD_TO_EAR, true);
+ dm.setProperty(IJ2EEFacetProjectCreationDataModelProperties.EAR_PROJECT_NAME,
earName);
+ } else {
+ dm.setProperty(IJ2EEFacetProjectCreationDataModelProperties.ADD_TO_EAR, false);
+ }
+
+ FacetDataModelMap facetMap = (FacetDataModelMap)
dm.getProperty(IFacetProjectCreationDataModelProperties.FACET_DM_MAP);
+ IDataModel facetModel =
facetMap.getFacetDataModel(IJ2EEFacetConstants.APPLICATION_CLIENT);
+ facetModel.setProperty(IFacetDataModelProperties.FACET_VERSION, version);
+
facetModel.setProperty(IAppClientFacetInstallDataModelProperties.CREATE_DEFAULT_MAIN_CLASS,
createDefaultMainClass);
+
+
+ facetModel.setBooleanProperty(IJ2EEFacetInstallDataModelProperties.GENERATE_DD,
createDD);
+
+ IDataModel javaFacetModel =
facetMap.getFacetDataModel(IJ2EEFacetConstants.JAVA);
+ javaFacetModel.setProperty(IFacetDataModelProperties.FACET_VERSION,
JavaEEFacetConstants.JAVA_5);
+
+ return dm;
+ }
+
+ /**
+ * Creates and returns a Web Data Model with the given name and of the given
version.
+ * Can also be used to specify none default context root, content directory, and/or
+ * the java source directory.
+ * If earName is not null then Web will be added to the EAR with earName, and if
appropriate
+ * with or without a deployment descriptor.
+ *
+ * @param projName name of the project to create
+ * @param earName name of the ear to add the project too, if NULL then don't add
to an EAR
+ * @param contextRoot the context root to use for this project, use default if NULL
+ * @param contentDir the content directory to use for this project, use default if
NULL
+ * @param javaSrcDir the java source directory to use for this project, use default
if NULL
+ * @param version version of Web to use
+ * @param createDD only used if version is JEE5, if true then create DD else
don't
+ * @return a Web Data Model with the appropriate properties set
+ */
+ public static IDataModel getWebDataModel(String projName, String earName, String
contextRoot, String contentDir, String javaSrcDir, IProjectFacetVersion version, boolean
createDD){
+ IDataModel dm = DataModelFactory.createDataModel(new
WebFacetProjectCreationDataModelProvider());
+ dm.setProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME,
projName);
+
+ if(earName != null) {
+ dm.setProperty(IJ2EEFacetProjectCreationDataModelProperties.ADD_TO_EAR, true);
+ dm.setProperty(IJ2EEFacetProjectCreationDataModelProperties.EAR_PROJECT_NAME,
earName);
+ } else {
+ dm.setProperty(IJ2EEFacetProjectCreationDataModelProperties.ADD_TO_EAR, false);
+ }
+
+ FacetDataModelMap facetMap = (FacetDataModelMap)
dm.getProperty(IFacetProjectCreationDataModelProperties.FACET_DM_MAP);
+ IDataModel facetModel =
facetMap.getFacetDataModel(IJ2EEFacetConstants.DYNAMIC_WEB);
+ facetModel.setProperty(IFacetDataModelProperties.FACET_VERSION, version);
+
+ //if no contextRoot provided use default, contextRoot only matters if adding to EAR
+ if(contextRoot != null && earName != null) {
+ facetModel.setStringProperty(IWebFacetInstallDataModelProperties.CONTEXT_ROOT,
contextRoot);
+ }
+
+ //if no contentDir provided use default
+ if(contentDir != null) {
+
facetModel.setStringProperty(IJ2EEModuleFacetInstallDataModelProperties.CONFIG_FOLDER,
contentDir);
+ }
+
+ //if no javaSrcDir provided use default
+ if(javaSrcDir != null) {
+ facetModel.setStringProperty(IWebFacetInstallDataModelProperties.SOURCE_FOLDER,
javaSrcDir);
+ }
+
+
+ facetModel.setBooleanProperty(IJ2EEFacetInstallDataModelProperties.GENERATE_DD,
createDD);
+
+ IDataModel javaFacetModel =
facetMap.getFacetDataModel(IJ2EEFacetConstants.JAVA);
+ javaFacetModel.setProperty(IFacetDataModelProperties.FACET_VERSION,
JavaEEFacetConstants.JAVA_5);
+
+
+ return dm;
+ }
+
+
+
+ /**
+ * Creates and returns an EAR Data Model with the given name and of the given version
+ *
+ * Example of how to use this method:
+ * public void testEAR12_WithDependencies() throws Exception{
+ * IDataModel dm = getEARDataModel("zEAR", null,
getJ2EEDependencyList_12(), getJavaDependencyList_12(), JavaEEFacetConstants.EAR_12,
true);
+ * OperationTestCase.runAndVerify(dm);
+ * }
+ * @param projName name of the project to create
+ * @param version version of EAR to use
+ * @param contentDir directory to store the content in, if NULL use default
+ * @param dependenciesJ2EE list of J2EE IProjects that this EAR depends on, ignored
if NULL
+ * @param dependenciesJava list of Java IProjects that this EAR depends on, ignored
if NULL
+ * @param createDD only used if version is JEE5, if true then create DD else
don't
+ * @return an EAR Data Model with the appropriate properties set
+ */
+ public static IDataModel getEARDataModel(String projName, String contentDir, List
dependenciesJ2EE, List dependenciesJava, IProjectFacetVersion version, boolean createDD)
{
+ IDataModel dm = DataModelFactory.createDataModel(new
EARFacetProjectCreationDataModelProvider());
+ dm.setProperty(IFacetProjectCreationDataModelProperties.FACET_PROJECT_NAME,
projName);
+
+ FacetDataModelMap factMap = (FacetDataModelMap)
dm.getProperty(IFacetProjectCreationDataModelProperties.FACET_DM_MAP);
+ IDataModel facetModel = (IDataModel)
factMap.get(IEarFacetInstallDataModelProperties.ENTERPRISE_APPLICATION);
+ facetModel.setProperty(IFacetInstallDataModelProperties.FACET_VERSION, version);
+
+
+ if(contentDir != null) {
+ facetModel.setStringProperty(IEarFacetInstallDataModelProperties.CONTENT_DIR,contentDir);
+ }
+
+ if(dependenciesJ2EE != null) {
+ facetModel.setProperty(IEarFacetInstallDataModelProperties.J2EE_PROJECTS_LIST,
dependenciesJ2EE);
+ }
+
+ if(dependenciesJava != null) {
+ facetModel.setProperty(IEarFacetInstallDataModelProperties.JAVA_PROJECT_LIST,
dependenciesJava);
+ }
+
+
+ facetModel.setBooleanProperty(IJ2EEFacetInstallDataModelProperties.GENERATE_DD,
createDD);
+
+
+ return dm;
+ }
+
+
+
+ public static List getJ2EEDependencyList_12() throws Exception {
+ List dependencies = new ArrayList();
+ List<IDataModel> models = new ArrayList<IDataModel>();
+
+ models.add(getAppClientCreationDataModel(APP_CLIENT_PROJ_12, null,
JavaEEFacetConstants.APP_CLIENT_12, true, true));
+
+ models.add(getEJBDataModel(EJB_PROJ_11, null, null, null,
JavaEEFacetConstants.EJB_11, true));
+
+ models.add(getWebDataModel(WEB_PROJ_22, null, null, null, null,
JavaEEFacetConstants.WEB_22, true));
+
+ for(int i = 0; i < models.size(); i++) {
+ OperationTestCase.runDataModel(models.get(i));
+ }
+
+ dependencies.addAll(Arrays.asList(JavaEEProjectUtilities.getAllProjects()));
+
+ return dependencies;
+ }
+
+ public static List getJavaDependencyList_12() {
+ return Collections.emptyList();
+ }
+
+
+ public static List getJ2EEDependencyList_13() throws Exception {
+ getJ2EEDependencyList_12();
+ List dependencies = new ArrayList();
+ List<IDataModel> models = new ArrayList<IDataModel>();
+
+ models.add(getAppClientCreationDataModel(APP_CLIENT_PROJ_13, null,
JavaEEFacetConstants.APP_CLIENT_13, true, true));
+
+ models.add(getEJBDataModel(EJB_PROJ_2, null, null, null, JavaEEFacetConstants.EJB_2,
true));
+
+ models.add(getWebDataModel(WEB_PROJ_23, null, null, null, null,
JavaEEFacetConstants.WEB_23, true));
+
+ models.add(getConnectorDataModel(CONNECTOR_PROJ_1, null, null,
JavaEEFacetConstants.CONNECTOR_1));
+
+ for(int i = 0; i < models.size(); i++) {
+ OperationTestCase.runDataModel(models.get(i));
+ }
+
+ dependencies.addAll(Arrays.asList(JavaEEProjectUtilities.getAllProjects()));
+
+ return dependencies;
+ }
+
+ public static List getJavaDependencyList_13() {
+ return Collections.emptyList();
+ }
+
+
+ public static List getJ2EEDependencyList_14() throws Exception {
+ getJ2EEDependencyList_13();
+ List dependencies = new ArrayList();
+
+ List<IDataModel> models = new ArrayList<IDataModel>();
+
+ models.add(getAppClientCreationDataModel(APP_CLIENT_PROJ_14, null,
JavaEEFacetConstants.APP_CLIENT_14, true, true));
+
+ models.add(getEJBDataModel(EJB_PROJ_21, null, null, null,
JavaEEFacetConstants.EJB_21, true));
+
+ models.add(getWebDataModel(WEB_PROJ_24, null, null, null, null,
JavaEEFacetConstants.WEB_24, true));
+
+ for(int i = 0; i < models.size(); i++) {
+ OperationTestCase.runDataModel(models.get(i));
+ }
+
+ dependencies.addAll(Arrays.asList(JavaEEProjectUtilities.getAllProjects()));
+
+ return dependencies;
+ }
+
+ public static List getJavaDependencyList_14() {
+ return Collections.emptyList();
+ }
+
+ public static List getJ2EEDependencyList_5() throws Exception {
+ getJ2EEDependencyList_14();
+ List dependencies = new ArrayList();
+
+ List<IDataModel> models = new ArrayList<IDataModel>();
+
+ models.add(getAppClientCreationDataModel(APP_CLIENT_PROJ_5, null,
JavaEEFacetConstants.APP_CLIENT_5, true, false));
+ models.add(getAppClientCreationDataModel(APP_CLIENT_PROJ_5 + "_WithDD",
null, JavaEEFacetConstants.APP_CLIENT_5, true, true));
+
+ models.add(getEJBDataModel(EJB_PROJ_3, null, null, null, JavaEEFacetConstants.EJB_3,
false));
+ models.add(getEJBDataModel(EJB_PROJ_3 + "_WithDD", null, null, null,
JavaEEFacetConstants.EJB_3, true));
+
+ models.add(getWebDataModel(WEB_PROJ_25, null, null, null, null,
JavaEEFacetConstants.WEB_25, false));
+ models.add(getWebDataModel(WEB_PROJ_25 + "_WithDD", null, null, null,
null, JavaEEFacetConstants.WEB_25, true));
+
+ for(int i = 0; i < models.size(); i++) {
+ OperationTestCase.runDataModel(models.get(i));
+ }
+
+ dependencies.addAll(Arrays.asList(JavaEEProjectUtilities.getAllProjects()));
+
+ return dependencies;
+ }
+
+ public static List getJavaDependencyList_5() {
+ return Collections.emptyList();
+ }
+
+}
Added:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/wtp/ProjectUtility.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/wtp/ProjectUtility.java
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/wtp/ProjectUtility.java 2009-11-13
01:47:10 UTC (rev 18677)
@@ -0,0 +1,214 @@
+package org.jboss.ide.eclipse.as.test.util.wtp;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import junit.framework.Assert;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.AssertionFailedException;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Plugin;
+/**
+ * @author jsholl
+ *
+ * To change this generated comment edit the template variable "typecomment":
Window>Preferences>Java>Templates. To
+ * enable and disable the creation of type comments go to
Window>Preferences>Java>Code Generation.
+ */
+public class ProjectUtility {
+ public static IProject[] getAllProjects() {
+ IProject[] projects = new IProject[0];
+ try {
+ projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+ } catch (AssertionFailedException ex) {
+ // Catch Malformed tree exception that occurs from time to time...
+ }
+ return projects;
+ }
+ public static boolean projectExists(String projectName) {
+ return getProject(projectName) != null;
+ }
+ public static IProject verifyAndReturnProject(String projectName, boolean exists) {
+ IProject project = getProject(projectName);
+ if (exists) {
+ Assert.assertTrue("Project Does Not Exist:" + projectName,
project.exists());
+ } else {
+ Assert.assertTrue("Project Exists:" + projectName,
!project.exists());
+ }
+ return project;
+ }
+ public static void verifyProject(String projectName, boolean exists) {
+ IProject project = getProject(projectName);
+ if (exists) {
+ Assert.assertTrue("Project Does Not Exist:" + projectName,
project.exists());
+ } else {
+ Assert.assertTrue("Project Exists:" + projectName,
!project.exists());
+ }
+ }
+ public static IProject getProject(String projectName) {
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ String pathString = projectName;
+ if (!(workspace.getRoot().getProject(pathString) == null))
+ return workspace.getRoot().getProject(pathString);
+ else
+ return null;
+ }
+ public static void verifyNoProjects() {
+ IProject[] projects = getAllProjects();
+ String projectNames = "";
+ for (int i = 0; i < projects.length; i++) {
+ projectNames += " " + projects[i].getName();
+ }
+ Assert.assertTrue("All projects not deleted" + projectNames,
projects.length == 0);
+ }
+ public static void deleteProjectIfExists(String projectName) {
+ if (projectName == null)
+ return;
+ IProject project = getProject(projectName);
+ if (project != null && project.isAccessible()) {
+ try {
+ project.close(null);
+ project.delete(true, true, null);
+
ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, null);
+ } catch (Exception e) {
+ Assert.fail(e.getMessage());
+ }
+ }
+ }
+ public static void deleteAllProjects() throws Exception {
+ //closing projects and tread work in here is a hack because of a BeanInfo bug
holding
+ //onto jars loaded in another VM
+
+// for (int i = 0; i < projects.length; i++) {
+// if (projects[i].exists()) {
+// projects[i].close(null); // This should signal the extra VM to kill
itself
+// }
+// }
+ // Thread.yield(); // give the VM a chance to die
+ IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
+
+ public void run(IProgressMonitor monitor) {
+ IProject[] projects = getAllProjects();
+ for (int i = 0; i < projects.length; i++) {
+ IProject project = projects[i];
+ boolean success = false;
+ Exception lastException = null;
+ // Don't make 2^12 is about 4 seconds which is the max we
+ // will wait for the VM to die
+ for (int j = 0; j < 13 && !success; j++) {
+ try {
+ if (project.exists()) {
+ project.delete(true, true, null);
+ ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE,
null);
+ }
+ success = true;
+ } catch (Exception e) {
+ lastException = e;
+ if (project.exists()) {
+ try {
+ project.close(null);
+ project.open(null);
+ } catch (Exception e2) {
+ }
+ }
+ try {
+ Thread.sleep((int) Math.pow(2, j));
+ } catch (InterruptedException e1) {
+ } // if the VM
+ // isn't dead,
+ // try sleeping
+ }
+ }
+ if (!success && lastException != null) {
+ // TODO Log
+ // Assert.fail("Caught Exception=" +
+ // lastException.getMessage() + " when deleting
+ // project=" + project.getName());
+ }
+ }
+ }
+ };
+ try {
+ ResourcesPlugin.getWorkspace().run(runnable, null);
+ } catch (CoreException ce) {
+ }
+ //verifyNoProjects();
+ }
+ /**
+ * Return the absolute path Strings to the files based on the fileSuffix and
+ * path within the plugin.
+ *
+ * @param path
+ * @param fileSuffix
+ * the file ending with the "." if required (the suffix will be
+ * used as is)
+ * @return
+ */
+ public static List getSpecificFilesInDirectory(Plugin plugin, String path, final
String fileSuffix) {
+ URL entry = null;
+ entry = plugin.getBundle().getEntry(path);
+ List result = null;
+ File folder = null;
+ if (entry != null) {
+ try {
+ entry = Platform.asLocalURL(entry);
+ folder = new File(new URI(entry.toString()));
+ } catch (Exception e1) {
+ e1.printStackTrace();
+ return Collections.EMPTY_LIST;
+ }
+ List files = Arrays.asList(folder.list());
+ if (!files.isEmpty()) {
+ String folderPath = folder.getAbsolutePath() + File.separator;
+ result = new ArrayList();
+ for (int i = 0; i < files.size(); i++) {
+ String fileName = (String) files.get(i);
+ if (!fileName.endsWith(fileSuffix))
+ continue;
+ result.add(folderPath + fileName);
+ }
+ }
+ }
+ if (result == null)
+ result = Collections.EMPTY_LIST;
+ return result;
+ }
+ public static List getJarsInDirectory(Plugin plugin, String path) {
+ return getSpecificFilesInDirectory(plugin, path, ".jar");
+ }
+ public static List getRarsInDirectory(Plugin plugin, String path) {
+ return getSpecificFilesInDirectory(plugin, path, ".rar");
+ }
+ public static List getEarsInDirectory(Plugin plugin, String path) {
+ return getSpecificFilesInDirectory(plugin, path, ".ear");
+ }
+ public static List getWarsInDirectory(Plugin plugin, String path) {
+ return getSpecificFilesInDirectory(plugin, path, ".war");
+ }
+ public static String getFullFileName(Plugin plugin, String pluginRelativeFileName)
throws IOException {
+ IPath path = new Path(pluginRelativeFileName);
+ if (path.getDevice() != null)
+ return pluginRelativeFileName;
+ URL url = plugin.getBundle().getEntry(pluginRelativeFileName);
+ if (url != null) {
+ url = Platform.asLocalURL(url);
+ IPath iPath = new Path(url.getPath());
+ return iPath.toOSString();
+ }
+ return null;
+ }
+}
\ No newline at end of file
Added:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/wtp/TaskViewUtility.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/wtp/TaskViewUtility.java
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/wtp/TaskViewUtility.java 2009-11-13
01:47:10 UTC (rev 18677)
@@ -0,0 +1,193 @@
+package org.jboss.ide.eclipse.as.test.util.wtp;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+
+import junit.framework.Assert;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+
+/**
+ * @author jsholl
+ *
+ * To change this generated comment edit the template variable "typecomment":
+ * Window>Preferences>Java>Templates.
+ * To enable and disable the creation of type comments go to
+ * Window>Preferences>Java>Code Generation.
+ */
+public class TaskViewUtility {
+
+ public static IResource getWorkspaceRoot() {
+ return ResourcesPlugin.getWorkspace().getRoot();
+ }
+
+ public static void verifyNoNewTasks(HashSet hashSet) {
+ verifyNoNewTasks(null, hashSet);
+ }
+
+ public static void verifyNoNewTasks(IResource resource, HashSet hashSet) {
+ verifyNoNewTasksImpl(resource, hashSet, true);
+ }
+
+ private static void verifyNoNewTasksImpl(IResource resource, HashSet hashSet, boolean
failOnFailure) {
+ IResource markerSource = resource == null ? getWorkspaceRoot() : resource;
+ IMarker[] markers = null;
+ try {
+ markers = markerSource.findMarkers(IMarker.PROBLEM, true,
IResource.DEPTH_INFINITE);
+ } catch (CoreException e1) {
+ e1.printStackTrace();
+ Assert.fail();
+ }
+ for (int j = 0; markers != null && j < markers.length; j++) {
+ String message = markers[j].toString();
+ try {
+ message = (String) markers[j].getAttribute(IMarker.MESSAGE);
+ } catch (Exception e) {
+ }
+
+ if (null == hashSet) {
+ String failMsg = "Task in Tasks List: " + message;
+ if (failOnFailure) {
+ Assert.fail(failMsg);
+ } else {
+ System.out.println(failMsg);
+ }
+ } else if (!hashSet.contains(markers[j])) {
+ String failMsg = "New Task in Tasks List: " + message;
+ if (failOnFailure) {
+ Assert.fail(failMsg);
+ } else {
+ System.out.println(failMsg);
+ }
+
+ }
+ }
+ }
+
+ public static void verifyNoErrors() {
+ verifyNoErrors(null);
+ }
+
+ public static void verifyNoErrors(IResource resource) {
+ List markers = getErrors(resource);
+ if (null != markers && markers.size() > 0) {
+ int size = markers.size();
+ String message = "" + size + " errors in tasks view:";
+ IMarker marker;
+ for (int i = 0; i < size; i++) {
+ marker = (IMarker) markers.get(i);
+ try {
+ message += "\n" + i + " " + (String)
marker.getAttribute(IMarker.MESSAGE);
+ } catch (Exception e) {
+ }
+ }
+ Assert.fail(message);
+ }
+ }
+
+ /**
+ * @param resource
+ * @return
+ */
+ public static List getErrors(IResource resource) {
+ IResource markerSource = resource == null ? getWorkspaceRoot() : resource;
+ List markers = null;
+ try {
+ markers = findSeverityMarkers(markerSource, IMarker.SEVERITY_ERROR);
+ } catch (CoreException e1) {
+ e1.printStackTrace();
+ }
+ return markers;
+ }
+
+ private static List findSeverityMarkers(IResource markerSource, int severityLevel)
throws CoreException {
+ IMarker[] markers = markerSource.findMarkers(IMarker.PROBLEM, true,
IResource.DEPTH_INFINITE);
+ List results = null;
+ Integer severity;
+ for (int i = 0; i < markers.length; i++) {
+ severity = (Integer) markers[i].getAttribute(IMarker.SEVERITY);
+ if (severity.intValue() == severityLevel) {
+ if (results == null)
+ results = new ArrayList();
+ results.add(markers[i]);
+ }
+ }
+ if (results == null)
+ results = Collections.EMPTY_LIST;
+ return results;
+ }
+
+ public static void verifyNoWarnings() {
+
+ }
+
+ public static void verifyNoTasks() {
+ verifyNoTasks(null);
+ }
+
+ public static void verifyNoTasks(IResource resource) {
+ verifyNoNewTasksImpl(resource, null, true);
+ }
+
+ public static void verifyNoTasks(boolean failOnFailure) {
+ verifyNoTasks(null, failOnFailure);
+ }
+
+ public static void verifyNoTasks(IResource resource, boolean failOnFailure) {
+ verifyNoNewTasksImpl(resource, null, failOnFailure);
+ }
+ public static void verifyErrors(List markerDescriptionsExpected) {
+ verifyErrors(markerDescriptionsExpected,true,false);
+ }
+
+
+ public static void verifyErrors(List markerDescriptionsExpected, boolean
reportIfExpectedErrorNotFound, boolean removeAllSameTypesOfError) {
+ List markerDescriptionsFound = null;
+ try {
+ List markersFound = findSeverityMarkers(getWorkspaceRoot(),
IMarker.SEVERITY_ERROR);
+ markerDescriptionsFound = new ArrayList(markersFound.size());
+ for (int i = 0; i < markersFound.size(); i++) {
+ markerDescriptionsFound.add(((IMarker)
markersFound.get(i)).getAttribute("message"));
+ }
+ } catch (CoreException e1) {
+ e1.printStackTrace();
+ Assert.fail();
+ }
+
+ ArrayList markerDescriptionsNotFound = new ArrayList();
+ List markersDescriptionsToRemove = new ArrayList();
+ for (int i = 0; i < markerDescriptionsExpected.size(); i++) {
+ String messageToFind = (String)markerDescriptionsExpected.get(i);
+ boolean found = false;
+ for(int j=0;j<markerDescriptionsFound.size() &&(!found ||
removeAllSameTypesOfError);j++){
+ if(messageToFind.equals(markerDescriptionsFound.get(j))){
+ found = true;
+ markersDescriptionsToRemove.add(markerDescriptionsFound.get(j));
+ }
+ }
+ if (!found) {
+ markerDescriptionsNotFound.add(messageToFind);
+ }
+ }
+ markerDescriptionsFound.removeAll(markersDescriptionsToRemove);
+ if (markerDescriptionsNotFound.size() > 0 || markerDescriptionsFound.size()
> 0) {
+ String messages = "";
+ if (reportIfExpectedErrorNotFound){
+ for (int i = 0; i < markerDescriptionsNotFound.size(); i++) {
+ messages += "\nError not found:\"" +
markerDescriptionsNotFound.get(i)+"\"";
+ }
+ }
+ for (int i = 0; i < markerDescriptionsFound.size(); i++) {
+ messages += "\nUnexpected error found:\"" +
markerDescriptionsFound.get(i)+"\"";
+ }
+ if (!messages.equals(""))
+ Assert.fail(messages);
+ }
+
+ }
+}
\ No newline at end of file