Author: adietish
Date: 2011-01-06 17:40:47 -0500 (Thu, 06 Jan 2011)
New Revision: 27959
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/unmarshal/AbstractActionAwareUnmarshaller.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/unmarshal/AbstractDeltaCloudObjectsUnmarshaller.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/unmarshal/InstancesUnmarshaller.java
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/fakes/InstanceResponseFakes.java
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/fakes/KeyResponseFakes.java
Removed:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/unmarshal/AbstractDOMActionAwareUnmarshaller.java
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/fakes/ServerInstanceResponseFakes.java
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/fakes/ServerKeyResponseFakes.java
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/unmarshal/AbstractActionUnmarshaller.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/unmarshal/InstanceActionUnmarshaller.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/unmarshal/InstanceUnmarshaller.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/unmarshal/KeyActionUnmarshaller.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/unmarshal/KeyUnmarshaller.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/unmarshal/KeysUnmarshaller.java
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/core/client/InstanceDomUnmarshallingTest.java
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/core/client/KeyDomUnmarshallingTest.java
Log:
[JBIDE-7935] moved instance unmarshalling to its own class, removed from client, added
tests
Copied:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/unmarshal/AbstractActionAwareUnmarshaller.java
(from rev 27956,
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/unmarshal/AbstractDOMActionAwareUnmarshaller.java)
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/unmarshal/AbstractActionAwareUnmarshaller.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/unmarshal/AbstractActionAwareUnmarshaller.java 2011-01-06
22:40:47 UTC (rev 27959)
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.tools.deltacloud.core.client.unmarshal;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.tools.deltacloud.core.client.AbstractDeltaCloudResourceAction;
+import org.jboss.tools.deltacloud.core.client.DeltaCloudClientException;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * @author André Dietisheim
+ *
+ * @param <DELTACLOUDOBJECT>
+ */
+public abstract class AbstractActionAwareUnmarshaller<DELTACLOUDOBJECT, ACTION extends
AbstractDeltaCloudResourceAction<DELTACLOUDOBJECT>> extends
AbstractDOMUnmarshaller<DELTACLOUDOBJECT>{
+
+ private String actionElementName;
+ public AbstractActionAwareUnmarshaller(String tagName, Class<DELTACLOUDOBJECT>
type, String actionElementName) {
+ super(tagName, type);
+ this.actionElementName = actionElementName;
+ }
+
+ protected List<ACTION> getActions(Element element, DELTACLOUDOBJECT owner) throws
DeltaCloudClientException {
+ if (element == null) {
+ return null;
+ }
+ List<ACTION> actions = new ArrayList<ACTION>();
+ NodeList nodeList = element.getElementsByTagName(actionElementName);
+ for (int i = 0; i < nodeList.getLength(); i++) {
+ Node linkNode = nodeList.item(i);
+ ACTION action = createAction(linkNode);
+ if (action != null) {
+ action.setOwner(owner);
+ actions.add(action);
+ }
+ }
+ return actions;
+ }
+
+ protected ACTION createAction(Node node) throws DeltaCloudClientException {
+ if (!(node instanceof Element)) {
+ return null;
+ }
+ return unmarshallAction((Element) node);
+ }
+
+ protected abstract ACTION unmarshallAction(Element element) throws
DeltaCloudClientException;
+}
Property changes on:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/unmarshal/AbstractActionAwareUnmarshaller.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/unmarshal/AbstractActionUnmarshaller.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/unmarshal/AbstractActionUnmarshaller.java 2011-01-06
22:12:24 UTC (rev 27958)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/unmarshal/AbstractActionUnmarshaller.java 2011-01-06
22:40:47 UTC (rev 27959)
@@ -16,8 +16,7 @@
/**
* @author André Dietisheim
*/
-public class AbstractActionUnmarshaller
-<ACTION extends AbstractDeltaCloudResourceAction> extends
AbstractDOMUnmarshaller<ACTION> {
+public class AbstractActionUnmarshaller <ACTION extends
AbstractDeltaCloudResourceAction<OWNER>, OWNER> extends
AbstractDOMUnmarshaller<ACTION> {
public AbstractActionUnmarshaller(Class<ACTION> actionClass) {
super("link", actionClass);
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/unmarshal/AbstractDOMActionAwareUnmarshaller.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/unmarshal/AbstractDOMActionAwareUnmarshaller.java 2011-01-06
22:12:24 UTC (rev 27958)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/unmarshal/AbstractDOMActionAwareUnmarshaller.java 2011-01-06
22:40:47 UTC (rev 27959)
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.tools.deltacloud.core.client.unmarshal;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jboss.tools.deltacloud.core.client.AbstractDeltaCloudResourceAction;
-import org.jboss.tools.deltacloud.core.client.DeltaCloudClientException;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * @author André Dietisheim
- *
- * @param <DELTACLOUDOBJECT>
- */
-public abstract class AbstractDOMActionAwareUnmarshaller<DELTACLOUDOBJECT, ACTION
extends AbstractDeltaCloudResourceAction<DELTACLOUDOBJECT>> extends
AbstractDOMUnmarshaller<DELTACLOUDOBJECT>{
-
- private String actionElementName;
- public AbstractDOMActionAwareUnmarshaller(String tagName, Class<DELTACLOUDOBJECT>
type, String actionElementName) {
- super(tagName, type);
- this.actionElementName = actionElementName;
- }
-
- protected List<ACTION> getActions(Element element, DELTACLOUDOBJECT owner) throws
DeltaCloudClientException {
- if (element == null) {
- return null;
- }
- List<ACTION> actions = new ArrayList<ACTION>();
- NodeList nodeList = element.getElementsByTagName(actionElementName);
- for (int i = 0; i < nodeList.getLength(); i++) {
- Node linkNode = nodeList.item(i);
- ACTION action = createAction(linkNode);
- if (action != null) {
- action.setOwner(owner);
- actions.add(action);
- }
- }
- return actions;
- }
-
- protected ACTION createAction(Node node) throws DeltaCloudClientException {
- if (!(node instanceof Element)) {
- return null;
- }
- return unmarshallAction((Element) node);
- }
-
- protected abstract ACTION unmarshallAction(Element element) throws
DeltaCloudClientException;
-}
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/unmarshal/AbstractDeltaCloudObjectsUnmarshaller.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/unmarshal/AbstractDeltaCloudObjectsUnmarshaller.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/unmarshal/AbstractDeltaCloudObjectsUnmarshaller.java 2011-01-06
22:40:47 UTC (rev 27959)
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.tools.deltacloud.core.client.unmarshal;
+
+import java.util.List;
+
+import org.jboss.tools.deltacloud.core.client.DeltaCloudClientException;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * @author André Dietisheim
+ */
+@SuppressWarnings("rawtypes")
+public abstract class AbstractDeltaCloudObjectsUnmarshaller<CHILD> extends
AbstractDOMUnmarshaller<List> {
+
+ private String childTag;
+
+ public AbstractDeltaCloudObjectsUnmarshaller(String parentTag, String childTag) {
+ super(parentTag, List.class);
+ this.childTag = childTag;
+ }
+
+ @SuppressWarnings("unchecked")
+ protected List doUnmarshall(Element element, List children) throws Exception {
+ if (element != null) {
+ NodeList nodeList = element.getElementsByTagName(childTag);
+ if (nodeList != null
+ && nodeList.getLength() > 0) {
+ for (int i = 0; i < nodeList.getLength(); i++) {
+ Node node = nodeList.item(i);
+ if (node instanceof Element) {
+ CHILD child = unmarshallChild(node);
+ children.add(child);
+ }
+ }
+ }
+ }
+ return children;
+ }
+
+ protected abstract CHILD unmarshallChild(Node node) throws DeltaCloudClientException;
+}
Property changes on:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/unmarshal/AbstractDeltaCloudObjectsUnmarshaller.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/unmarshal/InstanceActionUnmarshaller.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/unmarshal/InstanceActionUnmarshaller.java 2011-01-06
22:12:24 UTC (rev 27958)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/unmarshal/InstanceActionUnmarshaller.java 2011-01-06
22:40:47 UTC (rev 27959)
@@ -10,12 +10,13 @@
******************************************************************************/
package org.jboss.tools.deltacloud.core.client.unmarshal;
+import org.jboss.tools.deltacloud.core.client.Instance;
import org.jboss.tools.deltacloud.core.client.InstanceAction;
/**
* @author André Dietisheim
*/
-public class InstanceActionUnmarshaller extends
AbstractActionUnmarshaller<InstanceAction> {
+public class InstanceActionUnmarshaller extends
AbstractActionUnmarshaller<InstanceAction, Instance> {
public InstanceActionUnmarshaller() {
super(InstanceAction.class);
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/unmarshal/InstanceUnmarshaller.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/unmarshal/InstanceUnmarshaller.java 2011-01-06
22:12:24 UTC (rev 27958)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/unmarshal/InstanceUnmarshaller.java 2011-01-06
22:40:47 UTC (rev 27959)
@@ -24,7 +24,7 @@
/**
* @author André Dietisheim
*/
-public class InstanceUnmarshaller extends AbstractDOMActionAwareUnmarshaller<Instance,
InstanceAction> {
+public class InstanceUnmarshaller extends AbstractActionAwareUnmarshaller<Instance,
InstanceAction> {
public InstanceUnmarshaller() {
super("instance", Instance.class, "link");
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/unmarshal/InstancesUnmarshaller.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/unmarshal/InstancesUnmarshaller.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/unmarshal/InstancesUnmarshaller.java 2011-01-06
22:40:47 UTC (rev 27959)
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.tools.deltacloud.core.client.unmarshal;
+
+import org.jboss.tools.deltacloud.core.client.DeltaCloudClientException;
+import org.jboss.tools.deltacloud.core.client.Instance;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * @author André Dietisheim
+ */
+public class InstancesUnmarshaller extends
AbstractDeltaCloudObjectsUnmarshaller<Instance> {
+
+ public InstancesUnmarshaller() {
+ super("instances", "instance");
+ }
+
+ @Override
+ protected Instance unmarshallChild(Node node) throws DeltaCloudClientException {
+ Instance instance = new InstanceUnmarshaller().unmarshall((Element) node, new
Instance());
+ return instance;
+ }
+}
Property changes on:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/unmarshal/InstancesUnmarshaller.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/unmarshal/KeyActionUnmarshaller.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/unmarshal/KeyActionUnmarshaller.java 2011-01-06
22:12:24 UTC (rev 27958)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/unmarshal/KeyActionUnmarshaller.java 2011-01-06
22:40:47 UTC (rev 27959)
@@ -10,12 +10,13 @@
******************************************************************************/
package org.jboss.tools.deltacloud.core.client.unmarshal;
+import org.jboss.tools.deltacloud.core.client.Key;
import org.jboss.tools.deltacloud.core.client.KeyAction;
/**
* @author André Dietisheim
*/
-public class KeyActionUnmarshaller extends AbstractActionUnmarshaller<KeyAction> {
+public class KeyActionUnmarshaller extends AbstractActionUnmarshaller<KeyAction,
Key> {
public KeyActionUnmarshaller() {
super(KeyAction.class);
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/unmarshal/KeyUnmarshaller.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/unmarshal/KeyUnmarshaller.java 2011-01-06
22:12:24 UTC (rev 27958)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/unmarshal/KeyUnmarshaller.java 2011-01-06
22:40:47 UTC (rev 27959)
@@ -22,7 +22,7 @@
/**
* @author André Dietisheim
*/
-public class KeyUnmarshaller extends AbstractDOMActionAwareUnmarshaller<Key,
KeyAction> {
+public class KeyUnmarshaller extends AbstractActionAwareUnmarshaller<Key,
KeyAction> {
public KeyUnmarshaller() {
super("key", Key.class, "link");
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/unmarshal/KeysUnmarshaller.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/unmarshal/KeysUnmarshaller.java 2011-01-06
22:12:24 UTC (rev 27958)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/unmarshal/KeysUnmarshaller.java 2011-01-06
22:40:47 UTC (rev 27959)
@@ -10,38 +10,23 @@
******************************************************************************/
package org.jboss.tools.deltacloud.core.client.unmarshal;
-import java.util.List;
-
+import org.jboss.tools.deltacloud.core.client.DeltaCloudClientException;
import org.jboss.tools.deltacloud.core.client.Key;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
/**
* @author André Dietisheim
*/
-@SuppressWarnings("rawtypes")
-public class KeysUnmarshaller extends AbstractDOMUnmarshaller<List> {
+public class KeysUnmarshaller extends AbstractDeltaCloudObjectsUnmarshaller<Key> {
public KeysUnmarshaller() {
- super("keys", List.class);
+ super("keys", "key");
}
- @SuppressWarnings("unchecked")
- protected List doUnmarshall(Element element, List keys) throws Exception {
- if (element != null) {
- NodeList nodeList = element.getElementsByTagName("key");
- if (nodeList != null
- && nodeList.getLength() > 0) {
- for (int i = 0; i < nodeList.getLength(); i++) {
- Node node = nodeList.item(i);
- if (node instanceof Element) {
- Key key = new KeyUnmarshaller().unmarshall((Element) node, new Key());
- keys.add(key);
- }
- }
- }
- }
- return keys;
+ @Override
+ protected Key unmarshallChild(Node node) throws DeltaCloudClientException {
+ Key key = new KeyUnmarshaller().unmarshall((Element) node, new Key());
+ return key;
}
}
Modified:
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/core/client/InstanceDomUnmarshallingTest.java
===================================================================
---
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/core/client/InstanceDomUnmarshallingTest.java 2011-01-06
22:12:24 UTC (rev 27958)
+++
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/core/client/InstanceDomUnmarshallingTest.java 2011-01-06
22:40:47 UTC (rev 27959)
@@ -15,6 +15,8 @@
import java.io.ByteArrayInputStream;
import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.List;
import javax.xml.bind.JAXBException;
@@ -23,8 +25,10 @@
import org.jboss.tools.deltacloud.core.client.InstanceAction;
import org.jboss.tools.deltacloud.core.client.unmarshal.InstanceActionUnmarshaller;
import org.jboss.tools.deltacloud.core.client.unmarshal.InstanceUnmarshaller;
-import
org.jboss.tools.internal.deltacloud.test.fakes.ServerInstanceResponseFakes.InstanceActionResponse;
-import
org.jboss.tools.internal.deltacloud.test.fakes.ServerInstanceResponseFakes.InstanceResponse;
+import org.jboss.tools.deltacloud.core.client.unmarshal.InstancesUnmarshaller;
+import
org.jboss.tools.internal.deltacloud.test.fakes.InstanceResponseFakes.InstanceActionResponse;
+import
org.jboss.tools.internal.deltacloud.test.fakes.InstanceResponseFakes.InstanceResponse;
+import
org.jboss.tools.internal.deltacloud.test.fakes.InstanceResponseFakes.InstancesResponse;
import org.junit.Test;
/**
@@ -33,7 +37,7 @@
public class InstanceDomUnmarshallingTest {
@Test
- public void keyActionMayBeUnmarshalled() throws MalformedURLException, JAXBException,
DeltaCloudClientException {
+ public void instanceActionMayBeUnmarshalled() throws MalformedURLException,
JAXBException, DeltaCloudClientException {
InstanceAction instanceAction = new InstanceAction();
ByteArrayInputStream inputStream = new
ByteArrayInputStream(InstanceActionResponse.response.getBytes());
new InstanceActionUnmarshaller().unmarshall(inputStream, instanceAction);
@@ -46,7 +50,7 @@
@Test
public void instanceMayBeUnmarshalled() throws DeltaCloudClientException {
Instance instance = new Instance();
- ByteArrayInputStream inputStream = new
ByteArrayInputStream(InstanceResponse.instanceResponse.getBytes());
+ ByteArrayInputStream inputStream = new
ByteArrayInputStream(InstanceResponse.response.getBytes());
new InstanceUnmarshaller().unmarshall(inputStream, instance);
assertNotNull(instance);
assertEquals(InstanceResponse.id1, instance.getId());
@@ -66,4 +70,22 @@
assertEquals(InstanceResponse.privateAddress1, instance.getPrivateAddresses().get(0));
}
+
+ @Test
+ public void instancesMayBeUnmarshalled() throws MalformedURLException, JAXBException,
DeltaCloudClientException {
+ ByteArrayInputStream inputStream = new
ByteArrayInputStream(InstancesResponse.response.getBytes());
+ List<Instance> instances = new ArrayList<Instance>();
+ new InstancesUnmarshaller().unmarshall(inputStream, instances);
+ assertEquals(2, instances.size());
+
+ Instance instance = instances.get(0);
+ assertEquals(InstancesResponse.id1, instance.getId());
+ assertEquals(InstancesResponse.name1, instance.getName());
+
+ instance = instances.get(1);
+ assertEquals(InstancesResponse.id2, instance.getId());
+ assertEquals(InstancesResponse.name2, instance.getName());
+ assertEquals(2, instance.getActions().size());
+ }
+
}
Modified:
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/core/client/KeyDomUnmarshallingTest.java
===================================================================
---
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/core/client/KeyDomUnmarshallingTest.java 2011-01-06
22:12:24 UTC (rev 27958)
+++
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/core/client/KeyDomUnmarshallingTest.java 2011-01-06
22:40:47 UTC (rev 27959)
@@ -28,10 +28,10 @@
import org.jboss.tools.deltacloud.core.client.unmarshal.KeyActionUnmarshaller;
import org.jboss.tools.deltacloud.core.client.unmarshal.KeyUnmarshaller;
import org.jboss.tools.deltacloud.core.client.unmarshal.KeysUnmarshaller;
-import org.jboss.tools.internal.deltacloud.test.fakes.ServerKeyResponseFakes;
-import
org.jboss.tools.internal.deltacloud.test.fakes.ServerKeyResponseFakes.KeyActionResponse;
-import
org.jboss.tools.internal.deltacloud.test.fakes.ServerKeyResponseFakes.KeyResponse;
-import
org.jboss.tools.internal.deltacloud.test.fakes.ServerKeyResponseFakes.KeysResponse;
+import org.jboss.tools.internal.deltacloud.test.fakes.KeyResponseFakes;
+import
org.jboss.tools.internal.deltacloud.test.fakes.KeyResponseFakes.KeyActionResponse;
+import org.jboss.tools.internal.deltacloud.test.fakes.KeyResponseFakes.KeyResponse;
+import org.jboss.tools.internal.deltacloud.test.fakes.KeyResponseFakes.KeysResponse;
import org.junit.Test;
/**
@@ -56,7 +56,7 @@
ByteArrayInputStream inputStream = new
ByteArrayInputStream(KeyResponse.keyResponse.getBytes());
new KeyUnmarshaller().unmarshall(inputStream, key);
assertNotNull(key);
- assertEquals(ServerKeyResponseFakes.KeyResponse.id, key.getId());
+ assertEquals(KeyResponseFakes.KeyResponse.id, key.getId());
assertEquals(KeyResponse.fingerprint, key.getFingerprint());
assertEquals(new URL(KeyResponse.url), key.getUrl());
assertEquals(KeyResponse.pem, key.getPem());
@@ -86,5 +86,4 @@
assertEquals(KeysResponse.name1, action.getName());
assertEquals(HttpMethod.valueOf(KeysResponse.method1.toUpperCase()),
action.getMethod());
}
-
}
Copied:
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/fakes/InstanceResponseFakes.java
(from rev 27956,
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/fakes/ServerInstanceResponseFakes.java)
===================================================================
---
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/fakes/InstanceResponseFakes.java
(rev 0)
+++
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/fakes/InstanceResponseFakes.java 2011-01-06
22:40:47 UTC (rev 27959)
@@ -0,0 +1,155 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.tools.internal.deltacloud.test.fakes;
+
+import org.jboss.tools.deltacloud.core.client.Instance.InstanceState;
+
+/**
+ * @author André Dietisheim
+ */
+public class InstanceResponseFakes {
+
+ public static class InstanceActionResponse {
+ public static final String url =
"http://try.steamcannon.org/deltacloud/api/instances/i-6f16e503/start";
+ public static final String method = "post";
+ public static final String name = "start";
+ public static final String response = ServerResponseFakes.getActionXML(url, method,
name);
+ }
+
+ public static class InstanceResponse {
+ public static final String url1 =
"http://try.steamcannon.org/deltacloud/api/instances/i-6f16e503";
+ public static final String id1 = "i-6f16e503";
+ public static final String name1 = "ami-7d07ec14";
+ public static final String ownerId1 = "357159121505";
+ public static final String image1Url =
"http://try.steamcannon.org/deltacloud/api/images/ami-7d07ec14";
+ public static final String image1Id = "ami-7d07ec14";
+ public static final String realm1Url =
"http://try.steamcannon.org/deltacloud/api/realms/us-east-1a";
+ public static final String realm1Id = "us-east-1a";
+ public static final InstanceState state = InstanceState.RUNNING;
+ public static final String hardwareProfile1Url =
"http://try.steamcannon.org/deltacloud/api/hardware_profiles/m1.small";
+ public static final String hardwareProfile1Id = "m1.small";
+ public static final String keyname1 = "ad10";
+ public static final String actionNameStop = "stop";
+ public static final String actionNameReboot = "reboot";
+ public static final String publicAddress1 =
"ec2-50-16-108-18.compute-1.amazonaws.com";
+ public static final String privateAddress1 =
"ec2-50-16-108-18.compute-1.amazonaws.com";
+
+ public static final String response = getInstanceResponseXML(url1, id1, name1,
ownerId1, image1Url,
+ image1Id, realm1Url, realm1Id, state, hardwareProfile1Url, hardwareProfile1Id,
keyname1,
+ actionNameStop, actionNameReboot, publicAddress1, privateAddress1);
+ }
+
+ public static class InstancesResponse {
+
+ public static final String url1 =
"http://try.steamcannon.org/deltacloud/api/instances/i-6f16e503";
+ public static final String id1 = "i-6f16e503";
+ public static final String name1 = "ami-7d07ec14";
+ public static final String ownerId1 = "357159121505";
+ public static final String image1Url =
"http://try.steamcannon.org/deltacloud/api/images/ami-7d07ec14";
+ public static final String image1Id = "ami-7d07ec14";
+ public static final String realm1Url =
"http://try.steamcannon.org/deltacloud/api/realms/us-east-1a";
+ public static final String realm1Id = "us-east-1a";
+ public static final InstanceState state = InstanceState.RUNNING;
+ public static final String hardwareProfile1Url =
"http://try.steamcannon.org/deltacloud/api/hardware_profiles/m1.small";
+ public static final String hardwareProfile1Id = "m1.small";
+ public static final String keyname1 = "ad10";
+ public static final String actionNameStop = "stop";
+ public static final String actionNameReboot = "reboot";
+ public static final String publicAddress1 =
"ec2-50-16-108-18.compute-1.amazonaws.com";
+ public static final String privateAddress1 =
"ec2-50-16-108-18.compute-1.amazonaws.com";
+
+ public static final String url2 =
"http://try.steamcannon.org/deltacloud/api/instances/i-6f16e553";
+ public static final String id2 = "i-6f16e503";
+ public static final String name2 = "ami-7d07ec14";
+ public static final String ownerId2 = "357159121505";
+ public static final String image2Url =
"http://try.steamcannon.org/deltacloud/api/images/ami-7d07ec17";
+ public static final String image2Id = "ami-7d07ec14";
+ public static final String realm2Url =
"http://try.steamcannon.org/deltacloud/api/realms/us-east-2a";
+ public static final String realm2Id = "us-east-2a";
+ public static final InstanceState state2 = InstanceState.STOPPED;
+ public static final String hardwareProfile2Url =
"http://try.steamcannon.org/deltacloud/api/hardware_profiles/m1.large";
+ public static final String hardwareProfile2Id = "m1.large";
+ public static final String keyname2 = "ad11";
+ public static final String publicAddress2 =
"ec2-50-16-108-19.compute-2.amazonaws.com";
+ public static final String privateAddress2 =
"ec2-50-16-108-19.compute-2.amazonaws.com";
+
+ public static final String response =
+ "<instances>"
+ + getInstanceResponseXML(url1, id1, name1, ownerId1, image1Url,
+ image1Id, realm1Url, realm1Id, state, hardwareProfile1Url, hardwareProfile1Id,
+ keyname1,
+ actionNameStop, actionNameReboot, publicAddress1, privateAddress1)
+ + getInstanceResponseXML(url2, id2, name2, ownerId2, image2Url,
+ image2Id, realm2Url, realm2Id, state, hardwareProfile2Url, hardwareProfile2Id,
+ keyname2,
+ actionNameReboot, actionNameReboot, publicAddress2, privateAddress2)
+ + "</instances>";
+
+ }
+
+ private static final String getInstanceResponseXML(String url, String id, String name,
String owner,
+ String imageUrl, String imageId, String realmUrl, String realmId, InstanceState
state,
+ String hardwareProfileUrl, String hardwareProfileId, String keyname, String
actionName1,
+ String actionName2, String publicAddress, String privateAddress) {
+ return "<instance href=\""
+ + url
+ + "\" id=\""
+ + id
+ + "\">"
+ + "<name>"
+ + name
+ + "</name>"
+ + "<owner_id>"
+ + owner
+ + "</owner_id>"
+ + "<image href=\""
+ + imageUrl
+ + "\" id=\""
+ + imageId
+ + "\"/>"
+ + getRealmResponseXML(realmUrl, realmId)
+ + "<state>"
+ + state.toString()
+ + "</state>"
+ + getHardwareProfileXML(hardwareProfileUrl, hardwareProfileId)
+ + "<actions>"
+ +
ServerResponseFakes.getActionXML("http://try.steamcannon.org/deltacl...
+ id
+ + "/reboot", "post", actionName1)
+ +
ServerResponseFakes.getActionXML("http://try.steamcannon.org/deltacl...
+ id
+ + "/stop", "post", actionName2)
+ + "</actions>"
+ + "<public_addresses>"
+ + getAddressXML(publicAddress)
+ + "</public_addresses>"
+ + "<private_addresses>"
+ + getAddressXML(privateAddress)
+ + "</private_addresses>"
+ + "<authentication type='key'>"
+ + "<login>"
+ + "<keyname>" + keyname + "</keyname>"
+ + "</login>"
+ + "</authentication>"
+ + "</instance>";
+ }
+
+ private static String getAddressXML(String address) {
+ return "<address>" + address + "</address>";
+ }
+
+ private static String getHardwareProfileXML(String url, String id) {
+ return "<hardware_profile href=\"" + url + "\"
id=\"" + id + "\"></hardware_profile>";
+ }
+
+ private static String getRealmResponseXML(String url, String id) {
+ return "<realm href=\"" + url + "\" id=\"" + id +
"\"/>";
+ }
+
+}
Property changes on:
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/fakes/InstanceResponseFakes.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/fakes/KeyResponseFakes.java
(from rev 27956,
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/fakes/ServerKeyResponseFakes.java)
===================================================================
---
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/fakes/KeyResponseFakes.java
(rev 0)
+++
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/fakes/KeyResponseFakes.java 2011-01-06
22:40:47 UTC (rev 27959)
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.tools.internal.deltacloud.test.fakes;
+
+/**
+ * @author André Dietisheim
+ */
+public class KeyResponseFakes {
+
+ public static class KeyActionResponse {
+ public static final String url =
"http://localhost:3001/api/keys/test1292840175447";
+ public static final String method = "delete";
+ public static final String name = "destroy";
+ public static final String keyActionResponse = ServerResponseFakes.getActionXML(url,
method, name);
+ }
+
+ public static class KeyResponse {
+ public static final String url =
"http://localhost:3001/api/keys/test1292840175447";
+ public static final String method = "delete";
+ public static final String id = "test1292840175447";
+ public static final String name = "destroy";
+ public static final String fingerprint =
"60:7c:f6:9e:e0:a1:52:bc:c0:9a:11:80:a7:1b:f6:8b:c6:55:cd:1f";
+ public static final String pem =
+ "-----BEGIN RSA PRIVATE KEY-----"
+ +
"YkFqsstgVJqYc=sxypCDk=qJbHOmhQNYxaQR4vna=ccPbj68MuxQSZ9tiyu+Z8yAog0DI65/j6u\n"
+ +
"xE6gTMsqqTrDkGmAwhiGLsgORkQyxEthGyDfA40YaBf5/5F=Cvuj2zpnp63JIrUrqoqI1FQYhnA\n"
+ +
"U34yKaj8+3/0AqsdEmWsWLMbV4HXaRtGZOPbERnJE28EhLlq/v+9wC59hpIZt6s4K0eRBYxCWz/\n"
+ +
"xvEG=7wZJi7WE0/tsH9YIAHaLRqyxV7H5kRqaYExZhUpBgf/x745KJlPpr1I20BJSrj6Fw4z4P5\n"
+ +
"DIUPDWit8aQdnBpO2fq9eQLGZKyWmj5xpzFm5DxbV1K=bdmqCnC6XHTLcfV4fqW1egYg2DK5WCj\n"
+ +
"nsl+mQjn4CNvEdymhna7+Bw0D3JcPcW/EGUrsBGEGLT/suQbEi8x0vQscpBEAizq5GZaKZ6Kec9\n"
+ +
"7MOHpx7qDqIAPjH9Y3ben7EaR0O3laY/OPrFREw8jP=mptePHF2r07s52QkdqkbU4ePC5BSWOcb\n"
+ +
"bhOqypbbv9V8YssYLyt6m3VOJFHOoERaDJQ2fMmqTDuFc87lxDrChJk4cw0q9o6Q+YzEnjTqGQo\n"
+ +
"XcwTtutpL97f1HjO34XlcHn3B1iZ8lsQGJWry9MWaiCdjj02v0mfN+UpbIQNBX452Xllf8YM//0\n"
+ +
"Kaylt3GZvr2bJsJ=lQIUIxVzREHd7ym/hRNTBx5qK2/=8h57IdyQHZSnjDT05qDRsSPcm5nQmbM\n"
+ +
"dgivv0/vXogWg9ehbym4DNez38QVkQaoJuKd/ESBIU2p8PIEXWC13HHzIMDbkbM235nFn3Roj59\n"
+ +
"xt2AJoQnltdfuhA4+5ApnnIYcWzgkd8vWZPhNL2u40Sw1ZPrM+g4n7H48IdwtE3vZ0XfF3Lpdee\n"
+ +
"IReubErRzxIMNVz=PrLQMAOhukYNJeH63PdxfSsJf7rtGwA1qEF1WcZ1ibvAuFr0G3KQalGCgCh\n"
+ +
"zkF63HCWcjafUTJ3jE6/U5ZPu8GrhAQQqu=r3NyzLgoTBaNwfe7ybxvBBofjdmD9xPipOhrQjDC\n"
+ +
"PDeaMDZ6XzwAddh4fd1K3kl29DXNBmPAgfaG8CgdnHVc/gQgAv40RvWDNnYae0/MGE+qrLN0XXF\n"
+ +
"1g3qHLkmqdtg88nCH=X7kf6FZZ3LE+bLKIF2Y4Xh3X8sqHlImLWSlKvKu6/CuB4GsrfLxu1VLdc\n"
+ +
"ee3DxUIaqz3LmkERnT7ALcMBjBjRNp=DR=x7zON0f0Nht0gIj1vvDWQmEzRqGxgTwS2PtGL3bOZ\n"
+ +
"v2hiV3G3+S/9SAD9rfiW9Ws1YLH5mVDcHcKWhHXoM/UqPj3ob3yGzvYgR+X/dIg7tug/k=TTtD8\n"
+ +
"1wkG4gTjHkfEhCs05/+PZ4rFG15nVpv06e/a3nXtyDQ77qH3irRPsLZDp/CWFdt=Poe4NLX46gE\n"
+ +
"nU07L+ueqgZUa8Tq6A9oG7QUyjtJh4ZxkShYkIullvUksW0yppaIeB32Xxw2XVEtdu/v=rFHSHh\n"
+ +
"HwoZ1A/=ku7ICdMg5gD6U+Zg0YlxniHDaSJ8A6kdt2iUaPaZQQcH8T4yh90CKHhbl5NzhxAu3Jz\n"
+ +
"dc=oRQqdzizw9UrN84wEmQ6r9hDHUq2x14PR=xBzwLGzR2dh73GdjxF5OmOrp3m4yCkw\n"
+ + "-----END RSA PRIVATE KEY-----\n";
+ public static final String keyResponse = getKeyResponseXML(id, fingerprint, pem, url,
method, name);
+ }
+
+ public static class KeysResponse {
+
+ public static final String url1 =
"http://localhost:3001/api/keys/test1292840175417";
+ public static final String method1 = "delete";
+ public static final String id1 = "test1292840175447";
+ public static final String name1 = "destroy";
+ public static final String fingerprint1 =
"60:7c:f6:9e:e0:a1:52:bc:c0:9a:11:80:a7:1b:f6:8b:c6:55:cd:1f";
+ public static final String pem1 = "-----BEGIN RSA PRIVATE KEY-----"
+ +
"YkFqsstgVJqYc=sxypCDk=qJbHOmhQNYxaQR4vna=ccPbj68MuxQSZ9tiyu+Z8yAog0DI65/j6u\n";
+
+ public static final String url2 =
"http://localhost:3001/api/keys/test1292840175427";
+ public static final String method2 = "delete";
+ public static final String id2 = "test1292840175447";
+ public static final String name2 = "destroy";
+ public static final String fingerprint2 =
"60:7c:f6:9e:e0:a1:52:bc:c0:9a:11:80:a7:1b:f6:8b:c6:55:cd:1f";
+ public static final String pem2 =
+ "-----BEGIN RSA PRIVATE KEY-----"
+ +
"YkFqsstgVJqYc=sxypCDk=qJbHOmhQNYxaQR4vna=ccPbj68MuxQSZ9tiyu+Z8yAog0DI65/j6u";
+
+ public static final String keysResponse =
+ "<keys>"
+ + getKeyResponseXML(id1, fingerprint1, pem1, url1, method1, name1)
+ + getKeyResponseXML(id2, fingerprint2, pem2, url2, method2, name2)
+ + "</keys>";
+ }
+
+ private static final String getKeyResponseXML(String id, String fingerprint, String pem,
String url, String method,
+ String name) {
+ return "<key href='" + url + "' id='" + id +
"' type='key'>"
+ + "<actions>"
+ + ServerResponseFakes.getActionXML(url, method, name)
+ + "</actions>"
+ + "<fingerprint>" + fingerprint + "</fingerprint>"
+ + "<pem><pem>" + pem + "</pem></pem>"
+ + "<state></state>"
+ + "</key>";
+
+ }
+
+}
Property changes on:
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/fakes/KeyResponseFakes.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted:
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/fakes/ServerInstanceResponseFakes.java
===================================================================
---
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/fakes/ServerInstanceResponseFakes.java 2011-01-06
22:12:24 UTC (rev 27958)
+++
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/fakes/ServerInstanceResponseFakes.java 2011-01-06
22:40:47 UTC (rev 27959)
@@ -1,108 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.tools.internal.deltacloud.test.fakes;
-
-import org.jboss.tools.deltacloud.core.client.Instance.InstanceState;
-
-/**
- * @author André Dietisheim
- */
-public class ServerInstanceResponseFakes {
-
- public static class InstanceActionResponse {
- public static final String url =
"http://try.steamcannon.org/deltacloud/api/instances/i-6f16e503/start";
- public static final String method = "post";
- public static final String name = "start";
- public static final String response = ServerResponseFakes.getActionXML(url, method,
name);
- }
-
- public static class InstanceResponse {
-
- public static final String url1 =
"http://try.steamcannon.org/deltacloud/api/instances/i-6f16e503";
- public static final String id1 = "i-6f16e503";
- public static final String name1 = "ami-7d07ec14";
- public static final String ownerId1 = "357159121505";
- public static final String image1Url =
"http://try.steamcannon.org/deltacloud/api/images/ami-7d07ec14";
- public static final String image1Id = "ami-7d07ec14";
- public static final String realm1Url =
"http://try.steamcannon.org/deltacloud/api/realms/us-east-1a";
- public static final String realm1Id = "us-east-1a";
- public static final InstanceState state = InstanceState.RUNNING;
- public static final String hardwareProfile1Url =
"http://try.steamcannon.org/deltacloud/api/hardware_profiles/m1.small";
- public static final String hardwareProfile1Id = "m1.small";
- public static final String keyname1 = "ad10";
- public static final String actionNameStop = "stop";
- public static final String actionNameReboot = "reboot";
- public static final String publicAddress1 =
"ec2-50-16-108-18.compute-1.amazonaws.com";
- public static final String privateAddress1 =
"ec2-50-16-108-18.compute-1.amazonaws.com";
-
- public static final String instanceResponse = getInstanceResponseXML(url1, id1, name1,
ownerId1, image1Url,
- image1Id, realm1Url, realm1Id, state, hardwareProfile1Url, hardwareProfile1Id,
keyname1,
- actionNameStop, actionNameReboot, publicAddress1, privateAddress1);
- }
-
- private static final String getInstanceResponseXML(String url, String id, String name,
String owner,
- String imageUrl, String imageId, String realmUrl, String realmId, InstanceState
state,
- String hardwareProfileUrl, String hardwareProfileId, String keyname, String
actionName1,
- String actionName2, String publicAddress, String privateAddress) {
- return "<instance href=\""
- + url
- + "\" id=\""
- + id
- + "\">"
- + "<name>"
- + name
- + "</name>"
- + "<owner_id>"
- + owner
- + "</owner_id>"
- + "<image href=\""
- + imageUrl
- + "\" id=\""
- + imageId
- + "\"/>"
- + getRealmResponseXML(realmUrl, realmId)
- + "<state>"
- + state.toString()
- + "</state>"
- + getHardwareProfileXML(hardwareProfileUrl, hardwareProfileId)
- + "<actions>"
- +
ServerResponseFakes.getActionXML("http://try.steamcannon.org/deltacl...
+ id
- + "/reboot", "post", actionName1)
- +
ServerResponseFakes.getActionXML("http://try.steamcannon.org/deltacl...
+ id
- + "/stop", "post", actionName2)
- + "</actions>"
- + "<public_addresses>"
- + getAddressXML(publicAddress)
- + "</public_addresses>"
- + "<private_addresses>"
- + getAddressXML(privateAddress)
- + "</private_addresses>"
- + "<authentication type='key'>"
- + "<login>"
- + "<keyname>" + keyname + "</keyname>"
- + "</login>"
- + "</authentication>"
- + "</instance>";
- }
-
- private static String getAddressXML(String address) {
- return "<address>" + address + "</address>";
- }
-
- private static String getHardwareProfileXML(String url, String id) {
- return "<hardware_profile href=\"" + url + "\"
id=\"" + id + "\"></hardware_profile>";
- }
-
- private static String getRealmResponseXML(String url, String id) {
- return "<realm href=\"" + url + "\" id=\"" + id +
"\"/>";
- }
-
-}
Deleted:
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/fakes/ServerKeyResponseFakes.java
===================================================================
---
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/fakes/ServerKeyResponseFakes.java 2011-01-06
22:12:24 UTC (rev 27958)
+++
trunk/deltacloud/tests/org.jboss.tools.deltacloud.test/src/org/jboss/tools/internal/deltacloud/test/fakes/ServerKeyResponseFakes.java 2011-01-06
22:40:47 UTC (rev 27959)
@@ -1,98 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.tools.internal.deltacloud.test.fakes;
-
-/**
- * @author André Dietisheim
- */
-public class ServerKeyResponseFakes {
-
- public static class KeyActionResponse {
- public static final String url =
"http://localhost:3001/api/keys/test1292840175447";
- public static final String method = "delete";
- public static final String name = "destroy";
- public static final String keyActionResponse = ServerResponseFakes.getActionXML(url,
method, name);
- }
-
- public static class KeyResponse {
- public static final String url =
"http://localhost:3001/api/keys/test1292840175447";
- public static final String method = "delete";
- public static final String id = "test1292840175447";
- public static final String name = "destroy";
- public static final String fingerprint =
"60:7c:f6:9e:e0:a1:52:bc:c0:9a:11:80:a7:1b:f6:8b:c6:55:cd:1f";
- public static final String pem =
- "-----BEGIN RSA PRIVATE KEY-----"
- +
"YkFqsstgVJqYc=sxypCDk=qJbHOmhQNYxaQR4vna=ccPbj68MuxQSZ9tiyu+Z8yAog0DI65/j6u\n"
- +
"xE6gTMsqqTrDkGmAwhiGLsgORkQyxEthGyDfA40YaBf5/5F=Cvuj2zpnp63JIrUrqoqI1FQYhnA\n"
- +
"U34yKaj8+3/0AqsdEmWsWLMbV4HXaRtGZOPbERnJE28EhLlq/v+9wC59hpIZt6s4K0eRBYxCWz/\n"
- +
"xvEG=7wZJi7WE0/tsH9YIAHaLRqyxV7H5kRqaYExZhUpBgf/x745KJlPpr1I20BJSrj6Fw4z4P5\n"
- +
"DIUPDWit8aQdnBpO2fq9eQLGZKyWmj5xpzFm5DxbV1K=bdmqCnC6XHTLcfV4fqW1egYg2DK5WCj\n"
- +
"nsl+mQjn4CNvEdymhna7+Bw0D3JcPcW/EGUrsBGEGLT/suQbEi8x0vQscpBEAizq5GZaKZ6Kec9\n"
- +
"7MOHpx7qDqIAPjH9Y3ben7EaR0O3laY/OPrFREw8jP=mptePHF2r07s52QkdqkbU4ePC5BSWOcb\n"
- +
"bhOqypbbv9V8YssYLyt6m3VOJFHOoERaDJQ2fMmqTDuFc87lxDrChJk4cw0q9o6Q+YzEnjTqGQo\n"
- +
"XcwTtutpL97f1HjO34XlcHn3B1iZ8lsQGJWry9MWaiCdjj02v0mfN+UpbIQNBX452Xllf8YM//0\n"
- +
"Kaylt3GZvr2bJsJ=lQIUIxVzREHd7ym/hRNTBx5qK2/=8h57IdyQHZSnjDT05qDRsSPcm5nQmbM\n"
- +
"dgivv0/vXogWg9ehbym4DNez38QVkQaoJuKd/ESBIU2p8PIEXWC13HHzIMDbkbM235nFn3Roj59\n"
- +
"xt2AJoQnltdfuhA4+5ApnnIYcWzgkd8vWZPhNL2u40Sw1ZPrM+g4n7H48IdwtE3vZ0XfF3Lpdee\n"
- +
"IReubErRzxIMNVz=PrLQMAOhukYNJeH63PdxfSsJf7rtGwA1qEF1WcZ1ibvAuFr0G3KQalGCgCh\n"
- +
"zkF63HCWcjafUTJ3jE6/U5ZPu8GrhAQQqu=r3NyzLgoTBaNwfe7ybxvBBofjdmD9xPipOhrQjDC\n"
- +
"PDeaMDZ6XzwAddh4fd1K3kl29DXNBmPAgfaG8CgdnHVc/gQgAv40RvWDNnYae0/MGE+qrLN0XXF\n"
- +
"1g3qHLkmqdtg88nCH=X7kf6FZZ3LE+bLKIF2Y4Xh3X8sqHlImLWSlKvKu6/CuB4GsrfLxu1VLdc\n"
- +
"ee3DxUIaqz3LmkERnT7ALcMBjBjRNp=DR=x7zON0f0Nht0gIj1vvDWQmEzRqGxgTwS2PtGL3bOZ\n"
- +
"v2hiV3G3+S/9SAD9rfiW9Ws1YLH5mVDcHcKWhHXoM/UqPj3ob3yGzvYgR+X/dIg7tug/k=TTtD8\n"
- +
"1wkG4gTjHkfEhCs05/+PZ4rFG15nVpv06e/a3nXtyDQ77qH3irRPsLZDp/CWFdt=Poe4NLX46gE\n"
- +
"nU07L+ueqgZUa8Tq6A9oG7QUyjtJh4ZxkShYkIullvUksW0yppaIeB32Xxw2XVEtdu/v=rFHSHh\n"
- +
"HwoZ1A/=ku7ICdMg5gD6U+Zg0YlxniHDaSJ8A6kdt2iUaPaZQQcH8T4yh90CKHhbl5NzhxAu3Jz\n"
- +
"dc=oRQqdzizw9UrN84wEmQ6r9hDHUq2x14PR=xBzwLGzR2dh73GdjxF5OmOrp3m4yCkw\n"
- + "-----END RSA PRIVATE KEY-----\n";
- public static final String keyResponse = getKeyResponseXML(id, fingerprint, pem, url,
method, name);
- }
-
- public static class KeysResponse {
-
- public static final String url1 =
"http://localhost:3001/api/keys/test1292840175417";
- public static final String method1 = "delete";
- public static final String id1 = "test1292840175447";
- public static final String name1 = "destroy";
- public static final String fingerprint1 =
"60:7c:f6:9e:e0:a1:52:bc:c0:9a:11:80:a7:1b:f6:8b:c6:55:cd:1f";
- public static final String pem1 = "-----BEGIN RSA PRIVATE KEY-----"
- +
"YkFqsstgVJqYc=sxypCDk=qJbHOmhQNYxaQR4vna=ccPbj68MuxQSZ9tiyu+Z8yAog0DI65/j6u\n";
-
- public static final String url2 =
"http://localhost:3001/api/keys/test1292840175427";
- public static final String method2 = "delete";
- public static final String id2 = "test1292840175447";
- public static final String name2 = "destroy";
- public static final String fingerprint2 =
"60:7c:f6:9e:e0:a1:52:bc:c0:9a:11:80:a7:1b:f6:8b:c6:55:cd:1f";
- public static final String pem2 =
- "-----BEGIN RSA PRIVATE KEY-----"
- +
"YkFqsstgVJqYc=sxypCDk=qJbHOmhQNYxaQR4vna=ccPbj68MuxQSZ9tiyu+Z8yAog0DI65/j6u";
-
- public static final String keysResponse =
- "<keys>"
- + getKeyResponseXML(id1, fingerprint1, pem1, url1, method1, name1)
- + getKeyResponseXML(id2, fingerprint2, pem2, url2, method2, name2)
- + "</keys>";
- }
-
- private static final String getKeyResponseXML(String id, String fingerprint, String pem,
String url, String method,
- String name) {
- return "<key href='" + url + "' id='" + id +
"' type='key'>"
- + "<actions>"
- + ServerResponseFakes.getActionXML(url, method, name)
- + "</actions>"
- + "<fingerprint>" + fingerprint + "</fingerprint>"
- + "<pem><pem>" + pem + "</pem></pem>"
- + "<state></state>"
- + "</key>";
-
- }
-
-}