[jbosstools-commits] JBoss Tools SVN: r30771 - in trunk/as: plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core and 8 other directories.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Thu Apr 21 21:49:28 EDT 2011
Author: rob.stryker at jboss.com
Date: 2011-04-21 21:49:27 -0400 (Thu, 21 Apr 2011)
New Revision: 30771
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.core/jbosscore/org/jboss/ide/eclipse/as/core/ExtensionManager.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/AbstractJSTPublisher.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/SingleFilePublisher.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7JSTPublisher.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7Server.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/RSEZippedJSTPublisher.java
trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/src/org/jboss/ide/eclipse/as/archives/integration/test/SingleFileZippedDeploymentIntegrationTest.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/publishing/v2/JSTDeployBinaryChildModuleTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/JSTDeploymentWarUpdateXML.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/MockJSTPublisherTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/MockPublishMethod.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:
AS7 Publishing plus unit tests
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-04-21 23:19:58 UTC (rev 30770)
+++ trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/WTPZippedPublisher.java 2011-04-22 01:49:27 UTC (rev 30771)
@@ -41,8 +41,7 @@
IModule lastMod = (module == null || module.length == 0 ) ? null : module[module.length -1];
if( getPublishMethod().equals(method) && lastMod == null)
return true;
- return getPublishMethod().equals(method)
- && ModuleCoreNature.isFlexibleProject(lastMod.getProject())
+ return ModuleCoreNature.isFlexibleProject(lastMod.getProject())
&& ds != null && ds.zipsWTPDeployments();
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/ExtensionManager.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/ExtensionManager.java 2011-04-21 23:19:58 UTC (rev 30770)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/ExtensionManager.java 2011-04-22 01:49:27 UTC (rev 30771)
@@ -221,6 +221,9 @@
}
return publisher;
}
+ public String toString() {
+ return element.getAttribute("class"); //$NON-NLS-1$
+ }
}
private ServerPublishMethodType[] publishMethodTypes;
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/AbstractJSTPublisher.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/AbstractJSTPublisher.java 2011-04-21 23:19:58 UTC (rev 30770)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/AbstractJSTPublisher.java 2011-04-22 01:49:27 UTC (rev 30771)
@@ -34,6 +34,7 @@
if( module == null || (publishMethodSpecific() && !method.equals(getTargetedPublishMethodId())))
return false;
IDeployableServer ds = ServerConverter.getDeployableServer(server);
+ boolean b = ds.zipsWTPDeployments();
return ds != null
&& ModuleCoreNature.isFlexibleProject(module[0].getProject())
&& !ds.zipsWTPDeployments();
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/SingleFilePublisher.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/SingleFilePublisher.java 2011-04-21 23:19:58 UTC (rev 30770)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/SingleFilePublisher.java 2011-04-22 01:49:27 UTC (rev 30771)
@@ -19,7 +19,7 @@
import org.jboss.ide.eclipse.as.core.util.ServerConverter;
import org.jboss.ide.eclipse.as.wtp.core.modules.IJBTModule;
-public class SingleFilePublisher extends AbstractJSTPublisher {
+public class SingleFilePublisher extends JBoss7JSTPublisher {
protected boolean forceZipModule(IModule[] moduleTree) {
return false;
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7JSTPublisher.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7JSTPublisher.java 2011-04-21 23:19:58 UTC (rev 30770)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7JSTPublisher.java 2011-04-22 01:49:27 UTC (rev 30771)
@@ -63,13 +63,20 @@
// jboss-7 specific
IDeployableServer ds = ServerConverter.getDeployableServer(server);
if( publishType == IJBossServerPublisher.REMOVE_PUBLISH) {
- JBoss7JSTPublisher.removeDeployedMarkerFile(method, ds, module, monitor);
+ if( JBoss7Server.supportsJBoss7MarkerDeployment(server) )
+ JBoss7JSTPublisher.removeDeployedMarkerFile(method, ds, module, monitor);
+ else
+ super.publishModule(method, server, module, publishType, delta, monitor);
} else {
IStatus s = super.publishModule(method, server, module, publishType, delta, monitor);
- if( publishType == IJBossServerPublisher.FULL_PUBLISH && module.length == 1) {
- // Only mark a doDeploy file for the root module, but this must be delayed,
- // becuase we don't know how many children modules will get published here (SUCK)
- JBoss7JSTPublisher.markDeployed(method, ds, module, monitor);
+ if( JBoss7Server.supportsJBoss7MarkerDeployment(server) ) {
+ if( module.length == 1 &&
+ publishType == IJBossServerPublisher.FULL_PUBLISH ||
+ publishType == IJBossServerPublisher.INCREMENTAL_PUBLISH) {
+ // Only mark a doDeploy file for the root module, but this must be delayed,
+ // becuase we don't know how many children modules will get published here (SUCK)
+ JBoss7JSTPublisher.markDeployed(method, ds, module, monitor);
+ }
}
return s;
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7Server.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7Server.java 2011-04-21 23:19:58 UTC (rev 30770)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7Server.java 2011-04-22 01:49:27 UTC (rev 30771)
@@ -33,7 +33,6 @@
return getDeployFolder(this, type);
}
-
public static boolean supportsJBoss7MarkerDeployment(IServer server) {
if( server.loadAdapter(IJBoss7Deployment.class, new NullProgressMonitor()) != null )
return true;
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-04-21 23:19:58 UTC (rev 30770)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/RSEPublishMethod.java 2011-04-22 01:49:27 UTC (rev 30771)
@@ -57,7 +57,9 @@
this.behaviour = behaviour;
loadRemoteDeploymentDetails();
ensureConnection(monitor);
- if( getServer().getServerState() == IServer.STATE_STARTED ) {
+
+ JBossServerBehavior b = (JBossServerBehavior) behaviour.getServer().loadAdapter(JBossServerBehavior.class, new NullProgressMonitor());
+ if( b != null && getServer().getServerState() == IServer.STATE_STARTED ) {
stopDeploymentScanner();
}
super.publishStart(behaviour, monitor);
@@ -65,7 +67,8 @@
public int publishFinish(DeployableServerBehavior behaviour,
IProgressMonitor monitor) throws CoreException {
- if( getServer().getServerState() == IServer.STATE_STARTED ) {
+ JBossServerBehavior b = (JBossServerBehavior) behaviour.getServer().loadAdapter(JBossServerBehavior.class, new NullProgressMonitor());
+ if( b != null && getServer().getServerState() == IServer.STATE_STARTED ) {
startDeploymentScanner();
}
return super.publishFinish(behaviour, monitor);
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-04-21 23:19:58 UTC (rev 30770)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.rse.core/src/org/jboss/ide/eclipse/as/rse/core/archives/RSEZippedJSTPublisher.java 2011-04-22 01:49:27 UTC (rev 30771)
@@ -109,7 +109,7 @@
if( !result.isOK() ) {
monitor.done();
} else {
- result = remoteFullPublish(sourcePath, destFolder, name,
+ result = remoteFullPublish(sourcePath, destFolder.removeLastSegments(1), name,
AbstractServerToolsPublisher.getSubMon(monitor, 150));
}
}
@@ -163,7 +163,8 @@
private IStatus removeRemoteDeploymentFolder(IPath sourcePath,
IPath destFolder, String name, IProgressMonitor monitor) throws SystemMessageException, CoreException {
// Now delete the file from RSE
- method.getCallbackHandler(destFolder, server).deleteResource(new Path(name), monitor);
+ // TODO *** FIX THIS IT IS NOT LOGGING ERRORS
+ IStatus[] tmp = method.getCallbackHandler(destFolder, server).deleteResource(new Path(name), monitor);
return Status.OK_STATUS;
}
}
Modified: trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/src/org/jboss/ide/eclipse/as/archives/integration/test/SingleFileZippedDeploymentIntegrationTest.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/src/org/jboss/ide/eclipse/as/archives/integration/test/SingleFileZippedDeploymentIntegrationTest.java 2011-04-21 23:19:58 UTC (rev 30770)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.archives.integration.test/src/org/jboss/ide/eclipse/as/archives/integration/test/SingleFileZippedDeploymentIntegrationTest.java 2011-04-22 01:49:27 UTC (rev 30771)
@@ -15,11 +15,13 @@
import org.jboss.ide.eclipse.as.core.modules.SingleDeployableFactory;
import org.jboss.ide.eclipse.as.core.server.IJBossServerPublisher;
import org.jboss.ide.eclipse.as.test.ASTest;
-import org.jboss.ide.eclipse.as.test.publishing.v2.SingleFileDeploymentTester;
+import org.jboss.ide.eclipse.as.test.publishing.v2.JSTDeploymentTester;
+import org.jboss.ide.eclipse.as.test.publishing.v2.MockPublishMethod;
import org.jboss.ide.eclipse.as.test.util.IOUtil;
import org.jboss.ide.eclipse.as.test.util.ServerRuntimeUtils;
+import org.jboss.tools.test.util.JobUtils;
-public class SingleFileZippedDeploymentIntegrationTest extends SingleFileDeploymentTester {
+public class SingleFileZippedDeploymentIntegrationTest extends JSTDeploymentTester {
public void testSingleFolderZipped() throws CoreException, IOException {
server = ServerRuntimeUtils.setZipped(server, true);
try {
@@ -28,20 +30,69 @@
server = ServerRuntimeUtils.setZipped(server, false);
}
}
- public void singleFolderZippedInternal2() throws CoreException, IOException {
- // create proj and files
+
+ public void testSingleFolderZippedForAS7() throws CoreException, IOException {
+ server = ServerRuntimeUtils.createMockJBoss7Server();
+ server = ServerRuntimeUtils.useMockPublishMethod(server);
+ server = ServerRuntimeUtils.setZipped(server, true);
+
final String folderName = "test";
IFolder folder = project.getFolder(folderName);
+ createFolder(folder);
+
+ SingleDeployableFactory.makeDeployable(folder);
+ IModule[] mods = SingleDeployableFactory.getFactory().getModules();
+ assertEquals(mods.length, 1);
+ server = ServerRuntimeUtils.addModule(server, mods[0]);
+ ServerRuntimeUtils.publish(server);
+ int ch = MockPublishMethod.getChanged().length;
+ int rm = MockPublishMethod.getRemoved().length;
+ assertEquals(2,ch);
+ assertEquals(1,rm);
+ MockPublishMethod.reset();
+
+ // make workspace change, repeat
+ IOUtil.setContents(folder.getFile("3.txt"), "3a");
+ ServerRuntimeUtils.publish(server);
+ JobUtils.waitForIdle();
+ Object o1 = MockPublishMethod.getChanged();
+ Object o2 = MockPublishMethod.getRemoved();
+
+ ch = MockPublishMethod.getChanged().length;
+ rm = MockPublishMethod.getRemoved().length;
+ assertEquals(2,ch);
+ assertEquals(1,rm);
+ MockPublishMethod.reset();
+
+ server = ServerRuntimeUtils.removeModule(server, mods[0]);
+ ServerRuntimeUtils.publish(server);
+ JobUtils.waitForIdle();
+ ch = MockPublishMethod.getChanged().length;
+ rm = MockPublishMethod.getRemoved().length;
+ assertEquals(0,ch);
+ assertEquals(1,rm);
+ MockPublishMethod.reset();
+ }
+
+
+ private void createFolder(IFolder folder) throws CoreException, IOException {
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);
+ }
+
+ public void singleFolderZippedInternal2() throws CoreException, IOException {
+ // create proj and files
+ final String folderName = "test";
+ IFolder folder = project.getFolder(folderName);
+ createFolder(folder);
// make deployable, do checks
SingleDeployableFactory.makeDeployable(folder);
- mods = SingleDeployableFactory.getFactory().getModules();
+ IModule[] mods = SingleDeployableFactory.getFactory().getModules();
assertEquals(mods.length, 1);
server = ServerRuntimeUtils.addModule(server, mods[0]);
IPath deployRoot = new Path(ServerRuntimeUtils.getDeployRoot(server));
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 2011-04-21 23:19:58 UTC (rev 30770)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/ASTestSuite.java 2011-04-22 01:49:27 UTC (rev 30771)
@@ -34,7 +34,9 @@
import org.jboss.ide.eclipse.as.test.publishing.JBIDE4184Test;
import org.jboss.ide.eclipse.as.test.publishing.v2.JSTDeployBinaryChildModuleTest;
import org.jboss.ide.eclipse.as.test.publishing.v2.JSTDeploymentTester;
+import org.jboss.ide.eclipse.as.test.publishing.v2.JSTDeploymentWarUpdateXML;
import org.jboss.ide.eclipse.as.test.publishing.v2.MockDeploymentBehaviour;
+import org.jboss.ide.eclipse.as.test.publishing.v2.MockJSTPublisherTest;
import org.jboss.ide.eclipse.as.test.publishing.v2.SingleFileDeploymentTester;
import org.jboss.ide.eclipse.as.test.server.JBossServerAPITest;
@@ -55,6 +57,8 @@
suite.addTestSuite(SingleFileDeploymentTester.class);
suite.addTestSuite(JBossServerAPITest.class);
suite.addTestSuite(MockDeploymentBehaviour.class);
+ suite.addTestSuite(JSTDeploymentWarUpdateXML.class);
+ suite.addTestSuite(MockJSTPublisherTest.class);
return suite;
}
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 2011-04-21 23:19:58 UTC (rev 30770)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/JSTDeployBinaryChildModuleTest.java 2011-04-22 01:49:27 UTC (rev 30771)
@@ -50,14 +50,14 @@
public void testStandardBinaryChildDeploymentMockPublishMethod() throws CoreException, IOException {
server = ServerRuntimeUtils.useMockPublishMethod(server);
- MockPublishMethod.HANDLER.reset();
+ MockPublishMethod.reset();
testJBoss7BinaryChildDeployment(8);
}
public void testJBoss7BinaryChildDeployment() throws CoreException, IOException {
server = ServerRuntimeUtils.createMockJBoss7Server();
server = ServerRuntimeUtils.useMockPublishMethod(server);
- MockPublishMethod.HANDLER.reset();
+ MockPublishMethod.reset();
testJBoss7BinaryChildDeployment(9);
}
@@ -66,8 +66,8 @@
IModule[] module = new IModule[] { mod };
server = ServerRuntimeUtils.addModule(server, mod);
ServerRuntimeUtils.publish(server);
- assertEquals(count,MockPublishMethod.HANDLER.getChanged().length);
- MockPublishMethod.HANDLER.reset();
+ assertEquals(count,MockPublishMethod.getChanged().length);
+ MockPublishMethod.reset();
}
}
Modified: trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/JSTDeploymentWarUpdateXML.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/JSTDeploymentWarUpdateXML.java 2011-04-21 23:19:58 UTC (rev 30770)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/JSTDeploymentWarUpdateXML.java 2011-04-22 01:49:27 UTC (rev 30771)
@@ -1,10 +1,7 @@
package org.jboss.ide.eclipse.as.test.publishing.v2;
-import java.io.File;
import java.io.IOException;
-import junit.framework.TestCase;
-
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -15,16 +12,11 @@
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.ServerUtil;
-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.IJBossServerPublisher;
-import org.jboss.ide.eclipse.as.test.ASTest;
-import org.jboss.ide.eclipse.as.test.util.IOUtil;
+import org.jboss.ide.eclipse.as.core.server.internal.v7.JBoss7JSTPublisher;
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;
public class JSTDeploymentWarUpdateXML extends AbstractJSTDeploymentTester {
@@ -74,19 +66,20 @@
public void testWarUpdateMockPublishMethodJBoss7() throws CoreException, IOException {
server = ServerRuntimeUtils.createMockJBoss7Server();
server = ServerRuntimeUtils.useMockPublishMethod(server);
- testMockPublishMethod(8,1,"newModule.war.isdeployed");
+ testMockPublishMethod(8,1,"newModule.war" + JBoss7JSTPublisher.DEPLOYED);
}
private void testMockPublishMethod(int initial, int remove, String removedFile) throws CoreException, IOException {
IModule mod = ServerUtil.getModule(project);
server = ServerRuntimeUtils.addModule(server,mod);
ServerRuntimeUtils.publish(server);
- assertEquals(initial, MockPublishMethod.HANDLER.getChanged().length);
- MockPublishMethod.HANDLER.reset();
+ assertEquals(initial, MockPublishMethod.getChanged().length);
+ MockPublishMethod.reset();
server = ServerRuntimeUtils.removeModule(server, mod);
ServerRuntimeUtils.publish(server);
- assertEquals(remove, MockPublishMethod.HANDLER.getRemoved().length);
- assertEquals(removedFile, MockPublishMethod.HANDLER.getRemoved()[0].toString());
+ assertEquals(remove, MockPublishMethod.getRemoved().length);
+ assertEquals(removedFile, MockPublishMethod.getRemoved()[0].toString());
+ MockPublishMethod.reset();
}
}
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-04-21 23:19:58 UTC (rev 30770)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/JSTZippedDeploymentTester.java 2011-04-22 01:49:27 UTC (rev 30771)
@@ -102,7 +102,8 @@
public void testZippedDeploymentMock() throws CoreException, IOException {
server = ServerRuntimeUtils.useMockPublishMethod(server);
- MockPublishMethod.HANDLER.reset();
+ setZipFlag();
+ MockPublishMethod.reset();
IModule mod = findModule();
testZippedDeploymentMock(mod,1,1);
}
@@ -112,20 +113,25 @@
// a zipped file is done being transfered or not
server = ServerRuntimeUtils.createMockJBoss7Server();
server = ServerRuntimeUtils.useMockPublishMethod(server);
- MockPublishMethod.HANDLER.reset();
+ setZipFlag();
+ MockPublishMethod.reset();
IModule mod = findModule();
- testZippedDeploymentMock(mod,1,1);
+ testZippedDeploymentMock(mod,2,1);
}
private void testZippedDeploymentMock(IModule mod, int pubCount, int removeCount) throws IOException, CoreException {
+ MockPublishMethod.reset();
server = ServerRuntimeUtils.addModule(server, mod);
ServerRuntimeUtils.publish(server);
- int changed = MockPublishMethod.HANDLER.getChanged().length;
- MockPublishMethod.HANDLER.reset();
+ int changed = MockPublishMethod.getChanged().length;
+ int deleted = MockPublishMethod.getRemoved().length;
+ assertEquals(changed, pubCount);
+ MockPublishMethod.reset();
server = ServerRuntimeUtils.removeModule(server, mod);
ServerRuntimeUtils.publish(server);
- changed = MockPublishMethod.HANDLER.getRemoved().length;
- int x = 1;
+ deleted = MockPublishMethod.getRemoved().length;
+ assertEquals(deleted, removeCount);
+ MockPublishMethod.reset();
}
}
Modified: trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/MockJSTPublisherTest.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/MockJSTPublisherTest.java 2011-04-21 23:19:58 UTC (rev 30770)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/MockJSTPublisherTest.java 2011-04-22 01:49:27 UTC (rev 30771)
@@ -6,21 +6,23 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.ServerUtil;
+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.test.util.IOUtil;
import org.jboss.ide.eclipse.as.test.util.ServerRuntimeUtils;
public class MockJSTPublisherTest extends AbstractJSTDeploymentTester {
public void testNormalLogic() throws CoreException, IOException {
server = ServerRuntimeUtils.useMockPublishMethod(server);
- MockPublishMethod.HANDLER.reset();
+ MockPublishMethod.reset();
theTest(2,1, "");
}
public void testForced7Logic() throws CoreException, IOException {
server = ServerRuntimeUtils.createMockJBoss7Server();
server = ServerRuntimeUtils.useMockPublishMethod(server);
- MockPublishMethod.HANDLER.reset();
- theTest(3,1, "newModule.ear.isDeployed");
+ MockPublishMethod.reset();
+ theTest(3,1, "newModule.ear" + JBoss7JSTPublisher.DEPLOYED);
}
private void theTest(int initialPublish, int remove, String relativePath) throws CoreException, IOException {
@@ -30,30 +32,30 @@
server = ServerRuntimeUtils.addModule(server,mod);
ServerRuntimeUtils.publish(server);
// one additional for doDeploy
- assertEquals(initialPublish, MockPublishMethod.HANDLER.getChanged().length);
- MockPublishMethod.HANDLER.reset();
+ assertEquals(initialPublish, MockPublishMethod.getChanged().length);
+ MockPublishMethod.reset();
IFile textFile = project.getFile(CONTENT_TEXT_FILE);
IOUtil.setContents(textFile, 0);
- assertEquals(0, MockPublishMethod.HANDLER.getChanged().length);
+ assertEquals(0, MockPublishMethod.getChanged().length);
ServerRuntimeUtils.publish(server);
- assertEquals(2, MockPublishMethod.HANDLER.getChanged().length);
- MockPublishMethod.HANDLER.reset();
+ assertEquals(2, MockPublishMethod.getChanged().length);
+ MockPublishMethod.reset();
IOUtil.setContents(textFile, 1);
ServerRuntimeUtils.publish(server);
- assertEquals(2, MockPublishMethod.HANDLER.getChanged().length);
- MockPublishMethod.HANDLER.reset();
+ assertEquals(2, MockPublishMethod.getChanged().length);
+ MockPublishMethod.reset();
textFile.delete(true, null);
ServerRuntimeUtils.publish(server);
- assertEquals(1, MockPublishMethod.HANDLER.getRemoved().length);
- MockPublishMethod.HANDLER.reset();
+ assertEquals(1, MockPublishMethod.getRemoved().length);
+ MockPublishMethod.reset();
server = ServerRuntimeUtils.removeModule(server, mod);
- assertEquals(0, MockPublishMethod.HANDLER.getRemoved().length);
+ assertEquals(0, MockPublishMethod.getRemoved().length);
// Still just one delete, but should be the .deployed file
ServerRuntimeUtils.publish(server);
- assertEquals(remove, MockPublishMethod.HANDLER.getRemoved().length);
+ assertEquals(remove, MockPublishMethod.getRemoved().length);
}
}
Modified: trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/MockPublishMethod.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/MockPublishMethod.java 2011-04-21 23:19:58 UTC (rev 30770)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/MockPublishMethod.java 2011-04-22 01:49:27 UTC (rev 30771)
@@ -17,11 +17,12 @@
public class MockPublishMethod extends AbstractPublishMethod {
public static final String PUBLISH_METHOD_ID = "mock";
- public static final MockCopyCallbackHandler HANDLER = new MockCopyCallbackHandler();
-
+ public static ArrayList<IPath> changed = new ArrayList<IPath>();
+ public static ArrayList<IPath> removed = new ArrayList<IPath>();
+
public IPublishCopyCallbackHandler getCallbackHandler(IPath path,
IServer server) {
- return HANDLER;
+ return new MockCopyCallbackHandler(path);
}
public String getPublishDefaultRootFolder(IServer server) {
@@ -31,35 +32,38 @@
public String getPublishMethodId() {
return PUBLISH_METHOD_ID;
}
+ public static void reset() {
+ changed.clear();
+ removed.clear();
+ }
+ public static IPath[] getRemoved() {
+ return (IPath[]) removed.toArray(new IPath[removed.size()]);
+ }
- public static class MockCopyCallbackHandler implements IPublishCopyCallbackHandler {
- public ArrayList<IPath> changed = new ArrayList<IPath>();
- public ArrayList<IPath> removed = new ArrayList<IPath>();
-
- public void reset() {
- changed.clear();
- removed.clear();
+ public static IPath[] getChanged() {
+ return (IPath[]) changed.toArray(new IPath[changed.size()]);
+ }
+
+
+ public class MockCopyCallbackHandler implements IPublishCopyCallbackHandler {
+ private IPath root;
+ public MockCopyCallbackHandler(IPath root) {
+ this.root = root;
}
- public IPath[] getRemoved() {
- return (IPath[]) removed.toArray(new IPath[removed.size()]);
- }
-
- public IPath[] getChanged() {
- return (IPath[]) changed.toArray(new IPath[changed.size()]);
- }
-
public IStatus[] deleteResource(IPath path, IProgressMonitor monitor)
throws CoreException {
- if( !removed.contains(path.makeRelative()))
- removed.add(path.makeRelative());
+ IPath path2 = root.append(path);
+ if( !removed.contains(path2.makeRelative()))
+ removed.add(path2.makeRelative());
return new IStatus[]{};
}
public IStatus[] makeDirectoryIfRequired(IPath dir,
IProgressMonitor monitor) throws CoreException {
- if( !changed.contains(dir.makeRelative()))
- changed.add(dir.makeRelative());
+ IPath path2 = root.append(dir);
+ if( !changed.contains(path2.makeRelative()))
+ changed.add(path2.makeRelative());
return new IStatus[]{};
}
@@ -71,14 +75,16 @@
IProgressMonitor monitor) throws CoreException {
File file = PublishUtil.getFile(mf);
shouldRestartModule |= PublishCopyUtil.checkRestartModule(file);
- if( !changed.contains(path.makeRelative()))
- changed.add(path.makeRelative());
+ IPath path2 = root.append(path);
+ if( !changed.contains(path2.makeRelative()))
+ changed.add(path2.makeRelative());
return new IStatus[]{};
}
public IStatus[] touchResource(IPath path) {
- if( !changed.contains(path.makeRelative()))
- changed.add(path.makeRelative());
+ IPath path2 = root.append(path);
+ if( !changed.contains(path2.makeRelative()))
+ changed.add(path2.makeRelative());
return new IStatus[]{};
}
}
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 2011-04-21 23:19:58 UTC (rev 30770)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/SingleFileDeploymentTester.java 2011-04-22 01:49:27 UTC (rev 30771)
@@ -2,6 +2,7 @@
import java.io.File;
import java.io.IOException;
+import java.util.ArrayList;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
@@ -12,7 +13,6 @@
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.extensions.events.ServerLogger;
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;
@@ -27,6 +27,7 @@
import org.jboss.tools.test.util.JobUtils;
public class SingleFileDeploymentTester extends JSTDeploymentTester {
+
public void testSingleFile() throws CoreException, IOException {
final String filename = "test.xml";
IResource file = createFile(filename, "<test>done</test>");
@@ -64,19 +65,7 @@
assertEquals(IOUtil.countAllResources(deployRoot.toFile()), 1);
}
- protected void verifyPublisher(IModule module, Class c) {
- IModule[] mod = new IModule[] { module };
- IJBossServerPublisher publisher = ExtensionManager
- .getDefault().getPublisher(server, mod, "local");
- assertTrue(publisher.getClass().equals(c));
- }
- 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 {
IPath moduleDeployRoot = new Path(ServerRuntimeUtils.getDeployRoot(server));
final String folderName = "test";
@@ -167,4 +156,112 @@
server = ServerRuntimeUtils.setZipped(server, false);
}
}
+
+
+ public void testSingleFileAS7() throws CoreException, IOException {
+ server = ServerRuntimeUtils.createMockJBoss7Server();
+ server = ServerRuntimeUtils.useMockPublishMethod(server);
+ MockPublishMethod.reset();
+
+ 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], SingleFilePublisher.class);
+ server = ServerRuntimeUtils.addModule(server, mods[0]);
+ ArrayList<IPath> changed2 = MockPublishMethod.changed;
+ ArrayList<IPath> removed2 = MockPublishMethod.removed;
+
+ assertEquals(changed2.size(), 0);
+ assertEquals(removed2.size(), 0);
+ MockPublishMethod.reset();
+ ServerRuntimeUtils.publish(server);
+ JobUtils.waitForIdle();
+ assertEquals(changed2.size(), 2); // Creating blah.jar and blah.jar.dodeploy
+ assertEquals(removed2.size(), 1); // TODO find out why its "removing" the empty string
+ MockPublishMethod.reset();
+
+ IOUtil.setContents(project.getFile(filename), "2");
+ ServerRuntimeUtils.publish(server);
+ JobUtils.waitForIdle();
+ assertEquals(changed2.size(), 2);
+ assertEquals(removed2.size(), 0);
+ MockPublishMethod.reset();
+
+ server = ServerRuntimeUtils.removeModule(server, mods[0]);
+ assertEquals(changed2.size(), 0);
+ assertEquals(removed2.size(), 0);
+ MockPublishMethod.reset();
+
+ ServerRuntimeUtils.publish(server);
+ JobUtils.waitForIdle();
+ assertEquals(changed2.size(), 0);
+ assertEquals(removed2.size(), 1);
+ MockPublishMethod.reset();
+ }
+
+ public void testSingleFolderAS7() throws CoreException, IOException {
+ IPath moduleDeployRoot = new Path(ServerRuntimeUtils.getDeployRoot(server));
+ final String folderName = "test";
+ moduleDeployRoot.toFile().mkdirs();
+ IModule[] mods = singleFolderCreateModules(folderName);
+ singleFolderPublishAndVerifyAS7(moduleDeployRoot, folderName, mods);
+ }
+
+ private void singleFolderPublishAndVerifyAS7(IPath moduleDeployRoot, String folderName, IModule[] mods) throws CoreException, IOException {
+ server = ServerRuntimeUtils.createMockJBoss7Server();
+ server = ServerRuntimeUtils.useMockPublishMethod(server);
+ MockPublishMethod.reset();
+
+ ArrayList<IPath> changed2 = MockPublishMethod.changed;
+ ArrayList<IPath> removed2 = MockPublishMethod.removed;
+ assertEquals(changed2.size(), 0);
+ assertEquals(removed2.size(), 0);
+
+ server = ServerRuntimeUtils.addModule(server, mods[0]);
+ assertEquals(changed2.size(), 0);
+ assertEquals(removed2.size(), 0);
+ ServerRuntimeUtils.publish(server);
+ assertEquals(changed2.size(), 4);
+ assertEquals(removed2.size(), 1);
+ MockPublishMethod.reset();
+
+ IFolder folder = project.getFolder(folderName);
+ IOUtil.setContents(folder.getFile("3.txt"), "3a");
+ ServerRuntimeUtils.publish(server);
+ assertEquals(changed2.size(), 2);
+ assertEquals(removed2.size(), 0);
+ MockPublishMethod.reset();
+
+ server = ServerRuntimeUtils.removeModule(server, mods[0]);
+ assertEquals(changed2.size(), 0);
+ assertEquals(removed2.size(), 0);
+ MockPublishMethod.reset();
+
+ ServerRuntimeUtils.publish(server);
+ JobUtils.waitForIdle();
+ assertEquals(changed2.size(), 0);
+ assertEquals(removed2.size(), 1);
+ MockPublishMethod.reset();
+
+ }
+
+
+ protected void verifyPublisher(IModule module, Class c) {
+ IModule[] mod = new IModule[] { module };
+ IJBossServerPublisher publisher = ExtensionManager
+ .getDefault().getPublisher(server, mod, "local");
+ assertTrue(publisher.getClass().equals(c));
+ }
+
+ protected IFile createFile(String filename, String contents) throws CoreException, IOException {
+ IFile resource = project.getFile(filename);
+ IOUtil.setContents(resource, contents);
+ return resource;
+ }
+
+
}
Modified: trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/ServerRuntimeUtils.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/ServerRuntimeUtils.java 2011-04-21 23:19:58 UTC (rev 30770)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/ServerRuntimeUtils.java 2011-04-22 01:49:27 UTC (rev 30771)
@@ -87,6 +87,7 @@
serverRuntimeMap.put(IJBossToolingConstants.SERVER_AS_50, IJBossToolingConstants.AS_50);
serverRuntimeMap.put(IJBossToolingConstants.SERVER_AS_51, IJBossToolingConstants.AS_51);
serverRuntimeMap.put(IJBossToolingConstants.SERVER_AS_60, IJBossToolingConstants.AS_60);
+ serverRuntimeMap.put(IJBossToolingConstants.SERVER_AS_70, IJBossToolingConstants.AS_70);
serverRuntimeMap.put(IJBossToolingConstants.SERVER_EAP_43, IJBossToolingConstants.EAP_43);
serverRuntimeMap.put(IJBossToolingConstants.SERVER_EAP_50, IJBossToolingConstants.EAP_50);
}
More information about the jbosstools-commits
mailing list