http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/eb990020/azurecompute/src/test/java/org/jclouds/azurecompute/features/NetworkSecurityGroupApiMockTest.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/NetworkSecurityGroupApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/NetworkSecurityGroupApiMockTest.java deleted file mode 100644 index 3a1bd54..0000000 --- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/NetworkSecurityGroupApiMockTest.java +++ /dev/null @@ -1,277 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azurecompute.features; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.assertNull; - -import org.jclouds.azurecompute.internal.BaseAzureComputeApiMockTest; -import org.testng.annotations.Test; - -import com.squareup.okhttp.mockwebserver.MockResponse; -import com.squareup.okhttp.mockwebserver.MockWebServer; - -import org.jclouds.azurecompute.domain.NetworkSecurityGroup; -import org.jclouds.azurecompute.domain.Rule; -import org.jclouds.azurecompute.xml.ListNetworkSecurityGroupsHandlerTest; -import org.jclouds.azurecompute.xml.NetworkSecurityGroupHandlerTest; - -@Test(groups = "unit", testName = "NetworkSecurityGroupApiMockTest") -public class NetworkSecurityGroupApiMockTest extends BaseAzureComputeApiMockTest { - - public void list() throws Exception { - final MockWebServer server = mockAzureManagementServer(); - server.enqueue(xmlResponse("/networksecuritygroups.xml")); - - try { - final NetworkSecurityGroupApi api = networkSecurityGroupApi(server); - assertEquals(api.list(), ListNetworkSecurityGroupsHandlerTest.expected()); - assertSent(server, "GET", "/services/networking/networksecuritygroups"); - } finally { - server.shutdown(); - } - } - - public void listWhenNotFound() throws Exception { - final MockWebServer server = mockAzureManagementServer(); - server.enqueue(new MockResponse().setResponseCode(404)); - - try { - final NetworkSecurityGroupApi api = networkSecurityGroupApi(server); - assertTrue(api.list().isEmpty()); - assertSent(server, "GET", "/services/networking/networksecuritygroups"); - } finally { - server.shutdown(); - } - } - - public void getFullDetails() throws Exception { - final MockWebServer server = mockAzureManagementServer(); - server.enqueue(xmlResponse("/networksecuritygroupfulldetails.xml")); - - try { - final NetworkSecurityGroupApi api = networkSecurityGroupApi(server); - assertEquals(api.getFullDetails("jclouds-NSG"), NetworkSecurityGroupHandlerTest.expectedFull()); - assertSent(server, "GET", "/services/networking/networksecuritygroups/jclouds-NSG?detaillevel=Full"); - } finally { - server.shutdown(); - } - } - - public void getFullDetailsWhenNotFound() throws Exception { - final MockWebServer server = mockAzureManagementServer(); - server.enqueue(new MockResponse().setResponseCode(404)); - - try { - final NetworkSecurityGroupApi api = networkSecurityGroupApi(server); - assertNull(api.getFullDetails("jclouds-NSG")); - assertSent(server, "GET", "/services/networking/networksecuritygroups/jclouds-NSG?detaillevel=Full"); - } finally { - server.shutdown(); - } - } - - public void get() throws Exception { - final MockWebServer server = mockAzureManagementServer(); - server.enqueue(xmlResponse("/networksecuritygroup.xml")); - - try { - final NetworkSecurityGroupApi api = networkSecurityGroupApi(server); - assertEquals(api.get("group1"), NetworkSecurityGroupHandlerTest.expected()); - assertSent(server, "GET", "/services/networking/networksecuritygroups/group1"); - } finally { - server.shutdown(); - } - } - - public void getWhenNotFound() throws Exception { - final MockWebServer server = mockAzureManagementServer(); - server.enqueue(new MockResponse().setResponseCode(404)); - - try { - final NetworkSecurityGroupApi api = networkSecurityGroupApi(server); - assertNull(api.get("group1")); - assertSent(server, "GET", "/services/networking/networksecuritygroups/group1"); - } finally { - server.shutdown(); - } - } - - public void getNetworkSecurityGroupAppliedToSubnet() throws Exception { - final MockWebServer server = mockAzureManagementServer(); - server.enqueue(xmlResponse("/networksecuritygroupforsubnet.xml")); - - try { - final NetworkSecurityGroupApi api = networkSecurityGroupApi(server); - assertEquals(api.getNetworkSecurityGroupAppliedToSubnet("myvn", "mysubnet"), - NetworkSecurityGroupHandlerTest.expectedForSubnet()); - assertSent(server, "GET", "/services/networking/virtualnetwork/myvn/subnets/mysubnet/networksecuritygroups"); - } finally { - server.shutdown(); - } - } - - public void getNetworkSecurityGroupAppliedToSubnetWhenNotFound() throws Exception { - final MockWebServer server = mockAzureManagementServer(); - server.enqueue(new MockResponse().setResponseCode(404)); - - try { - final NetworkSecurityGroupApi api = networkSecurityGroupApi(server); - assertNull(api.getNetworkSecurityGroupAppliedToSubnet("myvn", "mysubnet")); - assertSent(server, "GET", "/services/networking/virtualnetwork/myvn/subnets/mysubnet/networksecuritygroups"); - } finally { - server.shutdown(); - } - } - - public void deleteGroup() throws Exception { - MockWebServer server = mockAzureManagementServer(); - server.enqueue(requestIdResponse("request-1")); - - try { - final NetworkSecurityGroupApi api = networkSecurityGroupApi(server); - assertEquals(api.delete("mygroup"), "request-1"); - assertSent(server, "DELETE", "/services/networking/networksecuritygroups/mygroup"); - } finally { - server.shutdown(); - } - } - - public void deleteGroupWhenNotFound() throws Exception { - MockWebServer server = mockAzureManagementServer(); - server.enqueue(new MockResponse().setResponseCode(404)); - - try { - final NetworkSecurityGroupApi api = networkSecurityGroupApi(server); - assertNull(api.delete("mygroup")); - assertSent(server, "DELETE", "/services/networking/networksecuritygroups/mygroup"); - } finally { - server.shutdown(); - } - } - - public void deleteRule() throws Exception { - MockWebServer server = mockAzureManagementServer(); - server.enqueue(requestIdResponse("request-1")); - - try { - final NetworkSecurityGroupApi api = networkSecurityGroupApi(server); - assertEquals(api.deleteRule("mygroup", "myrule"), "request-1"); - assertSent(server, "DELETE", "/services/networking/networksecuritygroups/mygroup/rules/myrule"); - } finally { - server.shutdown(); - } - } - - public void deleteRuleWhenNotFound() throws Exception { - MockWebServer server = mockAzureManagementServer(); - server.enqueue(new MockResponse().setResponseCode(404)); - - try { - final NetworkSecurityGroupApi api = networkSecurityGroupApi(server); - assertNull(api.deleteRule("mygroup", "myrule")); - assertSent(server, "DELETE", "/services/networking/networksecuritygroups/mygroup/rules/myrule"); - } finally { - server.shutdown(); - } - } - - public void removeFromSubnet() throws Exception { - MockWebServer server = mockAzureManagementServer(); - server.enqueue(requestIdResponse("request-1")); - - try { - final NetworkSecurityGroupApi api = networkSecurityGroupApi(server); - assertEquals(api.removeFromSubnet("myvn", "mysubnet", "mygroup"), "request-1"); - assertSent(server, "DELETE", - "/services/networking/virtualnetwork/myvn/subnets/mysubnet/networksecuritygroups/mygroup"); - } finally { - server.shutdown(); - } - } - - public void removeFromSubnetWhenNotFound() throws Exception { - MockWebServer server = mockAzureManagementServer(); - server.enqueue(new MockResponse().setResponseCode(404)); - - try { - final NetworkSecurityGroupApi api = networkSecurityGroupApi(server); - assertNull(api.removeFromSubnet("myvn", "mysubnet", "mygroup")); - assertSent(server, "DELETE", - "/services/networking/virtualnetwork/myvn/subnets/mysubnet/networksecuritygroups/mygroup"); - } finally { - server.shutdown(); - } - } - - public void addToSubnet() throws Exception { - MockWebServer server = mockAzureManagementServer(); - server.enqueue(requestIdResponse("request-1")); - - try { - final NetworkSecurityGroupApi api = networkSecurityGroupApi(server); - assertEquals(api.addToSubnet("myvn", "mysubnet", "mygroup"), "request-1"); - assertSent(server, "POST", - "/services/networking/virtualnetwork/myvn/subnets/mysubnet/networksecuritygroups"); - } finally { - server.shutdown(); - } - } - - public void create() throws Exception { - MockWebServer server = mockAzureManagementServer(); - server.enqueue(requestIdResponse("request-1")); - - try { - final NetworkSecurityGroupApi api = networkSecurityGroupApi(server); - assertEquals(api.create(NetworkSecurityGroup.create("mygroup", "sec mygroup", "North Europe", null, null)), - "request-1"); - assertSent(server, "POST", "/services/networking/networksecuritygroups"); - } finally { - server.shutdown(); - } - } - - public void setRule() throws Exception { - MockWebServer server = mockAzureManagementServer(); - server.enqueue(requestIdResponse("request-1")); - - try { - final NetworkSecurityGroupApi api = networkSecurityGroupApi(server); - assertEquals(api.setRule("mygroup", "myrule", Rule.create( - "myrule", - Rule.Type.Inbound, - "100", - Rule.Action.Allow, - "192.168.0.2", - "*", - "192.168.0.1", - "80", - Rule.Protocol.TCP - )), "request-1"); - - assertSent(server, "PUT", "/services/networking/networksecuritygroups/mygroup/rules/myrule"); - } finally { - server.shutdown(); - } - } - - private NetworkSecurityGroupApi networkSecurityGroupApi(final MockWebServer server) { - return api(server.getUrl("/")).getNetworkSecurityGroupApi(); - } -}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/eb990020/azurecompute/src/test/java/org/jclouds/azurecompute/features/OSImageApiLiveTest.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/OSImageApiLiveTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/OSImageApiLiveTest.java deleted file mode 100644 index edff894..0000000 --- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/OSImageApiLiveTest.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azurecompute.features; - -import static com.google.common.collect.Iterables.transform; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import org.jclouds.azurecompute.domain.Location; -import org.jclouds.azurecompute.domain.OSImage; -import org.jclouds.azurecompute.internal.AbstractAzureComputeApiLiveTest; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import com.google.common.base.Function; -import com.google.common.collect.ImmutableSet; - -@Test(groups = "live", testName = "OSImageApiLiveTest") -public class OSImageApiLiveTest extends AbstractAzureComputeApiLiveTest { - - private ImmutableSet<String> locations; - - @BeforeClass(groups = {"integration", "live"}) - @Override - public void setup() { - super.setup(); - - locations = ImmutableSet.copyOf(transform(api.getLocationApi().list(), new Function<Location, String>() { - - @Override - public String apply(final Location location) { - return location.name(); - } - })); - } - - public void testList() { - for (OSImage osImage : api().list()) { - checkOSImage(osImage); - } - } - - private void checkOSImage(final OSImage osImage) { - assertNotNull(osImage.label(), "Label cannot be null for " + osImage); - assertNotNull(osImage.name(), "Name cannot be null for " + osImage); - assertNotNull(osImage.os(), "OS cannot be null for " + osImage); - assertTrue(osImage.logicalSizeInGB() > 0, "LogicalSizeInGB should be positive, if set" + osImage); - - if (osImage.category() != null) { - assertNotEquals("", osImage.category().trim(), "Invalid Category for " + osImage); - } - - if (osImage.mediaLink() != null) { - assertTrue(ImmutableSet.of("http", "https").contains(osImage.mediaLink().getScheme()), - "MediaLink should be an http(s) url" + osImage); - } - - // Ex. Dirty data in RightScale eula field comes out as an empty string. - assertFalse(osImage.eula().contains("")); - if (osImage.affinityGroup() != null) { - assertTrue(locations.contains(osImage.affinityGroup()), "No " + osImage.affinityGroup() + " in " + locations); - } - } - - private OSImageApi api() { - return api.getOSImageApi(); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/eb990020/azurecompute/src/test/java/org/jclouds/azurecompute/features/OSImageApiMockTest.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/OSImageApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/OSImageApiMockTest.java deleted file mode 100644 index 2483ce4..0000000 --- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/OSImageApiMockTest.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azurecompute.features; - -import static org.testng.Assert.assertEquals; -import java.net.URI; - -import org.jclouds.azurecompute.domain.OSImage; -import org.jclouds.azurecompute.domain.OSImageParams; -import org.jclouds.azurecompute.internal.BaseAzureComputeApiMockTest; -import org.jclouds.azurecompute.xml.ListOSImagesHandlerTest; -import org.testng.annotations.Test; - -import com.squareup.okhttp.mockwebserver.MockWebServer; - -@Test(groups = "unit", testName = "OSImageApiMockTest") -public class OSImageApiMockTest extends BaseAzureComputeApiMockTest { - - public void testList() throws Exception { - MockWebServer server = mockAzureManagementServer(); - server.enqueue(xmlResponse("/images.xml")); - - try { - OSImageApi api = api(server.getUrl("/")).getOSImageApi(); - - assertEquals(api.list(), ListOSImagesHandlerTest.expected()); - - assertSent(server, "GET", "/services/images"); - } finally { - server.shutdown(); - } - } - - public void testAdd() throws Exception { - MockWebServer server = mockAzureManagementServer(); - server.enqueue(requestIdResponse("request-1")); - - try { - OSImageApi api = api(server.getUrl("/")).getOSImageApi(); - - OSImageParams params = OSImageParams.builder().name("myimage").label("foo").os(OSImage.Type.LINUX) - .mediaLink(URI.create("http://example.blob.core.windows.net/disks/mydisk.vhd")).build(); - - assertEquals(api.add(params), "request-1"); - - assertSent(server, "POST", "/services/images", "/imageparams.xml"); - } finally { - server.shutdown(); - } - } - - public void testUpdate() throws Exception { - MockWebServer server = mockAzureManagementServer(); - server.enqueue(requestIdResponse("request-1")); - - try { - OSImageApi api = api(server.getUrl("/")).getOSImageApi(); - - OSImageParams params = OSImageParams.builder().name("myimage").label("foo").os(OSImage.Type.LINUX) - .mediaLink(URI.create("http://example.blob.core.windows.net/disks/mydisk.vhd")).build(); - - assertEquals(api.update(params), "request-1"); - - assertSent(server, "PUT", "/services/images/myimage", "/imageparams.xml"); - } finally { - server.shutdown(); - } - } - - public void testDelete() throws Exception { - MockWebServer server = mockAzureManagementServer(); - server.enqueue(requestIdResponse("request-1")); - - try { - OSImageApi api = api(server.getUrl("/")).getOSImageApi(); - - assertEquals(api.delete("myimage"), "request-1"); - - assertSent(server, "DELETE", "/services/images/myimage"); - } finally { - server.shutdown(); - } - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/eb990020/azurecompute/src/test/java/org/jclouds/azurecompute/features/OperationApiMockTest.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/OperationApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/OperationApiMockTest.java deleted file mode 100644 index f155f33..0000000 --- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/OperationApiMockTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azurecompute.features; - -import static org.testng.Assert.assertEquals; - -import org.jclouds.azurecompute.internal.BaseAzureComputeApiMockTest; -import org.jclouds.azurecompute.xml.OperationHandlerTest; -import org.testng.annotations.Test; - -import com.squareup.okhttp.mockwebserver.MockWebServer; - -@Test(groups = "unit", testName = "OperationApiMockTest") -public class OperationApiMockTest extends BaseAzureComputeApiMockTest { - - public void testGet() throws Exception { - final MockWebServer server = mockAzureManagementServer(); - server.enqueue(xmlResponse("/operation.xml")); - - try { - final OperationApi api = api(server.getUrl("/")).getOperationApi(); - assertEquals(api.get("request-id"), OperationHandlerTest.expected()); - assertSent(server, "GET", "/operations/request-id"); - } finally { - server.shutdown(); - } - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/eb990020/azurecompute/src/test/java/org/jclouds/azurecompute/features/ReservedIPAddressApiLiveTest.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/ReservedIPAddressApiLiveTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/ReservedIPAddressApiLiveTest.java deleted file mode 100644 index 79c9bf8..0000000 --- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/ReservedIPAddressApiLiveTest.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azurecompute.features; - -import static org.jclouds.azurecompute.internal.BaseAzureComputeApiLiveTest.LOCATION; -import static org.testng.Assert.assertTrue; - -import com.google.common.base.Predicate; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.jclouds.azurecompute.domain.ReservedIPAddress; -import org.jclouds.azurecompute.domain.ReservedIPAddress.State; -import org.jclouds.azurecompute.domain.ReservedIPAddressParams; -import org.jclouds.azurecompute.internal.AbstractAzureComputeApiLiveTest; -import org.jclouds.util.Predicates2; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.Test; - -@Test(groups = "live", testName = "ReservedIPAddressApiLiveTest", singleThreaded = true) -public class ReservedIPAddressApiLiveTest extends AbstractAzureComputeApiLiveTest { - - private static final String RESERVED_IP_NAME = String.format("%s%d-%s", - System.getProperty("user.name"), RAND, ReservedIPAddressApiLiveTest.class.getSimpleName()).toLowerCase(); - - @Test - public void testCreate() { - final String requestId = api().create( - ReservedIPAddressParams.builder().name(RESERVED_IP_NAME).location(LOCATION).build()); - assertTrue(operationSucceeded.apply(requestId), requestId); - Logger.getAnonymousLogger().log(Level.INFO, "operation succeeded: {0}", requestId); - } - - @Test(dependsOnMethods = "testCreate") - public void testGet() { - assertTrue(Predicates2.retry(new Predicate<String>() { - - @Override - public boolean apply(final String input) { - final ReservedIPAddress res = api().get(input); - Assert.assertEquals(res.name(), RESERVED_IP_NAME); - Assert.assertNull(res.label()); - Assert.assertEquals(res.location(), LOCATION); - Assert.assertNull(res.serviceName()); - Assert.assertNull(res.deploymentName()); - return res.state().equals(State.CREATED); - } - }, 60, 5, 5).apply(RESERVED_IP_NAME)); - } - - @Test(dependsOnMethods = "testCreate") - public void testList() { - final ReservedIPAddress res = api().list().get(0); - Assert.assertEquals(res.name(), RESERVED_IP_NAME); - Assert.assertNull(res.label()); - Assert.assertEquals(res.location(), LOCATION); - Assert.assertNull(res.serviceName()); - Assert.assertNull(res.deploymentName()); - } - - @AfterClass(alwaysRun = true) - public void testDelete() { - final ReservedIPAddress res = api().get(RESERVED_IP_NAME); - - if (res != null) { - final String requestId = api().delete(RESERVED_IP_NAME); - assertTrue(operationSucceeded.apply(requestId), requestId); - Logger.getAnonymousLogger().log(Level.INFO, "operation succeeded: {0}", requestId); - } - - Assert.assertNull(api().get(RESERVED_IP_NAME)); - } - - private ReservedIPAddressApi api() { - return api.getReservedIPAddressApi(); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/eb990020/azurecompute/src/test/java/org/jclouds/azurecompute/features/ReservedIPAddressApiMockTest.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/ReservedIPAddressApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/ReservedIPAddressApiMockTest.java deleted file mode 100644 index 8e598dd..0000000 --- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/ReservedIPAddressApiMockTest.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azurecompute.features; - -import static org.testng.Assert.assertTrue; - -import org.jclouds.azurecompute.internal.BaseAzureComputeApiMockTest; -import org.testng.annotations.Test; - -import com.squareup.okhttp.mockwebserver.MockResponse; -import com.squareup.okhttp.mockwebserver.MockWebServer; -import org.jclouds.azurecompute.domain.ReservedIPAddressParams; -import org.jclouds.azurecompute.xml.ListReservedIPAddressHandlerTest; -import org.jclouds.azurecompute.xml.ReservedIPAddressHandlerTest; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; - -@Test(groups = "unit", testName = "ReservedIPAddressApiMockTest") -public class ReservedIPAddressApiMockTest extends BaseAzureComputeApiMockTest { - - public void listWhenFound() throws Exception { - final MockWebServer server = mockAzureManagementServer(); - server.enqueue(xmlResponse("/listreservedipaddress.xml")); - - try { - final ReservedIPAddressApi api = api(server.getUrl("/")).getReservedIPAddressApi(); - assertEquals(api.list(), ListReservedIPAddressHandlerTest.expected()); - assertSent(server, "GET", "/services/networking/reservedips"); - } finally { - server.shutdown(); - } - } - - public void listWhenNotFound() throws Exception { - final MockWebServer server = mockAzureManagementServer(); - server.enqueue(new MockResponse().setResponseCode(404)); - - try { - final ReservedIPAddressApi api = api(server.getUrl("/")).getReservedIPAddressApi(); - assertTrue(api.list().isEmpty()); - assertSent(server, "GET", "/services/networking/reservedips"); - } finally { - server.shutdown(); - } - } - - public void getWhenFound() throws Exception { - final MockWebServer server = mockAzureManagementServer(); - server.enqueue(xmlResponse("/reservedipaddress.xml")); - - try { - final ReservedIPAddressApi api = api(server.getUrl("/")).getReservedIPAddressApi(); - assertEquals(api.get("myreservedip"), ReservedIPAddressHandlerTest.expected()); - assertSent(server, "GET", "/services/networking/reservedips/myreservedip"); - } finally { - server.shutdown(); - } - } - - public void getWhenNotFound() throws Exception { - final MockWebServer server = mockAzureManagementServer(); - server.enqueue(new MockResponse().setResponseCode(404)); - - try { - final ReservedIPAddressApi api = api(server.getUrl("/")).getReservedIPAddressApi(); - assertNull(api.get("myreservedip")); - assertSent(server, "GET", "/services/networking/reservedips/myreservedip"); - } finally { - server.shutdown(); - } - } - - public void deleteWhenFound() throws Exception { - final MockWebServer server = mockAzureManagementServer(); - server.enqueue(requestIdResponse("request-1")); - - try { - final ReservedIPAddressApi api = api(server.getUrl("/")).getReservedIPAddressApi(); - assertEquals(api.delete("myreservedip"), "request-1"); - assertSent(server, "DELETE", "/services/networking/reservedips/myreservedip"); - } finally { - server.shutdown(); - } - } - - public void deleteWhenNotFound() throws Exception { - final MockWebServer server = mockAzureManagementServer(); - server.enqueue(new MockResponse().setResponseCode(404)); - - try { - final ReservedIPAddressApi api = api(server.getUrl("/")).getReservedIPAddressApi(); - assertNull(api.delete("myreservedip")); - assertSent(server, "DELETE", "/services/networking/reservedips/myreservedip"); - } finally { - server.shutdown(); - } - } - - public void create() throws Exception { - final MockWebServer server = mockAzureManagementServer(); - server.enqueue(requestIdResponse("request-1")); - - try { - final ReservedIPAddressApi api = api(server.getUrl("/")).getReservedIPAddressApi(); - - final ReservedIPAddressParams params = ReservedIPAddressParams.builder(). - name("myreservedip"). - label("myreservedip label"). - location("West Europe").build(); - - assertEquals(api.create(params), "request-1"); - assertSent(server, "POST", "/services/networking/reservedips", "/reservedipaddressparams.xml"); - } finally { - server.shutdown(); - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/eb990020/azurecompute/src/test/java/org/jclouds/azurecompute/features/ServiceCertificatesApiLiveTest.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/ServiceCertificatesApiLiveTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/ServiceCertificatesApiLiveTest.java deleted file mode 100644 index e7aa14c..0000000 --- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/ServiceCertificatesApiLiveTest.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azurecompute.features; - -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; -import org.jclouds.azurecompute.domain.ServiceCertificate; -import org.jclouds.azurecompute.domain.ServiceCertificateParams; -import org.jclouds.azurecompute.internal.BaseAzureComputeApiLiveTest; -import static org.jclouds.azurecompute.internal.BaseAzureComputeApiLiveTest.LOCATION; -import org.testng.Assert; -import static org.testng.Assert.assertTrue; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -@Test(groups = "live", testName = "ServiceCertificatesApiLivTest", singleThreaded = true) -public class ServiceCertificatesApiLiveTest extends BaseAzureComputeApiLiveTest { - - private static final String CLOUD_SERVICE = String.format("%s%d-%s", - System.getProperty("user.name"), RAND, ServiceCertificatesApiLiveTest.class.getSimpleName()).toLowerCase(); - - private static final String FORMAT = "pfx"; - private static final String PASSWORD = "password"; - - private static final String THUMBPRINT = "8D6ED1395205C57D23E518672903FDAF144EE8AE"; - private static final String THUMBPRINT_ALGO = "sha1"; - private static final String DATA - = "MIIDyzCCArOgAwIBAgICEAcwDQYJKoZIhvcNAQELBQAwfzELMAkGA1UEBhMCSVQxDjAMBgNVBAgMBUl0YWx5MRAwDgYDVQQ" - + "HDAdQZXNjYXJhMQ8wDQYDVQQKDAZUaXJhc2ExDDAKBgNVBAsMA0lUQzEPMA0GA1UEAwwGVGlyYXNhMR4wHAYJKoZIh" - + "vcNAQkBFg9pbmZvQHRpcmFzYS5uZXQwHhcNMTUwMzA0MTQ1MzQwWhcNMTYwMzAzMTQ1MzQwWjBVMQswCQYDVQQGEwJ" - + "JVDEQMA4GA1UECAwHUGVzY2FyYTEPMA0GA1UECgwGVGlyYXNhMQswCQYDVQQLDAJBTTEWMBQGA1UEAwwNYW0udGlyY" - + "XNhLm5ldDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMzqTZFbzahmEqp60txg8aUYw4Y7PL44A7rzHVn" - + "b5cb01/4VVjNeijmROOL8o5ZEbkNkQly43zjoZcrkw4bpvOz95OP8/NH/ZgyYKR42VqcTlxcj/22iq2Ie1XhWsKARm" - + "ObdnNUcFCsdqXWXBo0bLF+WuUYh4ZoMxFMlP7YYl7WOCCgekE8E9sL02RuLZgq7v2M6fsxhT5rEG81jzUlmY5c/jXZ" - + "KbUIBaltKtzC3DnBpuk9u+S87WseqTeuhUzF6VvgwmiQ+zeHdr5Hjqxrvmq445DPz+2U3PYN1vFoB/6QzjtZVakSfO" - + "SZ0YAtFhZFHmR11kJTNMfVQ5k5oIQPtHksCAwEAAaN7MHkwCQYDVR0TBAIwADAsBglghkgBhvhCAQ0EHxYdT3BlblN" - + "TTCBHZW5lcmF0ZWQgQ2VydGlmaWNhdGUwHQYDVR0OBBYEFOIYM6WyNdc4odsThFVtOefT/xg1MB8GA1UdIwQYMBaAF" - + "DqheOl4dpXYelhPC/bM+VdN1AXpMA0GCSqGSIb3DQEBCwUAA4IBAQB33qLYghIYa2j1ycHBpeZVadsb8xb4AnfnAW9" - + "g5dYfZP1eIvmKzOxN3CjpuCRKNI4vyKHiLbucfFDl5zi9BdYwwdduPbYTgE8F8Ilyit3irSRJFk1wHICX0sBPq5ulz" - + "39MPZsP2Fmzbrphr9BrRZOc1RJdHnj8C7phrfBneGSfwoY+qH5H6/h5A5rS8oDAraeklR2RJK4ztK+yDvp8orRDJQq" - + "5LAALQtWDhdW8Qj7WoIbGUeB77aJLluLOgriJLK+kKaGoUuAaKFRJXPyTmtUC17CJUJbapmtDwivILhU/dSdz6+1YX" - + "Tg0ddNNlug3I6L5VVRnlwJJc/hIna1VjQJO"; - - @BeforeClass - @Override - public void setup() { - super.setup(); - final String requestId - = api.getCloudServiceApi().createWithLabelInLocation(CLOUD_SERVICE, CLOUD_SERVICE, LOCATION); - assertTrue(operationSucceeded.apply(requestId), requestId); - Logger.getAnonymousLogger().log(Level.INFO, "operation succeeded: {0}", requestId); - } - - @Test - public void testAdd() { - - final String requestId = api().add(CLOUD_SERVICE, - ServiceCertificateParams.builder().data(DATA).format(FORMAT).password(PASSWORD).build()); - - assertTrue(operationSucceeded.apply(requestId), requestId); - Logger.getAnonymousLogger().log(Level.INFO, "operation succeeded: {0}", requestId); - } - - @Test(dependsOnMethods = "testAdd") - public void testList() { - final List<ServiceCertificate> res = api().list(CLOUD_SERVICE); - Assert.assertEquals(res.size(), 1); - Assert.assertEquals(res.get(0).data(), DATA); - Assert.assertEquals(res.get(0).thumbprintAlgorithm(), THUMBPRINT_ALGO); - Assert.assertEquals(res.get(0).thumbprint(), THUMBPRINT); - } - - @Test(dependsOnMethods = "testList") - public void testGet() { - Assert.assertNotNull(api().get(CLOUD_SERVICE, THUMBPRINT_ALGO, THUMBPRINT)); - } - - @Test(dependsOnMethods = "testGet") - public void testDelete() { - final String requestId = api().delete(CLOUD_SERVICE, THUMBPRINT_ALGO, THUMBPRINT); - assertTrue(operationSucceeded.apply(requestId), requestId); - Logger.getAnonymousLogger().log(Level.INFO, "operation succeeded: {0}", requestId); - - Assert.assertNull(api().get(CLOUD_SERVICE, THUMBPRINT_ALGO, THUMBPRINT)); - } - - @Override - @AfterClass(alwaysRun = true) - protected void tearDown() { - final String requestId = api.getCloudServiceApi().delete(CLOUD_SERVICE); - if (requestId != null) { - operationSucceeded.apply(requestId); - } - - super.tearDown(); - } - - private ServiceCertificatesApi api() { - return api.getServiceCertificatesApi(); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/eb990020/azurecompute/src/test/java/org/jclouds/azurecompute/features/ServiceCertificatesApiMockTest.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/ServiceCertificatesApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/ServiceCertificatesApiMockTest.java deleted file mode 100644 index 29d5177..0000000 --- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/ServiceCertificatesApiMockTest.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azurecompute.features; - -import static org.testng.Assert.assertTrue; - -import org.jclouds.azurecompute.internal.BaseAzureComputeApiMockTest; -import org.testng.annotations.Test; - -import com.squareup.okhttp.mockwebserver.MockResponse; -import com.squareup.okhttp.mockwebserver.MockWebServer; -import org.jclouds.azurecompute.domain.ServiceCertificateParams; -import org.jclouds.azurecompute.xml.ListServiceCertificatessHandlerTest; -import org.jclouds.azurecompute.xml.ServiceCertificateHandlerTest; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; - -@Test(groups = "unit", testName = "ServiceCertificatesApiMockTest") -public class ServiceCertificatesApiMockTest extends BaseAzureComputeApiMockTest { - - public void listWhenFound() throws Exception { - final MockWebServer server = mockAzureManagementServer(); - server.enqueue(xmlResponse("/servicecertificates.xml")); - - try { - final ServiceCertificatesApi api = api(server.getUrl("/")).getServiceCertificatesApi(); - assertEquals(api.list("myservice"), ListServiceCertificatessHandlerTest.expected()); - assertSent(server, "GET", "/services/hostedservices/myservice/certificates"); - } finally { - server.shutdown(); - } - } - - public void listWhenNotFound() throws Exception { - final MockWebServer server = mockAzureManagementServer(); - server.enqueue(new MockResponse().setResponseCode(404)); - - try { - final ServiceCertificatesApi api = api(server.getUrl("/")).getServiceCertificatesApi(); - assertTrue(api.list("myservice").isEmpty()); - assertSent(server, "GET", "/services/hostedservices/myservice/certificates"); - } finally { - server.shutdown(); - } - } - - public void getWhenFound() throws Exception { - final MockWebServer server = mockAzureManagementServer(); - server.enqueue(xmlResponse("/servicecertificate.xml")); - - try { - final ServiceCertificatesApi api = api(server.getUrl("/")).getServiceCertificatesApi(); - assertEquals(api.get("myservice", "sha1", "8D6ED1395205C57D23E518672903FDAF144EE8AE"), - ServiceCertificateHandlerTest.expected()); - assertSent(server, "GET", - "/services/hostedservices/myservice/certificates/sha1-8D6ED1395205C57D23E518672903FDAF144EE8AE"); - } finally { - server.shutdown(); - } - } - - public void getWhenNotFound() throws Exception { - final MockWebServer server = mockAzureManagementServer(); - server.enqueue(new MockResponse().setResponseCode(404)); - - try { - final ServiceCertificatesApi api = api(server.getUrl("/")).getServiceCertificatesApi(); - assertNull(api.get("myservice", "sha1", "8D6ED1395205C57D23E518672903FDAF144EE8AE")); - assertSent(server, "GET", - "/services/hostedservices/myservice/certificates/sha1-8D6ED1395205C57D23E518672903FDAF144EE8AE"); - } finally { - server.shutdown(); - } - } - - public void deleteWhenFound() throws Exception { - final MockWebServer server = mockAzureManagementServer(); - server.enqueue(requestIdResponse("request-1")); - - try { - final ServiceCertificatesApi api = api(server.getUrl("/")).getServiceCertificatesApi(); - assertEquals(api.delete("myservice", "sha1", "8D6ED1395205C57D23E518672903FDAF144EE8AE"), "request-1"); - assertSent(server, "DELETE", - "/services/hostedservices/myservice/certificates/sha1-8D6ED1395205C57D23E518672903FDAF144EE8AE"); - - } finally { - server.shutdown(); - } - } - - public void deleteWhenNotFound() throws Exception { - final MockWebServer server = mockAzureManagementServer(); - server.enqueue(new MockResponse().setResponseCode(404)); - - try { - final ServiceCertificatesApi api = api(server.getUrl("/")).getServiceCertificatesApi(); - assertNull(api.delete("myservice", "sha1", "8D6ED1395205C57D23E518672903FDAF144EE8AE")); - assertSent(server, "DELETE", - "/services/hostedservices/myservice/certificates/sha1-8D6ED1395205C57D23E518672903FDAF144EE8AE"); - } finally { - server.shutdown(); - } - } - - public void add() throws Exception { - final MockWebServer server = mockAzureManagementServer(); - server.enqueue(requestIdResponse("request-1")); - - try { - final ServiceCertificatesApi api = api(server.getUrl("/")).getServiceCertificatesApi(); - - final ServiceCertificateParams params = ServiceCertificateParams.builder(). - data("MIIDyzCCArOgAwIBAgICEAcwDQYJKoZIhvcNAQELBQAwfzELMAkGA1UEBhMCSVQxDjAMBgNVBAgMBUl0YWx5MRAwDgYDVQQ" - + "HDAdQZXNjYXJhMQ8wDQYDVQQKDAZUaXJhc2ExDDAKBgNVBAsMA0lUQzEPMA0GA1UEAwwGVGlyYXNhMR4wHAYJKoZIh" - + "vcNAQkBFg9pbmZvQHRpcmFzYS5uZXQwHhcNMTUwMzA0MTQ1MzQwWhcNMTYwMzAzMTQ1MzQwWjBVMQswCQYDVQQGEwJ" - + "JVDEQMA4GA1UECAwHUGVzY2FyYTEPMA0GA1UECgwGVGlyYXNhMQswCQYDVQQLDAJBTTEWMBQGA1UEAwwNYW0udGlyY" - + "XNhLm5ldDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMzqTZFbzahmEqp60txg8aUYw4Y7PL44A7rzHVn" - + "b5cb01/4VVjNeijmROOL8o5ZEbkNkQly43zjoZcrkw4bpvOz95OP8/NH/ZgyYKR42VqcTlxcj/22iq2Ie1XhWsKARm" - + "ObdnNUcFCsdqXWXBo0bLF+WuUYh4ZoMxFMlP7YYl7WOCCgekE8E9sL02RuLZgq7v2M6fsxhT5rEG81jzUlmY5c/jXZ" - + "KbUIBaltKtzC3DnBpuk9u+S87WseqTeuhUzF6VvgwmiQ+zeHdr5Hjqxrvmq445DPz+2U3PYN1vFoB/6QzjtZVakSfO" - + "SZ0YAtFhZFHmR11kJTNMfVQ5k5oIQPtHksCAwEAAaN7MHkwCQYDVR0TBAIwADAsBglghkgBhvhCAQ0EHxYdT3BlblN" - + "TTCBHZW5lcmF0ZWQgQ2VydGlmaWNhdGUwHQYDVR0OBBYEFOIYM6WyNdc4odsThFVtOefT/xg1MB8GA1UdIwQYMBaAF" - + "DqheOl4dpXYelhPC/bM+VdN1AXpMA0GCSqGSIb3DQEBCwUAA4IBAQB33qLYghIYa2j1ycHBpeZVadsb8xb4AnfnAW9" - + "g5dYfZP1eIvmKzOxN3CjpuCRKNI4vyKHiLbucfFDl5zi9BdYwwdduPbYTgE8F8Ilyit3irSRJFk1wHICX0sBPq5ulz" - + "39MPZsP2Fmzbrphr9BrRZOc1RJdHnj8C7phrfBneGSfwoY+qH5H6/h5A5rS8oDAraeklR2RJK4ztK+yDvp8orRDJQq" - + "5LAALQtWDhdW8Qj7WoIbGUeB77aJLluLOgriJLK+kKaGoUuAaKFRJXPyTmtUC17CJUJbapmtDwivILhU/dSdz6+1YX" - + "Tg0ddNNlug3I6L5VVRnlwJJc/hIna1VjQJO"). - format("pfx"). - password("password").build(); - - assertEquals(api.add("myservice", params), "request-1"); - assertSent(server, "POST", "/services/hostedservices/myservice/certificates", "/servicecertificateparams.xml"); - } finally { - server.shutdown(); - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/eb990020/azurecompute/src/test/java/org/jclouds/azurecompute/features/StorageAccountApiLiveTest.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/StorageAccountApiLiveTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/StorageAccountApiLiveTest.java deleted file mode 100644 index 536be67..0000000 --- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/StorageAccountApiLiveTest.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azurecompute.features; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import com.google.common.collect.ImmutableMap; -import org.jclouds.azurecompute.domain.CreateStorageServiceParams; -import org.jclouds.azurecompute.domain.StorageService; -import org.jclouds.azurecompute.domain.StorageServiceKeys; -import org.jclouds.azurecompute.domain.UpdateStorageServiceParams; -import org.jclouds.azurecompute.internal.BaseAzureComputeApiLiveTest; -import org.testng.annotations.AfterClass; -import org.testng.annotations.Test; - -@Test(groups = "live", testName = "StorageAccountApiLiveTest") -public class StorageAccountApiLiveTest extends BaseAzureComputeApiLiveTest { - - private static final String NAME = String.format("%3.24s", - RAND + StorageAccountApiLiveTest.class.getSimpleName().toLowerCase()); - - private void check(final StorageService storage) { - assertNotNull(storage.url()); - assertNotNull(storage.serviceName()); - assertNotNull(storage.storageServiceProperties()); - assertNotNull(storage.storageServiceProperties().accountType()); - assertFalse(storage.storageServiceProperties().endpoints().isEmpty()); - assertNotNull(storage.storageServiceProperties().creationTime()); - } - - public void testList() { - for (StorageService storage : api().list()) { - check(storage); - } - } - - public void testIsAvailable() { - assertTrue(api().isAvailable(NAME).result()); - } - - @Test(dependsOnMethods = "testIsAvailable") - public void testCreate() { - final CreateStorageServiceParams params = CreateStorageServiceParams.builder(). - serviceName(NAME). - description("description"). - label("label"). - location(LOCATION). - extendedProperties(ImmutableMap.of("property_name", "property_value")). - accountType(StorageService.AccountType.Standard_ZRS). - build(); - final String requestId = api().create(params); - assertTrue(operationSucceeded.apply(requestId), requestId); - } - - @Test(dependsOnMethods = "testCreate") - public void testGet() { - final StorageService service = api().get(NAME); - assertNotNull(service); - assertEquals(service.serviceName(), NAME); - assertEquals(service.storageServiceProperties().description(), "description"); - assertEquals(service.storageServiceProperties().location(), LOCATION); - assertEquals(service.storageServiceProperties().label(), "label"); - assertEquals(service.storageServiceProperties().accountType(), StorageService.AccountType.Standard_ZRS); - assertTrue(service.extendedProperties().containsKey("property_name")); - assertEquals(service.extendedProperties().get("property_name"), "property_value"); - } - - @Test(dependsOnMethods = "testCreate") - public void testGetKeys() { - final StorageServiceKeys keys = api().getKeys(NAME); - assertNotNull(keys); - assertNotNull(keys.url()); - assertNotNull(keys.primary()); - assertNotNull(keys.secondary()); - } - - @Test(dependsOnMethods = "testCreate") - public void testRegenerateKeys() { - final String requestId = api().regenerateKeys(NAME, StorageServiceKeys.KeyType.Primary); - assertTrue(operationSucceeded.apply(requestId), requestId); - } - - @Test(dependsOnMethods = "testCreate") - public void testUpdate() { - final UpdateStorageServiceParams params = UpdateStorageServiceParams.builder(). - extendedProperties(ImmutableMap.of("another_property_name", "another_property_value")). - build(); - final String requestId = api().update(NAME, params); - assertTrue(operationSucceeded.apply(requestId), requestId); - } - - @AfterClass(alwaysRun = true) - public void testDelete() { - final String requestId = api().delete(NAME); - assertTrue(operationSucceeded.apply(requestId), requestId); - } - - private StorageAccountApi api() { - return api.getStorageAccountApi(); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/eb990020/azurecompute/src/test/java/org/jclouds/azurecompute/features/StorageAccountApiMockTest.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/StorageAccountApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/StorageAccountApiMockTest.java deleted file mode 100644 index 05e84ce..0000000 --- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/StorageAccountApiMockTest.java +++ /dev/null @@ -1,228 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azurecompute.features; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; - -import com.squareup.okhttp.mockwebserver.MockResponse; -import com.squareup.okhttp.mockwebserver.MockWebServer; -import java.net.URL; -import org.jclouds.azurecompute.domain.Availability; -import org.jclouds.azurecompute.domain.CreateStorageServiceParams; -import org.jclouds.azurecompute.domain.StorageService; -import org.jclouds.azurecompute.domain.StorageServiceKeys; -import org.jclouds.azurecompute.domain.UpdateStorageServiceParams; -import org.jclouds.azurecompute.internal.BaseAzureComputeApiMockTest; -import org.jclouds.azurecompute.xml.ListStorageServiceHandlerTest; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "StorageAccountApiMockTest") -public class StorageAccountApiMockTest extends BaseAzureComputeApiMockTest { - - public void testList() throws Exception { - final MockWebServer server = mockAzureManagementServer(); - server.enqueue(xmlResponse("/storageservices.xml")); - - try { - final StorageAccountApi api = api(server.getUrl("/")).getStorageAccountApi(); - - assertEquals(api.list(), ListStorageServiceHandlerTest.expected()); - - assertSent(server, "GET", "/services/storageservices"); - } finally { - server.shutdown(); - } - } - - public void testEmptyList() throws Exception { - final MockWebServer server = mockAzureManagementServer(); - server.enqueue(new MockResponse().setResponseCode(404)); - - try { - final StorageAccountApi api = api(server.getUrl("/")).getStorageAccountApi(); - - assertTrue(api.list().isEmpty()); - - assertSent(server, "GET", "/services/storageservices"); - } finally { - server.shutdown(); - } - } - - public void testCreate() throws Exception { - final MockWebServer server = mockAzureManagementServer(); - server.enqueue(requestIdResponse("request-1")); - - try { - final StorageAccountApi api = api(server.getUrl("/")).getStorageAccountApi(); - - final CreateStorageServiceParams params = CreateStorageServiceParams.builder(). - serviceName("name-of-storage-account"). - description("description-of-storage-account"). - label("base64-encoded-label"). - location("location-of-storage-account"). - extendedProperties(ImmutableMap.of("property_name", "property_value")). - accountType(StorageService.AccountType.Premium_LRS). - build(); - - assertEquals(api.create(params), "request-1"); - - assertSent(server, "POST", "/services/storageservices", "/createstorageserviceparams.xml"); - } finally { - server.shutdown(); - } - } - - public void testIsAvailable() throws Exception { - final MockWebServer server = mockAzureManagementServer(); - server.enqueue(xmlResponse("/isavailablestorageservice.xml")); - - try { - final StorageAccountApi api = api(server.getUrl("/")).getStorageAccountApi(); - - assertEquals(api.isAvailable("serviceName"), - Availability.create(false, "The storage account named 'serviceName' is already taken.")); - - assertSent(server, "GET", "/services/storageservices/operations/isavailable/serviceName"); - } finally { - server.shutdown(); - } - } - - public void testGet() throws Exception { - final MockWebServer server = mockAzureManagementServer(); - server.enqueue(xmlResponse("/storageservices.xml")); - - try { - final StorageAccountApi api = api(server.getUrl("/")).getStorageAccountApi(); - - assertEquals(api.get("serviceName"), ListStorageServiceHandlerTest.expected().get(0)); - - assertSent(server, "GET", "/services/storageservices/serviceName"); - } finally { - server.shutdown(); - } - } - - public void testNullGet() throws Exception { - final MockWebServer server = mockAzureManagementServer(); - server.enqueue(new MockResponse().setResponseCode(404)); - - try { - final StorageAccountApi api = api(server.getUrl("/")).getStorageAccountApi(); - - assertNull(api.get("serviceName")); - - assertSent(server, "GET", "/services/storageservices/serviceName"); - } finally { - server.shutdown(); - } - } - - public void testGetKeys() throws Exception { - final MockWebServer server = mockAzureManagementServer(); - server.enqueue(xmlResponse("/storageaccountkeys.xml")); - - try { - final StorageAccountApi api = api(server.getUrl("/")).getStorageAccountApi(); - - assertEquals(api.getKeys("serviceName"), StorageServiceKeys.create( - new URL("https://management.core.windows.net/subscriptionid/services/storageservices/serviceName"), - "bndO7lydwDkMo4Y0mFvmfLyi2f9aZY7bwfAVWoJWv4mOVK6E9c/exLnFsSm/NMWgifLCfxC/c6QBTbdEvWUA7w==", - "/jMLLT3kKqY4K+cUtJTbh7pCBdvG9EMKJxUvaJJAf6W6aUiZe1A1ulXHcibrqRVA2RJE0oUeXQGXLYJ2l85L7A==")); - - assertSent(server, "GET", "/services/storageservices/serviceName/keys"); - } finally { - server.shutdown(); - } - } - - public void testNullGetKeys() throws Exception { - final MockWebServer server = mockAzureManagementServer(); - server.enqueue(new MockResponse().setResponseCode(404)); - - try { - final StorageAccountApi api = api(server.getUrl("/")).getStorageAccountApi(); - - assertNull(api.getKeys("serviceName")); - - assertSent(server, "GET", "/services/storageservices/serviceName/keys"); - } finally { - server.shutdown(); - } - } - - public void testRegenerateKeys() throws Exception { - final MockWebServer server = mockAzureManagementServer(); - server.enqueue(requestIdResponse("request-1")); - - try { - final StorageAccountApi api = api(server.getUrl("/")).getStorageAccountApi(); - - assertEquals(api.regenerateKeys("serviceName", StorageServiceKeys.KeyType.Primary), "request-1"); - - assertSent(server, "POST", "/services/storageservices/serviceName/keys?action=regenerate", - "/storageaccountregeneratekeys.xml"); - } finally { - server.shutdown(); - } - } - - public void testUpdate() throws Exception { - final MockWebServer server = mockAzureManagementServer(); - server.enqueue(requestIdResponse("request-1")); - - try { - final StorageAccountApi api = api(server.getUrl("/")).getStorageAccountApi(); - - final UpdateStorageServiceParams params = UpdateStorageServiceParams.builder(). - description("description-of-storage-account"). - label("base64-encoded-label"). - extendedProperties(ImmutableMap.of("property_name", "property_value")). - customDomains(ImmutableList.of( - UpdateStorageServiceParams.CustomDomain.create("name-of-custom-domain", false))). - accountType(UpdateStorageServiceParams.AccountType.Standard_GRS). - build(); - - assertEquals(api.update("serviceName", params), "request-1"); - - assertSent(server, "PUT", "/services/storageservices/serviceName", "/updatestorageserviceparams.xml"); - } finally { - server.shutdown(); - } - } - - public void testDelete() throws Exception { - MockWebServer server = mockAzureManagementServer(); - server.enqueue(requestIdResponse("request-1")); - - try { - final StorageAccountApi api = api(server.getUrl("/")).getStorageAccountApi(); - - assertEquals(api.delete("serviceName"), "request-1"); - - assertSent(server, "DELETE", "/services/storageservices/serviceName"); - } finally { - server.shutdown(); - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/eb990020/azurecompute/src/test/java/org/jclouds/azurecompute/features/SubscriptionApiLiveTest.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/SubscriptionApiLiveTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/SubscriptionApiLiveTest.java deleted file mode 100644 index 7ae63f8..0000000 --- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/SubscriptionApiLiveTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azurecompute.features; - -import static org.testng.Assert.assertNotNull; - -import org.jclouds.azurecompute.domain.RoleSize; -import org.jclouds.azurecompute.internal.AbstractAzureComputeApiLiveTest; -import org.testng.annotations.Test; - -@Test(groups = "live", testName = "SubscriptionApiLiveTest") -public class SubscriptionApiLiveTest extends AbstractAzureComputeApiLiveTest { - - @Test - public void testList() { - for (RoleSize roleSize : api().listRoleSizes()) { - checkLocation(roleSize); - } - } - - private void checkLocation(final RoleSize roleSize) { - assertNotNull(roleSize.name(), "Name cannot be null for a Location."); - assertNotNull(roleSize.label(), "Label cannot be null for: " + roleSize); - assertNotNull(roleSize.cores(), "Cores cannot be null for: " + roleSize.name()); - } - - private SubscriptionApi api() { - return api.getSubscriptionApi(); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/eb990020/azurecompute/src/test/java/org/jclouds/azurecompute/features/SubscriptionApiMockTest.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/SubscriptionApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/SubscriptionApiMockTest.java deleted file mode 100644 index b74a243..0000000 --- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/SubscriptionApiMockTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azurecompute.features; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; - -import com.squareup.okhttp.mockwebserver.MockResponse; -import com.squareup.okhttp.mockwebserver.MockWebServer; -import org.jclouds.azurecompute.internal.BaseAzureComputeApiMockTest; -import org.jclouds.azurecompute.xml.ListRoleSizesHandlerTest; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "SubscriptionApiMockTest") -public class SubscriptionApiMockTest extends BaseAzureComputeApiMockTest { - - public void testList() throws Exception { - final MockWebServer server = mockAzureManagementServer(); - server.enqueue(xmlResponse("/rolesizes.xml")); - - try { - final SubscriptionApi api = api(server.getUrl("/")).getSubscriptionApi(); - - assertEquals(api.listRoleSizes(), ListRoleSizesHandlerTest.expected()); - - assertSent(server, "GET", "/rolesizes"); - } finally { - server.shutdown(); - } - } - - public void testEmptyList() throws Exception { - final MockWebServer server = mockAzureManagementServer(); - server.enqueue(new MockResponse().setResponseCode(404)); - - try { - final SubscriptionApi api = api(server.getUrl("/")).getSubscriptionApi(); - - assertTrue(api.listRoleSizes().isEmpty()); - - assertSent(server, "GET", "/rolesizes"); - } finally { - server.shutdown(); - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/eb990020/azurecompute/src/test/java/org/jclouds/azurecompute/features/TrafficManagerApiLiveTest.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/TrafficManagerApiLiveTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/TrafficManagerApiLiveTest.java deleted file mode 100644 index de8275c..0000000 --- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/TrafficManagerApiLiveTest.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azurecompute.features; - -import com.google.common.collect.ImmutableList; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; -import org.jclouds.azurecompute.domain.CreateProfileParams; -import org.jclouds.azurecompute.domain.Profile; -import org.jclouds.azurecompute.domain.ProfileDefinition; -import org.jclouds.azurecompute.domain.ProfileDefinitionEndpoint; -import org.jclouds.azurecompute.domain.ProfileDefinitionEndpointParams; -import org.jclouds.azurecompute.domain.ProfileDefinitionParams; -import org.jclouds.azurecompute.domain.UpdateProfileParams; -import org.jclouds.azurecompute.internal.BaseAzureComputeApiLiveTest; -import static org.jclouds.azurecompute.internal.BaseAzureComputeApiLiveTest.LOCATION; -import org.jclouds.azurecompute.util.ConflictManagementPredicate; -import org.testng.Assert; -import static org.testng.Assert.assertTrue; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -@Test(groups = "live", testName = "ServiceCertificatesApiLivTest", singleThreaded = true) -public class TrafficManagerApiLiveTest extends BaseAzureComputeApiLiveTest { - - private static final String CLOUD1 = String.format("%s%d-%s1", - System.getProperty("user.name"), RAND, TrafficManagerApiLiveTest.class.getSimpleName()).toLowerCase(); - - private static final String CLOUD2 = String.format("%s%d-%s2", - System.getProperty("user.name"), RAND, TrafficManagerApiLiveTest.class.getSimpleName()).toLowerCase(); - - @BeforeClass - @Override - public void setup() { - super.setup(); - String requestId = api.getCloudServiceApi().createWithLabelInLocation(CLOUD1, CLOUD1, LOCATION); - assertTrue(operationSucceeded.apply(requestId), requestId); - Logger.getAnonymousLogger().log(Level.INFO, "operation succeeded: {0}", requestId); - - requestId = api.getCloudServiceApi().createWithLabelInLocation(CLOUD2, CLOUD2, LOCATION); - assertTrue(operationSucceeded.apply(requestId), requestId); - Logger.getAnonymousLogger().log(Level.INFO, "operation succeeded: {0}", requestId); - } - - @Test - public void createProfile() throws Exception { - final CreateProfileParams params = CreateProfileParams.builder(). - domain(String.format("%s.trafficmanager.net", CLOUD1)).name(CLOUD1).build(); - - final String requestId = api().createProfile(params); - assertTrue(operationSucceeded.apply(requestId), requestId); - Logger.getAnonymousLogger().log(Level.INFO, "operation succeeded: {0}", requestId); - } - - @Test(dependsOnMethods = "createProfile") - public void createDefinition() throws Exception { - final ImmutableList.Builder<ProfileDefinitionEndpointParams> endpoints - = ImmutableList.<ProfileDefinitionEndpointParams>builder(); - - endpoints.add(ProfileDefinitionEndpointParams.builder() - .domain(String.format("%s.cloudapp.net", CLOUD1)) - .status(ProfileDefinition.Status.ENABLED) - .type(ProfileDefinitionEndpoint.Type.CLOUDSERVICE) - .weight(1).build()); - - endpoints.add(ProfileDefinitionEndpointParams.builder() - .domain(String.format("%s.cloudapp.net", CLOUD2)) - .status(ProfileDefinition.Status.ENABLED) - .type(ProfileDefinitionEndpoint.Type.CLOUDSERVICE) - .weight(1).build()); - - final ProfileDefinitionParams params = ProfileDefinitionParams.builder() - .ttl(300) - .lb(ProfileDefinition.LBMethod.ROUNDROBIN) - .path("/") - .port(80) - .protocol(ProfileDefinition.Protocol.HTTP) - .endpoints(endpoints.build()) - .build(); - - final String requestId = api().createDefinition(CLOUD1, params); - assertTrue(operationSucceeded.apply(requestId), requestId); - Logger.getAnonymousLogger().log(Level.INFO, "operation succeeded: {0}", requestId); - } - - @Test(dependsOnMethods = "createDefinition") - public void updateProfile() throws Exception { - final UpdateProfileParams params = UpdateProfileParams.builder(). - status(ProfileDefinition.Status.DISABLED).build(); - - final String requestId = api().updateProfile(CLOUD1, params); - assertTrue(operationSucceeded.apply(requestId), requestId); - Logger.getAnonymousLogger().log(Level.INFO, "operation succeeded: {0}", requestId); - } - - @Test(dependsOnMethods = "createDefinition") - public void listDefinitions() throws Exception { - final List<ProfileDefinition> defs = api().listDefinitions(CLOUD1); - Assert.assertEquals(defs.size(), 1); - Assert.assertEquals(defs.get(0).endpoints().size(), 2); - Assert.assertEquals(defs.get(0).monitors().size(), 1); - Assert.assertEquals(defs.get(0).lb(), ProfileDefinition.LBMethod.ROUNDROBIN); - Assert.assertEquals(defs.get(0).ttl(), 300, 0); - Assert.assertEquals(defs.get(0).status(), ProfileDefinition.Status.ENABLED); - Assert.assertEquals(defs.get(0).monitors().get(0).port(), 80, 0); - Assert.assertEquals(defs.get(0).monitors().get(0).path(), "/"); - Assert.assertEquals(defs.get(0).endpoints().get(0).type(), ProfileDefinitionEndpoint.Type.CLOUDSERVICE); - Assert.assertNull(defs.get(0).endpoints().get(0).location()); - } - - @Test(dependsOnMethods = "createDefinition") - public void getDefinitions() throws Exception { - final ProfileDefinition def = api().getDefinition(CLOUD1); - Assert.assertEquals(def.endpoints().size(), 2); - Assert.assertEquals(def.monitors().size(), 1); - Assert.assertEquals(def.lb(), ProfileDefinition.LBMethod.ROUNDROBIN); - Assert.assertEquals(def.ttl(), 300, 0); - Assert.assertEquals(def.status(), ProfileDefinition.Status.ENABLED); - Assert.assertEquals(def.monitors().get(0).port(), 80, 0); - Assert.assertEquals(def.monitors().get(0).path(), "/"); - Assert.assertEquals(def.endpoints().get(0).type(), ProfileDefinitionEndpoint.Type.CLOUDSERVICE); - Assert.assertNull(def.endpoints().get(0).location()); - } - - @Test(dependsOnMethods = "createDefinition") - public void listProfile() throws Exception { - final List<Profile> profs = api().listProfiles(); - Assert.assertFalse(profs.isEmpty()); - - final Profile prof = api().getProfile(CLOUD1); - Assert.assertEquals(prof.domain(), String.format("%s.trafficmanager.net", CLOUD1)); - Assert.assertEquals(prof.name(), CLOUD1); - Assert.assertEquals(prof.status(), ProfileDefinition.Status.ENABLED); - Assert.assertEquals(prof.version(), "1"); - Assert.assertFalse(prof.definitions().isEmpty()); - } - - @Override - @AfterClass(alwaysRun = true) - protected void tearDown() { - final String requestId = api().delete(CLOUD1); - assertTrue(operationSucceeded.apply(requestId), requestId); - Logger.getAnonymousLogger().log(Level.INFO, "operation succeeded: {0}", requestId); - - assertTrue(new ConflictManagementPredicate(api) { - @Override - protected String operation() { - return api.getCloudServiceApi().delete(CLOUD1); - } - }.apply(CLOUD1)); - - assertTrue(new ConflictManagementPredicate(api) { - @Override - protected String operation() { - return api.getCloudServiceApi().delete(CLOUD2); - } - }.apply(CLOUD2)); - - super.tearDown(); - } - - private TrafficManagerApi api() { - return api.getTrafficManaerApi(); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/eb990020/azurecompute/src/test/java/org/jclouds/azurecompute/features/TrafficManagerApiMockTest.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/TrafficManagerApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/TrafficManagerApiMockTest.java deleted file mode 100644 index e94a339..0000000 --- a/azurecompute/src/test/java/org/jclouds/azurecompute/features/TrafficManagerApiMockTest.java +++ /dev/null @@ -1,258 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azurecompute.features; - -import com.google.common.collect.ImmutableList; -import static org.testng.Assert.assertTrue; - -import org.jclouds.azurecompute.internal.BaseAzureComputeApiMockTest; -import org.testng.annotations.Test; - -import com.squareup.okhttp.mockwebserver.MockResponse; -import com.squareup.okhttp.mockwebserver.MockWebServer; -import org.jclouds.azurecompute.domain.CreateProfileParams; -import org.jclouds.azurecompute.domain.ProfileDefinition; -import org.jclouds.azurecompute.domain.ProfileDefinitionEndpoint; -import org.jclouds.azurecompute.domain.ProfileDefinitionEndpointParams; -import org.jclouds.azurecompute.domain.ProfileDefinitionParams; -import org.jclouds.azurecompute.domain.UpdateProfileParams; -import org.jclouds.azurecompute.xml.ListProfileDefinitionsHandlerTest; -import org.jclouds.azurecompute.xml.ListProfilesHandlerTest; -import org.jclouds.azurecompute.xml.ProfileDefinitionHandlerTest; -import org.jclouds.azurecompute.xml.ProfileHandlerTest; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; - -@Test(groups = "unit", testName = "TrafficManagerApiMockTest") -public class TrafficManagerApiMockTest extends BaseAzureComputeApiMockTest { - - public void listDefWhenFound() throws Exception { - final MockWebServer server = mockAzureManagementServer(); - server.enqueue(xmlResponse("/listprofiledefinitions.xml")); - - try { - final TrafficManagerApi api = api(server.getUrl("/")).getTrafficManaerApi(); - assertEquals(api.listDefinitions("myprofile"), ListProfileDefinitionsHandlerTest.expected()); - assertSent(server, "GET", "/services/WATM/profiles/myprofile/definitions"); - } finally { - server.shutdown(); - } - } - - public void listDefWhenNotFound() throws Exception { - final MockWebServer server = mockAzureManagementServer(); - server.enqueue(new MockResponse().setResponseCode(404)); - - try { - final TrafficManagerApi api = api(server.getUrl("/")).getTrafficManaerApi(); - assertTrue(api.listDefinitions("myprofile").isEmpty()); - assertSent(server, "GET", "/services/WATM/profiles/myprofile/definitions"); - } finally { - server.shutdown(); - } - } - - public void getDefWhenFound() throws Exception { - final MockWebServer server = mockAzureManagementServer(); - server.enqueue(xmlResponse("/profiledefinition.xml")); - - try { - final TrafficManagerApi api = api(server.getUrl("/")).getTrafficManaerApi(); - assertEquals(api.getDefinition("myprofile"), ProfileDefinitionHandlerTest.expected()); - assertSent(server, "GET", "/services/WATM/profiles/myprofile/definitions/1"); - } finally { - server.shutdown(); - } - } - - public void getDefWhenNotFound() throws Exception { - final MockWebServer server = mockAzureManagementServer(); - server.enqueue(new MockResponse().setResponseCode(404)); - - try { - final TrafficManagerApi api = api(server.getUrl("/")).getTrafficManaerApi(); - assertNull(api.getDefinition("myprofile")); - assertSent(server, "GET", "/services/WATM/profiles/myprofile/definitions/1"); - } finally { - server.shutdown(); - } - } - - public void listProfWhenFound() throws Exception { - final MockWebServer server = mockAzureManagementServer(); - server.enqueue(xmlResponse("/listprofiles.xml")); - - try { - final TrafficManagerApi api = api(server.getUrl("/")).getTrafficManaerApi(); - assertEquals(api.listProfiles(), ListProfilesHandlerTest.expected()); - assertSent(server, "GET", "/services/WATM/profiles"); - } finally { - server.shutdown(); - } - } - - public void listProfWhenNotFound() throws Exception { - final MockWebServer server = mockAzureManagementServer(); - server.enqueue(new MockResponse().setResponseCode(404)); - - try { - final TrafficManagerApi api = api(server.getUrl("/")).getTrafficManaerApi(); - assertTrue(api.listProfiles().isEmpty()); - assertSent(server, "GET", "/services/WATM/profiles"); - } finally { - server.shutdown(); - } - } - - public void getProfWhenFound() throws Exception { - final MockWebServer server = mockAzureManagementServer(); - server.enqueue(xmlResponse("/profile.xml")); - - try { - final TrafficManagerApi api = api(server.getUrl("/")).getTrafficManaerApi(); - assertEquals(api.getProfile("myprofile"), ProfileHandlerTest.expected()); - assertSent(server, "GET", "/services/WATM/profiles/myprofile"); - } finally { - server.shutdown(); - } - } - - public void getProfWhenNotFound() throws Exception { - final MockWebServer server = mockAzureManagementServer(); - server.enqueue(new MockResponse().setResponseCode(404)); - - try { - final TrafficManagerApi api = api(server.getUrl("/")).getTrafficManaerApi(); - assertNull(api.getProfile("myprofile")); - assertSent(server, "GET", "/services/WATM/profiles/myprofile"); - } finally { - server.shutdown(); - } - } - - public void checkDNSPrefixAvailability() throws Exception { - final MockWebServer server = mockAzureManagementServer(); - server.enqueue(xmlResponse("/checkdnsprefixavailability.xml")); - - try { - final TrafficManagerApi api = api(server.getUrl("/")).getTrafficManaerApi(); - assertTrue(api.checkDNSPrefixAvailability("jclouds.trafficmanager.net")); - assertSent(server, "GET", "/services/WATM/operations/isavailable/jclouds.trafficmanager.net"); - } finally { - server.shutdown(); - } - } - - public void deleteWhenFound() throws Exception { - final MockWebServer server = mockAzureManagementServer(); - server.enqueue(requestIdResponse("request-1")); - - try { - final TrafficManagerApi api = api(server.getUrl("/")).getTrafficManaerApi(); - assertEquals(api.delete("myprofile"), "request-1"); - assertSent(server, "DELETE", "/services/WATM/profiles/myprofile"); - - } finally { - server.shutdown(); - } - } - - public void deleteWhenNotFound() throws Exception { - final MockWebServer server = mockAzureManagementServer(); - server.enqueue(new MockResponse().setResponseCode(404)); - - try { - final TrafficManagerApi api = api(server.getUrl("/")).getTrafficManaerApi(); - assertNull(api.delete("myprofile")); - assertSent(server, "DELETE", "/services/WATM/profiles/myprofile"); - } finally { - server.shutdown(); - } - } - - public void createProfile() throws Exception { - final MockWebServer server = mockAzureManagementServer(); - server.enqueue(requestIdResponse("request-1")); - - try { - final TrafficManagerApi api = api(server.getUrl("/")).getTrafficManaerApi(); - - final CreateProfileParams params = CreateProfileParams.builder() - .domain("jclouds.trafficmanager.net").name("jclouds").build(); - - assertEquals(api.createProfile(params), "request-1"); - assertSent(server, "POST", "/services/WATM/profiles", "/createprofileparams.xml"); - } finally { - server.shutdown(); - } - } - - public void updateProfile() throws Exception { - final MockWebServer server = mockAzureManagementServer(); - server.enqueue(requestIdResponse("request-1")); - - try { - final TrafficManagerApi api = api(server.getUrl("/")).getTrafficManaerApi(); - - final UpdateProfileParams params = UpdateProfileParams.builder() - .status(ProfileDefinition.Status.ENABLED).build(); - - assertEquals(api.updateProfile("myprofile", params), "request-1"); - assertSent(server, "PUT", "/services/WATM/profiles/myprofile", "/updateprofileparams.xml"); - } finally { - server.shutdown(); - } - } - - public void createDefinition() throws Exception { - final MockWebServer server = mockAzureManagementServer(); - server.enqueue(requestIdResponse("request-1")); - - try { - final TrafficManagerApi api = api(server.getUrl("/")).getTrafficManaerApi(); - - final ImmutableList.Builder<ProfileDefinitionEndpointParams> endpoints - = ImmutableList.<ProfileDefinitionEndpointParams>builder(); - - endpoints.add(ProfileDefinitionEndpointParams.builder() - .domain("jclouds1.cloudapp.net") - .status(ProfileDefinition.Status.ENABLED) - .type(ProfileDefinitionEndpoint.Type.CLOUDSERVICE) - .weight(1).build()); - - endpoints.add(ProfileDefinitionEndpointParams.builder() - .domain("jclouds2.cloudapp.net") - .status(ProfileDefinition.Status.ENABLED) - .type(ProfileDefinitionEndpoint.Type.CLOUDSERVICE) - .weight(1).build()); - - final ProfileDefinitionParams params = ProfileDefinitionParams.builder() - .ttl(300) - .lb(ProfileDefinition.LBMethod.ROUNDROBIN) - .path("/") - .port(80) - .protocol(ProfileDefinition.Protocol.HTTP) - .endpoints(endpoints.build()) - .build(); - - assertEquals(api.createDefinition("myprofile", params), "request-1"); - assertSent(server, "POST", "/services/WATM/profiles/myprofile/definitions", "/profiledefinitioncsparams.xml"); - } finally { - server.shutdown(); - } - } -}
