Author: adietish
Date: 2011-09-08 04:56:04 -0400 (Thu, 08 Sep 2011)
New Revision: 34578
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/BadRequestException.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/UrlConnectionHttpClient.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/OpenshiftServiceIntegrationTest.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/OpenshiftServiceTest.java
Log:
[JBIDE-9510] implementing destroy application request
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/BadRequestException.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/BadRequestException.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/BadRequestException.java 2011-09-08
08:56:04 UTC (rev 34578)
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * 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.core;
+
+/**
+ * @author André Dietisheim
+ */
+public class BadRequestException extends HttpClientException {
+
+ private static final long serialVersionUID = 1L;
+
+ public BadRequestException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public BadRequestException(Throwable cause) {
+ super(cause);
+ }
+}
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/BadRequestException.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/UrlConnectionHttpClient.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/UrlConnectionHttpClient.java 2011-09-08
07:47:01 UTC (rev 34577)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/UrlConnectionHttpClient.java 2011-09-08
08:56:04 UTC (rev 34578)
@@ -46,6 +46,8 @@
switch (responseCode) {
case 500:
return new InternalServerErrorException(errorMessage, ioe);
+ case 400:
+ return new BadRequestException(errorMessage, ioe);
case 401:
return new UnauthorizedException(errorMessage, ioe);
default:
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/OpenshiftServiceIntegrationTest.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/OpenshiftServiceIntegrationTest.java 2011-09-08
07:47:01 UTC (rev 34577)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/OpenshiftServiceIntegrationTest.java 2011-09-08
08:56:04 UTC (rev 34578)
@@ -1,5 +1,6 @@
package org.jboss.ide.eclipse.as.openshift.internal.test.core;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -11,13 +12,14 @@
import org.jboss.ide.eclipse.as.openshift.core.OpenshiftService;
import org.jboss.ide.eclipse.as.openshift.internal.core.Cartridge;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
public class OpenshiftServiceIntegrationTest {
private OpenshiftService openshiftService;
private OpenshiftService invalidCredentialsOpenshiftService;
-
+
private static final String USERNAME = "toolsjboss(a)gmail.com";
private static final String PASSWORD = "1q2w3e";
@@ -27,11 +29,13 @@
this.invalidCredentialsOpenshiftService = new OpenshiftService(USERNAME,
"bogus");
}
- @Test(expected=OpenshiftException.class)
+ @Ignore
+ @Test(expected = OpenshiftException.class)
public void cannotGetUserInfoIfNotAppNorDomainCreated() throws OpenshiftException {
openshiftService.getUserInfo();
}
+ @Ignore
@Test
public void canRequestListCartridges() throws Exception {
List<Cartridge> cartridges = openshiftService.getCartridges();
@@ -39,17 +43,35 @@
assertTrue(cartridges.size() > 0);
}
- @Test(expected=InvalidCredentialsOpenshiftException.class)
+ @Test(expected = InvalidCredentialsOpenshiftException.class)
public void createApplicationWithInvalidCredentialsThrowsException() throws Exception {
invalidCredentialsOpenshiftService.createApplication(createRandomApplicationName(),
Cartridge.JBOSSAS_7);
}
@Test
public void canCreateApplication() throws Exception {
- Application application =
openshiftService.createApplication("test-application", Cartridge.JBOSSAS_7);
+ String applicationName = createRandomApplicationName();
+ Cartridge cartridge = Cartridge.JBOSSAS_7;
+ Application application = openshiftService.createApplication(applicationName,
cartridge);
assertNotNull(application);
+ assertEquals(applicationName, application.getName());
+ assertEquals(cartridge, application.getCartridge());
}
-
+
+ @Test
+ public void canDestroyApplication() throws Exception {
+ String applicationName = createRandomApplicationName();
+ openshiftService.createApplication(applicationName, Cartridge.JBOSSAS_7);
+ openshiftService.destroyApplication(applicationName, Cartridge.JBOSSAS_7);
+ }
+
+ @Test(expected = OpenshiftException.class)
+ public void createDuplicateApplicationThrowsException() throws Exception {
+ String applicationName = createRandomApplicationName();
+ openshiftService.createApplication(applicationName, Cartridge.JBOSSAS_7);
+ openshiftService.createApplication(applicationName, Cartridge.JBOSSAS_7);
+ }
+
private String createRandomApplicationName() {
return String.valueOf(System.currentTimeMillis());
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/OpenshiftServiceTest.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/OpenshiftServiceTest.java 2011-09-08
07:47:01 UTC (rev 34577)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/OpenshiftServiceTest.java 2011-09-08
08:56:04 UTC (rev 34578)
@@ -71,13 +71,36 @@
String createApplicationRequest = new ApplicationRequestJsonMarshaller().marshall(
new ApplicationRequest(
- "test-application", new Cartridge("jbossas-7.0"),
ApplicationAction.CONFIGURE, USERNAME, true));
+ "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);
+ }
+
+ @Test
public void canUnmarshallCartridgeListResponse() throws OpenshiftException {
/*
* WARNING: the current (9-7-2011) response from the openshift rest