You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ad...@apache.org on 2014/10/24 18:08:54 UTC

[20/21] In latest Azure api, there are both OS images and Disk images.

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListImagesHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListImagesHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListImagesHandler.java
deleted file mode 100644
index f220f8c..0000000
--- a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListImagesHandler.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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.jclouds.azurecompute.xml;
-
-import java.util.List;
-
-import org.jclouds.azurecompute.domain.Image;
-import org.jclouds.http.functions.ParseSax;
-import org.xml.sax.Attributes;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableList.Builder;
-
-public final class ListImagesHandler extends ParseSax.HandlerForGeneratedRequestWithResult<List<Image>> {
-   private boolean inOSImage;
-   private final ImageHandler imageHandler = new ImageHandler();
-   private final Builder<Image> images = ImmutableList.builder();
-
-   @Override
-   public List<Image> getResult() {
-      return images.build();
-   }
-
-   @Override
-   public void startElement(String url, String name, String qName, Attributes attributes) {
-      if (qName.equals("OSImage")) {
-         inOSImage = true;
-      }
-   }
-
-   @Override
-   public void endElement(String uri, String name, String qName) {
-      if (qName.equals("OSImage")) {
-         inOSImage = false;
-         images.add(imageHandler.getResult());
-      } else if (inOSImage) {
-         imageHandler.endElement(uri, name, qName);
-      }
-   }
-
-   @Override
-   public void characters(char ch[], int start, int length) {
-      if (inOSImage) {
-         imageHandler.characters(ch, start, length);
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListOSImagesHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListOSImagesHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListOSImagesHandler.java
new file mode 100644
index 0000000..a3b8819
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListOSImagesHandler.java
@@ -0,0 +1,61 @@
+/*
+ * 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.jclouds.azurecompute.xml;
+
+import java.util.List;
+
+import org.jclouds.azurecompute.domain.OSImage;
+import org.jclouds.http.functions.ParseSax;
+import org.xml.sax.Attributes;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableList.Builder;
+
+public final class ListOSImagesHandler extends ParseSax.HandlerForGeneratedRequestWithResult<List<OSImage>> {
+   private boolean inOSImage;
+   private final OSImageHandler OSImageHandler = new OSImageHandler();
+   private final Builder<OSImage> images = ImmutableList.builder();
+
+   @Override
+   public List<OSImage> getResult() {
+      return images.build();
+   }
+
+   @Override
+   public void startElement(String url, String name, String qName, Attributes attributes) {
+      if (qName.equals("OSImage")) {
+         inOSImage = true;
+      }
+   }
+
+   @Override
+   public void endElement(String uri, String name, String qName) {
+      if (qName.equals("OSImage")) {
+         inOSImage = false;
+         images.add(OSImageHandler.getResult());
+      } else if (inOSImage) {
+         OSImageHandler.endElement(uri, name, qName);
+      }
+   }
+
+   @Override
+   public void characters(char ch[], int start, int length) {
+      if (inOSImage) {
+         OSImageHandler.characters(ch, start, length);
+      }
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/main/java/org/jclouds/azurecompute/xml/OSImageHandler.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/OSImageHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/OSImageHandler.java
new file mode 100644
index 0000000..c64b69f
--- /dev/null
+++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/OSImageHandler.java
@@ -0,0 +1,113 @@
+/*
+ * 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.jclouds.azurecompute.xml;
+
+import static com.google.common.base.Strings.emptyToNull;
+import static org.jclouds.util.SaxUtils.currentOrNull;
+
+import java.net.URI;
+import java.util.List;
+
+import org.jclouds.azurecompute.domain.OSImage;
+import org.jclouds.http.functions.ParseSax;
+
+import com.google.common.base.Splitter;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
+
+/**
+ * @see <a href="http://msdn.microsoft.com/en-us/library/jj157191" >api</a>
+ */
+final class OSImageHandler extends ParseSax.HandlerForGeneratedRequestWithResult<OSImage> {
+   private String name;
+   private final List<String> locations = Lists.newArrayList();
+   private String affinityGroup;
+   private String label;
+   private String category;
+   private String description;
+   private OSImage.Type os;
+   private URI mediaLink;
+   private Integer logicalSizeInGB;
+   private final List<String> eulas = Lists.newArrayList();
+
+   private final StringBuilder currentText = new StringBuilder();
+
+   @Override public OSImage getResult() {
+      OSImage result = OSImage
+            .create(name, ImmutableList.copyOf(locations), affinityGroup, label, description, category, os, mediaLink,
+                  logicalSizeInGB, ImmutableList.copyOf(eulas));
+      resetState(); // handler is called in a loop.
+      return result;
+   }
+
+   private void resetState() {
+      name = affinityGroup = label = description = category = null;
+      os = null;
+      mediaLink = null;
+      logicalSizeInGB = null;
+      eulas.clear();
+      locations.clear();
+   }
+
+   @Override public void endElement(String ignoredUri, String ignoredName, String qName) {
+      if (qName.equals("OS")) {
+         String osText = currentOrNull(currentText);
+         if (osText != null) {
+            os = OSImage.Type.valueOf(currentOrNull(currentText).toUpperCase());
+         }
+      } else if (qName.equals("Name")) {
+         name = currentOrNull(currentText);
+      } else if (qName.equals("LogicalSizeInGB")) {
+         String gb = currentOrNull(currentText);
+         if (gb != null) {
+            logicalSizeInGB = Integer.parseInt(gb);
+         }
+      } else if (qName.equals("Description")) {
+         description = currentOrNull(currentText);
+      } else if (qName.equals("Category")) {
+         category = currentOrNull(currentText);
+      } else if (qName.equals("Location")) {
+         String locationField = currentOrNull(currentText);
+         if (locationField != null) {
+            locations.addAll(Splitter.on(';').splitToList(locationField));
+         }
+      } else if (qName.equals("AffinityGroup")) {
+         affinityGroup = currentOrNull(currentText);
+      } else if (qName.equals("MediaLink")) {
+         String link = currentOrNull(currentText);
+         if (link != null) {
+            mediaLink = URI.create(link);
+         }
+      } else if (qName.equals("Eula")) {
+         String eulaField = currentOrNull(currentText);
+         if (eulaField != null) {
+            for (String eula : Splitter.on(';').split(eulaField)) {
+               if ((eula = emptyToNull(eula.trim())) != null) { // Dirty data in RightScale eulas field.
+                  eulas.add(eula);
+               }
+            }
+         }
+      } else if (qName.equals("Label")) {
+         label = currentOrNull(currentText);
+      }
+      currentText.setLength(0);
+   }
+
+   @Override public void characters(char ch[], int start, int length) {
+      currentText.append(ch, start, length);
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/test/java/org/jclouds/azurecompute/features/DeploymentApiMockTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/DeploymentApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/DeploymentApiMockTest.java
index e6662ac..a469df3 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/DeploymentApiMockTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/DeploymentApiMockTest.java
@@ -22,11 +22,11 @@ import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertNull;
 
 import org.jclouds.azurecompute.domain.DeploymentParams;
-import org.jclouds.azurecompute.domain.Image;
+import org.jclouds.azurecompute.domain.OSImage;
 import org.jclouds.azurecompute.domain.RoleSize;
 import org.jclouds.azurecompute.internal.BaseAzureComputeApiMockTest;
 import org.jclouds.azurecompute.xml.DeploymentHandlerTest;
-import org.jclouds.azurecompute.xml.ListImagesHandlerTest;
+import org.jclouds.azurecompute.xml.ListOSImagesHandlerTest;
 import org.testng.annotations.Test;
 
 import com.squareup.okhttp.mockwebserver.MockResponse;
@@ -42,12 +42,12 @@ public class DeploymentApiMockTest extends BaseAzureComputeApiMockTest {
       try {
          DeploymentApi api = api(server.getUrl("/")).getDeploymentApiForService("myservice");
 
-         Image image = ListImagesHandlerTest.expected().get(5); // CentOS
+         OSImage OSImage = ListOSImagesHandlerTest.expected().get(5); // CentOS
 
          DeploymentParams params = DeploymentParams.builder()
                .name("mydeployment")
                .size(RoleSize.MEDIUM)
-               .sourceImageName(image.name()).mediaLink(image.mediaLink()).os(image.os())
+               .sourceImageName(OSImage.name()).mediaLink(OSImage.mediaLink()).os(OSImage.os())
                .username("username").password("testpwd")
                .externalEndpoint(inboundTcpToLocalPort(80, 8080))
                .externalEndpoint(inboundUdpToLocalPort(53, 53)).build();
@@ -67,12 +67,12 @@ public class DeploymentApiMockTest extends BaseAzureComputeApiMockTest {
       try {
          DeploymentApi api = api(server.getUrl("/")).getDeploymentApiForService("myservice");
 
-         Image image = ListImagesHandlerTest.expected().get(1); // Windows
+         OSImage OSImage = ListOSImagesHandlerTest.expected().get(1); // Windows
 
          DeploymentParams params = DeploymentParams.builder()
                .name("mydeployment")
                .size(RoleSize.MEDIUM)
-               .sourceImageName(image.name()).mediaLink(image.mediaLink()).os(image.os())
+               .sourceImageName(OSImage.name()).mediaLink(OSImage.mediaLink()).os(OSImage.os())
                .username("username").password("testpwd")
                .externalEndpoint(inboundTcpToLocalPort(80, 8080))
                .externalEndpoint(inboundUdpToLocalPort(53, 53)).build();

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/test/java/org/jclouds/azurecompute/features/DiskApiLiveTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/DiskApiLiveTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/DiskApiLiveTest.java
index 0f54641..2f9499e 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/DiskApiLiveTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/DiskApiLiveTest.java
@@ -21,8 +21,8 @@ import static org.testng.Assert.assertNull;
 import static org.testng.Assert.assertTrue;
 
 import org.jclouds.azurecompute.domain.Disk;
-import org.jclouds.azurecompute.domain.Image;
 import org.jclouds.azurecompute.domain.Location;
+import org.jclouds.azurecompute.domain.OSImage;
 import org.jclouds.azurecompute.internal.BaseAzureComputeApiLiveTest;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
@@ -46,8 +46,8 @@ public class DiskApiLiveTest extends BaseAzureComputeApiLiveTest {
                      return in.name();
                   }
                }));
-      images = ImmutableSet.copyOf(transform(api.getImageApi().list(), new Function<Image, String>() {
-         public String apply(Image in) {
+      images = ImmutableSet.copyOf(transform(api.getOSImageApi().list(), new Function<OSImage, String>() {
+         public String apply(OSImage in) {
             return in.name();
          }
       }));

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiLiveTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiLiveTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiLiveTest.java
deleted file mode 100644
index c4b36e4..0000000
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiLiveTest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * 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.jclouds.azurecompute.features;
-
-import static com.google.common.collect.Iterables.transform;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertNotEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
-
-import org.jclouds.azurecompute.domain.Image;
-import org.jclouds.azurecompute.domain.Location;
-import org.jclouds.azurecompute.internal.BaseAzureComputeApiLiveTest;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Function;
-import com.google.common.collect.ImmutableSet;
-
-@Test(groups = "live", testName = "ImageApiLiveTest")
-public class ImageApiLiveTest extends BaseAzureComputeApiLiveTest {
-
-   private ImmutableSet<String> locations;
-
-   @BeforeClass(groups = { "integration", "live" })
-   public void setup() {
-      super.setup();
-
-      locations = ImmutableSet.copyOf(transform(api.getLocationApi().list(), new Function<Location, String>() {
-         public String apply(Location in) {
-            return in.name();
-         }
-      }));
-   }
-
-   public void testList() {
-      for (Image image : api().list()) {
-         checkOSImage(image);
-      }
-   }
-
-   private void checkOSImage(Image image) {
-      assertNotNull(image.label(), "Label cannot be null for " + image);
-      assertNotNull(image.name(), "Name cannot be null for " + image);
-      assertNotNull(image.os(), "OS cannot be null for " + image);
-      assertTrue(image.logicalSizeInGB() > 0, "LogicalSizeInGB should be positive, if set" + image);
-
-      if (image.category() != null) {
-         assertNotEquals("", image.category().trim(), "Invalid Category for " + image);
-      }
-
-      if (image.mediaLink() != null) {
-         assertTrue(ImmutableSet.of("http", "https").contains(image.mediaLink().getScheme()),
-               "MediaLink should be an http(s) url" + image);
-      }
-      if (image.location() != null) {
-         assertTrue(locations.contains(image.location()), "Location not in " + locations + " :" + image);
-      }
-
-      // Ex. Dirty data in RightScale eula field comes out as an empty string.
-      assertFalse(image.eula().contains(""));
-      if (image.affinityGroup() != null) {
-         // TODO: list getAffinityGroups and check if there
-      }
-   }
-
-   private ImageApi api() {
-      return api.getImageApi();
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiMockTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiMockTest.java
deleted file mode 100644
index 4e05102..0000000
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiMockTest.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * 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.jclouds.azurecompute.features;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertTrue;
-
-import java.net.URI;
-
-import org.jclouds.azurecompute.domain.Image.OSType;
-import org.jclouds.azurecompute.domain.ImageParams;
-import org.jclouds.azurecompute.internal.BaseAzureComputeApiMockTest;
-import org.jclouds.azurecompute.xml.ListImagesHandlerTest;
-import org.testng.annotations.Test;
-
-import com.squareup.okhttp.mockwebserver.MockResponse;
-import com.squareup.okhttp.mockwebserver.MockWebServer;
-
-@Test(groups = "unit", testName = "ImageApiMockTest")
-public class ImageApiMockTest extends BaseAzureComputeApiMockTest {
-
-   public void listWhenFound() throws Exception {
-      MockWebServer server = mockAzureManagementServer();
-      server.enqueue(xmlResponse("/images.xml"));
-
-      try {
-         ImageApi api = api(server.getUrl("/")).getImageApi();
-
-         assertEquals(api.list(), ListImagesHandlerTest.expected());
-
-         assertSent(server, "GET", "/services/images");
-      } finally {
-         server.shutdown();
-      }
-   }
-
-   public void listWhenNotFound() throws Exception {
-      MockWebServer server = mockAzureManagementServer();
-      server.enqueue(new MockResponse().setResponseCode(404));
-
-      try {
-         ImageApi api = api(server.getUrl("/")).getImageApi();
-
-         assertTrue(api.list().isEmpty());
-
-         assertSent(server, "GET", "/services/images");
-      } finally {
-         server.shutdown();
-      }
-   }
-
-   public void add() throws Exception {
-      MockWebServer server = mockAzureManagementServer();
-      server.enqueue(requestIdResponse("request-1"));
-
-      try {
-         ImageApi api = api(server.getUrl("/")).getImageApi();
-
-         ImageParams params = ImageParams.builder().name("myimage").label("foo").os(OSType.LINUX)
-               .mediaLink(URI.create("http://example.blob.core.windows.net/disks/mydisk.vhd")).build();
-
-         assertEquals(api.add(params), "request-1");
-
-         assertSent(server, "POST", "/services/images", "/imageparams.xml");
-      } finally {
-         server.shutdown();
-      }
-   }
-
-   public void update() throws Exception {
-      MockWebServer server = mockAzureManagementServer();
-      server.enqueue(requestIdResponse("request-1"));
-
-      try {
-         ImageApi api = api(server.getUrl("/")).getImageApi();
-
-         ImageParams params = ImageParams.builder().name("myimage").label("foo").os(OSType.LINUX)
-               .mediaLink(URI.create("http://example.blob.core.windows.net/disks/mydisk.vhd")).build();
-
-         assertEquals(api.update(params), "request-1");
-
-         assertSent(server, "PUT", "/services/images/myimage", "/imageparams.xml");
-      } finally {
-         server.shutdown();
-      }
-   }
-
-   public void deleteWhenFound() throws Exception {
-      MockWebServer server = mockAzureManagementServer();
-      server.enqueue(requestIdResponse("request-1"));
-
-      try {
-         ImageApi api = api(server.getUrl("/")).getImageApi();
-
-         assertEquals(api.delete("myimage"), "request-1");
-
-         assertSent(server, "DELETE", "/services/images/myimage");
-      } finally {
-         server.shutdown();
-      }
-   }
-
-   public void deleteWhenNotFound() throws Exception {
-      MockWebServer server = mockAzureManagementServer();
-      server.enqueue(new MockResponse().setResponseCode(404));
-
-      try {
-         ImageApi api = api(server.getUrl("/")).getImageApi();
-
-         assertNull(api.delete("myimage"));
-
-         assertSent(server, "DELETE", "/services/images/myimage");
-      } finally {
-         server.shutdown();
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/test/java/org/jclouds/azurecompute/features/LocationApiMockTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/LocationApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/LocationApiMockTest.java
index b476ed1..9360cb0 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/LocationApiMockTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/LocationApiMockTest.java
@@ -16,13 +16,14 @@
  */
 package org.jclouds.azurecompute.features;
 
-import com.squareup.okhttp.mockwebserver.MockResponse;
-import com.squareup.okhttp.mockwebserver.MockWebServer;
+import static org.assertj.core.api.Assertions.assertThat;
+
 import org.jclouds.azurecompute.internal.BaseAzureComputeApiMockTest;
 import org.jclouds.azurecompute.xml.ListLocationsHandlerTest;
 import org.testng.annotations.Test;
 
-import static org.assertj.core.api.Assertions.assertThat;
+import com.squareup.okhttp.mockwebserver.MockResponse;
+import com.squareup.okhttp.mockwebserver.MockWebServer;
 
 @Test(groups = "unit", testName = "LocationApiMockTest")
 public class LocationApiMockTest extends BaseAzureComputeApiMockTest {

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/test/java/org/jclouds/azurecompute/features/OSImageApiLiveTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/OSImageApiLiveTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/OSImageApiLiveTest.java
new file mode 100644
index 0000000..785a5a1
--- /dev/null
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/OSImageApiLiveTest.java
@@ -0,0 +1,83 @@
+/*
+ * 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.jclouds.azurecompute.features;
+
+import static com.google.common.collect.Iterables.transform;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+import org.jclouds.azurecompute.domain.Location;
+import org.jclouds.azurecompute.domain.OSImage;
+import org.jclouds.azurecompute.internal.BaseAzureComputeApiLiveTest;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Function;
+import com.google.common.collect.ImmutableSet;
+
+@Test(groups = "live", testName = "OSImageApiLiveTest")
+public class OSImageApiLiveTest extends BaseAzureComputeApiLiveTest {
+
+   private ImmutableSet<String> locations;
+
+   @BeforeClass(groups = { "integration", "live" })
+   public void setup() {
+      super.setup();
+
+      locations = ImmutableSet.copyOf(transform(api.getLocationApi().list(), new Function<Location, String>() {
+         public String apply(Location in) {
+            return in.name();
+         }
+      }));
+   }
+
+   public void testList() {
+      for (OSImage OSImage : api().list()) {
+         checkOSImage(OSImage);
+      }
+   }
+
+   private void checkOSImage(OSImage OSImage) {
+      assertNotNull(OSImage.label(), "Label cannot be null for " + OSImage);
+      assertNotNull(OSImage.name(), "Name cannot be null for " + OSImage);
+      assertNotNull(OSImage.os(), "OS cannot be null for " + OSImage);
+      assertTrue(OSImage.logicalSizeInGB() > 0, "LogicalSizeInGB should be positive, if set" + OSImage);
+
+      if (OSImage.category() != null) {
+         assertNotEquals("", OSImage.category().trim(), "Invalid Category for " + OSImage);
+      }
+
+      if (OSImage.mediaLink() != null) {
+         assertTrue(ImmutableSet.of("http", "https").contains(OSImage.mediaLink().getScheme()),
+               "MediaLink should be an http(s) url" + OSImage);
+      }
+
+      assertTrue(locations.containsAll(OSImage.locations()), "Locations not in " + locations + " :" + OSImage);
+
+      // Ex. Dirty data in RightScale eula field comes out as an empty string.
+      assertFalse(OSImage.eula().contains(""));
+      if (OSImage.affinityGroup() != null) {
+         // TODO: list getAffinityGroups and check if there
+      }
+   }
+
+   private OSImageApi api() {
+      return api.getOSImageApi();
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/test/java/org/jclouds/azurecompute/features/OSImageApiMockTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/OSImageApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/OSImageApiMockTest.java
new file mode 100644
index 0000000..70c5ec6
--- /dev/null
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/OSImageApiMockTest.java
@@ -0,0 +1,132 @@
+/*
+ * 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.jclouds.azurecompute.features;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
+import java.net.URI;
+
+import org.jclouds.azurecompute.domain.OSImage;
+import org.jclouds.azurecompute.domain.OSImageParams;
+import org.jclouds.azurecompute.internal.BaseAzureComputeApiMockTest;
+import org.jclouds.azurecompute.xml.ListOSImagesHandlerTest;
+import org.testng.annotations.Test;
+
+import com.squareup.okhttp.mockwebserver.MockResponse;
+import com.squareup.okhttp.mockwebserver.MockWebServer;
+
+@Test(groups = "unit", testName = "OSImageApiMockTest")
+public class OSImageApiMockTest extends BaseAzureComputeApiMockTest {
+
+   public void listWhenFound() throws Exception {
+      MockWebServer server = mockAzureManagementServer();
+      server.enqueue(xmlResponse("/images.xml"));
+
+      try {
+         OSImageApi api = api(server.getUrl("/")).getOSImageApi();
+
+         assertEquals(api.list(), ListOSImagesHandlerTest.expected());
+
+         assertSent(server, "GET", "/services/images");
+      } finally {
+         server.shutdown();
+      }
+   }
+
+   public void listWhenNotFound() throws Exception {
+      MockWebServer server = mockAzureManagementServer();
+      server.enqueue(new MockResponse().setResponseCode(404));
+
+      try {
+         OSImageApi api = api(server.getUrl("/")).getOSImageApi();
+
+         assertTrue(api.list().isEmpty());
+
+         assertSent(server, "GET", "/services/images");
+      } finally {
+         server.shutdown();
+      }
+   }
+
+   public void add() throws Exception {
+      MockWebServer server = mockAzureManagementServer();
+      server.enqueue(requestIdResponse("request-1"));
+
+      try {
+         OSImageApi api = api(server.getUrl("/")).getOSImageApi();
+
+         OSImageParams params = OSImageParams.builder().name("myimage").label("foo").os(OSImage.Type.LINUX)
+               .mediaLink(URI.create("http://example.blob.core.windows.net/disks/mydisk.vhd")).build();
+
+         assertEquals(api.add(params), "request-1");
+
+         assertSent(server, "POST", "/services/images", "/imageparams.xml");
+      } finally {
+         server.shutdown();
+      }
+   }
+
+   public void update() throws Exception {
+      MockWebServer server = mockAzureManagementServer();
+      server.enqueue(requestIdResponse("request-1"));
+
+      try {
+         OSImageApi api = api(server.getUrl("/")).getOSImageApi();
+
+         OSImageParams params = OSImageParams.builder().name("myimage").label("foo").os(OSImage.Type.LINUX)
+               .mediaLink(URI.create("http://example.blob.core.windows.net/disks/mydisk.vhd")).build();
+
+         assertEquals(api.update(params), "request-1");
+
+         assertSent(server, "PUT", "/services/images/myimage", "/imageparams.xml");
+      } finally {
+         server.shutdown();
+      }
+   }
+
+   public void deleteWhenFound() throws Exception {
+      MockWebServer server = mockAzureManagementServer();
+      server.enqueue(requestIdResponse("request-1"));
+
+      try {
+         OSImageApi api = api(server.getUrl("/")).getOSImageApi();
+
+         assertEquals(api.delete("myimage"), "request-1");
+
+         assertSent(server, "DELETE", "/services/images/myimage");
+      } finally {
+         server.shutdown();
+      }
+   }
+
+   public void deleteWhenNotFound() throws Exception {
+      MockWebServer server = mockAzureManagementServer();
+      server.enqueue(new MockResponse().setResponseCode(404));
+
+      try {
+         OSImageApi api = api(server.getUrl("/")).getOSImageApi();
+
+         assertNull(api.delete("myimage"));
+
+         assertSent(server, "DELETE", "/services/images/myimage");
+      } finally {
+         server.shutdown();
+      }
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/test/java/org/jclouds/azurecompute/features/VirtualMachineApiMockTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/VirtualMachineApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/VirtualMachineApiMockTest.java
index 7e3ce5a..41cce90 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/VirtualMachineApiMockTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/VirtualMachineApiMockTest.java
@@ -16,13 +16,14 @@
  */
 package org.jclouds.azurecompute.features;
 
-import com.squareup.okhttp.mockwebserver.MockWebServer;
+import static org.assertj.core.api.Assertions.assertThat;
+
 import org.jclouds.azurecompute.internal.BaseAzureComputeApiMockTest;
 import org.testng.annotations.Test;
 
-import static org.assertj.core.api.Assertions.assertThat;
+import com.squareup.okhttp.mockwebserver.MockWebServer;
 
-@Test(groups = "unit", testName = "ApiMockTest")
+@Test(groups = "unit", testName = "VirtualMachineApiMockTest")
 public class VirtualMachineApiMockTest extends BaseAzureComputeApiMockTest {
 
    public void start() throws Exception {

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/test/java/org/jclouds/azurecompute/internal/BaseAzureComputeApiLiveTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/internal/BaseAzureComputeApiLiveTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/internal/BaseAzureComputeApiLiveTest.java
index 5e3fea4..a05d421 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/internal/BaseAzureComputeApiLiveTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/internal/BaseAzureComputeApiLiveTest.java
@@ -16,12 +16,13 @@
  */
 package org.jclouds.azurecompute.internal;
 
+import static org.jclouds.azurecompute.config.AzureComputeProperties.SUBSCRIPTION_ID;
+
 import java.util.Properties;
+
 import org.jclouds.apis.BaseApiLiveTest;
 import org.jclouds.azurecompute.AzureComputeApi;
 
-import static org.jclouds.azurecompute.config.AzureComputeProperties.SUBSCRIPTION_ID;
-
 public class BaseAzureComputeApiLiveTest extends BaseApiLiveTest<AzureComputeApi> {
 
    protected String subscriptionId;

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/test/java/org/jclouds/azurecompute/internal/BaseAzureComputeApiMockTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/internal/BaseAzureComputeApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/internal/BaseAzureComputeApiMockTest.java
index c01d8f8..d846a44 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/internal/BaseAzureComputeApiMockTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/internal/BaseAzureComputeApiMockTest.java
@@ -16,23 +16,25 @@
  */
 package org.jclouds.azurecompute.internal;
 
-import com.google.common.base.Throwables;
-import com.google.common.collect.ImmutableSet;
-import com.google.inject.Module;
-import com.squareup.okhttp.mockwebserver.MockResponse;
-import com.squareup.okhttp.mockwebserver.MockWebServer;
-import com.squareup.okhttp.mockwebserver.RecordedRequest;
+import static com.google.common.base.Charsets.UTF_8;
+import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
+import static org.assertj.core.api.Assertions.assertThat;
+
 import java.io.IOException;
 import java.net.URL;
 import java.util.Set;
+
 import org.jclouds.ContextBuilder;
 import org.jclouds.azurecompute.AzureComputeApi;
 import org.jclouds.concurrent.config.ExecutorServiceModule;
 import org.jclouds.util.Strings2;
 
-import static com.google.common.base.Charsets.UTF_8;
-import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
-import static org.assertj.core.api.Assertions.assertThat;
+import com.google.common.base.Throwables;
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Module;
+import com.squareup.okhttp.mockwebserver.MockResponse;
+import com.squareup.okhttp.mockwebserver.MockWebServer;
+import com.squareup.okhttp.mockwebserver.RecordedRequest;
 
 public class BaseAzureComputeApiMockTest {
    private final Set<Module> modules = ImmutableSet
@@ -81,7 +83,7 @@ public class BaseAzureComputeApiMockTest {
       RecordedRequest request = server.takeRequest();
       assertThat(request.getMethod()).isEqualTo(method);
       assertThat(request.getPath()).isEqualTo(path);
-      assertThat(request.getHeader("x-ms-version")).isEqualTo("2012-03-01");
+      assertThat(request.getHeader("x-ms-version")).isEqualTo("2014-06-01");
       assertThat(request.getHeader("Accept")).isEqualTo("application/xml");
       return request;
    }

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListDisksHandlerTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListDisksHandlerTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListDisksHandlerTest.java
index 320c405..491653b 100644
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListDisksHandlerTest.java
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListDisksHandlerTest.java
@@ -24,7 +24,7 @@ import java.util.List;
 
 import org.jclouds.azurecompute.domain.Disk;
 import org.jclouds.azurecompute.domain.Disk.Attachment;
-import org.jclouds.azurecompute.domain.Image.OSType;
+import org.jclouds.azurecompute.domain.OSImage;
 import org.jclouds.http.functions.BaseHandlerTest;
 import org.testng.annotations.Test;
 
@@ -47,7 +47,7 @@ public class ListDisksHandlerTest extends BaseHandlerTest {
                   "West Europe", // location
                   null, // affinityGroup
                   null, //description
-                  OSType.LINUX, // os
+                  OSImage.Type.LINUX, // os
                   URI.create("http://blobs/vhds/testimage2-testimage2-2012-08-17.vhd"), // mediaLink
                   30, // logicalSizeInGB
                   null, // attachedTo
@@ -57,7 +57,7 @@ public class ListDisksHandlerTest extends BaseHandlerTest {
                   "West Europe", // location
                   null, // affinityGroup
                   null, //description
-                  OSType.WINDOWS, // os
+                  OSImage.Type.WINDOWS, // os
                   URI.create("http://blobs/disks/neotysss/MSFT__Win2K8R2SP1-ABCD-en-us-30GB.vhd"), // mediaLink
                   30, // logicalSizeInGB
                   Attachment.create("neotysss", "neotysss", "neotysss"), // attachedTo

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListImagesHandlerTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListImagesHandlerTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListImagesHandlerTest.java
deleted file mode 100644
index ffd3de3..0000000
--- a/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListImagesHandlerTest.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * 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.jclouds.azurecompute.xml;
-
-import static org.testng.Assert.assertEquals;
-
-import java.io.InputStream;
-import java.net.URI;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import org.jclouds.azurecompute.domain.Image;
-import org.jclouds.azurecompute.domain.Image.OSType;
-import org.jclouds.http.functions.BaseHandlerTest;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-
-@Test(groups = "unit", testName = "ListImagesHandlerTest")
-public class ListImagesHandlerTest extends BaseHandlerTest {
-
-   public void test() {
-      InputStream is = getClass().getResourceAsStream("/images.xml");
-      List<Image> result = factory.create(new ListImagesHandler()).parse(is);
-
-      assertEquals(result, expected());
-   }
-
-   public static List<Image> expected() {
-      return ImmutableList.of( //
-            Image.create( //
-                  "CANONICAL__Canonical-Ubuntu-12-04-amd64-server-20120528.1.3-en-us-30GB.vhd", // name
-                  null, // location
-                  null, // affinityGroup
-                  "Ubuntu Server 12.04 LTS", // label
-                  "Ubuntu Server 12.04 LTS amd64 20120528 Cloud Image", //description
-                  "Canonical", // category
-                  OSType.LINUX, // os
-                  null, // mediaLink
-                  30, // logicalSizeInGB
-                  Arrays.asList("http://www.ubuntu.com/project/about-ubuntu/licensing") // eula
-            ),
-            Image.create( //
-                  "MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd", // name
-                  null, // location
-                  null, // affinityGroup
-                  "Windows Server 2008 R2 SP1, June 2012", // label
-                  "Windows Server 2008 R2 is a multi-purpose server.", //description
-                  "Microsoft", // category
-                  OSType.WINDOWS, // os
-                  URI.create("http://blobs/disks/mydeployment/MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd"), // mediaLink
-                  30, // logicalSizeInGB
-                  Collections.<String>emptyList() // eula
-            ),
-            Image.create( //
-                  "MSFT__Sql-Server-11EVAL-11.0.2215.0-05152012-en-us-30GB.vhd", // name
-                  null, // location
-                  null, // affinityGroup
-                  "Microsoft SQL Server 2012 Evaluation Edition", // label
-                  "SQL Server 2012 Evaluation Edition (64-bit).", //description
-                  "Microsoft", // category
-                  OSType.WINDOWS, // os
-                  null, // mediaLink
-                  30, // logicalSizeInGB
-                  Arrays.asList("http://go.microsoft.com/fwlink/?LinkID=251820",
-                                "http://go.microsoft.com/fwlink/?LinkID=131004") // eula
-            ),
-            Image.create( //
-                  "MSFT__Win2K12RC-Datacenter-201207.02-en.us-30GB.vhd", // name
-                  null, // location
-                  null, // affinityGroup
-                  "Windows Server 2012 Release Candidate, July 2012", // label
-                  "Windows Server 2012 incorporates Microsoft's experience building.", //description
-                  "Microsoft", // category
-                  OSType.WINDOWS, // os
-                  null, // mediaLink
-                  30, // logicalSizeInGB
-                  Collections.<String>emptyList() // eula
-            ),
-            Image.create( //
-                  "MSFT__Win2K8R2SP1-Datacenter-201207.01-en.us-30GB.vhd", // name
-                  null, // location
-                  null, // affinityGroup
-                  "Windows Server 2008 R2 SP1, July 2012", // label
-                  "Windows Server 2008 R2 is a multi-purpose server.", //description
-                  "Microsoft", // category
-                  OSType.WINDOWS, // os
-                  null, // mediaLink
-                  30, // logicalSizeInGB
-                  Collections.<String>emptyList() // eula
-            ),
-            Image.create( //
-                  "OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhd", // name
-                  null, // location
-                  null, // affinityGroup
-                  "OpenLogic CentOS 6.2", // label
-                  "This distribution of Linux is based on CentOS.", //description
-                  "OpenLogic", // category
-                  OSType.LINUX, // os
-                  URI.create("http://blobs/disks/mydeployment/OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhd"), // mediaLink
-                  30, // logicalSizeInGB
-                  Arrays.asList("http://www.openlogic.com/azure/service-agreement/") // eula
-            ),
-            Image.create( //
-                  "SUSE__openSUSE-12-1-20120603-en-us-30GB.vhd", // name
-                  null, // location
-                  null, // affinityGroup
-                  "openSUSE 12.1", // label
-                  "openSUSE is a free and Linux-based operating system!", //description
-                  "SUSE", // category
-                  OSType.LINUX, // os
-                  null, // mediaLink
-                  30, // logicalSizeInGB
-                  Arrays.asList("http://opensuse.org/") // eula
-            ),
-            Image.create( //
-                  "SUSE__SUSE-Linux-Enterprise-Server-11SP2-20120601-en-us-30GB.vhd", // name
-                  null, // location
-                  null, // affinityGroup
-                  "SUSE Linux Enterprise Server", // label
-                  "SUSE Linux Enterprise Server is a highly reliable value.", //description
-                  "SUSE", // category
-                  OSType.LINUX, // os
-                  null, // mediaLink
-                  30, // logicalSizeInGB
-                  Arrays.asList("http://www.novell.com/licensing/eula/") // eula
-            ),
-            Image.create( //
-                  "0b11de9248dd4d87b18621318e037d37__RightImage-CentOS-6.4-x64-v13.4", // name
-                  null, // location
-                  null, // affinityGroup
-                  "RightImage-CentOS-6.4-x64-v13.4", // label
-                  null, //description
-                  "RightScale with Linux", // category
-                  OSType.LINUX, // os
-                  null, // mediaLink
-                  10, // logicalSizeInGB
-                  Collections.<String>emptyList() // No EULA, as RightScale stuffed ';' into the field.
-            )
-      );
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListOSImagesHandlerTest.java
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListOSImagesHandlerTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListOSImagesHandlerTest.java
new file mode 100644
index 0000000..3809440
--- /dev/null
+++ b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListOSImagesHandlerTest.java
@@ -0,0 +1,158 @@
+/*
+ * 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.jclouds.azurecompute.xml;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.net.URI;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.jclouds.azurecompute.domain.OSImage;
+import org.jclouds.http.functions.BaseHandlerTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+
+@Test(groups = "unit", testName = "ListImagesHandlerTest")
+public class ListOSImagesHandlerTest extends BaseHandlerTest {
+
+   public void test() {
+      InputStream is = getClass().getResourceAsStream("/images.xml");
+      List<OSImage> result = factory.create(new ListOSImagesHandler()).parse(is);
+
+      assertEquals(result, expected());
+   }
+
+   public static List<OSImage> expected() {
+      return ImmutableList.of( //
+            OSImage.create( //
+                  "CANONICAL__Canonical-Ubuntu-12-04-amd64-server-20120528.1.3-en-us-30GB.vhd", // name
+                  Collections.<String>emptyList(), // locations
+                  null, // affinityGroup
+                  "Ubuntu Server 12.04 LTS", // label
+                  "Ubuntu Server 12.04 LTS amd64 20120528 Cloud Image", //description
+                  "Canonical", // category
+                  OSImage.Type.LINUX, // os
+                  null, // mediaLink
+                  30, // logicalSizeInGB
+                  Arrays.asList("http://www.ubuntu.com/project/about-ubuntu/licensing") // eula
+            ),
+            OSImage.create( //
+                  "MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd", // name
+                  Arrays.asList("East Asia", "Southeast Asia", "North Europe"), // locations
+                  null, // affinityGroup
+                  "Windows Server 2008 R2 SP1, June 2012", // label
+                  "Windows Server 2008 R2 is a multi-purpose server.", //description
+                  "Microsoft", // category
+                  OSImage.Type.WINDOWS, // os
+                  URI.create("http://blobs/disks/mydeployment/MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd"),
+                  // mediaLink
+                  30, // logicalSizeInGB
+                  Collections.<String>emptyList() // eula
+            ),
+            OSImage.create( //
+                  "MSFT__Sql-Server-11EVAL-11.0.2215.0-05152012-en-us-30GB.vhd", // name
+                  Collections.<String>emptyList(), // locations
+                  null, // affinityGroup
+                  "Microsoft SQL Server 2012 Evaluation Edition", // label
+                  "SQL Server 2012 Evaluation Edition (64-bit).", //description
+                  "Microsoft", // category
+                  OSImage.Type.WINDOWS, // os
+                  null, // mediaLink
+                  30, // logicalSizeInGB
+                  Arrays.asList("http://go.microsoft.com/fwlink/?LinkID=251820",
+                        "http://go.microsoft.com/fwlink/?LinkID=131004") // eula
+            ),
+            OSImage.create( //
+                  "MSFT__Win2K12RC-Datacenter-201207.02-en.us-30GB.vhd", // name
+                  Collections.<String>emptyList(), // locations
+                  null, // affinityGroup
+                  "Windows Server 2012 Release Candidate, July 2012", // label
+                  "Windows Server 2012 incorporates Microsoft's experience building.", //description
+                  "Microsoft", // category
+                  OSImage.Type.WINDOWS, // os
+                  null, // mediaLink
+                  30, // logicalSizeInGB
+                  Collections.<String>emptyList() // eula
+            ),
+            OSImage.create( //
+                  "MSFT__Win2K8R2SP1-Datacenter-201207.01-en.us-30GB.vhd", // name
+                  Collections.<String>emptyList(), // locations
+                  null, // affinityGroup
+                  "Windows Server 2008 R2 SP1, July 2012", // label
+                  "Windows Server 2008 R2 is a multi-purpose server.", //description
+                  "Microsoft", // category
+                  OSImage.Type.WINDOWS, // os
+                  null, // mediaLink
+                  30, // logicalSizeInGB
+                  Collections.<String>emptyList() // eula
+            ),
+            OSImage.create( //
+                  "OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhd", // name
+                  Collections.<String>emptyList(), // locations
+                  null, // affinityGroup
+                  "OpenLogic CentOS 6.2", // label
+                  "This distribution of Linux is based on CentOS.", //description
+                  "OpenLogic", // category
+                  OSImage.Type.LINUX, // os
+                  URI.create("http://blobs/disks/mydeployment/OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhd"),
+                  // mediaLink
+                  30, // logicalSizeInGB
+                  Arrays.asList("http://www.openlogic.com/azure/service-agreement/") // eula
+            ),
+            OSImage.create( //
+                  "SUSE__openSUSE-12-1-20120603-en-us-30GB.vhd", // name
+                  Collections.<String>emptyList(), // locations
+                  null, // affinityGroup
+                  "openSUSE 12.1", // label
+                  "openSUSE is a free and Linux-based operating system!", //description
+                  "SUSE", // category
+                  OSImage.Type.LINUX, // os
+                  null, // mediaLink
+                  30, // logicalSizeInGB
+                  Arrays.asList("http://opensuse.org/") // eula
+            ),
+            OSImage.create( //
+                  "SUSE__SUSE-Linux-Enterprise-Server-11SP2-20120601-en-us-30GB.vhd", // name
+                  Collections.<String>emptyList(), // locations
+                  null, // affinityGroup
+                  "SUSE Linux Enterprise Server", // label
+                  "SUSE Linux Enterprise Server is a highly reliable value.", //description
+                  "SUSE", // category
+                  OSImage.Type.LINUX, // os
+                  null, // mediaLink
+                  30, // logicalSizeInGB
+                  Arrays.asList("http://www.novell.com/licensing/eula/") // eula
+            ),
+            OSImage.create( //
+                  "0b11de9248dd4d87b18621318e037d37__RightImage-CentOS-6.4-x64-v13.4", // name
+                  Collections.<String>emptyList(), // locations
+                  null, // affinityGroup
+                  "RightImage-CentOS-6.4-x64-v13.4", // label
+                  null, //description
+                  "RightScale with Linux", // category
+                  OSImage.Type.LINUX, // os
+                  null, // mediaLink
+                  10, // logicalSizeInGB
+                  Collections.<String>emptyList() // No EULA, as RightScale stuffed ';' into the field.
+            )
+      );
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/test/resources/capturerolepayload.xml
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/resources/capturerolepayload.xml b/azurecompute/src/test/resources/capturerolepayload.xml
index 9414c52..36396ff 100644
--- a/azurecompute/src/test/resources/capturerolepayload.xml
+++ b/azurecompute/src/test/resources/capturerolepayload.xml
@@ -1 +1 @@
-<CaptureRoleOperation xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><OperationType>CaptureRoleOperation</OperationType><PostCaptureAction>Delete</PostCaptureAction><TargetImageLabel>myImageLabel</TargetImageLabel><TargetImageName>myImageName</TargetImageName></CaptureRoleOperation>
\ No newline at end of file
+<CaptureRoleOperation xmlns="http://schemas.microsoft.com/windowsazure"><OperationType>CaptureRoleOperation</OperationType><PostCaptureAction>Delete</PostCaptureAction><TargetImageLabel>myImageLabel</TargetImageLabel><TargetImageName>myImageName</TargetImageName></CaptureRoleOperation>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/test/resources/images.xml
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/resources/images.xml b/azurecompute/src/test/resources/images.xml
index 8c01393..e72370e 100644
--- a/azurecompute/src/test/resources/images.xml
+++ b/azurecompute/src/test/resources/images.xml
@@ -11,6 +11,7 @@
     <OSImage>
         <Category>Microsoft</Category>
         <Label>Windows Server 2008 R2 SP1, June 2012</Label>
+        <Location>East Asia;Southeast Asia;North Europe</Location>
         <LogicalSizeInGB>30</LogicalSizeInGB>
         <Name>MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd</Name>
         <MediaLink>http://blobs/disks/mydeployment/MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd</MediaLink>

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/test/resources/restartrolepayload.xml
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/resources/restartrolepayload.xml b/azurecompute/src/test/resources/restartrolepayload.xml
index 4eca508..54ccf84 100644
--- a/azurecompute/src/test/resources/restartrolepayload.xml
+++ b/azurecompute/src/test/resources/restartrolepayload.xml
@@ -1 +1 @@
-<RestartRoleOperation xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><OperationType>RestartRoleOperation</OperationType></RestartRoleOperation>
\ No newline at end of file
+<RestartRoleOperation xmlns="http://schemas.microsoft.com/windowsazure"><OperationType>RestartRoleOperation</OperationType></RestartRoleOperation>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/test/resources/shutdownrolepayload.xml
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/resources/shutdownrolepayload.xml b/azurecompute/src/test/resources/shutdownrolepayload.xml
index 27beee8..5048ca3 100644
--- a/azurecompute/src/test/resources/shutdownrolepayload.xml
+++ b/azurecompute/src/test/resources/shutdownrolepayload.xml
@@ -1 +1 @@
-<ShutdownRoleOperation xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><OperationType>ShutdownRoleOperation</OperationType></ShutdownRoleOperation>
\ No newline at end of file
+<ShutdownRoleOperation xmlns="http://schemas.microsoft.com/windowsazure"><OperationType>ShutdownRoleOperation</OperationType></ShutdownRoleOperation>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d1a637f1/azurecompute/src/test/resources/startrolepayload.xml
----------------------------------------------------------------------
diff --git a/azurecompute/src/test/resources/startrolepayload.xml b/azurecompute/src/test/resources/startrolepayload.xml
index 4e82022..6b6d7a3 100644
--- a/azurecompute/src/test/resources/startrolepayload.xml
+++ b/azurecompute/src/test/resources/startrolepayload.xml
@@ -1 +1 @@
-<StartRoleOperation xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><OperationType>StartRoleOperation</OperationType></StartRoleOperation>
\ No newline at end of file
+<StartRoleOperation xmlns="http://schemas.microsoft.com/windowsazure"><OperationType>StartRoleOperation</OperationType></StartRoleOperation>
\ No newline at end of file