You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by ma...@apache.org on 2011/06/01 12:03:43 UTC

svn commit: r1130080 [2/5] - in /incubator/deltacloud/trunk/clients/java: ./ org.apache.deltacloud.client.test/ org.apache.deltacloud.client.test/META-INF/ org.apache.deltacloud.client.test/src/ org.apache.deltacloud.client.test/src/org/ org.apache.del...

Added: incubator/deltacloud/trunk/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/ServerTypeMockIntegrationTest.java
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/ServerTypeMockIntegrationTest.java?rev=1130080&view=auto
==============================================================================
--- incubator/deltacloud/trunk/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/ServerTypeMockIntegrationTest.java (added)
+++ incubator/deltacloud/trunk/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/ServerTypeMockIntegrationTest.java Wed Jun  1 10:03:40 2011
@@ -0,0 +1,136 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+package org.apache.deltacloud.client.internal.test.client;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.deltacloud.client.DeltaCloudClientException;
+import org.apache.deltacloud.client.DeltaCloudClientImpl;
+import org.apache.deltacloud.client.DeltaCloudNotFoundClientException;
+import org.apache.deltacloud.client.HttpMethod;
+import org.apache.deltacloud.client.Image;
+import org.apache.deltacloud.client.API.Driver;
+import org.apache.deltacloud.client.internal.test.context.MockIntegrationTestContext;
+import org.apache.deltacloud.client.internal.test.fakes.ServerFake;
+import org.apache.deltacloud.client.request.DeltaCloudRequest;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Integration tests for {@link DeltaCloudClientImpl#getServerType()}.
+ *
+ * @author Andre Dietisheim
+ *
+ * @see DeltaCloudClientImpl#getServerType()
+ */
+public class ServerTypeMockIntegrationTest {
+
+	private MockIntegrationTestContext testSetup;
+
+	@Before
+	public void setUp() throws IOException, DeltaCloudClientException {
+		this.testSetup = new MockIntegrationTestContext();
+		testSetup.setUp();
+	}
+
+	@After
+	public void tearDown() {
+		testSetup.tearDown();
+	}
+
+	@Test
+	public void recognizesDeltaCloud() throws IOException {
+		assertEquals(Driver.MOCK, testSetup.getClient().getServerType());
+	}
+
+	/**
+	 *
+	 * #getServerType reports {@link DeltaCloudClient.DeltaCloudType#UNKNOWN) if it queries a fake server that responds with a unknown answer.
+	 *
+	 * @throws IOException
+	 *             Signals that an I/O exception has occurred.
+	 * @throws DeltaCloudClientException
+	 */
+	@Test
+	public void reportsUnknownUrl() throws IOException, DeltaCloudClientException {
+		ServerFake serverFake =
+				new ServerFake(
+						new URL(MockIntegrationTestContext.SERVERFAKE_URL).getPort(),
+						"<dummy></dummy>");
+		serverFake.start();
+		try {
+			assertEquals(
+					Driver.UNKNOWN,
+					new DeltaCloudClientImpl(
+							MockIntegrationTestContext.SERVERFAKE_URL, MockIntegrationTestContext.DELTACLOUD_USER,
+							MockIntegrationTestContext.DELTACLOUD_PASSWORD).getServerType());
+		} finally {
+			serverFake.stop();
+		}
+	}
+
+	@Test(expected = DeltaCloudClientException.class)
+	public void listImages_cannotListIfNotAuthenticated() throws MalformedURLException, DeltaCloudClientException {
+		DeltaCloudClientImpl client = new DeltaCloudClientImpl(MockIntegrationTestContext.DELTACLOUD_URL, "badUser",
+				"badPassword");
+		client.listImages();
+	}
+
+	@Test
+	public void throwsDeltaCloudClientExceptionOnUnknownResource() {
+		try {
+			DeltaCloudClientImpl errorClient = new DeltaCloudClientImpl(MockIntegrationTestContext.DELTACLOUD_URL) {
+				@Override
+				public List<Image> listImages() throws DeltaCloudClientException {
+					request(new DeltaCloudRequest() {
+
+						@Override
+						public URL getUrl() throws MalformedURLException {
+							return new URL(MockIntegrationTestContext.DELTACLOUD_URL + "/DUMMY");
+						}
+
+						@Override
+						public HttpMethod getHttpMethod() {
+							return HttpMethod.GET;
+						}
+
+						@Override
+						public String getUrlString() {
+							return null;
+						}
+					}
+					);
+					return Collections.emptyList();
+				}
+			};
+			errorClient.listImages();
+			fail("no exception catched");
+		} catch (Exception e) {
+			assertEquals(DeltaCloudNotFoundClientException.class, e.getClass());
+		}
+	}
+}

Added: incubator/deltacloud/trunk/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/context/MockIntegrationTestContext.java
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/context/MockIntegrationTestContext.java?rev=1130080&view=auto
==============================================================================
--- incubator/deltacloud/trunk/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/context/MockIntegrationTestContext.java (added)
+++ incubator/deltacloud/trunk/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/context/MockIntegrationTestContext.java Wed Jun  1 10:03:40 2011
@@ -0,0 +1,165 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+package org.apache.deltacloud.client.internal.test.context;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
+import java.net.ConnectException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import org.apache.deltacloud.client.DeltaCloudClient;
+import org.apache.deltacloud.client.DeltaCloudClientException;
+import org.apache.deltacloud.client.DeltaCloudClientImpl;
+import org.apache.deltacloud.client.Image;
+import org.apache.deltacloud.client.Instance;
+import org.apache.deltacloud.client.StateAware.State;
+
+/**
+ * A class that holds the integration test context
+ *
+ * @author Andre Dietisheim
+ *
+ */
+public class MockIntegrationTestContext {
+
+	public static final String DELTACLOUD_URL = "http://localhost:3001";
+	public static final String SERVERFAKE_URL = "http://localhost:3002";
+	public static final String DELTACLOUD_USER = "mockuser";
+	public static final String DELTACLOUD_PASSWORD = "mockpassword";
+	private static final long TIMEOUT = 5000;
+
+	private DeltaCloudClient client;
+	private Instance testInstance;
+
+	private ExecutorService executor = Executors.newSingleThreadExecutor();
+
+	public void setUp() throws IOException, DeltaCloudClientException {
+		ensureDeltaCloudIsRunning();
+		this.client = new DeltaCloudClientImpl(DELTACLOUD_URL, DELTACLOUD_USER, DELTACLOUD_PASSWORD);
+		Image image = getFirstImage(client);
+		this.testInstance = createTestInstance(image);
+	}
+
+	private Instance createTestInstance(Image image) throws DeltaCloudClientException {
+		assertNotNull(image);
+		Instance instance = client.createInstance(image.getId());
+		return instance;
+	}
+
+	public void ensureDeltaCloudIsRunning() throws IOException {
+		try {
+			URLConnection connection = new URL(DELTACLOUD_URL).openConnection();
+			connection.connect();
+		} catch (ConnectException e) {
+			fail("Local DeltaCloud instance is not running. Please start a DeltaCloud instance before running these tests.");
+		}
+	}
+
+	public DeltaCloudClient getClient() {
+		return client;
+	}
+
+	public Instance getTestInstance() {
+		return testInstance;
+	}
+
+	public Image getFirstImage(DeltaCloudClient client) throws DeltaCloudClientException {
+		List<Image> images = client.listImages();
+		assertTrue(images.size() >= 1);
+		Image image = images.get(0);
+		return image;
+	}
+
+	public Instance getInstanceById(String id, DeltaCloudClient client) throws DeltaCloudClientException {
+		for (Instance availableInstance : client.listInstances()) {
+			if (id.equals(availableInstance.getId())) {
+				return availableInstance;
+			}
+		}
+		return null;
+	}
+
+	public void tearDown() {
+		quietlyDestroyInstance(testInstance);
+		executor.shutdownNow();
+	}
+
+	public void quietlyDestroyInstance(Instance instance) {
+		if (instance != null) {
+			try {
+				if (instance.getState() == Instance.State.RUNNING) {
+					instance.stop(client);
+				}
+				instance = waitForInstanceState(instance.getId(), Instance.State.STOPPED, TIMEOUT);
+				assertNotNull("Could not stop instance " + instance.getName(), instance);
+				assertTrue("Could not destroy instance " + instance.getName(), instance.destroy(client));
+			} catch (Exception e) {
+				// ignore
+			}
+		}
+	}
+
+	/**
+	 * Waits for an instance to get the given state for a given timeout.
+	 *
+	 * @param instanceId
+	 *            the id of the instance to watch
+	 * @param state
+	 *            the state to wait for
+	 * @param timeout
+	 *            the timeout to wait for
+	 * @return <code>true</code>, if the state was reached while waiting for
+	 *         timeout, <code>false</code> otherwise
+	 * @throws ExecutionException
+	 * @throws InterruptedException
+	 */
+	public Instance waitForInstanceState(final String instanceId, final State state, final long timeout)
+			throws InterruptedException, ExecutionException {
+		final long startTime = System.currentTimeMillis();
+		Callable<Instance> waitingCallable = new Callable<Instance>() {
+
+			@Override
+			public Instance call() throws Exception {
+				try {
+					while (System.currentTimeMillis() < startTime + timeout) {
+						Instance instance = client.listInstances(instanceId);
+						if (instance.getState() == state) {
+							return instance;
+						}
+						Thread.sleep(200);
+					}
+					return null;
+				} catch (Exception e) {
+					e.printStackTrace();
+					return null;
+				}
+			}
+		};
+		return executor.submit(waitingCallable).get();
+	}
+}

Added: incubator/deltacloud/trunk/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/APIResponseFakes.java
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/APIResponseFakes.java?rev=1130080&view=auto
==============================================================================
--- incubator/deltacloud/trunk/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/APIResponseFakes.java (added)
+++ incubator/deltacloud/trunk/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/APIResponseFakes.java Wed Jun  1 10:03:40 2011
@@ -0,0 +1,64 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+package org.apache.deltacloud.client.internal.test.fakes;
+
+/**
+ * @author André Dietisheim
+ */
+public class APIResponseFakes {
+
+	public static class APIResponse {
+		public static final String url = "http://localhost:3001/api/keys/test1292840175447";
+		public static final String driver = "ec2";
+
+		public static final String apiResponse = getApiResponseXML(url, driver);
+		public static final String invalidDriverApiResponse = getApiResponseXML(url, "foo");
+	}
+
+	private static final String getApiResponseXML(String url, String driver) {
+		return "<api driver='" + driver + "' version='0.1'>"
+				+ "  <link href='" + url + "realms' rel='realms'>"
+				+ "  </link>"
+				+ "  <link href='" + url + "images' rel='images'>"
+				+ "    <feature name='owner_id'></feature>"
+				+ "  </link>"
+				+ "  <link href='" + url + "instance_states' rel='instance_states'>"
+				+ "  </link>"
+				+ "  <link href='" + url + "instances' rel='instances'>"
+				+ "    <feature name='user_data'></feature>"
+				+ "    <feature name='authentication_key'></feature>"
+				+ "    <feature name='public_ip'></feature>"
+				+ "    <feature name='security_group'></feature>"
+				+ "  </link>"
+				+ "  <link href='" + url + "hardware_profiles' rel='hardware_profiles'>"
+				+ "  </link>"
+				+ "  <link href='" + url + "storage_snapshots' rel='storage_snapshots'>"
+				+ "  </link>"
+				+ "  <link href='" + url + "storage_volumes' rel='storage_volumes'>"
+				+ "  </link>"
+				+ "  <link href='" + url + "keys' rel='keys'>"
+				+ "  </link>"
+				+ "  <link href='" + url + "buckets' rel='buckets'>"
+				+ "    <feature name='bucket_location'></feature>"
+				+ "  </link>"
+				+ "</api>";
+
+	}
+
+}

Added: incubator/deltacloud/trunk/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/HardwareProfileResponseFakes.java
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/HardwareProfileResponseFakes.java?rev=1130080&view=auto
==============================================================================
--- incubator/deltacloud/trunk/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/HardwareProfileResponseFakes.java (added)
+++ incubator/deltacloud/trunk/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/HardwareProfileResponseFakes.java Wed Jun  1 10:03:40 2011
@@ -0,0 +1,145 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+package org.apache.deltacloud.client.internal.test.fakes;
+
+import org.apache.deltacloud.client.Property;
+import org.apache.deltacloud.client.Property.UNIT;
+
+/**
+ * @author André Dietisheim
+ */
+public class HardwareProfileResponseFakes {
+
+	public static class HardwareProfile1Response {
+		public static final String id = "m1-small";
+		public static final String propMemKind = Property.Kind.FIXED.name().toLowerCase();
+		public static final String propMemUnit = UNIT.MB.name();
+		public static final String propMemValue = "1740.8";
+		public static final String propStorageKind = Property.Kind.FIXED.name().toLowerCase();
+		public static final String propStorageUnit = UNIT.GB.name();
+		public static final String propStorageValue = "160";
+		public static final String propCPUKind = Property.Kind.FIXED.name().toLowerCase();
+		public static final String propCPUUnit = UNIT.COUNT.name().toLowerCase();
+		public static final String propCPUValue = "1";
+		public static final String propArchKind = Property.Kind.FIXED.name().toLowerCase();
+		public static final String propArchUnit = UNIT.LABEL.name().toLowerCase();
+		public static final String propArchValue = "i386";
+
+		public static final String response = getHardwareProfileResponseXML(
+				id,
+				new String[] {
+						getFixedPropertyXML(Property.Names.MEMORY.name().toLowerCase(), propMemUnit, propMemValue),
+						getFixedPropertyXML(Property.Names.STORAGE.name().toLowerCase(), propStorageUnit,
+								propStorageValue),
+						getFixedPropertyXML(Property.Names.CPU.name().toLowerCase(), propCPUUnit, propCPUValue),
+						getFixedPropertyXML(Property.Names.ARCHITECTURE.name().toLowerCase(), propArchUnit,
+								propArchValue)
+										});
+	}
+
+	public static class HardwareProfile2Response {
+		public static final String id = "m1-large";
+		public static final String propMemKind = Property.Kind.RANGE.name().toLowerCase();
+		public static final String propMemUnit = UNIT.MB.name();
+		public static final String propMemValue = "10240";
+		public static final String propMemRangeFirst = "7680.0";
+		public static final String propMemRangeLast = "15360";
+		public static final String propStorageKind = Property.Kind.ENUM.name().toLowerCase();
+		public static final String propStorageUnit = UNIT.GB.name();
+		public static final String propStorageValue = "160";
+		public static final String propStorageEnum1 = "850";
+		public static final String propStorageEnum2 = "1024";
+		public static final String propCPUKind = Property.Kind.FIXED.name().toLowerCase();
+		public static final String propCPUUnit = UNIT.COUNT.name().toLowerCase();
+		public static final String propCPUValue = "2";
+		public static final String propArchKind = Property.Kind.FIXED.name().toLowerCase();
+		public static final String propArchUnit = UNIT.LABEL.name().toLowerCase();
+		public static final String propArchValue = "x86_64";
+
+		public static final String response = getHardwareProfileResponseXML(
+				id,
+				new String[] {
+						getRangePropertyXML(Property.Names.MEMORY.name().toLowerCase(), propMemUnit, propMemValue,
+								propMemRangeFirst, propMemRangeLast),
+						getEnumPropertyXML(Property.Names.STORAGE.name().toLowerCase(), propStorageUnit,
+								propStorageValue, propStorageEnum1, propStorageEnum2),
+						getFixedPropertyXML(Property.Names.CPU.name().toLowerCase(), propCPUUnit, propCPUValue),
+						getFixedPropertyXML(Property.Names.ARCHITECTURE.name().toLowerCase(), propArchUnit,
+								propArchValue)
+								});
+	}
+
+	public static class HardwareProfilesResponse {
+
+		public static final String response =
+			"<hardware_profiles>"
+				+ HardwareProfile1Response.response
+				+ HardwareProfile2Response.response
+			+"</hardware_profiles>";
+	}
+
+	private static final String getHardwareProfileResponseXML(String id, String[] properties) {
+		StringBuilder builder = new StringBuilder();
+		for (String propertyString : properties) {
+			builder.append(propertyString);
+		}
+		return getHardwareProfileResponseXML(id, builder.toString());
+	}
+
+	private static final String getHardwareProfileResponseXML(String id, String properties) {
+		return new StringBuilder()
+				.append("<hardware_profile href=\"fakeUrl\" id=\"").append(id).append("\">")
+				.append("<name>fakeName</name>")
+				.append(properties)
+				.append("</hardware_profile>")
+				.toString();
+	}
+
+	private static String getFixedPropertyXML(String name, String unit, String value) {
+		return getPropertyXML(name, "fixed", unit, value)
+				+ getClodingPropertyTag();
+	}
+
+	private static String getRangePropertyXML(String name, String unit, String value, String first, String last) {
+		return getPropertyXML(name, "range", unit, value)
+				+ "<range first='" + first + "' last='" + last + "'/>"
+				+ getClodingPropertyTag();
+	}
+
+	private static String getEnumPropertyXML(String name, String unit, String value, String... enumValues) {
+		StringBuilder builder = new StringBuilder(getPropertyXML(name, "enum", unit, value));
+		builder.append("<enum>");
+		for (String enumValue : enumValues) {
+			builder.append("<entry value='").append(enumValue).append("' />");
+		}
+		builder.append("</enum>");
+		builder.append(getClodingPropertyTag());
+		return builder.toString();
+	}
+
+	private static String getPropertyXML(String name, String kind, String unit, String value) {
+		return "<property kind=\"" + kind + "\" name=\"" + name + "\" unit=\"" + unit + "\" value=\"" + value + "\">";
+	}
+
+	private static String getClodingPropertyTag() {
+		return "</property>";
+
+	}
+
+}

Added: incubator/deltacloud/trunk/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/ImageResponseFakes.java
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/ImageResponseFakes.java?rev=1130080&view=auto
==============================================================================
--- incubator/deltacloud/trunk/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/ImageResponseFakes.java (added)
+++ incubator/deltacloud/trunk/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/ImageResponseFakes.java Wed Jun  1 10:03:40 2011
@@ -0,0 +1,72 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+package org.apache.deltacloud.client.internal.test.fakes;
+
+
+/**
+ * @author André Dietisheim
+ */
+public class ImageResponseFakes {
+
+	public static class ImageResponse {
+		public static final String url = "http://try.steamcannon.org/deltacloud/api/images/ami-16a3577f";
+		public static final String id = "ami-16a3577f";
+		public static final String name = "sles-10-sp3-v1.00.i386";
+		public static final String ownerId = "013907871322";
+		public static final String description = "SUSE Linux Enterprise Server 10 Service Pack 3 for x86 (v1.00)";
+		public static final String architecture = "i386";
+
+		public static final String response = getImageResponseXML(url, id, name, ownerId, description, architecture);
+	}
+
+	public static class ImagesResponse {
+
+		public static final String url1 = "http://try.steamcannon.org/deltacloud/api/images/ami-16a3577f";
+		public static final String id1 = "ami-16a3577f";
+		public static final String name1 = "sles-10-sp3-v1.00.i386";
+		public static final String ownerId1 = "013907871322";
+		public static final String description1 = "SUSE Linux Enterprise Server 10 Service Pack 3 for x86 (v1.00)";
+		public static final String architecture1 = "i386";
+
+		public static final String url2 = "http://try.steamcannon.org/deltacloud/api/images/ami-16a3578f";
+		public static final String id2 = "ami-16a3578f";
+		public static final String name2 = "sles-10-sp3-v2.00.i686";
+		public static final String ownerId2 = "013907871422";
+		public static final String description2 = "SUSE Linux Enterprise Server 10 Service Pack 3 for x86 (v2.00)";
+		public static final String architecture2 = "i686";
+
+		public static final String response =
+				"<images>"
+						+ getImageResponseXML(url1, id1, name1, ownerId1, description1, architecture1)
+						+ getImageResponseXML(url2, id2, name2, ownerId2, description2, architecture2)
+						+ "</images>";
+
+	}
+
+	private static String getImageResponseXML(String url, String id, String name, String ownerId,
+			String description, String architecture) {
+		return "<image href='" + url + "' id='" + id + "'>"
+				+ "<name>" + name + "</name>"
+				+ "<owner_id>" + ownerId + "</owner_id>"
+				+ "<description>" + description + "</description>"
+				+ "<architecture>" + architecture + "</architecture>"
+				+ "<state></state>"
+				+ "</image>";
+	}
+}

Added: incubator/deltacloud/trunk/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/InstanceResponseFakes.java
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/InstanceResponseFakes.java?rev=1130080&view=auto
==============================================================================
--- incubator/deltacloud/trunk/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/InstanceResponseFakes.java (added)
+++ incubator/deltacloud/trunk/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/InstanceResponseFakes.java Wed Jun  1 10:03:40 2011
@@ -0,0 +1,163 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+package org.apache.deltacloud.client.internal.test.fakes;
+
+import org.apache.deltacloud.client.StateAware.State;
+
+/**
+ * @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 State state = State.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 State state = State.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 State state2 = State.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, State 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/deltacloud/api/instances/" + id
+						+ "/reboot", "post", actionName1)
+				+ ServerResponseFakes.getActionXML("http://try.steamcannon.org/deltacloud/api/instances/" + 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 + "\"/>";
+	}
+
+}

Added: incubator/deltacloud/trunk/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/KeyResponseFakes.java
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/KeyResponseFakes.java?rev=1130080&view=auto
==============================================================================
--- incubator/deltacloud/trunk/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/KeyResponseFakes.java (added)
+++ incubator/deltacloud/trunk/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/KeyResponseFakes.java Wed Jun  1 10:03:40 2011
@@ -0,0 +1,106 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+package org.apache.deltacloud.client.internal.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>";
+
+	}
+
+}

Added: incubator/deltacloud/trunk/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/RealmResponseFakes.java
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/RealmResponseFakes.java?rev=1130080&view=auto
==============================================================================
--- incubator/deltacloud/trunk/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/RealmResponseFakes.java (added)
+++ incubator/deltacloud/trunk/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/RealmResponseFakes.java Wed Jun  1 10:03:40 2011
@@ -0,0 +1,93 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+package org.apache.deltacloud.client.internal.test.fakes;
+
+import org.apache.deltacloud.client.Realm.RealmState;
+
+/**
+ * @author André Dietisheim
+ */
+public class RealmResponseFakes {
+
+	public static final RealmResponse realmResponse = new RealmResponse(
+			"http://try.steamcannon.org/deltacloud/api/realms/us-east-1a",
+			"us-east-1a",
+			"us-east-1a",
+			RealmState.AVAILABLE.toString().toLowerCase(),
+			"22");
+	public static final RealmResponse invalidLimitRealmResponse = new RealmResponse(
+			"http://try.steamcannon.org/deltacloud/api/realms/us-east-1a",
+			"us-east-1a",
+			"us-east-1a",
+			RealmState.AVAILABLE.toString().toLowerCase(),
+			"aa");
+
+	public static class RealmResponse {
+
+		public RealmResponse(String url, String id, String name, String state, String limit) {
+			this.url = url;
+			this.id = id;
+			this.name = name;
+			this.state = state;
+			this.limit = limit;
+			this.response = getRealmResponseXML(url, id, name, state, limit);
+		}
+
+		public String url = "http://try.steamcannon.org/deltacloud/api/realms/us-east-1a";
+		public String id = "us-east-1a";
+		public String name = "us-east-1a";
+		public String state = RealmState.AVAILABLE.toString().toLowerCase();
+		public String limit = "22";
+		public String response = getRealmResponseXML(url, id, name, state, limit);
+
+		public int getIntLimit() {
+			return Integer.parseInt(limit);
+		}
+	}
+
+	public static class RealmsResponse {
+
+		public static final String url1 = "http://try.steamcannon.org/deltacloud/api/realms/us-east-1a";
+		public static final String id1 = "us-east-1a";
+		public static final String name1 = "us-east-1a";
+		public static final String state1 = RealmState.AVAILABLE.toString().toLowerCase();
+		public static final String limit1 = "2";
+
+		public static final String url2 = "http://try.steamcannon.org/deltacloud/api/realms/us-east-2a";
+		public static final String id2 = "us-east-2a";
+		public static final String name2 = "us-east-2a";
+		public static final String state2 = RealmState.AVAILABLE.toString().toLowerCase();
+		public static final String limit2 = "12";
+
+		public static final String response =
+				"<realms>"
+						+ getRealmResponseXML(url1, id1, name1, state1, limit1)
+						+ getRealmResponseXML(url2, id2, name2, state2, limit2)
+						+ "</realms>";
+
+	}
+
+	private static String getRealmResponseXML(String url, String id, String name, String state, String limit) {
+		return "<realm href='" + url + "' id='" + id + "'>"
+				+ "<name>" + name + "</name>"
+				+ "<state>" + state + "</state>"
+				+ "<limit>" + limit + "</limit>"
+				+ "</realm>";
+	}
+}

Added: incubator/deltacloud/trunk/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/ServerFake.java
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/ServerFake.java?rev=1130080&view=auto
==============================================================================
--- incubator/deltacloud/trunk/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/ServerFake.java (added)
+++ incubator/deltacloud/trunk/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/ServerFake.java Wed Jun  1 10:03:40 2011
@@ -0,0 +1,94 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+package org.apache.deltacloud.client.internal.test.fakes;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+public class ServerFake {
+
+	public static final int DEFAULT_PORT = 3003;
+	private ExecutorService executor;
+	private int port;
+	private String response;
+	private ServerFakeSocket serverSocket;
+
+	public ServerFake(String response) {
+		this(DEFAULT_PORT, response);
+	}
+
+	public ServerFake(int port, String response) {
+		this.port = port;
+		this.response = response;
+	}
+
+	public void start() {
+		executor = Executors.newFixedThreadPool(1);
+		this.serverSocket = new ServerFakeSocket(port, response);
+		executor.submit(serverSocket);
+	}
+
+	public void stop() {
+		executor.shutdownNow();
+		serverSocket.shutdown();
+	}
+
+	private class ServerFakeSocket implements Runnable {
+		private String response;
+		private ServerSocket serverSocket;
+
+		private ServerFakeSocket(int port, String response) {
+
+			this.response = response;
+
+			try {
+				this.serverSocket = new ServerSocket(port);
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+		}
+
+		public void shutdown() {
+			try {
+				this.serverSocket.close();
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+		}
+
+		@Override
+		public void run() {
+			Socket socket;
+			try {
+				socket = serverSocket.accept();
+				OutputStream outputStream = socket.getOutputStream();
+				outputStream.write(response.getBytes());
+				outputStream.flush();
+				outputStream.close();
+				socket.close();
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+		}
+	}
+}
\ No newline at end of file

Added: incubator/deltacloud/trunk/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/ServerResponseFakes.java
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/ServerResponseFakes.java?rev=1130080&view=auto
==============================================================================
--- incubator/deltacloud/trunk/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/ServerResponseFakes.java (added)
+++ incubator/deltacloud/trunk/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/ServerResponseFakes.java Wed Jun  1 10:03:40 2011
@@ -0,0 +1,32 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+package org.apache.deltacloud.client.internal.test.fakes;
+
+/**
+ * @author André Dietisheim
+ */
+public class ServerResponseFakes {
+
+	public static final String getActionXML(String url, String method, String name) {
+		return "<link "
+				+ "method='" + method + "' "
+				+ "href='" + url + "' "
+				+ "rel='" + name + "' />";
+	}
+}

Added: incubator/deltacloud/trunk/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/utils/UrlBuilderTest.java
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/utils/UrlBuilderTest.java?rev=1130080&view=auto
==============================================================================
--- incubator/deltacloud/trunk/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/utils/UrlBuilderTest.java (added)
+++ incubator/deltacloud/trunk/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/utils/UrlBuilderTest.java Wed Jun  1 10:03:40 2011
@@ -0,0 +1,75 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+package org.apache.deltacloud.client.internal.test.utils;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.deltacloud.client.utils.UrlBuilder;
+import org.junit.Test;
+
+public class UrlBuilderTest {
+
+	@Test
+	public void buildsHost() {
+		String host = "jboss.org";
+		assertEquals(host, new UrlBuilder(host).toString());
+	}
+
+	@Test
+	public void buildsHostWithPort() {
+		assertEquals(
+				"jboss.org:8080",
+				new UrlBuilder("jboss.org")
+						.port(8080)
+						.toString());
+	}
+
+	@Test
+	public void buildsWithPath() {
+		assertEquals(
+				"jboss.org:8080/tools",
+				new UrlBuilder("jboss.org")
+						.port(8080)
+						.path("tools")
+						.toString());
+	}
+
+	@Test
+	public void buildsWith2Paths() {
+		assertEquals(
+				"jboss.org:8080/tools/usage",
+				new UrlBuilder("jboss.org")
+						.port(8080)
+						.path("tools")
+						.path("usage")
+						.toString());
+	}
+
+	@Test
+	public void buildsWithParameters() {
+		assertEquals(
+				"jboss.org:8080/tools/usage?parameter=dummy",
+				new UrlBuilder("jboss.org")
+						.port(8080)
+						.path("tools")
+						.path("usage")
+						.parameter("parameter", "dummy")
+						.toString());
+	}
+}

Added: incubator/deltacloud/trunk/clients/java/org.apache.deltacloud.client/.gitignore
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/clients/java/org.apache.deltacloud.client/.gitignore?rev=1130080&view=auto
==============================================================================
--- incubator/deltacloud/trunk/clients/java/org.apache.deltacloud.client/.gitignore (added)
+++ incubator/deltacloud/trunk/clients/java/org.apache.deltacloud.client/.gitignore Wed Jun  1 10:03:40 2011
@@ -0,0 +1,2 @@
+/bin
+/target