Author: adietish
Date: 2011-09-26 04:07:52 -0400 (Mon, 26 Sep 2011)
New Revision: 35035
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/ApplicationIntegrationTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/ApplicationTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/utils/ApplicationAsserts.java
Log:
[JBIDE-9762] implemented integration test for Application#getGitUri
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/ApplicationIntegrationTest.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/ApplicationIntegrationTest.java 2011-09-26
07:30:16 UTC (rev 35034)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/ApplicationIntegrationTest.java 2011-09-26
08:07:52 UTC (rev 35035)
@@ -10,6 +10,8 @@
******************************************************************************/
package org.jboss.ide.eclipse.as.openshift.test.internal.core;
+import static
org.jboss.ide.eclipse.as.openshift.test.internal.core.utils.ApplicationAsserts.assertGitUri;
+
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -30,7 +32,6 @@
public class ApplicationIntegrationTest {
private IOpenshiftService service;
- private IOpenshiftService invalidCredentialsOpenshiftService;
private static final String RHLOGIN = "toolsjboss(a)gmail.com";
private static final String PASSWORD = "1q2w3e";
@@ -51,6 +52,7 @@
service.createApplication(createRandomApplicationName(), Cartridge.JBOSSAS_7,
invalidUser);
}
+ @Ignore
@Test
public void canCreateApplication() throws Exception {
String applicationName = createRandomApplicationName();
@@ -165,6 +167,7 @@
}
}
+ @Ignore
@Test
public void canGetStatus() throws Exception {
String applicationName = createRandomApplicationName();
@@ -191,6 +194,19 @@
}
}
+ @Test
+ public void returnsValidGitUri() throws Exception {
+ String applicationName = createRandomApplicationName();
+ try {
+ Application application = service.createApplication(applicationName,
Cartridge.JBOSSAS_7, user);
+ String gitUri = application.getGitUri();
+ assertNotNull(gitUri);
+ assertGitUri(applicationName, gitUri);
+ } finally {
+ silentlyDestroyAS7Application(applicationName, service);
+ }
+ }
+
private String createRandomApplicationName() {
return String.valueOf(System.currentTimeMillis());
}
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/ApplicationTest.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/ApplicationTest.java 2011-09-26
07:30:16 UTC (rev 35034)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/ApplicationTest.java 2011-09-26
08:07:52 UTC (rev 35035)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.ide.eclipse.as.openshift.test.internal.core;
+import static
org.jboss.ide.eclipse.as.openshift.test.internal.core.utils.ApplicationAsserts.assertGitUri;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -17,8 +18,6 @@
import java.io.IOException;
import java.net.URLEncoder;
import java.util.Arrays;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
import org.jboss.ide.eclipse.as.openshift.core.Application;
import org.jboss.ide.eclipse.as.openshift.core.ApplicationInfo;
@@ -47,8 +46,6 @@
*/
public class ApplicationTest {
- public static final Pattern GIT_URI_REGEXP =
Pattern.compile("ssh://(.+)@(.+)-([^\\.]+)\\.(.+)/~/git/(.+).git/");
-
private User user = new User(ApplicationResponseFake.RHLOGIN,
ApplicationResponseFake.PASSWORD,
new NoopOpenshiftServiceFake());
@@ -154,24 +151,14 @@
assertNotNull(gitUri);
Domain domain = user.getDomain();
assertNotNull(domain);
- assertGitUri(gitUri
- , ApplicationResponseFake.APPLICATION_UUID
+ assertGitUri(
+ ApplicationResponseFake.APPLICATION_UUID
, ApplicationResponseFake.APPLICATION_NAME
, ApplicationResponseFake.NAMESPACE
- , ApplicationResponseFake.RHC_DOMAIN);
+ , ApplicationResponseFake.RHC_DOMAIN
+ , gitUri);
}
- private void assertGitUri(String gitUri, String uuid, String name, String namespace,
String rhcDomain) {
- Matcher matcher = GIT_URI_REGEXP.matcher(gitUri);
- assertTrue(matcher.matches());
- assertEquals(5, matcher.groupCount());
- assertEquals(uuid, matcher.group(1));
- assertEquals(name, matcher.group(2));
- assertEquals(namespace, matcher.group(3));
- assertEquals(rhcDomain, matcher.group(4));
- assertEquals(name, matcher.group(5));
- }
-
@Test
public void canUnmarshallApplicationStatus() throws OpenshiftException {
String response = JsonSanitizer.sanitize(ApplicationResponseFake.statusResponse);
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/utils/ApplicationAsserts.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/utils/ApplicationAsserts.java 2011-09-26
07:30:16 UTC (rev 35034)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/utils/ApplicationAsserts.java 2011-09-26
08:07:52 UTC (rev 35035)
@@ -12,10 +12,13 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.text.MessageFormat;
import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import javax.xml.datatype.DatatypeConfigurationException;
@@ -28,6 +31,15 @@
*/
public class ApplicationAsserts {
+ /**
+ * $1 = application uuid
+ * $2 = application name
+ * $3 = user uuid
+ * $4 = rhc cloud domain (
rhcloud.com)
+ * $5 = application name
+ */
+ public static final Pattern GIT_URI_REGEXP =
Pattern.compile("ssh://(.+)@(.+)-([^\\.]+)\\.(.+)/~/git/(.+).git/");
+
public static void assertThatContainsApplication(String applicationName, String
embedded, String applicationUUID,
String cartridgeName, String creationTime, List<Application> applications)
throws OpenshiftException {
Application application = getApplication(applicationName, applications);
@@ -65,4 +77,23 @@
}
}
+ public static void assertGitUri(String applicationName, String gitUri) {
+ Matcher matcher = GIT_URI_REGEXP.matcher(gitUri);
+ assertTrue(matcher.matches());
+ assertEquals(5, matcher.groupCount());
+ assertEquals(applicationName, matcher.group(2));
+ assertEquals(applicationName, matcher.group(5));
+ }
+
+ public static void assertGitUri(String uuid, String name, String namespace, String
rhcDomain, String gitUri) {
+ Matcher matcher = GIT_URI_REGEXP.matcher(gitUri);
+ assertTrue(matcher.matches());
+ assertEquals(5, matcher.groupCount());
+ assertEquals(uuid, matcher.group(1));
+ assertEquals(name, matcher.group(2));
+ assertEquals(namespace, matcher.group(3));
+ assertEquals(rhcDomain, matcher.group(4));
+ assertEquals(name, matcher.group(5));
+ }
+
}