Author: adietish
Date: 2011-09-28 12:10:48 -0400 (Wed, 28 Sep 2011)
New Revision: 35120
Added:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/UserIntegrationTest.java
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/OpenshiftIntegrationTestSuite.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-9773] added user integration test
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/OpenshiftIntegrationTestSuite.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/OpenshiftIntegrationTestSuite.java 2011-09-28
15:59:40 UTC (rev 35119)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/OpenshiftIntegrationTestSuite.java 2011-09-28
16:10:48 UTC (rev 35120)
@@ -21,7 +21,8 @@
CartridgesIntegrationTest.class,
DomainIntegrationTest.class,
ListCartridgesIntegrationTest.class,
- UserInfoIntegrationTest.class
+ UserInfoIntegrationTest.class,
+ UserIntegrationTest.class
})
/**
* @author André Dietisheim
Added:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/UserIntegrationTest.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/UserIntegrationTest.java
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/UserIntegrationTest.java 2011-09-28
16:10:48 UTC (rev 35120)
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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 org.jboss.ide.eclipse.as.openshift.test.internal.core;
+
+import static
org.jboss.ide.eclipse.as.openshift.test.internal.core.utils.ApplicationAsserts.assertApplication;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Collection;
+
+import javax.xml.datatype.DatatypeConfigurationException;
+
+import org.jboss.ide.eclipse.as.openshift.core.IApplication;
+import org.jboss.ide.eclipse.as.openshift.core.ICartridge;
+import org.jboss.ide.eclipse.as.openshift.core.IDomain;
+import org.jboss.ide.eclipse.as.openshift.core.ISSHPublicKey;
+import org.jboss.ide.eclipse.as.openshift.core.OpenshiftException;
+import org.jboss.ide.eclipse.as.openshift.core.internal.InternalUser;
+import org.jboss.ide.eclipse.as.openshift.core.internal.OpenshiftService;
+import org.jboss.ide.eclipse.as.openshift.test.internal.core.fakes.TestUser;
+import org.jboss.ide.eclipse.as.openshift.test.internal.core.utils.ApplicationUtils;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author André Dietisheim
+ */
+public class UserIntegrationTest {
+
+ private InternalUser user;
+
+ @Before
+ public void setUp() throws OpenshiftException, DatatypeConfigurationException {
+ this.user = new TestUser();
+ }
+
+ @Test
+ public void canGetUserUUID() throws OpenshiftException {
+ String uuid = user.getUUID();
+ assertNotNull(uuid);
+ assertTrue(uuid.length() > 0);
+ }
+
+ @Test
+ public void canGetPublicKey() throws OpenshiftException {
+ ISSHPublicKey key = user.getSshKey();
+ assertNotNull(key);
+ assertNotNull(key.getPublicKey());
+ assertTrue(key.getPublicKey().length() > 0);
+ }
+
+ @Test
+ public void canGetDomain() throws OpenshiftException {
+ IDomain domain = user.getDomain();
+ assertNotNull(domain);
+ assertNotNull(domain.getRhcDomain());
+ assertTrue(domain.getRhcDomain().length() > 0);
+ assertNotNull(domain.getNamespace());
+ assertTrue(domain.getNamespace().length() > 0);
+ }
+
+ @Test
+ public void canGetCartridges() throws OpenshiftException {
+ Collection<ICartridge> cartridges = user.getCartridges();
+ assertNotNull(cartridges);
+ assertTrue(cartridges.size() >= 5);
+ }
+
+ @Test
+ public void canGetApplications() throws OpenshiftException {
+ Collection<IApplication> applications = user.getApplications();
+ assertNotNull(applications);
+ }
+
+ @Test
+ public void canCreateApplication() throws OpenshiftException {
+ String applicationName = ApplicationUtils.createRandomApplicationName();
+ try {
+ Collection<IApplication> applications = user.getApplications();
+ assertNotNull(applications);
+ int numOfApplications = applications.size();
+ IApplication application = user.createApplication(applicationName,
ICartridge.JBOSSAS_7);
+ assertEquals(numOfApplications + 1, applications.size());
+ assertApplication(applicationName, ICartridge.JBOSSAS_7.getName(), application);
+ } finally {
+ ApplicationUtils.silentlyDestroyAS7Application(applicationName, user, new
OpenshiftService());
+ }
+ }
+
+ @Test
+ public void canGetApplicationByName() throws OpenshiftException,
DatatypeConfigurationException {
+ String applicationName = ApplicationUtils.createRandomApplicationName();
+ try {
+ IApplication application = user.createApplication(applicationName,
ICartridge.JBOSSAS_7);
+ IApplication applicationFound = user.getApplicationByName(applicationName);
+ assertNotNull(applicationFound);
+ assertEquals(application, applicationFound);
+ } finally {
+ ApplicationUtils.silentlyDestroyAS7Application(applicationName, user, new
OpenshiftService());
+ }
+ }
+}
Property changes on:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/UserIntegrationTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
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-28
15:59:40 UTC (rev 35119)
+++
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-28
16:10:48 UTC (rev 35120)
@@ -72,8 +72,6 @@
assertNotNull(application);
assertEquals(embedded, application.getEmbedded());
assertEquals(uuid, application.getUUID());
- assertNotNull(application.getCartridge());
- assertEquals(cartridgeName, application.getCartridge().getName());
try {
assertEquals(RFC822DateUtils.getDate(creationTime), application.getCreationTime());
} catch (DatatypeConfigurationException e) {
@@ -81,6 +79,12 @@
}
}
+ public static void assertApplication(String name, String cartridgeName, IApplication
application) throws OpenshiftException {
+ assertNotNull(application);
+ assertNotNull(application.getCartridge());
+ assertEquals(cartridgeName, application.getCartridge().getName());
+ }
+
public static void assertGitUri(String applicationName, String gitUri) {
Matcher matcher = GIT_URI_REGEXP.matcher(gitUri);
assertTrue(matcher.matches());