[jbosstools-commits] JBoss Tools SVN: r35326 - in trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test: wtp and 1 other directory.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Tue Oct 4 10:29:08 EDT 2011


Author: jjankovi
Date: 2011-10-04 10:29:08 -0400 (Tue, 04 Oct 2011)
New Revision: 35326

Modified:
   trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/eap/EAPCompAllTests.java
   trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/eap/EAPFromWSDLTest.java
   trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/wtp/WSTestBase.java
Log:
Workaround for Web Service Client app

Modified: trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/eap/EAPCompAllTests.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/eap/EAPCompAllTests.java	2011-10-04 13:40:42 UTC (rev 35325)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/eap/EAPCompAllTests.java	2011-10-04 14:29:08 UTC (rev 35326)
@@ -17,11 +17,11 @@
 /**
  * Documentation/description is available at <a href="https://docspace.corp.redhat.com/docs/DOC-43675">Docspace</a>}
  * 
- * @author jlukas
+ * @author jlukas, jjankovi
  * @see <a href="https://docspace.corp.redhat.com/docs/DOC-43675">DOC-43675</a>
  */
 @SuiteClasses({
-    EAPFromJavaTest.class,
+	EAPFromJavaTest.class,
     EAPFromWSDLTest.class
 })
 @RunWith(RequirementAwareSuite.class)

Modified: trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/eap/EAPFromWSDLTest.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/eap/EAPFromWSDLTest.java	2011-10-04 13:40:42 UTC (rev 35325)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/eap/EAPFromWSDLTest.java	2011-10-04 14:29:08 UTC (rev 35326)
@@ -21,10 +21,19 @@
 import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
+import org.eclipse.swtbot.swt.finder.results.Result;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
 import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
+import org.jboss.tools.ui.bot.ext.SWTBotExt;
+import org.jboss.tools.ui.bot.ext.SWTUtilExt;
+import org.jboss.tools.ui.bot.ext.Timing;
 import org.jboss.tools.ui.bot.ext.config.Annotations.Require;
 import org.jboss.tools.ui.bot.ext.config.Annotations.Server;
 import org.jboss.tools.ui.bot.ext.config.Annotations.ServerType;
+import org.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
 import org.jboss.tools.ws.ui.bot.test.uiutils.wizards.WsWizardBase.Slider_Level;
 import org.jboss.tools.ws.ui.bot.test.wtp.TopDownWSTest;
 import org.jboss.tools.ws.ui.bot.test.wtp.WSTestBase;
@@ -36,144 +45,222 @@
 import org.junit.runner.RunWith;
 import org.junit.runners.Suite.SuiteClasses;
 
- at Require(server=
- at Server(type = ServerType.EAP), perspective = "Java EE")
+ at Require(server = @Server(type = ServerType.EAP), perspective = "Java EE")
 @RunWith(RequirementAwareSuite.class)
