You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ra...@apache.org on 2014/12/23 05:26:41 UTC
[17/51] [partial] stratos git commit: dropping jclouds 1.8.0 clone
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/gce/1.8.0-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/functions/FirewallToIpPermissionTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/functions/FirewallToIpPermissionTest.java b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/functions/FirewallToIpPermissionTest.java
deleted file mode 100644
index 62f9260..0000000
--- a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/functions/FirewallToIpPermissionTest.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.googlecomputeengine.compute.functions;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-
-import java.net.URI;
-import java.util.Date;
-
-import org.jclouds.googlecomputeengine.domain.Firewall;
-import org.jclouds.net.domain.IpPermission;
-import org.jclouds.net.domain.IpProtocol;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
-import com.google.common.collect.Iterables;
-
-public class FirewallToIpPermissionTest {
-
- @Test
- public void testApply() {
-
- Firewall fw = fwForTest();
-
- FirewallToIpPermission converter = new FirewallToIpPermission();
-
- Iterable<IpPermission> perms = converter.apply(fw);
-
- assertEquals(Iterables.size(perms), 3, "There should be three IpPermissions but there is only " + Iterables.size(perms));
-
- assertTrue(Iterables.any(perms, Predicates.and(hasProtocol(IpProtocol.TCP),
- hasStartAndEndPort(1, 10))), "No permission found for TCP, ports 1-10");
- assertTrue(Iterables.any(perms, Predicates.and(hasProtocol(IpProtocol.TCP),
- hasStartAndEndPort(33, 33))), "No permission found for TCP, port 33");
- assertTrue(Iterables.any(perms, hasProtocol(IpProtocol.ICMP)),
- "No permission found for ICMP");
- }
-
- public static Firewall fwForTest() {
- Firewall.Builder builder = Firewall.builder();
-
- builder.addSourceRange("0.0.0.0/0");
- builder.addAllowed(Firewall.Rule.builder().IpProtocol(IpProtocol.TCP)
- .addPortRange(1, 10).build());
- builder.addAllowed(Firewall.Rule.builder().IpProtocol(IpProtocol.TCP)
- .addPort(33).build());
- builder.addAllowed(Firewall.Rule.builder().IpProtocol(IpProtocol.ICMP).build());
- builder.id("abcd");
- builder.selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/firewalls/jclouds-test"));
- builder.network(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/jclouds-test"));
- builder.creationTimestamp(new Date());
- builder.name("jclouds-test");
-
- return builder.build();
- }
-
- public static Predicate<IpPermission> hasProtocol(final IpProtocol protocol) {
- return new Predicate<IpPermission>() {
-
- @Override
- public boolean apply(IpPermission perm) {
- return protocol.equals(perm.getIpProtocol());
- }
- };
- }
-
- public static Predicate<IpPermission> hasStartAndEndPort(final int startPort, final int endPort) {
- return new Predicate<IpPermission>() {
-
- @Override
- public boolean apply(IpPermission perm) {
- return startPort == perm.getFromPort() && endPort == perm.getToPort();
- }
- };
- }
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/gce/1.8.0-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/functions/GoogleComputeEngineImageToImageTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/functions/GoogleComputeEngineImageToImageTest.java b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/functions/GoogleComputeEngineImageToImageTest.java
deleted file mode 100644
index 239cea5..0000000
--- a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/functions/GoogleComputeEngineImageToImageTest.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.googlecomputeengine.compute.functions;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertSame;
-
-import java.net.URI;
-
-import org.jclouds.compute.domain.OsFamily;
-import org.jclouds.googlecomputeengine.domain.Image;
-import org.testng.annotations.Test;
-
-@Test(groups = "unit")
-public class GoogleComputeEngineImageToImageTest {
-
- Image.Builder imageBuilder = Image.builder()
- .id("1234")
- .selfLink(URI.create("http://test.com"))
- .sourceType("RAW")
- .description("")
- .rawDisk(Image.RawDisk.builder().source("").containerType("TAR").build());
-
- public void testArbitratyImageName() {
- GoogleComputeEngineImageToImage imageToImage = new GoogleComputeEngineImageToImage();
- Image image = imageBuilder.name("arbitratyname").build();
- org.jclouds.compute.domain.Image transformed = imageToImage.apply(image);
- assertEquals(transformed.getName(), image.getName());
- assertEquals(transformed.getId(), image.getName());
- assertEquals(transformed.getProviderId(), image.getId());
- assertSame(transformed.getOperatingSystem().getFamily(), OsFamily.LINUX);
- }
-
- public void testWellFormedImageName() {
- GoogleComputeEngineImageToImage imageToImage = new GoogleComputeEngineImageToImage();
- Image image = imageBuilder.name("ubuntu-12-04-v123123").build();
- org.jclouds.compute.domain.Image transformed = imageToImage.apply(image);
- assertEquals(transformed.getName(), image.getName());
- assertEquals(transformed.getId(), image.getName());
- assertEquals(transformed.getProviderId(), image.getId());
- assertSame(transformed.getOperatingSystem().getFamily(), OsFamily.UBUNTU);
- assertEquals(transformed.getOperatingSystem().getVersion(), "12.04");
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/gce/1.8.0-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/functions/InstanceInZoneToNodeMetadataTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/functions/InstanceInZoneToNodeMetadataTest.java b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/functions/InstanceInZoneToNodeMetadataTest.java
deleted file mode 100644
index dd2416e..0000000
--- a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/functions/InstanceInZoneToNodeMetadataTest.java
+++ /dev/null
@@ -1,286 +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.googlecomputeengine.compute.functions;
-
-import static org.easymock.EasyMock.createMock;
-import static org.testng.Assert.assertEquals;
-import static org.jclouds.compute.domain.Image.Status.AVAILABLE;
-
-import java.net.URI;
-import java.util.Map;
-import java.util.Set;
-
-import org.jclouds.compute.domain.Hardware;
-import org.jclouds.compute.domain.HardwareBuilder;
-import org.jclouds.compute.domain.Image;
-import org.jclouds.compute.domain.ImageBuilder;
-import org.jclouds.compute.domain.NodeMetadata;
-import org.jclouds.compute.domain.OperatingSystem;
-import org.jclouds.compute.domain.OsFamily;
-import org.jclouds.compute.domain.Processor;
-import org.jclouds.compute.domain.Volume.Type;
-import org.jclouds.compute.domain.VolumeBuilder;
-import org.jclouds.compute.functions.GroupNamingConvention;
-import org.jclouds.date.internal.SimpleDateFormatDateService;
-import org.jclouds.domain.Location;
-import org.jclouds.domain.LocationBuilder;
-import org.jclouds.domain.LocationScope;
-import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
-import org.jclouds.googlecomputeengine.domain.Instance;
-import org.jclouds.googlecomputeengine.domain.InstanceInZone;
-import org.jclouds.googlecomputeengine.domain.Metadata;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Function;
-import com.google.common.base.Predicate;
-import com.google.common.base.Supplier;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Maps;
-
-@Test(groups = "unit", testName = "InstanceInZoneToNodeMetadataTest")
-public class InstanceInZoneToNodeMetadataTest {
-
- /**
- * GroupNamingConvention that always returns the same name provided in the constructor.
- * The predicates returned always evaluate to true.
- *
- */
- class FixedGroupNamingConvention implements GroupNamingConvention {
- private final String name;
-
- public FixedGroupNamingConvention(final String name) {
- this.name = name;
- }
-
- @Override
- public String sharedNameForGroup(final String group) {
- return name;
- }
-
- @Override
- public String uniqueNameForGroup(final String group) {
- return name;
- }
-
- @Override
- public String groupInUniqueNameOrNull(final String encoded) {
- return name;
- }
-
- @Override
- public String groupInSharedNameOrNull(final String encoded) {
- return name;
- }
-
- @Override
- public Predicate<String> containsGroup(final String group) {
- return new Predicate<String>() {
- @Override
- public boolean apply(final String input) {
- return true;
- }
- };
- }
-
- @Override
- public Predicate<String> containsAnyGroup() {
- return new Predicate<String>() {
- @Override
- public boolean apply(final String input) {
- return true;
- }
- };
- }
-
- @Override
- public String extractGroup(final String encoded) {
- return name;
- }
- }
-
- private Instance instance;
-
- private Set<Hardware> hardwares;
-
- private Set<Image> images;
-
- private Set<Location> locations;
-
- private InstanceInZoneToNodeMetadata groupGroupNodeParser;
- private InstanceInZoneToNodeMetadata groupNullNodeParser;
-
- @BeforeMethod
- public final void setup() {
- instance = Instance.builder()
- .id("13051190678907570425")
- .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2012-11-25T23:48:20.758"))
- .selfLink(URI.create("https://www.googleapis"
- + ".com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-0"))
- .description("desc")
- .name("test-0")
- .machineType(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/"
- + "machineTypes/n1-standard-1"))
- .status(Instance.Status.RUNNING)
- .zone(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a"))
- .addNetworkInterface(
- Instance.NetworkInterface.builder()
- .name("nic0")
- .networkIP("10.240.121.115")
- .network(URI.create("https://www.googleapis"
- + ".com/compute/v1/projects/myproject/global/networks/default"))
- .build())
- .addDisk(
- Instance.PersistentAttachedDisk.builder()
- .index(0)
- .mode(Instance.PersistentAttachedDisk.Mode.READ_WRITE)
- .deviceName("test")
- .source(URI.create("https://www.googleapis"
- + ".com/compute/v1/projects/myproject/zones/us-central1-a/disks/test"))
- .boot(true)
- .build())
- .tags(Instance.Tags.builder().fingerprint("abcd").addItem("aTag").addItem("Group-port-42").build())
- .metadata(Metadata.builder()
- .items(ImmutableMap.of("aKey", "aValue",
- "jclouds-image",
- "https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images/gcel-12-04-v20121106",
- "jclouds-delete-boot-disk", "true"))
- .fingerprint("efgh")
- .build())
- .addServiceAccount(Instance.ServiceAccount.builder().email("default").addScopes("myscope").build())
- .build();
-
- images = ImmutableSet.of(new ImageBuilder()
- .id("1")
- .uri(URI.create("https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images/"
- + "gcel-12-04-v20121106"))
- .providerId("1")
- .name("mock image")
- .status(AVAILABLE)
- .operatingSystem(
- OperatingSystem.builder().name("Ubuntu 14.04 x86_64").description("Ubuntu").family(OsFamily.UBUNTU)
- .version("10.04").arch("x86_64").is64Bit(true).build()).build());
-
- hardwares = ImmutableSet.of(new HardwareBuilder().id("my_id")
- .uri(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/machineTypes/"
- + "n1-standard-1"))
- .providerId("1")
- .name("mock hardware").processor(new Processor(1.0, 1.0)).ram(2048)
- .volume(new VolumeBuilder().size(20f).type(Type.LOCAL).build()).build());
-
- locations = ImmutableSet.of(new LocationBuilder()
- .id("id")
- .description("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a")
- .scope(LocationScope.REGION)
- .parent(
- new LocationBuilder().id("0").description("mock parent location").scope(LocationScope.PROVIDER)
- .build()).build());
-
- groupGroupNodeParser = createNodeParser(hardwares, images, locations, "Group");
- groupNullNodeParser = createNodeParser(hardwares, images, locations, null);
- }
-
- private InstanceInZoneToNodeMetadata createNodeParser(final Set<Hardware> hardware, final Set<Image> images,
- final Set<Location> locations, final String groupName) {
- Supplier<Map<URI, ? extends Location>> locationSupplier = new Supplier<Map<URI, ? extends Location>>() {
- @Override
- public Map<URI, ? extends Location> get() {
- return Maps.uniqueIndex(locations, new Function<Location, URI>() {
- @Override
- public URI apply(final Location input) {
- return URI.create(input.getDescription());
- }
- });
- }
- };
-
- Supplier<Map<URI, ? extends Hardware>> hardwareSupplier = new Supplier<Map<URI, ? extends Hardware>>() {
- @Override
- public Map<URI, ? extends Hardware> get() {
- return Maps.uniqueIndex(hardware, new Function<Hardware, URI>() {
- @Override
- public URI apply(final Hardware input) {
- return input.getUri();
- }
- });
- }
- };
-
- Supplier<Map<URI, ? extends Image>> imageSupplier = new Supplier<Map<URI, ? extends Image>>() {
- @Override
- public Map<URI, ? extends Image> get() {
- return Maps.uniqueIndex(images, new Function<Image, URI>() {
- @Override
- public URI apply(final Image input) {
- return input.getUri();
- }
- });
- }
- };
-
- Supplier<String> userProjectSupplier = new Supplier<String>() {
- @Override
- public String get() {
- return "userProject";
- }
- };
-
- GroupNamingConvention.Factory namingConventionFactory =
- new GroupNamingConvention.Factory() {
- @Override
- public GroupNamingConvention createWithoutPrefix() {
- return new FixedGroupNamingConvention(groupName);
- }
-
- @Override
- public GroupNamingConvention create() {
- return new FixedGroupNamingConvention(groupName);
- }
- };
-
- return new InstanceInZoneToNodeMetadata(
- ImmutableMap.<Instance.Status, NodeMetadata.Status>builder()
- .put(Instance.Status.RUNNING, NodeMetadata.Status.PENDING).build(),
- namingConventionFactory,
- imageSupplier,
- hardwareSupplier,
- locationSupplier,
- new FirewallTagNamingConvention.Factory(namingConventionFactory),
- createMock(GoogleComputeEngineApi.class),
- userProjectSupplier);
- }
-
- @Test
- public final void testTagFilteringWorks() {
- InstanceInZone instanceInZone = new InstanceInZone(instance, "zoneId");
- NodeMetadata nodeMetadata = groupGroupNodeParser.apply(instanceInZone);
- assertEquals(nodeMetadata.getId(), "id/test-0");
- assertEquals(nodeMetadata.getTags(), ImmutableSet.<String>of(
- "aTag" // "aTag" kept as a non firewall tag.
- // "Group-port-42" filtered out as a firewall tag.
- ));
- }
-
- @Test
- public final void testInstanceWithGroupNull() {
- InstanceInZone instanceInZone = new InstanceInZone(instance, "zoneId");
- NodeMetadata nodeMetadata = groupNullNodeParser.apply(instanceInZone);
- assertEquals(nodeMetadata.getId(), "id/test-0");
- assertEquals(nodeMetadata.getTags(), ImmutableSet.<String>of("aTag", "Group-port-42"));
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/gce/1.8.0-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/functions/NetworkToSecurityGroupTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/functions/NetworkToSecurityGroupTest.java b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/functions/NetworkToSecurityGroupTest.java
deleted file mode 100644
index 795c989..0000000
--- a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/functions/NetworkToSecurityGroupTest.java
+++ /dev/null
@@ -1,94 +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.googlecomputeengine.compute.functions;
-
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.jclouds.googlecomputeengine.compute.functions.FirewallToIpPermissionTest.hasProtocol;
-import static org.jclouds.googlecomputeengine.compute.functions.FirewallToIpPermissionTest.hasStartAndEndPort;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-
-import java.net.URI;
-import java.util.Date;
-
-import org.jclouds.collect.IterableWithMarkers;
-import org.jclouds.collect.PagedIterables;
-import org.jclouds.compute.domain.SecurityGroup;
-import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
-import org.jclouds.googlecomputeengine.domain.Network;
-import org.jclouds.googlecomputeengine.features.FirewallApi;
-import org.jclouds.googlecomputeengine.options.ListOptions;
-import org.jclouds.googlecomputeengine.options.ListOptions.Builder;
-import org.jclouds.net.domain.IpProtocol;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Predicates;
-import com.google.common.base.Supplier;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-
-public class NetworkToSecurityGroupTest {
-
- @Test
- public void testApply() {
- Supplier<String> projectSupplier = new Supplier<String>() {
- @Override
- public String get() {
- return "myproject";
- }
- };
-
- FirewallToIpPermission fwToPerm = new FirewallToIpPermission();
-
- GoogleComputeEngineApi api = createMock(GoogleComputeEngineApi.class);
- FirewallApi fwApi = createMock(FirewallApi.class);
-
- ListOptions options = new Builder().filter("network eq .*/jclouds-test");
- expect(api.getFirewallApiForProject(projectSupplier.get()))
- .andReturn(fwApi);
- expect(fwApi.list(options)).andReturn(PagedIterables.of(IterableWithMarkers.from(ImmutableSet.of(FirewallToIpPermissionTest.fwForTest()))));
-
- replay(api, fwApi);
- Network.Builder builder = Network.builder();
-
- builder.id("abcd");
- builder.selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/jclouds-test"));
- builder.creationTimestamp(new Date());
- builder.description("some description");
- builder.gatewayIPv4("1.2.3.4");
- builder.IPv4Range("0.0.0.0/0");
- builder.name("jclouds-test");
-
- Network network = builder.build();
-
- NetworkToSecurityGroup netToSg = new NetworkToSecurityGroup(fwToPerm, api, projectSupplier);
-
- SecurityGroup group = netToSg.apply(network);
-
- assertEquals(group.getId(), "jclouds-test");
- assertEquals(group.getUri(), URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/jclouds-test"));
- assertEquals(group.getIpPermissions().size(), 3);
- assertTrue(Iterables.any(group.getIpPermissions(), Predicates.and(hasProtocol(IpProtocol.TCP),
- hasStartAndEndPort(1, 10))), "No permission found for TCP, ports 1-10");
- assertTrue(Iterables.any(group.getIpPermissions(), Predicates.and(hasProtocol(IpProtocol.TCP),
- hasStartAndEndPort(33, 33))), "No permission found for TCP, port 33");
- assertTrue(Iterables.any(group.getIpPermissions(), hasProtocol(IpProtocol.ICMP)),
- "No permission found for ICMP");
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/gce/1.8.0-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/functions/OrphanedGroupsFromDeadNodesTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/functions/OrphanedGroupsFromDeadNodesTest.java b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/functions/OrphanedGroupsFromDeadNodesTest.java
deleted file mode 100644
index cae3432..0000000
--- a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/functions/OrphanedGroupsFromDeadNodesTest.java
+++ /dev/null
@@ -1,136 +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.googlecomputeengine.compute.functions;
-
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.testng.Assert.assertSame;
-import static org.testng.Assert.assertTrue;
-
-import java.util.Set;
-
-import org.easymock.EasyMock;
-import org.jclouds.compute.ComputeService;
-import org.jclouds.compute.domain.ComputeMetadata;
-import org.jclouds.compute.domain.NodeMetadata;
-import org.jclouds.compute.domain.internal.NodeMetadataImpl;
-import org.jclouds.googlecomputeengine.compute.predicates.AllNodesInGroupTerminated;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Predicate;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Sets;
-
-public class OrphanedGroupsFromDeadNodesTest {
-
- private static class IdAndGroupOnlyNodeMetadata extends NodeMetadataImpl {
-
- public IdAndGroupOnlyNodeMetadata(String id, String group, Status status) {
- super(null, null, id, null, null, ImmutableMap.<String, String>of(), ImmutableSet.<String>of(), group, null,
- null, null, status, null, 0, ImmutableSet.<String>of(), ImmutableSet.<String>of(), null, null);
- }
- }
-
-
- @Test
- public void testDetectsAllOrphanedGroupsWhenAllNodesTerminated() {
-
- Set<? extends NodeMetadata> deadNodesGroup1 = (Set) ImmutableSet.builder()
- .add(new IdAndGroupOnlyNodeMetadata("a", "1", NodeMetadata.Status.TERMINATED)).build();
-
- Set<? extends NodeMetadata> deadNodesGroup2 = (Set) ImmutableSet.builder()
- .add(new IdAndGroupOnlyNodeMetadata("b", "2", NodeMetadata.Status.TERMINATED)).build();
-
- Set<? extends NodeMetadata> allDeadNodes = Sets.union(deadNodesGroup1, deadNodesGroup2);
-
- ComputeService mock = createMock(ComputeService.class);
- expect(mock.listNodesDetailsMatching(EasyMock.<Predicate<ComputeMetadata>>anyObject()))
- .andReturn((Set) deadNodesGroup1).once();
- expect(mock.listNodesDetailsMatching(EasyMock.<Predicate<ComputeMetadata>>anyObject()))
- .andReturn((Set) deadNodesGroup2).once();
-
- replay(mock);
-
- OrphanedGroupsFromDeadNodes orphanedGroupsFromDeadNodes = new OrphanedGroupsFromDeadNodes(new
- AllNodesInGroupTerminated(mock));
-
- Set<String> orphanedGroups = orphanedGroupsFromDeadNodes.apply(allDeadNodes);
-
- assertSame(orphanedGroups.size(), 2);
- assertTrue(orphanedGroups.contains("1"));
- assertTrue(orphanedGroups.contains("2"));
- }
-
- @Test
- public void testDetectsAllOrphanedGroupsWhenSomeNodesTerminatedAndOtherMissing() {
-
- Set<? extends NodeMetadata> deadNodesGroup1 = (Set) ImmutableSet.builder()
- .add(new IdAndGroupOnlyNodeMetadata("a", "1", NodeMetadata.Status.TERMINATED)).build();
-
- Set<? extends NodeMetadata> deadNodesGroup2 = (Set) ImmutableSet.builder()
- .add(new IdAndGroupOnlyNodeMetadata("b", "2", NodeMetadata.Status.TERMINATED)).build();
-
- Set<? extends NodeMetadata> allDeadNodes = Sets.union(deadNodesGroup1, deadNodesGroup2);
-
- ComputeService mock = createMock(ComputeService.class);
- expect(mock.listNodesDetailsMatching(EasyMock.<Predicate<ComputeMetadata>>anyObject()))
- .andReturn((Set) deadNodesGroup1).once();
- expect(mock.listNodesDetailsMatching(EasyMock.<Predicate<ComputeMetadata>>anyObject()))
- .andReturn((Set) ImmutableSet.of()).once();
-
- replay(mock);
-
- OrphanedGroupsFromDeadNodes orphanedGroupsFromDeadNodes = new OrphanedGroupsFromDeadNodes(new
- AllNodesInGroupTerminated(mock));
-
- Set<String> orphanedGroups = orphanedGroupsFromDeadNodes.apply(allDeadNodes);
-
- assertSame(orphanedGroups.size(), 2);
- assertTrue(orphanedGroups.contains("1"));
- assertTrue(orphanedGroups.contains("2"));
- }
-
- @Test
- public void testDetectsAllOrphanedGroupsWhenSomeNodesAreAlive() {
-
- Set<? extends NodeMetadata> deadNodesGroup1 = (Set) ImmutableSet.builder()
- .add(new IdAndGroupOnlyNodeMetadata("a", "1", NodeMetadata.Status.TERMINATED)).build();
-
- Set<? extends NodeMetadata> deadNodesGroup2 = (Set) ImmutableSet.builder()
- .add(new IdAndGroupOnlyNodeMetadata("b", "2", NodeMetadata.Status.RUNNING)).build();
-
- Set<? extends NodeMetadata> allDeadNodes = Sets.union(deadNodesGroup1, deadNodesGroup2);
-
- ComputeService mock = createMock(ComputeService.class);
- expect(mock.listNodesDetailsMatching(EasyMock.<Predicate<ComputeMetadata>>anyObject()))
- .andReturn((Set) deadNodesGroup1).once();
- expect(mock.listNodesDetailsMatching(EasyMock.<Predicate<ComputeMetadata>>anyObject()))
- .andReturn((Set) deadNodesGroup2).once();
-
- replay(mock);
-
- OrphanedGroupsFromDeadNodes orphanedGroupsFromDeadNodes = new OrphanedGroupsFromDeadNodes(new
- AllNodesInGroupTerminated(mock));
-
- Set<String> orphanedGroups = orphanedGroupsFromDeadNodes.apply(allDeadNodes);
-
- assertSame(orphanedGroups.size(), 1);
- assertTrue(orphanedGroups.contains("1"));
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/gce/1.8.0-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/loaders/FindNetworkOrCreateTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/loaders/FindNetworkOrCreateTest.java b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/loaders/FindNetworkOrCreateTest.java
deleted file mode 100644
index 467995f..0000000
--- a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/test/java/org/jclouds/googlecomputeengine/compute/loaders/FindNetworkOrCreateTest.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.googlecomputeengine.compute.loaders;
-
-import static com.google.common.base.Optional.fromNullable;
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-import static org.testng.Assert.assertEquals;
-
-import java.net.URI;
-
-import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
-import org.jclouds.googlecomputeengine.domain.Network;
-import org.jclouds.googlecomputeengine.domain.Operation;
-import org.jclouds.googlecomputeengine.domain.internal.NetworkAndAddressRange;
-import org.jclouds.googlecomputeengine.features.GlobalOperationApi;
-import org.jclouds.googlecomputeengine.features.NetworkApi;
-import org.jclouds.googlecomputeengine.functions.CreateNetworkIfNeeded;
-import org.jclouds.googlecomputeengine.predicates.GlobalOperationDonePredicate;
-import org.jclouds.http.HttpResponse;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Supplier;
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.LoadingCache;
-
-public class FindNetworkOrCreateTest {
-
- @Test
- public void testLoadExisting() {
- final GoogleComputeEngineApi api = createMock(GoogleComputeEngineApi.class);
- final NetworkApi nwApi = createMock(NetworkApi.class);
-
- Network network = Network.builder().IPv4Range("0.0.0.0/0")
- .id("abcd").name("this-network")
- .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/this-network"))
- .build();
-
- final Supplier<String> userProject = new Supplier<String>() {
- @Override
- public String get() {
- return "myproject";
- }
- };
-
- expect(api.getNetworkApiForProject(userProject.get())).andReturn(nwApi).atLeastOnce();
-
- expect(nwApi.get("this-network")).andReturn(network);
-
- replay(api, nwApi);
-
- NetworkAndAddressRange input = new NetworkAndAddressRange("this-network", "0.0.0.0/0", null);
-
- GlobalOperationDonePredicate pred = new GlobalOperationDonePredicate(api, userProject);
-
- CreateNetworkIfNeeded creator = new CreateNetworkIfNeeded(api, userProject, pred, 100l, 100l);
-
- FindNetworkOrCreate loader = new FindNetworkOrCreate(api, creator, userProject);
-
- LoadingCache<NetworkAndAddressRange, Network> cache = CacheBuilder.newBuilder().build(loader);
-
- assertEquals(cache.getUnchecked(input), network);
-
- // Second call is to ensure we only need to make the API calls once.
- assertEquals(cache.getUnchecked(input), network);
-
- verify(api, nwApi);
- }
-
- @Test
- public void testLoadNew() {
- final GoogleComputeEngineApi api = createMock(GoogleComputeEngineApi.class);
- final NetworkApi nwApi = createMock(NetworkApi.class);
- final GlobalOperationApi globalApi = createMock(GlobalOperationApi.class);
-
- Network network = Network.builder().IPv4Range("0.0.0.0/0")
- .id("abcd").name("this-network")
- .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/this-network"))
- .build();
-
- Operation createOp = createMock(Operation.class);
-
- final Supplier<String> userProject = new Supplier<String>() {
- @Override
- public String get() {
- return "myproject";
- }
- };
-
- expect(api.getNetworkApiForProject(userProject.get())).andReturn(nwApi).atLeastOnce();
- expect(api.getGlobalOperationApiForProject(userProject.get())).andReturn(globalApi).atLeastOnce();
-
- expect(nwApi.createInIPv4Range("this-network", "0.0.0.0/0"))
- .andReturn(createOp);
- expect(globalApi.get("create-op")).andReturn(createOp);
- // pre-creation
- expect(nwApi.get("this-network")).andReturn(null).times(2);
- // post-creation
- expect(nwApi.get("this-network")).andReturn(network);
-
- expect(createOp.getName()).andReturn("create-op");
- expect(createOp.getStatus()).andReturn(Operation.Status.DONE);
- expect(createOp.getHttpError()).andReturn(fromNullable((HttpResponse)null));
- replay(api, nwApi, createOp, globalApi);
-
- NetworkAndAddressRange input = new NetworkAndAddressRange("this-network", "0.0.0.0/0", null);
-
- GlobalOperationDonePredicate pred = new GlobalOperationDonePredicate(api, userProject);
-
- CreateNetworkIfNeeded creator = new CreateNetworkIfNeeded(api, userProject, pred, 100l, 100l);
-
- FindNetworkOrCreate loader = new FindNetworkOrCreate(api, creator, userProject);
-
- LoadingCache<NetworkAndAddressRange, Network> cache = CacheBuilder.newBuilder().build(loader);
-
- assertEquals(cache.getUnchecked(input), network);
-
- // Second call is to ensure we only need to make the API calls once.
- assertEquals(cache.getUnchecked(input), network);
-
- verify(api, nwApi, globalApi, createOp);
-
- }
-}
-
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/gce/1.8.0-stratos/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiExpectTest.java b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiExpectTest.java
deleted file mode 100644
index 1816b78..0000000
--- a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiExpectTest.java
+++ /dev/null
@@ -1,163 +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.googlecomputeengine.features;
-
-import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
-import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-import static org.testng.AssertJUnit.assertNull;
-
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
-import org.jclouds.googlecomputeengine.parse.ParseAddressListTest;
-import org.jclouds.googlecomputeengine.parse.ParseAddressTest;
-import org.jclouds.googlecomputeengine.parse.ParseOperationTest;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpResponse;
-import org.testng.annotations.Test;
-
-@Test(groups = "unit")
-public class AddressApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
-
- public void testGetAddressResponseIs2xx() throws Exception {
- HttpRequest get = HttpRequest
- .builder()
- .method("GET")
- .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1/addresses/test-ip1")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/address_get.json")).build();
-
- AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, get, operationResponse).getAddressApiForProject("myproject");
-
- assertEquals(api.getInRegion("us-central1", "test-ip1"),
- new ParseAddressTest().expected());
- }
-
- public void testGetAddressResponseIs4xx() throws Exception {
- HttpRequest get = HttpRequest
- .builder()
- .method("GET")
- .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1/addresses/test-ip1")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
-
- AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, get, operationResponse).getAddressApiForProject("myproject");
-
- assertNull(api.getInRegion("us-central1", "test-ip1"));
- }
-
- public void testInsertAddressResponseIs2xx() {
- HttpRequest insert = HttpRequest
- .builder()
- .method("POST")
- .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1/addresses")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN)
- .payload(payloadFromResourceWithContentType("/address_insert.json", MediaType.APPLICATION_JSON))
- .build();
-
- HttpResponse insertAddressResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/region_operation.json")).build();
-
- AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, insert,
- insertAddressResponse).getAddressApiForProject("myproject");
-
- assertEquals(api.createInRegion("us-central1", "test-ip1"), new ParseOperationTest().expected());
- }
-
- public void testDeleteAddressResponseIs2xx() {
- HttpRequest delete = HttpRequest
- .builder()
- .method("DELETE")
- .endpoint("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/regions/us-central1/addresses/test-ip1")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse deleteResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/region_operation.json")).build();
-
- AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, delete, deleteResponse).getAddressApiForProject("myproject");
-
- assertEquals(api.deleteInRegion("us-central1", "test-ip1"),
- new ParseOperationTest().expected());
- }
-
- public void testDeleteAddressResponseIs4xx() {
- HttpRequest delete = HttpRequest
- .builder()
- .method("DELETE")
- .endpoint("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/regions/us-central1/addresses/test-ip1")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build();
-
- AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, delete, deleteResponse).getAddressApiForProject("myproject");
-
- assertNull(api.deleteInRegion("us-central1", "test-ip1"));
- }
-
- public void testListAddresssResponseIs2xx() {
- HttpRequest list = HttpRequest
- .builder()
- .method("GET")
- .endpoint("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/regions/us-central1/addresses")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/address_list.json")).build();
-
- AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, list, operationResponse).getAddressApiForProject("myproject");
-
- assertEquals(api.listFirstPageInRegion("us-central1").toString(),
- new ParseAddressListTest().expected().toString());
- }
-
- public void testListAddresssResponseIs4xx() {
- HttpRequest list = HttpRequest
- .builder()
- .method("GET")
- .endpoint("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/regions/us-central1/addresses")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
-
- AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, list, operationResponse).getAddressApiForProject("myproject");
-
- assertTrue(api.listInRegion("us-central1").concat().isEmpty());
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/gce/1.8.0-stratos/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiLiveTest.java b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiLiveTest.java
deleted file mode 100644
index c11d04e..0000000
--- a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiLiveTest.java
+++ /dev/null
@@ -1,71 +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.googlecomputeengine.features;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-
-import java.util.List;
-
-import org.jclouds.collect.PagedIterable;
-import org.jclouds.googlecomputeengine.domain.Address;
-import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
-import org.jclouds.googlecomputeengine.options.ListOptions;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.Lists;
-
-public class AddressApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
-
- private static final String ADDRESS_NAME = "address-api-live-test-address";
- private static final int TIME_WAIT = 30;
-
- private AddressApi api() {
- return api.getAddressApiForProject(userProject.get());
- }
-
- @Test(groups = "live")
- public void testInsertAddress() {
-
- assertRegionOperationDoneSucessfully(api().createInRegion(DEFAULT_REGION_NAME, ADDRESS_NAME), TIME_WAIT);
- }
-
- @Test(groups = "live", dependsOnMethods = "testInsertAddress")
- public void testGetAddress() {
- Address address = api().getInRegion(DEFAULT_REGION_NAME, ADDRESS_NAME);
- assertNotNull(address);
- assertEquals(address.getName(), ADDRESS_NAME);
- }
-
- @Test(groups = "live", dependsOnMethods = "testGetAddress")
- public void testListAddress() {
-
- PagedIterable<Address> addresss = api().listInRegion(DEFAULT_REGION_NAME, new ListOptions.Builder()
- .filter("name eq " + ADDRESS_NAME));
-
- List<Address> addresssAsList = Lists.newArrayList(addresss.concat());
-
- assertEquals(addresssAsList.size(), 1);
-
- }
-
- @Test(groups = "live", dependsOnMethods = "testListAddress")
- public void testDeleteAddress() {
-
- assertRegionOperationDoneSucessfully(api().deleteInRegion(DEFAULT_REGION_NAME, ADDRESS_NAME), TIME_WAIT);
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/gce/1.8.0-stratos/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiExpectTest.java b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiExpectTest.java
deleted file mode 100644
index 6aaf8fa..0000000
--- a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiExpectTest.java
+++ /dev/null
@@ -1,226 +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.googlecomputeengine.features;
-
-import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
-import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-import static org.testng.AssertJUnit.assertNull;
-
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
-import org.jclouds.googlecomputeengine.parse.ParseDiskListTest;
-import org.jclouds.googlecomputeengine.parse.ParseDiskTest;
-import org.jclouds.googlecomputeengine.parse.ParseOperationTest;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpResponse;
-import org.testng.annotations.Test;
-
-@Test(groups = "unit")
-public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
- public static final String IMAGE_URL = "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/images/foo";
-
- public void testGetDiskResponseIs2xx() throws Exception {
- HttpRequest get = HttpRequest
- .builder()
- .method("GET")
- .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks/testimage1")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/disk_get.json")).build();
-
- DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, get, operationResponse).getDiskApiForProject("myproject");
-
- assertEquals(api.getInZone("us-central1-a", "testimage1"),
- new ParseDiskTest().expected());
- }
-
- public void testGetDiskResponseIs4xx() throws Exception {
- HttpRequest get = HttpRequest
- .builder()
- .method("GET")
- .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks/testimage1")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
-
- DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, get, operationResponse).getDiskApiForProject("myproject");
-
- assertNull(api.getInZone("us-central1-a", "testimage1"));
- }
-
- public void testInsertDiskResponseIs2xx() {
- HttpRequest insert = HttpRequest
- .builder()
- .method("POST")
- .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN)
- .payload(payloadFromResourceWithContentType("/disk_insert.json", MediaType.APPLICATION_JSON))
- .build();
-
- HttpResponse insertDiskResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/zone_operation.json")).build();
-
- DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, insert,
- insertDiskResponse).getDiskApiForProject("myproject");
-
- assertEquals(api.createInZone("testimage1", 1, "us-central1-a"), new ParseOperationTest().expected());
- }
-
- public void testInsertDiskFromImageResponseIs2xx() {
- HttpRequest insert = HttpRequest
- .builder()
- .method("POST")
- .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks"
- + "?sourceImage=" + IMAGE_URL.replaceAll(":", "%3A"))
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN)
- .payload(payloadFromResourceWithContentType("/disk_insert.json", MediaType.APPLICATION_JSON))
- .build();
-
- HttpResponse insertDiskResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/zone_operation.json")).build();
-
- DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, insert,
- insertDiskResponse).getDiskApiForProject("myproject");
-
- assertEquals(api.createFromImageWithSizeInZone(IMAGE_URL, "testimage1", 1, "us-central1-a"), new ParseOperationTest().expected());
- }
-
- public void testCreateSnapshotResponseIs2xx() {
- HttpRequest createSnapshotRequest = HttpRequest
- .builder()
- .method("POST")
- .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks"
- + "/testimage1/createSnapshot")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN)
- .payload(payloadFromResourceWithContentType("/disk_create_snapshot.json", MediaType.APPLICATION_JSON))
- .build();
-
- HttpResponse createSnapshotResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/zone_operation.json")).build();
-
- DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, createSnapshotRequest,
- createSnapshotResponse).getDiskApiForProject("myproject");
-
- assertEquals(api.createSnapshotInZone("us-central1-a", "testimage1", "test-snap"), new ParseOperationTest().expected());
- }
-
- public void testCreateSnapshotResponseIs4xx() {
- HttpRequest createSnapshotRequest = HttpRequest
- .builder()
- .method("POST")
- .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks"
- + "/testimage1/createSnapshot")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN)
- .payload(payloadFromResourceWithContentType("/disk_create_snapshot.json", MediaType.APPLICATION_JSON))
- .build();
-
- HttpResponse createSnapshotResponse = HttpResponse.builder().statusCode(404).build();
-
- DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, createSnapshotRequest,
- createSnapshotResponse).getDiskApiForProject("myproject");
-
- assertNull(api.createSnapshotInZone("us-central1-a", "testimage1", "test-snap"));
- }
-
- public void testDeleteDiskResponseIs2xx() {
- HttpRequest delete = HttpRequest
- .builder()
- .method("DELETE")
- .endpoint("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/zones/us-central1-a/disks/testimage1")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse deleteResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/zone_operation.json")).build();
-
- DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, delete, deleteResponse).getDiskApiForProject("myproject");
-
- assertEquals(api.deleteInZone("us-central1-a", "testimage1"),
- new ParseOperationTest().expected());
- }
-
- public void testDeleteDiskResponseIs4xx() {
- HttpRequest delete = HttpRequest
- .builder()
- .method("DELETE")
- .endpoint("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/zones/us-central1-a/disks/testimage1")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build();
-
- DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, delete, deleteResponse).getDiskApiForProject("myproject");
-
- assertNull(api.deleteInZone("us-central1-a", "testimage1"));
- }
-
- public void testListDisksResponseIs2xx() {
- HttpRequest list = HttpRequest
- .builder()
- .method("GET")
- .endpoint("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/zones/us-central1-a/disks")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/disk_list.json")).build();
-
- DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, list, operationResponse).getDiskApiForProject("myproject");
-
- assertEquals(api.listFirstPageInZone("us-central1-a").toString(),
- new ParseDiskListTest().expected().toString());
- }
-
- public void testListDisksResponseIs4xx() {
- HttpRequest list = HttpRequest
- .builder()
- .method("GET")
- .endpoint("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/zones/us-central1-a/disks")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
-
- DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, list, operationResponse).getDiskApiForProject("myproject");
-
- assertTrue(api.listInZone("us-central1-a").concat().isEmpty());
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/gce/1.8.0-stratos/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiLiveTest.java b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiLiveTest.java
deleted file mode 100644
index bd26621..0000000
--- a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiLiveTest.java
+++ /dev/null
@@ -1,85 +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.googlecomputeengine.features;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-
-import java.util.List;
-
-import org.jclouds.collect.PagedIterable;
-import org.jclouds.googlecomputeengine.domain.Disk;
-import org.jclouds.googlecomputeengine.domain.Project;
-import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
-import org.jclouds.googlecomputeengine.options.ListOptions;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-
-public class DiskApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
-
- public static final String DISK_NAME = "disk-api-live-test-disk";
- public static final int TIME_WAIT = 30;
- public static final int sizeGb = 1;
-
- private DiskApi api() {
- return api.getDiskApiForProject(userProject.get());
- }
-
- @Test(groups = "live")
- public void testInsertDisk() {
- Project project = api.getProjectApi().get(userProject.get());
- assertZoneOperationDoneSucessfully(api().createInZone(DISK_NAME, sizeGb, DEFAULT_ZONE_NAME), TIME_WAIT);
-
- }
-
- @Test(groups = "live", dependsOnMethods = "testInsertDisk")
- public void testGetDisk() {
-
- Disk disk = api().getInZone(DEFAULT_ZONE_NAME, DISK_NAME);
- assertNotNull(disk);
- assertDiskEquals(disk);
- }
-
- @Test(groups = "live", dependsOnMethods = "testGetDisk")
- public void testListDisk() {
-
- PagedIterable<Disk> disks = api().listInZone(DEFAULT_ZONE_NAME, new ListOptions.Builder()
- .filter("name eq " + DISK_NAME));
-
- List<Disk> disksAsList = Lists.newArrayList(disks.concat());
-
- assertEquals(disksAsList.size(), 1);
-
- assertDiskEquals(Iterables.getOnlyElement(disksAsList));
-
- }
-
- @Test(groups = "live", dependsOnMethods = "testListDisk")
- public void testDeleteDisk() {
-
- assertZoneOperationDoneSucessfully(api().deleteInZone(DEFAULT_ZONE_NAME, DISK_NAME), TIME_WAIT);
- }
-
- private void assertDiskEquals(Disk result) {
- assertEquals(result.getName(), DISK_NAME);
- assertEquals(result.getSizeGb(), sizeGb);
- assertEquals(result.getZone(), getDefaultZoneUrl(userProject.get()));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/gce/1.8.0-stratos/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiExpectTest.java b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiExpectTest.java
deleted file mode 100644
index 7a5759b..0000000
--- a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiExpectTest.java
+++ /dev/null
@@ -1,301 +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.googlecomputeengine.features;
-
-import static com.google.common.base.Joiner.on;
-import static com.google.common.collect.Iterables.transform;
-import static java.lang.String.format;
-import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
-import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
-import static org.jclouds.io.Payloads.newStringPayload;
-import static org.jclouds.util.Strings2.toStringAndClose;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-import static org.testng.AssertJUnit.assertNull;
-
-import java.io.IOException;
-import java.net.URI;
-import java.util.Set;
-
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.googlecomputeengine.domain.Firewall;
-import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
-import org.jclouds.googlecomputeengine.options.FirewallOptions;
-import org.jclouds.googlecomputeengine.parse.ParseFirewallListTest;
-import org.jclouds.googlecomputeengine.parse.ParseFirewallTest;
-import org.jclouds.googlecomputeengine.parse.ParseOperationTest;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.io.Payload;
-import org.jclouds.net.domain.IpProtocol;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Function;
-import com.google.common.collect.ImmutableSet;
-
-@Test(groups = "unit")
-public class FirewallApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
-
- public static final HttpRequest GET_FIREWALL_REQUEST = HttpRequest
- .builder()
- .method("GET")
- .endpoint("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/global/firewalls/jclouds-test")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- public static HttpResponse GET_FIREWALL_RESPONSE = HttpResponse.builder().statusCode(200)
- .payload(staticPayloadFromResource("/firewall_get.json")).build();
-
- public void testGetFirewallResponseIs2xx() throws Exception {
-
- FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, GET_FIREWALL_REQUEST, GET_FIREWALL_RESPONSE).getFirewallApiForProject("myproject");
-
- assertEquals(api.get("jclouds-test"), new ParseFirewallTest().expected());
- }
-
-
- public static Payload firewallPayloadFirewallOfName(String firewallName,
- String networkName,
- Set<String> sourceRanges,
- Set<String> sourceTags,
- Set<String> targetTags,
- Set<String> portRanges) throws IOException {
- Function<String, String> addQuotes = new Function<String, String>() {
- @Override
- public String apply(String input) {
- return "\"" + input + "\"";
- }
- };
-
- String ports = on(",").skipNulls().join(transform(portRanges, addQuotes));
-
- Payload payload = newStringPayload(
- format(toStringAndClose(FirewallApiExpectTest.class.getResourceAsStream("/firewall_insert.json")),
- firewallName,
- networkName,
- on(",").skipNulls().join(transform(sourceRanges, addQuotes)),
- on(",").skipNulls().join(transform(sourceTags, addQuotes)),
- on(",").skipNulls().join(transform(targetTags, addQuotes)),
- ports,
- ports));
- payload.getContentMetadata().setContentType(MediaType.APPLICATION_JSON);
- return payload;
- }
-
-
- public void testGetFirewallResponseIs4xx() throws Exception {
- HttpRequest get = HttpRequest
- .builder()
- .method("GET")
- .endpoint("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/global/firewalls/jclouds-test")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
-
- FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, get, operationResponse).getFirewallApiForProject("myproject");
-
- assertNull(api.get("jclouds-test"));
- }
-
- public void testInsertFirewallResponseIs2xx() throws IOException {
-
- HttpRequest request = HttpRequest
- .builder()
- .method("POST")
- .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/global/firewalls")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN)
- .payload(firewallPayloadFirewallOfName(
- "myfw",
- "default",
- ImmutableSet.<String>of("10.0.1.0/32"),
- ImmutableSet.<String>of("tag1"),
- ImmutableSet.<String>of("tag2"),
- ImmutableSet.<String>of("22", "23-24")))
- .build();
-
- HttpResponse insertFirewallResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/operation.json")).build();
-
- FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, request, insertFirewallResponse).getFirewallApiForProject("myproject");
-
- assertEquals(api.createInNetwork("myfw", URI.create("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/global/networks/default"),
- new FirewallOptions()
- .addAllowedRule(Firewall.Rule.builder()
- .IpProtocol(IpProtocol.TCP)
- .addPort(22)
- .addPortRange(23, 24).build())
- .addSourceTag("tag1")
- .addSourceRange("10.0.1.0/32")
- .addTargetTag("tag2")), new ParseOperationTest().expected());
-
- }
-
- public void testUpdateFirewallResponseIs2xx() throws IOException {
- HttpRequest update = HttpRequest
- .builder()
- .method("PUT")
- .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/global/firewalls/myfw")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN)
- .payload(firewallPayloadFirewallOfName(
- "myfw",
- "default",
- ImmutableSet.<String>of("10.0.1.0/32"),
- ImmutableSet.<String>of("tag1"),
- ImmutableSet.<String>of("tag2"),
- ImmutableSet.<String>of("22", "23-24")))
- .build();
-
- HttpResponse updateFirewallResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/operation.json")).build();
-
- FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, update,
- updateFirewallResponse).getFirewallApiForProject("myproject");
-
- assertEquals(api.update("myfw",
- new FirewallOptions()
- .name("myfw")
- .network(URI.create("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/global/networks/default"))
- .addAllowedRule(Firewall.Rule.builder()
- .IpProtocol(IpProtocol.TCP)
- .addPort(22)
- .addPortRange(23, 24).build())
- .addSourceTag("tag1")
- .addSourceRange("10.0.1.0/32")
- .addTargetTag("tag2")), new ParseOperationTest().expected());
- }
-
- public void testPatchFirewallResponseIs2xx() throws IOException {
- HttpRequest update = HttpRequest
- .builder()
- .method("PATCH")
- .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/global/firewalls/myfw")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN)
- .payload(firewallPayloadFirewallOfName(
- "myfw",
- "default",
- ImmutableSet.<String>of("10.0.1.0/32"),
- ImmutableSet.<String>of("tag1"),
- ImmutableSet.<String>of("tag2"),
- ImmutableSet.<String>of("22", "23-24")))
- .build();
-
- HttpResponse updateFirewallResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/operation.json")).build();
-
- FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, update,
- updateFirewallResponse).getFirewallApiForProject("myproject");
-
- assertEquals(api.patch("myfw",
- new FirewallOptions()
- .name("myfw")
- .network(URI.create("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/global/networks/default"))
- .addAllowedRule(Firewall.Rule.builder()
- .IpProtocol(IpProtocol.TCP)
- .addPort(22)
- .addPortRange(23, 24).build())
- .addSourceTag("tag1")
- .addSourceRange("10.0.1.0/32")
- .addTargetTag("tag2")), new ParseOperationTest().expected());
- }
-
- public void testDeleteFirewallResponseIs2xx() {
- HttpRequest delete = HttpRequest
- .builder()
- .method("DELETE")
- .endpoint("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/global/firewalls/default-allow-internal")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse deleteResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/operation.json")).build();
-
- FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, delete, deleteResponse).getFirewallApiForProject("myproject");
-
- assertEquals(api.delete("default-allow-internal"),
- new ParseOperationTest().expected());
- }
-
- public void testDeleteFirewallResponseIs4xx() {
- HttpRequest delete = HttpRequest
- .builder()
- .method("DELETE")
- .endpoint("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/global/firewalls/default-allow-internal")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build();
-
- FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, delete, deleteResponse).getFirewallApiForProject("myproject");
-
- assertNull(api.delete("default-allow-internal"));
- }
-
- public void testListFirewallsResponseIs2xx() {
- HttpRequest list = HttpRequest
- .builder()
- .method("GET")
- .endpoint("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/global/firewalls")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/firewall_list.json")).build();
-
- FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, list, operationResponse).getFirewallApiForProject("myproject");
-
- assertEquals(api.listFirstPage().toString(),
- new ParseFirewallListTest().expected().toString());
- }
-
- public void testListFirewallsResponseIs4xx() {
- HttpRequest list = HttpRequest
- .builder()
- .method("GET")
- .endpoint("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/global/firewalls")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
-
- FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, list, operationResponse).getFirewallApiForProject("myproject");
-
- assertTrue(api.list().concat().isEmpty());
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/gce/1.8.0-stratos/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiLiveTest.java b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiLiveTest.java
deleted file mode 100644
index 24b5242..0000000
--- a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiLiveTest.java
+++ /dev/null
@@ -1,163 +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.googlecomputeengine.features;
-
-import static com.google.common.collect.Iterables.getOnlyElement;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-
-import java.util.List;
-
-import org.jclouds.collect.PagedIterable;
-import org.jclouds.googlecomputeengine.domain.Firewall;
-import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
-import org.jclouds.googlecomputeengine.options.FirewallOptions;
-import org.jclouds.googlecomputeengine.options.ListOptions;
-import org.jclouds.net.domain.IpProtocol;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Lists;
-
-public class FirewallApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
-
- private static final String FIREWALL_NAME = "firewall-api-live-test-firewall";
- private static final String FIREWALL_NETWORK_NAME = "firewall-api-live-test-network";
- private static final String IPV4_RANGE = "10.0.0.0/8";
- private static final int TIME_WAIT = 30;
-
- private FirewallApi api() {
- return api.getFirewallApiForProject(userProject.get());
- }
-
- @Test(groups = "live")
- public void testInsertFirewall() {
-
- // need to create the network first
- assertGlobalOperationDoneSucessfully(api.getNetworkApiForProject(userProject.get()).createInIPv4Range
- (FIREWALL_NETWORK_NAME, IPV4_RANGE), TIME_WAIT);
-
- FirewallOptions firewall = new FirewallOptions()
- .addAllowedRule(
- Firewall.Rule.builder()
- .IpProtocol(IpProtocol.TCP)
- .addPort(22).build())
- .addSourceRange("10.0.0.0/8")
- .addSourceTag("tag1")
- .addTargetTag("tag2");
-
- assertGlobalOperationDoneSucessfully(api().createInNetwork(FIREWALL_NAME, getNetworkUrl(userProject.get(),
- FIREWALL_NETWORK_NAME), firewall), TIME_WAIT);
-
- }
-
- @Test(groups = "live", dependsOnMethods = "testInsertFirewall")
- public void testUpdateFirewall() {
-
- FirewallOptions firewall = new FirewallOptions()
- .name(FIREWALL_NAME)
- .network(getNetworkUrl(userProject.get(), FIREWALL_NETWORK_NAME))
- .addSourceRange("10.0.0.0/8")
- .addSourceTag("tag1")
- .addTargetTag("tag2")
- .allowedRules(ImmutableSet.of(
- Firewall.Rule.builder()
- .IpProtocol(IpProtocol.TCP)
- .addPort(23)
- .build()));
-
-
- assertGlobalOperationDoneSucessfully(api().update(FIREWALL_NAME, firewall), TIME_WAIT);
-
- }
-
- @Test(groups = "live", dependsOnMethods = "testUpdateFirewall")
- public void testPatchFirewall() {
-
- FirewallOptions firewall = new FirewallOptions()
- .name(FIREWALL_NAME)
- .network(getNetworkUrl(userProject.get(), FIREWALL_NETWORK_NAME))
- .allowedRules(ImmutableSet.of(
- Firewall.Rule.builder()
- .IpProtocol(IpProtocol.TCP)
- .addPort(22)
- .build(),
- Firewall.Rule.builder()
- .IpProtocol(IpProtocol.TCP)
- .addPort(23)
- .build()))
- .addSourceRange("10.0.0.0/8")
- .addSourceTag("tag1")
- .addTargetTag("tag2");
-
- assertGlobalOperationDoneSucessfully(api().update(FIREWALL_NAME, firewall), TIME_WAIT);
-
- }
-
- @Test(groups = "live", dependsOnMethods = "testPatchFirewall")
- public void testGetFirewall() {
-
- FirewallOptions patchedFirewall = new FirewallOptions()
- .name(FIREWALL_NAME)
- .network(getNetworkUrl(userProject.get(), FIREWALL_NETWORK_NAME))
- .allowedRules(ImmutableSet.of(
- Firewall.Rule.builder()
- .IpProtocol(IpProtocol.TCP)
- .addPort(22)
- .build(),
- Firewall.Rule.builder()
- .IpProtocol(IpProtocol.TCP)
- .addPort(23)
- .build()))
- .addSourceRange("10.0.0.0/8")
- .addSourceTag("tag1")
- .addTargetTag("tag2");
-
- Firewall firewall = api().get(FIREWALL_NAME);
- assertNotNull(firewall);
- assertFirewallEquals(firewall, patchedFirewall);
- }
-
- @Test(groups = "live", dependsOnMethods = "testGetFirewall")
- public void testListFirewall() {
-
- PagedIterable<Firewall> firewalls = api().list(new ListOptions.Builder()
- .filter("name eq " + FIREWALL_NAME));
-
- List<Firewall> firewallsAsList = Lists.newArrayList(firewalls.concat());
-
- assertEquals(firewallsAsList.size(), 1);
-
- }
-
- @Test(groups = "live", dependsOnMethods = "testListFirewall")
- public void testDeleteFirewall() {
-
- assertGlobalOperationDoneSucessfully(api().delete(FIREWALL_NAME), TIME_WAIT);
- assertGlobalOperationDoneSucessfully(api.getNetworkApiForProject(userProject.get()).delete
- (FIREWALL_NETWORK_NAME), TIME_WAIT);
- }
-
- private void assertFirewallEquals(Firewall result, FirewallOptions expected) {
- assertEquals(result.getName(), expected.getName());
- assertEquals(getOnlyElement(result.getSourceRanges()), getOnlyElement(expected.getSourceRanges()));
- assertEquals(getOnlyElement(result.getSourceTags()), getOnlyElement(expected.getSourceTags()));
- assertEquals(getOnlyElement(result.getTargetTags()), getOnlyElement(expected.getTargetTags()));
- assertEquals(result.getAllowed(), expected.getAllowed());
- }
-
-}