Author: adietish
Date: 2011-09-12 06:08:05 -0400 (Mon, 12 Sep 2011)
New Revision: 34623
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/response/DomainResponseUnmarshaller.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/Activator.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/ApplicationTest.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/DomainTest.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/ListCartridgesTest.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/OpenshiftTestSuite.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/UserInfoTest.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/fakes/
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/fakes/TestSSHKey.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/utils/
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/utils/StreamUtils.java
Removed:
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/test/
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/Domain.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/IOpenshiftJsonConstants.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/marshalling/AbstractJsonMarshaller.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/OpenshiftService.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/META-INF/MANIFEST.MF
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/DomainIntegrationTest.java
Log:
[JBIDE-9510] implementing alter domain
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/Domain.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/Domain.java 2011-09-10
00:02:46 UTC (rev 34622)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/Domain.java 2011-09-12
10:08:05 UTC (rev 34623)
@@ -11,14 +11,23 @@
package org.jboss.ide.eclipse.as.openshift.core;
+/**
+ * @author André Dietisheim
+ */
public class Domain implements IOpenshiftObject {
private User user;
+ private String name;
- public Domain(User user) {
+ public Domain(String name, User user) {
+ this.name = name;
this.user = user;
}
+ public String getName() {
+ return name;
+ }
+
public User getUser() {
return user;
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/IOpenshiftJsonConstants.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/IOpenshiftJsonConstants.java 2011-09-10
00:02:46 UTC (rev 34622)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/IOpenshiftJsonConstants.java 2011-09-12
10:08:05 UTC (rev 34623)
@@ -31,5 +31,6 @@
public static final String PROPERTY_NAMESPACE = "namespace";
public static final String PROPERTY_ALTER = "alter";
public static final String PROPERTY_SSH = "ssh";
+ public static final String PROPERTY_UUID = "uuid";
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/marshalling/AbstractJsonMarshaller.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/marshalling/AbstractJsonMarshaller.java 2011-09-10
00:02:46 UTC (rev 34622)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/marshalling/AbstractJsonMarshaller.java 2011-09-12
10:08:05 UTC (rev 34623)
@@ -7,7 +7,7 @@
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.ide.eclipse.as.openshift.core.internal.marshalling;
import org.jboss.dmr.ModelNode;
@@ -18,12 +18,13 @@
/**
* @author André Dietisheim
*/
-public abstract class AbstractJsonMarshaller<REQUEST extends
AbstractOpenshiftRequest> implements IOpenshiftMarshaller<REQUEST> {
+public abstract class AbstractJsonMarshaller<REQUEST extends
AbstractOpenshiftRequest> implements
+ IOpenshiftMarshaller<REQUEST> {
public String marshall(REQUEST request) throws OpenshiftException {
ModelNode node = new ModelNode();
setStringProperty(IOpenshiftJsonConstants.PROPERTY_RHLOGIN, request.getRhLogin(),
node);
- setStringProperty(IOpenshiftJsonConstants.PROPERTY_DEBUG, request.isDebug(), node);
+ setStringProperty(IOpenshiftJsonConstants.PROPERTY_DEBUG,
String.valueOf(request.isDebug()), node);
setJsonDataProperties(node, request);
return node.toJSONString(true);
}
@@ -31,20 +32,21 @@
protected void setJsonDataProperties(ModelNode node, REQUEST request) throws
OpenshiftException {
// empty default implementation
}
-
+
protected void setStringProperty(String propertyName, Object value, ModelNode node) {
- if (!isSet(value)) {
- if (value instanceof String) {
- setStringProperty((String) value, propertyName, node);
- }
+ if (!(value instanceof String)
+ && !isSet((String) value)) {
+ return;
}
+
+ setStringProperty((String) value, propertyName, node);
}
-
+
protected void setStringProperty(String propertyName, String value, ModelNode node) {
if (!isSet(value)) {
return;
}
-
+
node.get(propertyName).set(value);
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/OpenshiftService.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/OpenshiftService.java 2011-09-10
00:02:46 UTC (rev 34622)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/OpenshiftService.java 2011-09-12
10:08:05 UTC (rev 34623)
@@ -23,7 +23,6 @@
import org.jboss.ide.eclipse.as.openshift.core.OpenshiftEndpointException;
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.UserInfo;
import
org.jboss.ide.eclipse.as.openshift.core.internal.marshalling.ApplicationRequestJsonMarshaller;
import
org.jboss.ide.eclipse.as.openshift.core.internal.marshalling.DomainRequestJsonMarshaller;
@@ -40,6 +39,7 @@
import
org.jboss.ide.eclipse.as.openshift.internal.core.request.OpenshiftJsonRequestFactory;
import org.jboss.ide.eclipse.as.openshift.internal.core.request.UserInfoRequest;
import
org.jboss.ide.eclipse.as.openshift.internal.core.response.ApplicationResponseUnmarshaller;
+import
org.jboss.ide.eclipse.as.openshift.internal.core.response.DomainResponseUnmarshaller;
import
org.jboss.ide.eclipse.as.openshift.internal.core.response.ListCartridgesResponseUnmarshaller;
import org.jboss.ide.eclipse.as.openshift.internal.core.response.OpenshiftResponse;
@@ -120,8 +120,9 @@
password,
new DomainRequestJsonMarshaller().marshall(request))
.create();
- String domainReponse = createHttpClient(url).post(requestString);
- return new Domain(new User("", ""));
+ String responseString = createHttpClient(url).post(requestString);
+ OpenshiftResponse<Domain> response = new
DomainResponseUnmarshaller(responseString, request.getName()).unmarshall();
+ return response.getData();
} catch (MalformedURLException e) {
throw new OpenshiftEndpointException(url, e, "Could not list available cartridges
at \"{0}\"", url);
} catch (HttpClientException e) {
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/response/DomainResponseUnmarshaller.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/response/DomainResponseUnmarshaller.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/response/DomainResponseUnmarshaller.java 2011-09-12
10:08:05 UTC (rev 34623)
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * 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.response;
+
+import org.jboss.dmr.ModelNode;
+import org.jboss.ide.eclipse.as.openshift.core.Domain;
+import org.jboss.ide.eclipse.as.openshift.core.IOpenshiftJsonConstants;
+import org.jboss.ide.eclipse.as.openshift.core.User;
+
+/**
+ * @author André Dietisheim
+ */
+public class DomainResponseUnmarshaller extends
AbstractOpenshiftJsonResponseUnmarshaller<Domain> {
+
+ private String domainName;
+
+ public DomainResponseUnmarshaller(String response, String domainName) {
+ super(response);
+ this.domainName = domainName;
+ }
+
+ @Override
+ protected Domain createOpenshiftObject(ModelNode node) {
+ User user = createUser(node);
+ return new Domain(domainName, user);
+ }
+
+ protected User createUser(ModelNode node) {
+ String username = getString(IOpenshiftJsonConstants.PROPERTY_RHLOGIN, node);
+ String uuid = getString(IOpenshiftJsonConstants.PROPERTY_UUID, node);
+
+ return new User(username, uuid);
+ }
+}
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/response/DomainResponseUnmarshaller.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/META-INF/MANIFEST.MF
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/META-INF/MANIFEST.MF 2011-09-10
00:02:46 UTC (rev 34622)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/META-INF/MANIFEST.MF 2011-09-12
10:08:05 UTC (rev 34623)
@@ -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.test.Activator
+Bundle-Activator: org.jboss.ide.eclipse.as.openshift.internal.test.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)",
Copied:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/Activator.java
(from rev 34538,
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/test/Activator.java)
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/Activator.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/Activator.java 2011-09-12
10:08:05 UTC (rev 34623)
@@ -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.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;
+ }
+
+}
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/Activator.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/ApplicationTest.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/ApplicationTest.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/ApplicationTest.java 2011-09-12
10:08:05 UTC (rev 34623)
@@ -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.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.internal.core.request.ApplicationAction;
+import org.jboss.ide.eclipse.as.openshift.internal.core.request.ApplicationRequest;
+import
org.jboss.ide.eclipse.as.openshift.internal.core.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);
+ }
+}
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/ApplicationTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/DomainIntegrationTest.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/DomainIntegrationTest.java 2011-09-10
00:02:46 UTC (rev 34622)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/DomainIntegrationTest.java 2011-09-12
10:08:05 UTC (rev 34623)
@@ -10,16 +10,14 @@
******************************************************************************/
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.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.StringReader;
-
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.internal.core.OpenshiftService;
+import org.jboss.ide.eclipse.as.openshift.internal.test.core.fakes.TestSSHKey;
import org.junit.Before;
import org.junit.Test;
@@ -30,34 +28,6 @@
private static final String USERNAME = "openshift.only.domain(a)gmail.com";
private static final String PASSWORD = "1q2w3e";
- private static final String privateKey =
- "-----BEGIN RSA PRIVATE KEY-----\n" +
- "Proc-Type: 4,ENCRYPTED\n" +
- "DEK-Info: DES-EDE3-CBC,30E8B3A668E44D77\n" +
- "\n" +
- "wsXCU31SUTYhjPnOiW56UlZ7VXKlIjItLo5Wrk5LwCLv/OERK7UWJkrwM2bHPb6n\n" +
- "3zAaDDZfQe786URQjfmUYWBdVeI7DrRMwoLaaUcR1tuJtMu3Jv3CK72YMkOzGapZ\n" +
- "ZAAoTno/GRhTwptXG1KPSqKyzfqlxjbZry1HZmY+P6ikw9DWOPZC6rISIqQ3u9zm\n" +
- "iPvi/Oo7JWZtX1d1MYp3vVt2bo2duD4RSoXWWaW471WUOIQZUh0V4dxp+eAHZziu\n" +
- "osAfU4WoIrrSCSVl2uiKS2Zijn77PvcCXnm45eMQpww32AlslzIBNsMzUXhPtVAZ\n" +
- "a9uvfZxlOIRu4ObN7AB3WExucbBHCvTOgxpSs95br1QtfMVl62d9VkIAXg1x9gH8\n" +
- "kjcEP+0OS3EItYTFj1tCKC8GgBImj44AxbPSWu3SfTnYfAtFnO0pUqhPOBN63DCC\n" +
- "XxzMm13UeER7Z3s968Swa48r6LRAbHI8JD0Ld4E02fgBYM/N/aGtPppD0FoJJwo3\n" +
- "QVafS2PY+bALgy4qrI9daOo1mTS3gWDSAG0QbLoKd3hD8ZnLEk6rfR/0SE34Fc7j\n" +
- "mviCy78C16hkllhWz27ROl5pheHV0Xt6ZlUsNWVz7tg/AcIFB0geMuzuM0Kd7ufj\n" +
- "g5c8mhlI06n4vzo0uB6UXtwTBzNqyUl8yxA31S2VJfBZxkEwKc5cktNUiejQuWbU\n" +
- "iwapdiSR0gNGyYBNMYax9OOfYH+BBQeD5kboVU3yvT7UNcz0T9GZiEhfvcaYSP8C\n" +
- "ejQ1vuTNTKMrgyLpNi/4Sq8lm8OukRqQyE0EKYCwvkI=\n" +
- "-----END RSA PRIVATE KEY-----";
-
- private static final String publicKey =
- "ssh-rsa "
- +
- "AAAAB3NzaC1yc2EAAAADAQABAAAAgQC6BGRDydfGsQHhnZgo43dEfLzSJBke/hE8MLBBG1+5Z"
+
- "wktsrE+f2VdVt0McRLVAO6rdJRyMUX0rTbm7SABRVSX+zeQjlfqbbUtYFc7TIfd4RQc3GaISG"
+
- "1rS3C4svRSjdWaG36vDY2KxowdFvpKj8i8IYNPlLoRA/7EzzyneS6iyw" +
- "== created by org.jboss.ide.eclipse.as.openshift.core";
-
@Before
public void setUp() {
this.openshiftService = new OpenshiftService(USERNAME, PASSWORD);
@@ -65,40 +35,20 @@
@Test
public void canCreateDomain() throws Exception {
- File privateKeyFile = File.createTempFile(createRandomString(), null);
- writeTo(privateKey, privateKeyFile);
- File publicKeyFile = File.createTempFile(createRandomString(), null);
- writeTo(publicKey, publicKeyFile);
-
- SSHKey key = openshiftService.loadKey(privateKeyFile.getAbsolutePath(),
publicKeyFile.getAbsolutePath());
String domainName = createRandomString();
- Domain domain = openshiftService.createDomain(domainName, key);
+ 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());
}
private String createRandomString() {
return String.valueOf(System.currentTimeMillis());
}
-
- private void writeTo(String data, File file) throws IOException {
- StringReader reader = null;
- FileWriter writer = null;
- try {
- writer = new FileWriter(file);
- reader = new StringReader(data);
- for (int character = -1; (character = reader.read()) != -1;) {
- writer.write(character);
- }
- } finally {
- if (writer != null) {
- writer.flush();
- writer.close();
- }
- if (reader != null) {
- reader.close();
- }
- }
- }
}
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/DomainTest.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/DomainTest.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/DomainTest.java 2011-09-12
10:08:05 UTC (rev 34623)
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * 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.io.IOException;
+import java.net.URLEncoder;
+
+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.internal.marshalling.DomainRequestJsonMarshaller;
+import org.jboss.ide.eclipse.as.openshift.internal.core.request.CreateDomainRequest;
+import
org.jboss.ide.eclipse.as.openshift.internal.core.request.OpenshiftJsonRequestFactory;
+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";
+
+ @Test
+ public void canMarshallDomainCreateResponse() throws IOException, OpenshiftException {
+ String expectedRequestString =
+ "password="
+ + PASSWORD
+ + "&json_data=%7B"
+ + "%22rhlogin%22+%3A+"
+ + "%22"
+ + URLEncoder.encode(USERNAME, "UTF-8")
+ + "%22"
+ + "%2C+%22debug%22+%3A+%22true%22"
+ + "%2C+%22namespace%22+%3A+%22toolsjboss%40gmail.com%22"
+ + "%2C+%22alter%22+%3A+%22false%22"
+ +
"%2C+%22ssh%22+%3A+%22AAAAB3NzaC1yc2EAAAADAQABAAAAgQC6BGRDydfGsQHhnZgo43dEfLzSJBke%2FhE8MLBBG1%2B5ZwktsrE%2Bf2VdVt0McRLVAO6rdJRyMUX0rTbm7SABRVSX%2BzeQjlfqbbUtYFc7TIfd4RQc3GaISG1rS3C4svRSjdWaG36vDY2KxowdFvpKj8i8IYNPlLoRA%2F7EzzyneS6iyw%3D%3D%22"
+ + "%7D";
+
+ SSHKey sshKey = TestSSHKey.create();
+ CreateDomainRequest request = new CreateDomainRequest(USERNAME, sshKey, USERNAME,
true);
+ String requestString =
+ new OpenshiftJsonRequestFactory(
+ PASSWORD,
+ new DomainRequestJsonMarshaller().marshall(request))
+ .create();
+ assertEquals(expectedRequestString, requestString);
+ }
+}
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/DomainTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/ListCartridgesTest.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/ListCartridgesTest.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/ListCartridgesTest.java 2011-09-12
10:08:05 UTC (rev 34623)
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * 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.fail;
+
+import java.net.URLEncoder;
+import java.text.MessageFormat;
+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.internal.core.request.ListCartridgesRequest;
+import
org.jboss.ide.eclipse.as.openshift.internal.core.request.OpenshiftJsonRequestFactory;
+import
org.jboss.ide.eclipse.as.openshift.internal.core.response.ListCartridgesResponseUnmarshaller;
+import org.jboss.ide.eclipse.as.openshift.internal.core.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}";
+
+ OpenshiftResponse<List<Cartridge>> response = new
ListCartridgesResponseUnmarshaller(cartridgeListResponse)
+ .unmarshall();
+ 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());
+ }
+
+ private 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));
+ }
+ }
+}
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/ListCartridgesTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Deleted:
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-10
00:02:46 UTC (rev 34622)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/OpenshiftServiceTest.java 2011-09-12
10:08:05 UTC (rev 34623)
@@ -1,160 +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.fail;
-
-import java.net.URLEncoder;
-import java.text.MessageFormat;
-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.ApplicationRequestJsonMarshaller;
-import
org.jboss.ide.eclipse.as.openshift.core.internal.marshalling.ListCartridgesRequestJsonMarshaller;
-import
org.jboss.ide.eclipse.as.openshift.core.internal.marshalling.UserInfoRequestJsonMarshaller;
-import org.jboss.ide.eclipse.as.openshift.internal.core.request.ApplicationAction;
-import org.jboss.ide.eclipse.as.openshift.internal.core.request.ApplicationRequest;
-import org.jboss.ide.eclipse.as.openshift.internal.core.request.ListCartridgesRequest;
-import
org.jboss.ide.eclipse.as.openshift.internal.core.request.OpenshiftJsonRequestFactory;
-import org.jboss.ide.eclipse.as.openshift.internal.core.request.UserInfoRequest;
-import
org.jboss.ide.eclipse.as.openshift.internal.core.response.ListCartridgesResponseUnmarshaller;
-import org.jboss.ide.eclipse.as.openshift.internal.core.response.OpenshiftResponse;
-import org.junit.Test;
-
-/**
- * @author André Dietisheim
- */
-public class OpenshiftServiceTest {
-
- 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);
- }
-
- @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 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);
- }
-
- @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}";
-
- OpenshiftResponse<List<Cartridge>> response = new
ListCartridgesResponseUnmarshaller(cartridgeListResponse)
- .unmarshall();
- 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());
-
- }
-
- private 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));
- }
- }
-}
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/OpenshiftTestSuite.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/OpenshiftTestSuite.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/OpenshiftTestSuite.java 2011-09-12
10:08:05 UTC (rev 34623)
@@ -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.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 {
+
+}
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/OpenshiftTestSuite.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Copied:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/UserInfoTest.java
(from rev 34585,
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/UserInfoTest.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/UserInfoTest.java 2011-09-12
10:08:05 UTC (rev 34623)
@@ -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.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.internal.core.request.OpenshiftJsonRequestFactory;
+import org.jboss.ide.eclipse.as.openshift.internal.core.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);
+ }
+}
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/UserInfoTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/fakes/TestSSHKey.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/fakes/TestSSHKey.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/fakes/TestSSHKey.java 2011-09-12
10:08:05 UTC (rev 34623)
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * 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.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;
+
+/**
+ * @author André Dietisheim
+ */
+public class TestSSHKey {
+
+ private static final String privateKey =
+ "-----BEGIN RSA PRIVATE KEY-----\n" +
+ "Proc-Type: 4,ENCRYPTED\n" +
+ "DEK-Info: DES-EDE3-CBC,30E8B3A668E44D77\n" +
+ "\n" +
+ "wsXCU31SUTYhjPnOiW56UlZ7VXKlIjItLo5Wrk5LwCLv/OERK7UWJkrwM2bHPb6n\n" +
+ "3zAaDDZfQe786URQjfmUYWBdVeI7DrRMwoLaaUcR1tuJtMu3Jv3CK72YMkOzGapZ\n" +
+ "ZAAoTno/GRhTwptXG1KPSqKyzfqlxjbZry1HZmY+P6ikw9DWOPZC6rISIqQ3u9zm\n" +
+ "iPvi/Oo7JWZtX1d1MYp3vVt2bo2duD4RSoXWWaW471WUOIQZUh0V4dxp+eAHZziu\n" +
+ "osAfU4WoIrrSCSVl2uiKS2Zijn77PvcCXnm45eMQpww32AlslzIBNsMzUXhPtVAZ\n" +
+ "a9uvfZxlOIRu4ObN7AB3WExucbBHCvTOgxpSs95br1QtfMVl62d9VkIAXg1x9gH8\n" +
+ "kjcEP+0OS3EItYTFj1tCKC8GgBImj44AxbPSWu3SfTnYfAtFnO0pUqhPOBN63DCC\n" +
+ "XxzMm13UeER7Z3s968Swa48r6LRAbHI8JD0Ld4E02fgBYM/N/aGtPppD0FoJJwo3\n" +
+ "QVafS2PY+bALgy4qrI9daOo1mTS3gWDSAG0QbLoKd3hD8ZnLEk6rfR/0SE34Fc7j\n" +
+ "mviCy78C16hkllhWz27ROl5pheHV0Xt6ZlUsNWVz7tg/AcIFB0geMuzuM0Kd7ufj\n" +
+ "g5c8mhlI06n4vzo0uB6UXtwTBzNqyUl8yxA31S2VJfBZxkEwKc5cktNUiejQuWbU\n" +
+ "iwapdiSR0gNGyYBNMYax9OOfYH+BBQeD5kboVU3yvT7UNcz0T9GZiEhfvcaYSP8C\n" +
+ "ejQ1vuTNTKMrgyLpNi/4Sq8lm8OukRqQyE0EKYCwvkI=\n" +
+ "-----END RSA PRIVATE KEY-----";
+
+ private static final String publicKey =
+ "ssh-rsa "
+ +
+ "AAAAB3NzaC1yc2EAAAADAQABAAAAgQC6BGRDydfGsQHhnZgo43dEfLzSJBke/hE8MLBBG1+5Z"
+
+ "wktsrE+f2VdVt0McRLVAO6rdJRyMUX0rTbm7SABRVSX+zeQjlfqbbUtYFc7TIfd4RQc3GaISG"
+
+ "1rS3C4svRSjdWaG36vDY2KxowdFvpKj8i8IYNPlLoRA/7EzzyneS6iyw" +
+ "== created by org.jboss.ide.eclipse.as.openshift.core";
+
+ public static SSHKey create() throws IOException, OpenshiftException {
+ File privateKeyFile = File.createTempFile(createRandomString(), null);
+ StreamUtils.writeTo(privateKey, privateKeyFile);
+
+ File publicKeyFile = File.createTempFile(createRandomString(), null);
+ StreamUtils.writeTo(publicKey, publicKeyFile);
+
+ return SSHKey.load(privateKeyFile.getAbsolutePath(), publicKeyFile.getAbsolutePath());
+ }
+
+ private static String createRandomString() {
+ return String.valueOf(System.currentTimeMillis());
+ }
+
+
+}
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/fakes/TestSSHKey.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/utils/StreamUtils.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/utils/StreamUtils.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/utils/StreamUtils.java 2011-09-12
10:08:05 UTC (rev 34623)
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * 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.utils;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.StringReader;
+
+public class StreamUtils {
+
+ public static void writeTo(String data, String path) throws IOException {
+ writeTo(data, new File(path));
+ }
+
+ public static void writeTo(String data, File file) throws IOException {
+ StringReader reader = null;
+ FileWriter writer = null;
+ try {
+ writer = new FileWriter(file);
+ reader = new StringReader(data);
+ for (int character = -1; (character = reader.read()) != -1;) {
+ writer.write(character);
+ }
+ } finally {
+ if (writer != null) {
+ writer.flush();
+ writer.close();
+ }
+ if (reader != null) {
+ reader.close();
+ }
+ }
+ }
+}
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/utils/StreamUtils.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain