Author: rob.stryker(a)jboss.com
Date: 2010-11-01 10:17:36 -0400 (Mon, 01 Nov 2010)
New Revision: 26162
Added:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/IOUtil.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/ISSHDeploymentConstants.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHPublishUtil.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/ASTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/JSTDeployBinaryChildModuleTest.java
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/JSTZippedDeploymentTester.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
Log:
JBIDE-7471 - zipped folder publishing order tests and slight changes to accomodate
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/ISSHDeploymentConstants.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/ISSHDeploymentConstants.java 2010-11-01
14:08:51 UTC (rev 26161)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/ISSHDeploymentConstants.java 2010-11-01
14:17:36 UTC (rev 26162)
@@ -10,10 +10,13 @@
******************************************************************************/
package org.jboss.ide.eclipse.as.ssh.server;
+import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
+
public interface ISSHDeploymentConstants {
public static final String HOSTS_FILE =
"org.jboss.ide.eclipse.as.ssh.server.hostsFile"; //$NON-NLS-1$
public static final String DEPLOY_DIRECTORY =
"org.jboss.ide.eclipse.as.ssh.server.deployDirectory"; //$NON-NLS-1$
public static final String USERNAME =
"org.jboss.ide.eclipse.as.ssh.server.username"; //$NON-NLS-1$
public static final String PASSWORD =
"org.jboss.ide.eclipse.as.ssh.server.password"; //$NON-NLS-1$
- public static final String ZIP_DEPLOYMENTS_PREF =
"org.jboss.ide.eclipse.as.ssh.server.zipDeploymentsPreference"; //$NON-NLS-1$
+ public static final String SSH_ZIP_DEPLOYMENTS_PREF_LEGACY =
"org.jboss.ide.eclipse.as.ssh.server.zipDeploymentsPreference"; //$NON-NLS-1$
+ public static final String ZIP_DEPLOYMENTS_PREF =
IDeployableServer.ZIP_DEPLOYMENTS_PREF;
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHPublishUtil.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHPublishUtil.java 2010-11-01
14:08:51 UTC (rev 26161)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ssh/src/org/jboss/ide/eclipse/as/ssh/server/SSHPublishUtil.java 2010-11-01
14:17:36 UTC (rev 26162)
@@ -18,7 +18,8 @@
public class SSHPublishUtil {
public static boolean getZipsSSHDeployments(IServer server) {
- return ((Server)server).getAttribute(ISSHDeploymentConstants.ZIP_DEPLOYMENTS_PREF,
false);
+ boolean defaultVal =
((Server)server).getAttribute(ISSHDeploymentConstants.SSH_ZIP_DEPLOYMENTS_PREF_LEGACY,
false);
+ return ((Server)server).getAttribute(ISSHDeploymentConstants.ZIP_DEPLOYMENTS_PREF,
defaultVal);
}
public static String getDeployDir(IServer server) {
return ((Server)server).getAttribute(ISSHDeploymentConstants.DEPLOY_DIRECTORY,
"/home");
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 2010-11-01
14:08:51 UTC (rev 26161)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/ASTest.java 2010-11-01
14:17:36 UTC (rev 26162)
@@ -21,7 +21,11 @@
*/
package org.jboss.ide.eclipse.as.test;
+import java.io.File;
+
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Plugin;
+import org.jboss.ide.eclipse.as.core.util.FileUtil;
import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
import org.osgi.framework.BundleContext;
@@ -81,4 +85,17 @@
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);
+
+ public static 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]);
+ }
+ }
+ }
+
+
+
}
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/JSTDeployBinaryChildModuleTest.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/JSTDeployBinaryChildModuleTest.java 2010-11-01
14:08:51 UTC (rev 26161)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/JSTDeployBinaryChildModuleTest.java 2010-11-01
14:17:36 UTC (rev 26162)
@@ -14,6 +14,7 @@
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.ServerUtil;
import org.jboss.ide.eclipse.as.test.publishing.AbstractDeploymentTest;
+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;
@@ -37,9 +38,9 @@
IModule mod = ServerUtil.getModule(project);
IModule[] module = new IModule[] { mod };
verifyJSTPublisher(module);
- addModule(mod);
- publish();
- IPath deployRoot = new Path(getDeployRoot(server));
+ server = ServerRuntimeUtils.addModule(server, mod);
+ ServerRuntimeUtils.publish(server);
+ IPath deployRoot = new Path(ServerRuntimeUtils.getDeployRoot(server));
IPath rootFolder = deployRoot.append(MODULE_NAME + ".war");
assertTrue(rootFolder.toFile().exists());
IPath webinf_lib_testjar =
rootFolder.append("WEB-INF").append("lib").append("test.jar");
Modified:
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 2010-11-01
14:08:51 UTC (rev 26161)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/JSTDeploymentTester.java 2010-11-01
14:17:36 UTC (rev 26162)
@@ -1,11 +1,7 @@
package org.jboss.ide.eclipse.as.test.publishing.v2;
-import java.io.BufferedInputStream;
-import java.io.ByteArrayInputStream;
import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
-import java.io.InputStream;
import junit.framework.TestCase;
@@ -14,34 +10,21 @@
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.IOUtil;
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 {
@@ -53,14 +36,14 @@
final IPath CONTENT_TEXT_FILE = new Path(CONTENT_DIR).append(TEXT_FILE);
public void setUp() throws Exception {
project = createProject();
- server = createServer();
+ server = ServerRuntimeUtils.createMockDeployOnlyServer();
}
public void tearDown() throws Exception {
ServerRuntimeUtils.deleteAllServers();
ServerRuntimeUtils.deleteAllRuntimes();
ProjectUtility.deleteAllProjects();
- clearStateLocation();
+ ASTest.clearStateLocation();
}
protected IProject createProject() throws Exception {
@@ -70,110 +53,19 @@
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);
+ assertEquals(val, IOUtil.getContents(file));
}
protected void assertContents(File file, int val) throws IOException, CoreException {
@@ -181,68 +73,40 @@
}
protected void assertContents(File file, String val) throws IOException, CoreException
{
- String contents = getContents(file);
- assertEquals(val, contents);
+ assertEquals(val, IOUtil.getContents(file));
}
- 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));
+ server = ServerRuntimeUtils.addModule(server,mod);
+ ServerRuntimeUtils.publish(server);
+ IPath deployRoot = new Path(ServerRuntimeUtils.getDeployRoot(server));
IPath rootFolder = deployRoot.append(MODULE_NAME + ".ear");
assertTrue(rootFolder.toFile().exists());
- assertTrue(countFiles(rootFolder.toFile()) == 0);
- assertTrue(countAllResources(rootFolder.toFile()) == 1);
+ assertTrue(IOUtil.countFiles(rootFolder.toFile()) == 0);
+ assertTrue(IOUtil.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);
+ IOUtil.setContents(textFile, 0);
+ assertEquals(IOUtil.countFiles(rootFolder.toFile()), 0);
+ assertTrue(IOUtil.countAllResources(rootFolder.toFile()) == 1);
+ ServerRuntimeUtils.publish(server);
+ assertEquals(IOUtil.countFiles(rootFolder.toFile()), 1);
+ assertTrue(IOUtil.countAllResources(rootFolder.toFile()) == 2);
assertContents(rootFolder.append(TEXT_FILE).toFile(), 0);
- setContents(textFile, 1);
- publish();
+ IOUtil.setContents(textFile, 1);
+ ServerRuntimeUtils.publish(server);
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);
+ assertEquals(IOUtil.countFiles(rootFolder.toFile()), 1);
+ assertTrue(IOUtil.countAllResources(rootFolder.toFile()) == 2);
+ ServerRuntimeUtils.publish(server);
+ assertEquals(IOUtil.countFiles(rootFolder.toFile()), 0);
+ assertTrue(IOUtil.countAllResources(rootFolder.toFile()) == 1);
+ server = ServerRuntimeUtils.removeModule(server, mod);
assertTrue(rootFolder.toFile().exists());
- publish();
+ ServerRuntimeUtils.publish(server);
assertFalse(rootFolder.toFile().exists());
}
}
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/JSTZippedDeploymentTester.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/JSTZippedDeploymentTester.java 2010-11-01
14:08:51 UTC (rev 26161)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/JSTZippedDeploymentTester.java 2010-11-01
14:17:36 UTC (rev 26162)
@@ -2,12 +2,10 @@
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
-import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
-import java.io.InputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
@@ -42,12 +40,12 @@
import org.jboss.ide.eclipse.as.core.util.ServerConverter;
import org.jboss.ide.eclipse.as.test.ASTest;
import org.jboss.ide.eclipse.as.test.publishing.AbstractDeploymentTest;
+import org.jboss.ide.eclipse.as.test.util.IOUtil;
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 JSTZippedDeploymentTester extends TestCase {
@@ -59,7 +57,7 @@
final IPath CONTENT_TEXT_FILE = new Path(CONTENT_DIR).append(TEXT_FILE);
public void setUp() throws Exception {
project = createProject();
- server = createServer();
+ server = ServerRuntimeUtils.createMockDeployOnlyServer();
IServerWorkingCopy wc = server.createWorkingCopy();
ServerAttributeHelper helper = new ServerAttributeHelper(server, wc);
helper.setAttribute(IDeployableServer.ZIP_DEPLOYMENTS_PREF, true);
@@ -70,7 +68,7 @@
ServerRuntimeUtils.deleteAllServers();
ServerRuntimeUtils.deleteAllRuntimes();
ProjectUtility.deleteAllProjects();
- clearStateLocation();
+ ASTest.clearStateLocation();
}
protected IProject createProject() throws Exception {
@@ -86,111 +84,23 @@
p.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
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);
- wc.setLocation(ASTest.getDefault().getStateLocation());
- 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 verifyJSTZippedPublisher(IModule[] module) {
IJBossServerPublisher publisher = ExtensionManager
.getDefault().getPublisher(server, module, "local");
assertTrue(publisher.getClass().getName().contains("WTPZippedPublisher"));
}
- 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);
+ IOUtil.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);
+ assertEquals(val, IOUtil.getContents(file));
}
protected void assertContents(File file, int val) throws IOException, CoreException {
@@ -198,37 +108,9 @@
}
protected void assertContents(File file, String val) throws IOException, CoreException
{
- String contents = getContents(file);
- assertEquals(val, contents);
+ assertEquals(val, IOUtil.getContents(file));
}
-
- 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[] mods = ServerUtil.getModules(project);
IModule mod = null;
@@ -240,55 +122,24 @@
assertNotNull(mod);
IModule[] module = new IModule[] { mod };
verifyJSTZippedPublisher(module);
- addModule(mod);
- publish();
+ server = ServerRuntimeUtils.addModule(server, mod);
+ ServerRuntimeUtils.publish(server);
IPath projLoc = project.getLocation();
System.out.println(projLoc);
- IPath deployRoot = new Path(getDeployRoot(server));
+ IPath deployRoot = new Path(ServerRuntimeUtils.getDeployRoot(server));
IPath zipped = deployRoot.append(MODULE_NAME + ".ear");
assertTrue(zipped.toFile().exists());
assertTrue(zipped.toFile().isFile());
IPath unzip1 = ASTest.getDefault().getStateLocation().append("unzip1");
IPath unzip2 = ASTest.getDefault().getStateLocation().append("unzip2");
- unzipFile(zipped,unzip1);
+ IOUtil.unzipFile(zipped,unzip1);
assertTrue(unzip1.toFile().list().length == 1);
- unzipFile(unzip1.append("mvel2.jar"), unzip2);
+ IOUtil.unzipFile(unzip1.append("mvel2.jar"), unzip2);
assertTrue(unzip2.toFile().list().length > 1);
System.out.println("end");
- removeModule(mod);
- publish();
+ server = ServerRuntimeUtils.removeModule(server, mod);
+ ServerRuntimeUtils.publish(server);
assertFalse(zipped.toFile().exists());
}
-
-
- public static void unzipFile(IPath zipped, IPath toLoc) {
- toLoc.toFile().mkdirs();
- final int BUFFER = 2048;
- try {
- BufferedOutputStream dest = null;
- FileInputStream fis = new
- FileInputStream(zipped.toFile());
- ZipInputStream zis = new ZipInputStream(new BufferedInputStream(fis));
- ZipEntry entry;
- while((entry = zis.getNextEntry()) != null) {
- int count;
- byte data[] = new byte[BUFFER];
- // write the files to the disk
- toLoc.append(entry.getName()).toFile().getParentFile().mkdirs();
- if( !toLoc.append(entry.getName()).toFile().exists()) {
- FileOutputStream fos = new
FileOutputStream(toLoc.append(entry.getName()).toOSString());
- dest = new BufferedOutputStream(fos, BUFFER);
- while ((count = zis.read(data, 0, BUFFER)) != -1) {
- dest.write(data, 0, count);
- }
- dest.flush();
- dest.close();
- }
- }
- zis.close();
- } catch(Exception e) {
- e.printStackTrace();
- }
- }
}
Modified:
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 2010-11-01
14:08:51 UTC (rev 26161)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/SingleFileDeploymentTester.java 2010-11-01
14:17:36 UTC (rev 26162)
@@ -1,61 +1,174 @@
package org.jboss.ide.eclipse.as.test.publishing.v2;
+import java.io.File;
import java.io.IOException;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
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;
+import org.jboss.ide.eclipse.as.test.ASTest;
+import org.jboss.ide.eclipse.as.test.util.IOUtil;
+import org.jboss.ide.eclipse.as.test.util.ServerRuntimeUtils;
public class SingleFileDeploymentTester extends JSTDeploymentTester {
- public void testMain() throws CoreException, IOException {
- IFile file = createXMLFile();
+ public void testSingleFile() throws CoreException, IOException {
+ final String filename = "test.xml";
+ IResource file = createFile(filename, "<test>done</test>");
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));
+ verifyPublisher(mods[0], SingleFilePublisher.class);
+ server = ServerRuntimeUtils.addModule(server, mods[0]);
+ IPath deployRoot = new Path(ServerRuntimeUtils.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);
+ assertEquals(IOUtil.countFiles(deployRoot.toFile()), 0);
+ assertEquals(IOUtil.countAllResources(deployRoot.toFile()), 1);
+ ServerRuntimeUtils.publish(server);
+ assertEquals(IOUtil.countFiles(deployRoot.toFile()), 1);
+ assertEquals(IOUtil.countAllResources(deployRoot.toFile()), 2);
assertContents(deployRoot.append("test.xml").toFile(),
"<test>done</test>");
- setContents(file, "<test>done2</test>");
+ IOUtil.setContents(project.getFile(filename),
"<test>done2</test>");
assertContents(deployRoot.append("test.xml").toFile(),
"<test>done</test>");
- publish();
+ ServerRuntimeUtils.publish(server);
assertContents(deployRoot.append("test.xml").toFile(),
"<test>done2</test>");
- removeModule(mods[0]);
+ server = ServerRuntimeUtils.removeModule(server, mods[0]);
assertContents(deployRoot.append("test.xml").toFile(),
"<test>done2</test>");
- assertEquals(countAllResources(deployRoot.toFile()), 2);
- publish();
+ assertEquals(IOUtil.countAllResources(deployRoot.toFile()), 2);
+ ServerRuntimeUtils.publish(server);
assertFalse(deployRoot.append("test.xml").toFile().exists());
- assertEquals(countAllResources(deployRoot.toFile()), 1);
+ assertEquals(IOUtil.countAllResources(deployRoot.toFile()), 1);
}
- protected void verifyPublisher(IModule module) {
+ protected void verifyPublisher(IModule module, Class c) {
IModule[] mod = new IModule[] { module };
IJBossServerPublisher publisher = ExtensionManager
.getDefault().getPublisher(server, mod, "local");
- assertTrue(publisher instanceof SingleFilePublisher);
+ assertTrue(publisher.getClass().equals(c));
}
- protected IFile createXMLFile() throws CoreException, IOException {
- IFile xmlFile = project.getFile("test.xml");
- setContents(xmlFile, "<test>done</test>");
- return xmlFile;
+ protected IFile createFile(String filename, String contents) throws CoreException,
IOException {
+ IFile resource = project.getFile(filename);
+ IOUtil.setContents(resource, contents);
+ return resource;
}
+
+ public void testSingleFolder() throws CoreException, IOException {
+ final String folderName = "test";
+ IFolder folder = project.getFolder(folderName);
+ folder.create(true, true, new NullProgressMonitor());
+ IOUtil.setContents(folder.getFile("1.txt"), "1");
+ IOUtil.setContents(folder.getFile("2.txt"), "2");
+ IOUtil.setContents(folder.getFile("3.txt"), "3");
+ IModule[] mods = SingleDeployableFactory.getFactory().getModules();
+ assertEquals(mods.length, 0);
+ SingleDeployableFactory.makeDeployable(folder);
+ mods = SingleDeployableFactory.getFactory().getModules();
+ assertEquals(mods.length, 1);
+ verifyPublisher(mods[0], SingleFilePublisher.class);
+ server = ServerRuntimeUtils.addModule(server, mods[0]);
+ IPath deployRoot = new Path(ServerRuntimeUtils.getDeployRoot(server));
+ deployRoot.toFile().mkdirs();
+ assertEquals(IOUtil.countFiles(deployRoot.toFile()), 0);
+ assertEquals(IOUtil.countAllResources(deployRoot.toFile()), 1);
+ ServerRuntimeUtils.publish(server);
+ assertEquals(IOUtil.countFiles(deployRoot.toFile()), 3);
+ assertEquals(IOUtil.countAllResources(deployRoot.toFile()), 4);
+ File folder2 = deployRoot.toFile().listFiles()[0];
+ assertTrue(folder2.getName().equals(folderName));
+ File[] folderChildren = folder2.listFiles();
+ assertTrue(folderChildren.length == 3);
+ File three = new File(folder2, "3.txt");
+ assertEquals(IOUtil.getContents(three), "3");
+ IOUtil.setContents(folder.getFile("3.txt"), "3a");
+ ServerRuntimeUtils.publish(server);
+ assertEquals(IOUtil.countFiles(deployRoot.toFile()), 3);
+ assertEquals(IOUtil.countAllResources(deployRoot.toFile()), 4);
+ folder2 = deployRoot.toFile().listFiles()[0];
+ assertTrue(folder2.getName().equals(folderName));
+ folderChildren = folder2.listFiles();
+ assertTrue(folderChildren.length == 3);
+ three = new File(folder2, "3.txt");
+ assertEquals(IOUtil.getContents(three), "3a");
+ }
+
+ public void testSingleFileZipped() throws CoreException, IOException {
+ server = ServerRuntimeUtils.setZipped(server, true);
+ try {
+ testSingleFile();
+ } finally {
+ server = ServerRuntimeUtils.setZipped(server, false);
+ }
+ }
+
+ public void testSingleFolderZipped() throws CoreException, IOException {
+ server = ServerRuntimeUtils.setZipped(server, true);
+ try {
+ singleFolderZippedInternal2();
+ } finally {
+ server = ServerRuntimeUtils.setZipped(server, false);
+ }
+ }
+
+ public void singleFolderZippedInternal2() throws CoreException, IOException {
+ // create proj and files
+ final String folderName = "test";
+ IFolder folder = project.getFolder(folderName);
+ folder.create(true, true, new NullProgressMonitor());
+ IOUtil.setContents(folder.getFile("1.txt"), "1");
+ IOUtil.setContents(folder.getFile("2.txt"), "2");
+ IOUtil.setContents(folder.getFile("3.txt"), "3");
+ IModule[] mods = SingleDeployableFactory.getFactory().getModules();
+ assertEquals(mods.length, 0);
+
+ // make deployable, do checks
+ SingleDeployableFactory.makeDeployable(folder);
+ mods = SingleDeployableFactory.getFactory().getModules();
+ assertEquals(mods.length, 1);
+ server = ServerRuntimeUtils.addModule(server, mods[0]);
+ IPath deployRoot = new Path(ServerRuntimeUtils.getDeployRoot(server));
+ deployRoot.toFile().mkdirs();
+ assertEquals(IOUtil.countFiles(deployRoot.toFile()), 0);
+ assertEquals(IOUtil.countAllResources(deployRoot.toFile()), 1);
+
+ // publish and verify deployment
+ ServerRuntimeUtils.publish(server);
+ assertEquals(IOUtil.countFiles(deployRoot.toFile()), 1);
+ assertEquals(IOUtil.countAllResources(deployRoot.toFile()), 2);
+
+ // unzip, verify 3.txt
+ IPath unzip1 = ASTest.getDefault().getStateLocation().append("unzip1");
+ IOUtil.unzipFile(deployRoot.append(folderName),unzip1);
+ assertEquals(IOUtil.countFiles(unzip1.toFile()), 3);
+ String deploy3txt1 = IOUtil.getContents(unzip1.append("3.txt").toFile());
+ assertEquals("3", deploy3txt1);
+
+ // make workspace change, repeat
+ IOUtil.setContents(folder.getFile("3.txt"), "3a");
+ ServerRuntimeUtils.publish(server);
+ assertEquals(IOUtil.countFiles(deployRoot.toFile()), 1);
+ assertEquals(IOUtil.countAllResources(deployRoot.toFile()), 2);
+
+ // verify new changes
+ IPath unzip2 = ASTest.getDefault().getStateLocation().append("unzip2");
+ IOUtil.unzipFile(deployRoot.append(folderName),unzip2);
+ assertEquals(IOUtil.countFiles(unzip2.toFile()), 3);
+ String deploy3txt2 = IOUtil.getContents(unzip2.append("3.txt").toFile());
+ assertEquals("3a", deploy3txt2);
+
+ }
}
Added:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/IOUtil.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/IOUtil.java
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/IOUtil.java 2010-11-01
14:17:36 UTC (rev 26162)
@@ -0,0 +1,107 @@
+package org.jboss.ide.eclipse.as.test.util;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.jboss.tools.test.util.JobUtils;
+
+public class IOUtil {
+ public static String getContents(IFile file) throws IOException, CoreException {
+ return getContents(file.getLocation().toFile());
+ }
+
+ public static String getContents(File aFile) throws IOException {
+ return new String(getBytesFromFile(aFile));
+ }
+
+ 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;
+ }
+
+ public static void setContents(IFile file, int val) throws IOException , CoreException{
+ setContents(file, "" + val);
+ }
+
+ public static 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();
+ }
+
+ public static 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 static 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;
+ }
+
+ public static void unzipFile(IPath zipped, IPath toLoc) {
+ toLoc.toFile().mkdirs();
+ final int BUFFER = 2048;
+ try {
+ BufferedOutputStream dest = null;
+ FileInputStream fis = new
+ FileInputStream(zipped.toFile());
+ ZipInputStream zis = new ZipInputStream(new BufferedInputStream(fis));
+ ZipEntry entry;
+ while((entry = zis.getNextEntry()) != null) {
+ int count;
+ byte data[] = new byte[BUFFER];
+ // write the files to the disk
+ toLoc.append(entry.getName()).toFile().getParentFile().mkdirs();
+ if( !toLoc.append(entry.getName()).toFile().exists()) {
+ FileOutputStream fos = new
FileOutputStream(toLoc.append(entry.getName()).toOSString());
+ dest = new BufferedOutputStream(fos, BUFFER);
+ while ((count = zis.read(data, 0, BUFFER)) != -1) {
+ dest.write(data, 0, count);
+ }
+ dest.flush();
+ dest.close();
+ }
+ }
+ zis.close();
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+}
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/ServerRuntimeUtils.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/ServerRuntimeUtils.java 2010-11-01
14:08:51 UTC (rev 26161)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/ServerRuntimeUtils.java 2010-11-01
14:17:36 UTC (rev 26162)
@@ -17,6 +17,7 @@
import org.eclipse.core.runtime.Status;
import org.eclipse.jdt.launching.IVMInstall;
import org.eclipse.jdt.launching.JavaRuntime;
+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;
@@ -26,9 +27,14 @@
import org.eclipse.wst.server.core.ServerCore;
import org.eclipse.wst.server.core.ServerUtil;
import org.eclipse.wst.server.core.internal.RuntimeWorkingCopy;
+import org.eclipse.wst.server.core.internal.ServerWorkingCopy;
+import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
import org.jboss.ide.eclipse.as.core.server.IJBossServerRuntime;
+import org.jboss.ide.eclipse.as.core.server.internal.DeployableServer;
+import org.jboss.ide.eclipse.as.core.server.internal.ServerAttributeHelper;
import org.jboss.ide.eclipse.as.core.util.FileUtil;
import org.jboss.ide.eclipse.as.core.util.IJBossToolingConstants;
+import org.jboss.ide.eclipse.as.core.util.ServerConverter;
import org.jboss.ide.eclipse.as.test.ASTest;
import org.jboss.ide.eclipse.as.test.publishing.AbstractDeploymentTest;
import org.osgi.framework.Bundle;
@@ -70,8 +76,35 @@
serverRuntimeMap.put(IJBossToolingConstants.SERVER_AS_60,
IJBossToolingConstants.AS_60);
serverRuntimeMap.put(IJBossToolingConstants.SERVER_EAP_43,
IJBossToolingConstants.EAP_43);
serverRuntimeMap.put(IJBossToolingConstants.SERVER_EAP_50,
IJBossToolingConstants.EAP_50);
-}
+ }
+ public static IServer createMockDeployOnlyServer() throws CoreException {
+ IPath state = ASTest.getDefault().getStateLocation();
+ IPath deploy = state.append("testDeployments").append("deploy");
+ IPath tmpDeploy =
state.append("testDeployments").append("tmpDeploy");
+ return ServerRuntimeUtils.createMockDeployOnlyServer(deploy.toOSString(),
+ tmpDeploy.toOSString());
+ }
+ public static IServer createMockDeployOnlyServer(String deployLocation, String
tempDeployLocation) throws CoreException {
+ return createMockDeployOnlyServer(deployLocation, tempDeployLocation,
"testRuntime", "testServer");
+ }
+ public static IServer createMockDeployOnlyServer(String deployLocation, String
tempDeployLocation,
+ String rtName, String serverName) throws CoreException {
+ IRuntimeType rt =
ServerCore.findRuntimeType("org.jboss.ide.eclipse.as.runtime.stripped");
+ IRuntimeWorkingCopy wc = rt.createRuntime(rtName, null);
+ IRuntime runtime = wc.save(true, null);
+ IServerType st =
ServerCore.findServerType("org.jboss.ide.eclipse.as.systemCopyServer");
+ ServerWorkingCopy swc = (ServerWorkingCopy) st.createServer(serverName, null, null);
+ swc.setServerConfiguration(null);
+ swc.setName(serverName);
+ swc.setRuntime(runtime);
+ swc.setAttribute(DeployableServer.DEPLOY_DIRECTORY, deployLocation);
+ swc.setAttribute(DeployableServer.TEMP_DEPLOY_DIRECTORY, tempDeployLocation);
+ IServer server = swc.save(true, null);
+ return server;
+ }
+
+
public static IServer createMockServerWithRuntime(String serverType, String name, String
config) {
try {
IPath serverDir = createMockServerDirectory(name, twiddleMap.get(serverType),
config);
@@ -176,4 +209,38 @@
String location = url.getFile();
return new File(location);
}
+
+ public static String getDeployRoot(IServer server) {
+ IDeployableServer ds = ServerConverter.getDeployableServer(server);
+ return ds.getDeployFolder();
+ }
+
+ public static IServer setServerAttribute(IServer server, String attribute, boolean
value) {
+ ServerAttributeHelper helper =
+ new ServerAttributeHelper(server, server.createWorkingCopy());
+ helper.setAttribute(attribute, value);
+ return helper.save();
+ }
+
+ public static IServer addModule(IServer server, IModule module) throws CoreException {
+ IServerWorkingCopy copy = server.createWorkingCopy();
+ copy.modifyModules(new IModule[]{module}, new IModule[0], new NullProgressMonitor());
+ return copy.save(false, new NullProgressMonitor());
+ }
+
+ public static IServer removeModule(IServer server, IModule module) throws CoreException
{
+ IServerWorkingCopy copy = server.createWorkingCopy();
+ copy.modifyModules(new IModule[]{}, new IModule[] {module}, new
NullProgressMonitor());
+ return copy.save(false, new NullProgressMonitor());
+ }
+
+ public static IStatus publish(IServer server) throws CoreException {
+ return server.publish(IServer.PUBLISH_INCREMENTAL, new NullProgressMonitor());
+ }
+
+ public static IServer setZipped(IServer server, boolean val) {
+ return ServerRuntimeUtils.setServerAttribute(server,
IDeployableServer.ZIP_DEPLOYMENTS_PREF, val);
+ }
+
+
}