Author: adietish
Date: 2011-09-13 08:15:53 -0400 (Tue, 13 Sep 2011)
New Revision: 34675
Added:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/Activator.java
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/CartridgeAsserts.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/CartridgesIntegrationTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/DomainIntegrationTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/DomainTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/ListCartridgesIntegrationTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/ListCartridgesTest.java
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/OpenshiftTestSuite.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/SSHKeyTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/UserInfoTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/fakes/
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/utils/
Removed:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/Activator.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/ApplicationIntegrationTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/ApplicationTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/CartridgeAsserts.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/CartridgesIntegrationTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/DomainIntegrationTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/DomainTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/ListCartridgesIntegrationTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/ListCartridgesTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/OpenshiftIntegrationTestSuite.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/OpenshiftTestSuite.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/SSHKeyTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/UserInfoTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/fakes/
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/utils/
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/META-INF/MANIFEST.MF
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/fakes/TestSSHKey.java
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/utils/StreamUtils.java
Log:
[JBIDE-9510] corrected package structure
Modified: trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/META-INF/MANIFEST.MF 2011-09-13
12:13:05 UTC (rev 34674)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/META-INF/MANIFEST.MF 2011-09-13
12:15:53 UTC (rev 34675)
@@ -3,7 +3,7 @@
Bundle-Name: Openshift Test Plugin
Bundle-SymbolicName: org.jboss.ide.eclipse.as.openshift.test
Bundle-Version: 1.0.0.qualifier
-Bundle-Activator: org.jboss.ide.eclipse.as.openshift.internal.test.core.Activator
+Bundle-Activator: org.jboss.ide.eclipse.as.openshift.test.internal.core.Activator
Bundle-Vendor: JBoss by Red Hat
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.7.0,4.0.0)",
org.junit;bundle-version="[4.8.0,5.0.0)",
Deleted:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/Activator.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/Activator.java 2011-09-13
12:13:05 UTC (rev 34674)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/Activator.java 2011-09-13
12:15:53 UTC (rev 34675)
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * 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.internal.test.core;
-
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-
-public class Activator implements BundleActivator {
-
- private static BundleContext context;
-
- static BundleContext getContext() {
- return context;
- }
-
- public void start(BundleContext bundleContext) throws Exception {
- Activator.context = bundleContext;
- }
-
- public void stop(BundleContext bundleContext) throws Exception {
- Activator.context = null;
- }
-
-}
Deleted:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/ApplicationIntegrationTest.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/ApplicationIntegrationTest.java 2011-09-13
12:13:05 UTC (rev 34674)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/ApplicationIntegrationTest.java 2011-09-13
12:15:53 UTC (rev 34675)
@@ -1,188 +0,0 @@
-/*******************************************************************************
- * 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.internal.test.core;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import org.jboss.ide.eclipse.as.openshift.core.Application;
-import org.jboss.ide.eclipse.as.openshift.core.Cartridge;
-import org.jboss.ide.eclipse.as.openshift.core.IOpenshiftService;
-import org.jboss.ide.eclipse.as.openshift.core.InvalidCredentialsOpenshiftException;
-import org.jboss.ide.eclipse.as.openshift.core.OpenshiftException;
-import org.jboss.ide.eclipse.as.openshift.core.Status;
-import org.jboss.ide.eclipse.as.openshift.core.internal.OpenshiftService;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-
-/**
- * @author André Dietisheim
- */
-public class ApplicationIntegrationTest {
-
- private IOpenshiftService openshiftService;
- private IOpenshiftService invalidCredentialsOpenshiftService;
-
- private static final String USERNAME = "toolsjboss(a)gmail.com";
- private static final String PASSWORD = "1q2w3e";
-
- @Before
- public void setUp() {
- this.openshiftService = new OpenshiftService(USERNAME, PASSWORD);
- this.invalidCredentialsOpenshiftService = new OpenshiftService(USERNAME,
"bogus");
- }
-
- @Ignore
- @Test(expected = InvalidCredentialsOpenshiftException.class)
- public void createApplicationWithInvalidCredentialsThrowsException() throws Exception {
- invalidCredentialsOpenshiftService.createApplication(createRandomApplicationName(),
Cartridge.JBOSSAS_7);
- }
-
- @Ignore
- @Test
- public void canCreateApplication() throws Exception {
- String applicationName = createRandomApplicationName();
- try {
- Cartridge cartridge = Cartridge.JBOSSAS_7;
- Application application = openshiftService.createApplication(applicationName,
cartridge);
- assertNotNull(application);
- assertEquals(applicationName, application.getName());
- assertEquals(cartridge, application.getCartridge());
- } finally {
- silentlyDestroyApplication(applicationName, openshiftService);
- }
- }
-
- @Ignore
- @Test
- public void canDestroyApplication() throws Exception {
- String applicationName = createRandomApplicationName();
- openshiftService.createApplication(applicationName, Cartridge.JBOSSAS_7);
- openshiftService.destroyApplication(applicationName, Cartridge.JBOSSAS_7);
- }
-
- @Ignore
- @Test(expected = OpenshiftException.class)
- public void createDuplicateApplicationThrowsException() throws Exception {
- String applicationName = createRandomApplicationName();
- try {
- openshiftService.createApplication(applicationName, Cartridge.JBOSSAS_7);
- openshiftService.createApplication(applicationName, Cartridge.JBOSSAS_7);
- } finally {
- silentlyDestroyApplication(applicationName, openshiftService);
- }
- }
-
- @Ignore
- @Test
- public void canStopApplication() throws Exception {
- String applicationName = createRandomApplicationName();
- try {
- openshiftService.createApplication(applicationName, Cartridge.JBOSSAS_7);
- openshiftService.stopApplication(applicationName, Cartridge.JBOSSAS_7);
- } finally {
- silentlyDestroyApplication(applicationName, openshiftService);
- }
- }
-
- @Ignore
- @Test
- public void canStartStoppedApplication() throws Exception {
- String applicationName = createRandomApplicationName();
- try {
- openshiftService.createApplication(applicationName, Cartridge.JBOSSAS_7);
- openshiftService.stopApplication(applicationName, Cartridge.JBOSSAS_7);
- openshiftService.startApplication(applicationName, Cartridge.JBOSSAS_7);
- } finally {
- silentlyDestroyApplication(applicationName, openshiftService);
- }
- }
-
- @Ignore
- @Test
- public void canStartStartedApplication() throws Exception {
- String applicationName = createRandomApplicationName();
- try {
- /**
- * freshly created apps are started
- *
- * @link
- *
https://github.com/openshift/os-client-tools/blob/master/express/doc/API
- */
- openshiftService.createApplication(applicationName, Cartridge.JBOSSAS_7);
- openshiftService.startApplication(applicationName, Cartridge.JBOSSAS_7);
- } finally {
- silentlyDestroyApplication(applicationName, openshiftService);
- }
- }
-
- @Ignore
- @Test
- public void canStopStoppedApplication() throws Exception {
- String applicationName = createRandomApplicationName();
- try {
- /**
- * freshly created apps are started
- *
- * @link
- *
https://github.com/openshift/os-client-tools/blob/master/express/doc/API
- */
- openshiftService.createApplication(applicationName, Cartridge.JBOSSAS_7);
- openshiftService.stopApplication(applicationName, Cartridge.JBOSSAS_7);
- openshiftService.stopApplication(applicationName, Cartridge.JBOSSAS_7);
- } finally {
- silentlyDestroyApplication(applicationName, openshiftService);
- }
- }
-
- @Ignore
- @Test
- public void canRestartApplication() throws Exception {
- String applicationName = createRandomApplicationName();
- try {
- /**
- * freshly created apps are started
- *
- * @link
- *
https://github.com/openshift/os-client-tools/blob/master/express/doc/API
- */
- openshiftService.createApplication(applicationName, Cartridge.JBOSSAS_7);
- openshiftService.restartApplication(applicationName, Cartridge.JBOSSAS_7);
- } finally {
- silentlyDestroyApplication(applicationName, openshiftService);
- }
- }
-
- @Test
- public void canGetStatus() throws Exception {
- String applicationName = createRandomApplicationName();
- try {
- Application application = openshiftService.createApplication(applicationName,
Cartridge.JBOSSAS_7);
- Status status = openshiftService.getStatus(application);
- assertNotNull(status);
- } finally {
- silentlyDestroyApplication(applicationName, openshiftService);
- }
- }
-
- private String createRandomApplicationName() {
- return String.valueOf(System.currentTimeMillis());
- }
-
- private void silentlyDestroyApplication(String name, IOpenshiftService service) {
- try {
- service.destroyApplication(name, Cartridge.JBOSSAS_7);
- } catch (OpenshiftException e) {
- e.printStackTrace();
- }
- }
-}
Deleted:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/ApplicationTest.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/ApplicationTest.java 2011-09-13
12:13:05 UTC (rev 34674)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/ApplicationTest.java 2011-09-13
12:15:53 UTC (rev 34675)
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * 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.internal.test.core;
-
-import static org.junit.Assert.assertEquals;
-
-import java.net.URLEncoder;
-
-import org.jboss.ide.eclipse.as.openshift.core.Cartridge;
-import
org.jboss.ide.eclipse.as.openshift.core.internal.marshalling.ApplicationRequestJsonMarshaller;
-import org.jboss.ide.eclipse.as.openshift.core.internal.request.ApplicationAction;
-import org.jboss.ide.eclipse.as.openshift.core.internal.request.ApplicationRequest;
-import
org.jboss.ide.eclipse.as.openshift.core.internal.request.OpenshiftJsonRequestFactory;
-import org.junit.Test;
-
-/**
- * @author André Dietisheim
- */
-public class ApplicationTest {
-
- private static final String USERNAME = "toolsjboss(a)gmail.com";
- private static final String PASSWORD = "1q2w3e";
-
- @Test
- public void canMarshallApplicationCreateRequest() throws Exception {
- String expectedRequestString =
- "password="
- + PASSWORD
- + "&json_data=%7B"
- + "%22rhlogin%22+%3A+%22"
- + URLEncoder.encode(USERNAME, "UTF-8")
- + "%22"
- + "%2C+%22debug%22+%3A+%22true%22"
- + "%2C+%22cartridge%22+%3A+%22jbossas-7.0%22"
- + "%2C+%22action%22+%3A+%22configure%22"
- + "%2C+%22app_name%22+%3A+%22test-application%22"
- + "%7D";
-
- String createApplicationRequest = new ApplicationRequestJsonMarshaller().marshall(
- new ApplicationRequest(
- "test-application", Cartridge.JBOSSAS_7, ApplicationAction.CONFIGURE,
USERNAME, true));
- String effectiveRequest = new OpenshiftJsonRequestFactory(PASSWORD,
createApplicationRequest).create();
-
- assertEquals(expectedRequestString, effectiveRequest);
- }
-
- @Test
- public void canMarshallApplicationDestroyRequest() throws Exception {
- String expectedRequestString =
- "password="
- + PASSWORD
- + "&json_data=%7B"
- + "%22rhlogin%22+%3A+"
- + "%22" + URLEncoder.encode(USERNAME, "UTF-8") +
"%22"
- + "%2C+%22debug%22+%3A+%22true%22"
- + "%2C+%22cartridge%22+%3A+%22jbossas-7.0%22"
- + "%2C+%22action%22+%3A+%22deconfigure%22"
- + "%2C+%22app_name%22+%3A+%22test-application%22"
- + "%7D";
-
- String createApplicationRequest = new ApplicationRequestJsonMarshaller().marshall(
- new ApplicationRequest(
- "test-application", Cartridge.JBOSSAS_7, ApplicationAction.DECONFIGURE,
USERNAME, true));
- String effectiveRequest = new OpenshiftJsonRequestFactory(PASSWORD,
createApplicationRequest).create();
-
- assertEquals(expectedRequestString, effectiveRequest);
- }
-}
Deleted:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/CartridgeAsserts.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/CartridgeAsserts.java 2011-09-13
12:13:05 UTC (rev 34674)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/CartridgeAsserts.java 2011-09-13
12:15:53 UTC (rev 34675)
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * 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.internal.test.core;
-
-import static org.junit.Assert.fail;
-
-import java.text.MessageFormat;
-import java.util.List;
-
-import org.jboss.ide.eclipse.as.openshift.core.Cartridge;
-
-public class CartridgeAsserts {
-
- public static void assertThatContainsCartridge(String cartridgeName,
List<Cartridge> cartridges) {
- boolean found = false;
- for (Cartridge cartridge : cartridges) {
- if (cartridgeName.equals(cartridge.getName())) {
- found = true;
- break;
- }
- }
- if (!found) {
- fail(MessageFormat.format("Could not find cartridge with name
\"{0}\"", cartridgeName));
- }
- }
-
-
-}
Deleted:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/CartridgesIntegrationTest.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/CartridgesIntegrationTest.java 2011-09-13
12:13:05 UTC (rev 34674)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/CartridgesIntegrationTest.java 2011-09-13
12:15:53 UTC (rev 34675)
@@ -1,33 +0,0 @@
-package org.jboss.ide.eclipse.as.openshift.internal.test.core;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.List;
-
-import org.jboss.ide.eclipse.as.openshift.core.Cartridge;
-import org.jboss.ide.eclipse.as.openshift.core.internal.OpenshiftService;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-
-public class CartridgesIntegrationTest {
-
- private OpenshiftService openshiftService;
-
- private static final String USERNAME = "toolsjboss(a)gmail.com";
- private static final String PASSWORD = "1q2w3e";
-
- @Before
- public void setUp() {
- this.openshiftService = new OpenshiftService(USERNAME, PASSWORD);
- }
-
- @Ignore
- @Test
- public void canRequestListCartridges() throws Exception {
- List<Cartridge> cartridges = openshiftService.getCartridges();
- assertNotNull(cartridges);
- assertTrue(cartridges.size() > 0);
- }
-}
Deleted:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/DomainIntegrationTest.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/DomainIntegrationTest.java 2011-09-13
12:13:05 UTC (rev 34674)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/DomainIntegrationTest.java 2011-09-13
12:15:53 UTC (rev 34675)
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * 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.internal.test.core;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import org.jboss.ide.eclipse.as.openshift.core.Domain;
-import org.jboss.ide.eclipse.as.openshift.core.SSHKey;
-import org.jboss.ide.eclipse.as.openshift.core.User;
-import org.jboss.ide.eclipse.as.openshift.core.internal.OpenshiftService;
-import org.jboss.ide.eclipse.as.openshift.internal.test.core.fakes.TestSSHKey;
-import org.junit.Before;
-import org.junit.Test;
-
-public class DomainIntegrationTest {
-
- private OpenshiftService openshiftService;
-
- private static final String USERNAME = "toolsjboss(a)gmail.com";
- private static final String PASSWORD = "1q2w3e";
-
- @Before
- public void setUp() {
- this.openshiftService = new OpenshiftService(USERNAME, PASSWORD);
- }
-
- @Test
- public void canCreateDomain() throws Exception {
-
- String domainName = createRandomString();
- SSHKey sshKey = TestSSHKey.create();
- Domain domain = openshiftService.createDomain(domainName, sshKey);
-
- assertNotNull(domain);
- assertEquals(domainName, domain.getName());
- assertNotNull(domain.getUser());
- User user = domain.getUser();
- assertEquals(USERNAME, user.getRhlogin());
- assertNotNull(user.getUuid());
- }
-
- @Test
- public void canChangeDomain() throws Exception {
-
- String domainName = createRandomString();
- SSHKey sshKey = TestSSHKey.create();
- Domain domain = openshiftService.changeDomain(domainName, sshKey);
-
- assertNotNull(domain);
- assertEquals(domainName, domain.getName());
- assertNotNull(domain.getUser());
- User user = domain.getUser();
- assertEquals(USERNAME, user.getRhlogin());
- assertNotNull(user.getUuid());
- }
-
- private String createRandomString() {
- return String.valueOf(System.currentTimeMillis());
- }
-}
Deleted:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/DomainTest.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/DomainTest.java 2011-09-13
12:13:05 UTC (rev 34674)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/DomainTest.java 2011-09-13
12:15:53 UTC (rev 34675)
@@ -1,124 +0,0 @@
-/*******************************************************************************
- * 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.internal.test.core;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-
-import org.jboss.ide.eclipse.as.openshift.core.Domain;
-import org.jboss.ide.eclipse.as.openshift.core.OpenshiftException;
-import org.jboss.ide.eclipse.as.openshift.core.SSHKey;
-import org.jboss.ide.eclipse.as.openshift.core.User;
-import
org.jboss.ide.eclipse.as.openshift.core.internal.marshalling.DomainRequestJsonMarshaller;
-import org.jboss.ide.eclipse.as.openshift.core.internal.request.ChangeDomainRequest;
-import org.jboss.ide.eclipse.as.openshift.core.internal.request.CreateDomainRequest;
-import
org.jboss.ide.eclipse.as.openshift.core.internal.request.OpenshiftJsonRequestFactory;
-import
org.jboss.ide.eclipse.as.openshift.core.internal.response.DomainResponseUnmarshaller;
-import org.jboss.ide.eclipse.as.openshift.core.internal.response.JsonSanitizer;
-import org.jboss.ide.eclipse.as.openshift.core.internal.response.OpenshiftResponse;
-import org.jboss.ide.eclipse.as.openshift.internal.test.core.fakes.TestSSHKey;
-import org.junit.Test;
-
-/**
- * @author André Dietisheim
- */
-public class DomainTest {
-
- private static final String USERNAME = "toolsjboss(a)gmail.com";
- private static final String PASSWORD = "1q2w3e";
- private static final String UUID = "0c82860dae904a4d87f8e5d87a5af840";
-
- @Test
- public void canMarshallDomainCreateRequest() throws IOException, OpenshiftException {
- SSHKey sshKey = TestSSHKey.create();
- String expectedRequestString = createDomainRequestString(PASSWORD, USERNAME, true,
"myDomain", false,
- sshKey.getPublicKeyContent());
-
- CreateDomainRequest request = new CreateDomainRequest("myDomain", sshKey,
USERNAME, true);
- String requestString =
- new OpenshiftJsonRequestFactory(
- PASSWORD,
- new DomainRequestJsonMarshaller().marshall(request))
- .create();
- assertEquals(expectedRequestString, requestString);
- }
-
- @Test
- public void canUnmarshallDomainCreateResponse() throws IOException, OpenshiftException
{
- String domainName = "myDomain";
- String responseString = createDomainResponseString(USERNAME, UUID);
-
- responseString = JsonSanitizer.sanitize(responseString);
- OpenshiftResponse<Domain> response = new
DomainResponseUnmarshaller(domainName).unmarshall(responseString);
-
- assertNotNull(response);
- Domain domain = response.getData();
- assertEquals(domainName, domain.getName());
- User user = domain.getUser();
- assertNotNull(user);
- assertEquals(USERNAME, user.getRhlogin());
- assertEquals(UUID, user.getUuid());
- }
-
- @Test
- public void canMarshallDomainAlterRequest() throws IOException, OpenshiftException {
- SSHKey sshKey = TestSSHKey.create();
- String expectedRequestString = createDomainRequestString(PASSWORD, USERNAME, true,
"myDomain", true,
- sshKey.getPublicKeyContent());
-
- ChangeDomainRequest request = new ChangeDomainRequest("myDomain", sshKey,
USERNAME, true);
- String requestString =
- new OpenshiftJsonRequestFactory(
- PASSWORD,
- new DomainRequestJsonMarshaller().marshall(request))
- .create();
- assertEquals(expectedRequestString, requestString);
- }
-
- private String createDomainRequestString(String password, String username, boolean
debug, String namespace,
- boolean alter, String sshPublicKey) throws UnsupportedEncodingException {
- return "password="
- + password
- + "&json_data=%7B"
- + "%22rhlogin%22+%3A+"
- + "%22"
- + URLEncoder.encode(username, "UTF-8")
- + "%22"
- + "%2C+%22debug%22+%3A+%22" + String.valueOf(debug) + "%22"
- + "%2C+%22namespace%22+%3A+%22" + URLEncoder.encode(namespace,
"UTF-8") + "%22"
- + "%2C+%22alter%22+%3A+%22" + String.valueOf(alter) + "%22"
- + "%2C+%22ssh%22+%3A+%22"
- + URLEncoder.encode(sshPublicKey, "UTF-8")
- + "%22"
- + "%7D";
- }
-
- /**
- * WARNING: the response this method returns matches the actual response
- * from the openshift service (9-12-2011). It is not valid json since it quotes the
- * nested json object
- * <p>
- * "data": "{\"rhlogin\": ...
- */
- private String createDomainResponseString(String username, String uuid) {
- return
"{\"messages\":\"\",\"debug\":\"\",\"data\":\""
- + "{\\\"rhlogin\\\":\\\""
- + username
- + "\\\",\\\"uuid\\\":\\\""
- + uuid
- + "\\\"}"
- +
"\",\"api\":\"1.1.1\",\"api_c\":[\"placeholder\"],\"result\":null,\"broker\":\"1.1.1\",\"broker_c\":[\"namespace\",\"rhlogin\",\"ssh\",\"app_uuid\",\"debug\",\"alter\",\"cartridge\",\"cart_type\",\"action\",\"app_name\",\"api\"],\"exit_code\":0}";
- }
-}
Deleted:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/ListCartridgesIntegrationTest.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/ListCartridgesIntegrationTest.java 2011-09-13
12:13:05 UTC (rev 34674)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/ListCartridgesIntegrationTest.java 2011-09-13
12:15:53 UTC (rev 34675)
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * 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.internal.test.core;
-
-import static
org.jboss.ide.eclipse.as.openshift.internal.test.core.CartridgeAsserts.assertThatContainsCartridge;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.List;
-
-import org.jboss.ide.eclipse.as.openshift.core.Cartridge;
-import org.jboss.ide.eclipse.as.openshift.core.internal.OpenshiftService;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * @author André Dietisheim
- */
-public class ListCartridgesIntegrationTest {
-
- private OpenshiftService openshiftService;
-
- private static final String USERNAME = "toolsjboss(a)gmail.com";
- private static final String PASSWORD = "1q2w3e";
-
- @Before
- public void setUp() {
- this.openshiftService = new OpenshiftService(USERNAME, PASSWORD);
- }
-
- @Test
- public void canListCartridges() throws Exception {
- List<Cartridge> cartridges = openshiftService.getCartridges();
- assertNotNull(cartridges);
- assertTrue(cartridges.size() > 0);
- assertThatContainsCartridge("jbossas-7.0", cartridges);
- }
-}
Deleted:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/ListCartridgesTest.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/ListCartridgesTest.java 2011-09-13
12:13:05 UTC (rev 34674)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/ListCartridgesTest.java 2011-09-13
12:15:53 UTC (rev 34675)
@@ -1,94 +0,0 @@
-/*******************************************************************************
- * 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.internal.test.core;
-
-import static
org.jboss.ide.eclipse.as.openshift.internal.test.core.CartridgeAsserts.assertThatContainsCartridge;
-import static org.junit.Assert.assertEquals;
-
-import java.net.URLEncoder;
-import java.util.List;
-
-import org.jboss.ide.eclipse.as.openshift.core.Cartridge;
-import org.jboss.ide.eclipse.as.openshift.core.OpenshiftException;
-import
org.jboss.ide.eclipse.as.openshift.core.internal.marshalling.ListCartridgesRequestJsonMarshaller;
-import org.jboss.ide.eclipse.as.openshift.core.internal.request.ListCartridgesRequest;
-import
org.jboss.ide.eclipse.as.openshift.core.internal.request.OpenshiftJsonRequestFactory;
-import org.jboss.ide.eclipse.as.openshift.core.internal.response.JsonSanitizer;
-import
org.jboss.ide.eclipse.as.openshift.core.internal.response.ListCartridgesResponseUnmarshaller;
-import org.jboss.ide.eclipse.as.openshift.core.internal.response.OpenshiftResponse;
-import org.junit.Test;
-
-/**
- * @author André Dietisheim
- */
-public class ListCartridgesTest {
-
- private static final String USERNAME = "toolsjboss(a)gmail.com";
- private static final String PASSWORD = "1q2w3e";
-
- @Test
- public void canMarshallListCartridgesRequest() throws Exception {
- String expectedRequestString = "password=" + PASSWORD +
"&json_data=%7B%22rhlogin%22+%3A+%22"
- + URLEncoder.encode(USERNAME, "UTF-8")
- +
"%22%2C+%22debug%22+%3A+%22true%22%2C+%22cart_type%22+%3A+%22standalone%22%7D";
-
- String listCartridgeRequest = new ListCartridgesRequestJsonMarshaller().marshall(
- new ListCartridgesRequest(USERNAME, true));
- String effectiveRequest = new OpenshiftJsonRequestFactory(PASSWORD,
listCartridgeRequest).create();
-
- assertEquals(expectedRequestString, effectiveRequest);
- }
-
- @Test
- public void canUnmarshallCartridgeListResponse() throws OpenshiftException {
- String cartridgeListResponse =
- "{"
- + "\"messages\":\"\","
- + "\"debug\":\"\","
- + "\"data\":"
- +
"\"{\\\"carts\\\":[\\\"perl-5.10\\\",\\\"jbossas-7.0\\\",\\\"wsgi-3.2\\\",\\\"rack-1.1\\\",\\\"php-5.3\\\"]}\","
- + "\"api\":\"1.1.1\","
- + "\"api_c\":[\"placeholder\"],"
- + "\"result\":null,"
- + "\"broker\":\"1.1.1\","
- + "\"broker_c\":["
- + "\"namespace\","
- + "\"rhlogin\","
- + "\"ssh\","
- + "\"app_uuid\","
- + "\"debug\","
- + "\"alter\","
- + "\"cartridge\","
- + "\"cart_type\","
- + "\"action\","
- + "\"app_name\","
- + "\"api"
- + "\"],"
- + "\"exit_code\":0}";
-
- cartridgeListResponse = JsonSanitizer.sanitize(cartridgeListResponse);
- OpenshiftResponse<List<Cartridge>> response =
- new ListCartridgesResponseUnmarshaller().unmarshall(cartridgeListResponse);
- assertEquals("", response.getMessages());
- assertEquals(false, response.isDebug());
-
- List<Cartridge> cartridges = response.getData();
- assertEquals(5, cartridges.size());
- assertThatContainsCartridge("perl-5.10", cartridges);
- assertThatContainsCartridge("jbossas-7.0", cartridges);
- assertThatContainsCartridge("wsgi-3.2", cartridges);
- assertThatContainsCartridge("rack-1.1", cartridges);
- assertThatContainsCartridge("php-5.3", cartridges);
- assertEquals(null, response.getResult());
- assertEquals(0, response.getExitCode());
- }
-
-}
Deleted:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/OpenshiftIntegrationTestSuite.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/OpenshiftIntegrationTestSuite.java 2011-09-13
12:13:05 UTC (rev 34674)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/OpenshiftIntegrationTestSuite.java 2011-09-13
12:15:53 UTC (rev 34675)
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * 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.internal.test.core;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-
-(a)RunWith(Suite.class)
-(a)Suite.SuiteClasses({
- ApplicationIntegrationTest.class,
- CartridgesIntegrationTest.class,
- DomainIntegrationTest.class,
- ListCartridgesIntegrationTest.class
-})
-/**
- * @author André Dietisheim
- */
-public class OpenshiftIntegrationTestSuite {
-
-}
Deleted:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/OpenshiftTestSuite.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/OpenshiftTestSuite.java 2011-09-13
12:13:05 UTC (rev 34674)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/OpenshiftTestSuite.java 2011-09-13
12:15:53 UTC (rev 34675)
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * 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.internal.test.core;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-
-(a)RunWith(Suite.class)
-(a)Suite.SuiteClasses({
- ApplicationTest.class,
- ListCartridgesTest.class,
- DomainTest.class,
- UserInfoTest.class
-})
-/**
- * @author André Dietisheim
- */
-public class OpenshiftTestSuite {
-
-}
Deleted:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/SSHKeyTest.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/SSHKeyTest.java 2011-09-13
12:13:05 UTC (rev 34674)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/SSHKeyTest.java 2011-09-13
12:15:53 UTC (rev 34675)
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * 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.internal.test.core;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.IOException;
-
-import org.jboss.ide.eclipse.as.openshift.core.SSHKey;
-import org.junit.Test;
-
-public class SSHKeyTest {
-
- private static final String PASSPHRASE = "12345";
-
- @Test
- public void canCreatePublicKey() throws Exception {
- String publicKeyPath = createTempFile().getAbsolutePath();
- String privateKeyPath = createTempFile().getAbsolutePath();
- SSHKey sshKey = SSHKey.create(PASSPHRASE, privateKeyPath, publicKeyPath);
- String publicKey = sshKey.getPublicKeyContent();
-
- assertNotNull(publicKey);
- assertTrue(!publicKey.contains("ssh-rsa")); // no identifier
- assertTrue(!publicKey.contains(" ")); // no comment
- }
-
- @Test
- public void canLoadPublicKey() throws Exception {
- String publicKeyPath = createTempFile().getAbsolutePath();
- String privateKeyPath = createTempFile().getAbsolutePath();
- SSHKey.create(PASSPHRASE, privateKeyPath, publicKeyPath);
-
- SSHKey sshKey = SSHKey.load(privateKeyPath, publicKeyPath);
- String publicKey = sshKey.getPublicKeyContent();
-
- assertNotNull(publicKey);
- assertTrue(!publicKey.contains("ssh-rsa")); // no identifier
- assertTrue(!publicKey.contains(" ")); // no comment
- }
-
- private File createTempFile() throws IOException {
- return File.createTempFile(String.valueOf(System.currentTimeMillis()), null);
- }
-}
Deleted:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/UserInfoTest.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/UserInfoTest.java 2011-09-13
12:13:05 UTC (rev 34674)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/UserInfoTest.java 2011-09-13
12:15:53 UTC (rev 34675)
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * 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.internal.test.core;
-
-import static org.junit.Assert.assertEquals;
-
-import java.net.URLEncoder;
-
-import
org.jboss.ide.eclipse.as.openshift.core.internal.marshalling.UserInfoRequestJsonMarshaller;
-import
org.jboss.ide.eclipse.as.openshift.core.internal.request.OpenshiftJsonRequestFactory;
-import org.jboss.ide.eclipse.as.openshift.core.internal.request.UserInfoRequest;
-import org.junit.Test;
-
-/**
- * @author André Dietisheim
- */
-public class UserInfoTest {
-
- private static final String USERNAME = "toolsjboss(a)gmail.com";
- private static final String PASSWORD = "1q2w3e";
-
- @Test
- public void canMarshallUserInfoRequest() throws Exception {
- String expectedRequestString =
- "password=" + PASSWORD
- + "&json_data=%7B"
- + "%22rhlogin%22+%3A+%22" + URLEncoder.encode(USERNAME,
"UTF-8") + "%22%2C+"
- + "%22debug%22+%3A+%22true%22"
- + "%7D";
-
- String userInfoRequest = new UserInfoRequestJsonMarshaller().marshall(new
UserInfoRequest(USERNAME, true));
- String effectiveRequest = new OpenshiftJsonRequestFactory(PASSWORD,
userInfoRequest).create();
-
- assertEquals(expectedRequestString, effectiveRequest);
- }
-}
Copied:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/Activator.java
(from rev 34670,
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/Activator.java)
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/Activator.java
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/Activator.java 2011-09-13
12:15:53 UTC (rev 34675)
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * 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 org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator implements BundleActivator {
+
+ private static BundleContext context;
+
+ static BundleContext getContext() {
+ return context;
+ }
+
+ public void start(BundleContext bundleContext) throws Exception {
+ Activator.context = bundleContext;
+ }
+
+ public void stop(BundleContext bundleContext) throws Exception {
+ Activator.context = null;
+ }
+
+}
Copied:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/ApplicationIntegrationTest.java
(from rev 34674,
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/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
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/ApplicationIntegrationTest.java 2011-09-13
12:15:53 UTC (rev 34675)
@@ -0,0 +1,188 @@
+/*******************************************************************************
+ * 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.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.jboss.ide.eclipse.as.openshift.core.Application;
+import org.jboss.ide.eclipse.as.openshift.core.Cartridge;
+import org.jboss.ide.eclipse.as.openshift.core.IOpenshiftService;
+import org.jboss.ide.eclipse.as.openshift.core.InvalidCredentialsOpenshiftException;
+import org.jboss.ide.eclipse.as.openshift.core.OpenshiftException;
+import org.jboss.ide.eclipse.as.openshift.core.Status;
+import org.jboss.ide.eclipse.as.openshift.core.internal.OpenshiftService;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * @author André Dietisheim
+ */
+public class ApplicationIntegrationTest {
+
+ private IOpenshiftService openshiftService;
+ private IOpenshiftService invalidCredentialsOpenshiftService;
+
+ private static final String USERNAME = "toolsjboss(a)gmail.com";
+ private static final String PASSWORD = "1q2w3e";
+
+ @Before
+ public void setUp() {
+ this.openshiftService = new OpenshiftService(USERNAME, PASSWORD);
+ this.invalidCredentialsOpenshiftService = new OpenshiftService(USERNAME,
"bogus");
+ }
+
+ @Ignore
+ @Test(expected = InvalidCredentialsOpenshiftException.class)
+ public void createApplicationWithInvalidCredentialsThrowsException() throws Exception {
+ invalidCredentialsOpenshiftService.createApplication(createRandomApplicationName(),
Cartridge.JBOSSAS_7);
+ }
+
+ @Ignore
+ @Test
+ public void canCreateApplication() throws Exception {
+ String applicationName = createRandomApplicationName();
+ try {
+ Cartridge cartridge = Cartridge.JBOSSAS_7;
+ Application application = openshiftService.createApplication(applicationName,
cartridge);
+ assertNotNull(application);
+ assertEquals(applicationName, application.getName());
+ assertEquals(cartridge, application.getCartridge());
+ } finally {
+ silentlyDestroyApplication(applicationName, openshiftService);
+ }
+ }
+
+ @Ignore
+ @Test
+ public void canDestroyApplication() throws Exception {
+ String applicationName = createRandomApplicationName();
+ openshiftService.createApplication(applicationName, Cartridge.JBOSSAS_7);
+ openshiftService.destroyApplication(applicationName, Cartridge.JBOSSAS_7);
+ }
+
+ @Ignore
+ @Test(expected = OpenshiftException.class)
+ public void createDuplicateApplicationThrowsException() throws Exception {
+ String applicationName = createRandomApplicationName();
+ try {
+ openshiftService.createApplication(applicationName, Cartridge.JBOSSAS_7);
+ openshiftService.createApplication(applicationName, Cartridge.JBOSSAS_7);
+ } finally {
+ silentlyDestroyApplication(applicationName, openshiftService);
+ }
+ }
+
+ @Ignore
+ @Test
+ public void canStopApplication() throws Exception {
+ String applicationName = createRandomApplicationName();
+ try {
+ openshiftService.createApplication(applicationName, Cartridge.JBOSSAS_7);
+ openshiftService.stopApplication(applicationName, Cartridge.JBOSSAS_7);
+ } finally {
+ silentlyDestroyApplication(applicationName, openshiftService);
+ }
+ }
+
+ @Ignore
+ @Test
+ public void canStartStoppedApplication() throws Exception {
+ String applicationName = createRandomApplicationName();
+ try {
+ openshiftService.createApplication(applicationName, Cartridge.JBOSSAS_7);
+ openshiftService.stopApplication(applicationName, Cartridge.JBOSSAS_7);
+ openshiftService.startApplication(applicationName, Cartridge.JBOSSAS_7);
+ } finally {
+ silentlyDestroyApplication(applicationName, openshiftService);
+ }
+ }
+
+ @Ignore
+ @Test
+ public void canStartStartedApplication() throws Exception {
+ String applicationName = createRandomApplicationName();
+ try {
+ /**
+ * freshly created apps are started
+ *
+ * @link
+ *
https://github.com/openshift/os-client-tools/blob/master/express/doc/API
+ */
+ openshiftService.createApplication(applicationName, Cartridge.JBOSSAS_7);
+ openshiftService.startApplication(applicationName, Cartridge.JBOSSAS_7);
+ } finally {
+ silentlyDestroyApplication(applicationName, openshiftService);
+ }
+ }
+
+ @Ignore
+ @Test
+ public void canStopStoppedApplication() throws Exception {
+ String applicationName = createRandomApplicationName();
+ try {
+ /**
+ * freshly created apps are started
+ *
+ * @link
+ *
https://github.com/openshift/os-client-tools/blob/master/express/doc/API
+ */
+ openshiftService.createApplication(applicationName, Cartridge.JBOSSAS_7);
+ openshiftService.stopApplication(applicationName, Cartridge.JBOSSAS_7);
+ openshiftService.stopApplication(applicationName, Cartridge.JBOSSAS_7);
+ } finally {
+ silentlyDestroyApplication(applicationName, openshiftService);
+ }
+ }
+
+ @Ignore
+ @Test
+ public void canRestartApplication() throws Exception {
+ String applicationName = createRandomApplicationName();
+ try {
+ /**
+ * freshly created apps are started
+ *
+ * @link
+ *
https://github.com/openshift/os-client-tools/blob/master/express/doc/API
+ */
+ openshiftService.createApplication(applicationName, Cartridge.JBOSSAS_7);
+ openshiftService.restartApplication(applicationName, Cartridge.JBOSSAS_7);
+ } finally {
+ silentlyDestroyApplication(applicationName, openshiftService);
+ }
+ }
+
+ @Test
+ public void canGetStatus() throws Exception {
+ String applicationName = createRandomApplicationName();
+ try {
+ Application application = openshiftService.createApplication(applicationName,
Cartridge.JBOSSAS_7);
+ Status status = openshiftService.getStatus(application);
+ assertNotNull(status);
+ } finally {
+ silentlyDestroyApplication(applicationName, openshiftService);
+ }
+ }
+
+ private String createRandomApplicationName() {
+ return String.valueOf(System.currentTimeMillis());
+ }
+
+ private void silentlyDestroyApplication(String name, IOpenshiftService service) {
+ try {
+ service.destroyApplication(name, Cartridge.JBOSSAS_7);
+ } catch (OpenshiftException e) {
+ e.printStackTrace();
+ }
+ }
+}
Copied:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/ApplicationTest.java
(from rev 34674,
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/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
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/ApplicationTest.java 2011-09-13
12:15:53 UTC (rev 34675)
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * 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.junit.Assert.assertEquals;
+
+import java.net.URLEncoder;
+
+import org.jboss.ide.eclipse.as.openshift.core.Cartridge;
+import
org.jboss.ide.eclipse.as.openshift.core.internal.marshalling.ApplicationRequestJsonMarshaller;
+import org.jboss.ide.eclipse.as.openshift.core.internal.request.ApplicationAction;
+import org.jboss.ide.eclipse.as.openshift.core.internal.request.ApplicationRequest;
+import
org.jboss.ide.eclipse.as.openshift.core.internal.request.OpenshiftJsonRequestFactory;
+import org.junit.Test;
+
+/**
+ * @author André Dietisheim
+ */
+public class ApplicationTest {
+
+ private static final String USERNAME = "toolsjboss(a)gmail.com";
+ private static final String PASSWORD = "1q2w3e";
+
+ @Test
+ public void canMarshallApplicationCreateRequest() throws Exception {
+ String expectedRequestString =
+ "password="
+ + PASSWORD
+ + "&json_data=%7B"
+ + "%22rhlogin%22+%3A+%22"
+ + URLEncoder.encode(USERNAME, "UTF-8")
+ + "%22"
+ + "%2C+%22debug%22+%3A+%22true%22"
+ + "%2C+%22cartridge%22+%3A+%22jbossas-7.0%22"
+ + "%2C+%22action%22+%3A+%22configure%22"
+ + "%2C+%22app_name%22+%3A+%22test-application%22"
+ + "%7D";
+
+ String createApplicationRequest = new ApplicationRequestJsonMarshaller().marshall(
+ new ApplicationRequest(
+ "test-application", Cartridge.JBOSSAS_7, ApplicationAction.CONFIGURE,
USERNAME, true));
+ String effectiveRequest = new OpenshiftJsonRequestFactory(PASSWORD,
createApplicationRequest).create();
+
+ assertEquals(expectedRequestString, effectiveRequest);
+ }
+
+ @Test
+ public void canMarshallApplicationDestroyRequest() throws Exception {
+ String expectedRequestString =
+ "password="
+ + PASSWORD
+ + "&json_data=%7B"
+ + "%22rhlogin%22+%3A+"
+ + "%22" + URLEncoder.encode(USERNAME, "UTF-8") +
"%22"
+ + "%2C+%22debug%22+%3A+%22true%22"
+ + "%2C+%22cartridge%22+%3A+%22jbossas-7.0%22"
+ + "%2C+%22action%22+%3A+%22deconfigure%22"
+ + "%2C+%22app_name%22+%3A+%22test-application%22"
+ + "%7D";
+
+ String createApplicationRequest = new ApplicationRequestJsonMarshaller().marshall(
+ new ApplicationRequest(
+ "test-application", Cartridge.JBOSSAS_7, ApplicationAction.DECONFIGURE,
USERNAME, true));
+ String effectiveRequest = new OpenshiftJsonRequestFactory(PASSWORD,
createApplicationRequest).create();
+
+ assertEquals(expectedRequestString, effectiveRequest);
+ }
+}
Copied:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/CartridgeAsserts.java
(from rev 34670,
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/CartridgeAsserts.java)
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/CartridgeAsserts.java
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/CartridgeAsserts.java 2011-09-13
12:15:53 UTC (rev 34675)
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * 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.junit.Assert.fail;
+
+import java.text.MessageFormat;
+import java.util.List;
+
+import org.jboss.ide.eclipse.as.openshift.core.Cartridge;
+
+public class CartridgeAsserts {
+
+ public static void assertThatContainsCartridge(String cartridgeName,
List<Cartridge> cartridges) {
+ boolean found = false;
+ for (Cartridge cartridge : cartridges) {
+ if (cartridgeName.equals(cartridge.getName())) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ fail(MessageFormat.format("Could not find cartridge with name
\"{0}\"", cartridgeName));
+ }
+ }
+
+
+}
Copied:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/CartridgesIntegrationTest.java
(from rev 34674,
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/CartridgesIntegrationTest.java)
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/CartridgesIntegrationTest.java
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/CartridgesIntegrationTest.java 2011-09-13
12:15:53 UTC (rev 34675)
@@ -0,0 +1,33 @@
+package org.jboss.ide.eclipse.as.openshift.test.internal.core;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+
+import org.jboss.ide.eclipse.as.openshift.core.Cartridge;
+import org.jboss.ide.eclipse.as.openshift.core.internal.OpenshiftService;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class CartridgesIntegrationTest {
+
+ private OpenshiftService openshiftService;
+
+ private static final String USERNAME = "toolsjboss(a)gmail.com";
+ private static final String PASSWORD = "1q2w3e";
+
+ @Before
+ public void setUp() {
+ this.openshiftService = new OpenshiftService(USERNAME, PASSWORD);
+ }
+
+ @Ignore
+ @Test
+ public void canRequestListCartridges() throws Exception {
+ List<Cartridge> cartridges = openshiftService.getCartridges();
+ assertNotNull(cartridges);
+ assertTrue(cartridges.size() > 0);
+ }
+}
Copied:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/DomainIntegrationTest.java
(from rev 34674,
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/DomainIntegrationTest.java)
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/DomainIntegrationTest.java
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/DomainIntegrationTest.java 2011-09-13
12:15:53 UTC (rev 34675)
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * 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.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.jboss.ide.eclipse.as.openshift.core.Domain;
+import org.jboss.ide.eclipse.as.openshift.core.SSHKey;
+import org.jboss.ide.eclipse.as.openshift.core.User;
+import org.jboss.ide.eclipse.as.openshift.core.internal.OpenshiftService;
+import org.jboss.ide.eclipse.as.openshift.test.internal.core.fakes.TestSSHKey;
+import org.junit.Before;
+import org.junit.Test;
+
+public class DomainIntegrationTest {
+
+ private OpenshiftService openshiftService;
+
+ private static final String USERNAME = "toolsjboss(a)gmail.com";
+ private static final String PASSWORD = "1q2w3e";
+
+ @Before
+ public void setUp() {
+ this.openshiftService = new OpenshiftService(USERNAME, PASSWORD);
+ }
+
+ @Test
+ public void canCreateDomain() throws Exception {
+
+ String domainName = createRandomString();
+ SSHKey sshKey = TestSSHKey.create();
+ Domain domain = openshiftService.createDomain(domainName, sshKey);
+
+ assertNotNull(domain);
+ assertEquals(domainName, domain.getName());
+ assertNotNull(domain.getUser());
+ User user = domain.getUser();
+ assertEquals(USERNAME, user.getRhlogin());
+ assertNotNull(user.getUuid());
+ }
+
+ @Test
+ public void canChangeDomain() throws Exception {
+
+ String domainName = createRandomString();
+ SSHKey sshKey = TestSSHKey.create();
+ Domain domain = openshiftService.changeDomain(domainName, sshKey);
+
+ assertNotNull(domain);
+ assertEquals(domainName, domain.getName());
+ assertNotNull(domain.getUser());
+ User user = domain.getUser();
+ assertEquals(USERNAME, user.getRhlogin());
+ assertNotNull(user.getUuid());
+ }
+
+ private String createRandomString() {
+ return String.valueOf(System.currentTimeMillis());
+ }
+}
Copied:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/DomainTest.java
(from rev 34674,
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/DomainTest.java)
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/DomainTest.java
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/DomainTest.java 2011-09-13
12:15:53 UTC (rev 34675)
@@ -0,0 +1,124 @@
+/*******************************************************************************
+ * 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.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+
+import org.jboss.ide.eclipse.as.openshift.core.Domain;
+import org.jboss.ide.eclipse.as.openshift.core.OpenshiftException;
+import org.jboss.ide.eclipse.as.openshift.core.SSHKey;
+import org.jboss.ide.eclipse.as.openshift.core.User;
+import
org.jboss.ide.eclipse.as.openshift.core.internal.marshalling.DomainRequestJsonMarshaller;
+import org.jboss.ide.eclipse.as.openshift.core.internal.request.ChangeDomainRequest;
+import org.jboss.ide.eclipse.as.openshift.core.internal.request.CreateDomainRequest;
+import
org.jboss.ide.eclipse.as.openshift.core.internal.request.OpenshiftJsonRequestFactory;
+import
org.jboss.ide.eclipse.as.openshift.core.internal.response.DomainResponseUnmarshaller;
+import org.jboss.ide.eclipse.as.openshift.core.internal.response.JsonSanitizer;
+import org.jboss.ide.eclipse.as.openshift.core.internal.response.OpenshiftResponse;
+import org.jboss.ide.eclipse.as.openshift.test.internal.core.fakes.TestSSHKey;
+import org.junit.Test;
+
+/**
+ * @author André Dietisheim
+ */
+public class DomainTest {
+
+ private static final String USERNAME = "toolsjboss(a)gmail.com";
+ private static final String PASSWORD = "1q2w3e";
+ private static final String UUID = "0c82860dae904a4d87f8e5d87a5af840";
+
+ @Test
+ public void canMarshallDomainCreateRequest() throws IOException, OpenshiftException {
+ SSHKey sshKey = TestSSHKey.create();
+ String expectedRequestString = createDomainRequestString(PASSWORD, USERNAME, true,
"myDomain", false,
+ sshKey.getPublicKeyContent());
+
+ CreateDomainRequest request = new CreateDomainRequest("myDomain", sshKey,
USERNAME, true);
+ String requestString =
+ new OpenshiftJsonRequestFactory(
+ PASSWORD,
+ new DomainRequestJsonMarshaller().marshall(request))
+ .create();
+ assertEquals(expectedRequestString, requestString);
+ }
+
+ @Test
+ public void canUnmarshallDomainCreateResponse() throws IOException, OpenshiftException
{
+ String domainName = "myDomain";
+ String responseString = createDomainResponseString(USERNAME, UUID);
+
+ responseString = JsonSanitizer.sanitize(responseString);
+ OpenshiftResponse<Domain> response = new
DomainResponseUnmarshaller(domainName).unmarshall(responseString);
+
+ assertNotNull(response);
+ Domain domain = response.getData();
+ assertEquals(domainName, domain.getName());
+ User user = domain.getUser();
+ assertNotNull(user);
+ assertEquals(USERNAME, user.getRhlogin());
+ assertEquals(UUID, user.getUuid());
+ }
+
+ @Test
+ public void canMarshallDomainAlterRequest() throws IOException, OpenshiftException {
+ SSHKey sshKey = TestSSHKey.create();
+ String expectedRequestString = createDomainRequestString(PASSWORD, USERNAME, true,
"myDomain", true,
+ sshKey.getPublicKeyContent());
+
+ ChangeDomainRequest request = new ChangeDomainRequest("myDomain", sshKey,
USERNAME, true);
+ String requestString =
+ new OpenshiftJsonRequestFactory(
+ PASSWORD,
+ new DomainRequestJsonMarshaller().marshall(request))
+ .create();
+ assertEquals(expectedRequestString, requestString);
+ }
+
+ private String createDomainRequestString(String password, String username, boolean
debug, String namespace,
+ boolean alter, String sshPublicKey) throws UnsupportedEncodingException {
+ return "password="
+ + password
+ + "&json_data=%7B"
+ + "%22rhlogin%22+%3A+"
+ + "%22"
+ + URLEncoder.encode(username, "UTF-8")
+ + "%22"
+ + "%2C+%22debug%22+%3A+%22" + String.valueOf(debug) + "%22"
+ + "%2C+%22namespace%22+%3A+%22" + URLEncoder.encode(namespace,
"UTF-8") + "%22"
+ + "%2C+%22alter%22+%3A+%22" + String.valueOf(alter) + "%22"
+ + "%2C+%22ssh%22+%3A+%22"
+ + URLEncoder.encode(sshPublicKey, "UTF-8")
+ + "%22"
+ + "%7D";
+ }
+
+ /**
+ * WARNING: the response this method returns matches the actual response
+ * from the openshift service (9-12-2011). It is not valid json since it quotes the
+ * nested json object
+ * <p>
+ * "data": "{\"rhlogin\": ...
+ */
+ private String createDomainResponseString(String username, String uuid) {
+ return
"{\"messages\":\"\",\"debug\":\"\",\"data\":\""
+ + "{\\\"rhlogin\\\":\\\""
+ + username
+ + "\\\",\\\"uuid\\\":\\\""
+ + uuid
+ + "\\\"}"
+ +
"\",\"api\":\"1.1.1\",\"api_c\":[\"placeholder\"],\"result\":null,\"broker\":\"1.1.1\",\"broker_c\":[\"namespace\",\"rhlogin\",\"ssh\",\"app_uuid\",\"debug\",\"alter\",\"cartridge\",\"cart_type\",\"action\",\"app_name\",\"api\"],\"exit_code\":0}";
+ }
+}
Copied:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/ListCartridgesIntegrationTest.java
(from rev 34674,
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/ListCartridgesIntegrationTest.java)
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/ListCartridgesIntegrationTest.java
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/ListCartridgesIntegrationTest.java 2011-09-13
12:15:53 UTC (rev 34675)
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * 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.CartridgeAsserts.assertThatContainsCartridge;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+
+import org.jboss.ide.eclipse.as.openshift.core.Cartridge;
+import org.jboss.ide.eclipse.as.openshift.core.internal.OpenshiftService;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author André Dietisheim
+ */
+public class ListCartridgesIntegrationTest {
+
+ private OpenshiftService openshiftService;
+
+ private static final String USERNAME = "toolsjboss(a)gmail.com";
+ private static final String PASSWORD = "1q2w3e";
+
+ @Before
+ public void setUp() {
+ this.openshiftService = new OpenshiftService(USERNAME, PASSWORD);
+ }
+
+ @Test
+ public void canListCartridges() throws Exception {
+ List<Cartridge> cartridges = openshiftService.getCartridges();
+ assertNotNull(cartridges);
+ assertTrue(cartridges.size() > 0);
+ assertThatContainsCartridge("jbossas-7.0", cartridges);
+ }
+}
Copied:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/ListCartridgesTest.java
(from rev 34674,
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/ListCartridgesTest.java)
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/ListCartridgesTest.java
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/ListCartridgesTest.java 2011-09-13
12:15:53 UTC (rev 34675)
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * 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.CartridgeAsserts.assertThatContainsCartridge;
+import static org.junit.Assert.assertEquals;
+
+import java.net.URLEncoder;
+import java.util.List;
+
+import org.jboss.ide.eclipse.as.openshift.core.Cartridge;
+import org.jboss.ide.eclipse.as.openshift.core.OpenshiftException;
+import
org.jboss.ide.eclipse.as.openshift.core.internal.marshalling.ListCartridgesRequestJsonMarshaller;
+import org.jboss.ide.eclipse.as.openshift.core.internal.request.ListCartridgesRequest;
+import
org.jboss.ide.eclipse.as.openshift.core.internal.request.OpenshiftJsonRequestFactory;
+import org.jboss.ide.eclipse.as.openshift.core.internal.response.JsonSanitizer;
+import
org.jboss.ide.eclipse.as.openshift.core.internal.response.ListCartridgesResponseUnmarshaller;
+import org.jboss.ide.eclipse.as.openshift.core.internal.response.OpenshiftResponse;
+import org.junit.Test;
+
+/**
+ * @author André Dietisheim
+ */
+public class ListCartridgesTest {
+
+ private static final String USERNAME = "toolsjboss(a)gmail.com";
+ private static final String PASSWORD = "1q2w3e";
+
+ @Test
+ public void canMarshallListCartridgesRequest() throws Exception {
+ String expectedRequestString = "password=" + PASSWORD +
"&json_data=%7B%22rhlogin%22+%3A+%22"
+ + URLEncoder.encode(USERNAME, "UTF-8")
+ +
"%22%2C+%22debug%22+%3A+%22true%22%2C+%22cart_type%22+%3A+%22standalone%22%7D";
+
+ String listCartridgeRequest = new ListCartridgesRequestJsonMarshaller().marshall(
+ new ListCartridgesRequest(USERNAME, true));
+ String effectiveRequest = new OpenshiftJsonRequestFactory(PASSWORD,
listCartridgeRequest).create();
+
+ assertEquals(expectedRequestString, effectiveRequest);
+ }
+
+ @Test
+ public void canUnmarshallCartridgeListResponse() throws OpenshiftException {
+ String cartridgeListResponse =
+ "{"
+ + "\"messages\":\"\","
+ + "\"debug\":\"\","
+ + "\"data\":"
+ +
"\"{\\\"carts\\\":[\\\"perl-5.10\\\",\\\"jbossas-7.0\\\",\\\"wsgi-3.2\\\",\\\"rack-1.1\\\",\\\"php-5.3\\\"]}\","
+ + "\"api\":\"1.1.1\","
+ + "\"api_c\":[\"placeholder\"],"
+ + "\"result\":null,"
+ + "\"broker\":\"1.1.1\","
+ + "\"broker_c\":["
+ + "\"namespace\","
+ + "\"rhlogin\","
+ + "\"ssh\","
+ + "\"app_uuid\","
+ + "\"debug\","
+ + "\"alter\","
+ + "\"cartridge\","
+ + "\"cart_type\","
+ + "\"action\","
+ + "\"app_name\","
+ + "\"api"
+ + "\"],"
+ + "\"exit_code\":0}";
+
+ cartridgeListResponse = JsonSanitizer.sanitize(cartridgeListResponse);
+ OpenshiftResponse<List<Cartridge>> response =
+ new ListCartridgesResponseUnmarshaller().unmarshall(cartridgeListResponse);
+ assertEquals("", response.getMessages());
+ assertEquals(false, response.isDebug());
+
+ List<Cartridge> cartridges = response.getData();
+ assertEquals(5, cartridges.size());
+ assertThatContainsCartridge("perl-5.10", cartridges);
+ assertThatContainsCartridge("jbossas-7.0", cartridges);
+ assertThatContainsCartridge("wsgi-3.2", cartridges);
+ assertThatContainsCartridge("rack-1.1", cartridges);
+ assertThatContainsCartridge("php-5.3", cartridges);
+ assertEquals(null, response.getResult());
+ assertEquals(0, response.getExitCode());
+ }
+
+}
Copied:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/OpenshiftIntegrationTestSuite.java
(from rev 34670,
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/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
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/OpenshiftIntegrationTestSuite.java 2011-09-13
12:15:53 UTC (rev 34675)
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * 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 org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+
+(a)RunWith(Suite.class)
+(a)Suite.SuiteClasses({
+ ApplicationIntegrationTest.class,
+ CartridgesIntegrationTest.class,
+ DomainIntegrationTest.class,
+ ListCartridgesIntegrationTest.class
+})
+/**
+ * @author André Dietisheim
+ */
+public class OpenshiftIntegrationTestSuite {
+
+}
Copied:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/OpenshiftTestSuite.java
(from rev 34670,
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/OpenshiftTestSuite.java)
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/OpenshiftTestSuite.java
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/OpenshiftTestSuite.java 2011-09-13
12:15:53 UTC (rev 34675)
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * 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 org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+
+(a)RunWith(Suite.class)
+(a)Suite.SuiteClasses({
+ ApplicationTest.class,
+ ListCartridgesTest.class,
+ DomainTest.class,
+ UserInfoTest.class
+})
+/**
+ * @author André Dietisheim
+ */
+public class OpenshiftTestSuite {
+
+}
Copied:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/SSHKeyTest.java
(from rev 34670,
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/SSHKeyTest.java)
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/SSHKeyTest.java
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/SSHKeyTest.java 2011-09-13
12:15:53 UTC (rev 34675)
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * 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.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.jboss.ide.eclipse.as.openshift.core.SSHKey;
+import org.junit.Test;
+
+public class SSHKeyTest {
+
+ private static final String PASSPHRASE = "12345";
+
+ @Test
+ public void canCreatePublicKey() throws Exception {
+ String publicKeyPath = createTempFile().getAbsolutePath();
+ String privateKeyPath = createTempFile().getAbsolutePath();
+ SSHKey sshKey = SSHKey.create(PASSPHRASE, privateKeyPath, publicKeyPath);
+ String publicKey = sshKey.getPublicKeyContent();
+
+ assertNotNull(publicKey);
+ assertTrue(!publicKey.contains("ssh-rsa")); // no identifier
+ assertTrue(!publicKey.contains(" ")); // no comment
+ }
+
+ @Test
+ public void canLoadPublicKey() throws Exception {
+ String publicKeyPath = createTempFile().getAbsolutePath();
+ String privateKeyPath = createTempFile().getAbsolutePath();
+ SSHKey.create(PASSPHRASE, privateKeyPath, publicKeyPath);
+
+ SSHKey sshKey = SSHKey.load(privateKeyPath, publicKeyPath);
+ String publicKey = sshKey.getPublicKeyContent();
+
+ assertNotNull(publicKey);
+ assertTrue(!publicKey.contains("ssh-rsa")); // no identifier
+ assertTrue(!publicKey.contains(" ")); // no comment
+ }
+
+ private File createTempFile() throws IOException {
+ return File.createTempFile(String.valueOf(System.currentTimeMillis()), null);
+ }
+}
Copied:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/UserInfoTest.java
(from rev 34674,
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/UserInfoTest.java)
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/UserInfoTest.java
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/UserInfoTest.java 2011-09-13
12:15:53 UTC (rev 34675)
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * 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.junit.Assert.assertEquals;
+
+import java.net.URLEncoder;
+
+import
org.jboss.ide.eclipse.as.openshift.core.internal.marshalling.UserInfoRequestJsonMarshaller;
+import
org.jboss.ide.eclipse.as.openshift.core.internal.request.OpenshiftJsonRequestFactory;
+import org.jboss.ide.eclipse.as.openshift.core.internal.request.UserInfoRequest;
+import org.junit.Test;
+
+/**
+ * @author André Dietisheim
+ */
+public class UserInfoTest {
+
+ private static final String USERNAME = "toolsjboss(a)gmail.com";
+ private static final String PASSWORD = "1q2w3e";
+
+ @Test
+ public void canMarshallUserInfoRequest() throws Exception {
+ String expectedRequestString =
+ "password=" + PASSWORD
+ + "&json_data=%7B"
+ + "%22rhlogin%22+%3A+%22" + URLEncoder.encode(USERNAME,
"UTF-8") + "%22%2C+"
+ + "%22debug%22+%3A+%22true%22"
+ + "%7D";
+
+ String userInfoRequest = new UserInfoRequestJsonMarshaller().marshall(new
UserInfoRequest(USERNAME, true));
+ String effectiveRequest = new OpenshiftJsonRequestFactory(PASSWORD,
userInfoRequest).create();
+
+ assertEquals(expectedRequestString, effectiveRequest);
+ }
+}
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/fakes/TestSSHKey.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/fakes/TestSSHKey.java 2011-09-13
11:53:25 UTC (rev 34670)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/fakes/TestSSHKey.java 2011-09-13
12:15:53 UTC (rev 34675)
@@ -8,14 +8,14 @@
* Contributors:
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
-package org.jboss.ide.eclipse.as.openshift.internal.test.core.fakes;
+package org.jboss.ide.eclipse.as.openshift.test.internal.core.fakes;
import java.io.File;
import java.io.IOException;
import org.jboss.ide.eclipse.as.openshift.core.OpenshiftException;
import org.jboss.ide.eclipse.as.openshift.core.SSHKey;
-import org.jboss.ide.eclipse.as.openshift.internal.test.core.utils.StreamUtils;
+import org.jboss.ide.eclipse.as.openshift.test.internal.core.utils.StreamUtils;
/**
* @author André Dietisheim
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/utils/StreamUtils.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/utils/StreamUtils.java 2011-09-13
11:53:25 UTC (rev 34670)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/internal/core/utils/StreamUtils.java 2011-09-13
12:15:53 UTC (rev 34675)
@@ -8,7 +8,7 @@
* Contributors:
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
-package org.jboss.ide.eclipse.as.openshift.internal.test.core.utils;
+package org.jboss.ide.eclipse.as.openshift.test.internal.core.utils;
import java.io.File;
import java.io.FileWriter;