Author: ljelinko
Date: 2012-04-19 07:27:07 -0400 (Thu, 19 Apr 2012)
New Revision: 40334
Added:
trunk/runtime/tests/org.jboss.tools.runtime.as.ui.bot.test/src/org/jboss/tools/runtime/as/ui/bot/test/template/
trunk/runtime/tests/org.jboss.tools.runtime.as.ui.bot.test/src/org/jboss/tools/runtime/as/ui/bot/test/template/DetectServerTemplate.java
trunk/runtime/tests/org.jboss.tools.runtime.as.ui.bot.test/src/org/jboss/tools/runtime/as/ui/bot/test/template/OperateServerTemplate.java
Modified:
trunk/runtime/tests/org.jboss.tools.runtime.as.ui.bot.test/src/org/jboss/tools/runtime/as/ui/bot/test/jboss71/DetectJBoss71.java
trunk/runtime/tests/org.jboss.tools.runtime.as.ui.bot.test/src/org/jboss/tools/runtime/as/ui/bot/test/jboss71/OperateJBoss71.java
Log:
Extracted templates from the JBoss71 tests.
Modified:
trunk/runtime/tests/org.jboss.tools.runtime.as.ui.bot.test/src/org/jboss/tools/runtime/as/ui/bot/test/jboss71/DetectJBoss71.java
===================================================================
---
trunk/runtime/tests/org.jboss.tools.runtime.as.ui.bot.test/src/org/jboss/tools/runtime/as/ui/bot/test/jboss71/DetectJBoss71.java 2012-04-19
11:26:36 UTC (rev 40333)
+++
trunk/runtime/tests/org.jboss.tools.runtime.as.ui.bot.test/src/org/jboss/tools/runtime/as/ui/bot/test/jboss71/DetectJBoss71.java 2012-04-19
11:27:07 UTC (rev 40334)
@@ -1,37 +1,20 @@
package org.jboss.tools.runtime.as.ui.bot.test.jboss71;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-
import org.jboss.tools.runtime.as.ui.bot.test.RuntimeProperties;
-import
org.jboss.tools.runtime.as.ui.bot.test.dialog.preferences.RuntimeDetectionPreferencesDialog;
-import
org.jboss.tools.runtime.as.ui.bot.test.dialog.preferences.SearchingForRuntimesDialog;
import org.jboss.tools.runtime.as.ui.bot.test.entity.Server;
-import org.jboss.tools.runtime.as.ui.bot.test.matcher.ServerMatcher;
-import org.jboss.tools.ui.bot.ext.SWTTestExt;
-import org.junit.After;
-import org.junit.Test;
+import org.jboss.tools.runtime.as.ui.bot.test.template.DetectServerTemplate;
-public class DetectJBoss71 extends SWTTestExt {
+public class DetectJBoss71 extends DetectServerTemplate {
public static final String JBOSS_7_1 = "jboss-as-7.1.0.Final";
- private RuntimeDetectionPreferencesDialog preferences;
-
- private SearchingForRuntimesDialog searchingForRuntimesDialog;
-
- @Test
- public void detectJBoss71(){
- preferences = new RuntimeDetectionPreferencesDialog();
- preferences.open();
- preferences.addPath(RuntimeProperties.getInstance().getRuntimePath(JBOSS_7_1));
- searchingForRuntimesDialog = preferences.search();
-
- assertThat(searchingForRuntimesDialog.getServers().size(), is(1));
- assertThat(searchingForRuntimesDialog.getServers().get(0), new
ServerMatcher(getExpectedServer()));
+ @Override
+ protected String getServerID() {
+ return JBOSS_7_1;
}
- private Server getExpectedServer() {
+ @Override
+ protected Server getExpectedServer() {
Server expectedServer = new Server();
expectedServer.setName(JBOSS_7_1);
expectedServer.setVersion("7.1");
@@ -39,10 +22,4 @@
expectedServer.setLocation(RuntimeProperties.getInstance().getRuntimePath(JBOSS_7_1));
return expectedServer;
}
-
- @After
- public void closePreferences(){
- searchingForRuntimesDialog.ok();
- preferences.ok();
- }
}
Modified:
trunk/runtime/tests/org.jboss.tools.runtime.as.ui.bot.test/src/org/jboss/tools/runtime/as/ui/bot/test/jboss71/OperateJBoss71.java
===================================================================
---
trunk/runtime/tests/org.jboss.tools.runtime.as.ui.bot.test/src/org/jboss/tools/runtime/as/ui/bot/test/jboss71/OperateJBoss71.java 2012-04-19
11:26:36 UTC (rev 40333)
+++
trunk/runtime/tests/org.jboss.tools.runtime.as.ui.bot.test/src/org/jboss/tools/runtime/as/ui/bot/test/jboss71/OperateJBoss71.java 2012-04-19
11:27:07 UTC (rev 40334)
@@ -1,54 +1,11 @@
package org.jboss.tools.runtime.as.ui.bot.test.jboss71;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.not;
+import org.jboss.tools.runtime.as.ui.bot.test.template.OperateServerTemplate;
-import org.jboss.tools.ui.bot.ext.SWTTestExt;
-import org.jboss.tools.ui.bot.ext.matcher.console.ConsoleOutputMatcher;
-import org.jboss.tools.ui.bot.ext.view.ServersView;
-import org.junit.Test;
+public class OperateJBoss71 extends OperateServerTemplate {
-public class OperateJBoss71 extends SWTTestExt {
-
- private ServersView serversView = new ServersView();
-
- @Test
- public void startJBoss71(){
- serversView.startServer(DetectJBoss71.JBOSS_7_1);
-
- assertNoException();
- assertServerState("Started");
+ @Override
+ protected String getServerName() {
+ return DetectJBoss71.JBOSS_7_1;
}
-
- @Test
- public void restartJBoss71(){
- serversView.restartServer(DetectJBoss71.JBOSS_7_1);
-
- assertNoException();
- assertServerState("Started");
- }
-
- @Test
- public void stopJBoss71(){
- serversView.stopServer(DetectJBoss71.JBOSS_7_1);
-
- assertNoException();
- assertServerState("Stopped");
- }
-
- @Test
- public void deleteJBoss71(){
- serversView.deleteServer(DetectJBoss71.JBOSS_7_1);
-
- assertFalse(serversView.serverExists(DetectJBoss71.JBOSS_7_1));
- }
-
- private void assertNoException() {
- assertThat("Exception:", not(new ConsoleOutputMatcher()));
- }
-
- private void assertServerState(String state) {
- assertThat(serversView.getServerStatus(DetectJBoss71.JBOSS_7_1), is(state));
- }
}
Added:
trunk/runtime/tests/org.jboss.tools.runtime.as.ui.bot.test/src/org/jboss/tools/runtime/as/ui/bot/test/template/DetectServerTemplate.java
===================================================================
---
trunk/runtime/tests/org.jboss.tools.runtime.as.ui.bot.test/src/org/jboss/tools/runtime/as/ui/bot/test/template/DetectServerTemplate.java
(rev 0)
+++
trunk/runtime/tests/org.jboss.tools.runtime.as.ui.bot.test/src/org/jboss/tools/runtime/as/ui/bot/test/template/DetectServerTemplate.java 2012-04-19
11:27:07 UTC (rev 40334)
@@ -0,0 +1,48 @@
+package org.jboss.tools.runtime.as.ui.bot.test.template;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+
+import org.jboss.tools.runtime.as.ui.bot.test.RuntimeProperties;
+import
org.jboss.tools.runtime.as.ui.bot.test.dialog.preferences.RuntimeDetectionPreferencesDialog;
+import
org.jboss.tools.runtime.as.ui.bot.test.dialog.preferences.SearchingForRuntimesDialog;
+import org.jboss.tools.runtime.as.ui.bot.test.entity.Server;
+import org.jboss.tools.runtime.as.ui.bot.test.matcher.ServerMatcher;
+import org.jboss.tools.ui.bot.ext.SWTTestExt;
+import org.junit.After;
+import org.junit.Test;
+
+/**
+ * Common scenario for server detection tests. It adds the server's installation
+ * folder to the runtime detection and checks if it is correctly recognized and created.
+ *
+ * @author Lucia Jelinkova
+ *
+ */
+public abstract class DetectServerTemplate extends SWTTestExt {
+
+ private RuntimeDetectionPreferencesDialog preferences;
+
+ private SearchingForRuntimesDialog searchingForRuntimesDialog;
+
+ protected abstract String getServerID();
+
+ protected abstract Server getExpectedServer();
+
+ @Test
+ public void detectJBoss71(){
+ preferences = new RuntimeDetectionPreferencesDialog();
+ preferences.open();
+ preferences.addPath(RuntimeProperties.getInstance().getRuntimePath(getServerID()));
+ searchingForRuntimesDialog = preferences.search();
+
+ assertThat(searchingForRuntimesDialog.getServers().size(), is(1));
+ assertThat(searchingForRuntimesDialog.getServers().get(0), new
ServerMatcher(getExpectedServer()));
+ }
+
+ @After
+ public void closePreferences(){
+ searchingForRuntimesDialog.ok();
+ preferences.ok();
+ }
+}
Added:
trunk/runtime/tests/org.jboss.tools.runtime.as.ui.bot.test/src/org/jboss/tools/runtime/as/ui/bot/test/template/OperateServerTemplate.java
===================================================================
---
trunk/runtime/tests/org.jboss.tools.runtime.as.ui.bot.test/src/org/jboss/tools/runtime/as/ui/bot/test/template/OperateServerTemplate.java
(rev 0)
+++
trunk/runtime/tests/org.jboss.tools.runtime.as.ui.bot.test/src/org/jboss/tools/runtime/as/ui/bot/test/template/OperateServerTemplate.java 2012-04-19
11:27:07 UTC (rev 40334)
@@ -0,0 +1,63 @@
+package org.jboss.tools.runtime.as.ui.bot.test.template;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.not;
+
+import org.jboss.tools.ui.bot.ext.SWTTestExt;
+import org.jboss.tools.ui.bot.ext.matcher.console.ConsoleOutputMatcher;
+import org.jboss.tools.ui.bot.ext.view.ServersView;
+import org.junit.Test;
+
+/**
+ * Checks if the given server can be started, restarted, stopped and deleted without
+ * error.
+ *
+ * @author Lucia Jelinkova
+ *
+ */
+public abstract class OperateServerTemplate extends SWTTestExt{
+
+ private ServersView serversView = new ServersView();
+
+ protected abstract String getServerName();
+
+ @Test
+ public void startJBoss71(){
+ serversView.startServer(getServerName());
+
+ assertNoException();
+ assertServerState("Started");
+ }
+
+ @Test
+ public void restartJBoss71(){
+ serversView.restartServer(getServerName());
+
+ assertNoException();
+ assertServerState("Started");
+ }
+
+ @Test
+ public void stopJBoss71(){
+ serversView.stopServer(getServerName());
+
+ assertNoException();
+ assertServerState("Stopped");
+ }
+
+ @Test
+ public void deleteJBoss71(){
+ serversView.deleteServer(getServerName());
+
+ assertFalse(serversView.serverExists(getServerName()));
+ }
+
+ private void assertNoException() {
+ assertThat("Exception:", not(new ConsoleOutputMatcher()));
+ }
+
+ private void assertServerState(String state) {
+ assertThat(serversView.getServerStatus(getServerName()), is(state));
+ }
+}
Show replies by date