http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a6044372/digitalocean2/src/test/java/org/jclouds/digitalocean2/features/KeyApiLiveTest.java ---------------------------------------------------------------------- diff --git a/digitalocean2/src/test/java/org/jclouds/digitalocean2/features/KeyApiLiveTest.java b/digitalocean2/src/test/java/org/jclouds/digitalocean2/features/KeyApiLiveTest.java deleted file mode 100644 index e0ec1c9..0000000 --- a/digitalocean2/src/test/java/org/jclouds/digitalocean2/features/KeyApiLiveTest.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.digitalocean2.features; - -import static org.jclouds.digitalocean2.domain.options.ListOptions.Builder.page; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; - -import java.io.IOException; - -import org.jclouds.digitalocean2.domain.Key; -import org.jclouds.digitalocean2.internal.BaseDigitalOcean2ApiLiveTest; -import org.testng.annotations.AfterClass; -import org.testng.annotations.Test; - -import com.google.common.base.Charsets; -import com.google.common.base.Throwables; -import com.google.common.collect.FluentIterable; -import com.google.common.io.Resources; - -@Test(groups = "live", testName = "KeyApiLiveTest") -public class KeyApiLiveTest extends BaseDigitalOcean2ApiLiveTest { - - private Key dsa; - private Key ecdsa; - - public void testCreateKey() { - dsa = api().create("jclouds-test-dsa", loadKey("/ssh-dsa.pub")); - ecdsa = api().create("jclouds-test-ecdsa", loadKey("/ssh-ecdsa.pub")); - - assertEquals(dsa.name(), "jclouds-test-dsa"); - assertEquals(ecdsa.name(), "jclouds-test-ecdsa"); - } - - @Test(dependsOnMethods = "testCreateKey") - public void testListKeys() { - FluentIterable<Key> keys = api().list().concat(); - assertTrue(keys.size() >= 2, "At least the two created keys must exist"); - } - - @Test(dependsOnMethods = "testCreateKey") - public void testListKeysOnePAge() { - FluentIterable<Key> keys = api().list(page(1)); - assertTrue(keys.size() >= 2, "At least the two created keys must exist"); - } - - @Test(dependsOnMethods = "testCreateKey") - public void testGetKey() { - assertEquals(api().get(dsa.id()).fingerprint(), dsa.fingerprint()); - assertEquals(api().get(ecdsa.fingerprint()).id(), ecdsa.id()); - } - - @Test(dependsOnMethods = "testCreateKey") - public void testUpdateKey() { - api().update(dsa.id(), "jclouds-test-dsa-updated"); - assertEquals(api().get(dsa.id()).name(), "jclouds-test-dsa-updated"); - } - - @AfterClass(alwaysRun = true) - public void testDeleteKey() { - if (dsa != null) { - api().delete(dsa.id()); - FluentIterable<Key> keys = api().list().concat(); - assertFalse(keys.contains(dsa), "dsa key must not be present in list"); - } - if (ecdsa != null) { - api().delete(ecdsa.fingerprint()); - FluentIterable<Key> keys = api().list().concat(); - assertFalse(keys.contains(ecdsa), "dsa key must not be present in list"); - } - } - - private String loadKey(String resourceName) { - try { - return Resources.toString(getClass().getResource(resourceName), Charsets.UTF_8); - } catch (IOException e) { - throw Throwables.propagate(e); - } - } - - private KeyApi api() { - return api.keyApi(); - } -}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a6044372/digitalocean2/src/test/java/org/jclouds/digitalocean2/features/KeyApiMockTest.java ---------------------------------------------------------------------- diff --git a/digitalocean2/src/test/java/org/jclouds/digitalocean2/features/KeyApiMockTest.java b/digitalocean2/src/test/java/org/jclouds/digitalocean2/features/KeyApiMockTest.java deleted file mode 100644 index 2f9d5d3..0000000 --- a/digitalocean2/src/test/java/org/jclouds/digitalocean2/features/KeyApiMockTest.java +++ /dev/null @@ -1,203 +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.digitalocean2.features; - -import static com.google.common.collect.Iterables.isEmpty; -import static com.google.common.collect.Iterables.size; -import static org.jclouds.digitalocean2.domain.options.ListOptions.Builder.page; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; - -import java.util.Map; - -import org.jclouds.digitalocean2.domain.Key; -import org.jclouds.digitalocean2.internal.BaseDigitalOcean2ApiMockTest; -import org.testng.annotations.Test; - -import com.google.common.reflect.TypeToken; - -@Test(groups = "unit", testName = "KeyApiMockTest", singleThreaded = true) -public class KeyApiMockTest extends BaseDigitalOcean2ApiMockTest { - - public void testListKeys() throws InterruptedException { - server.enqueue(jsonResponse("/keys-first.json")); - server.enqueue(jsonResponse("/keys-last.json")); - - Iterable<Key> keys = api.keyApi().list().concat(); - - assertEquals(size(keys), 7); // Force the PagedIterable to advance - assertEquals(server.getRequestCount(), 2); - - assertSent(server, "GET", "/account/keys"); - assertSent(server, "GET", "/account/keys?page=2&per_page=5"); - } - - public void testListKeysReturns404() throws InterruptedException { - server.enqueue(response404()); - - Iterable<Key> keys = api.keyApi().list().concat(); - - assertTrue(isEmpty(keys)); - - assertEquals(server.getRequestCount(), 1); - assertSent(server, "GET", "/account/keys"); - } - - public void testListKeysWithOptions() throws InterruptedException { - server.enqueue(jsonResponse("/keys-first.json")); - - Iterable<Key> keys = api.keyApi().list(page(1).perPage(5)); - - assertEquals(size(keys), 5); - assertEquals(server.getRequestCount(), 1); - - assertSent(server, "GET", "/account/keys?page=1&per_page=5"); - } - - public void testListKeysWithOptionsReturns404() throws InterruptedException { - server.enqueue(response404()); - - Iterable<Key> keys = api.keyApi().list(page(1).perPage(5)); - - assertTrue(isEmpty(keys)); - - assertEquals(server.getRequestCount(), 1); - assertSent(server, "GET", "/account/keys?page=1&per_page=5"); - } - - public void testCreateKey() throws InterruptedException { - server.enqueue(jsonResponse("/key.json").setStatus("HTTP/1.1 201 Created")); - - String dsa = stringFromResource("/ssh-dsa.pub"); - - Key key = api.keyApi().create("foo", dsa); - - assertEquals(key, keyFromResource("/key.json")); - - assertEquals(server.getRequestCount(), 1); - assertSent(server, "POST", "/account/keys", String.format("{\"name\":\"foo\", \"public_key\":\"%s\"}", dsa)); - } - - public void testGetKey() throws InterruptedException { - server.enqueue(jsonResponse("/key.json")); - - Key key = api.keyApi().get(1); - - assertEquals(key, keyFromResource("/key.json")); - - assertEquals(server.getRequestCount(), 1); - assertSent(server, "GET", "/account/keys/1"); - } - - public void testGetKeyReturns404() throws InterruptedException { - server.enqueue(response404()); - - Key key = api.keyApi().get(1); - - assertNull(key); - - assertEquals(server.getRequestCount(), 1); - assertSent(server, "GET", "/account/keys/1"); - } - - public void testGetKeyUsingFingerprint() throws InterruptedException { - server.enqueue(jsonResponse("/key.json")); - - Key key = api.keyApi().get("1a:cc:9b:88:c8:4f:b8:77:96:15:d2:0c:95:86:ff:90"); - - assertEquals(key, keyFromResource("/key.json")); - - assertEquals(server.getRequestCount(), 1); - assertSent(server, "GET", "/account/keys/1a:cc:9b:88:c8:4f:b8:77:96:15:d2:0c:95:86:ff:90"); - } - - public void testGetKeyUsingFingerprintReturns404() throws InterruptedException { - server.enqueue(response404()); - - Key key = api.keyApi().get("1a:cc:9b:88:c8:4f:b8:77:96:15:d2:0c:95:86:ff:90"); - - assertNull(key); - - assertEquals(server.getRequestCount(), 1); - assertSent(server, "GET", "/account/keys/1a:cc:9b:88:c8:4f:b8:77:96:15:d2:0c:95:86:ff:90"); - } - - public void testUpdateKey() throws InterruptedException { - server.enqueue(jsonResponse("/key.json")); - - Key key = api.keyApi().update(1, "foo"); - - assertEquals(key, keyFromResource("/key.json")); - - assertEquals(server.getRequestCount(), 1); - assertSent(server, "PUT", "/account/keys/1", "{\"name\":\"foo\"}"); - } - - public void testUpdateKeyUsingFingerprint() throws InterruptedException { - server.enqueue(jsonResponse("/key.json")); - - Key key = api.keyApi().update("1a:cc:9b:88:c8:4f:b8:77:96:15:d2:0c:95:86:ff:90", "foo"); - - assertEquals(key, keyFromResource("/key.json")); - - assertEquals(server.getRequestCount(), 1); - assertSent(server, "PUT", "/account/keys/1a:cc:9b:88:c8:4f:b8:77:96:15:d2:0c:95:86:ff:90", "{\"name\":\"foo\"}"); - } - - public void testDeleteKey() throws InterruptedException { - server.enqueue(response204()); - - api.keyApi().delete(1); - - assertEquals(server.getRequestCount(), 1); - assertSent(server, "DELETE", "/account/keys/1"); - } - - public void testDeleteKeyReturns404() throws InterruptedException { - server.enqueue(response404()); - - api.keyApi().delete(1); - - assertEquals(server.getRequestCount(), 1); - assertSent(server, "DELETE", "/account/keys/1"); - } - - public void testDeleteKeyUsingFingerprint() throws InterruptedException { - server.enqueue(response204()); - - api.keyApi().delete("1a:cc:9b:88:c8:4f:b8:77:96:15:d2:0c:95:86:ff:90"); - - assertEquals(server.getRequestCount(), 1); - assertSent(server, "DELETE", "/account/keys/1a:cc:9b:88:c8:4f:b8:77:96:15:d2:0c:95:86:ff:90"); - } - - public void testDeleteKeyUsingfingerprintReturns404() throws InterruptedException { - server.enqueue(response404()); - - api.keyApi().delete("1a:cc:9b:88:c8:4f:b8:77:96:15:d2:0c:95:86:ff:90"); - - assertEquals(server.getRequestCount(), 1); - assertSent(server, "DELETE", "/account/keys/1a:cc:9b:88:c8:4f:b8:77:96:15:d2:0c:95:86:ff:90"); - } - - private Key keyFromResource(String resource) { - return onlyObjectFromResource(resource, new TypeToken<Map<String, Key>>() { - private static final long serialVersionUID = 1L; - }); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a6044372/digitalocean2/src/test/java/org/jclouds/digitalocean2/features/RegionApiLiveTest.java ---------------------------------------------------------------------- diff --git a/digitalocean2/src/test/java/org/jclouds/digitalocean2/features/RegionApiLiveTest.java b/digitalocean2/src/test/java/org/jclouds/digitalocean2/features/RegionApiLiveTest.java deleted file mode 100644 index 73c7451..0000000 --- a/digitalocean2/src/test/java/org/jclouds/digitalocean2/features/RegionApiLiveTest.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.digitalocean2.features; - -import static org.testng.Assert.assertTrue; -import static org.jclouds.digitalocean2.domain.options.ListOptions.Builder.page; - -import java.util.concurrent.atomic.AtomicInteger; - -import org.jclouds.digitalocean2.domain.Region; -import org.jclouds.digitalocean2.internal.BaseDigitalOcean2ApiLiveTest; -import org.testng.annotations.Test; -import org.testng.util.Strings; - -import com.google.common.base.Predicate; - -@Test(groups = "live", testName = "RegionApiLiveTest") -public class RegionApiLiveTest extends BaseDigitalOcean2ApiLiveTest { - - public void testListRegions() { - final AtomicInteger found = new AtomicInteger(0); - // DigitalOcean return 25 records per page by default. Inspect at most 2 pages - assertTrue(api().list().concat().limit(50).allMatch(new Predicate<Region>() { - @Override - public boolean apply(Region input) { - found.incrementAndGet(); - return !Strings.isNullOrEmpty(input.slug()); - } - }), "All regions must have the 'slug' field populated"); - assertTrue(found.get() > 0, "Expected some regions to be returned"); - } - - public void testListRegionsOnePage() { - final AtomicInteger found = new AtomicInteger(0); - assertTrue(api().list(page(1)).allMatch(new Predicate<Region>() { - @Override - public boolean apply(Region input) { - found.incrementAndGet(); - return !Strings.isNullOrEmpty(input.slug()); - } - }), "All regions must have the 'slug' field populated"); - assertTrue(found.get() > 0, "Expected some regions to be returned"); - } - - private RegionApi api() { - return api.regionApi(); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a6044372/digitalocean2/src/test/java/org/jclouds/digitalocean2/features/RegionApiMockTest.java ---------------------------------------------------------------------- diff --git a/digitalocean2/src/test/java/org/jclouds/digitalocean2/features/RegionApiMockTest.java b/digitalocean2/src/test/java/org/jclouds/digitalocean2/features/RegionApiMockTest.java deleted file mode 100644 index 8c8c326..0000000 --- a/digitalocean2/src/test/java/org/jclouds/digitalocean2/features/RegionApiMockTest.java +++ /dev/null @@ -1,77 +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.digitalocean2.features; - -import static com.google.common.collect.Iterables.isEmpty; -import static com.google.common.collect.Iterables.size; -import static org.jclouds.digitalocean2.domain.options.ListOptions.Builder.page; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; - -import org.jclouds.digitalocean2.domain.Region; -import org.jclouds.digitalocean2.internal.BaseDigitalOcean2ApiMockTest; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "RegionApiMockTest", singleThreaded = true) -public class RegionApiMockTest extends BaseDigitalOcean2ApiMockTest { - - public void testListRegions() throws InterruptedException { - server.enqueue(jsonResponse("/regions-first.json")); - server.enqueue(jsonResponse("/regions-last.json")); - - Iterable<Region> regions = api.regionApi().list().concat(); - - assertEquals(size(regions), 10); // Force the PagedIterable to advance - assertEquals(server.getRequestCount(), 2); - - assertSent(server, "GET", "/regions"); - assertSent(server, "GET", "/regions?page=2&per_page=5"); - } - - public void testListRegionsReturns404() throws InterruptedException { - server.enqueue(response404()); - - Iterable<Region> regions = api.regionApi().list().concat(); - - assertTrue(isEmpty(regions)); - - assertEquals(server.getRequestCount(), 1); - assertSent(server, "GET", "/regions"); - } - - public void testListRegionsWithOptions() throws InterruptedException { - server.enqueue(jsonResponse("/regions-first.json")); - - Iterable<Region> regions = api.regionApi().list(page(1).perPage(5)); - - assertEquals(size(regions), 5); - assertEquals(server.getRequestCount(), 1); - - assertSent(server, "GET", "/regions?page=1&per_page=5"); - } - - public void testListRegionsWithOptionsReturns404() throws InterruptedException { - server.enqueue(response404()); - - Iterable<Region> regions = api.regionApi().list(page(1).perPage(5)); - - assertTrue(isEmpty(regions)); - - assertEquals(server.getRequestCount(), 1); - assertSent(server, "GET", "/regions?page=1&per_page=5"); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a6044372/digitalocean2/src/test/java/org/jclouds/digitalocean2/features/SizeApiLiveTest.java ---------------------------------------------------------------------- diff --git a/digitalocean2/src/test/java/org/jclouds/digitalocean2/features/SizeApiLiveTest.java b/digitalocean2/src/test/java/org/jclouds/digitalocean2/features/SizeApiLiveTest.java deleted file mode 100644 index a9a8566..0000000 --- a/digitalocean2/src/test/java/org/jclouds/digitalocean2/features/SizeApiLiveTest.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.digitalocean2.features; - -import static org.jclouds.digitalocean2.domain.options.ListOptions.Builder.page; -import static org.testng.Assert.assertTrue; - -import java.util.concurrent.atomic.AtomicInteger; - -import org.jclouds.digitalocean2.domain.Size; -import org.jclouds.digitalocean2.internal.BaseDigitalOcean2ApiLiveTest; -import org.testng.annotations.Test; -import org.testng.util.Strings; - -import com.google.common.base.Predicate; - -@Test(groups = "live", testName = "SizeApiLiveTest") -public class SizeApiLiveTest extends BaseDigitalOcean2ApiLiveTest { - - public void testListSizes() { - final AtomicInteger found = new AtomicInteger(0); - // DigitalOcean return 25 records per page by default. Inspect at most 2 pages - assertTrue(api().list().concat().limit(50).allMatch(new Predicate<Size>() { - @Override - public boolean apply(Size input) { - found.incrementAndGet(); - return !Strings.isNullOrEmpty(input.slug()); - } - }), "All sizes must have the 'slug' field populated"); - assertTrue(found.get() > 0, "Expected some sizes to be returned"); - } - - public void testListSizesOnePage() { - final AtomicInteger found = new AtomicInteger(0); - assertTrue(api().list(page(1)).allMatch(new Predicate<Size>() { - @Override - public boolean apply(Size input) { - found.incrementAndGet(); - return !Strings.isNullOrEmpty(input.slug()); - } - }), "All sizes must have the 'slug' field populated"); - assertTrue(found.get() > 0, "Expected some sizes to be returned"); - } - - private SizeApi api() { - return api.sizeApi(); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a6044372/digitalocean2/src/test/java/org/jclouds/digitalocean2/features/SizeApiMockTest.java ---------------------------------------------------------------------- diff --git a/digitalocean2/src/test/java/org/jclouds/digitalocean2/features/SizeApiMockTest.java b/digitalocean2/src/test/java/org/jclouds/digitalocean2/features/SizeApiMockTest.java deleted file mode 100644 index 7403518..0000000 --- a/digitalocean2/src/test/java/org/jclouds/digitalocean2/features/SizeApiMockTest.java +++ /dev/null @@ -1,77 +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.digitalocean2.features; - -import static com.google.common.collect.Iterables.isEmpty; -import static com.google.common.collect.Iterables.size; -import static org.jclouds.digitalocean2.domain.options.ListOptions.Builder.page; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; - -import org.jclouds.digitalocean2.domain.Size; -import org.jclouds.digitalocean2.internal.BaseDigitalOcean2ApiMockTest; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "SizeApiMockTest", singleThreaded = true) -public class SizeApiMockTest extends BaseDigitalOcean2ApiMockTest { - - public void testListSizes() throws InterruptedException { - server.enqueue(jsonResponse("/sizes-first.json")); - server.enqueue(jsonResponse("/sizes-last.json")); - - Iterable<Size> sizes = api.sizeApi().list().concat(); - - assertEquals(size(sizes), 9); // Force the PagedIterable to advance - assertEquals(server.getRequestCount(), 2); - - assertSent(server, "GET", "/sizes"); - assertSent(server, "GET", "/sizes?page=2&per_page=5"); - } - - public void testListSizesReturns404() throws InterruptedException { - server.enqueue(response404()); - - Iterable<Size> sizes = api.sizeApi().list().concat(); - - assertTrue(isEmpty(sizes)); - - assertEquals(server.getRequestCount(), 1); - assertSent(server, "GET", "/sizes"); - } - - public void testListSizesWithOptions() throws InterruptedException { - server.enqueue(jsonResponse("/sizes-first.json")); - - Iterable<Size> sizes = api.sizeApi().list(page(1).perPage(5)); - - assertEquals(size(sizes), 5); - assertEquals(server.getRequestCount(), 1); - - assertSent(server, "GET", "/sizes?page=1&per_page=5"); - } - - public void testListSizesWithOptionsReturns404() throws InterruptedException { - server.enqueue(response404()); - - Iterable<Size> sizes = api.sizeApi().list(page(1).perPage(5)); - - assertTrue(isEmpty(sizes)); - - assertEquals(server.getRequestCount(), 1); - assertSent(server, "GET", "/sizes?page=1&per_page=5"); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a6044372/digitalocean2/src/test/java/org/jclouds/digitalocean2/functions/LinkToImageListOptionsTest.java ---------------------------------------------------------------------- diff --git a/digitalocean2/src/test/java/org/jclouds/digitalocean2/functions/LinkToImageListOptionsTest.java b/digitalocean2/src/test/java/org/jclouds/digitalocean2/functions/LinkToImageListOptionsTest.java deleted file mode 100644 index 22985fa..0000000 --- a/digitalocean2/src/test/java/org/jclouds/digitalocean2/functions/LinkToImageListOptionsTest.java +++ /dev/null @@ -1,65 +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.digitalocean2.functions; - -import static com.google.common.collect.Iterables.getOnlyElement; -import static org.jclouds.digitalocean2.domain.options.ImageListOptions.PRIVATE_PARAM; -import static org.jclouds.digitalocean2.domain.options.ImageListOptions.TYPE_PARAM; -import static org.jclouds.digitalocean2.domain.options.ListOptions.PAGE_PARAM; -import static org.jclouds.digitalocean2.domain.options.ListOptions.PER_PAGE_PARAM; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; - -import java.net.URI; - -import org.jclouds.digitalocean2.domain.options.ImageListOptions; -import org.testng.annotations.Test; - -import com.google.common.collect.Multimap; - -@Test(groups = "unit", testName = "LinkToImageListOptionsTest") -public class LinkToImageListOptionsTest { - - public void testNoOptions() { - LinkToImageListOptions function = new LinkToImageListOptions(); - - ImageListOptions options = function.apply(URI.create("https://api.digitalocean.com/v2/images")); - assertNotNull(options); - - Multimap<String, String> params = options.buildQueryParameters(); - assertFalse(params.containsKey(PAGE_PARAM)); - assertFalse(params.containsKey(PER_PAGE_PARAM)); - assertFalse(params.containsKey(TYPE_PARAM)); - assertFalse(params.containsKey(PRIVATE_PARAM)); - } - - public void testWithOptions() { - LinkToImageListOptions function = new LinkToImageListOptions(); - - ImageListOptions options = function.apply(URI - .create("https://api.digitalocean.com/v2/images?page=1&per_page=5&type=distribution&private=true")); - assertNotNull(options); - - Multimap<String, String> params = options.buildQueryParameters(); - assertEquals(getOnlyElement(params.get(PAGE_PARAM)), "1"); - assertEquals(getOnlyElement(params.get(PER_PAGE_PARAM)), "5"); - assertEquals(getOnlyElement(params.get(TYPE_PARAM)), "distribution"); - assertEquals(getOnlyElement(params.get(PRIVATE_PARAM)), "true"); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a6044372/digitalocean2/src/test/java/org/jclouds/digitalocean2/functions/LinkToListOptionsTest.java ---------------------------------------------------------------------- diff --git a/digitalocean2/src/test/java/org/jclouds/digitalocean2/functions/LinkToListOptionsTest.java b/digitalocean2/src/test/java/org/jclouds/digitalocean2/functions/LinkToListOptionsTest.java deleted file mode 100644 index 2bb3544..0000000 --- a/digitalocean2/src/test/java/org/jclouds/digitalocean2/functions/LinkToListOptionsTest.java +++ /dev/null @@ -1,58 +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.digitalocean2.functions; - -import static com.google.common.collect.Iterables.getOnlyElement; -import static org.jclouds.digitalocean2.domain.options.ListOptions.PAGE_PARAM; -import static org.jclouds.digitalocean2.domain.options.ListOptions.PER_PAGE_PARAM; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; - -import java.net.URI; - -import org.jclouds.digitalocean2.domain.options.ListOptions; -import org.testng.annotations.Test; - -import com.google.common.collect.Multimap; - -@Test(groups = "unit", testName = "LinkToListOptionsTest") -public class LinkToListOptionsTest { - - public void testNoOptions() { - LinkToListOptions function = new LinkToListOptions(); - - ListOptions options = function.apply(URI.create("https://api.digitalocean.com/v2/actions")); - assertNotNull(options); - - Multimap<String, String> params = options.buildQueryParameters(); - assertFalse(params.containsKey(PAGE_PARAM)); - assertFalse(params.containsKey(PER_PAGE_PARAM)); - } - - public void testWithOptions() { - LinkToListOptions function = new LinkToListOptions(); - - ListOptions options = function.apply(URI.create("https://api.digitalocean.com/v2/actions?page=2&per_page=5")); - assertNotNull(options); - - Multimap<String, String> params = options.buildQueryParameters(); - assertEquals(getOnlyElement(params.get(PAGE_PARAM)), "2"); - assertEquals(getOnlyElement(params.get(PER_PAGE_PARAM)), "5"); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a6044372/digitalocean2/src/test/java/org/jclouds/digitalocean2/handlers/RateLimitRetryHandlerTest.java ---------------------------------------------------------------------- diff --git a/digitalocean2/src/test/java/org/jclouds/digitalocean2/handlers/RateLimitRetryHandlerTest.java b/digitalocean2/src/test/java/org/jclouds/digitalocean2/handlers/RateLimitRetryHandlerTest.java deleted file mode 100644 index 6c7c87f..0000000 --- a/digitalocean2/src/test/java/org/jclouds/digitalocean2/handlers/RateLimitRetryHandlerTest.java +++ /dev/null @@ -1,153 +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.digitalocean2.handlers; - -import static org.jclouds.digitalocean2.handlers.RateLimitRetryHandler.RATE_LIMIT_RESET_HEADER; -import static org.jclouds.http.HttpUtils.releasePayload; -import static org.jclouds.io.Payloads.newInputStreamPayload; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; - -import java.io.ByteArrayInputStream; -import java.util.concurrent.TimeUnit; - -import org.jclouds.http.HttpCommand; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.io.Payload; -import org.testng.annotations.Test; - -import com.google.common.util.concurrent.Uninterruptibles; - -@Test(groups = "unit", testName = "RateLimitRetryHandlerTest") -public class RateLimitRetryHandlerTest { - - // Configure a safe timeout of one minute to abort the tests in case they get - // stuck - private static final long TEST_SAFE_TIMEOUT = 60000; - - private final RateLimitRetryHandler rateLimitRetryHandler = new RateLimitRetryHandler(); - - @Test(timeOut = TEST_SAFE_TIMEOUT) - public void testDoNotRetryIfNoRateLimit() { - HttpCommand command = new HttpCommand(HttpRequest.builder().method("GET").endpoint("http://localhost").build()); - HttpResponse response = HttpResponse.builder().statusCode(450).build(); - - assertFalse(rateLimitRetryHandler.shouldRetryRequest(command, response)); - } - - @Test(timeOut = TEST_SAFE_TIMEOUT) - public void testDoNotRetryIfNotReplayable() { - // InputStream payloads are not replayable - Payload payload = newInputStreamPayload(new ByteArrayInputStream(new byte[0])); - HttpCommand command = new HttpCommand(HttpRequest.builder().method("GET").endpoint("http://localhost") - .payload(payload).build()); - HttpResponse response = HttpResponse.builder().statusCode(429).build(); - - try { - assertFalse(rateLimitRetryHandler.shouldRetryRequest(command, response)); - } finally { - releasePayload(command.getCurrentRequest()); - } - } - - @Test(timeOut = TEST_SAFE_TIMEOUT) - public void testDoNotRetryIfNoRateLimitResetHeader() { - HttpCommand command = new HttpCommand(HttpRequest.builder().method("GET").endpoint("http://localhost").build()); - HttpResponse response = HttpResponse.builder().statusCode(429).build(); - - assertFalse(rateLimitRetryHandler.shouldRetryRequest(command, response)); - } - - @Test(timeOut = TEST_SAFE_TIMEOUT) - public void testDoNotRetryIfTooMuchWait() { - // 5 minutes Unix epoch timestamp - long rateLimitResetEpoch = (System.currentTimeMillis() + 300000) / 1000; - HttpCommand command = new HttpCommand(HttpRequest.builder().method("GET").endpoint("http://localhost").build()); - HttpResponse response = HttpResponse.builder().statusCode(429) - .addHeader(RATE_LIMIT_RESET_HEADER, String.valueOf(rateLimitResetEpoch)).build(); - - assertFalse(rateLimitRetryHandler.shouldRetryRequest(command, response)); - } - - @Test(timeOut = TEST_SAFE_TIMEOUT) - public void testRequestIsDelayed() { - // 5 seconds Unix epoch timestamp - long rateLimitResetEpoch = (System.currentTimeMillis() + 5000) / 1000; - HttpCommand command = new HttpCommand(HttpRequest.builder().method("GET").endpoint("http://localhost").build()); - HttpResponse response = HttpResponse.builder().statusCode(429) - .addHeader(RATE_LIMIT_RESET_HEADER, String.valueOf(rateLimitResetEpoch)).build(); - - long start = System.currentTimeMillis(); - - assertTrue(rateLimitRetryHandler.shouldRetryRequest(command, response)); - // Should have blocked the amount of time configured in the header. Use a - // smaller value to compensate the time it takes to reach the code that - // computes the amount of time to wait. - assertTrue(System.currentTimeMillis() - start > 2500); - } - - @Test(timeOut = TEST_SAFE_TIMEOUT) - public void testDoNotRetryIfRequestIsAborted() throws Exception { - // 10 seconds Unix epoch timestamp - long rateLimitResetEpoch = (System.currentTimeMillis() + 10000) / 1000; - final HttpCommand command = new HttpCommand(HttpRequest.builder().method("GET").endpoint("http://localhost") - .build()); - final HttpResponse response = HttpResponse.builder().statusCode(429) - .addHeader(RATE_LIMIT_RESET_HEADER, String.valueOf(rateLimitResetEpoch)).build(); - - final Thread requestThread = Thread.currentThread(); - Thread killer = new Thread() { - @Override - public void run() { - Uninterruptibles.sleepUninterruptibly(2, TimeUnit.SECONDS); - requestThread.interrupt(); - } - }; - - // Start the killer thread that will abort the rate limit wait - killer.start(); - assertFalse(rateLimitRetryHandler.shouldRetryRequest(command, response)); - } - - @Test(timeOut = TEST_SAFE_TIMEOUT) - public void testIncrementsFailureCount() { - HttpCommand command = new HttpCommand(HttpRequest.builder().method("GET").endpoint("http://localhost").build()); - HttpResponse response = HttpResponse.builder().statusCode(429).build(); - - rateLimitRetryHandler.shouldRetryRequest(command, response); - assertEquals(command.getFailureCount(), 1); - - rateLimitRetryHandler.shouldRetryRequest(command, response); - assertEquals(command.getFailureCount(), 2); - - rateLimitRetryHandler.shouldRetryRequest(command, response); - assertEquals(command.getFailureCount(), 3); - } - - @Test(timeOut = TEST_SAFE_TIMEOUT) - public void testDisallowExcessiveRetries() { - HttpCommand command = new HttpCommand(HttpRequest.builder().method("GET").endpoint("http://localhost").build()); - HttpResponse response = HttpResponse.builder().statusCode(429).addHeader(RATE_LIMIT_RESET_HEADER, "0").build(); - - for (int i = 0; i < 5; i++) { - assertTrue(rateLimitRetryHandler.shouldRetryRequest(command, response)); - } - assertFalse(rateLimitRetryHandler.shouldRetryRequest(command, response)); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a6044372/digitalocean2/src/test/java/org/jclouds/digitalocean2/internal/BaseDigitalOcean2ApiLiveTest.java ---------------------------------------------------------------------- diff --git a/digitalocean2/src/test/java/org/jclouds/digitalocean2/internal/BaseDigitalOcean2ApiLiveTest.java b/digitalocean2/src/test/java/org/jclouds/digitalocean2/internal/BaseDigitalOcean2ApiLiveTest.java deleted file mode 100644 index ee5bb55..0000000 --- a/digitalocean2/src/test/java/org/jclouds/digitalocean2/internal/BaseDigitalOcean2ApiLiveTest.java +++ /dev/null @@ -1,140 +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.digitalocean2.internal; - -import static com.google.common.base.Preconditions.checkState; -import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_RUNNING; -import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_SUSPENDED; -import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_TERMINATED; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; -import static org.testng.util.Strings.isNullOrEmpty; - -import java.util.Properties; - -import org.jclouds.apis.BaseApiLiveTest; -import org.jclouds.compute.config.ComputeServiceProperties; -import org.jclouds.digitalocean2.DigitalOcean2Api; -import org.jclouds.digitalocean2.config.DigitalOcean2RateLimitModule; -import org.jclouds.digitalocean2.domain.Action; -import org.jclouds.digitalocean2.domain.Image; -import org.jclouds.digitalocean2.domain.Region; -import org.jclouds.digitalocean2.domain.Size; - -import com.google.common.base.Predicate; -import com.google.common.collect.ComparisonChain; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Ordering; -import com.google.inject.Injector; -import com.google.inject.Key; -import com.google.inject.Module; -import com.google.inject.TypeLiteral; -import com.google.inject.name.Names; - -public class BaseDigitalOcean2ApiLiveTest extends BaseApiLiveTest<DigitalOcean2Api> { - - private Predicate<Integer> actionCompleted; - private Predicate<Integer> nodeTerminated; - private Predicate<Integer> nodeStopped; - private Predicate<Integer> nodeRunning; - - public BaseDigitalOcean2ApiLiveTest() { - provider = "digitalocean2"; - } - - @Override protected Properties setupProperties() { - Properties props = super.setupProperties(); - props.put(ComputeServiceProperties.POLL_INITIAL_PERIOD, 1000); - props.put(ComputeServiceProperties.POLL_MAX_PERIOD, 10000); - return props; - } - - @Override protected DigitalOcean2Api create(Properties props, Iterable<Module> modules) { - Injector injector = newBuilder().modules(modules).overrides(props).buildInjector(); - actionCompleted = injector.getInstance(Key.get(new TypeLiteral<Predicate<Integer>>(){})); - nodeTerminated = injector.getInstance(Key.get(new TypeLiteral<Predicate<Integer>>(){}, - Names.named(TIMEOUT_NODE_TERMINATED))); - nodeStopped = injector.getInstance(Key.get(new TypeLiteral<Predicate<Integer>>(){}, - Names.named(TIMEOUT_NODE_SUSPENDED))); - nodeRunning = injector.getInstance(Key.get(new TypeLiteral<Predicate<Integer>>(){}, - Names.named(TIMEOUT_NODE_RUNNING))); - return injector.getInstance(DigitalOcean2Api.class); - } - - @Override protected Iterable<Module> setupModules() { - return ImmutableSet.<Module> builder().addAll(super.setupModules()).add(new DigitalOcean2RateLimitModule()) - .build(); - } - - protected void assertActionCompleted(int actionId) { - checkState(actionCompleted.apply(actionId), "Timeout waiting for action: %s", actionId); - Action action = api.actionApi().get(actionId); - assertEquals(action.status(), Action.Status.COMPLETED); - } - - protected void assertNodeStopped(int dropletId) { - assertTrue(nodeStopped.apply(dropletId), String.format("Droplet %s did not stop in the configured timeout", dropletId)); - } - - protected void assertNodeRunning(int dropletId) { - assertTrue(nodeRunning.apply(dropletId), String.format("Droplet %s did not start in the configured timeout", dropletId)); - } - - protected void assertNodeTerminated(int dropletId) { - assertTrue(nodeTerminated.apply(dropletId), String.format("Droplet %s was not terminated in the configured timeout", dropletId)); - } - - protected Region firstAvailableRegion() { - return api.regionApi().list().concat().firstMatch(new Predicate<Region>() { - @Override - public boolean apply(Region input) { - return input.available(); - } - }).get(); - } - - protected Size cheapestSizeInRegion(final Region region) { - return sizesByPrice().min(api.sizeApi().list().concat().filter(new Predicate<Size>() { - @Override - public boolean apply(Size input) { - return input.available() && input.regions().contains(region.slug()); - } - })); - } - - protected Image ubuntuImageInRegion(final Region region) { - return api.imageApi().list().concat().firstMatch(new Predicate<Image>() { - @Override - public boolean apply(Image input) { - return "Ubuntu".equalsIgnoreCase(input.distribution()) && !isNullOrEmpty(input.slug()) - && input.regions().contains(region.slug()); - } - }).get(); - } - - protected static Ordering<Size> sizesByPrice() { - return new Ordering<Size>() { - @Override - public int compare(Size left, Size right) { - return ComparisonChain.start() - .compare(left.priceHourly(), right.priceHourly()) - .compare(left.priceMonthly(), right.priceMonthly()) - .result(); - } - }; - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a6044372/digitalocean2/src/test/java/org/jclouds/digitalocean2/internal/BaseDigitalOcean2ApiMockTest.java ---------------------------------------------------------------------- diff --git a/digitalocean2/src/test/java/org/jclouds/digitalocean2/internal/BaseDigitalOcean2ApiMockTest.java b/digitalocean2/src/test/java/org/jclouds/digitalocean2/internal/BaseDigitalOcean2ApiMockTest.java deleted file mode 100644 index ca0c4bd..0000000 --- a/digitalocean2/src/test/java/org/jclouds/digitalocean2/internal/BaseDigitalOcean2ApiMockTest.java +++ /dev/null @@ -1,142 +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.digitalocean2.internal; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.collect.Iterables.getOnlyElement; -import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor; -import static org.testng.Assert.assertEquals; - -import java.io.IOException; -import java.util.Map; -import java.util.Properties; -import java.util.Set; - -import org.jclouds.ContextBuilder; -import org.jclouds.concurrent.config.ExecutorServiceModule; -import org.jclouds.digitalocean2.DigitalOcean2Api; -import org.jclouds.digitalocean2.DigitalOcean2ProviderMetadata; -import org.jclouds.json.Json; -import org.jclouds.rest.ApiContext; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; - -import com.google.common.base.Charsets; -import com.google.common.base.Throwables; -import com.google.common.collect.ImmutableSet; -import com.google.common.io.Resources; -import com.google.common.reflect.TypeToken; -import com.google.gson.JsonParser; -import com.google.inject.Module; -import com.squareup.okhttp.mockwebserver.MockResponse; -import com.squareup.okhttp.mockwebserver.MockWebServer; -import com.squareup.okhttp.mockwebserver.RecordedRequest; - -public class BaseDigitalOcean2ApiMockTest { - - private static final String MOCK_BEARER_TOKEN = "c5401990f0c24135e8d6b5d260603fc71696d4738da9aa04a720229a01a2521d"; - private static final String DEFAULT_ENDPOINT = new DigitalOcean2ProviderMetadata().getEndpoint(); - - private final Set<Module> modules = ImmutableSet.<Module> of(new ExecutorServiceModule(sameThreadExecutor())); - - protected MockWebServer server; - protected DigitalOcean2Api api; - private Json json; - - // So that we can ignore formatting. - private final JsonParser parser = new JsonParser(); - - @BeforeMethod - public void start() throws IOException { - server = new MockWebServer(); - server.play(); - ApiContext<DigitalOcean2Api> ctx = ContextBuilder.newBuilder("digitalocean2") - .credentials("", MOCK_BEARER_TOKEN) - .endpoint(url("")) - .modules(modules) - .overrides(overrides()) - .build(); - json = ctx.utils().injector().getInstance(Json.class); - api = ctx.getApi(); - } - - @AfterMethod(alwaysRun = true) - public void stop() throws IOException { - server.shutdown(); - api.close(); - } - - protected Properties overrides() { - return new Properties(); - } - - protected String url(String path) { - return server.getUrl(path).toString(); - } - - protected MockResponse jsonResponse(String resource) { - return new MockResponse().addHeader("Content-Type", "application/json").setBody(stringFromResource(resource)); - } - - protected MockResponse response404() { - return new MockResponse().setStatus("HTTP/1.1 404 Not Found"); - } - - protected MockResponse response204() { - return new MockResponse().setStatus("HTTP/1.1 204 No Content"); - } - - protected String stringFromResource(String resourceName) { - try { - return Resources.toString(getClass().getResource(resourceName), Charsets.UTF_8) - .replace(DEFAULT_ENDPOINT, url("")); - } catch (IOException e) { - throw Throwables.propagate(e); - } - } - - protected <T> T onlyObjectFromResource(String resourceName, TypeToken<Map<String, T>> type) { - // Assume JSON objects passed here will be in the form: { "entity": { ... } } - String text = stringFromResource(resourceName); - Map<String, T> object = json.fromJson(text, type.getType()); - checkArgument(!object.isEmpty(), "The given json does not contain any object: %s", text); - checkArgument(object.keySet().size() == 1, "The given json does not contain more than one object: %s", text); - return object.get(getOnlyElement(object.keySet())); - } - - protected <T> T objectFromResource(String resourceName, Class<T> type) { - String text = stringFromResource(resourceName); - return json.fromJson(text, type); - } - - protected RecordedRequest assertSent(MockWebServer server, String method, String path) throws InterruptedException { - RecordedRequest request = server.takeRequest(); - assertEquals(request.getMethod(), method); - assertEquals(request.getPath(), path); - assertEquals(request.getHeader("Accept"), "application/json"); - assertEquals(request.getHeader("Authorization"), "Bearer " + MOCK_BEARER_TOKEN); - return request; - } - - protected RecordedRequest assertSent(MockWebServer server, String method, String path, String json) - throws InterruptedException { - RecordedRequest request = assertSent(server, method, path); - assertEquals(request.getHeader("Content-Type"), "application/json"); - assertEquals(parser.parse(new String(request.getBody(), Charsets.UTF_8)), parser.parse(json)); - return request; - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a6044372/digitalocean2/src/test/java/org/jclouds/digitalocean2/ssh/DSAKeysTest.java ---------------------------------------------------------------------- diff --git a/digitalocean2/src/test/java/org/jclouds/digitalocean2/ssh/DSAKeysTest.java b/digitalocean2/src/test/java/org/jclouds/digitalocean2/ssh/DSAKeysTest.java deleted file mode 100644 index 91f3c96..0000000 --- a/digitalocean2/src/test/java/org/jclouds/digitalocean2/ssh/DSAKeysTest.java +++ /dev/null @@ -1,54 +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.digitalocean2.ssh; - -import static org.testng.Assert.assertEquals; - -import java.io.IOException; -import java.security.KeyFactory; -import java.security.NoSuchAlgorithmException; -import java.security.interfaces.DSAPublicKey; -import java.security.spec.DSAPublicKeySpec; -import java.security.spec.InvalidKeySpecException; - -import org.jclouds.util.Strings2; -import org.testng.annotations.Test; - -/** - * Unit tests for the {@link DSAKeys} class. - */ -@Test(groups = "unit", testName = "DSAKeysTest") -public class DSAKeysTest { - - private static final String expectedFingerPrint = "2a:54:bb:8e:ba:44:96:c8:6c:9c:40:34:3c:4d:38:e4"; - - @Test - public void testCanReadRsaAndCompareFingerprintOnPublicRSAKey() throws IOException { - String dsa = Strings2.toStringAndClose(getClass().getResourceAsStream("/ssh-dsa.pub")); - String fingerPrint = DSAKeys.fingerprintPublicKey(dsa); - assertEquals(fingerPrint, expectedFingerPrint); - } - - @Test - public void testEncodeAsOpenSSH() throws IOException, InvalidKeySpecException, NoSuchAlgorithmException { - String dsa = Strings2.toStringAndClose(getClass().getResourceAsStream("/ssh-dsa.pub")); - DSAPublicKeySpec spec = DSAKeys.publicKeySpecFromOpenSSH(dsa); - DSAPublicKey key = (DSAPublicKey) KeyFactory.getInstance("DSA").generatePublic(spec); - - assertEquals(DSAKeys.encodeAsOpenSSH(key), dsa); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a6044372/digitalocean2/src/test/java/org/jclouds/digitalocean2/ssh/ECDSAKeysTest.java ---------------------------------------------------------------------- diff --git a/digitalocean2/src/test/java/org/jclouds/digitalocean2/ssh/ECDSAKeysTest.java b/digitalocean2/src/test/java/org/jclouds/digitalocean2/ssh/ECDSAKeysTest.java deleted file mode 100644 index 2053ac7..0000000 --- a/digitalocean2/src/test/java/org/jclouds/digitalocean2/ssh/ECDSAKeysTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.digitalocean2.ssh; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; - -import java.io.IOException; -import java.security.KeyFactory; -import java.security.NoSuchAlgorithmException; -import java.security.interfaces.ECPublicKey; -import java.security.spec.ECPublicKeySpec; -import java.security.spec.InvalidKeySpecException; - -import org.jclouds.util.Strings2; -import org.testng.annotations.Test; - -/** - * Unit tests for the {@link ECDSAKeysTest} class. - */ -@Test(groups = "unit", testName = "ECDSAKeysTest") -public class ECDSAKeysTest { - - private static final String expectedFingerPrint = "0e:9f:aa:cc:3e:79:5d:1e:f9:19:58:08:dc:c4:5e:1c"; - - @Test - public void testCanReadRsaAndCompareFingerprintOnPublicECDSAKey() throws IOException { - String ecdsa = Strings2.toStringAndClose(getClass().getResourceAsStream("/ssh-ecdsa.pub")); - String fingerPrint = ECDSAKeys.fingerprintPublicKey(ecdsa); - assertEquals(fingerPrint, expectedFingerPrint); - } - - @Test - public void testEncodeAsOpenSSH() throws IOException, InvalidKeySpecException, NoSuchAlgorithmException { - String ecdsa = Strings2.toStringAndClose(getClass().getResourceAsStream("/ssh-ecdsa.pub")); - ECPublicKeySpec spec = ECDSAKeys.publicKeySpecFromOpenSSH(ecdsa); - ECPublicKey key = (ECPublicKey) KeyFactory.getInstance("EC").generatePublic(spec); - - assertTrue(ecdsa.startsWith(ECDSAKeys.encodeAsOpenSSH(key))); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a6044372/digitalocean2/src/test/resources/action.json ---------------------------------------------------------------------- diff --git a/digitalocean2/src/test/resources/action.json b/digitalocean2/src/test/resources/action.json deleted file mode 100644 index 0202ca0..0000000 --- a/digitalocean2/src/test/resources/action.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "action": { - "region" : { - "name" : "New York 1", - "available" : true, - "slug" : "nyc1", - "features" : [ - "virtio", - "backups", - "metadata" - ], - "sizes" : [ - "512mb", - "8gb", - "16gb", - "32gb", - "48gb", - "64gb", - "1gb", - "2gb", - "4gb" - ] - }, - "started_at" : "2015-05-19T15:17:55Z", - "status" : "completed", - "resource_type" : "droplet", - "resource_id" : 5347489, - "region_slug" : "nyc1", - "id" : 50900149, - "completed_at" : "2015-05-19T15:18:01Z", - "type" : "destroy" - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a6044372/digitalocean2/src/test/resources/actions-first.json ---------------------------------------------------------------------- diff --git a/digitalocean2/src/test/resources/actions-first.json b/digitalocean2/src/test/resources/actions-first.json deleted file mode 100644 index c19fde3..0000000 --- a/digitalocean2/src/test/resources/actions-first.json +++ /dev/null @@ -1,168 +0,0 @@ -{ - "actions" : [ - { - "region" : { - "name" : "New York 1", - "available" : true, - "slug" : "nyc1", - "features" : [ - "virtio", - "backups", - "metadata" - ], - "sizes" : [ - "512mb", - "8gb", - "16gb", - "32gb", - "48gb", - "64gb", - "1gb", - "2gb", - "4gb" - ] - }, - "started_at" : "2015-05-19T15:17:55Z", - "status" : "completed", - "resource_type" : "droplet", - "resource_id" : 5347489, - "region_slug" : "nyc1", - "id" : 50900149, - "completed_at" : "2015-05-19T15:18:01Z", - "type" : "destroy" - }, - { - "started_at" : "2015-05-19T15:07:55Z", - "region" : { - "sizes" : [ - "512mb", - "8gb", - "16gb", - "32gb", - "48gb", - "64gb", - "1gb", - "2gb", - "4gb" - ], - "features" : [ - "virtio", - "backups", - "metadata" - ], - "available" : true, - "slug" : "nyc1", - "name" : "New York 1" - }, - "status" : "completed", - "resource_type" : "droplet", - "region_slug" : "nyc1", - "id" : 50899364, - "resource_id" : 5346565, - "completed_at" : "2015-05-19T15:08:04Z", - "type" : "destroy" - }, - { - "completed_at" : "2015-05-19T13:39:59Z", - "type" : "create", - "region" : { - "name" : "New York 1", - "sizes" : [ - "512mb", - "8gb", - "16gb", - "32gb", - "48gb", - "64gb", - "1gb", - "2gb", - "4gb" - ], - "features" : [ - "virtio", - "backups", - "metadata" - ], - "available" : true, - "slug" : "nyc1" - }, - "started_at" : "2015-05-19T13:39:12Z", - "resource_type" : "droplet", - "status" : "completed", - "resource_id" : 5347489, - "region_slug" : "nyc1", - "id" : 50892713 - }, - { - "resource_id" : 5346565, - "region_slug" : "nyc1", - "id" : 50888077, - "status" : "completed", - "resource_type" : "droplet", - "region" : { - "name" : "New York 1", - "features" : [ - "virtio", - "backups", - "metadata" - ], - "available" : true, - "slug" : "nyc1", - "sizes" : [ - "512mb", - "8gb", - "16gb", - "32gb", - "48gb", - "64gb", - "1gb", - "2gb", - "4gb" - ] - }, - "started_at" : "2015-05-19T12:37:23Z", - "type" : "create", - "completed_at" : "2015-05-19T12:38:13Z" - }, - { - "completed_at" : "2015-05-19T11:33:00Z", - "type" : "destroy", - "status" : "completed", - "resource_type" : "droplet", - "started_at" : "2015-05-19T11:32:55Z", - "region" : { - "available" : true, - "features" : [ - "virtio", - "backups", - "metadata" - ], - "slug" : "nyc1", - "sizes" : [ - "512mb", - "8gb", - "16gb", - "32gb", - "48gb", - "64gb", - "1gb", - "2gb", - "4gb" - ], - "name" : "New York 1" - }, - "region_slug" : "nyc1", - "id" : 50884032, - "resource_id" : 5344505 - } - ], - "links" : { - "pages" : { - "last" : "https://api.digitalocean.com/v2/actions?page=2&per_page=5", - "next" : "https://api.digitalocean.com/v2/actions?page=2&per_page=5" - } - }, - "meta" : { - "total" : 8 - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a6044372/digitalocean2/src/test/resources/actions-last.json ---------------------------------------------------------------------- diff --git a/digitalocean2/src/test/resources/actions-last.json b/digitalocean2/src/test/resources/actions-last.json deleted file mode 100644 index 5d86e7a..0000000 --- a/digitalocean2/src/test/resources/actions-last.json +++ /dev/null @@ -1,106 +0,0 @@ -{ - "meta" : { - "total" : 8 - }, - "links" : { - "pages" : { - "first" : "https://api.digitalocean.com/v2/actions?page=1&per_page=5", - "prev" : "https://api.digitalocean.com/v2/actions?page=1&per_page=5" - } - }, - "actions" : [ - { - "region" : { - "sizes" : [ - "512mb", - "8gb", - "16gb", - "32gb", - "48gb", - "64gb", - "1gb", - "2gb", - "4gb" - ], - "available" : true, - "features" : [ - "virtio", - "backups", - "metadata" - ], - "slug" : "nyc1", - "name" : "New York 1" - }, - "started_at" : "2014-01-18T22:39:08Z", - "type" : "create", - "resource_type" : "droplet", - "id" : 14115951, - "completed_at" : "2014-01-18T22:41:14Z", - "region_slug" : "nyc1", - "resource_id" : 1010699, - "status" : "completed" - }, - { - "started_at" : "2014-01-18T22:39:06Z", - "type" : "create", - "resource_type" : "droplet", - "region" : { - "sizes" : [ - "512mb", - "8gb", - "16gb", - "32gb", - "48gb", - "64gb", - "1gb", - "2gb", - "4gb" - ], - "slug" : "nyc1", - "name" : "New York 1", - "features" : [ - "virtio", - "backups", - "metadata" - ], - "available" : true - }, - "resource_id" : 1010697, - "region_slug" : "nyc1", - "status" : "completed", - "id" : 14115948, - "completed_at" : "2014-01-18T22:40:43Z" - }, - { - "region_slug" : "nyc1", - "resource_id" : 1010698, - "status" : "completed", - "id" : 14115949, - "completed_at" : "2014-01-18T22:44:08Z", - "type" : "create", - "started_at" : "2014-01-18T22:39:06Z", - "resource_type" : "droplet", - "region" : { - "sizes" : [ - "512mb", - "8gb", - "16gb", - "32gb", - "48gb", - "64gb", - "1gb", - "2gb", - "4gb" - ], - "slug" : "nyc1", - "name" : "New York 1", - "available" : true, - "features" : [ - "virtio", - "backups", - "metadata" - ] - } - } - ] -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a6044372/digitalocean2/src/test/resources/backups-first.json ---------------------------------------------------------------------- diff --git a/digitalocean2/src/test/resources/backups-first.json b/digitalocean2/src/test/resources/backups-first.json deleted file mode 100644 index f1083f1..0000000 --- a/digitalocean2/src/test/resources/backups-first.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "backups": [ - { - "id": 7622989, - "name": "example.com 2014-11-14", - "distribution": "Ubuntu", - "slug": null, - "public": false, - "regions": [ - "nyc3" - ], - "created_at": "2014-11-14T16:07:38Z", - "type": "snapshot", - "min_disk_size": 20 - } - ], - "links" : { - "pages" : { - "last" : "https://api.digitalocean.com/v2/droplets/3067509/backups?page=2", - "next" : "https://api.digitalocean.com/v2/droplets/3067509/backups?page=2" - } - }, - "meta": { - "total": 2 - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a6044372/digitalocean2/src/test/resources/backups-last.json ---------------------------------------------------------------------- diff --git a/digitalocean2/src/test/resources/backups-last.json b/digitalocean2/src/test/resources/backups-last.json deleted file mode 100644 index c927c19..0000000 --- a/digitalocean2/src/test/resources/backups-last.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "backups": [ - { - "id": 76229890, - "name": "example.com 2014-11-14", - "distribution": "Ubuntu", - "slug": null, - "public": false, - "regions": [ - "nyc3" - ], - "created_at": "2014-11-14T16:07:38Z", - "type": "snapshot", - "min_disk_size": 20 - } - ], - "links" : { - "pages" : { - "first" : "https://api.digitalocean.com/v2/droplets/3067509/backups?page=1", - "prev" : "https://api.digitalocean.com/v2/droplets/3067509/backups?page=1" - } - }, - "meta": { - "total": 2 - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a6044372/digitalocean2/src/test/resources/droplet-create-req.json ---------------------------------------------------------------------- diff --git a/digitalocean2/src/test/resources/droplet-create-req.json b/digitalocean2/src/test/resources/droplet-create-req.json deleted file mode 100644 index 3ed5273..0000000 --- a/digitalocean2/src/test/resources/droplet-create-req.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "digitalocean2-s-d5e", - "region": "sfo1", - "size": "512mb", - "image": "6374124", - "ssh_keys": [ - 421192 - ], - "backups": false, - "ipv6": false, - "private_networking": false -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a6044372/digitalocean2/src/test/resources/droplet-create-res.json ---------------------------------------------------------------------- diff --git a/digitalocean2/src/test/resources/droplet-create-res.json b/digitalocean2/src/test/resources/droplet-create-res.json deleted file mode 100644 index a7d37a5..0000000 --- a/digitalocean2/src/test/resources/droplet-create-res.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "droplet": { - "id": 2987224, - "name": "digitalocean2-s-d5e", - "memory": 512, - "vcpus": 1, - "disk": 20, - "locked": true, - "status": "new", - "kernel": { - "id": 70, - "name": "Ubuntu 10.04 x64 vmlinuz-2.6.32-41-server", - "version": "2.6.32-41-server" - }, - "created_at": "2014-10-27T19:33:34Z", - "features": [ - "virtio" - ], - "backup_ids": [], - "snapshot_ids": [], - "image": {}, - "size_slug": "512mb", - "networks": {}, - "region": {} - }, - "links": { - "actions": [ - { - "id": 35383956, - "rel": "create", - "href": "https://api.digitalocean.com/v2/actions/35383956" - } - ] - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a6044372/digitalocean2/src/test/resources/droplet.json ---------------------------------------------------------------------- diff --git a/digitalocean2/src/test/resources/droplet.json b/digitalocean2/src/test/resources/droplet.json deleted file mode 100644 index fb995c5..0000000 --- a/digitalocean2/src/test/resources/droplet.json +++ /dev/null @@ -1,105 +0,0 @@ -{ - "droplet" : - { - "created_at" : "2015-05-25T15:50:48Z", - "region" : { - "name" : "New York 1", - "sizes" : [ - "32gb", - "16gb", - "2gb", - "1gb", - "4gb", - "8gb", - "512mb", - "64gb", - "48gb" - ], - "slug" : "nyc1", - "features" : [ - "virtio", - "backups", - "metadata" - ], - "available" : true - }, - "id" : 5425561, - "disk" : 20, - "networks" : { - "v6" : [], - "v4" : [ - { - "type" : "public", - "ip_address" : "162.243.167.46", - "netmask" : "255.255.255.0", - "gateway" : "162.243.167.1" - } - ] - }, - "backup_ids" : [], - "image" : { - "slug" : "ubuntu-14-10-x32", - "public" : true, - "created_at" : "2015-01-08T18:41:22Z", - "distribution" : "Ubuntu", - "id" : 9801951, - "type" : "snapshot", - "regions" : [ - "nyc1", - "ams1", - "sfo1", - "nyc2", - "ams2", - "sgp1", - "lon1", - "nyc3", - "ams3", - "fra1" - ], - "name" : "14.10 x32", - "min_disk_size" : 20 - }, - "vcpus" : 1, - "next_backup_window" : { - "end" : "2015-06-01T23:00:00Z", - "start" : "2015-06-01T00:00:00Z" - }, - "locked" : false, - "snapshot_ids" : [], - "kernel" : { - "name" : "Ubuntu 14.10 x32 vmlinuz-3.16.0-28-generic", - "id" : 2926, - "version" : "3.16.0-28-generic" - }, - "status" : "active", - "features" : [ - "backups", - "virtio" - ], - "size" : { - "price_hourly" : 0.00744, - "slug" : "512mb", - "disk" : 20, - "available" : true, - "transfer" : 1, - "price_monthly" : 5, - "regions" : [ - "nyc1", - "sgp1", - "ams1", - "sfo1", - "nyc2", - "lon1", - "nyc3", - "ams3", - "ams2", - "fra1" - ], - "memory" : 512, - "vcpus" : 1 - }, - "name" : "test1", - "size_slug" : "512mb", - "memory" : 512 - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a6044372/digitalocean2/src/test/resources/droplets-first.json ---------------------------------------------------------------------- diff --git a/digitalocean2/src/test/resources/droplets-first.json b/digitalocean2/src/test/resources/droplets-first.json deleted file mode 100644 index 5493f7f..0000000 --- a/digitalocean2/src/test/resources/droplets-first.json +++ /dev/null @@ -1,115 +0,0 @@ -{ - "links" : { - "pages" : { - "next" : "https://api.digitalocean.com/v2/droplets/5425561?page=2&per_page=1", - "last" : "https://api.digitalocean.com/v2/droplets/5425561?page=2&per_page=1" - } - }, - "meta" : { - "total" : 2 - }, - "droplets" : [ - { - "created_at" : "2015-05-25T15:50:48Z", - "region" : { - "name" : "New York 1", - "sizes" : [ - "32gb", - "16gb", - "2gb", - "1gb", - "4gb", - "8gb", - "512mb", - "64gb", - "48gb" - ], - "slug" : "nyc1", - "features" : [ - "virtio", - "backups", - "metadata" - ], - "available" : true - }, - "id" : 5425561, - "disk" : 20, - "networks" : { - "v6" : [], - "v4" : [ - { - "type" : "public", - "ip_address" : "162.243.167.46", - "netmask" : "255.255.255.0", - "gateway" : "162.243.167.1" - } - ] - }, - "backup_ids" : [], - "image" : { - "slug" : "ubuntu-14-10-x32", - "public" : true, - "created_at" : "2015-01-08T18:41:22Z", - "distribution" : "Ubuntu", - "id" : 9801951, - "type" : "snapshot", - "regions" : [ - "nyc1", - "ams1", - "sfo1", - "nyc2", - "ams2", - "sgp1", - "lon1", - "nyc3", - "ams3", - "fra1" - ], - "name" : "14.10 x32", - "min_disk_size" : 20 - }, - "vcpus" : 1, - "next_backup_window" : { - "end" : "2015-06-01T23:00:00Z", - "start" : "2015-06-01T00:00:00Z" - }, - "locked" : false, - "snapshot_ids" : [], - "kernel" : { - "name" : "Ubuntu 14.10 x32 vmlinuz-3.16.0-28-generic", - "id" : 2926, - "version" : "3.16.0-28-generic" - }, - "status" : "active", - "features" : [ - "backups", - "virtio" - ], - "size" : { - "price_hourly" : 0.00744, - "slug" : "512mb", - "disk" : 20, - "available" : true, - "transfer" : 1, - "price_monthly" : 5, - "regions" : [ - "nyc1", - "sgp1", - "ams1", - "sfo1", - "nyc2", - "lon1", - "nyc3", - "ams3", - "ams2", - "fra1" - ], - "memory" : 512, - "vcpus" : 1 - }, - "name" : "test1", - "size_slug" : "512mb", - "memory" : 512 - } - ] -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a6044372/digitalocean2/src/test/resources/droplets-last.json ---------------------------------------------------------------------- diff --git a/digitalocean2/src/test/resources/droplets-last.json b/digitalocean2/src/test/resources/droplets-last.json deleted file mode 100644 index beeb654..0000000 --- a/digitalocean2/src/test/resources/droplets-last.json +++ /dev/null @@ -1,115 +0,0 @@ -{ - "links" : { - "pages" : { - "first" : "https://api.digitalocean.com/v2/droplets/5425561?page=2&per_page=1", - "prev" : "https://api.digitalocean.com/v2/droplets/5425561?page=2&per_page=1" - } - }, - "meta" : { - "total" : 2 - }, - "droplets" : [ - { - "created_at" : "2015-05-25T15:50:48Z", - "region" : { - "name" : "New York 1", - "sizes" : [ - "32gb", - "16gb", - "2gb", - "1gb", - "4gb", - "8gb", - "512mb", - "64gb", - "48gb" - ], - "slug" : "nyc1", - "features" : [ - "virtio", - "backups", - "metadata" - ], - "available" : true - }, - "id" : 5425561, - "disk" : 20, - "networks" : { - "v6" : [], - "v4" : [ - { - "type" : "public", - "ip_address" : "162.243.167.46", - "netmask" : "255.255.255.0", - "gateway" : "162.243.167.1" - } - ] - }, - "backup_ids" : [], - "image" : { - "slug" : "ubuntu-14-10-x32", - "public" : true, - "created_at" : "2015-01-08T18:41:22Z", - "distribution" : "Ubuntu", - "id" : 9801951, - "type" : "snapshot", - "regions" : [ - "nyc1", - "ams1", - "sfo1", - "nyc2", - "ams2", - "sgp1", - "lon1", - "nyc3", - "ams3", - "fra1" - ], - "name" : "14.10 x32", - "min_disk_size" : 20 - }, - "vcpus" : 1, - "next_backup_window" : { - "end" : "2015-06-01T23:00:00Z", - "start" : "2015-06-01T00:00:00Z" - }, - "locked" : false, - "snapshot_ids" : [], - "kernel" : { - "name" : "Ubuntu 14.10 x32 vmlinuz-3.16.0-28-generic", - "id" : 2926, - "version" : "3.16.0-28-generic" - }, - "status" : "active", - "features" : [ - "backups", - "virtio" - ], - "size" : { - "price_hourly" : 0.00744, - "slug" : "512mb", - "disk" : 20, - "available" : true, - "transfer" : 1, - "price_monthly" : 5, - "regions" : [ - "nyc1", - "sgp1", - "ams1", - "sfo1", - "nyc2", - "lon1", - "nyc3", - "ams3", - "ams2", - "fra1" - ], - "memory" : 512, - "vcpus" : 1 - }, - "name" : "test1", - "size_slug" : "512mb", - "memory" : 512 - } - ] -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a6044372/digitalocean2/src/test/resources/image.json ---------------------------------------------------------------------- diff --git a/digitalocean2/src/test/resources/image.json b/digitalocean2/src/test/resources/image.json deleted file mode 100644 index e66fda9..0000000 --- a/digitalocean2/src/test/resources/image.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "image" : { - "type" : "snapshot", - "id" : 11732785, - "name" : "Maintenance Mode", - "min_disk_size" : 20, - "distribution" : "Debian", - "created_at" : "2015-05-05T21:21:25Z", - "regions" : [ - "nyc1", - "ams1", - "sfo1", - "nyc2", - "ams2", - "sgp1", - "lon1", - "nyc3", - "ams3", - "fra1" - ], - "slug" : null, - "public" : true - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a6044372/digitalocean2/src/test/resources/images-first.json ---------------------------------------------------------------------- diff --git a/digitalocean2/src/test/resources/images-first.json b/digitalocean2/src/test/resources/images-first.json deleted file mode 100644 index 7d98cf9..0000000 --- a/digitalocean2/src/test/resources/images-first.json +++ /dev/null @@ -1,108 +0,0 @@ -{ - "meta" : { - "total" : 54 - }, - "links" : { - "pages" : { - "next" : "https://api.digitalocean.com/v2/images?page=2&per_page=5&type=distribution", - "last" : "https://api.digitalocean.com/v2/images?page=11&per_page=5&type=distribution" - } - }, - "images" : [ - { - "type" : "snapshot", - "id" : 11732785, - "name" : "Maintenance Mode", - "min_disk_size" : 20, - "distribution" : "Debian", - "created_at" : "2015-05-05T21:21:25Z", - "regions" : [ - "nyc1", - "ams1", - "sfo1", - "nyc2", - "ams2", - "sgp1", - "lon1", - "nyc3", - "ams3", - "fra1" - ], - "slug" : null, - "public" : true - }, - { - "type" : "snapshot", - "id" : 11833262, - "distribution" : "CoreOS", - "created_at" : "2015-05-12T17:41:36Z", - "regions" : [ - "nyc1", - "sfo1", - "ams2", - "sgp1", - "lon1", - "nyc3", - "ams3", - "fra1" - ], - "public" : true, - "slug" : "coreos-stable", - "name" : "647.0.0 (stable)", - "min_disk_size" : 20 - }, - { - "min_disk_size" : 20, - "name" : "668.3.0 (beta)", - "created_at" : "2015-05-18T18:14:12Z", - "public" : true, - "regions" : [ - "nyc1", - "sfo1", - "ams2", - "sgp1", - "lon1", - "nyc3", - "ams3", - "fra1" - ], - "slug" : "coreos-beta", - "distribution" : "CoreOS", - "id" : 11919888, - "type" : "snapshot" - }, - { - "type" : "snapshot", - "id" : 11919908, - "distribution" : "CoreOS", - "created_at" : "2015-05-18T18:20:08Z", - "public" : true, - "regions" : [ - "nyc1", - "sfo1", - "ams2", - "sgp1", - "lon1", - "nyc3", - "ams3", - "fra1" - ], - "slug" : "coreos-alpha", - "name" : "681.0.0 (alpha)", - "min_disk_size" : 20 - }, - { - "min_disk_size" : 30, - "name" : "vum-easter-move", - "slug" : null, - "regions" : [ - "ams1" - ], - "public" : true, - "created_at" : "2015-04-10T07:31:20Z", - "distribution" : "Debian", - "id" : 11385199, - "type" : "snapshot" - } - ] -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/a6044372/digitalocean2/src/test/resources/images-last.json ---------------------------------------------------------------------- diff --git a/digitalocean2/src/test/resources/images-last.json b/digitalocean2/src/test/resources/images-last.json deleted file mode 100644 index 89642fe..0000000 --- a/digitalocean2/src/test/resources/images-last.json +++ /dev/null @@ -1,123 +0,0 @@ -{ - "meta" : { - "total" : 54 - }, - "links" : { - "pages" : { - "prev" : "https://api.digitalocean.com/v2/images?page=1&per_page=5&type=distribution", - "first" : "https://api.digitalocean.com/v2/images?page=1&per_page=5&type=distribution" - } - }, - "images" : [ - { - "distribution" : "Fedora", - "min_disk_size" : 20, - "id" : 6370882, - "regions" : [ - "nyc1", - "ams1", - "sfo1", - "nyc2", - "ams2", - "sgp1", - "lon1", - "nyc3", - "ams3", - "fra1" - ], - "name" : "20 x64", - "type" : "snapshot", - "slug" : "fedora-20-x64", - "public" : true, - "created_at" : "2014-09-26T15:29:01Z" - }, - { - "name" : "20 x32", - "type" : "snapshot", - "distribution" : "Fedora", - "regions" : [ - "nyc1", - "ams1", - "sfo1", - "nyc2", - "ams2", - "sgp1", - "lon1", - "nyc3", - "ams3", - "fra1" - ], - "id" : 6370885, - "min_disk_size" : 20, - "created_at" : "2014-09-26T15:29:18Z", - "public" : true, - "slug" : "fedora-20-x32" - }, - { - "created_at" : "2014-09-26T16:40:18Z", - "slug" : "centos-5-8-x64", - "public" : true, - "type" : "snapshot", - "name" : "5.10 x64", - "regions" : [ - "nyc1", - "ams1", - "sfo1", - "nyc2", - "ams2", - "sgp1", - "lon1", - "nyc3", - "ams3", - "fra1" - ], - "min_disk_size" : 20, - "id" : 6372321, - "distribution" : "CentOS" - }, - { - "public" : true, - "slug" : "centos-5-8-x32", - "created_at" : "2014-09-26T16:45:29Z", - "id" : 6372425, - "min_disk_size" : 20, - "regions" : [ - "nyc1", - "ams1", - "sfo1", - "nyc2", - "ams2", - "sgp1", - "lon1", - "nyc3", - "ams3", - "fra1" - ], - "distribution" : "CentOS", - "type" : "snapshot", - "name" : "5.10 x32" - }, - { - "created_at" : "2014-09-26T16:56:00Z", - "public" : true, - "slug" : "debian-6-0-x64", - "type" : "snapshot", - "name" : "6.0 x64", - "regions" : [ - "nyc1", - "ams1", - "sfo1", - "nyc2", - "ams2", - "sgp1", - "lon1", - "nyc3", - "ams3", - "fra1" - ], - "min_disk_size" : 20, - "id" : 6372581, - "distribution" : "Debian" - } - ] -}
