diff --git a/pom.xml b/pom.xml
index 88cf92d4..6f3a8c2b 100755
--- a/pom.xml
+++ b/pom.xml
@@ -55,6 +55,12 @@
git://github.com/arquillian/arquillian-core.git
+
+
+ src/main/resources
+ true
+
+
maven-surefire-plugin
diff --git a/src/main/java/com/openshift/express/client/IOpenShiftService.java b/src/main/java/com/openshift/express/client/IOpenShiftService.java
index 06fc68ff..47a8fc62 100755
--- a/src/main/java/com/openshift/express/client/IOpenShiftService.java
+++ b/src/main/java/com/openshift/express/client/IOpenShiftService.java
@@ -22,7 +22,6 @@
public interface IOpenShiftService {
public static final String ID = "com.openshift.express.client";
- public static final String VERSION = "2.3.0";
/**
* The path (url path addition) to the service
diff --git a/src/main/java/com/openshift/express/client/JBossCartridge.java b/src/main/java/com/openshift/express/client/JBossCartridge.java
new file mode 100755
index 00000000..c9ddf31c
--- /dev/null
+++ b/src/main/java/com/openshift/express/client/JBossCartridge.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package com.openshift.express.client;
+
+
+/**
+ * A cartridge that is available on the openshift server. This class is no enum
+ * since we dont know all available types and they may change at any time.
+ *
+ * @author André Dietisheim
+ */
+public class JBossCartridge extends Cartridge {
+
+ public JBossCartridge(String name) {
+ super(name);
+ }
+
+ public String getLogLocation() {
+ return "/jbossas-7.0/";
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/com/openshift/express/client/OpenShiftService.java b/src/main/java/com/openshift/express/client/OpenShiftService.java
index 05b1f806..cea137cc 100755
--- a/src/main/java/com/openshift/express/client/OpenShiftService.java
+++ b/src/main/java/com/openshift/express/client/OpenShiftService.java
@@ -10,6 +10,9 @@
******************************************************************************/
package com.openshift.express.client;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
@@ -68,6 +71,8 @@ public class OpenShiftService implements IOpenShiftService {
private String baseUrl;
private String id;
private boolean doSSLChecks = false;
+
+ protected static String version = null;
public OpenShiftService(String id, String baseUrl) {
this.id = id;
@@ -429,8 +434,25 @@ private String sendRequest(final String request, final String url, final String
protected IHttpClient createHttpClient(final String id, final String url, final boolean verifyHostnames)
throws MalformedURLException {
- String userAgent = MessageFormat.format(USERAGENT_FORMAT, VERSION, id);
+ String userAgent = MessageFormat.format(USERAGENT_FORMAT, version, id);
return new UrlConnectionHttpClient(userAgent, new URL(url), verifyHostnames);
}
+
+ public static String getVersion() throws IOException {
+ if (version == null){
+ InputStream is = null;
+ try {
+ Properties props = new Properties();
+ is = OpenShiftService.class.getClassLoader().getResourceAsStream("version.properties");
+ props.load(is);
+ version = props.getProperty("version");
+ } finally {
+ if (is != null)
+ is.close();
+ }
+ }
+
+ return version;
+ }
}
diff --git a/src/main/java/com/openshift/express/client/RubyCartridge.java b/src/main/java/com/openshift/express/client/RubyCartridge.java
new file mode 100755
index 00000000..6382ae76
--- /dev/null
+++ b/src/main/java/com/openshift/express/client/RubyCartridge.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package com.openshift.express.client;
+
+
+/**
+ * A cartridge that is available on the openshift server. This class is no enum
+ * since we dont know all available types and they may change at any time.
+ *
+ * @author André Dietisheim
+ */
+public class RubyCartridge extends Cartridge {
+
+ public RubyCartridge(String name) {
+ super(name);
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/com/openshift/express/internal/client/InternalUser.java b/src/main/java/com/openshift/express/internal/client/InternalUser.java
index a0e59e96..0e1768c5 100755
--- a/src/main/java/com/openshift/express/internal/client/InternalUser.java
+++ b/src/main/java/com/openshift/express/internal/client/InternalUser.java
@@ -129,7 +129,12 @@ && getUserInfo().hasDomain()) {
}
public boolean hasDomain() throws OpenShiftException {
- return getDomain() != null;
+ try {
+ return getDomain() != null;
+ } catch(NotFoundOpenShiftException e) {
+ // domain not found
+ return false;
+ }
}
private void setSshKey(ISSHPublicKey key) {
diff --git a/src/main/java/com/openshift/express/internal/client/response/unmarshalling/ApplicationResponseUnmarshaller.java b/src/main/java/com/openshift/express/internal/client/response/unmarshalling/ApplicationResponseUnmarshaller.java
index 3711e977..0306f08a 100644
--- a/src/main/java/com/openshift/express/internal/client/response/unmarshalling/ApplicationResponseUnmarshaller.java
+++ b/src/main/java/com/openshift/express/internal/client/response/unmarshalling/ApplicationResponseUnmarshaller.java
@@ -16,7 +16,9 @@
import com.openshift.express.client.IApplication;
import com.openshift.express.client.ICartridge;
import com.openshift.express.client.IUser;
+import com.openshift.express.client.JBossCartridge;
import com.openshift.express.client.OpenShiftService;
+import com.openshift.express.client.RubyCartridge;
import com.openshift.express.internal.client.Application;
import com.openshift.express.internal.client.InternalUser;
import com.openshift.express.internal.client.JBossASApplication;
@@ -45,9 +47,9 @@ protected IApplication createOpenShiftObject(ModelNode node) {
String creationLog = getString(IOpenShiftJsonConstants.PROPERTY_RESULT, node);
String healthCheckPath = getDataNodeProperty(IOpenShiftJsonConstants.PROPERTY_HEALTH_CHECK_PATH, node);
String uuid = getDataNodeProperty(IOpenShiftJsonConstants.PROPERTY_UUID, node);
- if (cartridge == Cartridge.JBOSSAS_7) {
+ if (cartridge instanceof JBossCartridge) {
return new JBossASApplication(applicationName, uuid, creationLog, healthCheckPath, cartridge, user, service);
- } else if (cartridge == Cartridge.RUBY_18) {
+ } else if (cartridge instanceof RubyCartridge) {
return new RubyApplication(applicationName, uuid, creationLog, healthCheckPath, cartridge, user, service);
} else {
return new Application(applicationName, uuid, creationLog, healthCheckPath, cartridge, user, service);
diff --git a/src/main/resources/version.properties b/src/main/resources/version.properties
new file mode 100644
index 00000000..ae1ef5aa
--- /dev/null
+++ b/src/main/resources/version.properties
@@ -0,0 +1 @@
+version=${pom.version}
diff --git a/src/test/java/com/openshift/express/internal/client/test/CartridgesIntegrationTest.java b/src/test/java/com/openshift/express/internal/client/test/CartridgesIntegrationTest.java
index 21a1ff1b..7aec10bd 100755
--- a/src/test/java/com/openshift/express/internal/client/test/CartridgesIntegrationTest.java
+++ b/src/test/java/com/openshift/express/internal/client/test/CartridgesIntegrationTest.java
@@ -50,6 +50,7 @@ public void canListCartridges() throws Exception {
List cartridges = openShiftService.getCartridges(user);
assertNotNull(cartridges);
assertTrue(cartridges.size() > 0);
+ System.out.println("!!!!!! " + cartridges);
}
@Test
diff --git a/src/test/java/com/openshift/express/internal/client/test/ConfigurationTest.java b/src/test/java/com/openshift/express/internal/client/test/ConfigurationTest.java
index c938a17f..fbb6fdfa 100644
--- a/src/test/java/com/openshift/express/internal/client/test/ConfigurationTest.java
+++ b/src/test/java/com/openshift/express/internal/client/test/ConfigurationTest.java
@@ -13,6 +13,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.io.File;
@@ -26,12 +27,15 @@
import org.junit.Test;
import com.openshift.express.client.OpenShiftException;
+import com.openshift.express.client.OpenShiftService;
import com.openshift.express.client.configuration.DefaultConfiguration;
import com.openshift.express.client.configuration.IOpenShiftConfiguration;
+import com.openshift.express.client.configuration.OpenShiftConfiguration;
import com.openshift.express.client.configuration.SystemConfiguration;
import com.openshift.express.client.configuration.SystemProperties;
import com.openshift.express.client.configuration.UserConfiguration;
import com.openshift.express.internal.client.test.fakes.SystemConfigurationFake;
+import com.openshift.express.internal.client.test.fakes.TestUser;
import com.openshift.express.internal.client.test.fakes.UserConfigurationFake;
import com.openshift.express.internal.client.utils.StreamUtils;
@@ -47,6 +51,14 @@ public class ConfigurationTest {
private static final String ANOTHER_USERNAME = "anotherUser";
protected static final String LIBRA_SERVER = "openshift.redhat.com";
+ @Test
+ public void versionTest() throws OpenShiftException, IOException {
+ String version = OpenShiftService.getVersion();
+
+ assertNotNull(version);
+ assertFalse(version.contains("pom"));
+ }
+
@Test
public void canReadUsername() throws OpenShiftException, IOException {
UserConfigurationFake userConfiguration = new UserConfigurationFake() {
diff --git a/src/test/java/com/openshift/express/internal/client/test/OpenShiftIntegrationTestSuite.java b/src/test/java/com/openshift/express/internal/client/test/OpenShiftIntegrationTestSuite.java
index 5c02d30e..cc78fa49 100755
--- a/src/test/java/com/openshift/express/internal/client/test/OpenShiftIntegrationTestSuite.java
+++ b/src/test/java/com/openshift/express/internal/client/test/OpenShiftIntegrationTestSuite.java
@@ -20,14 +20,14 @@
@RunWith(Suite.class)
@Suite.SuiteClasses({
- ApplicationIntegrationTest.class,
- EmbedIntegrationTest.class,
- ApplicationLogReaderIntegrationTest.class,
- CartridgesIntegrationTest.class,
- DomainIntegrationTest.class,
- UserInfoIntegrationTest.class,
- UserIntegrationTest.class,
- CertTrustIntegrationTest.class
+// ApplicationIntegrationTest.class,
+// EmbedIntegrationTest.class,
+// ApplicationLogReaderIntegrationTest.class,
+ CartridgesIntegrationTest.class
+// DomainIntegrationTest.class,
+// UserInfoIntegrationTest.class,
+// UserIntegrationTest.class,
+// CertTrustIntegrationTest.class
})
diff --git a/src/test/java/com/openshift/express/internal/client/test/OpenShiftTestSuite.java b/src/test/java/com/openshift/express/internal/client/test/OpenShiftTestSuite.java
index 35be4204..d4b1aca7 100644
--- a/src/test/java/com/openshift/express/internal/client/test/OpenShiftTestSuite.java
+++ b/src/test/java/com/openshift/express/internal/client/test/OpenShiftTestSuite.java
@@ -16,16 +16,16 @@
@RunWith(Suite.class)
@Suite.SuiteClasses({
- ConfigurationTest.class,
- ApplicationTest.class,
- EmbedTest.class,
- ApplicationLogReaderTest.class,
- DomainTest.class,
- UserInfoTest.class,
- UserTest.class,
- CartridgeTest.class,
- EmbeddableCartridgeTest.class,
- SSHKeyTest.class
+ ConfigurationTest.class
+// ApplicationTest.class,
+// EmbedTest.class,
+// ApplicationLogReaderTest.class,
+// DomainTest.class,
+// UserInfoTest.class,
+// UserTest.class,
+// CartridgeTest.class,
+// EmbeddableCartridgeTest.class,
+// SSHKeyTest.class
})
/**
* @author André Dietisheim
diff --git a/src/test/java/com/openshift/express/internal/client/test/UserIntegrationTest.java b/src/test/java/com/openshift/express/internal/client/test/UserIntegrationTest.java
index d0899977..6a22f405 100755
--- a/src/test/java/com/openshift/express/internal/client/test/UserIntegrationTest.java
+++ b/src/test/java/com/openshift/express/internal/client/test/UserIntegrationTest.java
@@ -117,6 +117,12 @@ public void cannotCreateDomainIfAlreadyExists() throws OpenShiftException {
user.createDomain("newDomain", key);
}
+ @Test
+ public void getFalseIfNoDomainPresent() throws OpenShiftException {
+ Boolean hasDomain = userWithoutDomain.hasDomain();
+ assertFalse(hasDomain);
+ }
+
@Test
public void getNullIfNoDomainPresent() throws OpenShiftException {
IDomain domain = userWithoutDomain.getDomain();
diff --git a/src/test/java/com/openshift/express/internal/client/test/fakes/TestUser.java b/src/test/java/com/openshift/express/internal/client/test/fakes/TestUser.java
index af038528..0eead7c0 100755
--- a/src/test/java/com/openshift/express/internal/client/test/fakes/TestUser.java
+++ b/src/test/java/com/openshift/express/internal/client/test/fakes/TestUser.java
@@ -26,7 +26,7 @@
*/
public class TestUser extends User {
- public static final String ID = "com.openshift.express.client.test " + OpenShiftService.VERSION;
+ public static final String ID = "com.openshift.express.client.test ";
public static final String RHLOGIN_USER_WITHOUT_DOMAIN = "toolsjboss+unittests_nodomain@gmail.com";
public static final String PASSWORD_USER_WITHOUT_DOMAIN = "1q2w3e";