You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ab...@apache.org on 2013/07/01 21:15:01 UTC

[14/24] JCLOUDS-151 - CloudStack refactored to remove async, *Client renamed to *Api.

http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/c6986efd/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/DomainDomainClientExpectTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/DomainDomainClientExpectTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/DomainDomainClientExpectTest.java
deleted file mode 100644
index 923fd72..0000000
--- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/DomainDomainClientExpectTest.java
+++ /dev/null
@@ -1,158 +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.cloudstack.features;
-
-import static org.jclouds.cloudstack.options.ListDomainChildrenOptions.Builder.parentDomainId;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNull;
-
-import java.net.URI;
-
-import org.jclouds.cloudstack.CloudStackContext;
-import org.jclouds.cloudstack.domain.Domain;
-import org.jclouds.cloudstack.internal.BaseCloudStackExpectTest;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpResponse;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableSet;
-
-/**
- * Test the CloudStack DomainDomainClient
- *
- * @author Andrei Savu
- */
-@Test(groups = "unit", testName = "DomainDomainClientExpectTest")
-public class DomainDomainClientExpectTest extends BaseCloudStackExpectTest<DomainDomainClient> {
-
-   public void testListDomainsWhenResponseIs2xx() {
-      DomainDomainClient client = requestSendsResponse(
-         HttpRequest.builder()
-            .method("GET")
-            .endpoint(
-               URI.create("http://localhost:8080/client/api?response=json&" +
-                          "command=listDomains&listAll=true&apiKey=identity&signature=sVFaGTu0DNSTVtWy3wtRt7KTx0w%3D"))
-            .addHeader("Accept", "application/json")
-            .build(),
-         HttpResponse.builder()
-            .statusCode(200)
-            .payload(payloadFromResource("/listdomainsresponse.json"))
-            .build());
-
-      assertEquals(client.listDomains(),
-         ImmutableSet.of(
-            Domain.builder().id("1").name("ROOT").level(0).hasChild(true).build(),
-            Domain.builder().id("2").name("jclouds1").level(1).parentDomainId("1")
-               .parentDomainName("ROOT").hasChild(false).build()
-         ));
-   }
-
-   public void testListDomainsWhenResponseIs404() {
-      DomainDomainClient client = requestSendsResponse(
-         HttpRequest.builder()
-            .method("GET")
-            .endpoint(
-               URI.create("http://localhost:8080/client/api?response=json&" +
-                          "command=listDomains&listAll=true&apiKey=identity&signature=sVFaGTu0DNSTVtWy3wtRt7KTx0w%3D"))
-            .addHeader("Accept", "application/json")
-            .build(),
-         HttpResponse.builder()
-            .statusCode(404)
-            .build());
-
-      assertEquals(client.listDomains(), ImmutableSet.of());
-   }
-
-   public void testGetDomainWhenResponseIs2xx() {
-      DomainDomainClient client = requestSendsResponse(
-         HttpRequest.builder()
-            .method("GET")
-            .endpoint(
-               URI.create("http://localhost:8080/client/api?response=json&" +
-                          "command=listDomains&listAll=true&id=1&apiKey=identity&signature=M16YxHWKST/cIRUHvWhfWovJugU%3D"))
-            .addHeader("Accept", "application/json")
-            .build(),
-         HttpResponse.builder()
-            .statusCode(200)
-            .payload(payloadFromResource("/getdomainresponse.json"))
-            .build());
-
-      assertEquals(client.getDomainById("1"),
-         Domain.builder().id("1").name("ROOT").level(0).hasChild(true).build());
-   }
-
-   public void testGetDomainWhenResponseIs404() {
-      DomainDomainClient client = requestSendsResponse(
-         HttpRequest.builder()
-            .method("GET")
-            .endpoint(
-               URI.create("http://localhost:8080/client/api?response=json&" +
-                          "command=listDomains&listAll=true&id=1&apiKey=identity&signature=M16YxHWKST/cIRUHvWhfWovJugU%3D"))
-            .addHeader("Accept", "application/json")
-            .build(),
-         HttpResponse.builder()
-            .statusCode(404)
-            .build());
-
-      assertNull(client.getDomainById("1"));
-   }
-
-   public void testListDomainChildrenWhenResponseIs2xx() {
-      DomainDomainClient client = requestSendsResponse(
-         HttpRequest.builder()
-            .method("GET")
-            .endpoint(
-               URI.create("http://localhost:8080/client/api?response=json&" +
-                          "command=listDomainChildren&listAll=true&id=1&isrecursive=true&apiKey=identity&signature=Jn6kFkloRvfaaivlJiHd0F5J3Jk%3D"))
-            .addHeader("Accept", "application/json")
-            .build(),
-         HttpResponse.builder()
-            .statusCode(200)
-            .payload(payloadFromResource("/listdomainchildrenresponse.json"))
-            .build());
-
-      assertEquals(client.listDomainChildren(parentDomainId("1").isRecursive(true)),
-         ImmutableSet.of(
-            Domain.builder().id("2").name("jclouds1").level(1).parentDomainId("1")
-               .parentDomainName("ROOT").hasChild(false).build(),
-            Domain.builder().id("3").name("jclouds2").level(1).parentDomainId("1")
-               .parentDomainName("ROOT").hasChild(false).build()
-         ));
-   }
-
-   public void testListDomainChildrenWhenResponseIs404() {
-      DomainDomainClient client = requestSendsResponse(
-         HttpRequest.builder()
-            .method("GET")
-            .endpoint(
-               URI.create("http://localhost:8080/client/api?response=json&" +
-                  "command=listDomainChildren&listAll=true&id=1&isrecursive=true&apiKey=identity&" +
-                          "signature=Jn6kFkloRvfaaivlJiHd0F5J3Jk%3D"))
-            .addHeader("Accept", "application/json")
-            .build(),
-         HttpResponse.builder()
-            .statusCode(404)
-            .build());
-
-      assertEquals(client.listDomainChildren(parentDomainId("1").isRecursive(true)), ImmutableSet.of());
-   }
-
-   @Override
-   protected DomainDomainClient clientFrom(CloudStackContext context) {
-      return context.getDomainApi().getDomainClient();
-   }
-}

