Author: ldimaggio
Date: 2012-03-30 23:33:13 -0400 (Fri, 30 Mar 2012)
New Revision: 39951
Added:
trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/EAPExampleTest.java
trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/SimpleEAPTest.java
Modified:
trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/ESBExampleTest.java
Log:
Checking in (incomplete) test for -
https://issues.jboss.org/browse/JBQA-6077
Added:
trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/EAPExampleTest.java
===================================================================
---
trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/EAPExampleTest.java
(rev 0)
+++
trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/EAPExampleTest.java 2012-03-31
03:33:13 UTC (rev 39951)
@@ -0,0 +1,212 @@
+package org.jboss.tools.esb.ui.bot.tests.examples;
+
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.ui.bot.ext.ExampleTest;
+import org.jboss.tools.ui.bot.ext.SWTEclipseExt;
+import org.jboss.tools.ui.bot.ext.SWTTestExt;
+import org.jboss.tools.ui.bot.ext.Timing;
+import org.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
+import org.jboss.tools.ui.bot.ext.types.IDELabel;
+import org.jboss.tools.ui.bot.ext.view.ProblemsView;
+
+public class EAPExampleTest extends ExampleTest{
+
+
+ /**
+ * returns example project name (as it is imported to workspace)
+ * @return
+ */
+ public String getExampleProjectName() {
+ return getProjectNames()[0];
+ }
+ /**
+ * returns name of example client project (null if none)
+ * @return
+ */
+ public String getExampleClientProjectName() {
+ return getProjectNames()[1];
+ }
+ @Override
+ public String[] getProjectNames() {
+ return new String[2];
+ }
+
+ @Override
+ public String getExampleCategory() {
+ return getRunningSoaVersionTreeLabel();
+ }
+ /**
+ * called after example projects are imported, by default fixes both example project
references and (if defined) client example references
+ */
+ @Override
+ protected void postImport() {
+ fixExampleLibs();
+ if (getExampleClientProjectName()!=null) {
+ fixExampleClientLibs();
+ }
+ //openESBConfig();
+
+ /* Temporary fix to workaround JBDS-2011 */
+ System.out.println ("DEBUG - name = " + getExampleProjectName() );
+ if (!getExampleProjectName().equals("transform_CSV2XML")) {
+ assertProblemsView();
+ }
+ }
+ /**
+ * opens up ESB config file contained in example project in ESB Editor
+ */
+ protected void openESBConfig() {
+ String[] config =
{getExampleProjectName(),"esbcontent","META-INF","jboss-esb.xml"};
+ assertTrue("ESB config file does not
exist",projectExplorer.existsResource(config));
+ SWTBotEditor editor = projectExplorer.openFile(getExampleProjectName(),
"esbcontent","META-INF","jboss-esb.xml");
+ assertNotNull("No editor was opened", editor);
+ assertEquals("Wrong editor was opened", "jboss-esb.xml",
editor.getTitle());
+ editor.close();
+ }
+ /**
+ * executes (deploys) example project
+ */
+ @Override
+ protected void executeExample() {
+ super.executeExample();
+ packageExplorer.runOnServer(getExampleProjectName());
+ util.waitForNonIgnoredJobs();
+ }
+ /**
+ * executes given class in given project (path must include project name)
+ * @param path clientClass as could be seen in package explorer (e.g src,
org.jboss.tools.test.Class.java)
+ * @return string in server log console that was appended or null if nothing appended
+ */
+ protected String executeClientGetServerOutput(String... clientClass) {
+ String text = console.getConsoleText();
+ SWTBotTreeItem jmsCall =
SWTEclipseExt.selectTreeLocation(packageExplorer.show().bot(),clientClass);
+ eclipse.runTreeItemAsJavaApplication(jmsCall);
+ bot.sleep(Timing.time5S());
+ util.waitForNonIgnoredJobs();
+ console.switchConsole(configuredState.getServer().name);
+ //String text2 = console.getConsoleText(TIME_5S, TIME_20S, false);
+ String text2 = console.getConsoleText(TIME_5S, TIME_60S, false); /*
https://issues.jboss.org/browse/JBQA-5838 - ldimaggi */
+ if (text.length()>=text2.length()) {
+ return null;
+ }
+ return text2.substring(text.length());
+ }
+ /**
+ * executes given class in given project (path must include project name)
+ * @param path clientClass as could be seen in package explorer (e.g src,
org.jboss.tools.test.Class.java)
+ * @return string in log console that was appended
+ */
+ protected String executeClient(String... clientClass) {
+ SWTBotTreeItem jmsCall =
SWTEclipseExt.selectTreeLocation(packageExplorer.show().bot(),clientClass);
+ eclipse.runTreeItemAsJavaApplication(jmsCall);
+ bot.sleep(Timing.time5S());
+ String text = console.getConsoleText(TIME_5S, TIME_20S, false);
+ console.switchConsole(configuredState.getServer().name); // switch console back for
sure
+ return text;
+ }
+ /**
+ * executes given class in given project (path must include project name)
+ * @param className full name of class to run
+ * @param arguments arguments that should be passed to classes main method (can be
null)
+ * @return string in server log that was appended or null if nothing appended
+ */
+ protected String executeClientGetServerOutput(String className, String arguments) {
+ String text = console.getConsoleText();
+ eclipse.runJavaApplication(getExampleClientProjectName(), className, arguments);
+ bot.sleep(Timing.time5S());
+ console.switchConsole(configuredState.getServer().name);
+ String text2 = console.getConsoleText(TIME_5S, TIME_20S, false);
+ if (text.length()>=text2.length()) {
+ return null;
+ }
+ return text2.substring(text.length());
+ }
+ protected void fixJREToWorkspaceDefault(String project) {
+ SWTBotTree tree = projectExplorer.show().bot().tree();
+ SWTBotTreeItem proj = tree.select(project).getTreeItem(project);
+ for (SWTBotTreeItem item : proj.getItems()) {
+ if (item.getText().startsWith("JRE System")) {
+ ContextMenuHelper.prepareTreeItemForContextMenu(tree, item);
+ new SWTBotMenu(ContextMenuHelper.getContextMenu(tree, IDELabel.Menu.PROPERTIES,
false)).click();
+ SWTBotShell shell = bot.activeShell();
+ shell.bot().radio(2).click();
+ open.finish(shell.bot(),IDELabel.Button.OK);
+ break;
+ }
+ }
+
+ }
+ protected void fixExampleLibs() {
+ fixLibrary(getExampleProjectName(),"Server Library");
+ fixLibrary(getExampleProjectName(),"JBoss ESB Runtime");
+ util.waitForNonIgnoredJobs();
+ }
+ protected void fixExampleClientLibs() {
+ fixLibrary(getExampleClientProjectName(),"Server Library");
+ fixLibrary(getExampleClientProjectName(),"JBoss ESB Runtime");
+ fixJREToWorkspaceDefault(getExampleClientProjectName());
+ util.waitForNonIgnoredJobs();
+ }
+ protected void assertProblemsView() {
+ //bot.sleep(60000l);
+ SWTBotTreeItem errors = ProblemsView.getErrorsNode(bot);
+
+
+
+ assertNull("Project still contain problems
:"+SWTEclipseExt.getFormattedTreeNode(errors),errors);
+ }
+ protected void fixLibrary(String project, String lib) {
+ SWTBotTree tree = projectExplorer.show().bot().tree();
+ SWTBotTreeItem proj = tree.select(project).getTreeItem(project);
+ proj.expand();
+ boolean fixed=false;
+ boolean found=false;
+ for (SWTBotTreeItem item : proj.getItems()) {
+ if (item.getText().startsWith(lib)) {
+ found = true;
+ ContextMenuHelper.prepareTreeItemForContextMenu(tree, item);
+ new SWTBotMenu(ContextMenuHelper.getContextMenu(tree, IDELabel.Menu.PROPERTIES,
false)).click();
+ SWTBotShell shell = bot.activeShell();
+ shell.bot().table().select(configuredState.getServer().name);
+ open.finish(shell.bot(),IDELabel.Button.OK);
+ fixed=true;
+ break;
+ }
+ }
+ if (!fixed && found) {
+ log.error("Libray starting with '"+lib+"' in project
'"+project+"' was not fixed.");
+ bot.sleep(Long.MAX_VALUE);
+ }
+ if (!found) {
+ log.info("Libray starting with '"+lib+"' in project
'"+project+"' was not found.");
+ }
+ }
+ /**
+ * gets label in project examples tree derived by version of soa we currently run
+ * @return
+ */
+ protected String getRunningSoaVersionTreeLabel() {
+ String ret = "ESB for SOA-P ";
+ if (!configuredState.getServer().isConfigured) {
+ throw new NullPointerException("No server was configured for test, but it is
required");
+ }
+ if (configuredState.getServer().version.startsWith("5.")) {
+ ret+="5.0";
+ }
+ else if (configuredState.getServer().version.equals("4.3")) {
+ ret+="4.3";
+ }
+ else if (configuredState.getServer().version.equals("6.0")) {
+ ret="JBoss Quickstarts";
+ }
+ else {
+ assertNotNull("We are running on unexpected SOA-P version
"+configuredState.getServer().version+" update test source code
"+this.getClass().getName(), null);
+ return null;
+ }
+ return ret;
+ }
+}
Modified:
trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/ESBExampleTest.java
===================================================================
---
trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/ESBExampleTest.java 2012-03-31
01:41:48 UTC (rev 39950)
+++
trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/ESBExampleTest.java 2012-03-31
03:33:13 UTC (rev 39951)
@@ -200,6 +200,9 @@
else if (configuredState.getServer().version.equals("4.3")) {
ret+="4.3";
}
+ else if (configuredState.getServer().version.equals("6.0")) {
+ ret="JBoss Quickstarts";
+ }
else {
assertNotNull("We are running on unexpected SOA-P version
"+configuredState.getServer().version+" update test source code
"+this.getClass().getName(), null);
return null;
Added:
trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/SimpleEAPTest.java
===================================================================
---
trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/SimpleEAPTest.java
(rev 0)
+++
trunk/esb/tests/org.jboss.tools.esb.ui.bot.test/src/org/jboss/tools/esb/ui/bot/tests/examples/SimpleEAPTest.java 2012-03-31
03:33:13 UTC (rev 39951)
@@ -0,0 +1,138 @@
+package org.jboss.tools.esb.ui.bot.tests.examples;
+
+import org.jboss.tools.ui.bot.ext.ExampleTest;
+import org.jboss.tools.ui.bot.ext.SWTEclipseExt;
+import org.jboss.tools.ui.bot.ext.SWTOpenExt;
+import org.jboss.tools.ui.bot.ext.SWTTestExt;
+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.ServerState;
+import org.jboss.tools.ui.bot.ext.config.Annotations.ServerType;
+import org.jboss.tools.ui.bot.ext.gen.ActionItem;
+import org.jboss.tools.ui.bot.ext.gen.ActionItem.NewObject.ESBESBFile;
+
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTableItem;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+
+import org.jboss.tools.ui.bot.ext.gen.ActionItem.NewObject.GeneralFolder;
+import org.jboss.tools.ui.bot.ext.gen.ActionItem.View.ServerServers;
+import org.jboss.tools.ui.bot.ext.view.ProblemsView;
+import org.jboss.tools.ui.bot.ext.view.ServersView;
+
+/*
+ *
+ *
https://community.jboss.org/wiki/SmokeTestJBToolsServerSupport?prevContai...
+ *
+1) Open recent JBoss Tools
+2) open servers view (window -> show view -> other -> Servers)
+3) create new server
+ - type: JBoss Community -> JBoss AS 6.0
+ - use default configuration
+ - finish wizard
+4) double-click server in servers view to open the server editor
+5) in editor, verify all server ports are accurate (JNDI / Web / JMX RMI) (right side of
editor)
+6) click "open launch configuration" in the editor, verify launch configuration
arguments and vm args match with what is expected
+ a) *** If there are any new arguments that have changed since the previous AS version,
MAKE SURE the launch configuration HAS them!
+7) In servers view, expand the server and look at XML Configuration/Ports, verify all
labels have a number next to them
+9) Create a project (seam or dynamic web is fine, seam project is better)
+10) Deploy it to the server, Verify the deployment works
+11) remove deployment, verify console shows deployment removed
+12) Open MBean Viewer,
+ a) note that the server can now be expanded,
+ b) under it are mbeans. browse down to jboss.deployment -> URL
->DeploymentScanner,
+ c) double-click DeploymentScanner, go to "Operations" page, click
"stop" in viewer, click "stop" button on the right,
+ d) verify operation completes successfully
+13) in eclipse, deploy seam application again, verify console shows NO OUTPUT, deployment
does NOT deploy
+14) use mbean viewer / editor to execute start() operation on DeploymentScaner
+15) verify console now accepts deployment
+ */
+
+@Require(server=(a)Server(type=ServerType.EAP,state=ServerState.Running))
+public class SimpleEAPTest extends EAPExampleTest {
+
+ public static String baseDir = "/opt/local/EAP6_ER3";
+
+ @Override
+ public String getExampleName() {
+ return "Helloworld";
+ }
+ @Override
+ public String[] getProjectNames() {
+ return new String[] {"jboss-as-helloworld",
"jboss-as-helloworld"};
+ }
+ @Override
+ protected void executeExample() {
+
+ // 1) Open recent JBoss Tools
+ // 2) open servers view (window -> show view -> other -> Servers)
+ // 3) create new server
+ // - type: JBoss Community -> JBoss AS 6.0
+ // - use default configuration
+ // - finish wizard
+ // 8) Start server, verify when server is up and running, the servers view says
"Started" and not "Starting"
+
+ // 4) double-click server in servers view to open the server editor
+ SWTBotView theSWTBotView = open.viewOpen(ServerServers.LABEL);
+ SWTBotTree serverTree = bot.tree(0);
+ ServersView theServerView = new ServersView();
+ SWTBotTreeItem theServer = theServerView.findServerByName(serverTree,
"EAP-6.0");
+ //System.out.println ("*** the server = " + theServer.getText());
+ assertTrue("Found the EAP 6.0 server - and the name is correct: ",
theServer.getText().equals("EAP-6.0 [Started, Synchronized]"));
+
+ // 5) in editor, verify all server ports are accurate (JNDI / Web / JMX RMI) (right
side of editor)
+ theServer.doubleClick();
+ assertTrue("The web port is 8080 ",
bot.textWithLabel("Web").getText().equals("8080"));
+ assertTrue("The management port is 9999 ",
bot.textWithLabel("Management").getText().equals("9999"));
+
+ //6) click "open launch configuration" in the editor, verify launch
configuration arguments and vm args match with what is expected
+ // a) *** If there are any new arguments that have changed since the previous AS
version, MAKE SURE the launch configuration HAS them!
+ bot.hyperlink("Open launch configuration").click();
+
+ bot.sleep(3000l);
+ //System.out.println (bot.textInGroup("Program &arguments:").getText()
);
+ assertTrue ("The Program arguments match ",
+ bot.textInGroup("Program &arguments:").getText().equals("-mp
\"" + baseDir + "/jboss-eap-6.0/modules\" -jaxpmodule
javax.xml.jaxp-provider " +
+ "org.jboss.as.standalone -b localhost --server-config=standalone.xml "));
+
+ //System.out.println (bot.textInGroup("VM ar&guments:").getText() );
+ // Need to convert these to a hash
+ assertTrue ("The VM arguments match ",
+ bot.textInGroup("VM ar&guments:").getText().equals("-server
-Xms64m -Xmx512m -XX:MaxPermSize=256m " +
+ "-Djava.net.preferIPv4Stack=true " +
+ "-Dorg.jboss.resolver.warning=true " +
+ "-Dsun.rmi.dgc.client.gcInterval=3600000 " +
+ "-Dsun.rmi.dgc.server.gcInterval=3600000 " +
+ "-Djboss.modules.system.pkgs=org.jboss.byteman " +
+ "-Djava.awt.headless=true " +
+ "\"-Dorg.jboss.boot.log.file=" + baseDir +
"/jboss-eap-6.0/standalone/log/boot.log\" " +
+ "\"-Dlogging.configuration=file:" + baseDir +
"/jboss-eap-6.0/standalone/configuration/logging.properties\" " +
+ "\"-Djboss.home.dir=" + baseDir + "/jboss-eap-6.0\"
"));
+
+ //org.jboss.tools.ui.bot.ext.SWTUtilExt.displayAllBotWidgets(bot);
+
+// 7) In servers view, expand the server and look at XML Configuration/Ports, verify all
labels have a number next to them
+// 9) Create a project (seam or dynamic web is fine, seam project is better)
+// 10) Deploy it to the server, Verify the deployment works
+// 11) remove deployment, verify console shows deployment removed
+// 12) Open MBean Viewer,
+// a) note that the server can now be expanded,
+// b) under it are mbeans. browse down to jboss.deployment -> URL
->DeploymentScanner,
+// c) double-click DeploymentScanner, go to "Operations" page, click
"stop" in viewer, click "stop" button on the right,
+// d) verify operation completes successfully
+// 13) in eclipse, deploy seam application again, verify console shows NO OUTPUT,
deployment does NOT deploy
+// 14) use mbean viewer / editor to execute start() operation on DeploymentScaner
+// 15) verify console now accepts deployment
+
+ bot.sleep(60000l);
+ System.out.println("***End");
+
+ SWTTestExt.servers.removeAllProjectsFromServer();
+ // 16) stop server, verify server shuts down properly without error.
+ }
+}