You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ev...@apache.org on 2014/11/18 19:56:18 UTC
[3/5] jclouds git commit: JCLOUDS-716: Remove Rackspace First-Gen
Cloud Servers
http://git-wip-us.apache.org/repos/asf/jclouds/blob/162226b8/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/RebuildServerOptions.java
----------------------------------------------------------------------
diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/RebuildServerOptions.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/RebuildServerOptions.java
deleted file mode 100644
index 08769d4..0000000
--- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/RebuildServerOptions.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.cloudservers.options;
-
-import static com.google.common.base.Preconditions.checkArgument;
-
-import java.util.Map;
-
-import javax.inject.Inject;
-
-import org.jclouds.http.HttpRequest;
-import org.jclouds.rest.MapBinder;
-import org.jclouds.rest.binders.BindToJsonPayload;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Maps;
-
-public class RebuildServerOptions implements MapBinder {
- @Inject
- private BindToJsonPayload jsonBinder;
- Integer imageId;
-
- @Override
- public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
- Map<String, Integer> image = Maps.newHashMap();
- if (imageId != null)
- image.put("imageId", imageId);
- return jsonBinder.bindToRequest(request, ImmutableMap.of("rebuild", image));
- }
-
- @Override
- public <R extends HttpRequest> R bindToRequest(R request, Object toBind) {
- throw new IllegalStateException("RebuildServer is a POST operation");
- }
-
- /**
- *
- * @param id
- * of the image to rebuild the server with.
- */
- public RebuildServerOptions withImage(int id) {
- checkArgument(id > 0, "server id must be a positive number");
- this.imageId = id;
- return this;
- }
-
- public static class Builder {
-
- /**
- * @see RebuildServerOptions#withImage(int)
- */
- public static RebuildServerOptions withImage(int id) {
- RebuildServerOptions options = new RebuildServerOptions();
- return options.withImage(id);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/162226b8/apis/cloudservers/src/main/java/org/jclouds/cloudservers/predicates/ServerActive.java
----------------------------------------------------------------------
diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/predicates/ServerActive.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/predicates/ServerActive.java
deleted file mode 100644
index f2ea6e6..0000000
--- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/predicates/ServerActive.java
+++ /dev/null
@@ -1,62 +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.cloudservers.predicates;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import javax.annotation.Resource;
-import javax.inject.Singleton;
-
-import org.jclouds.cloudservers.CloudServersClient;
-import org.jclouds.cloudservers.domain.Server;
-import org.jclouds.cloudservers.domain.ServerStatus;
-import org.jclouds.logging.Logger;
-
-import com.google.common.base.Predicate;
-import com.google.inject.Inject;
-
-/**
- *
- * Tests to see if a task succeeds.
- */
-@Singleton
-public class ServerActive implements Predicate<Server> {
-
- private final CloudServersClient client;
-
- @Resource
- protected Logger logger = Logger.NULL;
-
- @Inject
- public ServerActive(CloudServersClient client) {
- this.client = client;
- }
-
- public boolean apply(Server server) {
- logger.trace("looking for state on server %s", checkNotNull(server, "server"));
- server = refresh(server);
- if (server == null)
- return false;
- logger.trace("%s: looking for server state %s: currently: %s", server.getId(),
- ServerStatus.ACTIVE, server.getStatus());
- return server.getStatus() == ServerStatus.ACTIVE;
- }
-
- private Server refresh(Server server) {
- return client.getServer(server.getId());
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/162226b8/apis/cloudservers/src/main/java/org/jclouds/cloudservers/predicates/ServerDeleted.java
----------------------------------------------------------------------
diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/predicates/ServerDeleted.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/predicates/ServerDeleted.java
deleted file mode 100644
index 0efbe24..0000000
--- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/predicates/ServerDeleted.java
+++ /dev/null
@@ -1,62 +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.cloudservers.predicates;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import javax.annotation.Resource;
-import javax.inject.Singleton;
-
-import org.jclouds.cloudservers.CloudServersClient;
-import org.jclouds.cloudservers.domain.Server;
-import org.jclouds.cloudservers.domain.ServerStatus;
-import org.jclouds.logging.Logger;
-
-import com.google.common.base.Predicate;
-import com.google.inject.Inject;
-
-/**
- *
- * Tests to see if a task succeeds.
- */
-@Singleton
-public class ServerDeleted implements Predicate<Server> {
-
- private final CloudServersClient client;
-
- @Resource
- protected Logger logger = Logger.NULL;
-
- @Inject
- public ServerDeleted(CloudServersClient client) {
- this.client = client;
- }
-
- public boolean apply(Server server) {
- logger.trace("looking for state on server %s", checkNotNull(server, "server"));
- server = refresh(server);
- if (server == null)
- return true;
- logger.trace("%s: looking for server state %s: currently: %s", server.getId(),
- ServerStatus.DELETED, server.getStatus());
- return server.getStatus() == ServerStatus.DELETED;
- }
-
- private Server refresh(Server server) {
- return client.getServer(server.getId());
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/162226b8/apis/cloudservers/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata
----------------------------------------------------------------------
diff --git a/apis/cloudservers/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/apis/cloudservers/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata
deleted file mode 100644
index 417ed21..0000000
--- a/apis/cloudservers/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata
+++ /dev/null
@@ -1 +0,0 @@
-org.jclouds.cloudservers.CloudServersApiMetadata
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds/blob/162226b8/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersApiMetadataTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersApiMetadataTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersApiMetadataTest.java
deleted file mode 100644
index c551a74..0000000
--- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersApiMetadataTest.java
+++ /dev/null
@@ -1,28 +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.cloudservers;
-
-import org.jclouds.compute.internal.BaseComputeServiceApiMetadataTest;
-import org.testng.annotations.Test;
-
-@Test(groups = "unit", testName = "CloudServersApiMetadataTest")
-public class CloudServersApiMetadataTest extends BaseComputeServiceApiMetadataTest {
-
- public CloudServersApiMetadataTest() {
- super(new CloudServersApiMetadata());
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/162226b8/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientLiveTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientLiveTest.java
deleted file mode 100644
index c9240f9..0000000
--- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientLiveTest.java
+++ /dev/null
@@ -1,606 +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.cloudservers;
-
-import static java.util.concurrent.TimeUnit.SECONDS;
-import static org.jclouds.cloudservers.options.CreateServerOptions.Builder.withFile;
-import static org.jclouds.cloudservers.options.CreateSharedIpGroupOptions.Builder.withServer;
-import static org.jclouds.cloudservers.options.ListOptions.Builder.withDetails;
-import static org.jclouds.util.Predicates2.retry;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
-
-import java.io.IOException;
-import java.lang.reflect.UndeclaredThrowableException;
-import java.security.SecureRandom;
-import java.util.Map;
-import java.util.Set;
-
-import org.jclouds.cloudservers.domain.BackupSchedule;
-import org.jclouds.cloudservers.domain.DailyBackup;
-import org.jclouds.cloudservers.domain.Flavor;
-import org.jclouds.cloudservers.domain.Image;
-import org.jclouds.cloudservers.domain.ImageStatus;
-import org.jclouds.cloudservers.domain.Limits;
-import org.jclouds.cloudservers.domain.RebootType;
-import org.jclouds.cloudservers.domain.Server;
-import org.jclouds.cloudservers.domain.ServerStatus;
-import org.jclouds.cloudservers.domain.SharedIpGroup;
-import org.jclouds.cloudservers.domain.WeeklyBackup;
-import org.jclouds.cloudservers.options.RebuildServerOptions;
-import org.jclouds.compute.domain.ExecResponse;
-import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
-import org.jclouds.domain.LoginCredentials;
-import org.jclouds.http.HttpResponseException;
-import org.jclouds.io.Payload;
-import org.jclouds.predicates.SocketOpen;
-import org.jclouds.ssh.SshClient;
-import org.jclouds.ssh.SshException;
-import org.jclouds.sshj.config.SshjSshClientModule;
-import org.jclouds.util.Strings2;
-import org.testng.annotations.AfterTest;
-import org.testng.annotations.BeforeGroups;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Predicate;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Iterables;
-import com.google.common.net.HostAndPort;
-import com.google.inject.Injector;
-import com.google.inject.Module;
-
-/**
- * Tests behavior of {@code CloudServersClient}
- */
-@Test(groups = "live", singleThreaded = true, testName = "CloudServersClientLiveTest")
-public class CloudServersClientLiveTest extends BaseComputeServiceContextLiveTest {
-
- public CloudServersClientLiveTest() {
- provider = "cloudservers";
- }
-
- protected CloudServersClient client;
- protected SshClient.Factory sshFactory;
- protected Predicate<HostAndPort> socketTester;
-
- @BeforeGroups(groups = { "integration", "live" })
- @Override
- public void setupContext() {
- super.setupContext();
- Injector injector = view.utils().injector();
- client = injector.getInstance(CloudServersClient.class);
- sshFactory = injector.getInstance(SshClient.Factory.class);
- SocketOpen socketOpen = injector.getInstance(SocketOpen.class);
- socketTester = retry(socketOpen, 120, 1, SECONDS);
- injector.injectMembers(socketOpen); // add logger
- }
-
- public void testLimits() throws Exception {
- Limits response = client.getLimits();
- assert null != response;
- assertTrue(!response.getAbsolute().isEmpty());
- assertTrue(!response.getRate().isEmpty());
- }
-
- public void testListServers() throws Exception {
-
- Set<Server> response = client.listServers();
- assert null != response;
- long initialContainerCount = response.size();
- assertTrue(initialContainerCount >= 0);
-
- }
-
- public void testListServersDetail() throws Exception {
- Set<Server> response = client.listServers(withDetails());
- assert null != response;
- long initialContainerCount = response.size();
- assertTrue(initialContainerCount >= 0);
- }
-
- public void testListImages() throws Exception {
- Set<Image> response = client.listImages();
- assert null != response;
- long imageCount = response.size();
- assertTrue(imageCount >= 1);
- for (Image image : response) {
- assertTrue(image.getId() >= 0);
- assert null != image.getName() : image;
- }
-
- }
-
- public void testListImagesDetail() throws Exception {
- Set<Image> response = client.listImages(withDetails());
- assert null != response;
- long imageCount = response.size();
- assertTrue(imageCount >= 0);
- for (Image image : response) {
- assertTrue(image.getId() >= 1);
- assert null != image.getName() : image;
- assert null != image.getStatus() : image;
- }
- }
-
- public void testGetImagesDetail() throws Exception {
- Set<Image> response = client.listImages(withDetails());
- assert null != response;
- long imageCount = response.size();
- assertTrue(imageCount >= 0);
- for (Image image : response) {
- Image newDetails = client.getImage(image.getId());
- assertEquals(image, newDetails);
- }
- }
-
- @Test
- public void testGetImageDetailsNotFound() throws Exception {
- assert client.getImage(12312987) == null;
- }
-
- @Test
- public void testGetServerDetailsNotFound() throws Exception {
- assert client.getServer(12312987) == null;
- }
-
- public void testGetServersDetail() throws Exception {
- Set<Server> response = client.listServers(withDetails());
- assert null != response;
- long serverCount = response.size();
- assertTrue(serverCount >= 0);
- for (Server server : response) {
- Server newDetails = client.getServer(server.getId());
- assertEquals(server, newDetails);
- }
- }
-
- public void testListFlavors() throws Exception {
- Set<Flavor> response = client.listFlavors();
- assert null != response;
- long flavorCount = response.size();
- assertTrue(flavorCount >= 1);
- for (Flavor flavor : response) {
- assertTrue(flavor.getId() >= 0);
- assert null != flavor.getName() : flavor;
- }
-
- }
-
- public void testListFlavorsDetail() throws Exception {
- Set<Flavor> response = client.listFlavors(withDetails());
- assert null != response;
- long flavorCount = response.size();
- assertTrue(flavorCount >= 0);
- for (Flavor flavor : response) {
- assertTrue(flavor.getId() >= 1);
- assert null != flavor.getName() : flavor;
- assert null != flavor.getDisk() : flavor;
- assert null != flavor.getRam() : flavor;
- }
- }
-
- public void testGetFlavorsDetail() throws Exception {
- Set<Flavor> response = client.listFlavors(withDetails());
- assert null != response;
- long flavorCount = response.size();
- assertTrue(flavorCount >= 0);
- for (Flavor flavor : response) {
- Flavor newDetails = client.getFlavor(flavor.getId());
- assertEquals(flavor, newDetails);
- }
- }
-
- @Test
- public void testGetFlavorDetailsNotFound() throws Exception {
- assert client.getFlavor(12312987) == null;
- }
-
- public void testListSharedIpGroups() throws Exception {
- Set<SharedIpGroup> response = client.listSharedIpGroups();
- assert null != response;
- long sharedIpGroupCount = response.size();
- assertTrue(sharedIpGroupCount >= 0);
- for (SharedIpGroup sharedIpGroup : response) {
- assertTrue(sharedIpGroup.getId() >= 0);
- assert null != sharedIpGroup.getName() : sharedIpGroup;
- }
-
- }
-
- public void testListSharedIpGroupsDetail() throws Exception {
- Set<SharedIpGroup> response = client.listSharedIpGroups(withDetails());
- assert null != response;
- long sharedIpGroupCount = response.size();
- assertTrue(sharedIpGroupCount >= 0);
- for (SharedIpGroup sharedIpGroup : response) {
- assertTrue(sharedIpGroup.getId() >= 1);
- assert null != sharedIpGroup.getName() : sharedIpGroup;
- assert null != sharedIpGroup.getServers() : sharedIpGroup;
- }
- }
-
- public void testGetSharedIpGroupsDetail() throws Exception {
- Set<SharedIpGroup> response = client.listSharedIpGroups(withDetails());
- assert null != response;
- long sharedIpGroupCount = response.size();
- assertTrue(sharedIpGroupCount >= 0);
- for (SharedIpGroup sharedIpGroup : response) {
- SharedIpGroup newDetails = client.getSharedIpGroup(sharedIpGroup.getId());
- assertEquals(sharedIpGroup, newDetails);
- }
- }
-
- @Test
- public void testGetSharedIpGroupDetailsNotFound() throws Exception {
- assert client.getSharedIpGroup(12312987) == null;
- }
-
- @Test(timeOut = 5 * 60 * 1000, dependsOnMethods = "testCreateServer")
- public void testCreateSharedIpGroup() throws Exception {
- SharedIpGroup sharedIpGroup = null;
- while (sharedIpGroup == null) {
- String sharedIpGroupName = serverPrefix + "createSharedIpGroup" + new SecureRandom().nextInt();
- try {
- sharedIpGroup = client.createSharedIpGroup(sharedIpGroupName, withServer(serverId));
- } catch (UndeclaredThrowableException e) {
- HttpResponseException htpe = (HttpResponseException) e.getCause().getCause();
- if (htpe.getResponse().getStatusCode() == 400)
- continue;
- throw e;
- }
- }
- assertNotNull(sharedIpGroup.getName());
- sharedIpGroupId = sharedIpGroup.getId();
- // Response doesn't include the server id Web Hosting #119311
- assert !sharedIpGroup.getServers().equals(ImmutableList.of(serverId));
- }
-
- private int sharedIpGroupId;
-
- private String serverPrefix = System.getProperty("user.name") + ".cs";
- private int serverId;
- private String adminPass;
- Map<String, String> metadata = ImmutableMap.of("jclouds", "rackspace");
- private String ip;
- private int serverId2;
- private String adminPass2;
- private int imageId;
-
- public void testCreateServer() throws Exception {
- int imageId = 14362;
- int flavorId = 1;
- Server server = null;
- while (server == null) {
- String serverName = serverPrefix + "createserver" + new SecureRandom().nextInt();
- try {
- server = client.createServer(serverName, imageId, flavorId, withFile("/etc/jclouds.txt",
- "rackspace".getBytes()).withMetadata(metadata));
- } catch (UndeclaredThrowableException e) {
- HttpResponseException htpe = (HttpResponseException) e.getCause().getCause();
- if (htpe.getResponse().getStatusCode() == 400)
- continue;
- throw e;
- }
- }
- assertNotNull(server.getAdminPass());
- serverId = server.getId();
- adminPass = server.getAdminPass();
- ip = server.getAddresses().getPublicAddresses().iterator().next();
- assertEquals(server.getStatus(), ServerStatus.BUILD);
- blockUntilServerActive(serverId);
- }
-
- private void blockUntilServerActive(int serverId) throws InterruptedException {
- Server currentDetails = null;
- for (currentDetails = client.getServer(serverId); currentDetails.getStatus() != ServerStatus.ACTIVE; currentDetails = client
- .getServer(serverId)) {
- System.out.printf("blocking on status active%n%s%n", currentDetails);
- Thread.sleep(5 * 1000);
- }
- }
-
- private void blockUntilServerVerifyResize(int serverId) throws InterruptedException {
- Server currentDetails = null;
- for (currentDetails = client.getServer(serverId); currentDetails.getStatus() != ServerStatus.VERIFY_RESIZE; currentDetails = client
- .getServer(serverId)) {
- System.out.printf("blocking on status verify resize%n%s%n", currentDetails);
- Thread.sleep(5 * 1000);
- }
- }
-
- private void blockUntilImageActive(int imageId) throws InterruptedException {
- Image currentDetails = null;
- for (currentDetails = client.getImage(imageId); currentDetails.getStatus() != ImageStatus.ACTIVE; currentDetails = client
- .getImage(imageId)) {
- System.out.printf("blocking on status active%n%s%n", currentDetails);
- Thread.sleep(5 * 1000);
- }
- }
-
- @Test(timeOut = 5 * 60 * 1000, dependsOnMethods = "testCreateServer")
- public void testServerDetails() throws Exception {
- Server server = client.getServer(serverId);
-
- assertNotNull(server.getHostId());
- assertEquals(server.getStatus(), ServerStatus.ACTIVE);
- assert server.getProgress() >= 0 : "newDetails.getProgress()" + server.getProgress();
- assertEquals(Integer.valueOf(14362), server.getImageId());
- assertEquals(Integer.valueOf(1), server.getFlavorId());
- assertNotNull(server.getAddresses());
- // listAddresses tests..
- assertEquals(client.getAddresses(serverId), server.getAddresses());
- assertEquals(server.getAddresses().getPublicAddresses().size(), 1);
- assertEquals(client.listPublicAddresses(serverId), server.getAddresses().getPublicAddresses());
- assertEquals(server.getAddresses().getPrivateAddresses().size(), 1);
- assertEquals(client.listPrivateAddresses(serverId), server.getAddresses().getPrivateAddresses());
-
- // check metadata
- assertEquals(server.getMetadata(), metadata);
-
- checkPassOk(server, adminPass);
- }
-
- /**
- * this tests "personality" as the file looked up was sent during server creation
- */
- private void checkPassOk(Server newDetails, String pass) throws IOException {
- try {
- doCheckPass(newDetails, pass);
- } catch (SshException e) {// try twice in case there is a network timeout
- try {
- Thread.sleep(10 * 1000);
- } catch (InterruptedException e1) {
- }
- doCheckPass(newDetails, pass);
- }
- }
-
- private void doCheckPass(Server newDetails, String pass) throws IOException {
- HostAndPort socket = HostAndPort.fromParts(Iterables.get(newDetails.getAddresses().getPublicAddresses(), 0), 22);
- socketTester.apply(socket);
-
- SshClient client = sshFactory.create(socket, LoginCredentials.builder().user("root").password(pass).build());
- try {
- client.connect();
- Payload etcPasswd = client.get("/etc/jclouds.txt");
- String etcPasswdContents = Strings2.toStringAndClose(etcPasswd.openStream());
- assertEquals("rackspace", etcPasswdContents.trim());
- } finally {
- if (client != null)
- client.disconnect();
- }
- }
-
- private ExecResponse exec(Server details, String pass, String command) throws IOException {
- HostAndPort socket = HostAndPort.fromParts(Iterables.get(details.getAddresses().getPublicAddresses(), 0), 22);
- socketTester.apply(socket);
- SshClient client = sshFactory.create(socket, LoginCredentials.builder().user("root").password(pass).build());
- try {
- client.connect();
- return client.exec(command);
- } finally {
- if (client != null)
- client.disconnect();
- }
- }
-
- @Test(timeOut = 5 * 60 * 1000, dependsOnMethods = "testCreateServer")
- public void testRenameServer() throws Exception {
- Server server = client.getServer(serverId);
- String oldName = server.getName();
- client.renameServer(serverId, oldName + "new");
- blockUntilServerActive(serverId);
- assertEquals(oldName + "new", client.getServer(serverId).getName());
- }
-
- @Test(timeOut = 5 * 60 * 1000, dependsOnMethods = "testCreateServer")
- public void testChangePassword() throws Exception {
- client.changeAdminPass(serverId, "elmo");
- blockUntilServerActive(serverId);
- checkPassOk(client.getServer(serverId), "elmo");
- this.adminPass = "elmo";
- }
-
- @Test(timeOut = 5 * 60 * 1000, dependsOnMethods = "testCreateSharedIpGroup")
- public void testCreateServerIp() throws Exception {
- int imageId = 14362;
- int flavorId = 1;
- Server server = null;
- while (server == null) {
- String serverName = serverPrefix + "createserver" + new SecureRandom().nextInt();
- try {
- server = client
- .createServer(serverName, imageId, flavorId, withFile("/etc/jclouds.txt", "rackspace".getBytes())
- .withMetadata(metadata).withSharedIpGroup(sharedIpGroupId).withSharedIp(ip));
- } catch (UndeclaredThrowableException e) {
- HttpResponseException htpe = (HttpResponseException) e.getCause().getCause();
- if (htpe.getResponse().getStatusCode() == 400)
- continue;
- throw e;
- }
- }
- assertNotNull(server.getAdminPass());
- serverId2 = server.getId();
- adminPass2 = server.getAdminPass();
- blockUntilServerActive(serverId2);
- assertIpConfigured(server, adminPass2);
- assert server.getAddresses().getPublicAddresses().contains(ip) : server.getAddresses() + " doesn't contain " + ip;
- assertEquals(server.getSharedIpGroupId(), Integer.valueOf(sharedIpGroupId));
- }
-
- private void assertIpConfigured(Server server, String password) {
- try {
- ExecResponse response = exec(server, password, "ifconfig -a");
- assert response.getOutput().indexOf(ip) > 0 : String.format("server %s didn't get ip %s%n%s", server, ip,
- response);
- } catch (Exception e) {
- e.printStackTrace();
- } catch (AssertionError e) {
- e.printStackTrace();
- }
- }
-
- @Test(timeOut = 10 * 60 * 1000, dependsOnMethods = "testCreateServerIp")
- public void testUnshare() throws Exception {
- client.unshareIp(ip, serverId2);
- blockUntilServerActive(serverId2);
- Server server = client.getServer(serverId2);
- assert !server.getAddresses().getPublicAddresses().contains(ip) : server.getAddresses();
- assertIpNotConfigured(server, adminPass2);
- }
-
- private void assertIpNotConfigured(Server server, String password) {
- try {
- ExecResponse response = exec(server, password, "ifconfig -a");
- assert response.getOutput().indexOf(ip) == -1 : String.format("server %s still has get ip %s%n%s", server, ip,
- response);
- } catch (Exception e) {
- e.printStackTrace();
- } catch (AssertionError e) {
- e.printStackTrace();
- }
- }
-
- @Test(timeOut = 10 * 60 * 1000, dependsOnMethods = "testUnshare")
- public void testShareConfig() throws Exception {
- client.shareIp(ip, serverId2, sharedIpGroupId, true);
- blockUntilServerActive(serverId2);
- Server server = client.getServer(serverId2);
- assert server.getAddresses().getPublicAddresses().contains(ip) : server.getAddresses();
- assertIpConfigured(server, adminPass2);
- testUnshare();
- }
-
- @Test(timeOut = 10 * 60 * 1000, dependsOnMethods = "testShareConfig")
- public void testShareNoConfig() throws Exception {
- client.shareIp(ip, serverId2, sharedIpGroupId, false);
- blockUntilServerActive(serverId2);
- Server server = client.getServer(serverId2);
- assert server.getAddresses().getPublicAddresses().contains(ip) : server.getAddresses();
- assertIpNotConfigured(server, adminPass2);
- testUnshare();
- }
-
- @Test(timeOut = 10 * 60 * 1000, dependsOnMethods = "testShareNoConfig")
- public void testBackup() throws Exception {
- assertEquals(BackupSchedule.builder().build(), client.getBackupSchedule(serverId));
- BackupSchedule dailyWeekly = BackupSchedule.builder().enabled(true).weekly(WeeklyBackup.FRIDAY).daily(DailyBackup.H_0400_0600).build();
- client.replaceBackupSchedule(serverId, dailyWeekly);
- client.deleteBackupSchedule(serverId);
- // disables, doesn't delete: Web Hosting #119571
- assertEquals(client.getBackupSchedule(serverId).isEnabled(), false);
- }
-
- @Test(timeOut = 10 * 60 * 1000, dependsOnMethods = "testBackup")
- public void testCreateImage() throws Exception {
- Image image = client.createImageFromServer("hoofie", serverId);
- assertEquals("hoofie", image.getName());
- assertEquals(Integer.valueOf(serverId), image.getServerId());
- imageId = image.getId();
- blockUntilImageActive(imageId);
- }
-
- @Test(timeOut = 10 * 60 * 1000, dependsOnMethods = "testCreateImage")
- public void testRebuildServer() throws Exception {
- client.rebuildServer(serverId, new RebuildServerOptions().withImage(imageId));
- blockUntilServerActive(serverId);
- // issue Web Hosting #119580 imageId comes back incorrect after rebuild
- assert !Integer.valueOf(imageId).equals(client.getServer(serverId).getImageId());
- }
-
- @Test(timeOut = 10 * 60 * 1000, dependsOnMethods = "testRebuildServer")
- public void testRebootHard() throws Exception {
- client.rebootServer(serverId, RebootType.HARD);
- blockUntilServerActive(serverId);
- }
-
- @Test(timeOut = 10 * 60 * 1000, dependsOnMethods = "testRebootHard")
- public void testRebootSoft() throws Exception {
- client.rebootServer(serverId, RebootType.SOFT);
- blockUntilServerActive(serverId);
- }
-
- @Test(timeOut = 10 * 60 * 1000, dependsOnMethods = "testRebootSoft")
- public void testRevertResize() throws Exception {
- client.resizeServer(serverId, 2);
- blockUntilServerVerifyResize(serverId);
- client.revertResizeServer(serverId);
- blockUntilServerActive(serverId);
- assertEquals(Integer.valueOf(1), client.getServer(serverId).getFlavorId());
- }
-
- @Test(timeOut = 10 * 60 * 1000, dependsOnMethods = "testRebootSoft")
- public void testConfirmResize() throws Exception {
- client.resizeServer(serverId2, 2);
- blockUntilServerVerifyResize(serverId2);
- client.confirmResizeServer(serverId2);
- blockUntilServerActive(serverId2);
- assertEquals(Integer.valueOf(2), client.getServer(serverId2).getFlavorId());
- }
-
- @Test(timeOut = 10 * 60 * 1000, dependsOnMethods = { "testRebootSoft", "testRevertResize", "testConfirmResize" })
- void deleteServer2() {
- if (serverId2 > 0) {
- client.deleteServer(serverId2);
- assert client.getServer(serverId2) == null;
- }
- }
-
- @Test(timeOut = 10 * 60 * 1000, dependsOnMethods = "deleteServer2")
- void testDeleteImage() {
- if (imageId > 0) {
- client.deleteImage(imageId);
- assert client.getImage(imageId) == null;
- }
- }
-
- @Test(timeOut = 10 * 60 * 1000, dependsOnMethods = "testDeleteImage")
- void deleteServer1() {
- if (serverId > 0) {
- client.deleteServer(serverId);
- assert client.getServer(serverId) == null;
- }
- }
-
- @Test(timeOut = 10 * 60 * 1000, dependsOnMethods = { "deleteServer1" })
- void testDeleteSharedIpGroup() {
- if (sharedIpGroupId > 0) {
- client.deleteSharedIpGroup(sharedIpGroupId);
- assert client.getSharedIpGroup(sharedIpGroupId) == null;
- }
- }
-
- @AfterTest
- void deleteServersOnEnd() {
- if (serverId > 0) {
- client.deleteServer(serverId);
- }
- if (serverId2 > 0) {
- client.deleteServer(serverId2);
- }
- if (sharedIpGroupId > 0) {
- client.deleteSharedIpGroup(sharedIpGroupId);
- }
- }
-
- @Override
- protected Module getSshModule() {
- return new SshjSshClientModule();
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/162226b8/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientTest.java
deleted file mode 100644
index 28f9ca6..0000000
--- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientTest.java
+++ /dev/null
@@ -1,898 +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.cloudservers;
-
-import static org.jclouds.Constants.PROPERTY_API_VERSION;
-import static org.jclouds.cloudservers.options.CreateServerOptions.Builder.withFile;
-import static org.jclouds.cloudservers.options.CreateServerOptions.Builder.withMetadata;
-import static org.jclouds.cloudservers.options.CreateServerOptions.Builder.withSharedIpGroup;
-import static org.jclouds.cloudservers.options.CreateSharedIpGroupOptions.Builder.withServer;
-import static org.jclouds.cloudservers.options.ListOptions.Builder.changesSince;
-import static org.jclouds.cloudservers.options.ListOptions.Builder.withDetails;
-import static org.jclouds.cloudservers.options.RebuildServerOptions.Builder.withImage;
-import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS;
-import static org.jclouds.reflect.Reflection2.method;
-import static org.testng.Assert.assertEquals;
-
-import java.io.IOException;
-import java.net.UnknownHostException;
-import java.util.Date;
-import java.util.Properties;
-
-import javax.inject.Singleton;
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
-import org.jclouds.Fallbacks.FalseOnNotFoundOr404;
-import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
-import org.jclouds.apis.ApiMetadata;
-import org.jclouds.cloudservers.config.CloudServersHttpApiModule;
-import org.jclouds.cloudservers.domain.BackupSchedule;
-import org.jclouds.cloudservers.domain.DailyBackup;
-import org.jclouds.cloudservers.domain.RebootType;
-import org.jclouds.cloudservers.domain.WeeklyBackup;
-import org.jclouds.cloudservers.options.CreateServerOptions;
-import org.jclouds.cloudservers.options.CreateSharedIpGroupOptions;
-import org.jclouds.cloudservers.options.ListOptions;
-import org.jclouds.cloudservers.options.RebuildServerOptions;
-import org.jclouds.domain.Credentials;
-import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.functions.ReleasePayloadAndReturn;
-import org.jclouds.http.functions.ReturnTrueIf2xx;
-import org.jclouds.http.functions.UnwrapOnlyJsonValue;
-import org.jclouds.openstack.filters.AddTimestampQuery;
-import org.jclouds.openstack.filters.AuthenticateRequest;
-import org.jclouds.openstack.keystone.v1_1.config.AuthenticationServiceModule.GetAuth;
-import org.jclouds.openstack.keystone.v1_1.domain.Auth;
-import org.jclouds.openstack.keystone.v1_1.parse.ParseAuthTest;
-import org.jclouds.rest.ConfiguresHttpApi;
-import org.jclouds.rest.internal.BaseRestAnnotationProcessingTest;
-import org.jclouds.rest.internal.GeneratedHttpRequest;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.reflect.Invokable;
-import com.google.inject.Module;
-import com.google.inject.Provides;
-
-@Test(groups = "unit", singleThreaded = true, testName = "CloudServersClientTest")
-public class CloudServersClientTest extends BaseRestAnnotationProcessingTest<CloudServersClient> {
-
- public void testCreateServer() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersClient.class, "createServer", String.class, int.class, int.class,
- CreateServerOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("ralphie", 2, 1));
-
- assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, "{\"server\":{\"name\":\"ralphie\",\"imageId\":2,\"flavorId\":1}}",
- "application/json", false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
-
- }
-
- public void testCreateServerWithIpGroup() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersClient.class, "createServer", String.class, int.class, int.class,
- CreateServerOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("ralphie", 2, 1, withSharedIpGroup(2)));
-
- assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request,
- "{\"server\":{\"name\":\"ralphie\",\"imageId\":2,\"flavorId\":1,\"sharedIpGroupId\":2}}",
- "application/json", false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testCreateServerWithFile() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersClient.class, "createServer", String.class, int.class, int.class,
- CreateServerOptions[].class);
- GeneratedHttpRequest request = processor
- .createRequest(method, ImmutableList.<Object> of("ralphie", 2, 1, withFile("/etc/jclouds", "foo".getBytes())));
-
- assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(
- request,
- "{\"server\":{\"name\":\"ralphie\",\"imageId\":2,\"flavorId\":1,\"personality\":[{\"path\":\"/etc/jclouds\",\"contents\":\"Zm9v\"}]}}",
- "application/json", false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
-
- }
-
- public void testCreateServerWithMetadata() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersClient.class, "createServer", String.class, int.class, int.class,
- CreateServerOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("ralphie", 2, 1,
- withMetadata(ImmutableMap.of("foo", "bar"))));
-
- assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request,
- "{\"server\":{\"name\":\"ralphie\",\"imageId\":2,\"flavorId\":1,\"metadata\":{\"foo\":\"bar\"}}}",
- "application/json", false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
-
- }
-
- public void testCreateServerWithIpGroupAndSharedIp() throws IOException, SecurityException, NoSuchMethodException,
- UnknownHostException {
- Invokable<?, ?> method = method(CloudServersClient.class, "createServer", String.class, int.class, int.class,
- CreateServerOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("ralphie", 2, 1,
- withSharedIpGroup(2).withSharedIp("127.0.0.1")));
-
- assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(
- request,
- "{\"server\":{\"name\":\"ralphie\",\"imageId\":2,\"flavorId\":1,\"sharedIpGroupId\":2,\"addresses\":{\"public\":[\"127.0.0.1\"]}}}",
- "application/json", false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testDeleteImage() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersClient.class, "deleteImage", int.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
-
- assertRequestLineEquals(request, "DELETE https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images/2 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ReturnTrueIf2xx.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, FalseOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testLimits() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersClient.class, "getLimits");
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of());
-
- assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/limits?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testListServers() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersClient.class, "listServers", ListOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of());
-
- assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- Date now = new Date(10000000l);
-
- public void testListServersOptions() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersClient.class, "listServers", ListOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(changesSince(now).maxResults(1).startAt(2)));
-
- assertRequestLineEquals(request,
- "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers?format=json&changes-since=10000&limit=1&offset=2 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testListServersDetail() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersClient.class, "listServers", ListOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(withDetails()));
-
- assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/detail?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testGetServer() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersClient.class, "getServer", int.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
-
- assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testListFlavors() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersClient.class, "listFlavors", ListOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of());
-
- assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/flavors?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testListFlavorsOptions() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersClient.class, "listFlavors", ListOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(changesSince(now).maxResults(1).startAt(2)));
-
- assertRequestLineEquals(request,
- "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/flavors?format=json&changes-since=10000&limit=1&offset=2 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testListFlavorsDetail() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersClient.class, "listFlavors", ListOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(withDetails()));
-
- assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/flavors/detail?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testListFlavorsDetailOptions() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersClient.class, "listFlavors", ListOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(withDetails().changesSince(now).maxResults(1).startAt(2)));
-
- assertRequestLineEquals(request,
- "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/flavors/detail?format=json&changes-since=10000&limit=1&offset=2 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testGetFlavor() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersClient.class, "getFlavor", int.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
-
- assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/flavors/2?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testListImages() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersClient.class, "listImages", ListOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of());
-
- assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testListImagesDetail() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersClient.class, "listImages", ListOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(withDetails()));
-
- assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images/detail?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testListImagesOptions() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersClient.class, "listImages", ListOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(changesSince(now).maxResults(1).startAt(2)));
-
- assertRequestLineEquals(request,
- "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images?format=json&changes-since=10000&limit=1&offset=2 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testListImagesDetailOptions() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersClient.class, "listImages", ListOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(withDetails().changesSince(now).maxResults(1).startAt(2)));
-
- assertRequestLineEquals(request,
- "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images/detail?format=json&changes-since=10000&limit=1&offset=2 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testGetImage() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersClient.class, "getImage", int.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
-
- assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images/2?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testDeleteServer() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersClient.class, "deleteServer", int.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
-
- assertRequestLineEquals(request, "DELETE https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ReturnTrueIf2xx.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, FalseOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testShareIpNoConfig() throws IOException, SecurityException, NoSuchMethodException, UnknownHostException {
- Invokable<?, ?> method = method(CloudServersClient.class, "shareIp", String.class, int.class, int.class,
- boolean.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("127.0.0.1", 2, 3, false));
-
- assertRequestLineEquals(request, "PUT https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/ips/public/127.0.0.1 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, "{\"shareIp\":{\"sharedIpGroupId\":3,\"configureServer\":false}}",
- MediaType.APPLICATION_JSON, false);
-
- assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
-
- }
-
- public void testShareIpConfig() throws IOException, SecurityException, NoSuchMethodException, UnknownHostException {
- Invokable<?, ?> method = method(CloudServersClient.class, "shareIp", String.class, int.class, int.class,
- boolean.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("127.0.0.1", 2, 3, true));
-
- assertRequestLineEquals(request, "PUT https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/ips/public/127.0.0.1 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, "{\"shareIp\":{\"sharedIpGroupId\":3,\"configureServer\":true}}",
- MediaType.APPLICATION_JSON, false);
-
- assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
-
- }
-
- public void testUnshareIpNoConfig() throws IOException, SecurityException, NoSuchMethodException,
- UnknownHostException {
- Invokable<?, ?> method = method(CloudServersClient.class, "unshareIp", String.class, int.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("127.0.0.1", 2, 3, false));
-
- assertRequestLineEquals(request, "DELETE https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/ips/public/127.0.0.1 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
-
- checkFilters(request);
-
- }
-
- public void testReplaceBackupSchedule() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersClient.class, "replaceBackupSchedule", int.class, BackupSchedule.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2, BackupSchedule.builder().weekly(WeeklyBackup.MONDAY)
- .daily(DailyBackup.H_0800_1000).enabled(true).build()));
-
- assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/backup_schedule HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request,
- "{\"backupSchedule\":{\"daily\":\"H_0800_1000\",\"enabled\":true,\"weekly\":\"MONDAY\"}}",
- MediaType.APPLICATION_JSON, false);
-
- assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
-
- checkFilters(request);
-
- }
-
- public void testDeleteBackupSchedule() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersClient.class, "deleteBackupSchedule", int.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
-
- assertRequestLineEquals(request, "DELETE https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/backup_schedule HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, MediaType.APPLICATION_JSON, false);
-
- assertResponseParserClassEquals(method, request, ReturnTrueIf2xx.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, FalseOnNotFoundOr404.class);
-
- checkFilters(request);
-
- }
-
- public void testChangeAdminPass() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersClient.class, "changeAdminPass", int.class, String.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2, "foo"));
-
- assertRequestLineEquals(request, "PUT https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, "{\"server\":{\"adminPass\":\"foo\"}}", MediaType.APPLICATION_JSON, false);
-
- assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
-
- }
-
- public void testChangeServerName() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersClient.class, "renameServer", int.class, String.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2, "foo"));
-
- assertRequestLineEquals(request, "PUT https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, "{\"server\":{\"name\":\"foo\"}}", MediaType.APPLICATION_JSON, false);
-
- assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
-
- }
-
- public void testListSharedIpGroups() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersClient.class, "listSharedIpGroups", ListOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of());
-
- assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/shared_ip_groups?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testListSharedIpGroupsOptions() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersClient.class, "listSharedIpGroups", ListOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(changesSince(now).maxResults(1).startAt(2)));
-
- assertRequestLineEquals(request,
- "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/shared_ip_groups?format=json&changes-since=10000&limit=1&offset=2 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testListSharedIpGroupsDetail() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersClient.class, "listSharedIpGroups", ListOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(withDetails()));
-
- assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/shared_ip_groups/detail?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testListSharedIpGroupsDetailOptions() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersClient.class, "listSharedIpGroups", ListOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(withDetails().changesSince(now).maxResults(1).startAt(2)));
-
- assertRequestLineEquals(request,
- "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/shared_ip_groups/detail?format=json&changes-since=10000&limit=1&offset=2 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testGetSharedIpGroup() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersClient.class, "getSharedIpGroup", int.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
-
- assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/shared_ip_groups/2?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testCreateSharedIpGroup() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersClient.class, "createSharedIpGroup", String.class,
- CreateSharedIpGroupOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("ralphie"));
-
- assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/shared_ip_groups?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, "{\"sharedIpGroup\":{\"name\":\"ralphie\"}}", MediaType.APPLICATION_JSON, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
-
- }
-
- public void testCreateSharedIpGroupWithIpGroup() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersClient.class, "createSharedIpGroup", String.class,
- CreateSharedIpGroupOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("ralphie", withServer(2)));
-
- assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/shared_ip_groups?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, "{\"sharedIpGroup\":{\"name\":\"ralphie\",\"server\":2}}",
- MediaType.APPLICATION_JSON, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testDeleteSharedIpGroup() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersClient.class, "deleteSharedIpGroup", int.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
-
- assertRequestLineEquals(request, "DELETE https://lon.servers.api.rackspacecloud.com/v1.0/10001786/shared_ip_groups/2 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ReturnTrueIf2xx.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, FalseOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testListAddresses() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersClient.class, "getAddresses", int.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
-
- assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/ips?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testListPublicAddresses() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersClient.class, "listPublicAddresses", int.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
-
- assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/ips/public?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testListPrivateAddresses() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersClient.class, "listPrivateAddresses", int.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
-
- assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/ips/private?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testListBackupSchedule() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersClient.class, "getBackupSchedule", int.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
-
- assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/backup_schedule?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
-
- checkFilters(request);
- }
-
- public void testCreateImageWithIpGroup() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersClient.class, "createImageFromServer", String.class, int.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("ralphie", 2));
-
- assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, "{\"image\":{\"serverId\":2,\"name\":\"ralphie\"}}", MediaType.APPLICATION_JSON,
- false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
-
- }
-
- public void testRebuildServer() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersClient.class, "rebuildServer", int.class,
- RebuildServerOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(3));
-
- assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/3/action?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, "{\"rebuild\":{}}", MediaType.APPLICATION_JSON, false);
-
- assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testRebuildServerWithImage() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersClient.class, "rebuildServer", int.class,
- RebuildServerOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(3, withImage(2)));
-
- assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/3/action?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, "{\"rebuild\":{\"imageId\":2}}", MediaType.APPLICATION_JSON, false);
-
- assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testReboot() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersClient.class, "rebootServer", int.class, RebootType.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2, RebootType.HARD));
-
- assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/action?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, "{\"reboot\":{\"type\":\"HARD\"}}", MediaType.APPLICATION_JSON, false);
-
- assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testResize() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersClient.class, "resizeServer", int.class, int.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2, 3));
-
- assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/action?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, "{\"resize\":{\"flavorId\":3}}", MediaType.APPLICATION_JSON, false);
-
- assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
-
- }
-
- public void testConfirmResize() throws IOException, IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersClient.class, "confirmResizeServer", int.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
-
- assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/action?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, "{\"confirmResize\":null}", MediaType.APPLICATION_JSON, false);
-
- assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testRevertResize() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersClient.class, "revertResizeServer", int.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
-
- assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/action?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, "{\"revertResize\":null}", MediaType.APPLICATION_JSON, false);
-
- assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- @Override
- protected void checkFilters(HttpRequest request) {
- assertEquals(request.getFilters().size(), 2);
- assertEquals(request.getFilters().get(0).getClass(), AuthenticateRequest.class);
- assertEquals(request.getFilters().get(1).getClass(), AddTimestampQuery.class);
-
- }
-
- @Override
- protected Module createModule() {
- return new TestCloudServersHttpApiModule();
- }
-
- @ConfiguresHttpApi
- protected static class TestCloudServersHttpApiModule extends CloudServersHttpApiModule {
-
- @Provides
- @Singleton
- GetAuth provideGetAuth() {
- return new GetAuth(null) {
- @Override
- public Auth load(Credentials in) {
- return new ParseAuthTest().expected();
- }
- };
- }
-
- }
-
- protected String provider = "cloudservers";
-
- @Override
- protected ApiMetadata createApiMetadata() {
- return new CloudServersApiMetadata();
- }
-
- @Override
- protected Properties setupProperties() {
- Properties overrides = new Properties();
- overrides.setProperty(PROPERTY_REGIONS, "US");
- overrides.setProperty(PROPERTY_API_VERSION, "1");
- overrides.setProperty(provider + ".endpoint", "https://auth");
- return overrides;
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/162226b8/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersExpectTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersExpectTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersExpectTest.java
deleted file mode 100644
index 6a15cac..0000000
--- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersExpectTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.cloudservers;
-
-import java.net.URI;
-
-import org.jclouds.cloudservers.internal.BaseCloudServersRestClientExpectTest;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpResponse;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableMultimap;
-
-@Test(groups = "unit", testName = "CloudServersExpectTest")
-public class CloudServersExpectTest extends BaseCloudServersRestClientExpectTest {
-
- public void deleteImageReturnsTrueOn200AndFalseOn404() {
-
- HttpRequest deleteImage11 = HttpRequest.builder().method("DELETE").endpoint(
- URI.create("https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images/11?now=1257695648897")).headers(
- ImmutableMultimap.<String, String> builder()
- .put("X-Auth-Token", authToken).build()).build();
-
- HttpResponse imageDeleted = HttpResponse.builder().statusCode(204).message("HTTP/1.1 204 No Content").build();
-
- CloudServersClient clientWhenImageExists = requestsSendResponses(initialAuth, responseWithAuth, deleteImage11, imageDeleted);
- assert clientWhenImageExists.deleteImage(11);
-
- HttpResponse imageNotFound = HttpResponse.builder().statusCode(404).message("HTTP/1.1 404 Not Found").build();
-
- CloudServersClient clientWhenImageDoesntExist = requestsSendResponses(initialAuth, responseWithAuth, deleteImage11, imageNotFound);
- assert !clientWhenImageDoesntExist.deleteImage(11);
-
- }
-
-}