Author: dennyxu
Date: 2010-04-15 00:33:23 -0400 (Thu, 15 Apr 2010)
New Revision: 21485
Added:
workspace/Denny/swtbot_test/org.guvnor.tools.test.swtbot/.classpath
workspace/Denny/swtbot_test/org.guvnor.tools.test.swtbot/.project
workspace/Denny/swtbot_test/org.guvnor.tools.test.swtbot/.settings/
workspace/Denny/swtbot_test/org.guvnor.tools.test.swtbot/.settings/org.eclipse.jdt.core.prefs
workspace/Denny/swtbot_test/org.guvnor.tools.test.swtbot/META-INF/
workspace/Denny/swtbot_test/org.guvnor.tools.test.swtbot/META-INF/MANIFEST.MF
workspace/Denny/swtbot_test/org.guvnor.tools.test.swtbot/build.properties
workspace/Denny/swtbot_test/org.guvnor.tools.test.swtbot/screenshots/
workspace/Denny/swtbot_test/org.guvnor.tools.test.swtbot/src/
workspace/Denny/swtbot_test/org.guvnor.tools.test.swtbot/src/org/
workspace/Denny/swtbot_test/org.guvnor.tools.test.swtbot/src/org/guvnor/
workspace/Denny/swtbot_test/org.guvnor.tools.test.swtbot/src/org/guvnor/tools/
workspace/Denny/swtbot_test/org.guvnor.tools.test.swtbot/src/org/guvnor/tools/test/
workspace/Denny/swtbot_test/org.guvnor.tools.test.swtbot/src/org/guvnor/tools/test/swtbot/
workspace/Denny/swtbot_test/org.guvnor.tools.test.swtbot/src/org/guvnor/tools/test/swtbot/GuvnorSWTBotTest.java
workspace/Denny/swtbot_test/org.guvnor.tools.test.swtbot/src/org/guvnor/tools/test/swtbot/drools-guvnor.war
Log:
Guvnor swtbot tests
Added: workspace/Denny/swtbot_test/org.guvnor.tools.test.swtbot/.classpath
===================================================================
--- workspace/Denny/swtbot_test/org.guvnor.tools.test.swtbot/.classpath
(rev 0)
+++ workspace/Denny/swtbot_test/org.guvnor.tools.test.swtbot/.classpath 2010-04-15
04:33:23 UTC (rev 21485)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: workspace/Denny/swtbot_test/org.guvnor.tools.test.swtbot/.project
===================================================================
--- workspace/Denny/swtbot_test/org.guvnor.tools.test.swtbot/.project
(rev 0)
+++ workspace/Denny/swtbot_test/org.guvnor.tools.test.swtbot/.project 2010-04-15 04:33:23
UTC (rev 21485)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.guvnor.tools.test.swtbot</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added:
workspace/Denny/swtbot_test/org.guvnor.tools.test.swtbot/.settings/org.eclipse.jdt.core.prefs
===================================================================
---
workspace/Denny/swtbot_test/org.guvnor.tools.test.swtbot/.settings/org.eclipse.jdt.core.prefs
(rev 0)
+++
workspace/Denny/swtbot_test/org.guvnor.tools.test.swtbot/.settings/org.eclipse.jdt.core.prefs 2010-04-15
04:33:23 UTC (rev 21485)
@@ -0,0 +1,8 @@
+#Tue Apr 13 21:51:13 CST 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
Added: workspace/Denny/swtbot_test/org.guvnor.tools.test.swtbot/META-INF/MANIFEST.MF
===================================================================
--- workspace/Denny/swtbot_test/org.guvnor.tools.test.swtbot/META-INF/MANIFEST.MF
(rev 0)
+++
workspace/Denny/swtbot_test/org.guvnor.tools.test.swtbot/META-INF/MANIFEST.MF 2010-04-15
04:33:23 UTC (rev 21485)
@@ -0,0 +1,16 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Guvnor SWTBot Test
+Bundle-SymbolicName: org.guvnor.tools.test.swtbot
+Bundle-Version: 1.0.0.qualifier
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.swtbot.eclipse.finder;bundle-version="2.0.0",
+ org.eclipse.swtbot.swt.finder;bundle-version="2.0.0",
+ org.eclipse.swtbot.junit4_x;bundle-version="2.0.0",
+ org.hamcrest;bundle-version="1.1.0",
+ org.apache.commons.collections;bundle-version="3.2.0",
+ org.junit4;bundle-version="4.5.0",
+ org.apache.log4j;bundle-version="1.2.13"
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Added: workspace/Denny/swtbot_test/org.guvnor.tools.test.swtbot/build.properties
===================================================================
--- workspace/Denny/swtbot_test/org.guvnor.tools.test.swtbot/build.properties
(rev 0)
+++ workspace/Denny/swtbot_test/org.guvnor.tools.test.swtbot/build.properties 2010-04-15
04:33:23 UTC (rev 21485)
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
Added:
workspace/Denny/swtbot_test/org.guvnor.tools.test.swtbot/src/org/guvnor/tools/test/swtbot/GuvnorSWTBotTest.java
===================================================================
---
workspace/Denny/swtbot_test/org.guvnor.tools.test.swtbot/src/org/guvnor/tools/test/swtbot/GuvnorSWTBotTest.java
(rev 0)
+++
workspace/Denny/swtbot_test/org.guvnor.tools.test.swtbot/src/org/guvnor/tools/test/swtbot/GuvnorSWTBotTest.java 2010-04-15
04:33:23 UTC (rev 21485)
@@ -0,0 +1,218 @@
+package org.guvnor.tools.test.swtbot;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+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.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+(a)RunWith(SWTBotJunit4ClassRunner.class)
+public class GuvnorSWTBotTest {
+
+ public static final String JBOSS_AS_42_HOME = System.getProperty(
+ "jbosstools.test.jboss.home.4.2",
+ "/home/fugang/jboss-all/jbossesb-server-4.7");
+
+ static String GUVNOR_REPOSITORY =
"/drools-guvnor/org.drools.guvnor.Guvnor/webdav";
+
+ private static SWTWorkbenchBot bot;
+
+
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ bot = new SWTWorkbenchBot();
+ bot.viewByTitle("Welcome").close();
+ bot.perspectiveByLabel("Guvnor Repository Exploring").activate();
+
+ File server = new File(JBOSS_AS_42_HOME);
+ assertTrue("JBOSS_AS_42 HOME is not configured", server.exists());
+
+ deployGuvnorApp();
+ createNewServer();
+
+ }
+
+ @AfterClass
+ public static void after() throws Exception{
+ bot.viewByTitle("Servers").show();
+// bot.shell("Servers").activate();
+
+ bot.tree().select(0).contextMenu("Stop").isEnabled();
+ bot.tree().select(0).contextMenu("Stop").click();
+ String treeItem = "";
+ int i = 0;
+ while(treeItem.indexOf("Stopped") < 0 && i < 30){
+ bot.sleep(2000);
+ bot.viewByTitle("Servers").show();
+ treeItem = bot.tree().getAllItems()[0].getText();
+ i ++;
+ }
+
+ assertTrue("Guvnor server failed to stop",
treeItem.indexOf("Stopped") >= 0);
+
+ //undeploy drools-guvnor.war
+ IPath path = new Path(JBOSS_AS_42_HOME);
+ path =
path.append("server").append("default").append("deploy").append("drools-guvnor.war");
+ File desFile = path.toFile();
+ if(desFile.exists()){
+ desFile.delete();
+ }
+ }
+
+ private static void createNewServer() {
+
+ String serverName = "Guvnor";
+
+ bot.menu("Window").menu("Show
View").menu("Other...").click();
+ SWTBotShell shell = bot.activeShell();
+ shell.activate();
+ bot.text(0).setText("Server");
+ SWTBotTree d = bot.tree();
+ d.expandNode("Server").select("Servers");
+ bot.button("OK").click();
+
+// bot.tree().contextMenu("New").menu("Server").click();
+ bot.menu("File").menu("New").menu("Other...").click();
+ bot.activeShell().activate();
+ bot.text(0).setText("Server");
+ SWTBotTree wizardTree = bot.tree();
+ wizardTree.expandNode("Server").select("Server");
+ bot.button("Next >").click();
+
+// bot.shell("New Server").activate();
+ bot.text(1).setText("JBoss AS 4.2");
+ bot.text(2).setText(serverName);
+ bot.tree().expandNode("JBoss Community").select("JBoss AS 4.2");
+
+ bot.button("Next >").click();
+
+ bot.text(1).setText(JBOSS_AS_42_HOME);
+
+ //
+ bot.button("< Back").click();
+ bot.text(1).setText("JBoss AS 4.2");
+ bot.tree().expandNode("JBoss Community").select("JBoss AS 4.2");
+ bot.button("Next >").click();
+ bot.button("Finish").click();
+
+
+
+
+ bot.viewByTitle("Servers").show();
+// bot.shell("Servers").activate();
+ bot.tree().select(0).contextMenu("Start").click();
+
+ String treeItem = "";
+ int i = 0;
+ while(treeItem.indexOf("Started") < 0 && i < 60){
+ bot.sleep(2000);
+ bot.viewByTitle("Servers").show();
+ treeItem = bot.tree().getAllItems()[0].getText();
+
+// System.out.println(treeItem);
+ i ++;
+ }
+
+ assertTrue("Guvnor server is not started",
treeItem.indexOf("Started") >= 0);
+
+
+
+ }
+
+ private static void deployGuvnorApp(){
+
+ InputStream is =
GuvnorSWTBotTest.class.getResourceAsStream("drools-guvnor.war");
+ if( is != null){
+ IPath path = new Path(JBOSS_AS_42_HOME);
+ path =
path.append("server").append("default").append("deploy").append("drools-guvnor.war");
+ File desFile = path.toFile();
+
+ try {
+ if(!desFile.exists()){
+ boolean isCreated = desFile.createNewFile();
+ assertTrue("Failed to deploy Drools-Guvnor.war ", isCreated);
+ }
+ OutputStream os = new FileOutputStream(path.toFile());
+ byte[] b = new byte[1024 * 5];
+ int len;
+ while ( (len = is.read(b)) != -1) {
+ os.write(b, 0, len);
+ }
+ os.flush();
+ os.close();
+ is.close();
+ } catch (Exception e) {
+ assertTrue("Failed to deploy Drools-Guvnor.war :" + e.getMessage(),
false);
+ e.printStackTrace();
+ }
+ }
+ }
+
+ @Test
+ public void test_JBIDE_6165(){
+ //show Guvnor perspective
+ bot.viewByTitle("Guvnor Repositories").toolbarButton("Add a Guvnor
respository connection").click();
+
+ bot.text(2).setText(GUVNOR_REPOSITORY);
+ bot.text(3).setText("admin");
+ bot.text(4).setText("admin");
+
+ bot.button("Finish").click();
+
+
+ SWTBotView view = bot.viewByTitle("Guvnor Repositories");
+ view.show();
+
+ SWTBotTree tree = bot.tree();
+ for( int i = 0; i < 100; i++){
+ tree = bot.tree(i);
+ if(tree.getAllItems().length > 0){
+ SWTBotTreeItem item = tree.getAllItems()[0];
+ if(item.getText() != null && item.getText().indexOf(GUVNOR_REPOSITORY) >
0){
+ break;
+ }
+ }
+ }
+
+ tree.select(0).contextMenu("Properties").click();
+
+ bot.activeShell().activate();
+ bot.tabItem(1).activate();
+ assertTrue("The 'User' text is not enabled",
bot.text(0).isEnabled());
+
+ String newUserName = "admin_new";
+ String newPwd = "passsword_new";
+ bot.text(0).setText(newUserName);
+ bot.text(1).setText(newPwd);
+
+ bot.button("OK").click();
+
+ //open properties page to verify the previous changes
+
+ tree.select(0).contextMenu("Properties").click();
+ bot.activeShell().activate();
+ bot.tabItem(1).activate();
+ assertEquals("Failed to update User Name", newUserName,
bot.text(0).getText());
+ assertEquals("Failed to update Password", newPwd, bot.text(1).getText());
+
+
+ bot.sleep(10000);
+ }
+
+}
Added:
workspace/Denny/swtbot_test/org.guvnor.tools.test.swtbot/src/org/guvnor/tools/test/swtbot/drools-guvnor.war
===================================================================
(Binary files differ)
Property changes on:
workspace/Denny/swtbot_test/org.guvnor.tools.test.swtbot/src/org/guvnor/tools/test/swtbot/drools-guvnor.war
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Show replies by date