Author: rob.stryker(a)jboss.com
Date: 2011-03-22 15:27:14 -0400 (Tue, 22 Mar 2011)
New Revision: 29946
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/WTPZippedPublisher.java
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSEPublishMethod.java
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/archives/RSEZippedFolderPublisher.java
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/archives/RSEZippedJSTPublisher.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/util/IOUtil.java
Log:
JBIDE-7514 jboss 7 support tests and cleanup
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/WTPZippedPublisher.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/WTPZippedPublisher.java 2011-03-22
19:04:23 UTC (rev 29945)
+++
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/WTPZippedPublisher.java 2011-03-22
19:27:14 UTC (rev 29946)
@@ -33,7 +33,10 @@
public class WTPZippedPublisher implements IJBossServerPublisher {
private int moduleState = IServer.PUBLISH_STATE_NONE;
+
public boolean accepts(String method, IServer server, IModule[] module) {
+ if( module == null || (publishMethodSpecific() &&
!method.equals(getTargetedPublishMethodId())))
+ return false;
IDeployableServer ds = ServerConverter.getDeployableServer(server);
IModule lastMod = (module == null || module.length == 0 ) ? null : module[module.length
-1];
if( getPublishMethod().equals(method) && lastMod == null)
@@ -43,6 +46,14 @@
&& ds != null && ds.zipsWTPDeployments();
}
+ protected boolean publishMethodSpecific() {
+ return true;
+ }
+
+ protected String getTargetedPublishMethodId() {
+ return getPublishMethod();
+ }
+
protected String getPublishMethod() {
return LocalPublishMethod.LOCAL_PUBLISH_METHOD;
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSEPublishMethod.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSEPublishMethod.java 2011-03-22
19:04:23 UTC (rev 29945)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSEPublishMethod.java 2011-03-22
19:27:14 UTC (rev 29946)
@@ -25,10 +25,8 @@
import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.services.files.IFileService;
import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystem;
-import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IServer;
import org.jboss.ide.eclipse.as.core.publishers.AbstractPublishMethod;
-import org.jboss.ide.eclipse.as.core.publishers.PublishUtil;
import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
import org.jboss.ide.eclipse.as.core.server.IJBoss6Server;
import org.jboss.ide.eclipse.as.core.server.internal.DeployableServerBehavior;
@@ -182,15 +180,6 @@
return null;
}
- public static IPath findModuleFolderWithDefault(IModule module, IDeployableServer
server, IPath startingPath) {
- IModule[] moduleTree = new IModule[]{module};
- String folder = PublishUtil.getDeployRootFolder(
- moduleTree, server, startingPath.toString(),
- IJBossToolingConstants.LOCAL_DEPLOYMENT_LOC);
- return PublishUtil.getDeployPath(moduleTree, folder).removeLastSegments(1);
- }
-
-
public IPublishCopyCallbackHandler getCallbackHandler(IPath path, IServer server) {
return new RSERemotePublishHandler(path, this);
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/archives/RSEZippedFolderPublisher.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/archives/RSEZippedFolderPublisher.java 2011-03-22
19:04:23 UTC (rev 29945)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/archives/RSEZippedFolderPublisher.java 2011-03-22
19:27:14 UTC (rev 29946)
@@ -16,9 +16,9 @@
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IServer;
import org.jboss.ide.eclipse.as.core.modules.SingleDeployableFactory;
+import org.jboss.ide.eclipse.as.core.publishers.LocalPublishMethod;
import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
import org.jboss.ide.eclipse.as.core.util.ServerConverter;
-import org.jboss.ide.eclipse.as.rse.core.RSEPublishMethod;
import org.jboss.ide.eclipse.as.wtp.core.modules.IJBTModule;
/**
@@ -26,8 +26,8 @@
*/
public class RSEZippedFolderPublisher extends RSEZippedJSTPublisher {
public boolean accepts(String method, IServer server, IModule[] module) {
- if( !RSEPublishMethod.RSE_ID.equals(method))
- return false;
+ if( !LocalPublishMethod.LOCAL_PUBLISH_METHOD.equals(method))
+ return true;
IDeployableServer ds = ServerConverter.getDeployableServer(server);
if( module != null && module.length > 0
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/archives/RSEZippedJSTPublisher.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/archives/RSEZippedJSTPublisher.java 2011-03-22
19:04:23 UTC (rev 29945)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/archives/RSEZippedJSTPublisher.java 2011-03-22
19:27:14 UTC (rev 29946)
@@ -17,15 +17,19 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.rse.services.clientserver.messages.SystemElementNotFoundException;
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.model.IModuleFile;
import org.eclipse.wst.server.core.model.IModuleResourceDelta;
+import org.eclipse.wst.server.core.util.ModuleFile;
import org.jboss.ide.eclipse.archives.webtools.modules.WTPZippedPublisher;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
import org.jboss.ide.eclipse.as.core.publishers.AbstractServerToolsPublisher;
+import org.jboss.ide.eclipse.as.core.publishers.LocalPublishMethod;
import org.jboss.ide.eclipse.as.core.publishers.PublishUtil;
import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
import org.jboss.ide.eclipse.as.core.server.IJBossServerConstants;
@@ -34,7 +38,6 @@
import org.jboss.ide.eclipse.as.core.server.internal.v7.JBoss7JSTPublisher;
import org.jboss.ide.eclipse.as.core.server.internal.v7.JBoss7Server;
import org.jboss.ide.eclipse.as.core.util.ServerConverter;
-import org.jboss.ide.eclipse.as.rse.core.RSEPublishMethod;
/**
* This class is in charge of RSE zipped publishing for flexible projects.
@@ -42,11 +45,16 @@
* by uploading the file after building it in a temporary directory
*/
public class RSEZippedJSTPublisher extends WTPZippedPublisher {
-
- protected String getPublishMethod() {
- return RSEPublishMethod.RSE_ID;
+ public boolean accepts(String method, IServer server, IModule[] module) {
+ if( !LocalPublishMethod.LOCAL_PUBLISH_METHOD.equals(method))
+ return super.accepts(method, server, module);
+ return false;
}
+ protected boolean publishMethodSpecific() {
+ return false; // can publish all method types
+ }
+
/**
* Here we put the deployment first in a temporary remote deploy folder
* Then during the publishModule call, we'll also upload it to remote machine
@@ -86,10 +94,7 @@
IDeployableServer server2 = ServerConverter.getDeployableServer(server);
String remoteTempDeployRoot = getDeployRoot(module,
ServerConverter.getDeployableServer(server));
IPath sourcePath = PublishUtil.getDeployPath(module, remoteTempDeployRoot);
- IModule lastMod = module[module.length-1];
- RSEPublishMethod method2 = (RSEPublishMethod)method;
- IPath destFolder = RSEPublishMethod.findModuleFolderWithDefault(lastMod, server2,
method2.getRemoteRootFolder());
- //IPath tempDestFolder = RSEPublishMethod.findModuleFolderWithDefault(lastMod, server2,
method2.getRemoteTemporaryFolder());
+ IPath destFolder = PublishUtil.getDeployPath(method, module, server2);
String name = sourcePath.lastSegment();
IStatus result = null;
@@ -120,11 +125,14 @@
private IStatus remoteFullPublish(IPath sourcePath,
IPath destFolder, String name, IProgressMonitor monitor) {
// Now transfer the file to RSE
- RSEPublishMethod method2 = (RSEPublishMethod)method;
try {
removeRemoteDeploymentFolder(sourcePath, destFolder, name, new
NullProgressMonitor());
- method2.getFileService().upload(sourcePath.toFile(), destFolder.toString(), name,
true, null, null,
- AbstractServerToolsPublisher.getSubMon(monitor, 150));
+ IModuleFile mf = new ModuleFile(sourcePath.toFile(), name, new Path("/"));
+ method.getCallbackHandler(destFolder, server).copyFile(mf, new Path(name),
+ AbstractServerToolsPublisher.getSubMon(monitor, 150)
+ );
+// method2.getFileService().upload(sourcePath.toFile(), destFolder.toString(), name,
true, null, null,
+// AbstractServerToolsPublisher.getSubMon(monitor, 150));
if( JBoss7Server.supportsJBoss7Deployment(server))
JBoss7JSTPublisher.addDoDeployMarkerFile(method,
ServerConverter.getDeployableServer(server), module, monitor);
} catch( SystemMessageException sme ) {
@@ -154,9 +162,8 @@
private IStatus removeRemoteDeploymentFolder(IPath sourcePath,
IPath destFolder, String name, IProgressMonitor monitor) throws
SystemMessageException, CoreException {
- // Now transfer the file to RSE
- RSEPublishMethod method2 = (RSEPublishMethod)method;
- method2.getFileService().delete(destFolder.toString(), name, monitor);
+ // Now delete the file from RSE
+ method.getCallbackHandler(destFolder, server).deleteResource(new Path(name), monitor);
return Status.OK_STATUS;
}
}
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 2011-03-22
19:04:23 UTC (rev 29945)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/JSTZippedDeploymentTester.java 2011-03-22
19:27:14 UTC (rev 29946)
@@ -1,43 +1,24 @@
package org.jboss.ide.eclipse.as.test.publishing.v2;
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
import java.io.IOException;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipInputStream;
-import junit.framework.TestCase;
-
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.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.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.server.internal.ServerAttributeHelper;
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.publishing.AbstractDeploymentTest;
import org.jboss.ide.eclipse.as.test.util.IOUtil;
@@ -45,32 +26,22 @@
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;
-public class JSTZippedDeploymentTester extends TestCase {
+public class JSTZippedDeploymentTester extends AbstractJSTDeploymentTester {
- 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 = ServerRuntimeUtils.createMockDeployOnlyServer();
+ setZipFlag();
+ }
+
+ private void setZipFlag() throws IOException, CoreException {
IServerWorkingCopy wc = server.createWorkingCopy();
ServerAttributeHelper helper = new ServerAttributeHelper(server, wc);
helper.setAttribute(IDeployableServer.ZIP_DEPLOYMENTS_PREF, true);
server = wc.save(true, new NullProgressMonitor());
}
- public void tearDown() throws Exception {
- ServerRuntimeUtils.deleteAllServers();
- ServerRuntimeUtils.deleteAllRuntimes();
- ProjectUtility.deleteAllProjects();
- ASTest.clearStateLocation();
- }
-
protected IProject createProject() throws Exception {
IDataModel dm = ProjectCreationUtil.getEARDataModel(MODULE_NAME, CONTENT_DIR, null,
null, JavaEEFacetConstants.EAR_5, false);
OperationTestCase.runAndVerify(dm);
@@ -91,27 +62,7 @@
assertTrue(publisher.getClass().getName().contains("WTPZippedPublisher"));
}
- protected void setContents(IFile file, int val) throws IOException , CoreException{
- IOUtil.setContents(file, "" + val);
- }
-
- protected void assertContents(IFile file, int val) throws IOException, CoreException {
- assertContents(file, "" + val);
- }
-
- protected void assertContents(IFile file, String val) throws IOException, CoreException
{
- assertEquals(val, IOUtil.getContents(file));
- }
-
- protected void assertContents(File file, int val) throws IOException, CoreException {
- assertContents(file, "" + val);
- }
-
- protected void assertContents(File file, String val) throws IOException, CoreException
{
- assertEquals(val, IOUtil.getContents(file));
- }
-
- public void testMain() throws CoreException, IOException {
+ private IModule findModule() {
IModule[] mods = ServerUtil.getModules(project);
IModule mod = null;
// find hte right module ugh
@@ -120,6 +71,12 @@
mod = mods[i];
}
assertNotNull(mod);
+ return mod;
+ }
+
+
+ public void testZippedDeploymentLocal() throws CoreException, IOException {
+ IModule mod = findModule();
IModule[] module = new IModule[] { mod };
verifyJSTZippedPublisher(module);
server = ServerRuntimeUtils.addModule(server, mod);
@@ -142,4 +99,33 @@
ServerRuntimeUtils.publish(server);
assertFalse(zipped.toFile().exists());
}
+
+ public void testZippedDeploymentMock() throws CoreException, IOException {
+ server = ServerRuntimeUtils.useMockPublishMethod(server);
+ MockPublishMethod.HANDLER.reset();
+ IModule mod = findModule();
+ testZippedDeploymentMock(mod,1,1);
+ }
+
+ public void testZippedDeploymentMockAS7() throws CoreException, IOException {
+ // Same as without previous AS versions, as the server can tell when
+ // a zipped file is done being transfered or not
+ server = ServerRuntimeUtils.createMockJBoss7Server();
+ server = ServerRuntimeUtils.useMockPublishMethod(server);
+ MockPublishMethod.HANDLER.reset();
+ IModule mod = findModule();
+ testZippedDeploymentMock(mod,1,1);
+ }
+
+ private void testZippedDeploymentMock(IModule mod, int pubCount, int removeCount) throws
IOException, CoreException {
+ server = ServerRuntimeUtils.addModule(server, mod);
+ ServerRuntimeUtils.publish(server);
+ int changed = MockPublishMethod.HANDLER.getChanged().length;
+ MockPublishMethod.HANDLER.reset();
+
+ server = ServerRuntimeUtils.removeModule(server, mod);
+ ServerRuntimeUtils.publish(server);
+ changed = MockPublishMethod.HANDLER.getRemoved().length;
+ int x = 1;
+ }
}
Modified:
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 2011-03-22
19:04:23 UTC (rev 29945)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/IOUtil.java 2011-03-22
19:27:14 UTC (rev 29946)
@@ -87,15 +87,20 @@
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);
+ if( entry.isDirectory() ) {
+ toLoc.append(entry.getName()).toFile().mkdirs();
+ } else {
+ toLoc.append(entry.getName()).toFile().getParentFile().mkdirs();
+ if( !toLoc.append(entry.getName()).toFile().exists()) {
+ String out = toLoc.append(entry.getName()).toOSString();
+ FileOutputStream fos = new FileOutputStream(out);
+ dest = new BufferedOutputStream(fos, BUFFER);
+ while ((count = zis.read(data, 0, BUFFER)) != -1) {
+ dest.write(data, 0, count);
+ }
+ dest.flush();
+ dest.close();
}
- dest.flush();
- dest.close();
}
}
zis.close();