You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by an...@apache.org on 2014/10/02 23:53:11 UTC
[07/11] JCLOUDS-664 Updating Azure compute provider
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/6ab58bd2/azure-management/src/main/java/org/jclouds/azure/management/xml/DiskHandler.java
----------------------------------------------------------------------
diff --git a/azure-management/src/main/java/org/jclouds/azure/management/xml/DiskHandler.java b/azure-management/src/main/java/org/jclouds/azure/management/xml/DiskHandler.java
deleted file mode 100644
index 0dc7fb8..0000000
--- a/azure-management/src/main/java/org/jclouds/azure/management/xml/DiskHandler.java
+++ /dev/null
@@ -1,119 +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.azure.management.xml;
-
-import static org.jclouds.util.SaxUtils.currentOrNull;
-import static org.jclouds.util.SaxUtils.equalsOrSuffix;
-
-import java.net.URI;
-
-import javax.inject.Inject;
-
-import org.jclouds.azure.management.domain.Disk;
-import org.jclouds.azure.management.domain.OSType;
-import org.jclouds.http.functions.ParseSax;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-
-/**
- * @see <a href="http://msdn.microsoft.com/en-us/library/jj157176" >api</a>
- */
-public class DiskHandler extends
- ParseSax.HandlerForGeneratedRequestWithResult<Disk> {
-
- protected final AttachmentHandler attachmentHandler;
-
- @Inject
- protected DiskHandler(AttachmentHandler attachmentHandler) {
- this.attachmentHandler = attachmentHandler;
- }
-
- protected StringBuilder currentText = new StringBuilder();
- private Disk.Builder<?> builder = Disk.builder();
-
- protected boolean inAttachment;
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Disk getResult() {
- try {
- return builder.build();
- } finally {
- builder = Disk.builder();
- }
- }
-
- @Override
- public void startElement(String uri, String localName, String qName,
- Attributes attributes) throws SAXException {
- if (equalsOrSuffix(qName, "AttachedTo")) {
- inAttachment = true;
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void endElement(String uri, String name, String qName)
- throws SAXException {
- if (equalsOrSuffix(qName, "AttachedTo")) {
- builder.attachedTo(attachmentHandler.getResult());
- inAttachment = false;
- } else if (inAttachment) {
- attachmentHandler.endElement(uri, name, qName);
- } else if (equalsOrSuffix(qName, "OS")) {
- builder.os(OSType.fromValue(currentOrNull(currentText)));
- } else if (equalsOrSuffix(qName, "Name")) {
- builder.name(currentOrNull(currentText));
- } else if (equalsOrSuffix(qName, "LogicalDiskSizeInGB")) {
- String gb = currentOrNull(currentText);
- if (gb != null)
- builder.logicalSizeInGB(Integer.parseInt(gb));
- } else if (equalsOrSuffix(qName, "Description")) {
- builder.description(currentOrNull(currentText));
- } else if (equalsOrSuffix(qName, "Location")) {
- builder.location(currentOrNull(currentText));
- } else if (equalsOrSuffix(qName, "AffinityGroup")) {
- builder.affinityGroup(currentOrNull(currentText));
- } else if (equalsOrSuffix(qName, "MediaLink")) {
- String link = currentOrNull(currentText);
- if (link != null)
- builder.mediaLink(URI.create(link));
- } else if (equalsOrSuffix(qName, "SourceImageName")) {
- builder.sourceImage(currentOrNull(currentText));
- } else if (equalsOrSuffix(qName, "Label")) {
- builder.label(currentOrNull(currentText));
- }
- currentText.setLength(0);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void characters(char ch[], int start, int length) {
- if (inAttachment) {
- attachmentHandler.characters(ch, start, length);
- } else {
- currentText.append(ch, start, length);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/6ab58bd2/azure-management/src/main/java/org/jclouds/azure/management/xml/ErrorHandler.java
----------------------------------------------------------------------
diff --git a/azure-management/src/main/java/org/jclouds/azure/management/xml/ErrorHandler.java b/azure-management/src/main/java/org/jclouds/azure/management/xml/ErrorHandler.java
deleted file mode 100644
index 459346b..0000000
--- a/azure-management/src/main/java/org/jclouds/azure/management/xml/ErrorHandler.java
+++ /dev/null
@@ -1,68 +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.azure.management.xml;
-
-import org.jclouds.azure.management.domain.Error;
-import org.jclouds.azure.management.domain.Error.Code;
-import org.jclouds.http.functions.ParseSax;
-import org.jclouds.util.SaxUtils;
-import org.xml.sax.SAXException;
-
-/**
- * @see <a href="http://msdn.microsoft.com/en-us/library/ee460801" >api</a>
- */
-public class ErrorHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Error> {
-
- private StringBuilder currentText = new StringBuilder();
- private Error.Builder builder = Error.builder();
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Error getResult() {
- try {
- return builder.build();
- } finally {
- builder = Error.builder();
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void endElement(String uri, String name, String qName) throws SAXException {
- if (qName.equals("Code")) {
- String rawCode = SaxUtils.currentOrNull(currentText);
- builder.rawCode(rawCode);
- builder.code(Code.fromValue(rawCode));
- } else if (qName.equals("Message")) {
- builder.message(SaxUtils.currentOrNull(currentText));
- }
- currentText.setLength(0);
- }
-
- /**
- * {@inheritDoc}
- */
- @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/6ab58bd2/azure-management/src/main/java/org/jclouds/azure/management/xml/HostedServiceHandler.java
----------------------------------------------------------------------
diff --git a/azure-management/src/main/java/org/jclouds/azure/management/xml/HostedServiceHandler.java b/azure-management/src/main/java/org/jclouds/azure/management/xml/HostedServiceHandler.java
deleted file mode 100644
index e5060e2..0000000
--- a/azure-management/src/main/java/org/jclouds/azure/management/xml/HostedServiceHandler.java
+++ /dev/null
@@ -1,109 +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.azure.management.xml;
-
-import static org.jclouds.util.SaxUtils.currentOrNull;
-import static org.jclouds.util.SaxUtils.equalsOrSuffix;
-
-import java.net.URI;
-
-import javax.inject.Inject;
-
-import org.jclouds.azure.management.domain.HostedService;
-import org.jclouds.azure.management.domain.HostedService.Builder;
-import org.jclouds.http.functions.ParseSax;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-
-/**
- * @see <a href="http://msdn.microsoft.com/en-us/library/gg441293" >api</a>
- */
-public class HostedServiceHandler extends ParseSax.HandlerForGeneratedRequestWithResult<HostedService> {
-
- protected final HostedServicePropertiesHandler hostedServicePropertiesHandler;
-
- @Inject
- protected HostedServiceHandler(HostedServicePropertiesHandler hostedServicePropertiesHandler) {
- this.hostedServicePropertiesHandler = hostedServicePropertiesHandler;
- }
-
- protected StringBuilder currentText = new StringBuilder();
- protected HostedService.Builder<?> builder = builder();
-
- protected Builder<?> builder() {
- return HostedService.builder();
- }
-
- protected boolean inHostedServiceProperties;
-
- /**
- * {@inheritDoc}
- */
- @Override
- public HostedService getResult() {
- try {
- return builder.build();
- } finally {
- builder = builder();
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException {
- if (equalsOrSuffix(qName, "HostedServiceProperties")) {
- inHostedServiceProperties = true;
- }
- if (inHostedServiceProperties) {
- hostedServicePropertiesHandler.startElement(url, name, qName, attributes);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void endElement(String uri, String name, String qName) throws SAXException {
-
- if (equalsOrSuffix(qName, "HostedServiceProperties")) {
- builder.properties(hostedServicePropertiesHandler.getResult());
- inHostedServiceProperties = false;
- } else if (inHostedServiceProperties) {
- hostedServicePropertiesHandler.endElement(uri, name, qName);
- } else if (equalsOrSuffix(qName, "Url")) {
- builder.url(URI.create(currentOrNull(currentText)));
- } else if (equalsOrSuffix(qName, "ServiceName")) {
- builder.name(currentOrNull(currentText));
- }
- currentText.setLength(0);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void characters(char ch[], int start, int length) {
- if (inHostedServiceProperties) {
- hostedServicePropertiesHandler.characters(ch, start, length);
- } else {
- currentText.append(ch, start, length);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/6ab58bd2/azure-management/src/main/java/org/jclouds/azure/management/xml/HostedServicePropertiesHandler.java
----------------------------------------------------------------------
diff --git a/azure-management/src/main/java/org/jclouds/azure/management/xml/HostedServicePropertiesHandler.java b/azure-management/src/main/java/org/jclouds/azure/management/xml/HostedServicePropertiesHandler.java
deleted file mode 100644
index 3d7dfb2..0000000
--- a/azure-management/src/main/java/org/jclouds/azure/management/xml/HostedServicePropertiesHandler.java
+++ /dev/null
@@ -1,74 +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.azure.management.xml;
-
-import static com.google.common.base.Charsets.UTF_8;
-import static com.google.common.io.BaseEncoding.base64;
-import static org.jclouds.util.SaxUtils.currentOrNull;
-import static org.jclouds.util.SaxUtils.equalsOrSuffix;
-
-import org.jclouds.azure.management.domain.HostedServiceProperties;
-import org.jclouds.http.functions.ParseSax;
-import org.xml.sax.SAXException;
-
-/**
- * @see <a href="http://msdn.microsoft.com/en-us/library/gg441293" >api</a>
- */
-public class HostedServicePropertiesHandler extends
- ParseSax.HandlerForGeneratedRequestWithResult<HostedServiceProperties> {
-
- protected StringBuilder currentText = new StringBuilder();
- private HostedServiceProperties.Builder<?> builder = HostedServiceProperties.builder();
-
- /**
- * {@inheritDoc}
- */
- @Override
- public HostedServiceProperties getResult() {
- try {
- return builder.build();
- } finally {
- builder = HostedServiceProperties.builder();
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void endElement(String uri, String name, String qName) throws SAXException {
- if (equalsOrSuffix(qName, "Description")) {
- builder.description(currentOrNull(currentText));
- } else if (equalsOrSuffix(qName, "Location")) {
- builder.location(currentOrNull(currentText));
- } else if (equalsOrSuffix(qName, "AffinityGroup")) {
- builder.affinityGroup(currentOrNull(currentText));
- } else if (equalsOrSuffix(qName, "Label")) {
- builder.label(new String(base64().decode(currentOrNull(currentText)), UTF_8));
- }
- currentText.setLength(0);
- }
-
- /**
- * {@inheritDoc}
- */
- @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/6ab58bd2/azure-management/src/main/java/org/jclouds/azure/management/xml/HostedServiceWithDetailedPropertiesHandler.java
----------------------------------------------------------------------
diff --git a/azure-management/src/main/java/org/jclouds/azure/management/xml/HostedServiceWithDetailedPropertiesHandler.java b/azure-management/src/main/java/org/jclouds/azure/management/xml/HostedServiceWithDetailedPropertiesHandler.java
deleted file mode 100644
index 73a203e..0000000
--- a/azure-management/src/main/java/org/jclouds/azure/management/xml/HostedServiceWithDetailedPropertiesHandler.java
+++ /dev/null
@@ -1,44 +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.azure.management.xml;
-
-import javax.inject.Inject;
-
-import org.jclouds.azure.management.domain.HostedServiceWithDetailedProperties;
-
-public class HostedServiceWithDetailedPropertiesHandler extends HostedServiceHandler {
-
- @Inject
- protected HostedServiceWithDetailedPropertiesHandler(
- DetailedHostedServicePropertiesHandler hostedServicePropertiesHandler) {
- super(hostedServicePropertiesHandler);
- }
-
- @Override
- protected HostedServiceWithDetailedProperties.Builder<?> builder() {
- return HostedServiceWithDetailedProperties.builder();
- }
-
- @Override
- public HostedServiceWithDetailedProperties getResult() {
- try {
- return HostedServiceWithDetailedProperties.class.cast(builder.build());
- } finally {
- builder = builder();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/6ab58bd2/azure-management/src/main/java/org/jclouds/azure/management/xml/ListDisksHandler.java
----------------------------------------------------------------------
diff --git a/azure-management/src/main/java/org/jclouds/azure/management/xml/ListDisksHandler.java b/azure-management/src/main/java/org/jclouds/azure/management/xml/ListDisksHandler.java
deleted file mode 100644
index b9e4c09..0000000
--- a/azure-management/src/main/java/org/jclouds/azure/management/xml/ListDisksHandler.java
+++ /dev/null
@@ -1,88 +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.azure.management.xml;
-
-import java.util.Set;
-
-import org.jclouds.azure.management.domain.Disk;
-import org.jclouds.http.functions.ParseSax;
-import org.jclouds.util.SaxUtils;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.ImmutableSet.Builder;
-import com.google.inject.Inject;
-
-public class ListDisksHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Set<Disk>> {
-
- private final DiskHandler diskHandler;
-
- private Builder<Disk> disks = ImmutableSet.<Disk> builder();
-
- private boolean inDisk;
-
- @Inject
- public ListDisksHandler(final DiskHandler diskHandler) {
- this.diskHandler = diskHandler;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Set<Disk> getResult() {
- return disks.build();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException {
- if (SaxUtils.equalsOrSuffix(qName, "Disk")) {
- inDisk = true;
- }
- if (inDisk) {
- diskHandler.startElement(url, name, qName, attributes);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void endElement(String uri, String name, String qName) throws SAXException {
- if (qName.equals("Disk")) {
- inDisk = false;
- disks.add(diskHandler.getResult());
- } else if (inDisk) {
- diskHandler.endElement(uri, name, qName);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void characters(char ch[], int start, int length) {
- if (inDisk) {
- diskHandler.characters(ch, start, length);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/6ab58bd2/azure-management/src/main/java/org/jclouds/azure/management/xml/ListHostedServicesHandler.java
----------------------------------------------------------------------
diff --git a/azure-management/src/main/java/org/jclouds/azure/management/xml/ListHostedServicesHandler.java b/azure-management/src/main/java/org/jclouds/azure/management/xml/ListHostedServicesHandler.java
deleted file mode 100644
index aa2dea6..0000000
--- a/azure-management/src/main/java/org/jclouds/azure/management/xml/ListHostedServicesHandler.java
+++ /dev/null
@@ -1,93 +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.azure.management.xml;
-
-import java.util.Set;
-
-import org.jclouds.azure.management.domain.HostedServiceWithDetailedProperties;
-import org.jclouds.http.functions.ParseSax;
-import org.jclouds.util.SaxUtils;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.ImmutableSet.Builder;
-import com.google.inject.Inject;
-
-/**
- * @see <a href="http://msdn.microsoft.com/en-us/library/ee460781">doc</a>
- */
-public class ListHostedServicesHandler extends
- ParseSax.HandlerForGeneratedRequestWithResult<Set<HostedServiceWithDetailedProperties>> {
-
- private final HostedServiceWithDetailedPropertiesHandler hostedServiceHandler;
-
- private Builder<HostedServiceWithDetailedProperties> hostedServices = ImmutableSet
- .<HostedServiceWithDetailedProperties> builder();
-
- private boolean inHostedService;
-
- @Inject
- public ListHostedServicesHandler(HostedServiceWithDetailedPropertiesHandler hostedServiceHandler) {
- this.hostedServiceHandler = hostedServiceHandler;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Set<HostedServiceWithDetailedProperties> getResult() {
- return hostedServices.build();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException {
- if (SaxUtils.equalsOrSuffix(qName, "HostedService")) {
- inHostedService = true;
- }
- if (inHostedService) {
- hostedServiceHandler.startElement(url, name, qName, attributes);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void endElement(String uri, String name, String qName) throws SAXException {
- if (qName.equals("HostedService")) {
- inHostedService = false;
- hostedServices.add(hostedServiceHandler.getResult());
- } else if (inHostedService) {
- hostedServiceHandler.endElement(uri, name, qName);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void characters(char ch[], int start, int length) {
- if (inHostedService) {
- hostedServiceHandler.characters(ch, start, length);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/6ab58bd2/azure-management/src/main/java/org/jclouds/azure/management/xml/ListLocationsHandler.java
----------------------------------------------------------------------
diff --git a/azure-management/src/main/java/org/jclouds/azure/management/xml/ListLocationsHandler.java b/azure-management/src/main/java/org/jclouds/azure/management/xml/ListLocationsHandler.java
deleted file mode 100644
index d29a30f..0000000
--- a/azure-management/src/main/java/org/jclouds/azure/management/xml/ListLocationsHandler.java
+++ /dev/null
@@ -1,88 +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.azure.management.xml;
-
-import java.util.Set;
-
-import org.jclouds.azure.management.domain.Location;
-import org.jclouds.http.functions.ParseSax;
-import org.jclouds.util.SaxUtils;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.ImmutableSet.Builder;
-import com.google.inject.Inject;
-
-public class ListLocationsHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Set<Location>> {
-
- private final LocationHandler locationHandler;
-
- private Builder<Location> locations = ImmutableSet.<Location> builder();
-
- private boolean inLocation;
-
- @Inject
- public ListLocationsHandler(LocationHandler locationHandler) {
- this.locationHandler = locationHandler;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Set<Location> getResult() {
- return locations.build();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException {
- if (SaxUtils.equalsOrSuffix(qName, "Location")) {
- inLocation = true;
- }
- if (inLocation) {
- locationHandler.startElement(url, name, qName, attributes);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void endElement(String uri, String name, String qName) throws SAXException {
- if (qName.equals("Location")) {
- inLocation = false;
- locations.add(locationHandler.getResult());
- } else if (inLocation) {
- locationHandler.endElement(uri, name, qName);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void characters(char ch[], int start, int length) {
- if (inLocation) {
- locationHandler.characters(ch, start, length);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/6ab58bd2/azure-management/src/main/java/org/jclouds/azure/management/xml/ListOSImagesHandler.java
----------------------------------------------------------------------
diff --git a/azure-management/src/main/java/org/jclouds/azure/management/xml/ListOSImagesHandler.java b/azure-management/src/main/java/org/jclouds/azure/management/xml/ListOSImagesHandler.java
deleted file mode 100644
index 593a0ed..0000000
--- a/azure-management/src/main/java/org/jclouds/azure/management/xml/ListOSImagesHandler.java
+++ /dev/null
@@ -1,88 +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.azure.management.xml;
-
-import java.util.Set;
-
-import org.jclouds.azure.management.domain.OSImage;
-import org.jclouds.http.functions.ParseSax;
-import org.jclouds.util.SaxUtils;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.ImmutableSet.Builder;
-import com.google.inject.Inject;
-
-public class ListOSImagesHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Set<OSImage>> {
-
- private final OSImageHandler locationHandler;
-
- private Builder<OSImage> locations = ImmutableSet.<OSImage> builder();
-
- private boolean inOSImage;
-
- @Inject
- public ListOSImagesHandler(OSImageHandler locationHandler) {
- this.locationHandler = locationHandler;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Set<OSImage> getResult() {
- return locations.build();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException {
- if (SaxUtils.equalsOrSuffix(qName, "OSImage")) {
- inOSImage = true;
- }
- if (inOSImage) {
- locationHandler.startElement(url, name, qName, attributes);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void endElement(String uri, String name, String qName) throws SAXException {
- if (qName.equals("OSImage")) {
- inOSImage = false;
- locations.add(locationHandler.getResult());
- } else if (inOSImage) {
- locationHandler.endElement(uri, name, qName);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void characters(char ch[], int start, int length) {
- if (inOSImage) {
- locationHandler.characters(ch, start, length);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/6ab58bd2/azure-management/src/main/java/org/jclouds/azure/management/xml/LocationHandler.java
----------------------------------------------------------------------
diff --git a/azure-management/src/main/java/org/jclouds/azure/management/xml/LocationHandler.java b/azure-management/src/main/java/org/jclouds/azure/management/xml/LocationHandler.java
deleted file mode 100644
index 6313820..0000000
--- a/azure-management/src/main/java/org/jclouds/azure/management/xml/LocationHandler.java
+++ /dev/null
@@ -1,67 +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.azure.management.xml;
-
-import org.jclouds.azure.management.domain.Location;
-import org.jclouds.http.functions.ParseSax;
-import org.jclouds.util.SaxUtils;
-import org.xml.sax.SAXException;
-
-/**
- * @see <a href="http://msdn.microsoft.com/en-us/library/gg441293" >api</a>
- */
-public class LocationHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Location> {
-
- private StringBuilder currentText = new StringBuilder();
- private Location.Builder builder = Location.builder();
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Location getResult() {
- try {
- return builder.build();
- } finally {
- builder = Location.builder();
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void endElement(String uri, String name, String qName) throws SAXException {
- if (qName.equals("Name")) {
- builder.name(SaxUtils.currentOrNull(currentText));
- } else if (qName.equals("DisplayName")) {
- builder.displayName(SaxUtils.currentOrNull(currentText));
- } else if (qName.equals("AvailableService")) {
- builder.addAvailableService(SaxUtils.currentOrNull(currentText));
- }
- currentText.setLength(0);
- }
-
- /**
- * {@inheritDoc}
- */
- @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/6ab58bd2/azure-management/src/main/java/org/jclouds/azure/management/xml/OSImageHandler.java
----------------------------------------------------------------------
diff --git a/azure-management/src/main/java/org/jclouds/azure/management/xml/OSImageHandler.java b/azure-management/src/main/java/org/jclouds/azure/management/xml/OSImageHandler.java
deleted file mode 100644
index 22508e8..0000000
--- a/azure-management/src/main/java/org/jclouds/azure/management/xml/OSImageHandler.java
+++ /dev/null
@@ -1,92 +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.azure.management.xml;
-
-import static org.jclouds.util.SaxUtils.currentOrNull;
-import static org.jclouds.util.SaxUtils.equalsOrSuffix;
-
-import java.net.URI;
-
-import org.jclouds.azure.management.domain.OSImage;
-import org.jclouds.azure.management.domain.OSType;
-import org.jclouds.http.functions.ParseSax;
-import org.xml.sax.SAXException;
-
-/**
- * @see <a href="http://msdn.microsoft.com/en-us/library/jj157191" >api</a>
- */
-public class OSImageHandler extends ParseSax.HandlerForGeneratedRequestWithResult<OSImage> {
-
- protected StringBuilder currentText = new StringBuilder();
- private OSImage.Builder<?> builder = OSImage.builder();
-
- /**
- * {@inheritDoc}
- */
- @Override
- public OSImage getResult() {
- try {
- return builder.build();
- } finally {
- builder = OSImage.builder();
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void endElement(String uri, String name, String qName) throws SAXException {
- if (equalsOrSuffix(qName, "OS")) {
- builder.os(OSType.fromValue(currentOrNull(currentText)));
- } else if (equalsOrSuffix(qName, "Name")) {
- builder.name(currentOrNull(currentText));
- } else if (equalsOrSuffix(qName, "LogicalSizeInGB")) {
- String gb = currentOrNull(currentText);
- if (gb != null)
- builder.logicalSizeInGB(Integer.parseInt(gb));
- } else if (equalsOrSuffix(qName, "Description")) {
- builder.description(currentOrNull(currentText));
- } else if (equalsOrSuffix(qName, "Category")) {
- builder.category(currentOrNull(currentText));
- } else if (equalsOrSuffix(qName, "Location")) {
- builder.location(currentOrNull(currentText));
- } else if (equalsOrSuffix(qName, "AffinityGroup")) {
- builder.affinityGroup(currentOrNull(currentText));
- } else if (equalsOrSuffix(qName, "MediaLink")) {
- String link = currentOrNull(currentText);
- if (link != null)
- builder.mediaLink(URI.create(link));
- } else if (equalsOrSuffix(qName, "Eula")) {
- String eula = currentOrNull(currentText);
- if (eula != null)
- builder.eula(URI.create(eula));
- } else if (equalsOrSuffix(qName, "Label")) {
- builder.label(currentOrNull(currentText));
- }
- currentText.setLength(0);
- }
-
- /**
- * {@inheritDoc}
- */
- @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/6ab58bd2/azure-management/src/main/java/org/jclouds/azure/management/xml/OperationHandler.java
----------------------------------------------------------------------
diff --git a/azure-management/src/main/java/org/jclouds/azure/management/xml/OperationHandler.java b/azure-management/src/main/java/org/jclouds/azure/management/xml/OperationHandler.java
deleted file mode 100644
index 816a0d7..0000000
--- a/azure-management/src/main/java/org/jclouds/azure/management/xml/OperationHandler.java
+++ /dev/null
@@ -1,111 +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.azure.management.xml;
-
-import static org.jclouds.util.SaxUtils.currentOrNull;
-import static org.jclouds.util.SaxUtils.equalsOrSuffix;
-
-import javax.inject.Inject;
-
-import org.jclouds.azure.management.domain.Operation;
-import org.jclouds.azure.management.domain.Operation.Builder;
-import org.jclouds.azure.management.domain.Operation.Status;
-import org.jclouds.http.functions.ParseSax;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-
-/**
- * @see <a href="http://msdn.microsoft.com/en-us/library/ee460783" >api</a>
- */
-public class OperationHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Operation> {
-
- protected final ErrorHandler errorHandler;
-
- @Inject
- protected OperationHandler(ErrorHandler errorHandler) {
- this.errorHandler = errorHandler;
- }
-
- protected StringBuilder currentText = new StringBuilder();
- protected Operation.Builder builder = builder();
-
- protected Builder builder() {
- return Operation.builder();
- }
-
- protected boolean inError;
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Operation getResult() {
- try {
- return builder.build();
- } finally {
- builder = builder();
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException {
- if (equalsOrSuffix(qName, "Error")) {
- inError = true;
- }
- if (inError) {
- errorHandler.startElement(url, name, qName, attributes);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void endElement(String uri, String name, String qName) throws SAXException {
- if (equalsOrSuffix(qName, "Error")) {
- builder.error(errorHandler.getResult());
- inError = false;
- } else if (inError) {
- errorHandler.endElement(uri, name, qName);
- } else if (equalsOrSuffix(qName, "ID")) {
- builder.id(currentOrNull(currentText));
- } else if (qName.equals("Status")) {
- String rawStatus = currentOrNull(currentText);
- builder.rawStatus(rawStatus);
- builder.status(Status.fromValue(rawStatus));
- } else if (equalsOrSuffix(qName, "HttpStatusCode")) {
- builder.httpStatusCode(Integer.parseInt(currentOrNull(currentText)));
- }
- currentText.setLength(0);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void characters(char ch[], int start, int length) {
- if (inError) {
- errorHandler.characters(ch, start, length);
- } else {
- currentText.append(ch, start, length);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/6ab58bd2/azure-management/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata
----------------------------------------------------------------------
diff --git a/azure-management/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/azure-management/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata
deleted file mode 100644
index 03fb1db..0000000
--- a/azure-management/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata
+++ /dev/null
@@ -1 +0,0 @@
-org.jclouds.azure.management.AzureManagementProviderMetadata
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/6ab58bd2/azure-management/src/test/java/org/jclouds/azure/management/AzureManagementProviderMetadataTest.java
----------------------------------------------------------------------
diff --git a/azure-management/src/test/java/org/jclouds/azure/management/AzureManagementProviderMetadataTest.java b/azure-management/src/test/java/org/jclouds/azure/management/AzureManagementProviderMetadataTest.java
deleted file mode 100644
index a8cf4a7..0000000
--- a/azure-management/src/test/java/org/jclouds/azure/management/AzureManagementProviderMetadataTest.java
+++ /dev/null
@@ -1,28 +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.azure.management;
-
-import org.jclouds.providers.internal.BaseProviderMetadataTest;
-import org.testng.annotations.Test;
-
-@Test(groups = "unit", testName = "AzureManagementProviderMetadataTest")
-public class AzureManagementProviderMetadataTest extends BaseProviderMetadataTest {
-
- public AzureManagementProviderMetadataTest() {
- super(new AzureManagementProviderMetadata(), new AzureManagementApiMetadata());
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/6ab58bd2/azure-management/src/test/java/org/jclouds/azure/management/features/DiskApiExpectTest.java
----------------------------------------------------------------------
diff --git a/azure-management/src/test/java/org/jclouds/azure/management/features/DiskApiExpectTest.java b/azure-management/src/test/java/org/jclouds/azure/management/features/DiskApiExpectTest.java
deleted file mode 100644
index c2fbd08..0000000
--- a/azure-management/src/test/java/org/jclouds/azure/management/features/DiskApiExpectTest.java
+++ /dev/null
@@ -1,81 +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.azure.management.features;
-
-import static org.testng.Assert.assertEquals;
-
-import org.jclouds.azure.management.AzureManagementApi;
-import org.jclouds.azure.management.internal.BaseAzureManagementApiExpectTest;
-import org.jclouds.azure.management.parse.ListDisksTest;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpResponse;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableSet;
-
-@Test(groups = "unit", testName = "DiskApiExpectTest")
-public class DiskApiExpectTest extends BaseAzureManagementApiExpectTest {
-
- private static final String DISK_NAME = "mydisk";
-
- HttpRequest list = HttpRequest.builder().method("GET")
- .endpoint("https://management.core.windows.net/" + subscriptionId + "/services/disks")
- .addHeader("x-ms-version", "2012-03-01")
- .addHeader("Accept", "application/xml").build();
-
- public void testListWhenResponseIs2xx() throws Exception {
-
- HttpResponse listResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResourceWithContentType("/disks.xml", "application/xml")).build();
-
- AzureManagementApi apiWhenExist = requestSendsResponse(
- list, listResponse);
-
- assertEquals(apiWhenExist.getDiskApi().list().toString(), new ListDisksTest().expected().toString());
- }
-
- public void testListWhenResponseIs404() throws Exception {
-
- HttpResponse listResponse = HttpResponse.builder().statusCode(404).build();
-
- AzureManagementApi apiWhenDontExist = requestSendsResponse(
- list, listResponse);
-
- assertEquals(apiWhenDontExist.getDiskApi().list(), ImmutableSet.of());
- }
-
- HttpRequest delete = HttpRequest.builder().method("DELETE")
- .endpoint("https://management.core.windows.net/" + subscriptionId + "/services/disks/" + DISK_NAME)
- .addHeader("x-ms-version", "2012-03-01")
- .build();
-
- public void testDeleteWhenResponseIs2xx() throws Exception {
- HttpResponse deleteResponse = HttpResponse.builder().statusCode(200).addHeader("x-ms-request-id", "fakerequestid").build();
-
- AzureManagementApi apiWhenExist = requestSendsResponse(delete, deleteResponse);
-
- apiWhenExist.getDiskApi().delete(DISK_NAME);
- }
-
- public void testDeleteWhenResponseIs404() throws Exception {
- HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build();
-
- AzureManagementApi apiWhenDontExist = requestSendsResponse(delete, deleteResponse);
-
- apiWhenDontExist.getDiskApi().delete(DISK_NAME);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/6ab58bd2/azure-management/src/test/java/org/jclouds/azure/management/features/DiskApiLiveTest.java
----------------------------------------------------------------------
diff --git a/azure-management/src/test/java/org/jclouds/azure/management/features/DiskApiLiveTest.java b/azure-management/src/test/java/org/jclouds/azure/management/features/DiskApiLiveTest.java
deleted file mode 100644
index 7299bdf..0000000
--- a/azure-management/src/test/java/org/jclouds/azure/management/features/DiskApiLiveTest.java
+++ /dev/null
@@ -1,122 +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.azure.management.features;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.collect.Iterables.transform;
-import static org.testng.Assert.assertNotEquals;
-import static org.testng.Assert.assertTrue;
-
-import java.util.Set;
-
-import org.jclouds.azure.management.domain.Disk;
-import org.jclouds.azure.management.domain.Location;
-import org.jclouds.azure.management.domain.OSImage;
-import org.jclouds.azure.management.domain.OSType;
-import org.jclouds.azure.management.internal.BaseAzureManagementApiLiveTest;
-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 = "DiskApiLiveTest")
-public class DiskApiLiveTest extends BaseAzureManagementApiLiveTest {
-
- private ImmutableSet<String> locations;
- private ImmutableSet<String> images;
-
- @BeforeClass(groups = { "integration", "live" })
- public void setupContext() {
- super.initializeContext();
-
- locations = ImmutableSet.copyOf(transform(context.getApi().getLocationApi().list(),
- new Function<Location, String>() {
- @Override
- public String apply(Location in) {
- return in.getName();
- }
- }));
- images = ImmutableSet.copyOf(transform(context.getApi().getOSImageApi().list(), new Function<OSImage, String>() {
- @Override
- public String apply(OSImage in) {
- return in.getName();
- }
- }));
- }
-
- @Test
- protected void testList() {
- Set<Disk> response = api().list();
-
- for (Disk disk : response) {
- checkDisk(disk);
- }
- }
-
- private void checkDisk(Disk disk) {
- checkNotNull(disk.getName(), "Name cannot be null for Disk %s", disk.getLabel());
- checkNotNull(disk.getOS(), "OS cannot be null for Disk: %s", disk);
- assertNotEquals(disk.getOS(), OSType.UNRECOGNIZED, "Status cannot be UNRECOGNIZED for Disk: " + disk);
-
- checkNotNull(disk.getAttachedTo(), "While AttachedTo can be null for Disk, its Optional wrapper cannot: %s", disk);
- if (disk.getAttachedTo().isPresent()) {
- // TODO: verify you can lookup the role
- }
-
- checkNotNull(disk.getLogicalSizeInGB(),
- "While LogicalSizeInGB can be null for Disk, its Optional wrapper cannot: %s", disk);
-
- if (disk.getLogicalSizeInGB().isPresent())
- assertTrue(disk.getLogicalSizeInGB().get() > 0, "LogicalSizeInGB should be positive, if set" + disk.toString());
-
- checkNotNull(disk.getMediaLink(), "While MediaLink can be null for Disk, its Optional wrapper cannot: %s", disk);
-
- if (disk.getMediaLink().isPresent())
- assertTrue(ImmutableSet.of("http", "https").contains(disk.getMediaLink().get().getScheme()),
- "MediaLink should be an http(s) url" + disk.toString());
-
- checkNotNull(disk.getLabel(), "While Label can be null for Disk, its Optional wrapper cannot: %s",
- disk);
-
- checkNotNull(disk.getDescription(), "While Description can be null for Disk, its Optional wrapper cannot: %s",
- disk);
-
- checkNotNull(disk.getLocation(), "While Location can be null for Disk, its Optional wrapper cannot: %s", disk);
- if (disk.getLocation().isPresent()) {
- assertTrue(locations.contains(disk.getLocation().get()),
- "Location not in " + locations + " :" + disk.toString());
- }
-
- checkNotNull(disk.getSourceImage(), "While SourceImage can be null for Disk, its Optional wrapper cannot: %s",
- disk);
- if (disk.getSourceImage().isPresent()) {
- assertTrue(images.contains(disk.getSourceImage().get()),
- "SourceImage not in " + images + " :" + disk.toString());
- }
-
- checkNotNull(disk.getAffinityGroup(),
- "While AffinityGroup can be null for Disk, its Optional wrapper cannot: %s", disk);
- if (disk.getAffinityGroup().isPresent()) {
- // TODO: list getAffinityGroups and check if there
- }
- }
-
- protected DiskApi api() {
- return context.getApi().getDiskApi();
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/6ab58bd2/azure-management/src/test/java/org/jclouds/azure/management/features/HostedServiceApiExpectTest.java
----------------------------------------------------------------------
diff --git a/azure-management/src/test/java/org/jclouds/azure/management/features/HostedServiceApiExpectTest.java b/azure-management/src/test/java/org/jclouds/azure/management/features/HostedServiceApiExpectTest.java
deleted file mode 100644
index 31aec87..0000000
--- a/azure-management/src/test/java/org/jclouds/azure/management/features/HostedServiceApiExpectTest.java
+++ /dev/null
@@ -1,168 +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.azure.management.features;
-
-import static org.jclouds.azure.management.options.CreateHostedServiceOptions.Builder.description;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNull;
-
-import org.jclouds.azure.management.AzureManagementApi;
-import org.jclouds.azure.management.internal.BaseAzureManagementApiExpectTest;
-import org.jclouds.azure.management.parse.GetHostedServiceDetailsTest;
-import org.jclouds.azure.management.parse.GetHostedServiceTest;
-import org.jclouds.azure.management.parse.ListHostedServicesTest;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpResponse;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
-
-@Test(groups = "unit", testName = "HostedServiceApiExpectTest")
-public class HostedServiceApiExpectTest extends BaseAzureManagementApiExpectTest {
-
- private static final String SERVICE_NAME = "myservice";
- HttpRequest list = HttpRequest.builder().method("GET")
- .endpoint("https://management.core.windows.net/" + subscriptionId + "/services/hostedservices")
- .addHeader("x-ms-version", "2012-03-01")
- .addHeader("Accept", "application/xml").build();
-
- public void testListWhenResponseIs2xx() throws Exception {
-
- HttpResponse listResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResourceWithContentType("/hostedservices.xml", "application")).build();
-
- AzureManagementApi apiWhenExist = requestSendsResponse(
- list, listResponse);
-
- assertEquals(apiWhenExist.getHostedServiceApi().list().toString(), new ListHostedServicesTest().expected().toString());
- }
-
- public void testListWhenResponseIs404() throws Exception {
-
- HttpResponse listResponse = HttpResponse.builder().statusCode(404).build();
-
- AzureManagementApi apiWhenDontExist = requestSendsResponse(
- list, listResponse);
-
- assertEquals(apiWhenDontExist.getHostedServiceApi().list(), ImmutableSet.of());
- }
-
-
- public void testCreateServiceWithLabelInLocationWhenResponseIs2xx() throws Exception {
- HttpRequest create = HttpRequest.builder().method("POST")
- .endpoint("https://management.core.windows.net/" + subscriptionId + "/services/hostedservices")
- .addHeader("x-ms-version", "2012-03-01")
- .payload(payloadFromResourceWithContentType("/create_hostedservice_location.xml", "application/xml")).build();
-
- HttpResponse createResponse = HttpResponse.builder()
- .addHeader("x-ms-request-id", "171f77920784404db208200702e59227")
- .statusCode(201).build();
-
- AzureManagementApi apiWhenExist = requestSendsResponse(create, createResponse);
-
- assertEquals(
- apiWhenExist.getHostedServiceApi().createServiceWithLabelInLocation(SERVICE_NAME, "service mine",
- "West US"), "171f77920784404db208200702e59227");
- }
-
- public void testCreateWithOptionalParamsWhenResponseIs2xx() throws Exception {
- HttpRequest create = HttpRequest.builder().method("POST")
- .endpoint("https://management.core.windows.net/" + subscriptionId + "/services/hostedservices")
- .addHeader("x-ms-version", "2012-03-01")
- .payload(payloadFromResourceWithContentType("/create_hostedservice_location_options.xml", "application/xml")).build();
-
- HttpResponse createResponse = HttpResponse.builder()
- .addHeader("x-ms-request-id", "171f77920784404db208200702e59227")
- .statusCode(201).build();
-
- AzureManagementApi apiWhenExist = requestSendsResponse(create, createResponse);
-
- assertEquals(
- apiWhenExist.getHostedServiceApi().createServiceWithLabelInLocation(SERVICE_NAME, "service mine",
- "West US",
- description("my description").extendedProperties(ImmutableMap.of("Role", "Production"))),
- "171f77920784404db208200702e59227");
- }
-
- HttpRequest get = HttpRequest.builder().method("GET")
- .endpoint("https://management.core.windows.net/" + subscriptionId + "/services/hostedservices/" + SERVICE_NAME)
- .addHeader("x-ms-version", "2012-03-01")
- .addHeader("Accept", "application/xml").build();
-
- public void testGetWhenResponseIs2xx() throws Exception {
- HttpResponse getResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResourceWithContentType("/hostedservice.xml", "application")).build();
-
- AzureManagementApi apiWhenExist = requestSendsResponse(get, getResponse);
-
- assertEquals(apiWhenExist.getHostedServiceApi().get(SERVICE_NAME).toString(), new GetHostedServiceTest().expected().toString());
- }
-
- public void testGetWhenResponseIs404() throws Exception {
- HttpResponse getResponse = HttpResponse.builder().statusCode(404).build();
-
- AzureManagementApi apiWhenDontExist = requestSendsResponse(get, getResponse);
-
- assertNull(apiWhenDontExist.getHostedServiceApi().get(SERVICE_NAME));
- }
-
- HttpRequest getDetails = HttpRequest.builder().method("GET")
- .endpoint("https://management.core.windows.net/" + subscriptionId + "/services/hostedservices/" + SERVICE_NAME + "?embed-detail=true")
- .addHeader("x-ms-version", "2012-03-01")
- .addHeader("Accept", "application/xml").build();
-
- public void testGetDetailsWhenResponseIs2xx() throws Exception {
- HttpResponse getResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResourceWithContentType("/hostedservice_details.xml", "application")).build();
-
- AzureManagementApi apiWhenExist = requestSendsResponse(getDetails, getResponse);
-
- assertEquals(apiWhenExist.getHostedServiceApi().getDetails(SERVICE_NAME).toString(), new GetHostedServiceDetailsTest().expected().toString());
- }
-
- public void testGetDetailsWhenResponseIs404() throws Exception {
- HttpResponse getResponse = HttpResponse.builder().statusCode(404).build();
-
- AzureManagementApi apiWhenDontExist = requestSendsResponse(getDetails, getResponse);
-
- assertNull(apiWhenDontExist.getHostedServiceApi().getDetails(SERVICE_NAME));
- }
-
- HttpRequest delete = HttpRequest.builder().method("DELETE")
- .endpoint("https://management.core.windows.net/" + subscriptionId + "/services/hostedservices/" + SERVICE_NAME)
- .addHeader("x-ms-version", "2012-03-01")
- .build();
-
- public void testDeleteWhenResponseIs2xx() throws Exception {
- HttpResponse deleteResponse = HttpResponse.builder()
- .addHeader("x-ms-request-id", "171f77920784404db208200702e59227")
- .statusCode(200).build();
-
- AzureManagementApi apiWhenExist = requestSendsResponse(delete, deleteResponse);
-
- assertEquals(apiWhenExist.getHostedServiceApi().delete(SERVICE_NAME), "171f77920784404db208200702e59227");
- }
-
- public void testDeleteWhenResponseIs404() throws Exception {
- HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build();
-
- AzureManagementApi apiWhenDontExist = requestSendsResponse(delete, deleteResponse);
-
- assertNull(apiWhenDontExist.getHostedServiceApi().delete(SERVICE_NAME));
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/6ab58bd2/azure-management/src/test/java/org/jclouds/azure/management/features/HostedServiceApiLiveTest.java
----------------------------------------------------------------------
diff --git a/azure-management/src/test/java/org/jclouds/azure/management/features/HostedServiceApiLiveTest.java b/azure-management/src/test/java/org/jclouds/azure/management/features/HostedServiceApiLiveTest.java
deleted file mode 100644
index 4789541..0000000
--- a/azure-management/src/test/java/org/jclouds/azure/management/features/HostedServiceApiLiveTest.java
+++ /dev/null
@@ -1,171 +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.azure.management.features;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
-import static java.util.concurrent.TimeUnit.SECONDS;
-import static org.jclouds.util.Predicates2.retry;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotEquals;
-import static org.testng.Assert.assertTrue;
-
-import java.util.Set;
-import java.util.logging.Logger;
-
-import org.jclouds.azure.management.domain.DetailedHostedServiceProperties;
-import org.jclouds.azure.management.domain.HostedService;
-import org.jclouds.azure.management.domain.HostedService.Status;
-import org.jclouds.azure.management.domain.HostedServiceWithDetailedProperties;
-import org.jclouds.azure.management.domain.Operation;
-import org.jclouds.azure.management.internal.BaseAzureManagementApiLiveTest;
-import org.testng.Assert;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterables;
-
-@Test(groups = "live", testName = "HostedServiceApiLiveTest")
-public class HostedServiceApiLiveTest extends BaseAzureManagementApiLiveTest {
-
- public static final String HOSTED_SERVICE = (System.getProperty("user.name") + "-jclouds-hostedService")
- .toLowerCase();
-
- private Predicate<String> operationSucceeded;
- private Predicate<HostedServiceWithDetailedProperties> hostedServiceCreated;
- private Predicate<HostedService> hostedServiceGone;
-
- private String location;
-
- @BeforeClass(groups = "live")
- @Override
- public void setupContext() {
- super.setupContext();
- // TODO: filter locations on those who have compute
- location = Iterables.get(context.getApi().getLocationApi().list(), 0).getName();
- operationSucceeded = retry(new Predicate<String>() {
- public boolean apply(String input) {
- return context.getApi().getOperationApi().get(input).getStatus() == Operation.Status.SUCCEEDED;
- }
- }, 600, 5, 5, SECONDS);
- hostedServiceCreated = retry(new Predicate<HostedServiceWithDetailedProperties>() {
- public boolean apply(HostedServiceWithDetailedProperties input) {
- return api().getDetails(input.getName()).getProperties().getStatus() == Status.CREATED;
- }
- }, 600, 5, 5, SECONDS);
- hostedServiceGone = retry(new Predicate<HostedService>() {
- public boolean apply(HostedService input) {
- return api().get(input.getName()) == null;
- }
- }, 600, 5, 5, SECONDS);
- }
-
- private HostedServiceWithDetailedProperties hostedService;
-
- public void testCreateHostedService() {
-
- String requestId = api().createServiceWithLabelInLocation(HOSTED_SERVICE, HOSTED_SERVICE, location);
- assertTrue(operationSucceeded.apply(requestId), requestId);
- Logger.getAnonymousLogger().info("operation succeeded: " + requestId);
-
- hostedService = api().getDetails(HOSTED_SERVICE);
- Logger.getAnonymousLogger().info("created hostedService: " + hostedService);
-
- assertEquals(hostedService.getName(), HOSTED_SERVICE);
-
- checkHostedService(hostedService);
-
- assertTrue(hostedServiceCreated.apply(hostedService), hostedService.toString());
- hostedService = api().getDetails(hostedService.getName());
- Logger.getAnonymousLogger().info("hostedService available: " + hostedService);
-
- }
-
- @Test(dependsOnMethods = "testCreateHostedService")
- public void testDeleteHostedService() {
- String requestId = api().delete(hostedService.getName());
- assertTrue(operationSucceeded.apply(requestId), requestId);
- Logger.getAnonymousLogger().info("operation succeeded: " + requestId);
-
- assertTrue(hostedServiceGone.apply(hostedService), hostedService.toString());
- Logger.getAnonymousLogger().info("hostedService deleted: " + hostedService);
- }
-
- @Override
- @AfterClass(groups = "live")
- protected void tearDownContext() {
- String requestId = api().delete(HOSTED_SERVICE);
- if (requestId != null)
- operationSucceeded.apply(requestId);
-
- super.tearDownContext();
- }
-
- @Test
- protected void testList() {
- Set<HostedServiceWithDetailedProperties> response = api().list();
-
- for (HostedServiceWithDetailedProperties hostedService : response) {
- checkHostedService(hostedService);
- }
-
- if (response.size() > 0) {
- HostedService hostedService = response.iterator().next();
- Assert.assertEquals(api().getDetails(hostedService.getName()), hostedService);
- }
- }
-
- private void checkHostedService(HostedServiceWithDetailedProperties hostedService) {
- checkNotNull(hostedService.getUrl(), "Url cannot be null for a HostedService.");
- checkNotNull(hostedService.getName(), "ServiceName cannot be null for HostedService %s", hostedService.getUrl());
- checkNotNull(hostedService.getProperties(), "Properties cannot be null for HostedService %s",
- hostedService.getUrl());
- checkProperties(hostedService.getProperties());
- }
-
- private void checkProperties(DetailedHostedServiceProperties hostedService) {
- checkNotNull(hostedService.getDescription(),
- "While Description can be null for DetailedHostedServiceProperties, its Optional wrapper cannot: %s",
- hostedService);
- checkNotNull(hostedService.getLocation(),
- "While Location can be null for DetailedHostedServiceProperties, its Optional wrapper cannot: %s",
- hostedService);
- checkNotNull(hostedService.getAffinityGroup(),
- "While AffinityGroup can be null for DetailedHostedServiceProperties, its Optional wrapper cannot: %s",
- hostedService);
- checkState(hostedService.getLocation().isPresent() || hostedService.getAffinityGroup().isPresent(),
- "Location or AffinityGroup must be present for DetailedHostedServiceProperties: %s", hostedService);
- checkNotNull(hostedService.getLabel(), "Label cannot be null for HostedService %s", hostedService);
-
- checkNotNull(hostedService.getStatus(), "Status cannot be null for DetailedHostedServiceProperties: %s",
- hostedService);
- assertNotEquals(hostedService.getStatus(), Status.UNRECOGNIZED,
- "Status cannot be UNRECOGNIZED for DetailedHostedServiceProperties: " + hostedService);
- checkNotNull(hostedService.getCreated(), "Created cannot be null for DetailedHostedServiceProperties %s",
- hostedService);
- checkNotNull(hostedService.getLastModified(),
- "LastModified cannot be null for DetailedHostedServiceProperties %s", hostedService);
- checkNotNull(hostedService.getExtendedProperties(),
- "ExtendedProperties cannot be null for DetailedHostedServiceProperties %s", hostedService);
- }
-
- protected HostedServiceApi api() {
- return context.getApi().getHostedServiceApi();
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/6ab58bd2/azure-management/src/test/java/org/jclouds/azure/management/features/LocationApiExpectTest.java
----------------------------------------------------------------------
diff --git a/azure-management/src/test/java/org/jclouds/azure/management/features/LocationApiExpectTest.java b/azure-management/src/test/java/org/jclouds/azure/management/features/LocationApiExpectTest.java
deleted file mode 100644
index 3eae54e..0000000
--- a/azure-management/src/test/java/org/jclouds/azure/management/features/LocationApiExpectTest.java
+++ /dev/null
@@ -1,59 +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.azure.management.features;
-
-import static org.testng.Assert.assertEquals;
-
-import org.jclouds.azure.management.AzureManagementApi;
-import org.jclouds.azure.management.internal.BaseAzureManagementApiExpectTest;
-import org.jclouds.azure.management.parse.ListLocationsTest;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpResponse;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableSet;
-
-@Test(groups = "unit", testName = "LocationApiExpectTest")
-public class LocationApiExpectTest extends BaseAzureManagementApiExpectTest {
-
- HttpRequest list = HttpRequest.builder()
- .method("GET")
- .endpoint("https://management.core.windows.net/" + subscriptionId + "/locations")
- .addHeader("x-ms-version", "2012-03-01")
- .addHeader("Accept", "application/xml").build();
-
- public void testListWhenResponseIs2xx() throws Exception {
-
- HttpResponse listResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResourceWithContentType("/locations.xml", "application")).build();
-
- AzureManagementApi apiWhenExist = requestSendsResponse(
- list, listResponse);
-
- assertEquals(apiWhenExist.getLocationApi().list().toString(), new ListLocationsTest().expected().toString());
- }
-
- public void testListWhenResponseIs404() throws Exception {
-
- HttpResponse listResponse = HttpResponse.builder().statusCode(404).build();
-
- AzureManagementApi apiWhenDontExist = requestSendsResponse(
- list, listResponse);
-
- assertEquals(apiWhenDontExist.getLocationApi().list(), ImmutableSet.of());
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/6ab58bd2/azure-management/src/test/java/org/jclouds/azure/management/features/LocationApiLiveTest.java
----------------------------------------------------------------------
diff --git a/azure-management/src/test/java/org/jclouds/azure/management/features/LocationApiLiveTest.java b/azure-management/src/test/java/org/jclouds/azure/management/features/LocationApiLiveTest.java
deleted file mode 100644
index 713c9c5..0000000
--- a/azure-management/src/test/java/org/jclouds/azure/management/features/LocationApiLiveTest.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.azure.management.features;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
-
-import java.util.Set;
-
-import org.jclouds.azure.management.domain.Location;
-import org.jclouds.azure.management.internal.BaseAzureManagementApiLiveTest;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-
-@Test(groups = "live", testName = "LocationApiLiveTest")
-public class LocationApiLiveTest extends BaseAzureManagementApiLiveTest {
-
- @Test
- protected void testList() {
- Set<Location> response = api().list();
-
- for (Location location : response) {
- checkLocation(location);
- }
-
- }
-
- protected Predicate<String> knownServices = Predicates.in(ImmutableSet.of("Compute", "Storage", "PersistentVMRole"));
-
- private void checkLocation(Location location) {
- checkNotNull(location.getName(), "Name cannot be null for a Location.");
- checkNotNull(location.getDisplayName(), "DisplayName cannot be null for Location %s", location.getName());
- checkNotNull(location.getAvailableServices(), "AvailableServices cannot be null for Location %s",
- location.getName());
- checkState(Iterables.all(location.getAvailableServices(), knownServices),
- "AvailableServices in Location %s didn't match %s: %s", location.getName(), knownServices,
- location.getAvailableServices());
- }
-
- protected LocationApi api() {
- return context.getApi().getLocationApi();
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/6ab58bd2/azure-management/src/test/java/org/jclouds/azure/management/features/OSImageApiExpectTest.java
----------------------------------------------------------------------
diff --git a/azure-management/src/test/java/org/jclouds/azure/management/features/OSImageApiExpectTest.java b/azure-management/src/test/java/org/jclouds/azure/management/features/OSImageApiExpectTest.java
deleted file mode 100644
index 0b3e849..0000000
--- a/azure-management/src/test/java/org/jclouds/azure/management/features/OSImageApiExpectTest.java
+++ /dev/null
@@ -1,115 +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.azure.management.features;
-
-import static org.testng.Assert.assertEquals;
-
-import java.net.URI;
-
-import org.jclouds.azure.management.AzureManagementApi;
-import org.jclouds.azure.management.domain.OSImageParams;
-import org.jclouds.azure.management.domain.OSType;
-import org.jclouds.azure.management.internal.BaseAzureManagementApiExpectTest;
-import org.jclouds.azure.management.parse.ListOSImagesTest;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpResponse;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableSet;
-
-@Test(groups = "unit", testName = "OSImageApiExpectTest")
-public class OSImageApiExpectTest extends BaseAzureManagementApiExpectTest {
-
- private static final String IMAGE_NAME = "myimage";
-
- HttpRequest list = HttpRequest.builder().method("GET")
- .endpoint("https://management.core.windows.net/" + subscriptionId + "/services/images")
- .addHeader("x-ms-version", "2012-03-01")
- .addHeader("Accept", "application/xml").build();
-
- public void testListWhenResponseIs2xx() throws Exception {
-
- HttpResponse listResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResourceWithContentType("/images.xml", "application/xml")).build();
-
- AzureManagementApi apiWhenExist = requestSendsResponse(
- list, listResponse);
-
- assertEquals(apiWhenExist.getOSImageApi().list().toString(), new ListOSImagesTest().expected().toString());
- }
-
- public void testListWhenResponseIs404() throws Exception {
-
- HttpResponse listResponse = HttpResponse.builder().statusCode(404).build();
-
- AzureManagementApi apiWhenDontExist = requestSendsResponse(
- list, listResponse);
-
- assertEquals(apiWhenDontExist.getOSImageApi().list(), ImmutableSet.of());
- }
-
- HttpRequest add = HttpRequest.builder().method("POST")
- .endpoint("https://management.core.windows.net/" + subscriptionId + "/services/images")
- .addHeader("x-ms-version", "2012-03-01")
- .payload(payloadFromResourceWithContentType("/imageparams.xml", "application/xml")).build();
-
- public void testAddWhenResponseIs2xx() throws Exception {
- HttpResponse addResponse = HttpResponse.builder().statusCode(200).build();
-
- AzureManagementApi apiWhenExist = requestSendsResponse(add, addResponse);
-
- OSImageParams params = OSImageParams.builder().name(IMAGE_NAME).label("foo").os(OSType.LINUX)
- .mediaLink(URI.create("http://example.blob.core.windows.net/disks/mydisk.vhd")).build();
- apiWhenExist.getOSImageApi().add(params);
- }
-
- HttpRequest update = HttpRequest.builder().method("PUT")
- .endpoint("https://management.core.windows.net/" + subscriptionId + "/services/images/" + IMAGE_NAME)
- .addHeader("x-ms-version", "2012-03-01")
- .payload(payloadFromResourceWithContentType("/imageparams.xml", "application/xml")).build();
-
- public void testUpdateWhenResponseIs2xx() throws Exception {
- HttpResponse updateResponse = HttpResponse.builder().statusCode(200).build();
-
- AzureManagementApi apiWhenExist = requestSendsResponse(update, updateResponse);
-
- OSImageParams params = OSImageParams.builder().name(IMAGE_NAME).label("foo").os(OSType.LINUX)
- .mediaLink(URI.create("http://example.blob.core.windows.net/disks/mydisk.vhd")).build();
- apiWhenExist.getOSImageApi().update(params);
- }
-
- HttpRequest delete = HttpRequest.builder().method("DELETE")
- .endpoint("https://management.core.windows.net/" + subscriptionId + "/services/images/" + IMAGE_NAME)
- .addHeader("x-ms-version", "2012-03-01")
- .build();
-
- public void testDeleteWhenResponseIs2xx() throws Exception {
- HttpResponse deleteResponse = HttpResponse.builder().statusCode(200).build();
-
- AzureManagementApi apiWhenExist = requestSendsResponse(delete, deleteResponse);
-
- apiWhenExist.getOSImageApi().delete(IMAGE_NAME);
- }
-
- public void testDeleteWhenResponseIs404() throws Exception {
- HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build();
-
- AzureManagementApi apiWhenDontExist = requestSendsResponse(delete, deleteResponse);
-
- apiWhenDontExist.getOSImageApi().delete(IMAGE_NAME);
- }
-}