[jbosstools-commits] JBoss Tools SVN: r42798 - in trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test: publishing and 2 other directories.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Tue Jul 31 00:47:45 EDT 2012


Author: rob.stryker at jboss.com
Date: 2012-07-31 00:47:44 -0400 (Tue, 31 Jul 2012)
New Revision: 42798

Modified:
   trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/defects/WebDeployableArtifactUtilDefectTest.java
   trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/DeployAndTempDeployFolderTest.java
   trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/AbstractJSTDeploymentTester.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/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/util/ServerRuntimeUtils.java
Log:
JBIDE-12363 fixing old test suite

Modified: trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/defects/WebDeployableArtifactUtilDefectTest.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/defects/WebDeployableArtifactUtilDefectTest.java	2012-07-31 01:21:40 UTC (rev 42797)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/defects/WebDeployableArtifactUtilDefectTest.java	2012-07-31 04:47:44 UTC (rev 42798)
@@ -29,8 +29,12 @@
 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 WebDeployableArtifactUtilDefectTest extends TestCase {
+	public void setUp() {
+		JobUtils.waitForIdle(2000);
+	}
 	public void tearDown() throws Exception {
 		ServerRuntimeUtils.deleteAllServers();
 		ServerRuntimeUtils.deleteAllRuntimes();
@@ -56,6 +60,7 @@
 	}
 	
 	public void testWebDeployableDefect() throws Exception {
+		JobUtils.waitForIdle();
 		IFile f = createProjectAndGetJavaIFile();
 		IModuleArtifact artifact = new WebDeployableArtifactUtil().getModuleObject(f);
 		if( artifact == null )

Modified: trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/DeployAndTempDeployFolderTest.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/DeployAndTempDeployFolderTest.java	2012-07-31 01:21:40 UTC (rev 42797)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/DeployAndTempDeployFolderTest.java	2012-07-31 04:47:44 UTC (rev 42798)
@@ -46,8 +46,8 @@
 		wc.setAttribute(IDeployableServer.DEPLOY_DIRECTORY_TYPE, IDeployableServer.DEPLOY_CUSTOM);
 		s = wc.save(true, null);
 		IDeployableServer ds = ServerConverter.getDeployableServer(s);
-		assertTrue("/home/test1".equals(ds.getDeployFolder()));
-		assertTrue("/home/test2".equals(ds.getTempDeployFolder()));
+		assertEquals("/home/test1",ds.getDeployFolder());
+		assertEquals("/home/test2",ds.getTempDeployFolder());
 	}
 
 	public void testAS7xCustomRelative() throws CoreException {
@@ -56,8 +56,8 @@
 		wc.setAttribute(IDeployableServer.DEPLOY_DIRECTORY_TYPE, IDeployableServer.DEPLOY_CUSTOM);
 		s = wc.save(true, null);
 		IDeployableServer ds = ServerConverter.getDeployableServer(s);
-		assertTrue("/rtHome/home/test1".equals(ds.getDeployFolder()));
-		assertTrue("/rtHome/home/test2".equals(ds.getTempDeployFolder()));
+		assertEquals("/rtHome/home/test1",ds.getDeployFolder());
+		assertEquals("/rtHome/home/test2",ds.getTempDeployFolder());
 	}
 
 	

Modified: trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/AbstractJSTDeploymentTester.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/AbstractJSTDeploymentTester.java	2012-07-31 01:21:40 UTC (rev 42797)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/AbstractJSTDeploymentTester.java	2012-07-31 04:47:44 UTC (rev 42798)
@@ -31,6 +31,7 @@
 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 AbstractJSTDeploymentTester extends TestCase {
 	protected IProject project;
@@ -40,6 +41,7 @@
 	private final String TEXT_FILE = "test.txt";
 	private final IPath CONTENT_TEXT_FILE = new Path(CONTENT_DIR).append(TEXT_FILE);
 	public void setUp() throws Exception {
+		JobUtils.waitForIdle();
 		project = createProject();
 		server = ServerRuntimeUtils.createMockDeployOnlyServer();
 	}

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	2012-07-31 01:21:40 UTC (rev 42797)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/JSTDeploymentTester.java	2012-07-31 04:47:44 UTC (rev 42798)
@@ -18,12 +18,31 @@
 import org.eclipse.core.runtime.Path;
 import org.eclipse.wst.server.core.IModule;
 import org.eclipse.wst.server.core.ServerUtil;
+import org.eclipse.wst.server.core.internal.ServerPlugin;
+import org.eclipse.wst.server.core.internal.ServerPreferences;
+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.ProjectUtility;
+import org.jboss.ide.eclipse.as.ui.editor.ServerPasswordSection;
+import org.jboss.tools.test.util.JobUtils;
 
 public class JSTDeploymentTester extends AbstractJSTDeploymentTester {
+	protected String getModuleName() {
+		return "JSTDeploymentTester5";
+	}
+	private boolean initial;
+	public void setUp() throws Exception {
+		super.setUp();
+		initial = ServerPreferences.getInstance().isAutoPublishing();
+		ServerPreferences.getInstance().setAutoPublishing(false);
+	}
+	public void tearDown() throws Exception {
+		super.tearDown();
+		ServerPreferences.getInstance().setAutoPublishing(initial);
+	}
+
 	
-	
 	public void testMain() throws CoreException, IOException {
 		IModule mod = ServerUtil.getModule(project);
 		IModule[] module = new IModule[] { mod };
@@ -31,6 +50,7 @@
 		server = ServerRuntimeUtils.addModule(server,mod);
 		ServerRuntimeUtils.publish(server);
 		IPath deployRoot = new Path(ServerRuntimeUtils.getDeployRoot(server));
+		System.out.println(deployRoot.toOSString());
 		IPath rootFolder = deployRoot.append(getModuleName() + ".ear");
 		assertTrue(rootFolder.toFile().exists());
 		assertTrue(IOUtil.countFiles(rootFolder.toFile()) == 0);

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	2012-07-31 01:21:40 UTC (rev 42797)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/MockJSTPublisherTest.java	2012-07-31 04:47:44 UTC (rev 42798)
@@ -16,19 +16,46 @@
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServerWorkingCopy;
 import org.eclipse.wst.server.core.ServerUtil;
+import org.eclipse.wst.server.core.internal.Server;
 import org.eclipse.wst.server.core.internal.ServerPreferences;
 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 MockJSTPublisherTest extends AbstractJSTDeploymentTester {
+	private boolean initialAutopublishVal;
 	public void setUp() throws Exception {
+		super.setUp();
+		initialAutopublishVal = ServerPreferences.getInstance().isAutoPublishing();
+		ServerPreferences.getInstance().setAutoPublishing(false);
 	}
+	public void tearDown() throws Exception {
+		super.tearDown();
+		ServerPreferences.getInstance().setAutoPublishing(initialAutopublishVal);
+	}
 
+	private static int INDEX = 1;
+	private String MY_NAME = null;
+	protected String getModuleName() {
+		if( MY_NAME == null ) {
+			MY_NAME = "MockJSTPublisherTestModule" + INDEX;
+			INDEX++;
+		}
+		return MY_NAME;
+	}
+
+	
 	public void testNormalLogic() throws CoreException, IOException, Exception {
 		server = ServerRuntimeUtils.createMockDeployOnlyServer();
 		server = ServerRuntimeUtils.useMockPublishMethod(server);
+		IServerWorkingCopy wc = server.createWorkingCopy();
+		wc.setAttribute(Server.PROP_AUTO_PUBLISH_SETTING, Server.AUTO_PUBLISH_DISABLE);
+		server = wc.save(true, null);
+		JobUtils.waitForIdle(1000);
 		project = createProject();
+		JobUtils.waitForIdle(1000);
 		MockPublishMethod.reset();
 		theTest(false);
 	}
@@ -48,13 +75,13 @@
 		ServerRuntimeUtils.publish(server);
 		assertChanged(
 				isAs7, 
-				new String[] { "newModule.ear", "newModule.ear/META-INF/application.xml" }, 
-				new String[] { "newModule.ear", "newModule.ear/META-INF/application.xml", "newModule.ear.dodeploy" });
+				new String[] { MY_NAME + ".ear", MY_NAME + ".ear/META-INF/application.xml" }, 
+				new String[] { MY_NAME + ".ear", MY_NAME + ".ear/META-INF/application.xml", MY_NAME + ".ear.dodeploy" });
 		assertRemoved(
 				isAs7, 
-				new String[] { "newModule.ear" }, 
+				new String[] { MY_NAME + ".ear" }, 
 				// jst publisher always removes the prior deployed artifact since we could have switched from zipped to exploded
-				new String[] { "newModule.ear", "newModule.ear.failed" }); 
+				new String[] { MY_NAME + ".ear", MY_NAME + ".ear.failed" }); 
 		MockPublishMethod.reset();
 
 		IFile textFile = project.getFile(getContentTextFilePath());
@@ -63,43 +90,44 @@
 		ServerRuntimeUtils.publish(server);
 		assertChanged(
 				isAs7,
-				new String[] { "newModule.ear", "newModule.ear/test.txt" }, 
-				new String[] { "newModule.ear", "newModule.ear/test.txt" });
+				new String[] { MY_NAME + ".ear", MY_NAME + ".ear/test.txt" }, 
+				new String[] { MY_NAME + ".ear", MY_NAME + ".ear/test.txt" });
 		assertRemoved(
 				isAs7,
-				new String[] {}, new String[] { "newModule.ear.failed" });
+				new String[] {}, new String[] { MY_NAME + ".ear.failed" });
 		MockPublishMethod.reset();
 		IOUtil.setContents(textFile, 1);
 		ServerRuntimeUtils.publish(server);
 		assertChanged(
 				isAs7,
-				new String[] { "newModule.ear", "newModule.ear/test.txt" }, 
-				new String[] { "newModule.ear", "newModule.ear/test.txt" });
+				new String[] { MY_NAME + ".ear", MY_NAME + ".ear/test.txt" }, 
+				new String[] { MY_NAME + ".ear", MY_NAME + ".ear/test.txt" });
 		assertRemoved(
 				isAs7,
 				new String[] {}, 
-				new String[] { "newModule.ear.failed" });
+				new String[] { MY_NAME + ".ear.failed" });
 		MockPublishMethod.reset();
 		textFile.delete(true, null);
 		ServerRuntimeUtils.publish(server);
 		assertRemoved(
 				isAs7,
-				new String[] { "newModule.ear/test.txt" }, 
-				new String[] { "newModule.ear.failed", "newModule.ear/test.txt" });
+				new String[] { MY_NAME + ".ear/test.txt" }, 
+				new String[] { MY_NAME + ".ear.failed", MY_NAME + ".ear/test.txt" });
 		assertChanged(
 				isAs7,
 				new String[] {}, 
 				new String[] {});
 		MockPublishMethod.reset();
 
