Author: rob.stryker(a)jboss.com
Date: 2010-11-18 04:37:17 -0500 (Thu, 18 Nov 2010)
New Revision: 26700
Added:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/JSTDeploymentWarUpdateXML.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/AbstractServerToolsPublisher.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/ServerRuntimeUtils.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/wtp/ProjectCreationUtil.java
Log:
JBIDE-7626 - fix with test! =D
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/AbstractServerToolsPublisher.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/AbstractServerToolsPublisher.java 2010-11-18
08:02:29 UTC (rev 26699)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/AbstractServerToolsPublisher.java 2010-11-18
09:37:17 UTC (rev 26700)
@@ -171,6 +171,7 @@
if( !forceZip && !isBinaryObject) {
PublishCopyUtil util = new PublishCopyUtil(callback);
list.addAll(Arrays.asList(util.initFullPublish(members,
ProgressMonitorUtil.submon(monitor, 700))));
+ JSTPublisherXMLToucher.getInstance().touch(deployPath, module, callback);
} else if( isBinaryObject )
list.addAll(Arrays.asList(copyBinaryModule(moduleTree,
ProgressMonitorUtil.submon(monitor, 700))));
else {
@@ -182,11 +183,7 @@
File temp = deployRoot.toFile().createTempFile(module.getName(), ".tmp",
deployRoot.toFile()); //$NON-NLS-1$
IPath tempFile = new Path(temp.getAbsolutePath());
list.addAll(Arrays.asList(PublishUtil.packModuleIntoJar(moduleTree[moduleTree.length-1],
tempFile)));
- String device = deployPath.getDevice();
- String root = "/"; //$NON-NLS-1$
- if (device != null) {
- root = device + root;
- }
+ String root = (deployPath.getDevice() == null ? "" :
deployPath.getDevice()) + "/"; //$NON-NLS-1$//$NON-NLS-2$
IPublishCopyCallbackHandler handler = getCallbackHandler(new Path(root));
String parentFolder = deployPath.removeLastSegments(1).toString();
handler.makeDirectoryIfRequired(new Path(parentFolder),
ProgressMonitorUtil.submon(monitor, 200));
Added:
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
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/JSTDeploymentWarUpdateXML.java 2010-11-18
09:37:17 UTC (rev 26700)
@@ -0,0 +1,108 @@
+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;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+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.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.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 TestCase {
+
+ IProject project;
+ IServer server;
+ final String MODULE_NAME = "newModule";
+ final String CONTENT_DIR = "contentDirS";
+ final String TEXT_FILE = "test.txt";
+ final IPath CONTENT_TEXT_FILE = new Path(CONTENT_DIR).append(TEXT_FILE);
+ public void setUp() throws Exception {
+ project = createProject();
+ server = ServerRuntimeUtils.createMockDeployOnlyServer();
+ }
+
+ public void tearDown() throws Exception {
+ ServerRuntimeUtils.deleteAllServers();
+ ServerRuntimeUtils.deleteAllRuntimes();
+ ProjectUtility.deleteAllProjects();
+ ASTest.clearStateLocation();
+ }
+
+ protected IProject createProject() throws Exception {
+ IDataModel dm = ProjectCreationUtil.getWebDataModel(MODULE_NAME, null, null,
CONTENT_DIR, null, JavaEEFacetConstants.WEB_25, true);
+ OperationTestCase.runAndVerify(dm);
+ IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject(MODULE_NAME);
+ assertTrue(p.exists());
+ return p;
+ }
+
+ protected void verifyJSTPublisher(IModule[] module) {
+ IJBossServerPublisher publisher = ExtensionManager
+ .getDefault().getPublisher(server, module, "local");
+ assertTrue(publisher instanceof JstPublisher);
+ }
+
+ 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 {
+ IModule mod = ServerUtil.getModule(project);
+ IModule[] module = new IModule[] { mod };
+ verifyJSTPublisher(module);
+ IFile f =
project.getFolder(CONTENT_DIR).getFolder("WEB-INF").getFile("web.xml");
+
+ 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());
+
+ long workspaceModified =
project.getFolder(CONTENT_DIR).getFolder("WEB-INF").getFile("web.xml").getLocation().toFile().lastModified();
+ long publishedModified =
rootFolder.append("WEB-INF").append("web.xml").toFile().lastModified();
+
+ // FULL PUBLISH and verify web xml's timestamp
+ ServerRuntimeUtils.publish(IServer.PUBLISH_FULL, server);
+ try {
+ Thread.sleep(400);
+ } catch(InterruptedException ie) {}
+
+ long publishedModified2 =
rootFolder.append("WEB-INF").append("web.xml").toFile().lastModified();
+ assertNotSame(publishedModified, publishedModified2);
+
+ server = ServerRuntimeUtils.removeModule(server, mod);
+ assertTrue(rootFolder.toFile().exists());
+ ServerRuntimeUtils.publish(server);
+ assertFalse(rootFolder.toFile().exists());
+ }
+}
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-18
08:02:29 UTC (rev 26699)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/ServerRuntimeUtils.java 2010-11-18
09:37:17 UTC (rev 26700)
@@ -235,8 +235,12 @@
}
public static IStatus publish(IServer server) throws CoreException {
- return server.publish(IServer.PUBLISH_INCREMENTAL, new NullProgressMonitor());
+ return publish(IServer.PUBLISH_INCREMENTAL, server);
}
+
+ public static IStatus publish(int type, IServer server) throws CoreException {
+ return server.publish(type, new NullProgressMonitor());
+ }
public static IServer setZipped(IServer server, boolean val) {
return ServerRuntimeUtils.setServerAttribute(server,
IDeployableServer.ZIP_DEPLOYMENTS_PREF, val);
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/wtp/ProjectCreationUtil.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/wtp/ProjectCreationUtil.java 2010-11-18
08:02:29 UTC (rev 26699)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/wtp/ProjectCreationUtil.java 2010-11-18
09:37:17 UTC (rev 26700)
@@ -37,23 +37,23 @@
}
- private static final String APP_CLIENT_PROJ_12 = "myAppClient_12";
- private static final String APP_CLIENT_PROJ_13 = "myAppClient_13";
- private static final String APP_CLIENT_PROJ_14 = "myAppClient_14";
- private static final String APP_CLIENT_PROJ_5 = "myAppClient_5";
+ public static final String APP_CLIENT_PROJ_12 = "myAppClient_12";
+ public static final String APP_CLIENT_PROJ_13 = "myAppClient_13";
+ public static final String APP_CLIENT_PROJ_14 = "myAppClient_14";
+ public static final String APP_CLIENT_PROJ_5 = "myAppClient_5";
- private static final String EJB_PROJ_11 = "myEJB_11";
- private static final String EJB_PROJ_2 = "myEJB_2";
- private static final String EJB_PROJ_21 = "myEJB_21";
- private static final String EJB_PROJ_3 = "myEJB_3";
+ public static final String EJB_PROJ_11 = "myEJB_11";
+ public static final String EJB_PROJ_2 = "myEJB_2";
+ public static final String EJB_PROJ_21 = "myEJB_21";
+ public static final String EJB_PROJ_3 = "myEJB_3";
- private static final String WEB_PROJ_22 = "myWeb_22";
- private static final String WEB_PROJ_23 = "myWeb_23";
- private static final String WEB_PROJ_24 = "myWeb_24";
- private static final String WEB_PROJ_25 = "myWeb_25";
+ public static final String WEB_PROJ_22 = "myWeb_22";
+ public static final String WEB_PROJ_23 = "myWeb_23";
+ public static final String WEB_PROJ_24 = "myWeb_24";
+ public static final String WEB_PROJ_25 = "myWeb_25";
- private static final String CONNECTOR_PROJ_1 = "myConnector_1";
- private static final String CONNECTOR_PROJ_15 = "myConnector_15";
+ public static final String CONNECTOR_PROJ_1 = "myConnector_1";
+ public static final String CONNECTOR_PROJ_15 = "myConnector_15";
/**
* Creates and returns an Connector Data Model with the given name and of the given
version.