http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/c6986efd/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/DomainDomainClientLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/DomainDomainClientLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/DomainDomainClientLiveTest.java
deleted file mode 100644
index cf75ca6..0000000
--- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/DomainDomainClientLiveTest.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.cloudstack.features;
-
-import static com.google.common.collect.Sets.newHashSet;
-import static org.jclouds.cloudstack.options.ListDomainChildrenOptions.Builder.parentDomainId;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertTrue;
-
-import java.util.NoSuchElementException;
-import java.util.Set;
-
-import org.jclouds.cloudstack.domain.Domain;
-import org.jclouds.cloudstack.internal.BaseCloudStackClientLiveTest;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Function;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Sets;
-
-/**
- * Tests behavior of {@code DomainDomainClient}
- *
- * @author Andrei Savu
- */
-@Test(groups = "live", singleThreaded = true, testName = "DomainDomainClientLiveTest")
-public class DomainDomainClientLiveTest extends BaseCloudStackClientLiveTest {
-
-   @Test
-   public void testListDomains() {
-      skipIfNotDomainAdmin();
-
-      Set<Domain> domains = domainAdminClient.getDomainClient().listDomains();
-      for (Domain candidate : domains) {
-         checkDomain(candidate);
-      }
-   }
-
-   private void checkDomain(Domain domain) {
-      assertNotNull(domain.getId());
-      if (domain.getLevel() == 0 /* global ROOT */) {
-         assertNull(domain.getParentDomainName());
-         assertNull(domain.getParentDomainId());
-      } else {
-         assertNotNull(domain.getParentDomainName());
-         assertNotNull(domain.getParentDomainId());
-      }
-   }
-
-   @Test
-   public void testListDomainChildren() {
-      skipIfNotDomainAdmin();
-
-      Set<Domain> domains = domainAdminClient.getDomainClient().listDomains();
-      Domain root = findRootOfVisibleTree(domains);
-      if (domains.size() > 1) {
-         assertTrue(root.hasChild());
-      }
-
-      Set<Domain> children = domainAdminClient.getDomainClient()
-         .listDomainChildren(parentDomainId(root.getId()).isRecursive(true));
-      assertEquals(domains.size() - 1, children.size());
-      assertTrue(Sets.difference(domains, children).contains(root));
-   }
-
-   private Domain findRootOfVisibleTree(Set<Domain> domains) {
-      final Set<String> names = newHashSet(Iterables.transform(domains,
-         new Function<Domain, String>() {
-            @Override
-            public String apply(Domain domain) {
-               return domain.getName();
-            }
-         }));
-
-      for (Domain candidate : domains) {
-         if (candidate.getParentDomainId() == null ||
-            !names.contains(candidate.getParentDomainName())) {
-            return candidate;
-         }
-      }
-      throw new NoSuchElementException("No root node found in this tree");
-   }
-}

http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/c6986efd/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/DomainLimitApiLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/DomainLimitApiLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/DomainLimitApiLiveTest.java
new file mode 100644
index 0000000..e552e2d
--- /dev/null
+++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/DomainLimitApiLiveTest.java
@@ -0,0 +1,30 @@
+/*
+ * 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.cloudstack.features;
+
+import org.jclouds.cloudstack.internal.BaseCloudStackApiLiveTest;
+import org.testng.annotations.Test;
+
+/**
+ * Tests behavior of {@code DomainLimitApi}
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "live", singleThreaded = true, testName = "DomainLimitApiLiveTest")
+public class DomainLimitApiLiveTest extends BaseCloudStackApiLiveTest {
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/c6986efd/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/DomainLimitApiTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/DomainLimitApiTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/DomainLimitApiTest.java
new file mode 100644
index 0000000..41146ec
--- /dev/null
+++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/DomainLimitApiTest.java
@@ -0,0 +1,59 @@
+/*
+ * 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.cloudstack.features;
+
+import static org.jclouds.reflect.Reflection2.method;
+
+import java.io.IOException;
+
+import org.jclouds.cloudstack.domain.ResourceLimit;
+import org.jclouds.cloudstack.domain.ResourceLimit.ResourceType;
+import org.jclouds.cloudstack.internal.BaseCloudStackApiTest;
+import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
+import org.jclouds.http.functions.ParseFirstJsonValueNamed;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.reflect.Invokable;
+/**
+ * Tests behavior of {@code DomainLimitApi}
+ * 
+ * @author Adrian
+ */
+@Test(groups = "unit", testName = "DomainLimitApiTest")
+public class DomainLimitApiTest extends BaseCloudStackApiTest<DomainLimitApi> {
+
+   public void testUpdateResourceLimit() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(DomainLimitApi.class, "updateResourceLimit", ResourceLimit.class);
+      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
+            ResourceLimit.builder().resourceType(ResourceType.SNAPSHOT).account("foo").domainId("100").max(101).build()));
+
+      assertRequestLineEquals(
+            httpRequest,
+            "GET http://localhost:8080/client/api?response=json&command=updateResourceLimit&resourcetype=3&account=foo&domainid=100&max=101 HTTP/1.1");
+      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
+      assertPayloadEquals(httpRequest, null, null, false);
+
+      assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
+
+      checkFilters(httpRequest);
+
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/c6986efd/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/DomainLimitAsyncClientTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/DomainLimitAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/DomainLimitAsyncClientTest.java
deleted file mode 100644
index bccca72..0000000
--- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/DomainLimitAsyncClientTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.cloudstack.features;
-
-import static org.jclouds.reflect.Reflection2.method;
-
-import java.io.IOException;
-
-import org.jclouds.cloudstack.domain.ResourceLimit;
-import org.jclouds.cloudstack.domain.ResourceLimit.ResourceType;
-import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
-import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
-import org.jclouds.http.functions.ParseFirstJsonValueNamed;
-import org.jclouds.rest.internal.GeneratedHttpRequest;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.reflect.Invokable;
-/**
- * Tests behavior of {@code DomainLimitAsyncClient}
- * 
- * @author Adrian
- */
-@Test(groups = "unit", testName = "DomainLimitAsyncClientTest")
-public class DomainLimitAsyncClientTest extends BaseCloudStackAsyncClientTest<DomainLimitAsyncClient> {
-
-   public void testUpdateResourceLimit() throws SecurityException, NoSuchMethodException, IOException {
-      Invokable<?, ?> method = method(DomainLimitAsyncClient.class, "updateResourceLimit", ResourceLimit.class);
-      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
-            ResourceLimit.builder().resourceType(ResourceType.SNAPSHOT).account("foo").domainId("100").max(101).build()));
-
-      assertRequestLineEquals(
-            httpRequest,
-            "GET http://localhost:8080/client/api?response=json&command=updateResourceLimit&resourcetype=3&account=foo&domainid=100&max=101 HTTP/1.1");
-      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
-      assertPayloadEquals(httpRequest, null, null, false);
-
-      assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
-      assertSaxResponseParserClassEquals(method, null);
-      assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
-
-      checkFilters(httpRequest);
-
-   }
-}