+		IModule[] all = server.getModules();
 		server = ServerRuntimeUtils.removeModule(server, mod);
 		assertEquals(0, MockPublishMethod.getRemoved().length);
 
 		ServerRuntimeUtils.publish(server);
 		assertRemoved(
 				isAs7,
-				new String[] { "newModule.ear" }, 
-				new String[] { "newModule.ear", "newModule.ear.deployed", "newModule.ear.failed" });
+				new String[] { MY_NAME + ".ear" }, 
+				new String[] { MY_NAME + ".ear", MY_NAME + ".ear.deployed", MY_NAME + ".ear.failed" });
 	}
 	
 	protected void assertRemoved(boolean isAs7, String[] nonAs7, String[] as7) {

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	2012-07-31 01:21:40 UTC (rev 42797)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/publishing/v2/MockPublishMethod.java	2012-07-31 04:47:44 UTC (rev 42798)
@@ -34,7 +34,6 @@
 	public static ArrayList<IPath> tempFiles = new ArrayList<IPath>();
 	public static ArrayList<IModuleFile> copiedFiles = new ArrayList<IModuleFile>();
 	
-	
 	protected static String expectedRoot = MOCK_ROOT;
 	protected static String expectedTempRoot = MOCK_TEMP_ROOT;
 	

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	2012-07-31 01:21:40 UTC (rev 42797)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/util/ServerRuntimeUtils.java	2012-07-31 04:47:44 UTC (rev 42798)
@@ -55,6 +55,7 @@
 import org.jboss.ide.eclipse.as.core.util.ServerUtil;
 import org.jboss.ide.eclipse.as.test.ASTest;
 import org.jboss.ide.eclipse.as.test.publishing.AbstractDeploymentTest;
+import org.jboss.tools.test.util.JobUtils;
 import org.osgi.framework.Bundle;
 
 public class ServerRuntimeUtils extends TestCase {
@@ -351,7 +352,9 @@
 	}
 
 	public static IStatus publish(int type, IServer server) throws CoreException {
-		return server.publish(type, new NullProgressMonitor());
+		IStatus s = server.publish(type, new NullProgressMonitor());
+		JobUtils.waitForIdle(1000);
+		return s;
 	}
 	
 	public static IServer setZipped(IServer server, boolean val) {



More information about the jbosstools-commits mailing list