- at SuiteClasses({ EAPCompAllTests.class})
+ at SuiteClasses({ EAPCompAllTests.class })
 public class EAPFromWSDLTest extends WSTestBase {
 
-    private static final Logger L = Logger.getLogger(EAPFromWSDLTest.class.getName());
-    private static boolean servicePassed = false;
+	private static final Logger L = Logger.getLogger(EAPFromWSDLTest.class
+			.getName());
+	private static boolean servicePassed = false;
 
-    public EAPFromWSDLTest() {
-    }
+	public EAPFromWSDLTest() {
+	}
 
-    @Before
-    @Override
-    public void setup() {
-        if (!projectExists(getWsProjectName())) {
-            createProject(getWsProjectName());
-        }
-        if (!projectExists(getWsClientProjectName())) {
-            createProject(getWsClientProjectName());
-        }
-    }
+	@Before
+	@Override
+	public void setup() {
+		if (!projectExists(getWsProjectName())) {
+			createProject(getWsProjectName());
+		}
+		if (!projectExists(getWsClientProjectName())) {
+			createProject(getWsClientProjectName());
+		}
+	}
 
-    @After
-    @Override
-    public void cleanup() {
-        L.info("overridden");
-    }
+	@After
+	@Override
+	public void cleanup() {
+		L.info("overridden");
+	}
 
-    @AfterClass
-    public static void x() {
-        L.info("x");
-        servers.removeAllProjectsFromServer();
-    }
+	@AfterClass
+	public static void x() {
+		L.info("x");
+		servers.removeAllProjectsFromServer();
+	}
 
-    @Override
-    protected String getWsProjectName() {
-        return "AreaWSProject";
-    }
+	@Override
+	protected String getWsProjectName() {
+		return "AreaWSProject";
+	}
 
-    @Override
-    protected String getEarProjectName() {
-        return getWsProjectName() + "EAR";
-    }
+	@Override
+	protected String getEarProjectName() {
+		return getWsProjectName() + "EAR";
+	}
 
-    protected String getWsClientProjectName() {
-        return "AreaWSClientProject";
-    }
+	protected String getWsClientProjectName() {
+		return "AreaWSClientProject";
+	}
 
-    protected String getClientEarProjectName() {
-        return getWsClientProjectName() + "EAR";
-    }
+	protected String getClientEarProjectName() {
+		return getWsClientProjectName() + "EAR";
+	}
 
-    @Override
-    protected String getWsPackage() {
-        return "org.jboss.ws";
-    }
+	@Override
+	protected String getWsPackage() {
+		return "org.jboss.ws";
+	}
 
-    @Override
-    protected String getWsName() {
-        return "AreaService";
-    }
+	@Override
+	protected String getWsName() {
+		return "AreaService";
+	}
 
-    @Override
-    protected Slider_Level getLevel() {
-        return Slider_Level.DEPLOY;
-    }
+	@Override
+	protected Slider_Level getLevel() {
+		return Slider_Level.DEPLOY;
+	}
 
-    @Test
-    public void testService() {
-        topDownWS(TopDownWSTest.class.getResourceAsStream("/resources/jbossws/AreaService.wsdl"), getWsPackage());
+	@Test
+	public void testService() {
+		topDownWS(TopDownWSTest.class.getResourceAsStream("/resources/jbossws/AreaService.wsdl"),
+				getWsPackage());
 
-        IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(getWsProjectName());
-        IFile f = project.getFile("src/" + getWsPackage().replace(".", "/") + "/AreaServiceImpl.java");
-        String content = readFile(f);
-        Assert.assertNotNull(content);
-        Assert.assertTrue(content.contains("public class AreaServiceImpl implements AreaService {"));
-        Assert.assertTrue(content.contains("public float calculateRectArea(Dimensions parameters)"));
-        replaceContent(f, "/resources/jbossws/AreaWS.java.ws");
+		IProject project = ResourcesPlugin.getWorkspace().getRoot()
+				.getProject(getWsProjectName());
+		IFile f = project.getFile("src/" + getWsPackage().replace(".", "/")
+				+ "/AreaServiceImpl.java");
+		String content = readFile(f);
+		Assert.assertNotNull(content);
+		Assert.assertTrue(content
+				.contains("public class AreaServiceImpl implements AreaService {"));
+		Assert.assertTrue(content
+				.contains("public float calculateRectArea(Dimensions parameters)"));
+		replaceContent(f, "/resources/jbossws/AreaWS.java.ws");
 
-        f = project.getFile("WebContent/WEB-INF/web.xml");
-        content = readFile(f);
-        Assert.assertNotNull(content);
-        Assert.assertTrue(content.contains("<servlet-class>org.jboss.ws.AreaServiceImpl</servlet-class>"));
-        Assert.assertTrue(content.contains("<url-pattern>/AreaService</url-pattern>"));
-        runProject(getEarProjectName());
-        assertServiceDeployed(getWSDLUrl(), 10000);
-        servicePassed = true;
-    }
+		f = project.getFile("WebContent/WEB-INF/web.xml");
+		content = readFile(f);
+		Assert.assertNotNull(content);
+		Assert.assertTrue(content
+				.contains("<servlet-class>org.jboss.ws.AreaServiceImpl</servlet-class>"));
+		Assert.assertTrue(content
+				.contains("<url-pattern>/AreaService</url-pattern>"));
+		runProject(getEarProjectName());
+		assertServiceDeployed(getWSDLUrl(), 10000);
+		servicePassed = true;
+	}
 
-    @Test
-    public void testClient() {
-        Assert.assertTrue("service must exist", servicePassed);
-        createClient(getWSDLUrl(), getWsClientProjectName(), Slider_Level.DEVELOP, "org.jboss.wsclient");
-        IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject(getWsClientProjectName());
-        String pkg = "org/jboss/wsclient";
-        String cls = "src/" + pkg + "/AreaService.java";
-        Assert.assertTrue(p.getFile(cls).exists());
-        cls = "src/" + pkg + "/clientsample/ClientSample.java";
-        IFile f = p.getFile(cls);
-        Assert.assertTrue(f.exists());
-        replaceContent(f, "/resources/jbossws/clientsample.java.ws");
-        eclipse.runJavaApplication(getWsClientProjectName(), "org.jboss.wsclient.clientsample.ClientSample", null);
-        util.waitForNonIgnoredJobs();
-        bot.sleep(15000);
-        String output = console.getConsoleText();
-        L.info(output);
-        Assert.assertTrue(output.contains("Server said: 37.5"));
-        Assert.assertTrue(output.contains("Server said: 3512.3699"));
-    }
+	@Test
+	public void testClient() {
+		Assert.assertTrue("service must exist", servicePassed);
+		createClient(getWSDLUrl(), getWsClientProjectName(),
+				Slider_Level.DEVELOP, "org.jboss.wsclient");
+		IProject p = ResourcesPlugin.getWorkspace().getRoot()
+				.getProject(getWsClientProjectName());
+		String pkg = "org/jboss/wsclient";
+		String cls = "src/" + pkg + "/AreaService.java";
+		Assert.assertTrue(p.getFile(cls).exists());
+		cls = "src/" + pkg + "/clientsample/ClientSample.java";
+		IFile f = p.getFile(cls);
+		Assert.assertTrue(f.exists());
+		replaceContent(f, "/resources/jbossws/clientsample.java.ws");
 
-    private void replaceContent(IFile f, String content) {
-        try {
-            f.delete(true, new NullProgressMonitor());
-        } catch (CoreException ce) {
-            L.log(Level.WARNING, ce.getMessage(), ce);
-        }
-        InputStream is = null;
-        try {
-            is = EAPFromWSDLTest.class.getResourceAsStream(content);
-            f.create(is, true, new NullProgressMonitor());
-        } catch (CoreException ce) {
-            L.log(Level.WARNING, ce.getMessage(), ce);
-        } finally {
-            if (is != null) {
-                try {
-                    is.close();
-                } catch (IOException ioe) {
-                    //ignore
-                }
-            }
-        }
-        try {
-            ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IWorkspaceRoot.DEPTH_INFINITE, new NullProgressMonitor());
-        } catch (CoreException e) {
-            L.log(Level.WARNING, e.getMessage(), e);
-        }
-        util.waitForNonIgnoredJobs();
-        bot.sleep(1000);
-    }
+		/*
+		 * workaround for https://issues.jboss.org/browse/JBIDE-9817
+		 */
+		projectExplorer.selectProject(getWsClientProjectName());
+		SWTBotTree tree = projectExplorer.bot().tree();
+		SWTBotTreeItem item = tree.getTreeItem(getWsClientProjectName());
+		item.expand();
+		removeRuntimeLibrary(tree, item, bot, util);
+
+		eclipse.runJavaApplication(getWsClientProjectName(),
+				"org.jboss.wsclient.clientsample.ClientSample", null);
+		util.waitForNonIgnoredJobs();
+		bot.sleep(15 * TIME_1S);
+		String output = console.getConsoleText();
+		L.info(output);
+		Assert.assertTrue(output, output.contains("Server said: 37.5"));
+		Assert.assertTrue(output.contains("Server said: 3512.3699"));
+	}
+
+	private void replaceContent(IFile f, String content) {
+		try {
+			f.delete(true, new NullProgressMonitor());
+		} catch (CoreException ce) {
+			L.log(Level.WARNING, ce.getMessage(), ce);
+		}
+		InputStream is = null;
+		try {
+			is = EAPFromWSDLTest.class.getResourceAsStream(content);
+			f.create(is, true, new NullProgressMonitor());
+		} catch (CoreException ce) {
+			L.log(Level.WARNING, ce.getMessage(), ce);
+		} finally {
+			if (is != null) {
+				try {
+					is.close();
+				} catch (IOException ioe) {
+					// ignore
+				}
+			}
+		}
+		try {
+			ResourcesPlugin
+					.getWorkspace()
+					.getRoot()
+					.refreshLocal(IWorkspaceRoot.DEPTH_INFINITE,
+							new NullProgressMonitor());
+		} catch (CoreException e) {
+			L.log(Level.WARNING, e.getMessage(), e);
+		}
+		util.waitForNonIgnoredJobs();
+		bot.sleep(TIME_1S);
+	}
+
+	private void removeRuntimeLibrary(final SWTBotTree tree,
+			SWTBotTreeItem item, SWTBotExt bot, SWTUtilExt util) {
+		nodeContextMenu(tree, item, "Build Path", "Configure Build Path...")
+				.click();
+		bot.activeShell().activate();
+		bot.tabItem("Libraries").activate();
+		assertTrue(!bot.button("Remove").isEnabled());
+		try {
+			findSelectEnterpriseRuntimeLibrary(bot);
+			assertTrue(bot.button("Remove").isEnabled());
+			bot.button("Remove").click();
+			bot.button("OK").click();
+			bot.sleep(Timing.time2S());
+			util.waitForNonIgnoredJobs();
+		} catch (Exception e) {
+			e.printStackTrace();
+			bot.button("Cancel").click();
+		}
+
+	}
+
+	private void findSelectEnterpriseRuntimeLibrary(SWTBotExt bot)
+			throws Exception {
+		SWTBotTree libraryTree = bot.tree(1);
+		boolean libraryFound = false;
+		for (SWTBotTreeItem libraryItem : libraryTree.getAllItems()) {
+			if (libraryItem.getText().contains(
+					"JBoss Enterprise Application Platform")) {
+				libraryTree.select(libraryItem);
+				libraryFound = true;
+				break;
+			}
+		}
+		if (!libraryFound)
+			throw new Exception("No runtime library has been found");
+	}
+
+	private SWTBotMenu nodeContextMenu(final SWTBotTree tree,
+			SWTBotTreeItem item, final String... menu) {
+		assert menu.length > 0;
+		ContextMenuHelper.prepareTreeItemForContextMenu(tree, item);
+		return UIThreadRunnable.syncExec(new Result<SWTBotMenu>() {
+
+			public SWTBotMenu run() {
+				SWTBotMenu m = new SWTBotMenu(ContextMenuHelper.getContextMenu(
+						tree, menu[0], false));
+				for (int i = 1; i < menu.length; i++) {
+					m = m.menu(menu[i]);
+				}
+				return m;
+			}
+		});
+	}
 }

Modified: trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/wtp/WSTestBase.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/wtp/WSTestBase.java	2011-10-04 13:40:42 UTC (rev 35325)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/wtp/WSTestBase.java	2011-10-04 14:29:08 UTC (rev 35326)
@@ -192,7 +192,7 @@
 		}
 		wsw.finish();
 		util.waitForNonIgnoredJobs();
-		bot.sleep(1000);
+		bot.sleep(2*TIME_1S);
 
 		// let's fail if there's some error in the wizard,
 		// and close error dialog and the wizard so other tests



More information about the jbosstools-commits mailing list