http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/c6986efd/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/DomainLimitClientLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/DomainLimitClientLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/DomainLimitClientLiveTest.java
deleted file mode 100644
index a65693e..0000000
--- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/DomainLimitClientLiveTest.java
+++ /dev/null
@@ -1,30 +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.cloudstack.features;
-
-import org.jclouds.cloudstack.internal.BaseCloudStackClientLiveTest;
-import org.testng.annotations.Test;
-
-/**
- * Tests behavior of {@code DomainLimitClient}
- *
- * @author Adrian Cole
- */
-@Test(groups = "live", singleThreaded = true, testName = "DomainLimitClientLiveTest")
-public class DomainLimitClientLiveTest extends BaseCloudStackClientLiveTest {
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/c6986efd/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/DomainUserApiLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/DomainUserApiLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/DomainUserApiLiveTest.java
new file mode 100644
index 0000000..8a467fa
--- /dev/null
+++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/DomainUserApiLiveTest.java
@@ -0,0 +1,91 @@
+/*
+ * 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.cloudstack.features;
+
+import static org.jclouds.cloudstack.features.GlobalAccountApiLiveTest.createTestAccount;
+import static org.jclouds.cloudstack.features.GlobalUserApiLiveTest.createTestUser;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+import java.util.Set;
+
+import org.jclouds.cloudstack.domain.Account;
+import org.jclouds.cloudstack.domain.AsyncCreateResponse;
+import org.jclouds.cloudstack.domain.AsyncJob;
+import org.jclouds.cloudstack.domain.User;
+import org.jclouds.cloudstack.internal.BaseCloudStackApiLiveTest;
+import org.testng.annotations.Test;
+
+/**
+ * Tests behavior of {@code DomainUserApi}
+ */
+@Test(groups = "live", singleThreaded = true, testName = "DomainUserApiLiveTest")
+public class DomainUserApiLiveTest extends BaseCloudStackApiLiveTest {
+
+   @Test
+   public void testListUsers() {
+      skipIfNotDomainAdmin();
+
+      Set<User> users = domainAdminClient.getUserClient().listUsers();
+
+      assert users.size() > 0;
+      assert users.contains(user); // contains the current user
+
+      for (User user : users) {
+         checkUser(user);
+      }
+   }
+
+   private void checkUser(User user) {
+      assert user.getId() != null;
+      assert user.getAccount() != null;
+      assert user.getDomain() != null;
+   }
+
+   @Test
+   public void testEnableDisableUser() {
+      skipIfNotGlobalAdmin();
+
+      Account testAccount = null;
+      User testUser = null;
+      try {
+         testAccount = createTestAccount(globalAdminClient, prefix);
+         testUser = createTestUser(globalAdminClient, testAccount, prefix);
+
+         AsyncCreateResponse response = domainAdminClient.getUserClient().disableUser(testUser.getId());
+         assertNotNull(response);
+         assertTrue(jobComplete.apply(response.getJobId()));
+
+         AsyncJob<User> job = domainAdminClient.getAsyncJobApi().getAsyncJob(response.getJobId());
+         assertNotNull(job);
+         assertEquals(job.getResult().getState(), User.State.DISABLED);
+
+         User updated = domainAdminClient.getUserClient().enableUser(testUser.getId());
+         assertNotNull(updated);
+         assertEquals(updated.getState(), User.State.ENABLED);
+
+      } finally {
+         if (testUser != null) {
+            globalAdminClient.getUserClient().deleteUser(testUser.getId());
+         }
+         if (testAccount != null) {
+            globalAdminClient.getAccountApi().deleteAccount(testAccount.getId());
+         }
+      }
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/c6986efd/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/DomainUserClientLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/DomainUserClientLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/DomainUserClientLiveTest.java
deleted file mode 100644
index 4873aad..0000000
--- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/DomainUserClientLiveTest.java
+++ /dev/null
@@ -1,91 +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.cloudstack.features;
-
-import static org.jclouds.cloudstack.features.GlobalAccountClientLiveTest.createTestAccount;
-import static org.jclouds.cloudstack.features.GlobalUserClientLiveTest.createTestUser;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
-
-import java.util.Set;
-
-import org.jclouds.cloudstack.domain.Account;
-import org.jclouds.cloudstack.domain.AsyncCreateResponse;
-import org.jclouds.cloudstack.domain.AsyncJob;
-import org.jclouds.cloudstack.domain.User;
-import org.jclouds.cloudstack.internal.BaseCloudStackClientLiveTest;
-import org.testng.annotations.Test;
-
-/**
- * Tests behavior of {@code DomainUserClient}
- */
-@Test(groups = "live", singleThreaded = true, testName = "DomainUserClientLiveTest")
-public class DomainUserClientLiveTest extends BaseCloudStackClientLiveTest {
-
-   @Test
-   public void testListUsers() {
-      skipIfNotDomainAdmin();
-
-      Set<User> users = domainAdminClient.getUserClient().listUsers();
-
-      assert users.size() > 0;
-      assert users.contains(user); // contains the current user
-
-      for (User user : users) {
-         checkUser(user);
-      }
-   }
-
-   private void checkUser(User user) {
-      assert user.getId() != null;
-      assert user.getAccount() != null;
-      assert user.getDomain() != null;
-   }
-
-   @Test
-   public void testEnableDisableUser() {
-      skipIfNotGlobalAdmin();
-
-      Account testAccount = null;
-      User testUser = null;
-      try {
-         testAccount = createTestAccount(globalAdminClient, prefix);
-         testUser = createTestUser(globalAdminClient, testAccount, prefix);
-
-         AsyncCreateResponse response = domainAdminClient.getUserClient().disableUser(testUser.getId());
-         assertNotNull(response);
-         assertTrue(jobComplete.apply(response.getJobId()));
-
-         AsyncJob<User> job = domainAdminClient.getAsyncJobClient().getAsyncJob(response.getJobId());
-         assertNotNull(job);
-         assertEquals(job.getResult().getState(), User.State.DISABLED);
-
-         User updated = domainAdminClient.getUserClient().enableUser(testUser.getId());
-         assertNotNull(updated);
-         assertEquals(updated.getState(), User.State.ENABLED);
-
-      } finally {
-         if (testUser != null) {
-            globalAdminClient.getUserClient().deleteUser(testUser.getId());
-         }
-         if (testAccount != null) {
-            globalAdminClient.getAccountClient().deleteAccount(testAccount.getId());
-         }
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/c6986efd/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/EventApiLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/EventApiLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/EventApiLiveTest.java
new file mode 100644
index 0000000..40f4a02
--- /dev/null
+++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/EventApiLiveTest.java
@@ -0,0 +1,69 @@
+/*
+ * 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.cloudstack.features;
+
+import static org.testng.Assert.assertTrue;
+
+import java.util.Set;
+
+import org.jclouds.cloudstack.domain.Event;
+import org.jclouds.cloudstack.internal.BaseCloudStackApiLiveTest;
+import org.testng.annotations.Test;
+
+/**
+ * Tests behavior of {@code EventApi}
+ *
+ * @author Vijay Kiran
+ */
+@Test(groups = "live", singleThreaded = true, testName = "EventApiLiveTest")
+public class EventApiLiveTest extends BaseCloudStackApiLiveTest {
+
+   public void testlistEventTypes() throws Exception {
+      final Set<String> response = client.getEventApi().listEventTypes();
+      assert null != response;
+      assertTrue(response.size() >= 0);
+      for (String type : response) {
+         checkEventType(type);
+      }
+   }
+
+   public void testlistEvents() throws Exception {
+      final Set<Event> response = client.getEventApi().listEvents();
+      assert null != response;
+      assertTrue(response.size() >= 0);
+      for (Event event : response) {
+         checkEvent(event);
+      }
+   }
+
+   private void checkEvent(Event event) {
+      assert event.getAccount() != null : event;
+      assert event.getCreated() != null : event;
+      assert event.getDescription() != null : event;
+      assert event.getDomain() != null : event;
+      assert event.getId() != null : event;
+      assert event.getLevel() != null : event;
+      assert event.getState() != null : event;
+      assert event.getType() != null : event;
+      assert event.getUsername() != null : event;
+   }
+
+   protected void checkEventType(String eventType) {
+      assert eventType != null : eventType;
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/c6986efd/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/EventApiTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/EventApiTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/EventApiTest.java
new file mode 100644
index 0000000..0c28c47
--- /dev/null
+++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/EventApiTest.java
@@ -0,0 +1,92 @@
+/*
+ * 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.cloudstack.features;
+
+import static org.jclouds.reflect.Reflection2.method;
+
+import java.io.IOException;
+
+import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
+import org.jclouds.cloudstack.functions.ParseEventTypesFromHttpResponse;
+import org.jclouds.cloudstack.internal.BaseCloudStackApiTest;
+import org.jclouds.cloudstack.options.ListEventsOptions;
+import org.jclouds.http.functions.ParseFirstJsonValueNamed;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.reflect.Invokable;
+/**
+ * Tests behavior of {@code EventApi}
+ *
+ * @author Vijay Kiran
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during
+// surefire
+@Test(groups = "unit", testName = "EventApiTest")
+public class EventApiTest extends BaseCloudStackApiTest<EventApi> {
+
+   public void testListEventTypes() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(EventApi.class, "listEventTypes");
+      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
+
+      assertRequestLineEquals(httpRequest,
+            "GET http://localhost:8080/client/api?response=json&listAll=true&command=listEventTypes HTTP/1.1");
+      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
+      assertPayloadEquals(httpRequest, null, null, false);
+
+      assertResponseParserClassEquals(method, httpRequest, ParseEventTypesFromHttpResponse.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
+
+      checkFilters(httpRequest);
+   }
+
+   public void testListEvents() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(EventApi.class, "listEvents", ListEventsOptions[].class);
+      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
+
+      assertRequestLineEquals(httpRequest,
+            "GET http://localhost:8080/client/api?response=json&listAll=true&command=listEvents HTTP/1.1");
+      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
+      assertPayloadEquals(httpRequest, null, null, false);
+
+      assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
+
+      checkFilters(httpRequest);
+
+   }
+
+   public void testEventsListOptions() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(EventApi.class, "listEvents", ListEventsOptions[].class);
+      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(ListEventsOptions.Builder.account("jclouds")));
+
+      assertRequestLineEquals(httpRequest,
+            "GET http://localhost:8080/client/api?response=json&listAll=true&command=listEvents&account=jclouds HTTP/1.1");
+      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
+      assertPayloadEquals(httpRequest, null, null, false);
+
+      assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
+
+      checkFilters(httpRequest);
+
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/c6986efd/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/EventAsyncClientTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/EventAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/EventAsyncClientTest.java
deleted file mode 100644
index 0e3cef9..0000000
--- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/EventAsyncClientTest.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.cloudstack.features;
-
-import static org.jclouds.reflect.Reflection2.method;
-
-import java.io.IOException;
-
-import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
-import org.jclouds.cloudstack.functions.ParseEventTypesFromHttpResponse;
-import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
-import org.jclouds.cloudstack.options.ListEventsOptions;
-import org.jclouds.http.functions.ParseFirstJsonValueNamed;
-import org.jclouds.rest.internal.GeneratedHttpRequest;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.reflect.Invokable;
-/**
- * Tests behavior of {@code EventAsyncClient}
- *
- * @author Vijay Kiran
- */
-// NOTE:without testName, this will not call @Before* and fail w/NPE during
-// surefire
-@Test(groups = "unit", testName = "EventAsyncClientTest")
-public class EventAsyncClientTest extends BaseCloudStackAsyncClientTest<EventAsyncClient> {
-
-   public void testListEventTypes() throws SecurityException, NoSuchMethodException, IOException {
-      Invokable<?, ?> method = method(EventAsyncClient.class, "listEventTypes");
-      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
-
-      assertRequestLineEquals(httpRequest,
-            "GET http://localhost:8080/client/api?response=json&listAll=true&command=listEventTypes HTTP/1.1");
-      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
-      assertPayloadEquals(httpRequest, null, null, false);
-
-      assertResponseParserClassEquals(method, httpRequest, ParseEventTypesFromHttpResponse.class);
-      assertSaxResponseParserClassEquals(method, null);
-      assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
-
-      checkFilters(httpRequest);
-   }
-
-   public void testListEvents() throws SecurityException, NoSuchMethodException, IOException {
-      Invokable<?, ?> method = method(EventAsyncClient.class, "listEvents", ListEventsOptions[].class);
-      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
-
-      assertRequestLineEquals(httpRequest,
-            "GET http://localhost:8080/client/api?response=json&listAll=true&command=listEvents HTTP/1.1");
-      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
-      assertPayloadEquals(httpRequest, null, null, false);
-
-      assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
-      assertSaxResponseParserClassEquals(method, null);
-      assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
-
-      checkFilters(httpRequest);
-
-   }
-
-   public void testEventsListOptions() throws SecurityException, NoSuchMethodException, IOException {
-      Invokable<?, ?> method = method(EventAsyncClient.class, "listEvents", ListEventsOptions[].class);
-      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(ListEventsOptions.Builder.account("jclouds")));
-
-      assertRequestLineEquals(httpRequest,
-            "GET http://localhost:8080/client/api?response=json&listAll=true&command=listEvents&account=jclouds HTTP/1.1");
-      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
-      assertPayloadEquals(httpRequest, null, null, false);
-
-      assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
-      assertSaxResponseParserClassEquals(method, null);
-      assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
-
-      checkFilters(httpRequest);
-
-   }
-}

http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/c6986efd/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/EventClientLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/EventClientLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/EventClientLiveTest.java
deleted file mode 100644
index 0317ad5..0000000
--- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/EventClientLiveTest.java
+++ /dev/null
@@ -1,69 +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.cloudstack.features;
-
-import static org.testng.Assert.assertTrue;
-
-import java.util.Set;
-
-import org.jclouds.cloudstack.domain.Event;
-import org.jclouds.cloudstack.internal.BaseCloudStackClientLiveTest;
-import org.testng.annotations.Test;
-
-/**
- * Tests behavior of {@code EventClient}
- *
- * @author Vijay Kiran
- */
-@Test(groups = "live", singleThreaded = true, testName = "EventClientLiveTest")
-public class EventClientLiveTest extends BaseCloudStackClientLiveTest {
-
-   public void testlistEventTypes() throws Exception {
-      final Set<String> response = client.getEventClient().listEventTypes();
-      assert null != response;
-      assertTrue(response.size() >= 0);
-      for (String type : response) {
-         checkEventType(type);
-      }
-   }
-
-   public void testlistEvents() throws Exception {
-      final Set<Event> response = client.getEventClient().listEvents();
-      assert null != response;
-      assertTrue(response.size() >= 0);
-      for (Event event : response) {
-         checkEvent(event);
-      }
-   }
-
-   private void checkEvent(Event event) {
-      assert event.getAccount() != null : event;
-      assert event.getCreated() != null : event;
-      assert event.getDescription() != null : event;
-      assert event.getDomain() != null : event;
-      assert event.getId() != null : event;
-      assert event.getLevel() != null : event;
-      assert event.getState() != null : event;
-      assert event.getType() != null : event;
-      assert event.getUsername() != null : event;
-   }
-
-   protected void checkEventType(String eventType) {
-      assert eventType != null : eventType;
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/c6986efd/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/FirewallApiExpectTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/FirewallApiExpectTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/FirewallApiExpectTest.java
new file mode 100644
index 0000000..979e4ed
--- /dev/null
+++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/FirewallApiExpectTest.java
@@ -0,0 +1,289 @@
+/*
+ * 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.cloudstack.features;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+
+import java.net.URI;
+import java.util.Set;
+
+import org.jclouds.cloudstack.CloudStackApiMetadata;
+import org.jclouds.cloudstack.CloudStackContext;
+import org.jclouds.cloudstack.domain.AsyncCreateResponse;
+import org.jclouds.cloudstack.domain.FirewallRule;
+import org.jclouds.cloudstack.domain.PortForwardingRule;
+import org.jclouds.cloudstack.internal.BaseCloudStackExpectTest;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Test the CloudStack FirewallApi
+ *
+ * @author Andrei Savu
+ */
+@Test(groups = "unit", testName = "FirewallApiExpectTest")
+public class FirewallApiExpectTest extends BaseCloudStackExpectTest<FirewallApi> {
+
+   public void testListFirewallRulesWhenResponseIs2xx() {
+      FirewallApi client = requestSendsResponse(
+         HttpRequest.builder()
+            .method("GET")
+            .endpoint(
+               URI.create("http://localhost:8080/client/api?response=json&command=listFirewallRules&listAll=true&" +
+                  "apiKey=identity&signature=9%2BtdTXe2uYLzAexPNgrMy5Tq8hE%3D"))
+            .addHeader("Accept", "application/json")
+            .build(),
+         HttpResponse.builder()
+            .statusCode(200)
+            .payload(payloadFromResource("/listfirewallrulesresponse.json"))
+            .build());
+
+      Set<String> CIDRs  = ImmutableSet.of("0.0.0.0/0");
+      assertEquals(client.listFirewallRules(),
+         ImmutableSet.of(
+            FirewallRule.builder().id("2017").protocol(FirewallRule.Protocol.TCP).startPort(30)
+               .endPort(35).ipAddressId("2").ipAddress("10.27.27.51").state(FirewallRule.State.ACTIVE)
+               .CIDRs(CIDRs).build(),
+            FirewallRule.builder().id("2016").protocol(FirewallRule.Protocol.TCP).startPort(22)
+               .endPort(22).ipAddressId("2").ipAddress("10.27.27.51").state(FirewallRule.State.ACTIVE)
+               .CIDRs(CIDRs).build(),
+            FirewallRule.builder().id("10").protocol(FirewallRule.Protocol.TCP).startPort(22)
+            .endPort(22).ipAddressId("8").ipAddress("10.27.27.57").state(FirewallRule.State.ACTIVE)
+               .CIDRs(CIDRs).build()
+         ));
+   }
+
+   public void testListFirewallRulesWhenReponseIs404() {
+      FirewallApi client = requestSendsResponse(
+         HttpRequest.builder()
+            .method("GET")
+            .endpoint(
+               URI.create("http://localhost:8080/client/api?response=json&command=listFirewallRules&listAll=true&" +
+                  "apiKey=identity&signature=9%2BtdTXe2uYLzAexPNgrMy5Tq8hE%3D"))
+            .addHeader("Accept", "application/json")
+            .build(),
+         HttpResponse.builder()
+            .statusCode(404)
+            .build());
+
+      assertEquals(client.listFirewallRules(), ImmutableSet.of());
+   }
+
+   public void testGetFirewallRuleWhenResponseIs2xx() {
+      FirewallApi client = requestSendsResponse(
+         HttpRequest.builder()
+            .method("GET")
+            .endpoint(
+               URI.create("http://localhost:8080/client/api?response=json&command=listFirewallRules&listAll=true&" +
+                  "id=2017&apiKey=identity&signature=6coh9Qdwla94TN1Dl008WlhzZUY%3D"))
+            .addHeader("Accept", "application/json")
+            .build(),
+         HttpResponse.builder()
+            .statusCode(200)
+            .payload(payloadFromResource("/getfirewallrulesresponse.json"))
+            .build());
+
+      assertEquals(client.getFirewallRule("2017"),
+         FirewallRule.builder().id("2017").protocol(FirewallRule.Protocol.TCP).startPort(30)
+            .endPort(35).ipAddressId("2").ipAddress("10.27.27.51").state(FirewallRule.State.ACTIVE)
+            .CIDRs(ImmutableSet.of("0.0.0.0/0")).build()
+      );
+   }
+
+   public void testGetFirewallRuleWhenResponseIs404() {
+      FirewallApi client = requestSendsResponse(
+         HttpRequest.builder()
+            .method("GET")
+            .endpoint(
+               URI.create("http://localhost:8080/client/api?response=json&command=listFirewallRules&listAll=true&" +
+                  "id=4&apiKey=identity&signature=rYd8gr7ptdSZlIehBEMQEKsm07Q%3D"))
+            .addHeader("Accept", "application/json")
+            .build(),
+         HttpResponse.builder()
+            .statusCode(404)
+            .build());
+
+      assertNull(client.getFirewallRule("4"));
+   }
+
+   public void testCreateFirewallRuleForIpAndProtocol() {
+      FirewallApi client = requestSendsResponse(
+         HttpRequest.builder()
+            .method("GET")
+            .endpoint(
+               URI.create("http://localhost:8080/client/api?response=json&command=createFirewallRule&" +
+                  "ipaddressid=2&protocol=TCP&apiKey=identity&signature=d0MZ/yhQPAaV%2BYQmfZsQtQL2C28%3D"))
+            .addHeader("Accept", "application/json")
+            .build(),
+         HttpResponse.builder()
+            .statusCode(200)
+            .payload(payloadFromResource("/createfirewallrulesresponse.json"))
+            .build());
+
+      AsyncCreateResponse response = client.createFirewallRuleForIpAndProtocol("2", FirewallRule.Protocol.TCP);
+      assertEquals(response.getJobId(), "2036");
+      assertEquals(response.getId(), "2017");
+   }
+
+   public void testDeleteFirewallRule() {
+      FirewallApi client = requestSendsResponse(
+         HttpRequest.builder()
+            .method("GET")
+            .endpoint(
+               URI.create("http://localhost:8080/client/api?response=json&" +
+                  "command=deleteFirewallRule&id=2015&apiKey=identity&signature=/T5FAO2yGPctaPmg7TEtIEFW3EU%3D"))
+            .build(),
+         HttpResponse.builder()
+            .statusCode(200)
+            .payload(payloadFromResource("/deletefirewallrulesresponse.json"))
+            .build());
+
+      client.deleteFirewallRule("2015");
+   }
+
+   public void testListPortForwardingRulesWhenResponseIs2xx() {
+      FirewallApi client = requestSendsResponse(
+         HttpRequest.builder()
+            .method("GET")
+            .endpoint(
+               URI.create("http://localhost:8080/client/api?response=json&" +
+                  "command=listPortForwardingRules&listAll=true&apiKey=identity&signature=8SXGJZWdcJfVz4V90Pyod12x9dM%3D"))
+            .addHeader("Accept", "application/json")
+            .build(),
+         HttpResponse.builder()
+            .statusCode(200)
+            .payload(payloadFromResource("/listportforwardingrulesresponse.json"))
+            .build());
+
+      Set<String> cidrs = ImmutableSet.of("0.0.0.0/1", "128.0.0.0/1");
+
+      assertEquals(client.listPortForwardingRules(),
+         ImmutableSet.<PortForwardingRule>of(
+            PortForwardingRule.builder().id("15").privatePort(22).protocol(PortForwardingRule.Protocol.TCP)
+               .publicPort(2022).virtualMachineId("3").virtualMachineName("i-3-3-VM").IPAddressId("3")
+               .IPAddress("72.52.126.32").state(PortForwardingRule.State.ACTIVE).CIDRs(cidrs).build(),
+            PortForwardingRule.builder().id("18").privatePort(22).protocol(PortForwardingRule.Protocol.TCP)
+               .publicPort(22).virtualMachineId("89").virtualMachineName("i-3-89-VM").IPAddressId("34")
+               .IPAddress("72.52.126.63").state(PortForwardingRule.State.ACTIVE).build())
+      );
+   }
+
+   public void testListPortForwardingRulesWhenReponseIs404() {
+      FirewallApi client = requestSendsResponse(
+         HttpRequest.builder()
+            .method("GET")
+            .endpoint(
+               URI.create("http://localhost:8080/client/api?response=json&" +
+                  "command=listPortForwardingRules&listAll=true&apiKey=identity&signature=8SXGJZWdcJfVz4V90Pyod12x9dM%3D"))
+            .addHeader("Accept", "application/json")
+            .build(),
+         HttpResponse.builder()
+            .statusCode(404)
+            .build());
+
+      assertEquals(client.listPortForwardingRules(), ImmutableSet.of());
+   }
+
+   public void testGetPortForwardingRuleWhenResponseIs2xx() {
+      FirewallApi client = requestSendsResponse(
+         HttpRequest.builder()
+            .method("GET")
+            .endpoint(
+               URI.create("http://localhost:8080/client/api?response=json&" +
+                  "command=listPortForwardingRules&listAll=true&id=15&apiKey=identity&signature=JL63p6cJzbb9vaffeV4u60IGlWE%3D"))
+            .addHeader("Accept", "application/json")
+            .build(),
+         HttpResponse.builder()
+            .statusCode(200)
+            .payload(payloadFromResource("/getportforwardingrulesresponse.json"))
+            .build());
+
+      Set<String> cidrs = ImmutableSet.of("0.0.0.0/1", "128.0.0.0/1");
+
+      assertEquals(client.getPortForwardingRule("15"),
+         PortForwardingRule.builder().id("15").privatePort(22).protocol(PortForwardingRule.Protocol.TCP)
+            .publicPort(2022).virtualMachineId("3").virtualMachineName("i-3-3-VM").IPAddressId("3")
+            .IPAddress("72.52.126.32").state(PortForwardingRule.State.ACTIVE).CIDRs(cidrs).build());
+   }
+
+   public void testGetPortForwardingRuleWhenResponseIs404() {
+      FirewallApi client = requestSendsResponse(
+         HttpRequest.builder()
+            .method("GET")
+            .endpoint(
+               URI.create("http://localhost:8080/client/api?response=json&" +
+                  "command=listPortForwardingRules&listAll=true&id=4&apiKey=identity&signature=4blbBVn2%2BZfF8HwoglbmtYoDAjs%3D"))
+            .addHeader("Accept", "application/json")
+            .build(),
+         HttpResponse.builder()
+            .statusCode(404)
+            .build());
+
+      assertNull(client.getPortForwardingRule("4"));
+   }
+
+   public void testCreatePortForwardingRuleForVirtualMachine() {
+      FirewallApi client = requestSendsResponse(
+         HttpRequest.builder().method("GET")
+                    .endpoint("http://localhost:8080/client/api")
+                    .addQueryParam("response", "json")
+                    .addQueryParam("command", "createPortForwardingRule")
+                    .addQueryParam("ipaddressid", "2")
+                    .addQueryParam("protocol", "tcp")
+                    .addQueryParam("publicport", "22")
+                    .addQueryParam("virtualmachineid", "1234")
+                    .addQueryParam("privateport", "22")
+                    .addQueryParam("apiKey", "identity")
+                    .addQueryParam("signature", "84dtGzQp0G6k3z3Gkc3F/HBNS2Y%3D")
+                    .addHeader("Accept", "application/json")
+                    .build(),
+         HttpResponse.builder()
+            .statusCode(200)
+            .payload(payloadFromResource("/createportforwardingrulesresponse.json"))
+            .build());
+
+      AsyncCreateResponse response = client.createPortForwardingRuleForVirtualMachine(
+         "2", PortForwardingRule.Protocol.TCP, 22, "1234", 22);
+      assertEquals(response.getJobId(), "2035");
+      assertEquals(response.getId(), "2015");
+   }
+
+   public void testDeletePortForwardingRule() {
+      FirewallApi client = requestSendsResponse(
+         HttpRequest.builder()
+            .method("GET")
+            .endpoint(
+               URI.create("http://localhost:8080/client/api?response=json&" +
+                  "command=deletePortForwardingRule&id=2015&apiKey=identity&signature=2UE7KB3wm5ocmR%2BGMNFKPKfiDo8%3D"))
+            .build(),
+         HttpResponse.builder()
+            .statusCode(200)
+            .payload(payloadFromResource("/deleteportforwardingrulesresponse.json"))
+            .build());
+
+      client.deletePortForwardingRule("2015");
+   }
+   
+   @Override
+   protected FirewallApi clientFrom(CloudStackContext context) {
+      return context.getApi().getFirewallApi();
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/c6986efd/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/FirewallApiLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/FirewallApiLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/FirewallApiLiveTest.java
new file mode 100644
index 0000000..64cdf44
--- /dev/null
+++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/FirewallApiLiveTest.java
@@ -0,0 +1,194 @@
+/*
+ * 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.cloudstack.features;
+
+import static com.google.common.collect.Iterables.find;
+import static org.jclouds.cloudstack.predicates.NetworkPredicates.supportsPortForwarding;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+import java.util.NoSuchElementException;
+import java.util.Set;
+
+import org.jclouds.cloudstack.domain.AsyncCreateResponse;
+import org.jclouds.cloudstack.domain.FirewallRule;
+import org.jclouds.cloudstack.domain.Network;
+import org.jclouds.cloudstack.domain.PortForwardingRule;
+import org.jclouds.cloudstack.domain.PublicIPAddress;
+import org.jclouds.cloudstack.domain.VirtualMachine;
+import org.jclouds.cloudstack.internal.BaseCloudStackApiLiveTest;
+import org.jclouds.cloudstack.options.CreateFirewallRuleOptions;
+import org.jclouds.logging.Logger;
+import org.testng.annotations.AfterGroups;
+import org.testng.annotations.BeforeGroups;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+import com.google.common.net.HostAndPort;
+
+/**
+ * Tests behavior of {@code FirewallApiLiveTest}
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "live", singleThreaded = true, testName = "FirewallApiLiveTest")
+public class FirewallApiLiveTest extends BaseCloudStackApiLiveTest {
+   private PublicIPAddress ip = null;
+   private VirtualMachine vm;
+
+   private FirewallRule firewallRule;
+   private PortForwardingRule portForwardingRule;
+
+   private Network network;
+   private boolean networksDisabled;
+
+   @BeforeGroups(groups = "live")
+   public void setupContext() {
+      super.setupContext();
+      prefix += "rule";
+      try {
+         network = find(client.getNetworkApi().listNetworks(), Predicates.and(supportsPortForwarding(),
+            new Predicate<Network>() {
+               @Override
+               public boolean apply(Network network) {
+                  return network.isDefault()
+                     && !network.isSecurityGroupEnabled()
+                     && network.getAccount().equals(user.getAccount());
+               }
+            }));
+
+         String defaultTemplate = template != null ? template.getImageId() : null;
+
+         vm = VirtualMachineApiLiveTest.createVirtualMachineInNetwork(network,
+            defaultTemplateOrPreferredInZone(defaultTemplate, client, network.getZoneId()),
+            client, jobComplete, virtualMachineRunning);
+
+         if (vm.getPassword() != null && loginCredentials.getOptionalPassword() == null)
+            loginCredentials = loginCredentials.toBuilder().password(vm.getPassword()).build();
+
+      } catch (NoSuchElementException e) {
+         networksDisabled = true;
+      }
+   }
+
+   public void testCreatePortForwardingRule() throws Exception {
+      if (networksDisabled)
+         return;
+      while (portForwardingRule == null) {
+         ip = reuseOrAssociate.apply(network);
+         try {
+            AsyncCreateResponse job = client.getFirewallApi()
+               .createPortForwardingRuleForVirtualMachine(ip.getId(), PortForwardingRule.Protocol.TCP, 22, vm.getId(), 22);
+            assertTrue(jobComplete.apply(job.getJobId()));
+            portForwardingRule = client.getFirewallApi().getPortForwardingRule(job.getId());
+
+         } catch (IllegalStateException e) {
+            Logger.CONSOLE.error("Failed while trying to allocate ip: " + e);
+            // very likely an ip conflict, so retry;
+         }
+      }
+
+      assertEquals(portForwardingRule.getIPAddressId(), ip.getId());
+      assertEquals(portForwardingRule.getVirtualMachineId(), vm.getId());
+      assertEquals(portForwardingRule.getPublicPort(), 22);
+      assertEquals(portForwardingRule.getProtocol(), PortForwardingRule.Protocol.TCP);
+
+      checkPortForwardingRule(portForwardingRule);
+      checkSSH(HostAndPort.fromParts(ip.getIPAddress(), 22));
+   }
+
+   @Test(dependsOnMethods = "testCreatePortForwardingRule")
+   public void testListPortForwardingRules() throws Exception {
+      Set<PortForwardingRule> response = client.getFirewallApi().listPortForwardingRules();
+      assert null != response;
+      assertTrue(response.size() >= 0);
+      for (final PortForwardingRule rule : response) {
+         checkPortForwardingRule(rule);
+      }
+   }
+
+   @Test(dependsOnMethods = "testCreatePortForwardingRule")
+   public void testCreateFirewallRule() {
+      if (networksDisabled)
+         return;
+
+      AsyncCreateResponse job = client.getFirewallApi().createFirewallRuleForIpAndProtocol(
+         ip.getId(), FirewallRule.Protocol.TCP, CreateFirewallRuleOptions.Builder.startPort(30).endPort(35));
+      assertTrue(jobComplete.apply(job.getJobId()));
+      firewallRule = client.getFirewallApi().getFirewallRule(job.getId());
+
+      assertEquals(firewallRule.getStartPort(), 30);
+      assertEquals(firewallRule.getEndPort(), 35);
+      assertEquals(firewallRule.getProtocol(), FirewallRule.Protocol.TCP);
+
+      checkFirewallRule(firewallRule);
+   }
+
+   @Test(dependsOnMethods = "testCreateFirewallRule")
+   public void testListFirewallRules() {
+      Set<FirewallRule> rules = client.getFirewallApi().listFirewallRules();
+
+      assert rules != null;
+      assertTrue(rules.size() > 0);
+
+      for(FirewallRule rule : rules) {
+         checkFirewallRule(rule);
+      }
+   }
+
+   @AfterGroups(groups = "live")
+   @Override
+   protected void tearDownContext() {
+      if (firewallRule != null) {
+         client.getFirewallApi().deleteFirewallRule(firewallRule.getId());
+      }
+      if (portForwardingRule != null) {
+         client.getFirewallApi().deletePortForwardingRule(portForwardingRule.getId());
+      }
+      if (vm != null) {
+         jobComplete.apply(client.getVirtualMachineApi().destroyVirtualMachine(vm.getId()));
+      }
+      if (ip != null) {
+         client.getAddressApi().disassociateIPAddress(ip.getId());
+      }
+      super.tearDownContext();
+   }
+
+   protected void checkFirewallRule(FirewallRule rule) {
+      assertEquals(rule,
+         client.getFirewallApi().getFirewallRule(rule.getId()));
+      assert rule.getId() != null : rule;
+      assert rule.getStartPort() > 0 : rule;
+      assert rule.getEndPort() >= rule.getStartPort() : rule;
+      assert rule.getProtocol() != null;
+   }
+
+   protected void checkPortForwardingRule(PortForwardingRule rule) {
+      assertEquals(rule,
+         client.getFirewallApi().getPortForwardingRule(rule.getId()));
+      assert rule.getId() != null : rule;
+      assert rule.getIPAddress() != null : rule;
+      assert rule.getIPAddressId() != null : rule;
+      assert rule.getPrivatePort() > 0 : rule;
+      assert rule.getProtocol() != null : rule;
+      assert rule.getPublicPort() > 0 : rule;
+      assert rule.getState() != null : rule;
+      assert rule.getVirtualMachineId() != null : rule;
+      assert rule.getVirtualMachineName() != null : rule;
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/c6986efd/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/FirewallApiTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/FirewallApiTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/FirewallApiTest.java
new file mode 100644
index 0000000..979dbf7
--- /dev/null
+++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/FirewallApiTest.java
@@ -0,0 +1,118 @@
+/*
+ * 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.cloudstack.features;
+
+import static org.jclouds.reflect.Reflection2.method;
+
+import java.io.IOException;
+
+import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
+import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
+import org.jclouds.cloudstack.domain.PortForwardingRule;
+import org.jclouds.cloudstack.internal.BaseCloudStackApiTest;
+import org.jclouds.cloudstack.options.ListPortForwardingRulesOptions;
+import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
+import org.jclouds.http.functions.ParseFirstJsonValueNamed;
+import org.jclouds.http.functions.ReleasePayloadAndReturn;
+import org.jclouds.http.functions.UnwrapOnlyJsonValue;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.reflect.Invokable;
+/**
+ * Tests behavior of {@code FirewallApi}
+ * 
+ * @author Adrian Cole
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during
+// surefire
+@Test(groups = "unit", testName = "FirewallApiTest")
+public class FirewallApiTest extends BaseCloudStackApiTest<FirewallApi> {
+   public void testListPortForwardingRules() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(FirewallApi.class, "listPortForwardingRules",
+            ListPortForwardingRulesOptions[].class);
+      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
+
+      assertRequestLineEquals(httpRequest,
+            "GET http://localhost:8080/client/api?response=json&command=listPortForwardingRules&listAll=true HTTP/1.1");
+      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
+      assertPayloadEquals(httpRequest, null, null, false);
+
+      assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
+
+      checkFilters(httpRequest);
+
+   }
+
+   public void testListPortForwardingRulesOptions() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(FirewallApi.class, "listPortForwardingRules",
+            ListPortForwardingRulesOptions[].class);
+      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(ListPortForwardingRulesOptions.Builder.ipAddressId("3")));
+
+      assertRequestLineEquals(httpRequest,
+            "GET http://localhost:8080/client/api?response=json&command=listPortForwardingRules&listAll=true&ipaddressid=3 HTTP/1.1");
+      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
+      assertPayloadEquals(httpRequest, null, null, false);
+
+      assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
+
+      checkFilters(httpRequest);
+
+   }
+
+   public void testCreatePortForwardingRuleForVirtualMachine() throws SecurityException, NoSuchMethodException,
+         IOException {
+      Invokable<?, ?> method = method(FirewallApi.class, "createPortForwardingRuleForVirtualMachine", String.class,
+            PortForwardingRule.Protocol.class, int.class, String.class, int.class);
+      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("6", PortForwardingRule.Protocol.TCP, 22, "7", 22));
+
+      assertRequestLineEquals(
+            httpRequest,
+            "GET http://localhost:8080/client/api?response=json&command=createPortForwardingRule&ipaddressid=6&protocol=tcp&publicport=22&virtualmachineid=7&privateport=22 HTTP/1.1");
+      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
+      assertPayloadEquals(httpRequest, null, null, false);
+
+      assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyJsonValue.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
+
+      checkFilters(httpRequest);
+
+   }
+
+   public void testDeletePortForwardingRule() throws SecurityException, NoSuchMethodException, IOException {
+      Invokable<?, ?> method = method(FirewallApi.class, "deletePortForwardingRule", String.class);
+      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
+
+      assertRequestLineEquals(httpRequest,
+            "GET http://localhost:8080/client/api?response=json&command=deletePortForwardingRule&id=5 HTTP/1.1");
+      assertNonPayloadHeadersEqual(httpRequest, "");
+      assertPayloadEquals(httpRequest, null, null, false);
+
+      assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
+      assertSaxResponseParserClassEquals(method, null);
+      assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
+
+      checkFilters(httpRequest);
+
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/c6986efd/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/FirewallAsyncClientTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/FirewallAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/FirewallAsyncClientTest.java
deleted file mode 100644
index 1824d15..0000000
--- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/FirewallAsyncClientTest.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.cloudstack.features;
-
-import static org.jclouds.reflect.Reflection2.method;
-
-import java.io.IOException;
-
-import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
-import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
-import org.jclouds.cloudstack.domain.PortForwardingRule;
-import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
-import org.jclouds.cloudstack.options.ListPortForwardingRulesOptions;
-import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
-import org.jclouds.http.functions.ParseFirstJsonValueNamed;
-import org.jclouds.http.functions.ReleasePayloadAndReturn;
-import org.jclouds.http.functions.UnwrapOnlyJsonValue;
-import org.jclouds.rest.internal.GeneratedHttpRequest;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.reflect.Invokable;
-/**
- * Tests behavior of {@code FirewallAsyncClient}
- * 
- * @author Adrian Cole
- */
-// NOTE:without testName, this will not call @Before* and fail w/NPE during
-// surefire
-@Test(groups = "unit", testName = "FirewallAsyncClientTest")
-public class FirewallAsyncClientTest extends BaseCloudStackAsyncClientTest<FirewallAsyncClient> {
-   public void testListPortForwardingRules() throws SecurityException, NoSuchMethodException, IOException {
-      Invokable<?, ?> method = method(FirewallAsyncClient.class, "listPortForwardingRules",
-            ListPortForwardingRulesOptions[].class);
-      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
-
-      assertRequestLineEquals(httpRequest,
-            "GET http://localhost:8080/client/api?response=json&command=listPortForwardingRules&listAll=true HTTP/1.1");
-      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
-      assertPayloadEquals(httpRequest, null, null, false);
-
-      assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
-      assertSaxResponseParserClassEquals(method, null);
-      assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
-
-      checkFilters(httpRequest);
-
-   }
-
-   public void testListPortForwardingRulesOptions() throws SecurityException, NoSuchMethodException, IOException {
-      Invokable<?, ?> method = method(FirewallAsyncClient.class, "listPortForwardingRules",
-            ListPortForwardingRulesOptions[].class);
-      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(ListPortForwardingRulesOptions.Builder.ipAddressId("3")));
-
-      assertRequestLineEquals(httpRequest,
-            "GET http://localhost:8080/client/api?response=json&command=listPortForwardingRules&listAll=true&ipaddressid=3 HTTP/1.1");
-      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
-      assertPayloadEquals(httpRequest, null, null, false);
-
-      assertResponseParserClassEquals(method, httpRequest, ParseFirstJsonValueNamed.class);
-      assertSaxResponseParserClassEquals(method, null);
-      assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
-
-      checkFilters(httpRequest);
-
-   }
-
-   public void testCreatePortForwardingRuleForVirtualMachine() throws SecurityException, NoSuchMethodException,
-         IOException {
-      Invokable<?, ?> method = method(FirewallAsyncClient.class, "createPortForwardingRuleForVirtualMachine", String.class,
-            PortForwardingRule.Protocol.class, int.class, String.class, int.class);
-      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("6", PortForwardingRule.Protocol.TCP, 22, "7", 22));
-
-      assertRequestLineEquals(
-            httpRequest,
-            "GET http://localhost:8080/client/api?response=json&command=createPortForwardingRule&ipaddressid=6&protocol=tcp&publicport=22&virtualmachineid=7&privateport=22 HTTP/1.1");
-      assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
-      assertPayloadEquals(httpRequest, null, null, false);
-
-      assertResponseParserClassEquals(method, httpRequest, UnwrapOnlyJsonValue.class);
-      assertSaxResponseParserClassEquals(method, null);
-      assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
-
-      checkFilters(httpRequest);
-
-   }
-
-   public void testDeletePortForwardingRule() throws SecurityException, NoSuchMethodException, IOException {
-      Invokable<?, ?> method = method(FirewallAsyncClient.class, "deletePortForwardingRule", String.class);
-      GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(5));
-
-      assertRequestLineEquals(httpRequest,
-            "GET http://localhost:8080/client/api?response=json&command=deletePortForwardingRule&id=5 HTTP/1.1");
-      assertNonPayloadHeadersEqual(httpRequest, "");
-      assertPayloadEquals(httpRequest, null, null, false);
-
-      assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
-      assertSaxResponseParserClassEquals(method, null);
-      assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
-
-      checkFilters(httpRequest);
-
-   }
-}