[jbosstools-commits] JBoss Tools SVN: r39337 - trunk/openshift/tests/org.jboss.tools.openshift.ui.bot.test/src/org/jboss/tools/openshift/ui/bot/util.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Wed Mar 7 08:54:59 EST 2012
Author: sbunciak
Date: 2012-03-07 08:54:58 -0500 (Wed, 07 Mar 2012)
New Revision: 39337
Added:
trunk/openshift/tests/org.jboss.tools.openshift.ui.bot.test/src/org/jboss/tools/openshift/ui/bot/util/DomainDestroyer.java
trunk/openshift/tests/org.jboss.tools.openshift.ui.bot.test/src/org/jboss/tools/openshift/ui/bot/util/OpenShiftUI.java
trunk/openshift/tests/org.jboss.tools.openshift.ui.bot.test/src/org/jboss/tools/openshift/ui/bot/util/TestProperties.java
Log:
Bot tests for JBoss Tools 3.3.0.Beta1 OpenShift UI
Added: trunk/openshift/tests/org.jboss.tools.openshift.ui.bot.test/src/org/jboss/tools/openshift/ui/bot/util/DomainDestroyer.java
===================================================================
--- trunk/openshift/tests/org.jboss.tools.openshift.ui.bot.test/src/org/jboss/tools/openshift/ui/bot/util/DomainDestroyer.java (rev 0)
+++ trunk/openshift/tests/org.jboss.tools.openshift.ui.bot.test/src/org/jboss/tools/openshift/ui/bot/util/DomainDestroyer.java 2012-03-07 13:54:58 UTC (rev 39337)
@@ -0,0 +1,56 @@
+package org.jboss.tools.openshift.ui.bot.util;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.PostMethod;
+
+/**
+ *
+ * @author sbunciak
+ *
+ * Utility class to destroy domain on OpenShift
+ */
+public class DomainDestroyer {
+
+ /**
+ *
+ * Destroys registered domain on OpenShift Express
+ *
+ * @param domain
+ * @param login
+ * @param password
+ * @return HTTP Response code or 0 if some Exception was caught
+ */
+ public static int destroyDomain(String domain, String login, String password) {
+
+ int resp_code = 0;
+ String input = "{\"namespace\": \"" + domain + "\", \"rhlogin\": \""
+ + login + "\", \"delete\": true }";
+
+ HttpClient client = new HttpClient();
+ PostMethod method = new PostMethod(
+ "https://openshift.redhat.com/broker/domain");
+
+ method.addParameter("json_data", input);
+ method.addParameter("password", password);
+
+ try {
+ resp_code = client.executeMethod(method);
+ } catch (Exception e) {
+ System.out.println(e);
+ } finally {
+ method.releaseConnection();
+ }
+ return resp_code;
+ }
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ if (destroyDomain("rhtest", "sbunciak", "rhtest123") == 200) {
+ System.out.println("Domain destroyed.");
+ } else {
+ System.out.println("Domain was not destroyed.");
+ }
+ }
+}
Added: trunk/openshift/tests/org.jboss.tools.openshift.ui.bot.test/src/org/jboss/tools/openshift/ui/bot/util/OpenShiftUI.java
===================================================================
--- trunk/openshift/tests/org.jboss.tools.openshift.ui.bot.test/src/org/jboss/tools/openshift/ui/bot/util/OpenShiftUI.java (rev 0)
+++ trunk/openshift/tests/org.jboss.tools.openshift.ui.bot.test/src/org/jboss/tools/openshift/ui/bot/util/OpenShiftUI.java 2012-03-07 13:54:58 UTC (rev 39337)
@@ -0,0 +1,95 @@
+package org.jboss.tools.openshift.ui.bot.util;
+
+import java.util.List;
+import java.util.Vector;
+
+import org.jboss.tools.ui.bot.ext.gen.INewObject;
+import org.jboss.tools.ui.bot.ext.gen.IView;
+
+/**
+ *
+ * Wrapper class for OpenShift UI tooling.
+ *
+ * @author sbunciak
+ *
+ */
+public class OpenShiftUI {
+
+ /**
+ *
+ * Class representing OpenShift Console View
+ *
+ */
+ public static class Console {
+
+ public static final IView iView = new IView() {
+ @Override
+ public String getName() {
+ return "OpenShift Express Console";
+ }
+
+ @Override
+ public List<String> getGroupPath() {
+ List<String> l = new Vector<String>();
+ l.add("JBoss Tools");
+ return l;
+ }
+ };
+ }
+
+ /**
+ *
+ * Class representing "navigation" to new OpenShift Express Application
+ *
+ */
+ public static class NewApplication {
+ public static final INewObject iNewObject = new INewObject() {
+ @Override
+ public String getName() {
+ return "OpenShift Application";
+ }
+
+ @Override
+ public List<String> getGroupPath() {
+ List<String> l = new Vector<String>();
+ l.add("OpenShift");
+ return l;
+ }
+ };
+ }
+
+ /**
+ * List of available application type labels
+ *
+ * @author sbunciak
+ *
+ */
+ public static class AppType {
+
+ public static final String JBOSS = "jbossas-7";
+ public static final String JENKINS = "jenkins-1.4";
+ public static final String PERL = "perl-5.10";
+ public static final String PHP = "php-5.3";
+ public static final String PYTHON = "python-2.6";
+ public static final String RAW = "raw-0.1";
+ public static final String RUBY = "ruby-1.8";
+ }
+
+ /**
+ * List of available cartridge labels
+ *
+ * @author sbunciak
+ *
+ */
+ public static class Cartridge {
+
+ public static final String MONGODB = "mongodb-2.0";
+ public static final String JENKINS = "jenkins-1.4";
+ public static final String CRON = "cron-1.4";
+ public static final String MYSQL = "mysql-5.1";
+ public static final String POSTGRESQL = "postgresql-8.4";
+ public static final String PHPMYADMIN = "phpmyadmin-3.4";
+ public static final String METRICS = "metrics-0.1";
+ public static final String ROCKMONGO = "rockmongo-1.1";
+ }
+}
Property changes on: trunk/openshift/tests/org.jboss.tools.openshift.ui.bot.test/src/org/jboss/tools/openshift/ui/bot/util/OpenShiftUI.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/openshift/tests/org.jboss.tools.openshift.ui.bot.test/src/org/jboss/tools/openshift/ui/bot/util/TestProperties.java
===================================================================
--- trunk/openshift/tests/org.jboss.tools.openshift.ui.bot.test/src/org/jboss/tools/openshift/ui/bot/util/TestProperties.java (rev 0)
+++ trunk/openshift/tests/org.jboss.tools.openshift.ui.bot.test/src/org/jboss/tools/openshift/ui/bot/util/TestProperties.java 2012-03-07 13:54:58 UTC (rev 39337)
@@ -0,0 +1,47 @@
+package org.jboss.tools.openshift.ui.bot.util;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.Properties;
+
+import org.apache.commons.codec.binary.Base64;
+import org.apache.log4j.Logger;
+
+/**
+ * Just static properties holder
+ *
+ * @author sbunciak
+ *
+ */
+public class TestProperties {
+
+ public static Properties props = new Properties();
+
+ static {
+
+ try {
+ props.load(new FileInputStream(
+ "resources/openshift.ui.bot.test.properties"));
+
+ } catch (FileNotFoundException e) {
+ Logger.getLogger(TestProperties.class).error(
+ "Property file not found !", e);
+ } catch (IOException e) {
+ Logger.getLogger(TestProperties.class).error(
+ "IO Exception !", e);
+ }
+
+ }
+
+ public static String getProperty(String key) {
+ return props.getProperty(key);
+ }
+
+ public static String getPassphrase() {
+ String passphrase = new String(new Base64().decode(TestProperties.getProperty(
+ "openshift.ssh.passphrase").getBytes()));
+ return passphrase;
+ }
+
+}
More information about the jbosstools-commits
mailing list