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:50 UTC
[09/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/features/NetworkSecurityRuleApiLiveTest.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/NetworkSecurityRuleApiLiveTest.java b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/NetworkSecurityRuleApiLiveTest.java
deleted file mode 100644
index 821dbe3..0000000
--- a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/NetworkSecurityRuleApiLiveTest.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.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.NetworkSecurityGroup;
-import org.jclouds.azurecompute.arm.domain.NetworkSecurityRule;
-import org.jclouds.azurecompute.arm.domain.NetworkSecurityRuleProperties;
-import org.jclouds.azurecompute.arm.domain.NetworkSecurityRuleProperties.Access;
-import org.jclouds.azurecompute.arm.domain.NetworkSecurityRuleProperties.Direction;
-import org.jclouds.azurecompute.arm.domain.NetworkSecurityRuleProperties.Protocol;
-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.Iterables;
-
-@Test(groups = "live", singleThreaded = true)
-public class NetworkSecurityRuleApiLiveTest extends BaseAzureComputeApiLiveTest {
-
- private static String UNKNOWN_RULE_NAME = "ruledoesntexist";
- private String nsgName;
-
- @BeforeClass
- @Override
- public void setup() {
- super.setup();
- createTestResourceGroup();
- nsgName = String.format("nsg-%s-%s", this.getClass().getSimpleName().toLowerCase(), System.getProperty("user.name"));
-
- // a network security group is needed
- final NetworkSecurityGroup nsg = newNetworkSecurityGroup(nsgName, LOCATION);
- assertNotNull(api.getNetworkSecurityGroupApi(resourceGroupName).createOrUpdate(nsgName,
- nsg.location(),
- nsg.tags(),
- nsg.properties()));
- }
-
- @Test
- public void deleteNetworkSecurityRuleDoesNotExist() {
- URI uri = api().delete(UNKNOWN_RULE_NAME);
- assertNull(uri);
- }
-
- @Test(dependsOnMethods = "deleteNetworkSecurityRuleDoesNotExist")
- public void createNetworkSecurityRule() {
- final NetworkSecurityRule rule = createRule();
- assertNotNull(rule);
-
- final NetworkSecurityRuleApi ruleApi = api.getNetworkSecurityRuleApi(resourceGroupName, nsgName);
- NetworkSecurityRule result = ruleApi.createOrUpdate(rule.name(), rule.properties());
- assertNotNull(result);
- assertEquals(result.name(), rule.name());
- }
-
- @Test(dependsOnMethods = "createNetworkSecurityRule")
- public void getNetworkSecurityRule() {
- final NetworkSecurityRule rule = createRule();
- assertNotNull(rule);
-
- NetworkSecurityRule result = api().get(rule.name());
- assertNotNull(result);
- assertNotNull(result.etag());
- assertEquals(result.name(), rule.name());
- }
-
- @Test(dependsOnMethods = "createNetworkSecurityRule")
- public void getNetworkSecurityDefaultRule() {
- String defaultRuleName = "AllowVnetInBound";
-
- NetworkSecurityRule result = api().getDefaultRule(defaultRuleName);
-
- assertNotNull(result);
- assertNotNull(result.etag());
- assertEquals(result.name(), defaultRuleName);
- }
-
- @Test(dependsOnMethods = "createNetworkSecurityRule")
- public void listNetworkSecurityRules() {
- final NetworkSecurityRule rule = createRule();
- assertNotNull(rule);
-
- List<NetworkSecurityRule> result = api().list();
-
- assertNotNull(result);
- assertEquals(result.size(), 2);
-
- boolean rulePresent = Iterables.any(result, new Predicate<NetworkSecurityRule>() {
- public boolean apply(NetworkSecurityRule input) {
- return input.name().equals(rule.name());
- }
- });
-
- assertTrue(rulePresent);
- }
-
- @Test(dependsOnMethods = "createNetworkSecurityRule")
- public void listDefaultSecurityRules() {
- List<NetworkSecurityRule> result = api().listDefaultRules();
- assertNotNull(result);
- assertTrue(result.size() > 0);
- }
-
- @Test(dependsOnMethods = {"listNetworkSecurityRules", "listDefaultSecurityRules", "getNetworkSecurityRule"})
- public void deleteNetworkSecurityRule() {
- final NetworkSecurityRule rule = createRule();
- assertNotNull(rule);
-
- URI uri = api().delete(rule.name());
- assertResourceDeleted(uri);
- }
-
- private NetworkSecurityRule createRule() {
- NetworkSecurityRule rule = NetworkSecurityRule.create("allowalludpin", null, null,
- NetworkSecurityRuleProperties.builder()
- .description("allow all udp in")
- .protocol(Protocol.Udp)
- .sourcePortRange("*")
- .destinationPortRange("*")
- .sourceAddressPrefix("*")
- .destinationAddressPrefix("*")
- .access(Access.Allow)
- .priority(4094)
- .direction(Direction.Inbound)
- .build());
- return rule;
- }
-
- private NetworkSecurityRuleApi api() {
- return api.getNetworkSecurityRuleApi(resourceGroupName, nsgName);
- }
-
-}
-
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/NetworkSecurityRuleApiMockTest.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/NetworkSecurityRuleApiMockTest.java b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/NetworkSecurityRuleApiMockTest.java
deleted file mode 100644
index 1ca4284..0000000
--- a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/NetworkSecurityRuleApiMockTest.java
+++ /dev/null
@@ -1,206 +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 com.google.gson.Gson;
-import org.jclouds.azurecompute.arm.domain.NetworkSecurityRule;
-import org.jclouds.azurecompute.arm.domain.NetworkSecurityRuleProperties;
-import org.jclouds.azurecompute.arm.domain.NetworkSecurityRuleProperties.Protocol;
-import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiMockTest;
-import org.testng.annotations.Test;
-
-import java.net.URI;
-import java.util.List;
-
-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;
-import static org.testng.Assert.assertNotNull;
-
-
-@Test(groups = "unit", testName = "NetworkSecurityRuleApiMockTest", singleThreaded = true)
-public class NetworkSecurityRuleApiMockTest extends BaseAzureComputeApiMockTest {
- private final String subscriptionid = "SUBSCRIPTIONID";
- private final String resourcegroup = "myresourcegroup";
- private final String apiVersion = "api-version=2016-03-30";
- private static String DEFAULT_NSG_NAME = "testNetworkSecurityGroup";
-
- private NetworkSecurityRule createRule() {
- NetworkSecurityRule rule = NetworkSecurityRule.create("allowalludpin", null, null,
- NetworkSecurityRuleProperties.builder()
- .description("allow all udp in")
- .protocol(Protocol.Udp)
- .sourcePortRange("*")
- .destinationPortRange("*")
- .sourceAddressPrefix("*")
- .destinationAddressPrefix("*")
- .access(NetworkSecurityRuleProperties.Access.Allow)
- .priority(4094)
- .direction(NetworkSecurityRuleProperties.Direction.Inbound)
- .build());
- return rule;
- }
-
- public void createNetworkSecurityRule() throws InterruptedException {
- NetworkSecurityRule rule = createRule();
-
- server.enqueue(jsonResponse("/networksecurityrulecreate.json").setResponseCode(200));
- final NetworkSecurityRuleApi ruleApi = api.getNetworkSecurityRuleApi(resourcegroup, DEFAULT_NSG_NAME);
-
- String path = String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/networkSecurityGroups/%s/securityRules/%s?%s", subscriptionid, resourcegroup, DEFAULT_NSG_NAME, rule.name(), apiVersion);
- NetworkSecurityRule result = ruleApi.createOrUpdate(rule.name(), rule.properties());
- String json = String.format("{\"properties\":%s}", new Gson().toJson(rule.properties()));
-
- assertSent(server, "PUT", path, json);
-
- assertNotNull(result);
- assertEquals(result.name(), rule.name());
- }
-
- public void getNetworkSecurityRule() throws InterruptedException {
- NetworkSecurityRule rule = createRule();
-
- server.enqueue(jsonResponse("/networksecurityruleget.json").setResponseCode(200));
- final NetworkSecurityRuleApi ruleApi = api.getNetworkSecurityRuleApi(resourcegroup, DEFAULT_NSG_NAME);
-
- String path = String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/networkSecurityGroups/%s/securityRules/%s?%s", subscriptionid, resourcegroup, DEFAULT_NSG_NAME, rule.name(), apiVersion);
- NetworkSecurityRule result = ruleApi.get(rule.name());
- assertSent(server, "GET", path);
-
- assertEquals(result.name(), rule.name());
- }
-
- public void getNetworkSecurityRuleReturns404() throws InterruptedException {
- server.enqueue(response404());
-
- String missingRuleName = "ruleismissing";
- final NetworkSecurityRuleApi ruleApi = api.getNetworkSecurityRuleApi(resourcegroup, DEFAULT_NSG_NAME);
-
- String path = String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/networkSecurityGroups/%s/securityRules/%s?%s", subscriptionid, resourcegroup, DEFAULT_NSG_NAME, missingRuleName, apiVersion);
- NetworkSecurityRule result = ruleApi.get(missingRuleName);
- assertSent(server, "GET", path);
-
- assertNull(result);
- }
-
- public void getNetworkSecurityDefaultRule() throws InterruptedException {
- server.enqueue(jsonResponse("/networksecurityrulegetdefault.json").setResponseCode(200));
- final NetworkSecurityRuleApi ruleApi = api.getNetworkSecurityRuleApi(resourcegroup, DEFAULT_NSG_NAME);
- String ruleName = "AllowVnetInBound";
-
- String path = String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/networkSecurityGroups/%s/defaultSecurityRules/%s?%s", subscriptionid, resourcegroup, DEFAULT_NSG_NAME, ruleName, apiVersion);
- NetworkSecurityRule result = ruleApi.getDefaultRule(ruleName);
- assertSent(server, "GET", path);
-
- assertNotNull(result);
- assertEquals(result.name(), ruleName);
- }
-
- public void getNetworkSecurityDefaultRuleReturns404() throws InterruptedException {
- server.enqueue(response404());
-
- String missingRuleName = "ruleismissing";
- final NetworkSecurityRuleApi ruleApi = api.getNetworkSecurityRuleApi(resourcegroup, DEFAULT_NSG_NAME);
-
- String path = String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/networkSecurityGroups/%s/defaultSecurityRules/%s?%s", subscriptionid, resourcegroup, DEFAULT_NSG_NAME, missingRuleName, apiVersion);
- NetworkSecurityRule result = ruleApi.getDefaultRule(missingRuleName);
- assertSent(server, "GET", path);
-
- assertNull(result);
- }
-
- public void listNetworkSecurityRules() throws InterruptedException {
- server.enqueue(jsonResponse("/networksecurityrulelist.json").setResponseCode(200));
-
- final NetworkSecurityRuleApi ruleApi = api.getNetworkSecurityRuleApi(resourcegroup, DEFAULT_NSG_NAME);
-
- String path = String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/networkSecurityGroups/%s/securityRules?%s", subscriptionid, resourcegroup, DEFAULT_NSG_NAME, apiVersion);
- List<NetworkSecurityRule> result = ruleApi.list();
- assertSent(server, "GET", path);
-
- assertNotNull(result);
- assertTrue(result.size() > 0);
- }
-
- public void listNetworkSecurityRulesReturns404() throws InterruptedException {
- server.enqueue(response404());
-
- final NetworkSecurityRuleApi ruleApi = api.getNetworkSecurityRuleApi(resourcegroup, DEFAULT_NSG_NAME);
-
- String path = String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/networkSecurityGroups/%s/securityRules?%s", subscriptionid, resourcegroup, DEFAULT_NSG_NAME, apiVersion);
- List<NetworkSecurityRule> result = ruleApi.list();
- assertSent(server, "GET", path);
-
- assertTrue(isEmpty(result));
- }
-
- public void listNetworkSecurityDefaultRules() throws InterruptedException {
- server.enqueue(jsonResponse("/networksecurityrulelistdefault.json").setResponseCode(200));
-
- final NetworkSecurityRuleApi ruleApi = api.getNetworkSecurityRuleApi(resourcegroup, DEFAULT_NSG_NAME);
-
- String path = String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/networkSecurityGroups/%s/defaultSecurityRules?%s", subscriptionid, resourcegroup, DEFAULT_NSG_NAME, apiVersion);
- List<NetworkSecurityRule> result = ruleApi.listDefaultRules();
- assertSent(server, "GET", path);
-
- assertNotNull(result);
- assertTrue(result.size() > 0);
- }
-
- public void listNetworkSecurityDefaultRulesReturns404() throws InterruptedException {
- server.enqueue(response404());
-
- final NetworkSecurityRuleApi ruleApi = api.getNetworkSecurityRuleApi(resourcegroup, DEFAULT_NSG_NAME);
-
- String path = String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/networkSecurityGroups/%s/defaultSecurityRules?%s", subscriptionid, resourcegroup, DEFAULT_NSG_NAME, apiVersion);
- List<NetworkSecurityRule> result = ruleApi.listDefaultRules();
- assertSent(server, "GET", path);
-
- assertTrue(isEmpty(result));
- }
-
- public void deleteNetworkSecurityRule() throws InterruptedException {
- server.enqueue(response202WithHeader());
-
- NetworkSecurityRule rule = createRule();
-
- final NetworkSecurityRuleApi ruleApi = api.getNetworkSecurityRuleApi(resourcegroup, DEFAULT_NSG_NAME);
- URI uri = ruleApi.delete(rule.name());
-
- assertEquals(server.getRequestCount(), 1);
- assertNotNull(uri);
-
- String path = String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/networkSecurityGroups/%s/securityRules/%s?%s", subscriptionid, resourcegroup, DEFAULT_NSG_NAME, rule.name(), apiVersion);
- assertSent(server, "DELETE", path);
-
- assertTrue(uri.toString().contains("api-version"));
- assertTrue(uri.toString().contains("operationresults"));
- }
-
- public void deleteNetworkSecurityRuleDoesNotExist() throws InterruptedException {
- server.enqueue(response404());
-
- final NetworkSecurityRuleApi ruleApi = api.getNetworkSecurityRuleApi(resourcegroup, DEFAULT_NSG_NAME);
- String dummyname = "dummyrulename";
- URI uri = ruleApi.delete(dummyname);
- assertNull(uri);
-
- String path = String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/networkSecurityGroups/%s/securityRules/%s?%s", subscriptionid, resourcegroup, DEFAULT_NSG_NAME, dummyname, 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/OSImageApiLiveTest.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/OSImageApiLiveTest.java b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/OSImageApiLiveTest.java
deleted file mode 100644
index 0756643..0000000
--- a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/OSImageApiLiveTest.java
+++ /dev/null
@@ -1,70 +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.util.List;
-
-import org.jclouds.azurecompute.arm.domain.Offer;
-import org.jclouds.azurecompute.arm.domain.Publisher;
-import org.jclouds.azurecompute.arm.domain.SKU;
-import org.jclouds.azurecompute.arm.domain.Version;
-import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiLiveTest;
-import org.testng.annotations.Test;
-
-import static org.testng.Assert.assertTrue;
-
-@Test(groups = "live", testName = "OSImageApiLiveTest")
-public class OSImageApiLiveTest extends BaseAzureComputeApiLiveTest {
-
- @Test
- public void testPublisher() {
- List<Publisher> publishers = api().listPublishers();
- assertTrue(publishers.size() > 0);
- }
-
- @Test
- public void testList() {
- List<Offer> offerList = api().listOffers("MicrosoftWindowsServer");
- assertTrue(offerList.size() > 0);
-
- List<SKU> skuList = api().listSKUs("MicrosoftWindowsServer", offerList.get(0).name());
- assertTrue(skuList.size() > 0);
-
- List<Version> versionList = api().listVersions("MicrosoftWindowsServer", offerList.get(0).name(), skuList.get(0).name());
-
- assertTrue(versionList.size() > 0);
- }
-
- @Test
- public void testListCanonicalUbuntu() {
- Iterable<Offer> offerList = api().listOffers("canonical");
- int total = 0;
-
- for (Offer offer : offerList) {
- Iterable<SKU> skuList = api().listSKUs("canonical", offer.name());
- for (SKU sku : skuList) {
- List<Version> versionList = api().listVersions("canonical", offer.name(), sku.name());
- total += versionList.size();
- }
- }
- assertTrue(total > 0);
- }
-
- private OSImageApi api() {
- return api.getOSImageApi("eastus");
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/OSImageApiMockTest.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/OSImageApiMockTest.java b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/OSImageApiMockTest.java
deleted file mode 100644
index d7dbc92..0000000
--- a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/OSImageApiMockTest.java
+++ /dev/null
@@ -1,123 +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 com.google.common.collect.Iterables.size;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-
-import java.util.List;
-
-import org.jclouds.azurecompute.arm.domain.Offer;
-import org.jclouds.azurecompute.arm.domain.Publisher;
-import org.jclouds.azurecompute.arm.domain.SKU;
-import org.jclouds.azurecompute.arm.domain.Version;
-import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiMockTest;
-import org.testng.annotations.Test;
-
-@Test(groups = "unit", testName = "OSImageApiMockTest", singleThreaded = true)
-public class OSImageApiMockTest extends BaseAzureComputeApiMockTest {
-
- private final String subscriptionid = "SUBSCRIPTIONID";
- private final String apiversion = "?api-version=2015-06-15";
- private final String location = "eastus";
- private final String publisher = "MicrosoftWindowsServer";
- private final String offer = "WindowsServer";
- private final String sku = "2008-R2-SP1";
-
- final String requestUrl = "/subscriptions/" + subscriptionid + "/providers/Microsoft.Compute/locations/" + location + "/publishers";
-
- public void testPublishers() throws InterruptedException {
- server.enqueue(jsonResponse("/publishers.json"));
-
- List<Publisher> publishers = api.getOSImageApi(location).listPublishers();
-
- assertEquals(size(publishers), 2);
-
- assertSent(server, "GET", requestUrl + apiversion);
- }
- public void testPublishersEmtpy() throws InterruptedException {
- server.enqueue(response404());
-
- List<Publisher> publishers = api.getOSImageApi(location).listPublishers();
-
- assertTrue(isEmpty(publishers));
-
- assertSent(server, "GET", requestUrl + apiversion);
- }
-
- public void testOffers() throws InterruptedException {
- server.enqueue(jsonResponse("/offers.json"));
-
- List<Offer> offers = api.getOSImageApi(location).listOffers(publisher);
-
- assertEquals(size(offers), 1);
-
- assertSent(server, "GET", requestUrl + "/" + publisher + "/artifacttypes/vmimage/offers" + apiversion);
- }
- public void testOffersEmtpy() throws InterruptedException {
- server.enqueue(response404());
-
- List<Offer> offers = api.getOSImageApi(location).listOffers(publisher);
-
- assertTrue(isEmpty(offers));
-
- assertSent(server, "GET", requestUrl + "/" + publisher + "/artifacttypes/vmimage/offers" + apiversion);
- }
-
- public void testSkus() throws InterruptedException {
- server.enqueue(jsonResponse("/skus.json"));
-
- List<SKU> skus = api.getOSImageApi(location).listSKUs(publisher, offer);
-
- assertEquals(size(skus), 2);
-
- assertSent(server, "GET", requestUrl + "/" + publisher + "/artifacttypes/vmimage/offers/" + offer + "/skus" + apiversion);
- }
-
- public void testSkusEmtpy() throws InterruptedException {
- server.enqueue(response404());
-
- List<SKU> skus = api.getOSImageApi(location).listSKUs(publisher, offer);
-
- assertTrue(isEmpty(skus));
-
- assertSent(server, "GET", requestUrl + "/" + publisher + "/artifacttypes/vmimage/offers/" + offer + "/skus" + apiversion);
- }
-
- public void testVersions() throws InterruptedException {
- server.enqueue(jsonResponse("/versions.json"));
-
- List<Version> versions = api.getOSImageApi(location).listVersions(publisher, offer, sku);
-
- assertEquals(size(versions), 2);
-
- assertSent(server, "GET", requestUrl + "/" + publisher + "/artifacttypes/vmimage/offers/" + offer + "/skus/" + sku + "/versions" + apiversion);
- }
- public void testVersionsEmtpy() throws InterruptedException {
- server.enqueue(response404());
-
- List<Version> versions = api.getOSImageApi(location).listVersions(publisher, offer, sku);
-
- assertTrue(isEmpty(versions));
-
- assertSent(server, "GET", requestUrl + "/" + publisher + "/artifacttypes/vmimage/offers/" + offer + "/skus/" + sku + "/versions" + apiversion);
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/PublicIPAddressApiLiveTest.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/PublicIPAddressApiLiveTest.java b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/PublicIPAddressApiLiveTest.java
deleted file mode 100644
index 9519ed6..0000000
--- a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/PublicIPAddressApiLiveTest.java
+++ /dev/null
@@ -1,129 +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 static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertTrue;
-
-import java.util.List;
-import java.util.Map;
-
-import org.jclouds.azurecompute.arm.domain.PublicIPAddress;
-import org.jclouds.azurecompute.arm.domain.PublicIPAddressProperties;
-import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiLiveTest;
-import org.jclouds.util.Predicates2;
-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", singleThreaded = true)
-public class PublicIPAddressApiLiveTest extends BaseAzureComputeApiLiveTest {
-
- private final String publicIpAddressName = "myipaddress";
- private String subscriptionid;
-
- @BeforeClass
- @Override
- public void setup() {
- super.setup();
- createTestResourceGroup();
- subscriptionid = getSubscriptionId();
- }
-
- @Test(groups = "live")
- public void deletePublicIPAddressResourceDoesNotExist() {
- final PublicIPAddressApi ipApi = api.getPublicIPAddressApi(resourceGroupName);
- boolean status = ipApi.delete(publicIpAddressName);
- assertFalse(status);
- }
-
- @Test(groups = "live", dependsOnMethods = "deletePublicIPAddressResourceDoesNotExist")
- public void createPublicIPAddress() {
-
- final PublicIPAddressApi ipApi = api.getPublicIPAddressApi(resourceGroupName);
-
- final Map<String, String> tags = ImmutableMap.of("testkey", "testvalue");
-
- PublicIPAddressProperties properties =
- PublicIPAddressProperties.builder()
- .publicIPAllocationMethod("Static")
- .idleTimeoutInMinutes(4)
- .build();
-
- PublicIPAddress ip = ipApi.createOrUpdate(publicIpAddressName, LOCATION, tags, properties);
-
- assertNotNull(ip);
- assertEquals(ip.name(), publicIpAddressName);
- assertEquals(ip.location(), LOCATION);
- assertEquals(ip.id(), String.format("/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/publicIPAddresses/%s", subscriptionid, resourceGroupName, publicIpAddressName));
- assertEquals(ip.tags().get("testkey"), "testvalue");
- assertNotNull(ip.properties());
- assertEquals(ip.properties().provisioningState(), "Updating");
- assertNull(ip.properties().ipAddress()); // as we don't get IP address until Succeeded state
- assertEquals(ip.properties().publicIPAllocationMethod(), "Static");
- assertEquals(ip.properties().idleTimeoutInMinutes().intValue(), 4);
- }
-
- @Test(groups = "live", dependsOnMethods = "createPublicIPAddress")
- public void getPublicIPAddress() {
-
- final PublicIPAddressApi ipApi = api.getPublicIPAddressApi(resourceGroupName);
-
- //Poll until resource is ready to be used
- boolean jobDone = Predicates2.retry(new Predicate<String>() {
- @Override public boolean apply(String name) {
- return ipApi.get(name).properties().provisioningState().equals("Succeeded");
- }
- }, 10 * 1000).apply(publicIpAddressName);
- assertTrue(jobDone, "get operation did not complete in the configured timeout");
-
- PublicIPAddress ip = ipApi.get(publicIpAddressName);
- assertNotNull(ip);
- assertEquals(ip.name(), publicIpAddressName);
- assertEquals(ip.location(), LOCATION);
- assertEquals(ip.id(), String.format("/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/publicIPAddresses/%s", subscriptionid, resourceGroupName, publicIpAddressName));
- assertEquals(ip.tags().get("testkey"), "testvalue");
- assertNotNull(ip.properties());
- assertEquals(ip.properties().provisioningState(), "Succeeded");
- assertNotNull(ip.properties().ipAddress()); // by this time we should have IP address already
- assertEquals(ip.properties().publicIPAllocationMethod(), "Static");
- assertEquals(ip.properties().idleTimeoutInMinutes().intValue(), 4);
- }
-
- @Test(groups = "live", dependsOnMethods = "createPublicIPAddress")
- public void listPublicIPAddresses() {
-
- final PublicIPAddressApi ipApi = api.getPublicIPAddressApi(resourceGroupName);
-
- List<PublicIPAddress> ipList = ipApi.list();
-
- assertTrue(ipList.size() > 0);
- }
-
- @Test(groups = "live", dependsOnMethods = {"listPublicIPAddresses", "getPublicIPAddress"}, alwaysRun = true)
- public void deletePublicIPAddress() {
- final PublicIPAddressApi ipApi = api.getPublicIPAddressApi(resourceGroupName);
- boolean status = ipApi.delete(publicIpAddressName);
- assertTrue(status);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/PublicIPAddressApiMockTest.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/PublicIPAddressApiMockTest.java b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/PublicIPAddressApiMockTest.java
deleted file mode 100644
index b510580..0000000
--- a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/PublicIPAddressApiMockTest.java
+++ /dev/null
@@ -1,178 +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 com.google.common.collect.ImmutableMap;
-import com.squareup.okhttp.mockwebserver.MockResponse;
-import org.jclouds.azurecompute.arm.domain.DnsSettings;
-import org.jclouds.azurecompute.arm.domain.PublicIPAddress;
-import org.jclouds.azurecompute.arm.domain.PublicIPAddressProperties;
-import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiMockTest;
-import org.testng.annotations.Test;
-
-import java.util.List;
-import java.util.Map;
-
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertNull;
-
-
-@Test(groups = "unit", testName = "NetworkInterfaceCardApiMockTest", singleThreaded = true)
-public class PublicIPAddressApiMockTest extends BaseAzureComputeApiMockTest {
-
- private final String subscriptionid = "SUBSCRIPTIONID";
- private final String resourcegroup = "myresourcegroup";
- private final String apiVersion = "api-version=2015-06-15";
- private final String location = "northeurope";
- private final String publicIpName = "mypublicaddress";
-
- public void getPublicIPAddressInfo() throws InterruptedException {
- server.enqueue(jsonResponse("/PublicIPAddressGetInfo.json"));
-
- final PublicIPAddressApi ipApi = api.getPublicIPAddressApi(resourcegroup);
- PublicIPAddress ip = ipApi.get(publicIpName);
-
- String path = String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/publicIPAddresses/%s?%s", subscriptionid, resourcegroup, publicIpName, apiVersion);
- assertSent(server, "GET", path);
-
- assertNotNull(ip);
- assertEquals(ip.name(), "mypublicaddress");
- assertEquals(ip.location(), "northeurope");
- assertEquals(ip.id(), "/subscriptions/fakeb2f5-4710-4e93-bdf4-419edbde2178/resourceGroups/myresourcegroup/providers/Microsoft.Network/publicIPAddresses/mypublicaddress");
- assertEquals(ip.tags().get("testkey"), "testvalue");
- assertNotNull(ip.properties());
- assertEquals(ip.properties().provisioningState(), "Succeeded");
- assertEquals(ip.properties().ipAddress(), "12.123.12.123");
- assertEquals(ip.properties().publicIPAllocationMethod(), "Static");
- assertEquals(ip.properties().idleTimeoutInMinutes().intValue(), 4);
- assertNotNull(ip.properties().dnsSettings());
- assertEquals(ip.properties().dnsSettings().domainNameLabel(), "foobar");
- assertEquals(ip.properties().dnsSettings().fqdn(), "foobar.northeurope.cloudapp.azure.com");
- assertNotNull(ip.properties().ipConfiguration());
- assertEquals(ip.properties().ipConfiguration().id(), "/subscriptions/fakeb2f5-4710-4e93-bdf4-419edbde2178/resourceGroups/myresourcegroup/providers/Microsoft.Network/networkInterfaces/myNic/ipConfigurations/myip1");
- }
-
- public void getPublicIPAddressInfoEmpty() throws Exception {
- server.enqueue(new MockResponse().setResponseCode(404));
-
- final PublicIPAddressApi ipApi = api.getPublicIPAddressApi(resourcegroup);
- PublicIPAddress ip = ipApi.get(publicIpName);
-
- String path = String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/publicIPAddresses/%s?%s", subscriptionid, resourcegroup, publicIpName, apiVersion);
- assertSent(server, "GET", path);
-
- assertNull(ip);
- }
-
- public void listPublicIPAddresses() throws InterruptedException {
- server.enqueue(jsonResponse("/PublicIPAddressList.json"));
-
- final PublicIPAddressApi ipApi = api.getPublicIPAddressApi(resourcegroup);
- List<PublicIPAddress> ipList = ipApi.list();
-
- String path = String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/publicIPAddresses?%s", subscriptionid, resourcegroup, apiVersion);
- assertSent(server, "GET", path);
- assertEquals(ipList.size(), 4);
- }
-
- public void listPublicIPAddressesEmpty() throws InterruptedException {
- server.enqueue(new MockResponse().setResponseCode(404));
-
- final PublicIPAddressApi ipApi = api.getPublicIPAddressApi(resourcegroup);
- List<PublicIPAddress> ipList = ipApi.list();
-
- String path = String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/publicIPAddresses?%s", subscriptionid, resourcegroup, apiVersion);
- assertSent(server, "GET", path);
- assertEquals(ipList.size(), 0);
- }
-
- public void createPublicIPAddress() throws InterruptedException {
-
- server.enqueue(jsonResponse("/PublicIPAddressCreate.json").setStatus("HTTP/1.1 201 Created"));
-
- final PublicIPAddressApi ipApi = api.getPublicIPAddressApi(resourcegroup);
-
- final Map<String, String> tags = ImmutableMap.of("testkey", "testvalue");
-
- PublicIPAddressProperties properties = PublicIPAddressProperties.create(null, null, "Static", 4, null,
- DnsSettings.create("foobar", "foobar.northeurope.cloudapp.azure.com", null));
-
- PublicIPAddress ip = ipApi.createOrUpdate(publicIpName, location, tags, properties);
-
- String path = String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/publicIPAddresses/%s?%s", subscriptionid, resourcegroup, publicIpName, apiVersion);
- String json = String.format("{ \"location\": \"%s\", \"tags\": { \"testkey\": \"testvalue\" }, \"properties\": { \"publicIPAllocationMethod\": \"Static\", \"idleTimeoutInMinutes\": 4, \"dnsSettings\": { \"domainNameLabel\": \"foobar\", \"fqdn\": \"foobar.northeurope.cloudapp.azure.com\" } } }", location);
- assertSent(server, "PUT", path, json);
-
- assertNotNull(ip);
- assertEquals(ip.name(), "mypublicaddress");
- assertEquals(ip.location(), "northeurope");
- assertEquals(ip.id(), "/subscriptions/fakeb2f5-4710-4e93-bdf4-419edbde2178/resourceGroups/myresourcegroup/providers/Microsoft.Network/publicIPAddresses/mypublicaddress");
- assertEquals(ip.tags().get("testkey"), "testvalue");
- assertNotNull(ip.properties());
- assertEquals(ip.properties().provisioningState(), "Updating");
- assertNull(ip.properties().ipAddress()); // as we don't get IP address until Succeeded state
- assertEquals(ip.properties().publicIPAllocationMethod(), "Static");
- assertEquals(ip.properties().idleTimeoutInMinutes().intValue(), 4);
- assertNotNull(ip.properties().dnsSettings());
- assertEquals(ip.properties().dnsSettings().domainNameLabel(), "foobar");
- assertEquals(ip.properties().dnsSettings().fqdn(), "foobar.northeurope.cloudapp.azure.com");
- }
-
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void createPublicIPAddressDnsRecordInUse() throws IllegalArgumentException, InterruptedException {
-
- server.enqueue(jsonResponse("/PublicIPAddressCreateDnsRecordInUse.json").setStatus("HTTP/1.1 400 Bad Request"));
-
- final PublicIPAddressApi ipApi = api.getPublicIPAddressApi(resourcegroup);
-
- final Map<String, String> tags = ImmutableMap.of("testkey", "testvalue");
-
- PublicIPAddressProperties properties = PublicIPAddressProperties.create(null, null, "Static", 4, null,
- DnsSettings.create("foobar", "foobar.northeurope.cloudapp.azure.com", null));
-
- ipApi.createOrUpdate(publicIpName, location, tags, properties);
- }
-
- public void deletePublicIPAddress() throws InterruptedException {
-
- server.enqueue(response202());
-
- final PublicIPAddressApi ipApi = api.getPublicIPAddressApi(resourcegroup);
- boolean status = ipApi.delete(publicIpName);
-
- String path = String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/publicIPAddresses/%s?%s", subscriptionid, resourcegroup, publicIpName, apiVersion);
- assertSent(server, "DELETE", path);
-
- assertTrue(status);
- }
-
- public void deletePublicIPAddressResourceDoesNotExist() throws InterruptedException {
-
- server.enqueue(response204());
-
- final PublicIPAddressApi ipApi = api.getPublicIPAddressApi(resourcegroup);
- boolean status = ipApi.delete(publicIpName);
-
- String path = String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/publicIPAddresses/%s?%s", subscriptionid, resourcegroup, publicIpName, apiVersion);
- assertSent(server, "DELETE", path);
-
- assertFalse(status);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/ResourceGroupApiLiveTest.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/ResourceGroupApiLiveTest.java b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/ResourceGroupApiLiveTest.java
deleted file mode 100644
index 2dd8097..0000000
--- a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/ResourceGroupApiLiveTest.java
+++ /dev/null
@@ -1,112 +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.Resource;
-import org.jclouds.azurecompute.arm.domain.ResourceGroup;
-import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiLiveTest;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Predicate;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Iterables;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertTrue;
-
-@Test(groups = "live", testName = "ResourceGroupApiLiveTest")
-public class ResourceGroupApiLiveTest extends BaseAzureComputeApiLiveTest {
-
- private static final String RESOURCE_GROUP_NAME = "jcloudstest";
-
- private ResourceGroupApi api() {
- return api.getResourceGroupApi();
- }
-
- @Test(dependsOnMethods = "testCreate")
- public void testResources() {
- List<Resource> resources = api().resources(RESOURCE_GROUP_NAME);
- assertTrue(resources.isEmpty());
- for (Resource resource : resources) {
- assertNotNull(resource);
- }
- }
-
- @Test(dependsOnMethods = "testCreate")
- public void testList() {
- final List<ResourceGroup> resourceGroups = api().list();
-
- assertTrue(resourceGroups.size() > 0);
-
- assertTrue(Iterables.any(resourceGroups, new Predicate<ResourceGroup>() {
-
- @Override
- public boolean apply(final ResourceGroup group) {
- return RESOURCE_GROUP_NAME.equals(group.name());
- }
- }));
- }
-
- @Test(dependsOnMethods = "testCreate")
- public void testRead() {
- final ResourceGroup resourceGroup = api().get(RESOURCE_GROUP_NAME);
- assertNotNull(resourceGroup);
- assertEquals(resourceGroup.name(), RESOURCE_GROUP_NAME);
- assertEquals(resourceGroup.location(), LOCATION);
- }
-
- public void testCreate() {
- final ResourceGroup resourceGroup = api().create(RESOURCE_GROUP_NAME, LOCATION, null);
- assertEquals(resourceGroup.name(), RESOURCE_GROUP_NAME);
- assertEquals(resourceGroup.location(), LOCATION);
- assertNull(resourceGroup.tags());
- assertTrue(resourceGroup.id().contains(RESOURCE_GROUP_NAME));
- assertEquals(resourceGroup.properties().provisioningState(), "Succeeded");
- }
-
- @Test(dependsOnMethods = "testCreate")
- public void testUpdateWithEmptyTag() {
- ImmutableMap<String, String> tags = ImmutableMap.<String, String>builder().build();
-
- final ResourceGroup resourceGroup = api().update(RESOURCE_GROUP_NAME, tags);
-
- assertEquals(resourceGroup.tags().size(), 0);
- assertEquals(resourceGroup.properties().provisioningState(), "Succeeded");
- }
-
- @Test(dependsOnMethods = "testCreate")
- public void testUpdateWithTag() {
- ImmutableMap<String, String> tags = ImmutableMap.<String, String>builder().put("test1", "value1").build();
-
- final ResourceGroup resourceGroup = api().update(RESOURCE_GROUP_NAME, tags);
-
- assertEquals(resourceGroup.tags().size(), 1);
- assertEquals(resourceGroup.properties().provisioningState(), "Succeeded");
- }
-
- @AfterClass(alwaysRun = true)
- public void testDelete() throws Exception {
- URI uri = api().delete(RESOURCE_GROUP_NAME);
- assertResourceDeleted(uri);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/ResourceGroupApiMockTest.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/ResourceGroupApiMockTest.java b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/ResourceGroupApiMockTest.java
deleted file mode 100644
index acac271..0000000
--- a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/ResourceGroupApiMockTest.java
+++ /dev/null
@@ -1,173 +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.Resource;
-import org.jclouds.azurecompute.arm.domain.ResourceGroup;
-import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiMockTest;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableMap;
-
-import static com.google.common.collect.Iterables.isEmpty;
-import static com.google.common.collect.Iterables.size;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertTrue;
-
-@Test(groups = "unit", testName = "ResourceGroupApiMockTest", singleThreaded = true)
-public class ResourceGroupApiMockTest extends BaseAzureComputeApiMockTest {
-
- final String subscriptionid = "SUBSCRIPTIONID";
- final String requestUrl = "/subscriptions/" + subscriptionid + "/resourcegroups";
- final String version = "?api-version=2015-01-01";
-
- public void testListResourceGroups() throws InterruptedException {
- server.enqueue(jsonResponse("/resourcegroups.json"));
-
- List<ResourceGroup> resourceGroups = api.getResourceGroupApi().list();
-
- assertEquals(size(resourceGroups), 2);
-
- assertSent(server, "GET", requestUrl + version);
- }
-
- public void testListResourceGroupsReturns404() throws InterruptedException {
- server.enqueue(response404());
-
- List<ResourceGroup> resourceGroups = api.getResourceGroupApi().list();
-
- assertTrue(isEmpty(resourceGroups));
-
- assertEquals(server.getRequestCount(), 1);
- assertSent(server, "GET", requestUrl + version);
- }
-
- public void testCreateResourceGroup() throws InterruptedException {
- server.enqueue(jsonResponse("/resourcegroup.json").setStatus("HTTP/1.1 201 Created"));
-
- ImmutableMap<String, String> tags = ImmutableMap.<String, String>builder().put("tagname1", "tagvalue1").build();
-
- ResourceGroup resourceGroup = api.getResourceGroupApi().create("jcloudstest", "West US", tags);
-
- assertEquals(resourceGroup.name(), "jcloudstest");
- assertEquals(resourceGroup.location(), "westus");
- assertEquals(resourceGroup.tags().size(), 1);
- assertTrue(resourceGroup.id().contains("jcloudstest"));
-
- assertEquals(server.getRequestCount(), 1);
- assertSent(server, "PUT", requestUrl + "/jcloudstest" + version, String.format("{\"location\":\"%s\", \"tags\":{\"tagname1\":\"tagvalue1\"}}", "West US"));
- }
-
- public void testCreateResourceGroupWithNoTag() throws InterruptedException {
- server.enqueue(jsonResponse("/resourcegroup.json").setStatus("HTTP/1.1 201 Created"));
-
- ResourceGroup resourceGroup = api.getResourceGroupApi().create("jcloudstest", "West US", null);
-
- assertEquals(resourceGroup.name(), "jcloudstest");
- assertEquals(resourceGroup.location(), "westus");
- assertTrue(resourceGroup.id().contains("jcloudstest"));
-
- assertEquals(server.getRequestCount(), 1);
- assertSent(server, "PUT", requestUrl + "/jcloudstest" + version, String.format("{\"location\":\"%s\"}", "West US"));
- }
-
- public void testGetResourceGroup() throws InterruptedException {
- server.enqueue(jsonResponse("/resourcegroup.json"));
-
- ResourceGroup resourceGroup = api.getResourceGroupApi().get("jcloudstest");
-
- assertEquals(resourceGroup.name(), "jcloudstest");
-
- assertEquals(server.getRequestCount(), 1);
- assertSent(server, "GET", requestUrl + "/jcloudstest" + version);
- }
-
- public void testGetResourceGroupReturns404() throws InterruptedException {
- server.enqueue(response404());
-
- ResourceGroup resourceGroup = api.getResourceGroupApi().get("jcloudstest");
-
- assertNull(resourceGroup);
-
- assertEquals(server.getRequestCount(), 1);
- assertSent(server, "GET", requestUrl + "/jcloudstest" + version);
- }
-
- public void testUpdateResourceGroupTags() throws InterruptedException {
- server.enqueue(jsonResponse("/resourcegroupupdated.json"));
-
- ImmutableMap<String, String> tags = ImmutableMap.<String, String>builder().build();
-
- ResourceGroup resourceGroup = api.getResourceGroupApi().update("jcloudstest", tags);
-
-
- assertEquals(resourceGroup.tags().size(), 0);
- assertEquals(resourceGroup.properties().provisioningState(), "Succeeded");
-
- assertEquals(server.getRequestCount(), 1);
- assertSent(server, "PATCH", requestUrl + "/jcloudstest" + version, "{\"tags\":{}}");
- }
-
- public void testDeleteResourceGroup() throws InterruptedException {
- server.enqueue(response202WithHeader());
-
- URI uri = api.getResourceGroupApi().delete("jcloudstest");
-
- assertEquals(server.getRequestCount(), 1);
- assertSent(server, "DELETE", requestUrl + "/jcloudstest" + version);
- assertNotNull(uri);
-
- assertTrue(uri.toString().contains("api-version"));
- assertTrue(uri.toString().contains("operationresults"));
- }
-
- public void testDeleteResourceGroupReturns404() throws InterruptedException {
- server.enqueue(response404());
-
- URI uri = api.getResourceGroupApi().delete("jcloudstest");
- assertNull(uri);
- assertEquals(server.getRequestCount(), 1);
- assertSent(server, "DELETE", requestUrl + "/jcloudstest" + version);
- }
-
- public void testListResourceGroupResources() throws InterruptedException {
- server.enqueue(jsonResponse("/resourcegroup-resources.json"));
-
- List<Resource> resources = api.getResourceGroupApi().resources("jcloudstest");
-
- assertEquals(size(resources), 6);
-
- assertSent(server, "GET", requestUrl + "/jcloudstest/resources" + version);
- }
-
- public void testListResourceGroupResourcesReturns404() throws InterruptedException {
- server.enqueue(response404());
-
- List<Resource> resources = api.getResourceGroupApi().resources("jcloudstest");
-
- assertTrue(isEmpty(resources));
-
- assertEquals(server.getRequestCount(), 1);
- assertSent(server, "GET", requestUrl + "/jcloudstest/resources" + version);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/ResourceProviderAPIMockTest.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/ResourceProviderAPIMockTest.java b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/ResourceProviderAPIMockTest.java
deleted file mode 100644
index 3c90d42..0000000
--- a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/ResourceProviderAPIMockTest.java
+++ /dev/null
@@ -1,66 +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.ResourceProviderMetaData;
-import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiMockTest;
-import org.testng.annotations.Test;
-
-import java.util.List;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertTrue;
-
-@Test(groups = "unit", testName = "NetworkInterfaceCardApiMockTest", singleThreaded = true)
-public class ResourceProviderAPIMockTest extends BaseAzureComputeApiMockTest {
-
- final String apiVersion = "2015-01-01";
- final String resource = "Microsoft.Compute";
-
- public void getPublicIPAddressInfo() throws InterruptedException {
- server.enqueue(jsonResponse("/getresourceprovidermetadata.json"));
-
- final ResourceProviderApi resourceProviderApi = api.getResourceProviderApi();
-
- List<ResourceProviderMetaData> metaDatas = resourceProviderApi.get(resource);
-
- String path = String.format("/subscriptions/SUBSCRIPTIONID/providers/%s?api-version=%s", resource, apiVersion);
-
- assertSent(server, "GET", path);
- assertTrue(metaDatas.size() > 0);
- ResourceProviderMetaData md = metaDatas.get(0);
-
- assertEquals(md.resourceType(), "availabilitySets");
- assertEquals(md.locations().get(0), "East US");
- assertEquals(md.apiVersions().get(0), "2016-03-30");
- }
-
- public void getPublicIPAddressInfoEmpty() throws InterruptedException {
- server.enqueue(response404());
-
- final ResourceProviderApi resourceProviderApi = api.getResourceProviderApi();
-
- List<ResourceProviderMetaData> metaDatas = resourceProviderApi.get(resource);
-
- String path = String.format("/subscriptions/SUBSCRIPTIONID/providers/%s?api-version=%s", resource, apiVersion);
-
- assertSent(server, "GET", path);
- assertNull(metaDatas);
- }
-}
-
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/ResourceProviderApiLiveTest.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/ResourceProviderApiLiveTest.java b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/ResourceProviderApiLiveTest.java
deleted file mode 100644
index 59ca114..0000000
--- a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/ResourceProviderApiLiveTest.java
+++ /dev/null
@@ -1,55 +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.util.List;
-
-import org.jclouds.azurecompute.arm.domain.ResourceProviderMetaData;
-import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiLiveTest;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterables;
-
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
-
-@Test(groups = "live", testName = "ResourceProviderApiLiveTest")
-public class ResourceProviderApiLiveTest extends BaseAzureComputeApiLiveTest {
-
- private final String PROVIDER = "Microsoft.Compute";
- private final String VM_RESOURCE_TYPE = "virtualMachines";
-
- private ResourceProviderApi api() {
- return api.getResourceProviderApi();
- }
-
- @Test
- public void testGetComputeProviderMetadata() {
-
- List<ResourceProviderMetaData> resourceProviderMetaDatas = api().get(PROVIDER);
-
- assertNotNull(resourceProviderMetaDatas);
-
- assertTrue(Iterables.any(resourceProviderMetaDatas, new Predicate<ResourceProviderMetaData>() {
- @Override
- public boolean apply(final ResourceProviderMetaData providerMetaData) {
- return providerMetaData.resourceType().equals(VM_RESOURCE_TYPE);
- }
- }));
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/StorageAccountApiLiveTest.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/StorageAccountApiLiveTest.java b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/StorageAccountApiLiveTest.java
deleted file mode 100644
index d01a972..0000000
--- a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/StorageAccountApiLiveTest.java
+++ /dev/null
@@ -1,143 +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 static org.testng.Assert.assertFalse;
-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.StorageService;
-import org.jclouds.azurecompute.arm.domain.StorageServiceKeys;
-import org.jclouds.azurecompute.arm.domain.StorageServiceUpdateParams;
-import org.jclouds.azurecompute.arm.functions.ParseJobStatus;
-import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiLiveTest;
-import org.jclouds.util.Predicates2;
-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 = "StorageAccountApiLiveTest")
-public class StorageAccountApiLiveTest extends BaseAzureComputeApiLiveTest {
-
- private static final String NAME = String.format("%3.24s",
- RAND + StorageAccountApiLiveTest.class.getSimpleName().toLowerCase());
-
- @BeforeClass
- @Override
- public void setup() {
- super.setup();
- createTestResourceGroup();
- }
-
- @Test(dependsOnMethods = "testCreate")
- public void testList() {
- List<StorageService> storages = api().list();
- assertTrue(storages.size() > 0);
- for (StorageService storage : storages) {
- check(storage);
- }
- }
-
- @Test()
- public void testIsAvailable() {
- assertTrue(api().isAvailable(NAME).nameAvailable().equals("true"));
- }
-
- @Test(dependsOnMethods = "testIsAvailable")
- public void testCreate() {
- URI uri = api().create(NAME, LOCATION, ImmutableMap.of("property_name",
- "property_value"), ImmutableMap.of("accountType", StorageService.AccountType.Standard_LRS.toString()));
- if (uri != null){
- assertTrue(uri.toString().contains("api-version"));
-
- boolean jobDone = Predicates2.retry(new Predicate<URI>() {
- @Override public boolean apply(URI uri) {
- return ParseJobStatus.JobStatus.DONE == api.getJobApi().jobStatus(uri);
- }
- }, 60 * 1 * 1000 /* 1 minute timeout */).apply(uri);
- assertTrue(jobDone, "create operation did not complete in the configured timeout");
- }
- final StorageService service = api().get(NAME);
- assertNotNull(service);
- assertEquals(service.location(), LOCATION);
- assertNotNull(service.storageServiceProperties().creationTime());
- }
-
- @Test(dependsOnMethods = "testCreate")
- public void testGet() {
- final StorageService service = api().get(NAME);
- assertNotNull(service);
- assertEquals(service.name(), NAME);
- assertEquals(service.storageServiceProperties().primaryLocation(), LOCATION);
- assertEquals(service.storageServiceProperties().accountType(), StorageService.AccountType.Standard_LRS);
- }
-
- @Test(dependsOnMethods = "testCreate")
- public void testGetKeys() {
- final StorageServiceKeys keys = api().getKeys(NAME);
- assertNotNull(keys);
- assertNotNull(keys.key1());
- assertNotNull(keys.key2());
- }
-
- @Test(dependsOnMethods = "testCreate")
- public void testRegenerateKeys() {
- StorageServiceKeys keys = api().regenerateKeys(NAME, "key1");
- assertFalse(keys.key1().isEmpty());
- assertFalse(keys.key2().isEmpty());
- }
-
- @Test(dependsOnMethods = "testCreate")
- public void testUpdateTags() {
- StorageServiceUpdateParams.StorageServiceUpdateProperties props =
- StorageServiceUpdateParams.StorageServiceUpdateProperties.create(null);
- final StorageServiceUpdateParams params = api().update(NAME,
- ImmutableMap.of("another_property_name", "another_property_value"), props);
- assertTrue(params.tags().containsKey("another_property_name"));
- assertNull(params.storageServiceProperties().accountType());
- }
-
- @Test(dependsOnMethods = {"testCreate", "testGet"})
- public void testUpdateAccountType() {
- StorageServiceUpdateParams.StorageServiceUpdateProperties props =
- StorageServiceUpdateParams.StorageServiceUpdateProperties.create(StorageService.AccountType.Standard_GRS);
- final StorageServiceUpdateParams params = api().update(NAME,
- null, props);
- assertNull(params.tags());
- assertEquals(params.storageServiceProperties().accountType(), StorageService.AccountType.Standard_GRS);
- }
-
- private void check(final StorageService storage) {
- assertNotNull(storage.id());
- assertNotNull(storage.name());
- assertNotNull(storage.storageServiceProperties());
- assertNotNull(storage.storageServiceProperties().accountType());
- assertFalse(storage.storageServiceProperties().primaryEndpoints().isEmpty());
- assertNotNull(storage.storageServiceProperties().creationTime());
- }
-
- private StorageAccountApi api() {
- return api.getStorageAccountApi(resourceGroupName);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/StorageAccountApiMockTest.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/StorageAccountApiMockTest.java b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/StorageAccountApiMockTest.java
deleted file mode 100644
index e3fdf6d..0000000
--- a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/StorageAccountApiMockTest.java
+++ /dev/null
@@ -1,312 +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 com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-
-import org.jclouds.azurecompute.arm.domain.StorageService;
-import org.jclouds.azurecompute.arm.domain.Availability;
-import org.jclouds.azurecompute.arm.domain.StorageServiceKeys;
-import org.jclouds.azurecompute.arm.domain.StorageServiceUpdateParams;
-import com.squareup.okhttp.mockwebserver.MockResponse;
-import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiMockTest;
-import org.jclouds.date.DateService;
-import org.jclouds.date.internal.SimpleDateFormatDateService;
-import org.testng.annotations.Test;
-
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static com.google.common.collect.Iterables.isEmpty;
-
-import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertFalse;
-
-
-@Test(groups = "unit", testName = "StorageAccountApiMockTest", singleThreaded = true)
-public class StorageAccountApiMockTest extends BaseAzureComputeApiMockTest {
-
- private String subsriptionId = "SUBSCRIPTIONID";
- private String resourceGroup = "resourceGroup";
-
- public void testList() throws Exception {
- server.enqueue(jsonResponse("/storageAccounts.json"));
-
- final StorageAccountApi storageAPI = api.getStorageAccountApi(resourceGroup);
-
- List<StorageService> list = storageAPI.list();
- assertEquals(list, expected());
-
- assertSent(server, "GET", "/subscriptions/" + subsriptionId +
- "/resourcegroups/resourceGroup/providers/Microsoft.Storage/storageAccounts?api-version=2015-06-15");
- }
-
- public void testListReturns404() throws InterruptedException {
- server.enqueue(response404());
-
- final StorageAccountApi storageAPI = api.getStorageAccountApi(resourceGroup);
-
- List<StorageService> list = storageAPI.list();
-
- assertTrue(isEmpty(list));
-
- assertEquals(server.getRequestCount(), 1);
- assertSent(server, "GET", "/subscriptions/" + subsriptionId +
- "/resourcegroups/resourceGroup/providers/Microsoft.Storage/storageAccounts?api-version=2015-06-15");
- }
-
- public void testCreate() throws Exception {
- final StorageAccountApi storageAPI = api.getStorageAccountApi(resourceGroup);
-
- server.enqueue(response202WithHeader());
-
- URI uri = storageAPI.create("name-of-storage-account", "westus",
- ImmutableMap.of("property_name", "property_value"),
- ImmutableMap.of("accountType", StorageService.AccountType.Premium_LRS.toString()));
- assertNotNull(uri);
-
- assertSent(server, "PUT", "/subscriptions/" + subsriptionId +
- "/resourcegroups/resourceGroup/providers/Microsoft.Storage/" +
- "storageAccounts/name-of-storage-account?api-version=2015-06-15", String.format("{\"location\":\"westus\",\"tags\":{\"property_name\":\"property_value\"},\"properties\":{\"accountType\":\"Premium_LRS\"}}"));
- }
-
- public void testCreateWithNullTag() throws Exception {
- final StorageAccountApi storageAPI = api.getStorageAccountApi(resourceGroup);
-
- server.enqueue(response202WithHeader());
-
- URI uri = storageAPI.create("name-of-storage-account", "westus",
- null,
- ImmutableMap.of("accountType", StorageService.AccountType.Premium_LRS.toString()));
- assertNotNull(uri);
-
- assertSent(server, "PUT", "/subscriptions/" + subsriptionId +
- "/resourcegroups/resourceGroup/providers/Microsoft.Storage/" +
- "storageAccounts/name-of-storage-account?api-version=2015-06-15", String.format("{\"location\":\"westus\",\"properties\":{\"accountType\":\"Premium_LRS\"}}"));
- }
-
- public void testIsAvailable() throws Exception {
- server.enqueue(jsonResponse("/isavailablestorageservice.json"));
-
- final StorageAccountApi storageAPI = api.getStorageAccountApi(resourceGroup);
-
- assertEquals(storageAPI.isAvailable("TESTSTORAGE"),
- Availability.create("true"));
-
- assertSent(server, "POST", "/subscriptions/" + subsriptionId +
- "/providers/Microsoft.Storage/checkNameAvailability?api-version=2015-06-15", String.format("{\"name\":\"TESTSTORAGE\",\"type\":\"Microsoft.Storage/storageAccounts\"}"));
- }
-
- public void testGet() throws Exception {
- server.enqueue(jsonResponse("/storageservices.json"));
-
- final StorageAccountApi storageAPI = api.getStorageAccountApi(resourceGroup);
-
- assertEquals(storageAPI.get("TESTSTORAGE"), expected().get(0));
-
- assertSent(server, "GET", "/subscriptions/" + subsriptionId + "/resourcegroups/" + resourceGroup +
- "/providers/Microsoft.Storage/storageAccounts/TESTSTORAGE?api-version=2015-06-15");
- }
-
- public void testNullGet() throws Exception {
- server.enqueue(new MockResponse().setResponseCode(404));
-
- final StorageAccountApi storageAPI = api.getStorageAccountApi(resourceGroup);
-
- assertNull(storageAPI.get("TESTSTORAGE"));
-
- assertSent(server, "GET", "/subscriptions/" + subsriptionId + "/resourcegroups/" + resourceGroup +
- "/providers/Microsoft.Storage/storageAccounts/TESTSTORAGE?api-version=2015-06-15");
- }
-
- public void testGetKeys() throws Exception {
- server.enqueue(jsonResponse("/storageaccountkeys.json"));
-
- final StorageAccountApi storageAPI = api.getStorageAccountApi(resourceGroup);
-
- assertEquals(storageAPI.getKeys("TESTSTORAGE"), StorageServiceKeys.create(
- "bndO7lydwDkMo4Y0mFvmfLyi2f9aZY7bwfAVWoJWv4mOVK6E9c/exLnFsSm/NMWgifLCfxC/c6QBTbdEvWUA7w==",
- "/jMLLT3kKqY4K+cUtJTbh7pCBdvG9EMKJxUvaJJAf6W6aUiZe1A1ulXHcibrqRVA2RJE0oUeXQGXLYJ2l85L7A=="));
-
- assertSent(server, "POST", "/subscriptions/" + subsriptionId + "/resourcegroups/" + resourceGroup +
- "/providers/Microsoft.Storage/storageAccounts/TESTSTORAGE/listKeys?api-version=2015-06-15");
- }
-
- public void testNullGetKeys() throws Exception {
- server.enqueue(new MockResponse().setResponseCode(404));
-
- final StorageAccountApi storageAPI = api.getStorageAccountApi(resourceGroup);
-
- assertNull(storageAPI.getKeys("TESTSTORAGE"));
-
- assertSent(server, "POST", "/subscriptions/" + subsriptionId + "/resourcegroups/" + resourceGroup +
- "/providers/Microsoft.Storage/storageAccounts/TESTSTORAGE/listKeys?api-version=2015-06-15");
- }
-
- public void testRegenerateKeys() throws Exception {
- server.enqueue(jsonResponse("/storageaccountkeys.json"));
-
- final StorageAccountApi storageAPI = api.getStorageAccountApi(resourceGroup);
-
- assertEquals(storageAPI.regenerateKeys("TESTSTORAGE", "key1"), StorageServiceKeys.create(
- "bndO7lydwDkMo4Y0mFvmfLyi2f9aZY7bwfAVWoJWv4mOVK6E9c/exLnFsSm/NMWgifLCfxC/c6QBTbdEvWUA7w==",
- "/jMLLT3kKqY4K+cUtJTbh7pCBdvG9EMKJxUvaJJAf6W6aUiZe1A1ulXHcibrqRVA2RJE0oUeXQGXLYJ2l85L7A=="));
-
- assertSent(server, "POST", "/subscriptions/" + subsriptionId + "/resourcegroups/" + resourceGroup +
- "/providers/Microsoft.Storage/storageAccounts/TESTSTORAGE/regenerateKey?api-version=2015-06-15", String.format("{\"keyName\":\"key1\"}"));
- }
-
- public void testUpdate() throws Exception {
- server.enqueue(jsonResponse("/storageaccountupdate.json"));
-
- final StorageAccountApi storageAPI = api.getStorageAccountApi(resourceGroup);
-
- StorageServiceUpdateParams.StorageServiceUpdateProperties props =
- StorageServiceUpdateParams.StorageServiceUpdateProperties.create(StorageService.AccountType.Standard_LRS);
-
- final StorageServiceUpdateParams params = storageAPI.update("TESTSTORAGE",
- ImmutableMap.of("another_property_name", "another_property_value"), props);
-
- assertTrue(params.tags().containsKey("another_property_name"));
-
- assertSent(server, "PATCH", "/subscriptions/" + subsriptionId + "/resourcegroups/" + resourceGroup +
- "/providers/Microsoft.Storage/storageAccounts/TESTSTORAGE?api-version=2015-06-15", String.format("{\"properties\":{ \"accountType\": \"Standard_LRS\" },\"tags\":{\"another_property_name\":\"another_property_value\"}}"));
- }
-
- public void testUpdateWithNullTagAndNullProperty() throws Exception {
- server.enqueue(jsonResponse("/storageaccountupdate.json"));
-
- final StorageAccountApi storageAPI = api.getStorageAccountApi(resourceGroup);
-
- StorageServiceUpdateParams.StorageServiceUpdateProperties props =
- StorageServiceUpdateParams.StorageServiceUpdateProperties.create(null);
-
- final StorageServiceUpdateParams params = storageAPI.update("TESTSTORAGE", null, props);
-
- assertTrue(params.tags().containsKey("another_property_name"));
-
- assertSent(server, "PATCH", "/subscriptions/" + subsriptionId + "/resourcegroups/" + resourceGroup +
- "/providers/Microsoft.Storage/storageAccounts/TESTSTORAGE?api-version=2015-06-15", String.format("{\"properties\":{}}"));
- }
-
- public void testDelete() throws Exception {
- server.enqueue(new MockResponse().setResponseCode(200));
-
- final StorageAccountApi storageAPI = api.getStorageAccountApi(resourceGroup);
-
- boolean status = storageAPI.delete("TESTSTORAGE");
- assertTrue(status);
-
- assertSent(server, "DELETE", "/subscriptions/" + subsriptionId + "/resourcegroups/" + resourceGroup +
- "/providers/Microsoft.Storage/storageAccounts/TESTSTORAGE?api-version=2015-06-15");
- }
-
- public void testDelete204() throws Exception {
-
- server.enqueue(new MockResponse().setResponseCode(204));
-
- final StorageAccountApi storageAPI = api.getStorageAccountApi(resourceGroup);
-
- boolean status = storageAPI.delete("TESTSTORAGE");
- assertFalse(status);
-
- assertSent(server, "DELETE", "/subscriptions/" + subsriptionId + "/resourcegroups/" + resourceGroup +
- "/providers/Microsoft.Storage/storageAccounts/TESTSTORAGE?api-version=2015-06-15");
- }
-
- private List<StorageService> expected() throws MalformedURLException {
- DateService DATE_SERVICE = new SimpleDateFormatDateService();
- Map<String, String> endpoints = new HashMap<String, String>();
- endpoints.put("blob", "https://TESTSTORAGE.blob.core.windows.net/");
- endpoints.put("file", "https://TESTSTORAGE.file.core.windows.net/");
- endpoints.put("queue", "https://TESTSTORAGE.queue.core.windows.net/");
- endpoints.put("table", "https://TESTSTORAGE.table.core.windows.net/");
- Map<String, String> secondaryEndpoints = new HashMap<String, String>();
- secondaryEndpoints.put("blob", "https://TESTSTORAGE-secondary.blob.core.windows.net/");
- secondaryEndpoints.put("queue", "https://TESTSTORAGE-secondary.queue.core.windows.net/");
- secondaryEndpoints.put("table", "https://TESTSTORAGE-secondary.table.core.windows.net/");
- Map<String, String> endpoints2 = new HashMap<String, String>();
- endpoints2.put("blob", "https://TESTSTORAGE2.blob.core.windows.net/");
- endpoints2.put("file", "https://TESTSTORAGE2.file.core.windows.net/");
- endpoints2.put("queue", "https://TESTSTORAGE2.queue.core.windows.net/");
- endpoints2.put("table", "https://TESTSTORAGE2.table.core.windows.net/");
- Map<String, String> secondaryEndpoints2 = new HashMap<String, String>();
- secondaryEndpoints2.put("blob", "https://TESTSTORAGE2-secondary.blob.core.windows.net/");
- secondaryEndpoints2.put("queue", "https://TESTSTORAGE2-secondary.queue.core.windows.net/");
- secondaryEndpoints2.put("table", "https://TESTSTORAGE2-secondary.table.core.windows.net/");
- Map<String, String> endpoints3 = new HashMap<String, String>();
- endpoints3.put("blob", "https://TESTSTORAGE3.blob.core.windows.net/");
- endpoints3.put("file", "https://TESTSTORAGE3.file.core.windows.net/");
- endpoints3.put("queue", "https://TESTSTORAGE3.queue.core.windows.net/");
- endpoints3.put("table", "https://TESTSTORAGE3.table.core.windows.net/");
- Map<String, String> secondaryEndpoints3 = new HashMap<String, String>();
- secondaryEndpoints3.put("blob", "https://TESTSTORAGE3-secondary.blob.core.windows.net/");
- secondaryEndpoints3.put("queue", "https://TESTSTORAGE3-secondary.queue.core.windows.net/");
- secondaryEndpoints3.put("table", "https://TESTSTORAGE3-secondary.table.core.windows.net/");
-
-
- String location = "westus";
- String secondaryLocation = "eastus";
- final StorageService.StorageServiceProperties props = StorageService.StorageServiceProperties.create(
- StorageService.AccountType.Standard_RAGRS,
- DATE_SERVICE.iso8601DateOrSecondsDateParse("2016-02-24T13:04:45.0890883Z"),
- endpoints,
- location,
- StorageService.Status.Succeeded, secondaryEndpoints, secondaryLocation,
- StorageService.RegionStatus.Available,
- StorageService.RegionStatus.Available);
- final StorageService.StorageServiceProperties props2 = StorageService.StorageServiceProperties.create(
- StorageService.AccountType.Standard_RAGRS,
- DATE_SERVICE.iso8601DateOrSecondsDateParse("2016-02-24T13:11:43.8265672Z"),
- endpoints2, location,
- StorageService.Status.Succeeded, secondaryEndpoints2, secondaryLocation,
- StorageService.RegionStatus.Available,
- StorageService.RegionStatus.Available);
- final StorageService.StorageServiceProperties props3 = StorageService.StorageServiceProperties.create(
- StorageService.AccountType.Standard_RAGRS,
- DATE_SERVICE.iso8601DateOrSecondsDateParse("2016-02-24T14:12:59.5223315Z"),
- endpoints3, location,
- StorageService.Status.Succeeded, secondaryEndpoints3, secondaryLocation,
- StorageService.RegionStatus.Available,
- StorageService.RegionStatus.Available);
-
- final Map<String, String> tags = ImmutableMap.of(
- "key1", "value1",
- "key2", "value2");
-
- return ImmutableList.of(StorageService.create(
- "/subscriptions/SUBSCRIPTIONID/resourceGroups/resourceGroup/" +
- "providers/Microsoft.Storage/storageAccounts/TESTSTORAGE",
- "TESTSTORAGE", location, tags, "Microsoft.Storage/storageAccounts", props),
- StorageService.create(
- "/subscriptions/SUBSCRIPTIONID/resourceGroups/resourceGroup/" +
- "providers/Microsoft.Storage/storageAccounts/TESTSTORAGE2",
- "TESTSTORAGE2", location, tags, "Microsoft.Storage/storageAccounts", props2),
- StorageService.create(
- "/subscriptions/SUBSCRIPTIONID/resourceGroups/resourceGroup/" +
- "providers/Microsoft.Storage/storageAccounts/TESTSTORAGE3",
- "TESTSTORAGE3", location, tags, "Microsoft.Storage/storageAccounts", props3));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/SubnetApiLiveTest.java
----------------------------------------------------------------------
diff --git a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/SubnetApiLiveTest.java b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/SubnetApiLiveTest.java
deleted file mode 100644
index 8144001..0000000
--- a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/SubnetApiLiveTest.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.azurecompute.arm.features;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
-
-import java.util.List;
-
-import org.jclouds.azurecompute.arm.domain.Subnet;
-import org.jclouds.azurecompute.arm.domain.VirtualNetwork;
-import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiLiveTest;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-@Test(groups = "live", singleThreaded = true)
-public class SubnetApiLiveTest extends BaseAzureComputeApiLiveTest {
-
- private String virtualNetworkName;
- private String subnetName;
-
- @BeforeClass
- @Override
- public void setup() {
- super.setup();
- createTestResourceGroup();
- virtualNetworkName = String.format("vn-%s-%s", this.getClass().getSimpleName().toLowerCase(),
- System.getProperty("user.name"));
- subnetName = "jclouds-" + RAND;
-
- // Subnets belong to a virtual network so that needs to be created first
- // VN will be deleted when resource group is deleted
- VirtualNetwork vn = createDefaultVirtualNetwork(resourceGroupName, virtualNetworkName, "10.2.0.0/16", LOCATION);
- assertNotNull(vn);
- }
-
- @Test
- public void deleteSubnetResourceDoesNotExist() {
- assertFalse(api().delete(subnetName));
- }
-
- @Test(dependsOnMethods = "deleteSubnetResourceDoesNotExist")
- public void createSubnet() {
- //Create properties object
- //addressPrefix must match Virtual network address space!
- Subnet.SubnetProperties properties = Subnet.SubnetProperties.builder().addressPrefix("10.2.0.0/23").build();
-
- Subnet subnet = api().createOrUpdate(subnetName, properties);
-
- assertEquals(subnet.name(), subnetName);
- assertEquals(subnet.properties().addressPrefix(), "10.2.0.0/23");
- }
-
- @Test(dependsOnMethods = "createSubnet")
- public void getSubnet() {
- Subnet subnet = api().get(subnetName);
- assertNotNull(subnet.name());
- assertNotNull(subnet.properties().addressPrefix());
- }
-
- @Test(dependsOnMethods = "createSubnet")
- public void listSubnets() {
- List<Subnet> subnets = api().list();
- assertTrue(subnets.size() > 0);
- }
-
- @Test(dependsOnMethods = {"listSubnets", "getSubnet"}, alwaysRun = true)
- public void deleteSubnet() {
- boolean status = api().delete(subnetName);
- assertTrue(status);
- }
-
- private SubnetApi api() {
- return api.getSubnetApi(resourceGroupName, virtualNetworkName);
- }
-
-}