You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by na...@apache.org on 2018/01/08 14:55:52 UTC
[11/21] jclouds-labs git commit: Promoted Azure ARM to the main repo
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/compute/extensions/AzureComputeSecurityGroupExtensionLiveTest.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/compute/extensions/AzureComputeSecurityGroupExtensionLiveTest.java b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/compute/extensions/AzureComputeSecurityGroupExtensionLiveTest.java
deleted file mode 100644
index 153df29..0000000
--- a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/compute/extensions/AzureComputeSecurityGroupExtensionLiveTest.java
+++ /dev/null
@@ -1,177 +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.arm.compute.extensions;
-
-import static com.google.common.collect.Iterables.get;
-import static com.google.common.collect.Iterables.getOnlyElement;
-import static org.jclouds.azurecompute.arm.compute.options.AzureTemplateOptions.Builder.resourceGroup;
-import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.TIMEOUT_RESOURCE_DELETED;
-import static org.jclouds.compute.predicates.NodePredicates.inGroup;
-import static org.jclouds.net.domain.IpProtocol.TCP;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
-
-import java.net.URI;
-import java.util.Properties;
-import java.util.Set;
-import java.util.concurrent.ExecutionException;
-
-import org.jclouds.azurecompute.arm.AzureComputeApi;
-import org.jclouds.azurecompute.arm.AzureComputeProviderMetadata;
-import org.jclouds.azurecompute.arm.compute.options.AzureTemplateOptions;
-import org.jclouds.azurecompute.arm.internal.AzureLiveTestUtils;
-import org.jclouds.compute.ComputeService;
-import org.jclouds.compute.RunNodesException;
-import org.jclouds.compute.domain.NodeMetadata;
-import org.jclouds.compute.domain.SecurityGroup;
-import org.jclouds.compute.domain.Template;
-import org.jclouds.compute.extensions.SecurityGroupExtension;
-import org.jclouds.compute.extensions.internal.BaseSecurityGroupExtensionLiveTest;
-import org.jclouds.domain.Location;
-import org.jclouds.net.domain.IpPermission;
-import org.jclouds.net.util.IpPermissions;
-import org.jclouds.providers.ProviderMetadata;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Optional;
-import com.google.common.base.Predicate;
-import com.google.inject.Key;
-import com.google.inject.TypeLiteral;
-import com.google.inject.name.Names;
-
-/**
- * Live test for AzureCompute
- * {@link org.jclouds.compute.extensions.SecurityGroupExtension} implementation.
- */
-@Test(groups = "live", singleThreaded = true, testName = "AzureComputeSecurityGroupExtensionLiveTest")
-public class AzureComputeSecurityGroupExtensionLiveTest extends BaseSecurityGroupExtensionLiveTest {
-
- private Predicate<URI> resourceDeleted;
- private String resourceGroupName;
-
- public AzureComputeSecurityGroupExtensionLiveTest() {
- provider = "azurecompute-arm";
- resourceGroupName = "sgelivetest";
- }
-
- @BeforeClass(groups = { "integration", "live" })
- public void setupContext() {
- super.setupContext();
- resourceDeleted = context.utils().injector().getInstance(Key.get(new TypeLiteral<Predicate<URI>>() {
- }, Names.named(TIMEOUT_RESOURCE_DELETED)));
- createResourceGroup(resourceGroupName);
- }
-
- @Test(groups = { "integration", "live" }, singleThreaded = true, dependsOnMethods = "testAddIpPermissionsFromSpec")
- public void testAddIpPermissionForAnyProtocol() {
- ComputeService computeService = view.getComputeService();
- Optional<SecurityGroupExtension> securityGroupExtension = computeService.getSecurityGroupExtension();
- assertTrue(securityGroupExtension.isPresent(), "security group extension was not present");
-
- SecurityGroup group = securityGroupExtension.get().getSecurityGroupById(groupId);
- assertNotNull(group, "No security group was found with id: " + groupId);
-
- IpPermission openAll = IpPermissions.permitAnyProtocol();
- SecurityGroup allOpenSecurityGroup = securityGroupExtension.get().addIpPermission(openAll, group);
-
- assertTrue(allOpenSecurityGroup.getIpPermissions().contains(openAll));
- }
-
- @Test(groups = { "integration", "live" }, dependsOnMethods = "testCreateSecurityGroup")
- public void testCreateNodeWithSecurityGroup() throws RunNodesException, InterruptedException, ExecutionException {
- ComputeService computeService = view.getComputeService();
- Optional<SecurityGroupExtension> securityGroupExtension = computeService.getSecurityGroupExtension();
- assertTrue(securityGroupExtension.isPresent(), "security group extension was not present");
-
- NodeMetadata node = getOnlyElement(computeService.createNodesInGroup(nodeGroup, 1,
- options().securityGroups(groupId)));
-
- try {
- Set<SecurityGroup> groups = securityGroupExtension.get().listSecurityGroupsForNode(node.getId());
- assertEquals(groups.size(), 1, "node has " + groups.size() + " groups");
- assertEquals(getOnlyElement(groups).getId(), groupId);
- } finally {
- computeService.destroyNodesMatching(inGroup(node.getGroup()));
- }
- }
-
- @Test(groups = { "integration", "live" }, dependsOnMethods = "testCreateSecurityGroup")
- public void testCreateNodeWithInboundPorts() throws RunNodesException, InterruptedException, ExecutionException {
- ComputeService computeService = view.getComputeService();
- Optional<SecurityGroupExtension> securityGroupExtension = computeService.getSecurityGroupExtension();
- assertTrue(securityGroupExtension.isPresent(), "security group extension was not present");
-
- NodeMetadata node = getOnlyElement(computeService.createNodesInGroup(nodeGroup, 1,
- options().inboundPorts(22, 23, 24, 8000)));
-
- try {
- Set<SecurityGroup> groups = securityGroupExtension.get().listSecurityGroupsForNode(node.getId());
- assertEquals(groups.size(), 1, "node has " + groups.size() + " groups");
-
- SecurityGroup group = getOnlyElement(groups);
- assertEquals(group.getIpPermissions().size(), 2);
- assertEquals(get(group.getIpPermissions(), 0), IpPermissions.permit(TCP).fromPort(22).to(24));
- assertEquals(get(group.getIpPermissions(), 1), IpPermissions.permit(TCP).port(8000));
- } finally {
- computeService.destroyNodesMatching(inGroup(node.getGroup()));
- }
- }
-
- @AfterClass(groups = { "integration", "live" })
- @Override
- protected void tearDownContext() {
- try {
- URI uri = view.unwrapApi(AzureComputeApi.class).getResourceGroupApi().delete(resourceGroupName);
- if (uri != null) {
- assertTrue(resourceDeleted.apply(uri),
- String.format("Resource %s was not terminated in the configured timeout", uri));
- }
- } finally {
- super.tearDownContext();
- }
- }
-
- @Override
- protected Properties setupProperties() {
- Properties properties = super.setupProperties();
- AzureLiveTestUtils.defaultProperties(properties);
- setIfTestSystemPropertyPresent(properties, "oauth.endpoint");
- return properties;
- }
-
- @Override
- protected ProviderMetadata createProviderMetadata() {
- return AzureComputeProviderMetadata.builder().build();
- }
-
- private AzureTemplateOptions options() {
- return resourceGroup(resourceGroupName);
- }
-
- @Override
- public Template getNodeTemplate() {
- return view.getComputeService().templateBuilder().options(options()).build();
- }
-
- private void createResourceGroup(String name) {
- Location location = getNodeTemplate().getLocation();
- view.unwrapApi(AzureComputeApi.class).getResourceGroupApi().create(name, location.getId(), null);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/compute/strategy/CreateResourcesThenCreateNodesTest.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/compute/strategy/CreateResourcesThenCreateNodesTest.java b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/compute/strategy/CreateResourcesThenCreateNodesTest.java
deleted file mode 100644
index 45c56a3..0000000
--- a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/compute/strategy/CreateResourcesThenCreateNodesTest.java
+++ /dev/null
@@ -1,116 +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.arm.compute.strategy;
-
-import org.jclouds.azurecompute.arm.AzureComputeApi;
-import org.jclouds.azurecompute.arm.compute.options.AzureTemplateOptions;
-import org.jclouds.azurecompute.arm.compute.options.IpOptions;
-import org.jclouds.azurecompute.arm.domain.PublicIPAddress;
-import org.jclouds.azurecompute.arm.domain.PublicIPAddressProperties;
-import org.jclouds.azurecompute.arm.domain.Subnet;
-import org.jclouds.azurecompute.arm.features.PublicIPAddressApi;
-import org.jclouds.azurecompute.arm.features.SubnetApi;
-import org.jclouds.util.PasswordGenerator;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-
-import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-import static org.testng.Assert.assertEquals;
-
-@Test(groups = "unit", testName = "CreateResourcesThenCreateNodesTest")
-public class CreateResourcesThenCreateNodesTest {
-
- @Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "The options.networks and options.ipOptions are exclusive")
- public void testNormalizeNetworkOptionsWithConflictingConfig() {
- AzureTemplateOptions options = new AzureTemplateOptions();
- options.ipOptions(IpOptions.builder().subnet(netResource("/virtualNetworks/vn/subnets/foo")).build());
- options.networks(netResource("/virtualNetworks/vn/subnets/bar"));
- strategy(null).normalizeNetworkOptions(options);
- }
-
- @Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "The allocateNewPublicIps and publicIpId are exclusive")
- public void testNormalizeNetworkOptionsExclusivePublicIps() {
- AzureTemplateOptions options = new AzureTemplateOptions();
- options.ipOptions(IpOptions.builder().subnet(netResource("/virtualNetworks/vn/subnets/foo"))
- .allocateNewPublicIp(true).publicIpId(netResource("/publicIPAddresses/pub")).build());
- strategy(null).normalizeNetworkOptions(options);
- }
-
- public void testPortableNetworkOptions() {
- AzureComputeApi api = createMock(AzureComputeApi.class);
- SubnetApi subnetApi = createMock(SubnetApi.class);
-
- expect(api.getSubnetApi(anyObject(String.class), anyObject(String.class))).andReturn(subnetApi).times(2);
- expect(subnetApi.get(anyObject(String.class))).andReturn(Subnet.builder().build()).times(2);
- replay(api, subnetApi);
-
- AzureTemplateOptions options = new AzureTemplateOptions();
- options.networks(netResource("/virtualNetworks/vn/subnets/foo"), netResource("/virtualNetworks/vn/subnets/bar"));
- strategy(api).normalizeNetworkOptions(options);
-
- assertEquals(options.getIpOptions(), ImmutableList.of(
- IpOptions.builder().subnet(netResource("/virtualNetworks/vn/subnets/foo")).allocateNewPublicIp(true).build(),
- IpOptions.builder().subnet(netResource("/virtualNetworks/vn/subnets/bar")).allocateNewPublicIp(true).build())
- );
-
- // Verify that the code has validated that the subnets exist
- verify(api, subnetApi);
- }
-
- public void testProviderSpecificNetworkOptions() {
- AzureComputeApi api = createMock(AzureComputeApi.class);
- SubnetApi subnetApi = createMock(SubnetApi.class);
- PublicIPAddressApi publicIpApi = createMock(PublicIPAddressApi.class);
-
- expect(api.getSubnetApi(anyObject(String.class), anyObject(String.class))).andReturn(subnetApi).times(2);
- expect(api.getPublicIPAddressApi(anyObject(String.class))).andReturn(publicIpApi);
- expect(subnetApi.get(anyObject(String.class))).andReturn(Subnet.builder().build()).times(2);
- expect(publicIpApi.get(anyObject(String.class))).andReturn(mockAddress());
- replay(api, subnetApi, publicIpApi);
-
- IpOptions publicOpts = IpOptions.builder().subnet(netResource("/virtualNetworks/vn/subnets/foo"))
- .publicIpId(netResource("/publicIPAddresses/pub")).address("10.0.0.2").build();
- IpOptions privateOpts = IpOptions.builder().subnet(netResource("/virtualNetworks/vn/subnets/bar")).build();
-
- AzureTemplateOptions options = new AzureTemplateOptions();
- options.ipOptions(publicOpts, privateOpts);
- strategy(api).normalizeNetworkOptions(options);
-
- assertEquals(options.getIpOptions(), ImmutableList.of(publicOpts, privateOpts));
-
- // Verify that the code has validated that the subnets exist
- verify(api, subnetApi, publicIpApi);
- }
-
- private static CreateResourcesThenCreateNodes strategy(AzureComputeApi api) {
- return new CreateResourcesThenCreateNodes(null, null, null, null, null, api, null, null, null, null, new PasswordGenerator().lower());
- }
-
- private static String netResource(String resource) {
- return "/subscriptions/subs/resourceGroups/rg/providers/Microsoft.Network" + resource;
- }
-
- private static PublicIPAddress mockAddress() {
- return PublicIPAddress.builder().name("name").id("id").etag("etag").location("location")
- .properties(PublicIPAddressProperties.builder().publicIPAllocationMethod("Dynamic").build()).build();
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/config/ParseTenantIdTest.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/config/ParseTenantIdTest.java b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/config/ParseTenantIdTest.java
deleted file mode 100644
index 5894505..0000000
--- a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/config/ParseTenantIdTest.java
+++ /dev/null
@@ -1,50 +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.arm.config;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.fail;
-
-import org.testng.annotations.Test;
-
-@Test(groups = "unit", testName = "ParseTenantIdTest")
-public class ParseTenantIdTest {
-
- @Test
- public void testParseTenantId() {
- AzureComputeHttpApiModule module = new AzureComputeHttpApiModule();
-
- assertEquals(module.provideTenant("https://login.microsoftonline.com/tenantId/oauth2/token"), "tenantId");
- assertEquals(module.provideTenant("https://login.microsoft.com/tenant2/oauth2/token"), "tenant2");
-
- assertInvalid(module, "https://login.microsoftonline.com/a/b/c/oauth2/token");
- assertInvalid(module, "https://login.microsoft.com/a/b/c/oauth2/token");
- assertInvalid(module, "https://login.microsoftonline.com//oauth2/token");
- assertInvalid(module, "https://login.microsoft.com//oauth2/token");
- assertInvalid(module, "https://login.microsoftabc.com/tenant/oauth2/token");
- }
-
- private static void assertInvalid(AzureComputeHttpApiModule module, String endpoint) {
- try {
- module.provideTenant(endpoint);
- fail("Expected an IllegalArgumentException for endpoint: " + endpoint);
- } catch (IllegalArgumentException ex) {
- assertEquals(ex.getMessage(), "Could not parse tenantId from: " + endpoint);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/domain/IdReferenceTest.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/domain/IdReferenceTest.java b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/domain/IdReferenceTest.java
deleted file mode 100644
index e2a56e1..0000000
--- a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/domain/IdReferenceTest.java
+++ /dev/null
@@ -1,63 +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.arm.domain;
-
-import static org.jclouds.azurecompute.arm.domain.IdReference.extractName;
-import static org.jclouds.azurecompute.arm.domain.IdReference.extractResourceGroup;
-import static org.testng.Assert.assertEquals;
-
-import org.testng.annotations.Test;
-
-@Test(groups = "unit", testName = "IdReferenceTest")
-public class IdReferenceTest {
-
- @Test
- public void testExtractResourceGroup() {
- assertEquals(extractResourceGroup(null), null);
- assertEquals(extractResourceGroup(""), null);
- assertEquals(
- extractResourceGroup("/subscriptions/subscription/resourceGroups/jclouds-northeurope/providers/Microsoft.Compute/virtualMachines/resources-8c5"),
- "jclouds-northeurope");
- assertEquals(extractResourceGroup("/subscriptions/subscription/resourceGroups/jclouds-west"), "jclouds-west");
- assertEquals(extractResourceGroup("/resourceGroups/jclouds-west2"), "jclouds-west2");
- assertEquals(
- extractResourceGroup("/resourceGroups/jclouds-northeurope2/providers/Microsoft.Compute/virtualMachines/resources-8c5"),
- "jclouds-northeurope2");
- assertEquals(extractResourceGroup("resourceGroups/jclouds-west2"), null);
- assertEquals(
- extractResourceGroup("resourceGroups/jclouds-northeurope2/providers/Microsoft.Compute/virtualMachines/resources-8c5"),
- null);
- assertEquals(
- extractResourceGroup("/subscriptions/subscription/providers/Microsoft.Compute/virtualMachines/resources-8c5"),
- null);
- assertEquals(
- extractResourceGroup("/subscriptions/subscription/resourceGroups//jclouds-northeurope/providers/Microsoft.Compute/virtualMachines/resources-8c5"),
- null);
- }
-
- @Test
- public void testExtractName() {
- assertEquals(extractName(null), null);
- assertEquals(extractName(""), "");
- assertEquals(extractName("foo"), "foo");
- assertEquals(extractName("/foo/bar"), "bar");
- assertEquals(extractName("/foo/bar/"), "bar");
- assertEquals(extractName("/foo/bar////"), "bar");
- assertEquals(extractName("/foo///bar////"), "bar");
- assertEquals(extractName("////bar"), "bar");
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/domain/SubnetTest.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/domain/SubnetTest.java b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/domain/SubnetTest.java
deleted file mode 100644
index a5ef44c..0000000
--- a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/domain/SubnetTest.java
+++ /dev/null
@@ -1,47 +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.arm.domain;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.fail;
-
-import org.testng.annotations.Test;
-
-@Test(groups = "unit", testName = "SubnetTest")
-public class SubnetTest {
-
- @Test
- public void testExtractVirtualNetwork() {
-
- assertEquals(Subnet.builder().build().virtualNetwork(), null);
- assertEquals(
- Subnet.builder()
- .id("/subscriptions/subscription/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vn/subnets/subnet")
- .build().virtualNetwork(), "vn");
- assertInvalidId("/subscriptions/subscription/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks");
- assertInvalidId("virtualNetworks/vn");
- }
-
- private static void assertInvalidId(String id) {
- try {
- Subnet.builder().id(id).build().virtualNetwork();
- fail("The given ID " + id + "should not match a valid virtual network");
- } catch (IllegalStateException ex) {
- // Expected
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/AvailabilitySetApiLiveTest.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/AvailabilitySetApiLiveTest.java b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/AvailabilitySetApiLiveTest.java
deleted file mode 100644
index 2b9e30a..0000000
--- a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/AvailabilitySetApiLiveTest.java
+++ /dev/null
@@ -1,105 +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.arm.features;
-
-import static com.google.common.collect.Iterables.any;
-import static org.jclouds.azurecompute.arm.domain.AvailabilitySet.AvailabilitySetType.MANAGED;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertTrue;
-
-import java.net.URI;
-import java.util.UUID;
-
-import org.jclouds.azurecompute.arm.domain.AvailabilitySet;
-import org.jclouds.azurecompute.arm.domain.AvailabilitySet.AvailabilitySetProperties;
-import org.jclouds.azurecompute.arm.domain.AvailabilitySet.SKU;
-import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiLiveTest;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Predicate;
-import com.google.common.collect.ImmutableMap;
-
-@Test(groups = "live", testName = "AvailabilitySetApiLiveTest", singleThreaded = true)
-public class AvailabilitySetApiLiveTest extends BaseAzureComputeApiLiveTest {
-
- private String asName;
-
- @BeforeClass
- @Override
- public void setup() {
- super.setup();
- createTestResourceGroup();
- asName = "jclouds-" + RAND;
- }
-
- @Test
- public void deleteAvailabilitySetDoesNotExist() {
- assertNull(api().delete(UUID.randomUUID().toString()));
- }
-
- @Test
- public void createAvailabilitySet() {
- AvailabilitySetProperties props = AvailabilitySetProperties.builder().platformUpdateDomainCount(2)
- .platformFaultDomainCount(3).build();
- AvailabilitySet as = api().createOrUpdate(asName, SKU.create(MANAGED), LOCATION, null, props);
-
- assertNotNull(as);
- assertEquals(as.name(), asName);
-
- assertNotNull(as.sku());
- assertEquals(as.sku().type(), MANAGED);
- }
-
- @Test(dependsOnMethods = "createAvailabilitySet")
- public void getAvailabilitySet() {
- assertNotNull(api().get(asName));
- }
-
- @Test(dependsOnMethods = "createAvailabilitySet")
- public void listAvailabilitySet() {
- assertTrue(any(api().list(), new Predicate<AvailabilitySet>() {
- @Override
- public boolean apply(AvailabilitySet input) {
- return asName.equals(input.name());
- }
- }));
- }
-
- @Test(dependsOnMethods = "createAvailabilitySet")
- public void updateAvailabilitySet() {
- AvailabilitySet as = api().get(asName);
- as = api().createOrUpdate(asName, SKU.create(MANAGED), LOCATION, ImmutableMap.of("foo", "bar"), as.properties());
-
- assertNotNull(as);
- assertTrue(as.tags().containsKey("foo"));
- assertEquals(as.tags().get("foo"), "bar");
- }
-
- @Test(dependsOnMethods = { "getAvailabilitySet", "listAvailabilitySet", "updateAvailabilitySet" })
- public void deleteAvailabilitySet() {
- URI uri = api().delete(asName);
- assertResourceDeleted(uri);
- }
-
- private AvailabilitySetApi api() {
- return api.getAvailabilitySetApi(resourceGroupName);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/AvailabilitySetApiMockTest.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/AvailabilitySetApiMockTest.java b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/AvailabilitySetApiMockTest.java
deleted file mode 100644
index 430c32f..0000000
--- a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/AvailabilitySetApiMockTest.java
+++ /dev/null
@@ -1,155 +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.arm.features;
-
-import static com.google.common.collect.Iterables.isEmpty;
-import static org.jclouds.azurecompute.arm.domain.AvailabilitySet.AvailabilitySetType.MANAGED;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertTrue;
-
-import java.net.URI;
-import java.util.List;
-
-import org.jclouds.azurecompute.arm.domain.AvailabilitySet;
-import org.jclouds.azurecompute.arm.domain.AvailabilitySet.AvailabilitySetProperties;
-import org.jclouds.azurecompute.arm.domain.AvailabilitySet.SKU;
-import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiMockTest;
-import org.testng.annotations.Test;
-
-@Test(groups = "unit", testName = "AvailabilitySetApiMockTest", singleThreaded = true)
-public class AvailabilitySetApiMockTest extends BaseAzureComputeApiMockTest {
-
- private final String subscriptionid = "SUBSCRIPTIONID";
- private final String resourcegroup = "myresourcegroup";
- private final String asName = "myas";
- private final String apiVersion = "api-version=2016-04-30-preview";
-
- public void createAvailabilitySet() throws InterruptedException {
-
- server.enqueue(jsonResponse("/availabilitysetcreate.json").setResponseCode(200));
-
- AvailabilitySetApi asApi = api.getAvailabilitySetApi(resourcegroup);
-
- AvailabilitySetProperties props = AvailabilitySetProperties.builder().platformUpdateDomainCount(2)
- .platformFaultDomainCount(3).build();
- AvailabilitySet as = asApi.createOrUpdate(asName, SKU.create(MANAGED), "westeurope", null, props);
-
- String path = String.format(
- "/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Compute/availabilitySets/%s?%s", subscriptionid,
- resourcegroup, asName, apiVersion);
- String json = "{\"location\":\"westeurope\",\"properties\":{\"platformUpdateDomainCount\":2,\"platformFaultDomainCount\":3},\"sku\":{\"name\":\"Aligned\"}}";
- assertSent(server, "PUT", path, json);
-
- assertEquals(as.name(), asName);
- assertEquals(as.properties().platformUpdateDomainCount(), 2);
- assertEquals(as.properties().platformFaultDomainCount(), 3);
- }
-
- public void getAvailabilitySet() throws InterruptedException {
-
- server.enqueue(jsonResponse("/availabilitysetget.json").setResponseCode(200));
-
- AvailabilitySetApi asApi = api.getAvailabilitySetApi(resourcegroup);
-
- AvailabilitySet as = asApi.get(asName);
-
- String path = String.format(
- "/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Compute/availabilitySets/%s?%s", subscriptionid,
- resourcegroup, asName, apiVersion);
- assertSent(server, "GET", path);
-
- assertEquals(as.name(), asName);
- }
-
- public void getAvailabilitySet404() throws InterruptedException {
- server.enqueue(response404());
-
- AvailabilitySetApi asApi = api.getAvailabilitySetApi(resourcegroup);
-
- AvailabilitySet as = asApi.get(asName);
-
- String path = String.format(
- "/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Compute/availabilitySets/%s?%s", subscriptionid,
- resourcegroup, asName, apiVersion);
- assertSent(server, "GET", path);
-
- assertNull(as);
- }
-
- public void listAvailabilitySets() throws InterruptedException {
-
- server.enqueue(jsonResponse("/availabilitysetlist.json").setResponseCode(200));
-
- AvailabilitySetApi asApi = api.getAvailabilitySetApi(resourcegroup);
-
- List<AvailabilitySet> asList = asApi.list();
-
- String path = String.format(
- "/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Compute/availabilitySets?%s", subscriptionid,
- resourcegroup, apiVersion);
- assertSent(server, "GET", path);
-
- assertTrue(asList.size() > 0);
- }
-
- public void listAvailabilitySets404() throws InterruptedException {
- server.enqueue(response404());
-
- AvailabilitySetApi asApi = api.getAvailabilitySetApi(resourcegroup);
-
- List<AvailabilitySet> asList = asApi.list();
-
- String path = String.format(
- "/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Compute/availabilitySets?%s", subscriptionid,
- resourcegroup, apiVersion);
- assertSent(server, "GET", path);
-
- assertTrue(isEmpty(asList));
- }
-
- public void deleteAvailabilitySet() throws InterruptedException {
-
- server.enqueue(response202WithHeader());
-
- AvailabilitySetApi asApi = api.getAvailabilitySetApi(resourcegroup);
-
- URI uri = asApi.delete(asName);
- assertNotNull(uri);
-
- String path = String.format(
- "/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Compute/availabilitySets/%s?%s", subscriptionid,
- resourcegroup, asName, apiVersion);
- assertSent(server, "DELETE", path);
- }
-
- public void deleteSubnetResourceDoesNotExist() throws InterruptedException {
-
- server.enqueue(response204());
-
- AvailabilitySetApi asApi = api.getAvailabilitySetApi(resourcegroup);
-
- URI uri = asApi.delete(asName);
- assertNull(uri);
-
- String path = String.format(
- "/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Compute/availabilitySets/%s?%s", subscriptionid,
- resourcegroup, asName, apiVersion);
- assertSent(server, "DELETE", path);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/DeploymentApiLiveTest.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/DeploymentApiLiveTest.java b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/DeploymentApiLiveTest.java
deleted file mode 100644
index 0b9ab05..0000000
--- a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/DeploymentApiLiveTest.java
+++ /dev/null
@@ -1,156 +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.arm.features;
-
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertTrue;
-
-import java.net.URI;
-import java.util.List;
-
-import org.jclouds.azurecompute.arm.domain.Deployment;
-import org.jclouds.azurecompute.arm.domain.Deployment.ProvisioningState;
-import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiLiveTest;
-import org.jclouds.util.Predicates2;
-import org.testng.Assert;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Predicate;
-import com.google.common.net.UrlEscapers;
-
-@Test(groups = "live", testName = "DeploymentApiLiveTest", singleThreaded = true)
-public class DeploymentApiLiveTest extends BaseAzureComputeApiLiveTest {
-
- private String deploymentName;
- private String properties;
- private String badProperties;
-
- @BeforeClass
- @Override
- public void setup() {
- super.setup();
- createTestResourceGroup();
- deploymentName = "jc" + System.currentTimeMillis();
- String storageAccountName = String.format("st%s%s", System.getProperty("user.name"), RAND);
-
- String rawtemplate = "{\"$schema\":\"https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#\",\"contentVersion\":\"1.0.0.0\",\"parameters\":{\"newStorageAccountName\":{\"type\":\"string\",\"metadata\":{\"description\":\"Name of the Storage Account\"}},\"storageAccountType\":{\"type\":\"string\",\"defaultValue\":\"Standard_LRS\",\"allowedValues\":[\"Standard_LRS\",\"Standard_GRS\",\"Standard_ZRS\"],\"metadata\":{\"description\":\"Storage Account type\"}},\"location\":{\"type\":\"string\",\"allowedValues\":[\"East US\",\"West US\",\"West Europe\",\"East Asia\",\"Southeast Asia\"],\"metadata\":{\"description\":\"Location of storage account\"}}},\"resources\":[{\"type\":\"Microsoft.Storage/storageAccounts\",\"name\":\"[parameters('newStorageAccountName')]\",\"apiVersion\":\"2015-05-01-preview\",\"location\":\"[parameters('location')]\",\"properties\":{\"accountType\":\"[parameters('storageAccountType')]\"}}]}";
- String rawparameters = "{\"newStorageAccountName\":{\"value\":\"" + storageAccountName + "\"},\"storageAccountType\":{\"value\":\"Standard_LRS\"},\"location\":{\"value\":\"West US\"}}";
- String rawbadParameters = "{\"newStorageAccountName\":{\"value\":\"" + storageAccountName + "\"},\"storageAccountType\":{\"value\":\"Standard_LRS\"},\"location\":{\"value\":\"West\"}}";
-
- properties = getPutBody(rawtemplate, "Incremental", rawparameters);
- badProperties = getPutBody(rawtemplate, "Incremental", rawbadParameters);
- }
-
- private String getPutBody(String template, String mode, String parameters) {
- String body = "{ " +
- "\"properties\" : " +
- " { " +
- " \"template\" : " + template + ", " +
- " \"mode\" : \"" + mode + "\", " +
- " \"parameters\" : " + parameters + " " +
- " } " +
- "}";
- return body;
- }
-
- @Test
- public void testValidate(){
- Deployment deploymentInvalid = null;
- try {
- deploymentInvalid = api().validate(deploymentName + "invalid", badProperties);
- } catch (Exception ex) {
- assertTrue(ex.getClass() == java.lang.IllegalArgumentException.class);
- }
- assertNull(deploymentInvalid);
-
- Deployment deploymentValid = null;
- try {
- deploymentValid = api().validate(deploymentName + "valid", properties);
- } catch (Exception ex) {
- assertTrue(ex.getClass() == java.lang.IllegalArgumentException.class);
- }
- assertNotNull(deploymentValid);
- }
-
- @Test(dependsOnMethods = "testValidate")
- public void testCreate() {
- String deploymentTemplate = UrlEscapers.urlFormParameterEscaper().escape(properties);
-
- Deployment deploymentValid = api().validate(deploymentName, deploymentTemplate);
- assertNotNull(deploymentValid);
-
- Deployment deployment = api().create(deploymentName, deploymentTemplate);
- assertNotNull(deployment);
-
- //Poll until resource is ready to be used
- boolean jobDone = Predicates2.retry(new Predicate<String>() {
- @Override
- public boolean apply(String name) {
- Deployment dp = api().get(deploymentName);
- ProvisioningState state = ProvisioningState.fromValue(dp.properties().provisioningState());
- if (state == ProvisioningState.FAILED) Assert.fail();
- return state == ProvisioningState.SUCCEEDED;
- }
- }, 60 * 20 * 1000).apply(deploymentName);
- assertTrue(jobDone, "create operation did not complete in the configured timeout");
-
- Deployment dp = api().get(deploymentName);
- ProvisioningState state = ProvisioningState.fromValue(dp.properties().provisioningState());
- assertTrue(state == ProvisioningState.SUCCEEDED);
- }
-
-
- @Test(dependsOnMethods = "testCreate")
- public void testGetDeployment() {
- Deployment deployment = api().get(deploymentName);
- assertNotNull(deployment);
- ProvisioningState state = ProvisioningState.fromValue(deployment.properties().provisioningState());
- assertTrue(state == ProvisioningState.SUCCEEDED);
- }
-
- @Test(dependsOnMethods = "testCreate")
- public void testListDeployments() {
- List<Deployment> deployments = api().list();
- assertTrue(deployments.size() > 0);
- boolean deploymentFound = false;
- for (Deployment d : deployments) {
-
- if (d.name().equals(deploymentName)) {
- deploymentFound = true;
- break;
- }
- }
- assertTrue(deploymentFound);
- }
-
- @Test(dependsOnMethods = {"testGetDeployment", "testListDeployments"})
- public void testDelete() throws Exception {
- List<Deployment> deployments = api().list();
- for (Deployment d : deployments) {
- if (d.name().contains("jc")) {
- URI uri = api().delete(d.name());
- assertResourceDeleted(uri);
- }
- }
- }
-
- private DeploymentApi api() {
- return api.getDeploymentApi(resourceGroupName);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/DeploymentApiMockTest.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/DeploymentApiMockTest.java b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/DeploymentApiMockTest.java
deleted file mode 100644
index 89d6aca..0000000
--- a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/DeploymentApiMockTest.java
+++ /dev/null
@@ -1,154 +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.arm.features;
-
-import org.jclouds.azurecompute.arm.domain.Deployment;
-import org.jclouds.azurecompute.arm.domain.Deployment.ProvisioningState;
-import com.squareup.okhttp.mockwebserver.MockResponse;
-import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiMockTest;
-import org.testng.annotations.Test;
-
-import java.net.URI;
-import java.util.List;
-
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.assertEquals;
-
-@Test(groups = "unit", testName = "DeploymentApiMockTest", singleThreaded = true)
-public class DeploymentApiMockTest extends BaseAzureComputeApiMockTest {
-
- private String subscriptionId = "SUBSCRIPTIONID";
- private String resourceGroup = "resourceGroup";
- private String deploymentName = "jcdep1458344383064";
- private String resourceName = "jcres1458344383064";
-
- private String getPutBody(String template, String mode, String parameters) {
- String body = "{ " +
- "\"properties\" : " +
- " { " +
- " \"template\" : " + template + ", " +
- " \"mode\" : \"" + mode + "\", " +
- " \"parameters\" : " + parameters + " " +
- " } " +
- "}";
- return body;
- }
-
- @Test
- public void testCreateDeployment() throws Exception {
- final DeploymentApi deploymentApi = api.getDeploymentApi(resourceGroup);
-
- // check if deployment accepted
- server.enqueue(jsonResponse("/createdeploymentaccepted.json"));
- String template = "{\"$schema\":\"https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#\",\"contentVersion\":\"1.0.0.0\",\"parameters\":{\"newStorageAccountName\":{\"type\":\"string\",\"metadata\":{\"description\":\"Name of the Storage Account\"}},\"storageAccountType\":{\"type\":\"string\",\"defaultValue\":\"Standard_LRS\",\"allowedValues\":[\"Standard_LRS\",\"Standard_GRS\",\"Standard_ZRS\"],\"metadata\":{\"description\":\"Storage Account type\"}},\"location\":{\"type\":\"string\",\"allowedValues\":[\"East US\",\"West US\",\"West Europe\",\"East Asia\",\"Southeast Asia\"],\"metadata\":{\"description\":\"Location of storage account\"}}},\"resources\":[{\"type\":\"Microsoft.Storage/storageAccounts\",\"name\":\"[parameters('newStorageAccountName')]\",\"apiVersion\":\"2015-05-01-preview\",\"location\":\"[parameters('location')]\",\"properties\":{\"accountType\":\"[parameters('storageAccountType')]\"}}]}";
- String parameters = "{\"newStorageAccountName\":{\"value\":\"" + resourceName + "\"},\"storageAccountType\":{\"value\":\"Standard_LRS\"},\"location\":{\"value\":\"West US\"}}";
- String properties = getPutBody(template, "Incremental", parameters);
- Deployment deployment = deploymentApi.create(deploymentName, properties);
- assertTrue(deployment != null);
- assertEquals(ProvisioningState.fromValue(deployment.properties().provisioningState()), ProvisioningState.ACCEPTED);
-
- // check if deployment succeeded
- server.enqueue(jsonResponse("/createdeploymentsucceeded.json"));
- deployment = deploymentApi.create(deploymentName, properties);
- assertTrue(deployment != null);
- assertEquals(ProvisioningState.fromValue(deployment.properties().provisioningState()), ProvisioningState.SUCCEEDED);
- assertSent(server, "PUT", "/subscriptions/" + subscriptionId + "/resourcegroups/" + resourceGroup +
- "/providers/microsoft.resources/deployments/" + deploymentName + "?api-version=2016-02-01", properties);
- }
-
- @Test
- public void testGetDeployment() throws Exception {
- final DeploymentApi deploymentApi = api.getDeploymentApi(resourceGroup);
-
- // check if deployment succeeded
- server.enqueue(jsonResponse("/createdeploymentsucceeded.json"));
- Deployment deployment = deploymentApi.get(deploymentName);
- assertTrue(deployment != null);
- assertEquals(ProvisioningState.fromValue(deployment.properties().provisioningState()), ProvisioningState.SUCCEEDED);
- assertSent(server, "GET", "/subscriptions/" + subscriptionId + "/resourcegroups/" + resourceGroup +
- "/providers/microsoft.resources/deployments/" + deploymentName + "?api-version=2016-02-01");
- }
-
- @Test
- public void testGetDeploymentEmpty() throws Exception {
- final DeploymentApi deploymentApi = api.getDeploymentApi(resourceGroup);
-
- server.enqueue(new MockResponse().setResponseCode(404));
-
- Deployment deployment = deploymentApi.get(deploymentName);
- assertNull(deployment);
-
- assertSent(server, "GET", "/subscriptions/" + subscriptionId + "/resourcegroups/" + resourceGroup +
- "/providers/microsoft.resources/deployments/" + deploymentName + "?api-version=2016-02-01");
- }
-
- @Test
- public void testListDeployment() throws Exception {
- final DeploymentApi deploymentApi = api.getDeploymentApi(resourceGroup);
-
- // check if deployment succeeded
- server.enqueue(jsonResponse("/listdeployments.json"));
- List<Deployment> deployments = deploymentApi.list();
- assertTrue(deployments.size() > 0);
-
- assertSent(server, "GET", "/subscriptions/" + subscriptionId + "/resourcegroups/" + resourceGroup +
- "/providers/microsoft.resources/deployments?api-version=2016-02-01");
-
- }
-
- @Test
- public void testListDeploymentEmpty() throws Exception {
- final DeploymentApi deploymentApi = api.getDeploymentApi(resourceGroup);
-
- server.enqueue(new MockResponse().setResponseCode(404));
-
- List<Deployment> deployments = deploymentApi.list();
- assertTrue(deployments.size() == 0);
-
- assertSent(server, "GET", "/subscriptions/" + subscriptionId + "/resourcegroups/" + resourceGroup +
- "/providers/microsoft.resources/deployments?api-version=2016-02-01");
-
- }
-
- @Test
- public void testDeleteDeployment() throws InterruptedException {
- final DeploymentApi deploymentApi = api.getDeploymentApi(resourceGroup);
-
- server.enqueue(response202WithHeader());
-
- URI uri = deploymentApi.delete(deploymentName);
- assertNotNull(uri);
-
- assertSent(server, "DELETE", "/subscriptions/" + subscriptionId + "/resourcegroups/" + resourceGroup +
- "/providers/microsoft.resources/deployments/" + deploymentName + "?api-version=2016-02-01");
- }
-
- @Test
- public void testDeleteDeploymentReturns404() throws InterruptedException {
- final DeploymentApi deploymentApi = api.getDeploymentApi(resourceGroup);
-
- server.enqueue(response404());
-
- URI uri = deploymentApi.delete(deploymentName);
- assertNull(uri);
-
- assertSent(server, "DELETE", "/subscriptions/" + subscriptionId + "/resourcegroups/" + resourceGroup +
- "/providers/microsoft.resources/deployments/" + deploymentName + "?api-version=2016-02-01");
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/DiskApiLiveTest.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/DiskApiLiveTest.java b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/DiskApiLiveTest.java
deleted file mode 100644
index f5af885..0000000
--- a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/DiskApiLiveTest.java
+++ /dev/null
@@ -1,107 +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.arm.features;
-
-import java.net.URI;
-import java.util.List;
-import java.util.UUID;
-
-import org.jclouds.azurecompute.arm.domain.CreationData;
-import org.jclouds.azurecompute.arm.domain.Disk;
-import org.jclouds.azurecompute.arm.domain.DiskProperties;
-import org.jclouds.azurecompute.arm.domain.Provisionable;
-import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiLiveTest;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Predicate;
-import com.google.common.base.Supplier;
-import com.google.common.collect.Iterables;
-
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertTrue;
-
-@Test(groups = "live", testName = "DiskApiLiveTest", singleThreaded = true)
-public class DiskApiLiveTest extends BaseAzureComputeApiLiveTest {
-
- public static final String JCLOUDS_DISK_PREFIX = "jclouds-";
- private String diskName;
-
- @BeforeClass
- @Override
- public void setup() {
- super.setup();
- createTestResourceGroup();
- diskName = JCLOUDS_DISK_PREFIX + RAND;
- }
-
- @Test
- public void deleteDiskResourceDoesNotExist() {
- assertNull(api().delete(JCLOUDS_DISK_PREFIX + UUID.randomUUID()));
- }
-
- @Test
- public void createDisk() {
- DiskProperties properties = DiskProperties.builder().creationData(CreationData.create(CreationData.CreateOptions.EMPTY)).diskSizeGB(2).build();
- Disk dataDisk = api().createOrUpdate(diskName, LOCATION, properties);
- assertTrue(waitUntilAvailable(diskName), "creation operation did not complete in the configured timeout");
- assertTrue(dataDisk.properties().diskSizeGB() == 2);
- }
-
- @Test(dependsOnMethods = "createDisk")
- public void getDisk() {
- Disk dataDisk = api().get(diskName);
- assertNotNull(dataDisk.name());
- assertTrue(dataDisk.properties().diskSizeGB() == 2);
- }
-
- @Test(dependsOnMethods = "createDisk")
- public void listDisks() {
- List<Disk> dataDisks = api().list();
- assertTrue(dataDisks.size() > 0);
- final Disk dataDisk = api().get(diskName);
-
- assertTrue(Iterables.any(dataDisks, new Predicate<Disk>() {
- @Override
- public boolean apply(Disk input) {
- return dataDisk.equals(input);
- }
- }));
- }
-
- @Test(dependsOnMethods = {"listDisks", "getDisk"}, alwaysRun = true)
- public void deleteDisk() {
- URI uri = api().delete(diskName);
- assertNotNull(uri);
- }
-
- private DiskApi api() {
- return api.getDiskApi(resourceGroupName);
- }
-
- private boolean waitUntilAvailable(final String name) {
- return resourceAvailable.apply(new Supplier<Provisionable>() {
- @Override public Provisionable get() {
- Disk disk = api().get(name);
- return disk == null ? null : disk.properties();
- }
- });
- }
-
-}
-
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/DiskApiMockTest.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/DiskApiMockTest.java b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/DiskApiMockTest.java
deleted file mode 100644
index 4c8ba2e..0000000
--- a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/DiskApiMockTest.java
+++ /dev/null
@@ -1,141 +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.arm.features;
-
-import java.net.URI;
-import java.util.List;
-
-import org.jclouds.azurecompute.arm.domain.CreationData;
-import org.jclouds.azurecompute.arm.domain.Disk;
-import org.jclouds.azurecompute.arm.domain.DiskProperties;
-import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiMockTest;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-import static com.google.common.collect.Iterables.isEmpty;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertTrue;
-
-
-@Test(groups = "unit", testName = "DiskApiMockTest", singleThreaded = true)
-public class DiskApiMockTest extends BaseAzureComputeApiMockTest {
-
- private final String subscriptionid = "SUBSCRIPTIONID";
- private final String resourcegroup = "myresourcegroup";
- private final String diskName = "myDisk";
- private final String apiVersion = "api-version=2017-03-30";
-
- public void createDisk() throws InterruptedException {
-
- server.enqueue(jsonResponse("/creatediskresponse.json").setResponseCode(200));
-
- final DiskApi diskApi = api.getDiskApi(resourcegroup);
-
- DiskProperties properties = DiskProperties.builder().diskSizeGB(2).creationData(CreationData.create(CreationData.CreateOptions.EMPTY)).build();
-
- Disk dataDisk = diskApi.createOrUpdate(diskName, "westus", properties);
-
- String path = String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Compute/disks/%s?%s", subscriptionid, resourcegroup, diskName, apiVersion);
- String json = "{\"location\":\"westus\",\"properties\":{\"diskSizeGB\":2,\"creationData\":{\"createOption\":\"Empty\"}}}";
- assertSent(server, "PUT", path, json);
-
- assertEquals(dataDisk.properties().provisioningState(), "Updating");
- assertTrue(dataDisk.properties().diskSizeGB() == 2);
- }
-
- public void getDisk() throws InterruptedException {
-
- server.enqueue(jsonResponse("/getdisk.json").setResponseCode(200));
-
- final DiskApi diskApi = api.getDiskApi(resourcegroup);
-
- Disk dataDisk = diskApi.get(diskName);
-
- String path = String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Compute/disks/%s?%s", subscriptionid, resourcegroup, diskName, apiVersion);
- assertSent(server, "GET", path);
-
- assertEquals(dataDisk.name(), diskName);
- assertTrue(dataDisk.properties().diskSizeGB() == 2);
- }
-
- public void getDiskReturns404() throws InterruptedException {
- server.enqueue(response404());
-
- final DiskApi diskApi = api.getDiskApi(resourcegroup);
-
- Disk dataDisk = diskApi.get(diskName);
-
- String path = String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Compute/disks/%s?%s", subscriptionid, resourcegroup, diskName, apiVersion);
- assertSent(server, "GET", path);
-
- assertNull(dataDisk);
- }
-
- public void listDisks() throws InterruptedException {
-
- server.enqueue(jsonResponse("/listdisks.json").setResponseCode(200));
-
- final DiskApi diskApi = api.getDiskApi(resourcegroup);
-
- List<Disk> dataDisks = diskApi.list();
-
- String path = String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Compute/disks?%s", subscriptionid, resourcegroup, apiVersion);
- assertSent(server, "GET", path);
-
- assertTrue(dataDisks.size() > 0);
- }
-
- public void listDisksReturns404() throws InterruptedException {
- server.enqueue(response404());
-
- final DiskApi diskApi = api.getDiskApi(resourcegroup);
-
- List<Disk> dataDisks = diskApi.list();
-
- String path = String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Compute/disks?%s", subscriptionid, resourcegroup, apiVersion);
- assertSent(server, "GET", path);
-
- assertTrue(isEmpty(dataDisks));
- }
-
- public void deleteDisk() throws InterruptedException {
-
- server.enqueue(response202WithHeader());
-
- final DiskApi diskApi = api.getDiskApi(resourcegroup);
-
- URI uri = diskApi.delete(diskName);
- Assert.assertNotNull(uri);
-
- String path = String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Compute/disks/%s?%s", subscriptionid, resourcegroup, diskName, apiVersion);
- assertSent(server, "DELETE", path);
- }
-
- public void deleteDiskResourceDoesNotExist() throws InterruptedException {
-
- server.enqueue(response204());
-
- final DiskApi diskApi = api.getDiskApi(resourcegroup);
-
- URI uri = diskApi.delete(diskName);
- assertNull(uri);
-
- String path = String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Compute/disks/%s?%s", subscriptionid, resourcegroup, diskName, apiVersion);
- assertSent(server, "DELETE", path);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/GraphRBACApiLiveTest.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/GraphRBACApiLiveTest.java b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/GraphRBACApiLiveTest.java
deleted file mode 100644
index ca6ce5e..0000000
--- a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/GraphRBACApiLiveTest.java
+++ /dev/null
@@ -1,39 +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.arm.features;
-
-import static org.testng.Assert.assertEquals;
-
-import org.jclouds.azurecompute.arm.domain.ServicePrincipal;
-import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiLiveTest;
-import org.testng.annotations.Test;
-
-@Test(groups = "live", testName = "GraphRBACApiLiveTest", singleThreaded = true)
-public class GraphRBACApiLiveTest extends BaseAzureComputeApiLiveTest {
-
- @Test
- public void testGetCurrentServicePrincipalSupplier() {
- ServicePrincipal currentUser = api.getServicePrincipal().get();
- assertEquals(currentUser.appId(), identity);
- }
-
- @Test
- public void testGetCurrentServicePrincipal() {
- ServicePrincipal currentUser = api.getGraphRBACApi().getCurrentServicePrincipal();
- assertEquals(currentUser.appId(), identity);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/GraphRBACApiMockTest.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/GraphRBACApiMockTest.java b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/GraphRBACApiMockTest.java
deleted file mode 100644
index 20b95e2..0000000
--- a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/GraphRBACApiMockTest.java
+++ /dev/null
@@ -1,39 +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.arm.features;
-
-import static org.testng.Assert.assertEquals;
-
-import java.io.IOException;
-
-import org.jclouds.azurecompute.arm.domain.ServicePrincipal;
-import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiMockTest;
-import org.testng.annotations.Test;
-
-@Test(groups = "unit", testName = "GraphRBACApiMockTest", singleThreaded = true)
-public class GraphRBACApiMockTest extends BaseAzureComputeApiMockTest {
-
- public void testGetCurrentServicePrincipal() throws IOException, InterruptedException {
- server.enqueue(jsonResponse("/serviceprincipals.json"));
-
- ServicePrincipal sp = api.getGraphRBACApi().getCurrentServicePrincipal();
-
- assertEquals(sp.appId(), "applicationId");
- assertSent(server, "GET", "/graphrbac/tenant-id/servicePrincipals?$filter=appId%20eq%20%27mock%27&api-version=1.6");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/ImageApiLiveTest.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/ImageApiLiveTest.java b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/ImageApiLiveTest.java
deleted file mode 100644
index 15231fd..0000000
--- a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/ImageApiLiveTest.java
+++ /dev/null
@@ -1,155 +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.arm.features;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.collect.Iterables.any;
-import static com.google.common.collect.Iterables.getOnlyElement;
-import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.TIMEOUT_RESOURCE_DELETED;
-import static org.jclouds.compute.predicates.NodePredicates.inGroup;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertTrue;
-import static org.jclouds.azurecompute.arm.compute.options.AzureTemplateOptions.Builder.resourceGroup;
-import java.net.URI;
-import java.util.Properties;
-
-import org.jclouds.azurecompute.arm.AzureComputeApi;
-import org.jclouds.azurecompute.arm.domain.IdReference;
-import org.jclouds.azurecompute.arm.domain.Image;
-import org.jclouds.azurecompute.arm.domain.ImageProperties;
-import org.jclouds.azurecompute.arm.internal.AzureLiveTestUtils;
-import org.jclouds.compute.RunNodesException;
-import org.jclouds.compute.domain.NodeMetadata;
-import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Predicate;
-import com.google.inject.Key;
-import com.google.inject.TypeLiteral;
-import com.google.inject.name.Names;
-
-// We extend the BaseComputeServiceContextLiveTest to create nodes using the abstraction, which is much easier
-@Test(groups = "live", singleThreaded = true, testName = "ImageApiLiveTest")
-public class ImageApiLiveTest extends BaseComputeServiceContextLiveTest {
-
- private static final String imageName = "imageFromRest";
-
- private Predicate<URI> resourceDeleted;
- private AzureComputeApi api;
-
- private String location;
- private ImageApi imageApi;
- private Image image;
-
- private String group;
-
- public ImageApiLiveTest() {
- provider = "azurecompute-arm";
- group = getClass().getSimpleName().toLowerCase();
- }
-
- @Override
- protected Properties setupProperties() {
- Properties properties = super.setupProperties();
- AzureLiveTestUtils.defaultProperties(properties);
- checkNotNull(setIfTestSystemPropertyPresent(properties, "oauth.endpoint"), "test.oauth.endpoint");
- return properties;
- }
-
- @Override
- protected void initializeContext() {
- super.initializeContext();
- resourceDeleted = context.utils().injector().getInstance(Key.get(new TypeLiteral<Predicate<URI>>() {
- }, Names.named(TIMEOUT_RESOURCE_DELETED)));
- api = view.unwrapApi(AzureComputeApi.class);
- }
-
- @Override
- @BeforeClass
- public void setupContext() {
- super.setupContext();
- // Use the resource name conventions used in the abstraction
- location = view.getComputeService().templateBuilder().build().getLocation().getId();
- view.unwrapApi(AzureComputeApi.class).getResourceGroupApi().create(group, location, null);
- imageApi = api.getVirtualMachineImageApi(group);
- }
-
- @Override
- @AfterClass(alwaysRun = true)
- protected void tearDownContext() {
- try {
- view.getComputeService().destroyNodesMatching(inGroup(group));
- } finally {
- try {
- URI uri = api.getResourceGroupApi().delete(group);
- assertResourceDeleted(uri);
- } finally {
- super.tearDownContext();
- }
- }
- }
-
- @Test
- public void testDeleteImageDoesNotExist() {
- assertNull(imageApi.delete("notAnImage"));
- }
-
- @Test
- public void testCreateImage() throws RunNodesException {
- NodeMetadata node = getOnlyElement(view.getComputeService().createNodesInGroup(group, 1, resourceGroup(group)));
- IdReference vmIdRef = IdReference.create(node.getProviderId());
- view.getComputeService().suspendNode(node.getId());
-
- api.getVirtualMachineApi(group).generalize(node.getName());
-
- image = imageApi.createOrUpdate(imageName, location, ImageProperties.builder()
- .sourceVirtualMachine(vmIdRef).build());
- assertNotNull(image);
- }
-
- @Test(dependsOnMethods = "testCreateImage")
- public void testListImages() {
- // Check that the image we've just created exists
- assertTrue(any(imageApi.list(), new Predicate<Image>() {
- @Override
- public boolean apply(Image input) {
- return image.name().equals(input.name());
- }
- }));
- }
-
- @Test(dependsOnMethods = "testCreateImage")
- public void testGetImage() {
- assertNotNull(imageApi.get(imageName));
- }
-
- @Test(dependsOnMethods = { "testCreateImage", "testListImages", "testGetImage" }, alwaysRun = true)
- public void deleteImage() {
- assertResourceDeleted(imageApi.delete(imageName));
- }
-
- private void assertResourceDeleted(final URI uri) {
- if (uri != null) {
- assertTrue(resourceDeleted.apply(uri),
- String.format("Resource %s was not deleted in the configured timeout", uri));
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/ImageApiMockTest.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/ImageApiMockTest.java b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/ImageApiMockTest.java
deleted file mode 100644
index cec0483..0000000
--- a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/ImageApiMockTest.java
+++ /dev/null
@@ -1,155 +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.arm.features;
-
-import static com.google.common.collect.Iterables.isEmpty;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertTrue;
-
-import java.net.URI;
-import java.util.List;
-
-import org.jclouds.azurecompute.arm.domain.DataDisk;
-import org.jclouds.azurecompute.arm.domain.IdReference;
-import org.jclouds.azurecompute.arm.domain.Image;
-import org.jclouds.azurecompute.arm.domain.ImageProperties;
-import org.jclouds.azurecompute.arm.domain.OSDisk;
-import org.jclouds.azurecompute.arm.domain.StorageProfile;
-import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiMockTest;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-
-@Test(groups = "unit", testName = "ImageApiMockTest", singleThreaded = true)
-public class ImageApiMockTest extends BaseAzureComputeApiMockTest {
- private static final String subscriptionid = "SUBSCRIPTIONID";
- private static final String resourcegroup = "myresourcegroup";
- private static final String apiVersion = "api-version=2016-04-30-preview";
- private static final String imageName = "testVirtualMachineImage";
- private static final String location = "canadaeast";
-
- private static final String PATH = String
- .format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Compute/images/%s?%s", subscriptionid,
- resourcegroup, imageName, apiVersion);
-
- public void createVirtualMachineImage() throws InterruptedException {
- server.enqueue(jsonResponse("/virtualmachineimagecreate.json"));
-
- ImageApi imageApi = api.getVirtualMachineImageApi(resourcegroup);
- Image result = imageApi.createOrUpdate(imageName, location, newVirtualMachineImage().properties());
-
- assertSent(server, "PUT", PATH, "{\"location\":\"" + location + "\","
- + "\"properties\":{\"sourceVirtualMachine\":{\"id\":\"vmId\"},"
- + "\"storageProfile\":{\"osDisk\":{\"osType\":\"Linux\",\"name\":\"Ubuntu\"},\"dataDisks\":[]},"
- + "\"provisioningState\":\"Succeeded\"}}");
-
- assertEquals(result.name(), imageName);
- assertEquals(result.location(), location);
- }
-
- public void getVirtualMachineImage() throws InterruptedException {
- server.enqueue(jsonResponse("/virtualmachineimageget.json"));
-
- ImageApi imageApi = api.getVirtualMachineImageApi(resourcegroup);
- Image result = imageApi.get(imageName);
-
- assertSent(server, "GET", PATH);
-
- assertEquals(result.name(), imageName);
- assertEquals(result.location(), location);
- assertNotNull(result.properties().sourceVirtualMachine());
- assertNotNull(result.properties().storageProfile());
- }
-
- public void getVirtualMachineImageReturns404() throws InterruptedException {
- server.enqueue(response404());
-
- final ImageApi imageApi = api.getVirtualMachineImageApi(resourcegroup);
- Image result = imageApi.get(imageName);
-
- assertSent(server, "GET", PATH);
-
- assertNull(result);
- }
-
- public void listVirtualMachineImages() throws InterruptedException {
- server.enqueue(jsonResponse("/virtualmachineimagelist.json"));
-
- final ImageApi imageApi = api.getVirtualMachineImageApi(resourcegroup);
- List<Image> result = imageApi.list();
-
- assertSent(server, "GET", String
- .format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Compute/images?%s", subscriptionid,
- resourcegroup, apiVersion));
-
- assertNotNull(result);
- assertTrue(result.size() > 0);
- }
-
- public void listVirtualMachineImagesReturns404() throws InterruptedException {
- server.enqueue(response404());
-
- final ImageApi imageApi = api.getVirtualMachineImageApi(resourcegroup);
- List<Image> result = imageApi.list();
-
- assertSent(server, "GET", String
- .format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Compute/images?%s", subscriptionid,
- resourcegroup, apiVersion));
-
- assertTrue(isEmpty(result));
- }
-
- public void deleteVirtualMachineImage() throws InterruptedException {
- server.enqueue(response202WithHeader());
-
- final ImageApi imageApi = api.getVirtualMachineImageApi(resourcegroup);
- URI uri = imageApi.delete(imageName);
-
- assertSent(server, "DELETE", PATH);
-
- assertNotNull(uri);
- assertTrue(uri.toString().contains("api-version"));
- assertTrue(uri.toString().contains("operationresults"));
- }
-
- public void deleteVirtualMachineImageDoesNotExist() throws InterruptedException {
- server.enqueue(response404());
-
- final ImageApi imageApi = api.getVirtualMachineImageApi(resourcegroup);
- URI uri = imageApi.delete(imageName);
- assertNull(uri);
-
- assertSent(server, "DELETE", PATH);
- }
-
- private Image newVirtualMachineImage() {
- return Image
- .builder()
- .name(imageName)
- .location(location)
- .properties(
- ImageProperties
- .builder()
- .sourceVirtualMachine(IdReference.create("vmId"))
- .storageProfile(
- StorageProfile.create(null, OSDisk.builder().osType("Linux").name("Ubuntu").build(),
- ImmutableList.<DataDisk> of())).provisioningState("Succeeded").build()).build();
-
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/JobApiMockTest.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/JobApiMockTest.java b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/JobApiMockTest.java
deleted file mode 100644
index 7364145..0000000
--- a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/JobApiMockTest.java
+++ /dev/null
@@ -1,96 +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.arm.features;
-
-import java.io.IOException;
-import java.net.URI;
-import java.util.List;
-
-import org.jclouds.azurecompute.arm.domain.ResourceDefinition;
-import org.jclouds.azurecompute.arm.functions.ParseJobStatus.JobStatus;
-import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiMockTest;
-import org.testng.annotations.Test;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-
-@Test(groups = "unit", testName = "JobApiMockTest", singleThreaded = true)
-public class JobApiMockTest extends BaseAzureComputeApiMockTest {
-
- final String requestUrl = "/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1SVEVTVC1DRU5UUkFMVVMiLCJqb2JMb2NhdGlvbiI6ImNlbnRyYWx1cyJ9?api-version=2014-04-01";
-
- public void testGetJobStatus() throws IOException, InterruptedException {
- server.enqueue(response200());
-
- JobStatus status = api.getJobApi().jobStatus(URI.create(requestUrl));
-
- assertEquals(status, JobStatus.DONE);
-
- assertSent(server, "GET", requestUrl);
- }
-
- public void testGetJobStatusInProgress() throws InterruptedException {
- server.enqueue(response202WithHeader());
-
- JobStatus status = api.getJobApi().jobStatus(URI.create(requestUrl));
-
- assertEquals(status, JobStatus.IN_PROGRESS);
-
- assertSent(server, "GET", requestUrl);
- }
-
- public void testGetJobStatusNoContent() throws InterruptedException {
- server.enqueue(jsonResponse("/resourcegroup.json").setStatus("HTTP/1.1 204 No Content"));
-
- JobStatus status = api.getJobApi().jobStatus(URI.create(requestUrl));
-
- assertEquals(status, JobStatus.NO_CONTENT);
-
- assertSent(server, "GET", requestUrl);
- }
-
- public void testGetJobStatusFailed() throws InterruptedException {
- server.enqueue(jsonResponse("/resourcegroup.json").setStatus("HTTP/1.1 208 Error"));
-
- JobStatus status = api.getJobApi().jobStatus(URI.create(requestUrl));
-
- assertEquals(status, JobStatus.FAILED);
-
- assertSent(server, "GET", requestUrl);
- }
-
- public void testCaptureJobStatus() throws IOException, InterruptedException {
- server.enqueue(jsonResponse("/resourceDefinition.json").setResponseCode(200));
-
- List<ResourceDefinition> resourceDefinitionsList = api.getJobApi().captureStatus(URI.create(requestUrl));
-
- assertTrue(resourceDefinitionsList.size() > 0);
-
- assertSent(server, "GET", requestUrl);
- }
-
- public void testCaptureJobStatusFailed() throws InterruptedException {
- server.enqueue(response404());
-
- List<ResourceDefinition> resourceDefinitionsList = api.getJobApi().captureStatus(URI.create(requestUrl));
-
- assertEquals(resourceDefinitionsList.size(), 0);
-
- assertSent(server, "GET", requestUrl);
- }
-
-}