Author: adietish
Date: 2011-09-08 12:30:53 -0400 (Thu, 08 Sep 2011)
New Revision: 34585
Added:
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/SSHKey.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/User.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/marshalling/DomainRequestJsonMarshaller.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/OpenshiftCoreActivator.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/request/AbstractDomainRequest.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/request/ChangeCreateDomainRequest.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/utils/Base64Encoder.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/ApplicationIntegrationTest.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/CartridgesIntegrationTest.java
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/SSHKeyTest.java
Removed:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/Activator.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/OpenshiftServiceIntegrationTest.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/META-INF/MANIFEST.MF
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/IOpenshiftService.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/OpenshiftException.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/UserInfo.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/core/internal/marshalling/ApplicationRequestJsonMarshaller.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/marshalling/ListCartridgesRequestJsonMarshaller.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.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/request/CreateDomainRequest.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 create domain
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/META-INF/MANIFEST.MF
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/META-INF/MANIFEST.MF 2011-09-08
11:39:03 UTC (rev 34584)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/META-INF/MANIFEST.MF 2011-09-08
16:30:53 UTC (rev 34585)
@@ -3,9 +3,10 @@
Bundle-Name: Openshift Core Plugin
Bundle-SymbolicName: org.jboss.ide.eclipse.as.openshift.core
Bundle-Version: 1.0.0.qualifier
-Bundle-Activator: org.jboss.ide.eclipse.as.openshift.internal.core.Activator
+Bundle-Activator:
org.jboss.ide.eclipse.as.openshift.internal.core.OpenshiftCoreActivator
Bundle-Vendor: JBoss by Red Hat
-Require-Bundle: org.eclipse.core.runtime
+Require-Bundle: org.eclipse.core.runtime,
+ com.jcraft.jsch;bundle-version="[0.1.41,2.0.0)"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: jboss-dmr-1.0.0.Final.jar,
Added:
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
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/Domain.java 2011-09-08
16:30:53 UTC (rev 34585)
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * 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.core;
+
+
+public class Domain implements IOpenshiftObject {
+
+ private User user;
+
+ public Domain(User user) {
+ this.user = user;
+ }
+
+ public User getUser() {
+ return user;
+ }
+}
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/Domain.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/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-08
11:39:03 UTC (rev 34584)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/IOpenshiftJsonConstants.java 2011-09-08
16:30:53 UTC (rev 34585)
@@ -28,5 +28,7 @@
public static final String PROPERTY_ACTION = "action";
public static final String PROPERTY_CARTRIDGE = "cartridge";
public static final String PROPERTY_CARTS = "carts";
+ public static final String PROPERTY_NAMESPACE = "namespace";
+ public static final String PROPERTY_ALTER = "alter";
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/IOpenshiftService.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/IOpenshiftService.java 2011-09-08
11:39:03 UTC (rev 34584)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/IOpenshiftService.java 2011-09-08
16:30:53 UTC (rev 34585)
@@ -12,7 +12,9 @@
import java.util.List;
-
+/**
+ * @author André Dietisheim
+ */
public interface IOpenshiftService {
public UserInfo getUserInfo() throws OpenshiftException;
@@ -23,5 +25,7 @@
public Application destroyApplication(String name, Cartridge cartridge) throws
OpenshiftException;
- public Application createDomain(String name) throws OpenshiftException;
+ public Domain createDomain(String name, String sshKey) throws OpenshiftException;
+
+ public Domain createDomain(String name, SSHKey keyPair) throws OpenshiftException;
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/OpenshiftException.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/OpenshiftException.java 2011-09-08
11:39:03 UTC (rev 34584)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/OpenshiftException.java 2011-09-08
16:30:53 UTC (rev 34585)
@@ -22,4 +22,8 @@
public OpenshiftException(Throwable cause, String message, Object... arguments) {
super(MessageFormat.format(message, arguments), cause);
}
+
+ public OpenshiftException(String message, Object... arguments) {
+ super(MessageFormat.format(message, arguments));
+ }
}
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/SSHKey.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/SSHKey.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/SSHKey.java 2011-09-08
16:30:53 UTC (rev 34585)
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * 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.core;
+
+import org.jboss.ide.eclipse.as.openshift.internal.core.OpenshiftCoreActivator;
+import org.jboss.ide.eclipse.as.openshift.internal.core.utils.Base64Encoder;
+
+import com.jcraft.jsch.JSch;
+import com.jcraft.jsch.JSchException;
+import com.jcraft.jsch.KeyPair;
+
+/**
+ * @author André Dietisheim
+ */
+public class SSHKey {
+
+ private KeyPair keyPair;
+ private String privateKeyPath;
+ private String publicKeyPath;
+
+ private SSHKey(KeyPair keyPair, String privateKeyPath, String publicKeyPath) throws
OpenshiftException {
+ this.keyPair = keyPair;
+ this.privateKeyPath = privateKeyPath;
+ this.publicKeyPath = publicKeyPath;
+ }
+
+ /**
+ * Creates private and public ssh-rsa keys and stores them to the given
+ * paths. The key is created while using the given pass phrase.
+ *
+ * @param passPhrase
+ * the pass phrase to set to the new key
+ * @param privateKeyPath
+ * the path where the new private key gets stored
+ * @param publicKeyPath
+ * the path where the new public key gets stored
+ * @return
+ * @throws OpenshiftException
+ * if the key could not be created
+ */
+ public static SSHKey create(String passPhrase, String privateKeyPath, String
publicKeyPath)
+ throws OpenshiftException {
+ try {
+ KeyPair keyPair = KeyPair.genKeyPair(new JSch(), KeyPair.RSA);
+ keyPair.setPassphrase(passPhrase);
+ keyPair.writePublicKey(publicKeyPath, "created by " +
OpenshiftCoreActivator.PLUGIN_ID);
+ keyPair.writePrivateKey(privateKeyPath);
+ return new SSHKey(keyPair, privateKeyPath, publicKeyPath);
+ } catch (Exception e) {
+ throw new OpenshiftException(e, "Could not create new rsa key", e);
+ }
+ }
+
+ public static SSHKey load(String privateKeyPath, String publicKeyPath)
+ throws OpenshiftException {
+ try {
+ KeyPair keyPair = KeyPair.load(new JSch(), privateKeyPath, publicKeyPath);
+ return new SSHKey(keyPair, privateKeyPath, publicKeyPath);
+ } catch (JSchException e) {
+ throw new OpenshiftException(e, "Could not create new rsa key");
+ }
+ }
+
+ /**
+ * Returns the content of the public key (key content without ssh-rsa
+ * identifier nor comment) of the ssh key
+ *
+ * @return the content of the public key (without signature, without
+ * comment)
+ * @throws OpenshiftException
+ */
+ public String getPublicKeyContent() throws OpenshiftException {
+ return new String(Base64Encoder.encode(keyPair.getPublicKeyBlob()));
+ }
+
+ protected String getPublicKeyPath() {
+ return publicKeyPath;
+ }
+
+ protected String getPrivateKeyPath() {
+ return privateKeyPath;
+ }
+
+}
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/SSHKey.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/User.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/User.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/User.java 2011-09-08
16:30:53 UTC (rev 34585)
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * 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.core;
+
+/**
+ * @author André Dietisheim
+ */
+public class User {
+
+ private String rhlogin;
+ private String uuid;
+
+ public User(String rhlogin, String uuid) {
+ this.rhlogin = rhlogin;
+ this.uuid = uuid;
+ }
+
+ public String getRhlogin() {
+ return rhlogin;
+ }
+
+ public String getUuid() {
+ return uuid;
+ }
+}
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/User.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/core/UserInfo.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/UserInfo.java 2011-09-08
11:39:03 UTC (rev 34584)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/UserInfo.java 2011-09-08
16:30:53 UTC (rev 34585)
@@ -10,8 +10,6 @@
******************************************************************************/
package org.jboss.ide.eclipse.as.openshift.core;
-import org.jboss.ide.eclipse.as.openshift.core.internal.marshalling.IOpenshiftRequest;
-
/**
* @author André Dietisheim
*/
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-08
11:39:03 UTC (rev 34584)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/marshalling/AbstractJsonMarshaller.java 2011-09-08
16:30:53 UTC (rev 34585)
@@ -23,11 +23,11 @@
ModelNode node = new ModelNode();
node.get(IOpenshiftJsonConstants.PROPERTY_RHLOGIN).set(request.getRhLogin());
node.get(IOpenshiftJsonConstants.PROPERTY_DEBUG).set(String.valueOf(request.isDebug()));
- setNodeProperties(node, request);
+ setJsonDataProperties(node, request);
return node.toJSONString(true);
}
- protected void setNodeProperties(ModelNode node, REQUEST request) {
+ protected void setJsonDataProperties(ModelNode node, REQUEST request) {
// empty default implementation
}
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/marshalling/ApplicationRequestJsonMarshaller.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/marshalling/ApplicationRequestJsonMarshaller.java 2011-09-08
11:39:03 UTC (rev 34584)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/marshalling/ApplicationRequestJsonMarshaller.java 2011-09-08
16:30:53 UTC (rev 34585)
@@ -22,7 +22,7 @@
public class ApplicationRequestJsonMarshaller extends
AbstractJsonMarshaller<ApplicationRequest> {
@Override
- protected void setNodeProperties(ModelNode node, ApplicationRequest request) {
+ protected void setJsonDataProperties(ModelNode node, ApplicationRequest request) {
node.get(IOpenshiftJsonConstants.PROPERTY_CARTRIDGE).set(getCartridgeName(request.getCartridge()));
node.get(IOpenshiftJsonConstants.PROPERTY_ACTION).set(getActionName(request.getAction()));
node.get(IOpenshiftJsonConstants.PROPERTY_APP_NAME).set(request.getName());
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/marshalling/DomainRequestJsonMarshaller.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/marshalling/DomainRequestJsonMarshaller.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/marshalling/DomainRequestJsonMarshaller.java 2011-09-08
16:30:53 UTC (rev 34585)
@@ -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.core.internal.marshalling;
+
+import org.jboss.dmr.ModelNode;
+import org.jboss.ide.eclipse.as.openshift.core.IOpenshiftJsonConstants;
+import org.jboss.ide.eclipse.as.openshift.internal.core.request.AbstractDomainRequest;
+
+/**
+ * @author André Dietisheim
+ */
+public class DomainRequestJsonMarshaller extends
AbstractJsonMarshaller<AbstractDomainRequest> {
+
+ @Override
+ protected void setJsonDataProperties(ModelNode node, AbstractDomainRequest request) {
+ node.get(IOpenshiftJsonConstants.PROPERTY_NAMESPACE).set(request.getName());
+ node.get(IOpenshiftJsonConstants.PROPERTY_ALTER).set(request.isAlter());
+ }
+}
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/marshalling/DomainRequestJsonMarshaller.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/core/internal/marshalling/ListCartridgesRequestJsonMarshaller.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/marshalling/ListCartridgesRequestJsonMarshaller.java 2011-09-08
11:39:03 UTC (rev 34584)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/core/internal/marshalling/ListCartridgesRequestJsonMarshaller.java 2011-09-08
16:30:53 UTC (rev 34585)
@@ -20,7 +20,7 @@
public class ListCartridgesRequestJsonMarshaller extends
AbstractJsonMarshaller<ListCartridgesRequest> {
@Override
- protected void setNodeProperties(ModelNode node, ListCartridgesRequest request) {
+ protected void setJsonDataProperties(ModelNode node, ListCartridgesRequest request) {
node.get(IOpenshiftJsonConstants.PROPERTY_CART_TYPE).set(request.getCartType());
}
}
Deleted:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/Activator.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/Activator.java 2011-09-08
11:39:03 UTC (rev 34584)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/Activator.java 2011-09-08
16:30:53 UTC (rev 34585)
@@ -1,31 +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.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/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/OpenshiftCoreActivator.java
(from rev 34538,
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/Activator.java)
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/OpenshiftCoreActivator.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/OpenshiftCoreActivator.java 2011-09-08
16:30:53 UTC (rev 34585)
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * 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;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class OpenshiftCoreActivator implements BundleActivator {
+
+ public static final String PLUGIN_ID =
"org.jboss.ide.eclipse.as.openshift.core";
+
+ private static BundleContext context;
+
+ static BundleContext getContext() {
+ return context;
+ }
+
+ public void start(BundleContext bundleContext) throws Exception {
+ OpenshiftCoreActivator.context = bundleContext;
+ }
+
+ public void stop(BundleContext bundleContext) throws Exception {
+ OpenshiftCoreActivator.context = null;
+ }
+}
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/OpenshiftCoreActivator.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/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-08
11:39:03 UTC (rev 34584)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/OpenshiftService.java 2011-09-08
16:30:53 UTC (rev 34585)
@@ -16,20 +16,26 @@
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.Domain;
import org.jboss.ide.eclipse.as.openshift.core.IHttpClient;
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.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;
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.httpclient.HttpClientException;
import
org.jboss.ide.eclipse.as.openshift.internal.core.httpclient.UnauthorizedException;
import
org.jboss.ide.eclipse.as.openshift.internal.core.httpclient.UrlConnectionHttpClient;
+import org.jboss.ide.eclipse.as.openshift.internal.core.request.AbstractDomainRequest;
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.CreateDomainRequest;
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;
@@ -72,7 +78,7 @@
/**
* WARNING: the current server implementation returns invalid json.
*
- * @see ListCartridgesResponseUnmarshaller
+ * @see ListCartridgesResponseUnmarshaller
*/
@Override
public List<Cartridge> getCartridges() throws OpenshiftException {
@@ -91,11 +97,32 @@
}
}
+ public Domain createDomain(String name, SSHKey sshKey) throws OpenshiftException {
+ return createDomain(name, sshKey.getPublicKeyContent());
+ }
+
@Override
- public Application createDomain(String name) throws OpenshiftException {
- throw new UnsupportedOperationException();
+ public Domain createDomain(String name, String sshKey) throws OpenshiftException {
+ return requestDomainAction(new CreateDomainRequest(name, sshKey, username, true));
}
+ protected Domain requestDomainAction(AbstractDomainRequest request) throws
OpenshiftException {
+ String url = request.getUrlString(BASE_URL);
+ try {
+ String requestString =
+ new OpenshiftJsonRequestFactory(
+ password,
+ new DomainRequestJsonMarshaller().marshall(request))
+ .create();
+ String domainReponse = createHttpClient(url).post(requestString);
+ return new Domain(new User("", ""));
+ } catch (MalformedURLException e) {
+ throw new OpenshiftEndpointException(url, e, "Could not list available cartridges
at \"{0}\"", url);
+ } catch (HttpClientException e) {
+ throw new OpenshiftEndpointException(url, e, "Could not list available cartridges
at \"{0}\"", url);
+ }
+ }
+
@Override
public Application createApplication(String name, Cartridge cartridge) throws
OpenshiftException {
return requestApplicationAction(name, cartridge,
@@ -125,7 +152,8 @@
applicationRequest.getAction().toHumanReadable(), name, url);
} catch (UnauthorizedException e) {
throw new InvalidCredentialsOpenshiftException(
- url, e, "Could not {0} application \"{1}\" at \"{2}\":
Invalid credentials user \"{3}\", password \"{4}\"",
+ url, e,
+ "Could not {0} application \"{1}\" at \"{2}\": Invalid
credentials user \"{3}\", password \"{4}\"",
applicationRequest.getAction().toHumanReadable(), name, url, username, password);
} catch (HttpClientException e) {
throw new OpenshiftEndpointException(
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/request/AbstractDomainRequest.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/request/AbstractDomainRequest.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/request/AbstractDomainRequest.java 2011-09-08
16:30:53 UTC (rev 34585)
@@ -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.internal.core.request;
+
+
+/**
+ * @author André Dietisheim
+ */
+public abstract class AbstractDomainRequest extends AbstractOpenshiftRequest {
+
+ private String name;
+ private String sshKey;
+
+ public AbstractDomainRequest(String name, String sshKey, ApplicationAction action,
String username) {
+ this(name, sshKey, username, false);
+ }
+
+ public AbstractDomainRequest(String name, String sshKey, String username, boolean debug)
{
+ super(username, debug);
+ this.name = name;
+ this.sshKey = sshKey;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getSshKey() {
+ return sshKey;
+ }
+
+ @Override
+ public String getResourcePath() {
+ return "domain";
+ }
+
+ public abstract boolean isAlter();
+}
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/request/AbstractDomainRequest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/request/ChangeCreateDomainRequest.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/request/ChangeCreateDomainRequest.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/request/ChangeCreateDomainRequest.java 2011-09-08
16:30:53 UTC (rev 34585)
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * 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.request;
+
+
+/**
+ * @author André Dietisheim
+ */
+public class ChangeCreateDomainRequest extends AbstractDomainRequest {
+
+ public ChangeCreateDomainRequest(String name, String namespace, String sshKey,
ApplicationAction action, String username) {
+ this(name, namespace, sshKey, username, false);
+ }
+
+ public ChangeCreateDomainRequest(String name, String namespace, String sshKey, String
username, boolean debug) {
+ super(name, sshKey, username, debug);
+ }
+
+ public boolean isAlter() {
+ return true;
+ }
+}
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/request/ChangeCreateDomainRequest.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/request/CreateDomainRequest.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/request/CreateDomainRequest.java 2011-09-08
11:39:03 UTC (rev 34584)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/request/CreateDomainRequest.java 2011-09-08
16:30:53 UTC (rev 34585)
@@ -14,37 +14,17 @@
/**
* @author André Dietisheim
*/
-public class CreateDomainRequest extends AbstractOpenshiftRequest {
+public class CreateDomainRequest extends AbstractDomainRequest {
- private String name;
- private String sshKey;
- private String namespace;
-
- public CreateDomainRequest(String name, String namespace, String sshKey,
ApplicationAction action, String username) {
- this(name, namespace, sshKey, username, false);
+ public CreateDomainRequest(String name, String sshKey, ApplicationAction action, String
username) {
+ this(name, sshKey, username, false);
}
- public CreateDomainRequest(String name, String namespace, String sshKey, String
username, boolean debug) {
- super(username, debug);
- this.name = name;
- this.namespace = namespace;
- this.sshKey = sshKey;
+ public CreateDomainRequest(String name, String sshKey, String username, boolean debug)
{
+ super(name, sshKey, username, debug);
}
- public String getName() {
- return name;
+ public boolean isAlter() {
+ return false;
}
-
- protected String getSshKey() {
- return sshKey;
- }
-
- protected String getNamespace() {
- return namespace;
- }
-
- @Override
- public String getResourcePath() {
- return "domain";
- }
}
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/utils/Base64Encoder.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/utils/Base64Encoder.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/utils/Base64Encoder.java 2011-09-08
16:30:53 UTC (rev 34585)
@@ -0,0 +1,79 @@
+/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
+/*
+Copyright (c) 2002-2008 ymnk, JCraft,Inc. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the distribution.
+
+ 3. The names of the authors may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
+INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+package org.jboss.ide.eclipse.as.openshift.internal.core.utils;
+
+public class Base64Encoder {
+
+ private static final byte[] b64 =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".getBytes();
+
+ public static byte[] encode(byte[] buf) {
+ return encode(buf, 0, buf.length);
+ }
+
+ public static byte[] encode(byte[] buf, int start, int length) {
+ byte[] tmp = new byte[length * 2];
+ int i, j, k;
+
+ int foo = (length / 3) * 3 + start;
+ i = 0;
+ for (j = start; j < foo; j += 3) {
+ k = (buf[j] >>> 2) & 0x3f;
+ tmp[i++] = b64[k];
+ k = (buf[j] & 0x03) << 4 | (buf[j + 1] >>> 4) & 0x0f;
+ tmp[i++] = b64[k];
+ k = (buf[j + 1] & 0x0f) << 2 | (buf[j + 2] >>> 6) & 0x03;
+ tmp[i++] = b64[k];
+ k = buf[j + 2] & 0x3f;
+ tmp[i++] = b64[k];
+ }
+
+ foo = (start + length) - foo;
+ if (foo == 1) {
+ k = (buf[j] >>> 2) & 0x3f;
+ tmp[i++] = b64[k];
+ k = ((buf[j] & 0x03) << 4) & 0x3f;
+ tmp[i++] = b64[k];
+ tmp[i++] = (byte) '=';
+ tmp[i++] = (byte) '=';
+ }
+ else if (foo == 2) {
+ k = (buf[j] >>> 2) & 0x3f;
+ tmp[i++] = b64[k];
+ k = (buf[j] & 0x03) << 4 | (buf[j + 1] >>> 4) & 0x0f;
+ tmp[i++] = b64[k];
+ k = ((buf[j + 1] & 0x0f) << 2) & 0x3f;
+ tmp[i++] = b64[k];
+ tmp[i++] = (byte) '=';
+ }
+ byte[] bar = new byte[i];
+ System.arraycopy(tmp, 0, bar, 0, i);
+ return bar;
+ }
+
+}
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/utils/Base64Encoder.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/ApplicationIntegrationTest.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/ApplicationIntegrationTest.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/ApplicationIntegrationTest.java 2011-09-08
16:30:53 UTC (rev 34585)
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * 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.internal.core.OpenshiftService;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author André Dietisheim
+ */
+public class ApplicationIntegrationTest {
+
+ private OpenshiftService openshiftService;
+ private OpenshiftService 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");
+ }
+
+ @Test(expected = InvalidCredentialsOpenshiftException.class)
+ public void createApplicationWithInvalidCredentialsThrowsException() throws Exception {
+ invalidCredentialsOpenshiftService.createApplication(createRandomApplicationName(),
Cartridge.JBOSSAS_7);
+ }
+
+ @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);
+ }
+ }
+
+ @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());
+ }
+
+ private void silentlyDestroyApplication(String name, IOpenshiftService service) {
+ try {
+ service.destroyApplication(name, Cartridge.JBOSSAS_7);
+ } catch (OpenshiftException e) {
+ e.printStackTrace();
+ }
+ }
+}
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/ApplicationIntegrationTest.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/CartridgesIntegrationTest.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/CartridgesIntegrationTest.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/CartridgesIntegrationTest.java 2011-09-08
16:30:53 UTC (rev 34585)
@@ -0,0 +1,33 @@
+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.internal.core.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);
+ }
+}
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/CartridgesIntegrationTest.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/DomainIntegrationTest.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/DomainIntegrationTest.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/DomainIntegrationTest.java 2011-09-08
16:30:53 UTC (rev 34585)
@@ -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.assertNotNull;
+
+import org.jboss.ide.eclipse.as.openshift.core.Domain;
+import org.jboss.ide.eclipse.as.openshift.internal.core.OpenshiftService;
+import org.junit.Before;
+import org.junit.Ignore;
+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);
+ }
+
+ @Ignore
+ @Test
+ public void canCreateDomain() throws Exception {
+ String name = createRandomDomainName();
+ Domain domain = openshiftService.createDomain(name, (String) null);
+ assertNotNull(domain);
+ }
+
+ private String createRandomDomainName() {
+ 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/DomainIntegrationTest.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/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
11:39:03 UTC (rev 34584)
+++
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
16:30:53 UTC (rev 34585)
@@ -1,92 +0,0 @@
-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;
-
-import java.util.List;
-
-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.internal.core.OpenshiftService;
-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";
-
- @Before
- public void setUp() {
- this.openshiftService = new OpenshiftService(USERNAME, PASSWORD);
- this.invalidCredentialsOpenshiftService = new OpenshiftService(USERNAME,
"bogus");
- }
-
- @Ignore
- @Test(expected = OpenshiftException.class)
- public void cannotGetUserInfoIfNotAppNorDomainCreated() throws OpenshiftException {
- openshiftService.getUserInfo();
- }
-
- @Ignore
- @Test
- public void canRequestListCartridges() throws Exception {
- List<Cartridge> cartridges = openshiftService.getCartridges();
- assertNotNull(cartridges);
- assertTrue(cartridges.size() > 0);
- }
-
- @Test(expected = InvalidCredentialsOpenshiftException.class)
- public void createApplicationWithInvalidCredentialsThrowsException() throws Exception {
- invalidCredentialsOpenshiftService.createApplication(createRandomApplicationName(),
Cartridge.JBOSSAS_7);
- }
-
- @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);
- }
- }
-
- @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());
- }
-
- private void silentlyDestroyApplication(String name, IOpenshiftService service) {
- try {
- service.destroyApplication(name, Cartridge.JBOSSAS_7);
- } catch (OpenshiftException e) {
- e.printStackTrace();
- }
-
- }
-}
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
11:39:03 UTC (rev 34584)
+++
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
16:30:53 UTC (rev 34585)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * 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;
@@ -21,6 +31,9 @@
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";
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/SSHKeyTest.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/SSHKeyTest.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/SSHKeyTest.java 2011-09-08
16:30:53 UTC (rev 34585)
@@ -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.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);
+ }
+}
Property changes on:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/SSHKeyTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain