http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/test/java/org/jclouds/profitbricks/BaseProfitBricksLiveTest.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/test/java/org/jclouds/profitbricks/BaseProfitBricksLiveTest.java b/profitbricks/src/test/java/org/jclouds/profitbricks/BaseProfitBricksLiveTest.java deleted file mode 100644 index 524149a..0000000 --- a/profitbricks/src/test/java/org/jclouds/profitbricks/BaseProfitBricksLiveTest.java +++ /dev/null @@ -1,186 +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.profitbricks; - -import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_RUNNING; -import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_SUSPENDED; -import static org.jclouds.profitbricks.config.ProfitBricksComputeProperties.POLL_PREDICATE_DATACENTER; -import static org.jclouds.profitbricks.config.ProfitBricksComputeProperties.POLL_PREDICATE_SNAPSHOT; -import static org.testng.Assert.assertTrue; - -import java.util.List; -import java.util.Objects; -import java.util.Properties; - -import org.jclouds.apis.BaseApiLiveTest; -import org.jclouds.profitbricks.domain.DataCenter; -import org.jclouds.profitbricks.domain.Location; -import org.jclouds.profitbricks.domain.Server; -import org.jclouds.profitbricks.domain.ProvisioningState; -import org.jclouds.profitbricks.features.DataCenterApi; -import org.jclouds.profitbricks.features.ServerApi; - -import com.google.common.base.Predicate; -import com.google.common.base.Supplier; -import com.google.common.collect.FluentIterable; -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; - -import org.jclouds.profitbricks.domain.Nic; -import org.jclouds.profitbricks.features.NicApi; - -public abstract class BaseProfitBricksLiveTest extends BaseApiLiveTest<ProfitBricksApi> { - - public static final Location testLocation = Location.US_LAS; - - private Predicate<String> dataCenterAvailable; - private Predicate<String> snapshotAvailable; - private Predicate<String> serverRunning; - private Predicate<String> serverSuspended; - - public BaseProfitBricksLiveTest() { - provider = "profitbricks"; - } - - @Override - protected ProfitBricksApi create(Properties props, Iterable<Module> modules) { - Injector injector = newBuilder().modules(modules).overrides(props).buildInjector(); - dataCenterAvailable = injector.getInstance(Key.get(new TypeLiteral<Predicate<String>>() { - }, Names.named(POLL_PREDICATE_DATACENTER))); - snapshotAvailable = injector.getInstance(Key.get(new TypeLiteral<Predicate<String>>() { - }, Names.named(POLL_PREDICATE_SNAPSHOT))); - serverRunning = injector.getInstance(Key.get(new TypeLiteral<Predicate<String>>() { - }, Names.named(TIMEOUT_NODE_RUNNING))); - serverSuspended = injector.getInstance(Key.get(new TypeLiteral<Predicate<String>>() { - }, Names.named(TIMEOUT_NODE_SUSPENDED))); - - return injector.getInstance(ProfitBricksApi.class); - } - - protected void assertDataCenterAvailable(DataCenter dataCenter) { - assertDataCenterAvailable(dataCenter.id()); - } - - protected void assertDataCenterAvailable(String dataCenterId) { - assertTrue(dataCenterAvailable.apply(dataCenterId), - String.format("Datacenter %s wasn't available in the configured timeout", dataCenterId)); - } - - protected void assertSnapshotAvailable(String snapshotId){ - assertTrue(snapshotAvailable.apply(snapshotId), - String.format("Snapshot %s wasn't available in the configured timeout", snapshotId)); - } - - protected void assertNodeRunning(String serverId) { - assertTrue(serverRunning.apply(serverId), String.format("Server %s did not start in the configured timeout", serverId)); - } - - protected void assertNodeSuspended(String serverId) { - assertTrue(serverSuspended.apply(serverId), String.format("Server %s did not stop in the configured timeout", serverId)); - } - - protected DataCenter findOrCreateDataCenter(final String name) { - DataCenterApi dataCenterApi = api.dataCenterApi(); - - return FluentIterable.from(dataCenterApi.getAllDataCenters()).firstMatch(new Predicate<DataCenter>() { - - @Override - public boolean apply(DataCenter input) { - boolean match = Objects.equals(input.name(), name); - if (match && input.location() == testLocation) - assertDataCenterAvailable(input); - - return match; - } - }).or(new Supplier<DataCenter>() { - - @Override - public DataCenter get() { - DataCenter dataCenter = api.dataCenterApi().createDataCenter( - DataCenter.Request.creatingPayload(name, testLocation)); - assertDataCenterAvailable(dataCenter); - - return api.dataCenterApi().getDataCenter(dataCenter.id()); - } - }); - } - - protected Server findOrCreateServer(final DataCenter dataCenter) { - return FluentIterable.from(dataCenter.servers()).firstMatch(new Predicate<Server>() { - - @Override - public boolean apply(Server input) { - return input.state() == ProvisioningState.AVAILABLE; - } - }).or(new Supplier<Server>() { - - @Override - public Server get() { - ServerApi serverApi = api.serverApi(); - String name = String.format("server-%d", dataCenter.servers().size()); - String createdServerId = serverApi.createServer( - Server.Request.creatingBuilder() - .dataCenterId(dataCenter.id()) - .name(name) - .cores(1) - .ram(256) - .build()); - assertDataCenterAvailable(dataCenter); - assertNodeRunning(createdServerId); - - return serverApi.getServer(createdServerId); - } - }); - } - - protected Nic findOrCreateNic(final DataCenter dataCenter) { - final NicApi nicApi = api.nicApi(); - final List<Nic> nics = nicApi.getAllNics(); - - return FluentIterable.from(nics).firstMatch(new Predicate<Nic>() { - - @Override - public boolean apply(Nic input) { - return Objects.equals(input.dataCenterId(), dataCenter.id()) - && input.state() == ProvisioningState.AVAILABLE; - } - }).or(new Supplier<Nic>() { - - @Override - public Nic get() { - Server server = findOrCreateServer(dataCenter); - String name = String.format("%s-nic-%d", server.name(), nics.size()); - String nicId = nicApi.createNic(Nic.Request.creatingBuilder() - .name(name) - .lanId(1) - .serverId(server.id()) - .build()); - assertDataCenterAvailable(dataCenter); - - return nicApi.getNic(nicId); - } - }); - } - - protected void destroyDataCenter(final DataCenter dataCenter) { - boolean success = api.dataCenterApi().deleteDataCenter(dataCenter.id()); - assertTrue(success, "DataCenter wasn't deleted"); - } -}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/test/java/org/jclouds/profitbricks/ProfitBricksProviderMetadataTest.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/test/java/org/jclouds/profitbricks/ProfitBricksProviderMetadataTest.java b/profitbricks/src/test/java/org/jclouds/profitbricks/ProfitBricksProviderMetadataTest.java deleted file mode 100644 index 210eeb9..0000000 --- a/profitbricks/src/test/java/org/jclouds/profitbricks/ProfitBricksProviderMetadataTest.java +++ /dev/null @@ -1,29 +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.profitbricks; - -import org.jclouds.providers.internal.BaseProviderMetadataTest; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "ProfitBricksProviderMetadataTest") -public class ProfitBricksProviderMetadataTest extends BaseProviderMetadataTest { - - public ProfitBricksProviderMetadataTest() { - super(new ProfitBricksProviderMetadata(), new ProfitBricksApiMetadata()); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/test/java/org/jclouds/profitbricks/binder/datacenter/CreateDataCenterRequestBinderTest.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/test/java/org/jclouds/profitbricks/binder/datacenter/CreateDataCenterRequestBinderTest.java b/profitbricks/src/test/java/org/jclouds/profitbricks/binder/datacenter/CreateDataCenterRequestBinderTest.java deleted file mode 100644 index 5190d6f..0000000 --- a/profitbricks/src/test/java/org/jclouds/profitbricks/binder/datacenter/CreateDataCenterRequestBinderTest.java +++ /dev/null @@ -1,47 +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.profitbricks.binder.datacenter; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import org.jclouds.profitbricks.domain.DataCenter; -import org.jclouds.profitbricks.domain.Location; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "CreateDataCenterRequestBinderTest") -public class CreateDataCenterRequestBinderTest { - - @Test - public void testCreatePayload() { - CreateDataCenterRequestBinder binder = new CreateDataCenterRequestBinder(); - - DataCenter.Request.CreatePayload payload = DataCenter.Request.creatingPayload("JClouds-DC", Location.DE_FKB); - - String actual = binder.createPayload(payload); - assertNotNull(actual, "Binder returned null payload"); - assertEquals(expectedPayload, actual); - } - - private final String expectedPayload - = (" <ws:createDataCenter>\n" - + " <request>\n" - + " <dataCenterName>JClouds-DC</dataCenterName>\n" - + " <location>de/fkb</location>\n" - + " </request>\n" - + " </ws:createDataCenter>\n").replaceAll("\\s+", ""); -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/test/java/org/jclouds/profitbricks/binder/datacenter/UpdateDataCenterRequestBinderTest.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/test/java/org/jclouds/profitbricks/binder/datacenter/UpdateDataCenterRequestBinderTest.java b/profitbricks/src/test/java/org/jclouds/profitbricks/binder/datacenter/UpdateDataCenterRequestBinderTest.java deleted file mode 100644 index 589fc69..0000000 --- a/profitbricks/src/test/java/org/jclouds/profitbricks/binder/datacenter/UpdateDataCenterRequestBinderTest.java +++ /dev/null @@ -1,46 +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.profitbricks.binder.datacenter; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import org.jclouds.profitbricks.domain.DataCenter; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "UpdateDataCenterRequestBinderTest") -public class UpdateDataCenterRequestBinderTest { - - @Test - public void testCreatePayload() { - UpdateDataCenterRequestBinder binder = new UpdateDataCenterRequestBinder(); - - DataCenter.Request.UpdatePayload payload = DataCenter.Request.updatingPayload("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "Apache-DC"); - - String actual = binder.createPayload(payload); - assertNotNull(actual, "Binder returned null payload"); - assertEquals(expectedPayload, actual); - } - - private final String expectedPayload - = (" <ws:updateDataCenter>\n" - + " <request>\n" - + " <dataCenterId>aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee</dataCenterId>\n" - + " <dataCenterName>Apache-DC</dataCenterName>\n" - + " </request>\n" - + " </ws:updateDataCenter>").replaceAll("\\s+", ""); -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/test/java/org/jclouds/profitbricks/binder/drive/AddRomDriveToServerRequestBinderTest.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/test/java/org/jclouds/profitbricks/binder/drive/AddRomDriveToServerRequestBinderTest.java b/profitbricks/src/test/java/org/jclouds/profitbricks/binder/drive/AddRomDriveToServerRequestBinderTest.java deleted file mode 100644 index 134b62f..0000000 --- a/profitbricks/src/test/java/org/jclouds/profitbricks/binder/drive/AddRomDriveToServerRequestBinderTest.java +++ /dev/null @@ -1,49 +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.profitbricks.binder.drive; - -import org.jclouds.profitbricks.domain.Drive; -import static org.testng.Assert.assertEquals; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "AddRomDriveToServerRequestBinderTest") -public class AddRomDriveToServerRequestBinderTest { - - @Test - public void testAddRomDriveToServerPayload() { - AddRomDriveToServerRequestBinder binder = new AddRomDriveToServerRequestBinder(); - - Drive.Request.AddRomDriveToServerPayload payload = Drive.Request.AddRomDriveToServerPayload.builder() - .serverId("server-id") - .imageId("image-id") - .deviceNumber("device-number") - .build(); - - String actual = binder.createPayload(payload); - assertEquals(expectedPayload, actual); - } - - private final String expectedPayload - = (" <ws:addRomDriveToServer>" - + " <request>" - + " <imageId>image-id</imageId>" - + " <serverId>server-id</serverId>" - + " <deviceNumber>device-number</deviceNumber>" - + " </request>" - + " </ws:addRomDriveToServer>").replaceAll("\\s+", ""); - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/test/java/org/jclouds/profitbricks/binder/firewall/AddFirewallRuleToNicRequestBinderTest.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/test/java/org/jclouds/profitbricks/binder/firewall/AddFirewallRuleToNicRequestBinderTest.java b/profitbricks/src/test/java/org/jclouds/profitbricks/binder/firewall/AddFirewallRuleToNicRequestBinderTest.java deleted file mode 100644 index 0e074a6..0000000 --- a/profitbricks/src/test/java/org/jclouds/profitbricks/binder/firewall/AddFirewallRuleToNicRequestBinderTest.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.profitbricks.binder.firewall; - -import org.jclouds.profitbricks.domain.Firewall; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import com.google.common.collect.ImmutableList; - -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "AddFirewallRuleToNicRequestBinderTest") -public class AddFirewallRuleToNicRequestBinderTest { - - @Test - public void testCreatePayload() { - AddFirewallRuleToNicRequestBinder binder = new AddFirewallRuleToNicRequestBinder(); - - Firewall.Request.AddRulePayload payload = Firewall.Request.createAddRulePayload( - "nic-id", ImmutableList.of( - Firewall.Rule.builder() - .name("name") - .portRangeEnd(45678) - .portRangeStart(12345) - .protocol(Firewall.Protocol.TCP) - .sourceIp("192.168.0.1") - .sourceMac("aa:bb:cc:dd:ee:ff") - .targetIp("192.168.0.2") - .build() - )); - - String actual = binder.createPayload(payload); - assertNotNull(actual, "Binder returned null payload"); - assertEquals(expectedPayload, actual); - } - - private final String expectedPayload = (" <ws:addFirewallRulesToNic>\n" - + " <nicId>nic-id</nicId>\n" - + " <request>\n" - + " <name>name</name>\n" - + " <portRangeEnd>45678</portRangeEnd>\n" - + " <portRangeStart>12345</portRangeStart>\n" - + " <protocol>TCP</protocol>\n" - + " <sourceIp>192.168.0.1</sourceIp>\n" - + " <sourceMac>aa:bb:cc:dd:ee:ff</sourceMac>\n" - + " <targetIp>192.168.0.2</targetIp>\n" - + " </request>\n" - + " </ws:addFirewallRulesToNic>").replaceAll("\\s+", ""); -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/test/java/org/jclouds/profitbricks/binder/firewall/FirewallBinderTest.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/test/java/org/jclouds/profitbricks/binder/firewall/FirewallBinderTest.java b/profitbricks/src/test/java/org/jclouds/profitbricks/binder/firewall/FirewallBinderTest.java deleted file mode 100644 index e32b788..0000000 --- a/profitbricks/src/test/java/org/jclouds/profitbricks/binder/firewall/FirewallBinderTest.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.profitbricks.binder.firewall; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import java.util.List; - -import org.jclouds.profitbricks.binder.firewall.FirewallBinder.ActivateFirewallRequestBinder; -import org.jclouds.profitbricks.binder.firewall.FirewallBinder.DeactivateFirewallRequestBinder; -import org.jclouds.profitbricks.binder.firewall.FirewallBinder.DeleteFirewallRequestBinder; -import org.jclouds.profitbricks.binder.firewall.FirewallBinder.RemoveFirewallRuleRequestBinder; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; - -@Test(groups = "unit", testName = "FirewallBinderTest") -public class FirewallBinderTest { - - @Test - public void testActivateFirewallBindPayload() { - ActivateFirewallRequestBinder binder = new ActivateFirewallRequestBinder(); - - List<String> payload = ImmutableList.of( - "firewall-id-1", - "firewall-id-2", - "firewall-id-3", - "firewall-id-4" - ); - - String actual = binder.createPayload(payload); - assertNotNull(actual, "Binder returned null payload"); - - String expected = ("<ws:activateFirewalls>\n" - + " <firewallIds>firewall-id-1</firewallIds>\n" - + " <firewallIds>firewall-id-2</firewallIds>\n" - + " <firewallIds>firewall-id-3</firewallIds>\n" - + " <firewallIds>firewall-id-4</firewallIds>\n" - + " </ws:activateFirewalls>").replaceAll("\\s+", ""); - - assertEquals(actual, expected); - } - - @Test - public void testDeactivateFirewallBindPayload() { - DeactivateFirewallRequestBinder binder = new DeactivateFirewallRequestBinder(); - - List<String> payload = ImmutableList.of( - "firewall-id-1", - "firewall-id-2", - "firewall-id-3", - "firewall-id-4" - ); - - String actual = binder.createPayload(payload); - assertNotNull(actual, "Binder returned null payload"); - - String expected = ("<ws:deactivateFirewalls>\n" - + " <firewallIds>firewall-id-1</firewallIds>\n" - + " <firewallIds>firewall-id-2</firewallIds>\n" - + " <firewallIds>firewall-id-3</firewallIds>\n" - + " <firewallIds>firewall-id-4</firewallIds>\n" - + " </ws:deactivateFirewalls>").replaceAll("\\s+", ""); - - assertEquals(actual, expected); - } - - @Test - public void testDeleteFirewallBindPayload() { - DeleteFirewallRequestBinder binder = new DeleteFirewallRequestBinder(); - - List<String> payload = ImmutableList.of( - "firewall-id-1", - "firewall-id-2", - "firewall-id-3", - "firewall-id-4" - ); - - String actual = binder.createPayload(payload); - assertNotNull(actual, "Binder returned null payload"); - - String expected = ("<ws:deleteFirewalls>\n" - + " <firewallIds>firewall-id-1</firewallIds>\n" - + " <firewallIds>firewall-id-2</firewallIds>\n" - + " <firewallIds>firewall-id-3</firewallIds>\n" - + " <firewallIds>firewall-id-4</firewallIds>\n" - + " </ws:deleteFirewalls>").replaceAll("\\s+", ""); - - assertEquals(actual, expected); - } - - @Test - public void testRemoveFirewallRuleBindPayload() { - RemoveFirewallRuleRequestBinder binder = new RemoveFirewallRuleRequestBinder(); - - List<String> payload = ImmutableList.of( - "firewall-rule-id-1", - "firewall-rule-id-2", - "firewall-rule-id-3", - "firewall-rule-id-4" - ); - - String actual = binder.createPayload(payload); - assertNotNull(actual, "Binder returned null payload"); - - String expected = ("<ws:removeFirewallRules>\n" - + " <firewallRuleIds>firewall-rule-id-1</firewallRuleIds>\n" - + " <firewallRuleIds>firewall-rule-id-2</firewallRuleIds>\n" - + " <firewallRuleIds>firewall-rule-id-3</firewallRuleIds>\n" - + " <firewallRuleIds>firewall-rule-id-4</firewallRuleIds>\n" - + " </ws:removeFirewallRules>").replaceAll("\\s+", ""); - - assertEquals(actual, expected); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/test/java/org/jclouds/profitbricks/binder/loadbalancer/CreateLoadBalancerRequestBinderTest.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/test/java/org/jclouds/profitbricks/binder/loadbalancer/CreateLoadBalancerRequestBinderTest.java b/profitbricks/src/test/java/org/jclouds/profitbricks/binder/loadbalancer/CreateLoadBalancerRequestBinderTest.java deleted file mode 100644 index 4744986..0000000 --- a/profitbricks/src/test/java/org/jclouds/profitbricks/binder/loadbalancer/CreateLoadBalancerRequestBinderTest.java +++ /dev/null @@ -1,68 +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.profitbricks.binder.loadbalancer; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import java.util.List; - -import com.google.common.collect.Lists; -import com.google.common.collect.ImmutableList; - -import org.testng.annotations.Test; -import org.jclouds.profitbricks.domain.LoadBalancer; -import org.jclouds.profitbricks.domain.LoadBalancer.Algorithm; - -@Test(groups = "unit", testName = "CreateLoadBalancerRequestBinderTest") -public class CreateLoadBalancerRequestBinderTest { - - @Test - public void testCreatePayload() { - CreateLoadBalancerRequestBinder binder = new CreateLoadBalancerRequestBinder(); - - List<String> serverIds = Lists.newArrayList(); - serverIds.add("server-ids"); - - String actual = binder.createPayload( - LoadBalancer.Request.creatingBuilder() - .dataCenterId("datacenter-id") - .name("load-balancer-name") - .algorithm(Algorithm.ROUND_ROBIN) - .ip("10.0.0.1") - .lanId(2) - .serverIds(ImmutableList.<String>of( - "server-id-1", "server-id-2")) - .build()); - - assertNotNull(actual, "Binder returned null payload"); - assertEquals(expectedPayload, actual); - } - - private final String expectedPayload - = ("<ws:createLoadBalancer>\n" - + " <request>\n" - + " <dataCenterId>datacenter-id</dataCenterId>\n" - + " <loadBalancerName>load-balancer-name</loadBalancerName>\n" - + " <loadBalancerAlgorithm>ROUND_ROBIN</loadBalancerAlgorithm>\n" - + " <ip>10.0.0.1</ip>\n" - + " <lanId>2</lanId>\n" - + " <serverIds>server-id-1</serverIds>\n" - + " <serverIds>server-id-2</serverIds>\n" - + " </request>\n" - + " </ws:createLoadBalancer>").replaceAll("\\s+", ""); -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/test/java/org/jclouds/profitbricks/binder/loadbalancer/DeregisterLoadBalancerRequestBinderTest.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/test/java/org/jclouds/profitbricks/binder/loadbalancer/DeregisterLoadBalancerRequestBinderTest.java b/profitbricks/src/test/java/org/jclouds/profitbricks/binder/loadbalancer/DeregisterLoadBalancerRequestBinderTest.java deleted file mode 100644 index c690fb3..0000000 --- a/profitbricks/src/test/java/org/jclouds/profitbricks/binder/loadbalancer/DeregisterLoadBalancerRequestBinderTest.java +++ /dev/null @@ -1,47 +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.profitbricks.binder.loadbalancer; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import com.google.common.collect.ImmutableList; - -import org.jclouds.profitbricks.domain.LoadBalancer; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "DeregisterLoadBalancerRequestBinderTest") -public class DeregisterLoadBalancerRequestBinderTest { - - @Test - public void testDeregisterPayload() { - DeregisterLoadBalancerRequestBinder binder = new DeregisterLoadBalancerRequestBinder(); - - String actual = binder.createPayload(LoadBalancer.Request.createDeregisteringPayload( - "load-balancer-id", ImmutableList.of("1", "2"))); - - assertNotNull(actual, "Binder returned null payload"); - assertEquals(expectedPayload, actual); - } - - private final String expectedPayload - = (" <ws:deregisterServersOnLoadBalancer>\n" - + " <serverIds>1</serverIds>\n" - + " <serverIds>2</serverIds>\n" - + " <loadBalancerId>load-balancer-id</loadBalancerId>\n" - + " </ws:deregisterServersOnLoadBalancer>").replaceAll("\\s+", ""); -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/test/java/org/jclouds/profitbricks/binder/loadbalancer/RegisterLoadBalancerRequestBinderTest.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/test/java/org/jclouds/profitbricks/binder/loadbalancer/RegisterLoadBalancerRequestBinderTest.java b/profitbricks/src/test/java/org/jclouds/profitbricks/binder/loadbalancer/RegisterLoadBalancerRequestBinderTest.java deleted file mode 100644 index 8f2e5a9..0000000 --- a/profitbricks/src/test/java/org/jclouds/profitbricks/binder/loadbalancer/RegisterLoadBalancerRequestBinderTest.java +++ /dev/null @@ -1,46 +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.profitbricks.binder.loadbalancer; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import org.jclouds.profitbricks.domain.LoadBalancer; - -import com.google.common.collect.ImmutableList; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "RegisterLoadBalancerRequestBinderTest") -public class RegisterLoadBalancerRequestBinderTest { - - @Test - public void testRegisterPayload() { - RegisterLoadBalancerRequestBinder binder = new RegisterLoadBalancerRequestBinder(); - String actual = binder.createPayload(LoadBalancer.Request.createRegisteringPaylod( - "load-balancer-id", ImmutableList.of("1", "2"))); - - assertNotNull(actual, "Binder returned null payload"); - assertEquals(expectedPayload, actual); - } - - private final String expectedPayload - = (" <ws:registerServersOnLoadBalancer>\n" - + " <loadBalancerId>load-balancer-id</loadBalancerId>\n" - + " <serverIds>1</serverIds>\n" - + " <serverIds>2</serverIds>\n" - + " </ws:registerServersOnLoadBalancer>").replaceAll("\\s+", ""); -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/test/java/org/jclouds/profitbricks/binder/loadbalancer/UpdateLoadBalancerRequestBinderTest.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/test/java/org/jclouds/profitbricks/binder/loadbalancer/UpdateLoadBalancerRequestBinderTest.java b/profitbricks/src/test/java/org/jclouds/profitbricks/binder/loadbalancer/UpdateLoadBalancerRequestBinderTest.java deleted file mode 100644 index b638c89..0000000 --- a/profitbricks/src/test/java/org/jclouds/profitbricks/binder/loadbalancer/UpdateLoadBalancerRequestBinderTest.java +++ /dev/null @@ -1,61 +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.profitbricks.binder.loadbalancer; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import java.util.List; - -import com.google.common.collect.Lists; - -import org.jclouds.profitbricks.domain.LoadBalancer; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "UpdateLoadBalancerRequestBinderTest") -public class UpdateLoadBalancerRequestBinderTest { - - @Test - public void testDeregisterPayload() { - UpdateLoadBalancerRequestBinder binder = new UpdateLoadBalancerRequestBinder(); - List<String> serverIds = Lists.newArrayList(); - serverIds.add("1"); - serverIds.add("2"); - - LoadBalancer.Request.UpdatePayload payload = LoadBalancer.Request.updatingBuilder() - .id("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .name("load-balancer-name") - .algorithm(LoadBalancer.Algorithm.ROUND_ROBIN) - .ip("10.0.0.2") - .build(); - - String actual = binder.createPayload(payload); - - assertNotNull(actual, "Binder returned null payload"); - assertEquals(expectedPayload, actual); - } - - private final String expectedPayload - = (" <ws:updateLoadBalancer>\n" - + " <request>\n" - + " <loadBalancerId>aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee</loadBalancerId>\n" - + " <loadBalancerName>load-balancer-name</loadBalancerName>\n" - + " <loadBalancerAlgorithm>ROUND_ROBIN</loadBalancerAlgorithm>\n" - + " <ip>10.0.0.2</ip> \n" - + " </request>\n" - + " </ws:updateLoadBalancer>").replaceAll("\\s+", ""); -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/test/java/org/jclouds/profitbricks/binder/nic/CreateNicRequestBinderTest.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/test/java/org/jclouds/profitbricks/binder/nic/CreateNicRequestBinderTest.java b/profitbricks/src/test/java/org/jclouds/profitbricks/binder/nic/CreateNicRequestBinderTest.java deleted file mode 100644 index 8e2630d..0000000 --- a/profitbricks/src/test/java/org/jclouds/profitbricks/binder/nic/CreateNicRequestBinderTest.java +++ /dev/null @@ -1,53 +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.profitbricks.binder.nic; - -import org.jclouds.profitbricks.domain.Nic; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "CreateNicRequestBinderTest") -public class CreateNicRequestBinderTest { - - @Test - public void testCreatePayload() { - CreateNicRequestBinder binder = new CreateNicRequestBinder(); - - Nic.Request.CreatePayload payload = Nic.Request.creatingBuilder() - .ip("192.168.0.1") - .name("nic-name") - .dhcpActive(true) - .serverId("server-id") - .lanId(1) - .build(); - - String actual = binder.createPayload(payload); - assertNotNull(actual, "Binder returned null payload"); - assertEquals(expectedPayload, actual); - } - - private final String expectedPayload = ("<ws:createNic>\n" - + " <request>\n" - + " <ip>192.168.0.1</ip>\n" - + " <nicName>nic-name</nicName>\n" - + " <dhcpActive>true</dhcpActive>\n" - + " <serverId>server-id</serverId>\n" - + " <lanId>1</lanId>\n" - + " </request>\n" - + " </ws:createNic>").replaceAll("\\s+", ""); -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/test/java/org/jclouds/profitbricks/binder/nic/SetInternetAccessBinderTest.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/test/java/org/jclouds/profitbricks/binder/nic/SetInternetAccessBinderTest.java b/profitbricks/src/test/java/org/jclouds/profitbricks/binder/nic/SetInternetAccessBinderTest.java deleted file mode 100644 index c499c73..0000000 --- a/profitbricks/src/test/java/org/jclouds/profitbricks/binder/nic/SetInternetAccessBinderTest.java +++ /dev/null @@ -1,48 +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.profitbricks.binder.nic; - -import org.jclouds.profitbricks.domain.Nic; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "SetInternetAccessBinderTest") -public class SetInternetAccessBinderTest { - - @Test - public void testCreatePayload() { - SetInternetAccessBinder binder = new SetInternetAccessBinder(); - - Nic.Request.SetInternetAccessPayload payload = Nic.Request.setInternetAccessBuilder() - .dataCenterId("datacenter-id") - .internetAccess(true) - .lanId(1) - .build(); - - String actual = binder.createPayload(payload); - - assertNotNull(actual, "Binder returned null payload"); - assertEquals(expectedPayload, actual); - } - - private final String expectedPayload = (" <ws:setInternetAccess>\n" - + " <dataCenterId>datacenter-id</dataCenterId>\n" - + " <lanId>1</lanId>\n" - + " <internetAccess>true</internetAccess>\n" - + " </ws:setInternetAccess>").replaceAll("\\s+", ""); -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/test/java/org/jclouds/profitbricks/binder/nic/UpdateNicRequestBinderTest.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/test/java/org/jclouds/profitbricks/binder/nic/UpdateNicRequestBinderTest.java b/profitbricks/src/test/java/org/jclouds/profitbricks/binder/nic/UpdateNicRequestBinderTest.java deleted file mode 100644 index 298fea7..0000000 --- a/profitbricks/src/test/java/org/jclouds/profitbricks/binder/nic/UpdateNicRequestBinderTest.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.profitbricks.binder.nic; - -import org.jclouds.profitbricks.domain.Nic; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "UpdateNicRequestBinderTest") -public class UpdateNicRequestBinderTest { - - @Test - public void testCreatePayload() { - UpdateNicRequestBinder binder = new UpdateNicRequestBinder(); - - Nic.Request.UpdatePayload payload = Nic.Request.updatingBuilder() - .id("nic-id") - .ip("192.168.0.1") - .name("nic-name") - .dhcpActive(true) - .lanId(1) - .build(); - - String actual = binder.createPayload(payload); - - assertNotNull(actual, "Binder returned null payload"); - assertEquals(expectedPayload, actual); - } - - private final String expectedPayload = (" <ws:updateNic>\n" - + " <request>\n" - + " <nicId>nic-id</nicId>\n" - + " <ip>192.168.0.1</ip>\n" - + " <nicName>nic-name</nicName>\n" - + " <dhcpActive>true</dhcpActive>\n" - + " <lanId>1</lanId>\n" - + " </request>\n" - + " </ws:updateNic>").replaceAll("\\s+", ""); -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/test/java/org/jclouds/profitbricks/binder/server/CreateServerRequestBinderTest.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/test/java/org/jclouds/profitbricks/binder/server/CreateServerRequestBinderTest.java b/profitbricks/src/test/java/org/jclouds/profitbricks/binder/server/CreateServerRequestBinderTest.java deleted file mode 100644 index 355f318..0000000 --- a/profitbricks/src/test/java/org/jclouds/profitbricks/binder/server/CreateServerRequestBinderTest.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.profitbricks.binder.server; - -import org.jclouds.profitbricks.domain.Server; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "CreateServerRequestBinderTest") -public class CreateServerRequestBinderTest { - - @Test - public void testCreatePayload() { - CreateServerRequestBinder binder = new CreateServerRequestBinder(); - - Server.Request.CreatePayload payload = Server.Request.creatingBuilder() - .name("jclouds-node") - .cores(4) - .ram(4 * 1024) - .dataCenterId("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .build(); - - String actual = binder.createPayload(payload); - assertNotNull(actual, "Binder returned null payload"); - assertEquals(actual, expectedPayload); - } - - private final String expectedPayload - = (" <ws:createServer>\n" - + " <request>\n" - + " <dataCenterId>aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee</dataCenterId>\n" - + " <cores>4</cores>\n" - + " <ram>4096</ram>\n" - + " <serverName>jclouds-node</serverName>\n" - // + " <bootFromStorageId>?</bootFromStorageId>\n" - // + " <bootFromImageId>?</bootFromImageId>\n" - // + " <internetAccess>false</internetAccess>\n" - // + " <lanId>?</lanId>\n" - // + " <osType>?</osType>\n" - // + " <availabilityZone>AUTO</availabilityZone>\n" - // + " <cpuHotPlug>false</cpuHotPlug>\n" - // + " <ramHotPlug>false</ramHotPlug>\n" - // + " <nicHotPlug>false</nicHotPlug>\n" - // + " <nicHotUnPlug>false</nicHotUnPlug>\n" - // + " <discVirtioHotPlug>false</discVirtioHotPlug>\n" - // + " <discVirtioHotUnPlug>false</discVirtioHotUnPlug>\n" - + " </request>\n" - + " </ws:createServer>") - .replaceAll("\\s+", ""); -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/test/java/org/jclouds/profitbricks/binder/server/UpdateServerRequestBinderTest.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/test/java/org/jclouds/profitbricks/binder/server/UpdateServerRequestBinderTest.java b/profitbricks/src/test/java/org/jclouds/profitbricks/binder/server/UpdateServerRequestBinderTest.java deleted file mode 100644 index aa0e31c..0000000 --- a/profitbricks/src/test/java/org/jclouds/profitbricks/binder/server/UpdateServerRequestBinderTest.java +++ /dev/null @@ -1,64 +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.profitbricks.binder.server; - -import org.jclouds.profitbricks.domain.Server; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "UpdateServerRequestBinderTest") -public class UpdateServerRequestBinderTest { - - @Test - public void testCreatePayload() { - UpdateServerRequestBinder binder = new UpdateServerRequestBinder(); - - Server.Request.UpdatePayload payload = Server.Request.updatingBuilder() - .id("qwertyui-qwer-qwer-qwer-qwertyyuiiop") - .cores(8) - .ram(8 * 1024) - .name("apache-node") - .build(); - - String actual = binder.createPayload(payload); - assertNotNull(actual, "Binder returned null payload"); - assertEquals(actual, expectedPayload); - } - - private final String expectedPayload - = (" <ws:updateServer>\n" - + " <request>\n" - + " <serverId>qwertyui-qwer-qwer-qwer-qwertyyuiiop</serverId>\n" - + " <cores>8</cores>\n" - + " <ram>8192</ram>\n" - + " <serverName>apache-node</serverName>\n" - // + " <bootFromStorageId>?</bootFromStorageId>\n" - // + " <bootFromImageId>?</bootFromImageId>\n" - // + " <osType>?</osType>\n" - // + " <availabilityZone>?</availabilityZone>\n" - // + " <cpuHotPlug>?</cpuHotPlug>\n" - // + " <ramHotPlug>?</ramHotPlug>\n" - // + " <nicHotPlug>?</nicHotPlug>\n" - // + " <nicHotUnPlug>?</nicHotUnPlug>\n" - // + " <discVirtioHotPlug>?</discVirtioHotPlug>\n" - // + " <discVirtioHotUnPlug>?</discVirtioHotUnPlug>\n" - + " </request>\n" - + " </ws:updateServer>") - .replaceAll("\\s+", ""); - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/test/java/org/jclouds/profitbricks/binder/snapshot/CreateSnapshotRequestBinderTest.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/test/java/org/jclouds/profitbricks/binder/snapshot/CreateSnapshotRequestBinderTest.java b/profitbricks/src/test/java/org/jclouds/profitbricks/binder/snapshot/CreateSnapshotRequestBinderTest.java deleted file mode 100644 index 8a9c581..0000000 --- a/profitbricks/src/test/java/org/jclouds/profitbricks/binder/snapshot/CreateSnapshotRequestBinderTest.java +++ /dev/null @@ -1,51 +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.profitbricks.binder.snapshot; - -import org.jclouds.profitbricks.domain.Snapshot; -import org.testng.annotations.Test; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -@Test(groups = "unit", testName = "CreateSnapshotRequestBinderTest") -public class CreateSnapshotRequestBinderTest { - - @Test - public void testCreatePayload() { - CreateSnapshotRequestBinder binder = new CreateSnapshotRequestBinder(); - - Snapshot.Request.CreatePayload payload = Snapshot.Request.creatingBuilder() - .storageId("123-1233-1324") - .name("snapshot-name") - .description("describing-the-snapshot") - .build(); - - String actual = binder.createPayload(payload); - assertNotNull(actual, "Binder returned null payload"); - assertEquals(expectedPayload, actual); - } - - private final String expectedPayload - = (" <ws:createSnapshot>\n" - + "<request>\n" - + "<storageId>123-1233-1324</storageId>\n" - + "<description>describing-the-snapshot</description>\n" - + "<snapshotName>snapshot-name</snapshotName>\n" - + "</request>\n" - + "</ws:createSnapshot>").replaceAll("\\s+", ""); -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/test/java/org/jclouds/profitbricks/binder/snapshot/RollbackSnapshotRequestBinderTest.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/test/java/org/jclouds/profitbricks/binder/snapshot/RollbackSnapshotRequestBinderTest.java b/profitbricks/src/test/java/org/jclouds/profitbricks/binder/snapshot/RollbackSnapshotRequestBinderTest.java deleted file mode 100644 index 87a043c..0000000 --- a/profitbricks/src/test/java/org/jclouds/profitbricks/binder/snapshot/RollbackSnapshotRequestBinderTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.profitbricks.binder.snapshot; - -import org.jclouds.profitbricks.domain.Snapshot; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "RollbackSnapshotRequestBinderTest") -public class RollbackSnapshotRequestBinderTest { - - @Test - public void testRollbackPayload() { - RollbackSnapshotRequestBinder binder = new RollbackSnapshotRequestBinder(); - - Snapshot.Request.RollbackPayload payload = Snapshot.Request.createRollbackPayload("snapshot-id", "storage-id"); - - String actual = binder.createPayload(payload); - assertNotNull(actual, "Binder returned null payload"); - assertEquals(expectedPayload, actual); - } - - private final String expectedPayload = "<ws:rollbackSnapshot>" - + "<request>" - + "<snapshotId>snapshot-id</snapshotId>" - + "<storageId>storage-id</storageId>" - + "</request>" - + "</ws:rollbackSnapshot>".replaceAll("\\s", ""); -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/test/java/org/jclouds/profitbricks/binder/snapshot/UpdateSnapshotRequestBinderTest.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/test/java/org/jclouds/profitbricks/binder/snapshot/UpdateSnapshotRequestBinderTest.java b/profitbricks/src/test/java/org/jclouds/profitbricks/binder/snapshot/UpdateSnapshotRequestBinderTest.java deleted file mode 100644 index 1809a1c..0000000 --- a/profitbricks/src/test/java/org/jclouds/profitbricks/binder/snapshot/UpdateSnapshotRequestBinderTest.java +++ /dev/null @@ -1,74 +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.profitbricks.binder.snapshot; - -import org.jclouds.profitbricks.domain.OsType; -import org.jclouds.profitbricks.domain.Snapshot; -import org.testng.annotations.Test; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -@Test(groups = "unit", testName = "UpdateSnapshotRequestBinderTest") -public class UpdateSnapshotRequestBinderTest { - - @Test - public void testUpdatePayload() { - UpdateSnapshotRequestBinder binder = new UpdateSnapshotRequestBinder(); - - Snapshot.Request.UpdatePayload payload = Snapshot.Request.updatingBuilder() - .id("qswdefrg-qaws-qaws-defe-rgrgdsvcxbrh") - .description("description") - .name("snapshot-name") - .bootable(true) - .osType(OsType.LINUX) - .isCpuHotPlug(true) - .isCpuHotUnPlug(true) - .isRamHotPlug(true) - .isRamHotUnPlug(true) - .isNicHotPlug(true) - .isNicHotUnPlug(true) - .isDiscVirtioHotPlug(true) - .isDiscVirtioHotUnPlug(true) - .build(); - - String actual = binder.createPayload(payload); - assertNotNull(actual, "Binder returned null payload"); - assertEquals(expectedPayload, actual); - - } - - private final String expectedPayload - = "<ws:updateSnapshot>" - + "<request>" - + "<snapshotId>qswdefrg-qaws-qaws-defe-rgrgdsvcxbrh</snapshotId>" - + "<description>description</description>" - + "<snapshotName>snapshot-name</snapshotName>" - + "<bootable>true</bootable>" - + "<osType>LINUX</osType>" - + "<cpuHotPlug>true</cpuHotPlug>" - + "<cpuHotUnPlug>true</cpuHotUnPlug>" - + "<ramHotPlug>true</ramHotPlug>" - + "<ramHotUnPlug>true</ramHotUnPlug>" - + "<nicHotPlug>true</nicHotPlug>" - + "<nicHotUnPlug>true</nicHotUnPlug>" - + "<discVirtioHotPlug>true</discVirtioHotPlug>" - + "<discVirtioHotUnPlug>true</discVirtioHotUnPlug>" - + "</request>" - + "</ws:updateSnapshot>".replaceAll("\\s", ""); - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/test/java/org/jclouds/profitbricks/binder/storage/ConnectStorageToServerRequestBinderTest.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/test/java/org/jclouds/profitbricks/binder/storage/ConnectStorageToServerRequestBinderTest.java b/profitbricks/src/test/java/org/jclouds/profitbricks/binder/storage/ConnectStorageToServerRequestBinderTest.java deleted file mode 100644 index 0c0d3a4..0000000 --- a/profitbricks/src/test/java/org/jclouds/profitbricks/binder/storage/ConnectStorageToServerRequestBinderTest.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.profitbricks.binder.storage; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import org.jclouds.profitbricks.domain.Storage; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "ConnectStorageToServerRequestBinderTest") -public class ConnectStorageToServerRequestBinderTest { - - @Test - public void testCreatePayload() { - ConnectStorageToServerRequestBinder binder = new ConnectStorageToServerRequestBinder(); - - Storage.Request.ConnectPayload payload = Storage.Request.connectingBuilder() - .serverId("qwertyui-qwer-qwer-qwer-qwertyyuiiop") - .storageId("qswdefrg-qaws-qaws-defe-rgrgdsvcxbrh") - .busType(Storage.BusType.VIRTIO) - .deviceNumber(2) - .build(); - - String actual = binder.createPayload(payload); - assertNotNull(actual, "Binder returned null payload"); - assertEquals(actual, expectedPayload); - } - - private final String expectedPayload - = (" <ws:connectStorageToServer>\n" - + " <request>\n" - + " <storageId>qswdefrg-qaws-qaws-defe-rgrgdsvcxbrh</storageId>\n" - + " <serverId>qwertyui-qwer-qwer-qwer-qwertyyuiiop</serverId>\n" - + " <busType>VIRTIO</busType>\n" - + " <deviceNumber>2</deviceNumber>\n" - + " </request>\n" - + " </ws:connectStorageToServer>") - .replaceAll("\\s+", ""); - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/test/java/org/jclouds/profitbricks/binder/storage/CreateStorageRequestBinderTest.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/test/java/org/jclouds/profitbricks/binder/storage/CreateStorageRequestBinderTest.java b/profitbricks/src/test/java/org/jclouds/profitbricks/binder/storage/CreateStorageRequestBinderTest.java deleted file mode 100644 index 9120be7..0000000 --- a/profitbricks/src/test/java/org/jclouds/profitbricks/binder/storage/CreateStorageRequestBinderTest.java +++ /dev/null @@ -1,56 +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.profitbricks.binder.storage; - -import org.jclouds.profitbricks.domain.Storage; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "CreateStorageRequestBinderTest") -public class CreateStorageRequestBinderTest { - - @Test - public void testCreatePayload() { - CreateStorageRequestBinder binder = new CreateStorageRequestBinder(); - - Storage.Request.CreatePayload payload = Storage.Request.creatingBuilder() - .name("hdd-1") - .size(60f) - .dataCenterId("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .mountImageId("5ad99c9e-9166-11e4-9d74-52540066fee9") - .imagePassword("qqqqqqqqq") - .build(); - - String actual = binder.createPayload(payload); - assertNotNull(actual, "Binder returned null payload"); - assertEquals(actual, expectedPayload); - } - - private final String expectedPayload - = (" <ws:createStorage>\n" - + " <request>\n" - + " <dataCenterId>aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee</dataCenterId>\n" - + " <storageName>hdd-1</storageName>\n" - + " <size>60</size>\n" - + " <mountImageId>5ad99c9e-9166-11e4-9d74-52540066fee9</mountImageId>\n" - + " <profitBricksImagePassword>qqqqqqqqq</profitBricksImagePassword>\n" - + " </request>\n" - + " </ws:createStorage>") - .replaceAll("\\s+", ""); - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/test/java/org/jclouds/profitbricks/binder/storage/UpdateStorageRequestBinderTest.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/test/java/org/jclouds/profitbricks/binder/storage/UpdateStorageRequestBinderTest.java b/profitbricks/src/test/java/org/jclouds/profitbricks/binder/storage/UpdateStorageRequestBinderTest.java deleted file mode 100644 index 0240297..0000000 --- a/profitbricks/src/test/java/org/jclouds/profitbricks/binder/storage/UpdateStorageRequestBinderTest.java +++ /dev/null @@ -1,53 +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.profitbricks.binder.storage; - -import org.jclouds.profitbricks.domain.Storage; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "UpdateStorageRequestBinderTest") -public class UpdateStorageRequestBinderTest { - - @Test - public void testUpdatePayload() { - UpdateStorageRequestBinder binder = new UpdateStorageRequestBinder(); - - Storage.Request.UpdatePayload payload = Storage.Request.updatingBuilder() - .id("pppppppp-llkl-kkjk-fhgh-vnmegrdgdsgr") - .size(100f) - .name("hdd-2") - .mountImageId("5f3cac96-915f-11e4-9d74-52540066fee9") - .build(); - - String actual = binder.createPayload(payload); - assertNotNull(actual, "Binder returned null payload"); - assertEquals(actual, expectedPayload); - } - - private final String expectedPayload - = (" <ws:updateStorage>\n" - + " <request>\n" - + " <storageId>pppppppp-llkl-kkjk-fhgh-vnmegrdgdsgr</storageId>\n" - + " <size>100</size>\n" - + " <storageName>hdd-2</storageName>\n" - + " <mountImageId>5f3cac96-915f-11e4-9d74-52540066fee9</mountImageId>\n" - + " </request>\n" - + " </ws:updateStorage>") - .replaceAll("\\s+", ""); -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/test/java/org/jclouds/profitbricks/compute/ProfitBricksComputeServiceLiveTest.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/test/java/org/jclouds/profitbricks/compute/ProfitBricksComputeServiceLiveTest.java b/profitbricks/src/test/java/org/jclouds/profitbricks/compute/ProfitBricksComputeServiceLiveTest.java deleted file mode 100644 index 0061090..0000000 --- a/profitbricks/src/test/java/org/jclouds/profitbricks/compute/ProfitBricksComputeServiceLiveTest.java +++ /dev/null @@ -1,73 +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.profitbricks.compute; - -import org.jclouds.compute.domain.ExecResponse; -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.internal.BaseComputeServiceLiveTest; -import org.jclouds.logging.config.LoggingModule; -import org.jclouds.logging.slf4j.config.SLF4JLoggingModule; -import org.jclouds.sshj.config.SshjSshClientModule; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; - -@Test(groups = "live", singleThreaded = true, testName = "ProfitBricksComputeServiceLiveTest") -public class ProfitBricksComputeServiceLiveTest extends BaseComputeServiceLiveTest { - - public ProfitBricksComputeServiceLiveTest() { - provider = "profitbricks"; - } - - @Override - protected Module getSshModule() { - return new SshjSshClientModule(); - } - - @Override - protected LoggingModule getLoggingModule() { - return new SLF4JLoggingModule(); - } - - @Override - public void testOptionToNotBlock() throws Exception { - // ProfitBricks implementation intentionally blocks until the node is 'AVAILABLE' - } - - @Override - protected void checkTagsInNodeEquals(NodeMetadata node, ImmutableSet<String> tags) { - // ProfitBricks doesn't support tags - } - - @Override - protected void checkUserMetadataContains(NodeMetadata node, ImmutableMap<String, String> userMetadata) { - // ProfitBricks doesn't support user metadata - } - - @Override - protected void checkResponseEqualsHostname(ExecResponse execResponse, NodeMetadata node1) { - // ProfitBricks doesn't support hostname - } - - @Override - protected void checkOsMatchesTemplate(NodeMetadata node) { - // Not enough description from API to match template - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/test/java/org/jclouds/profitbricks/compute/ProfitBricksTemplateBuilderLiveTest.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/test/java/org/jclouds/profitbricks/compute/ProfitBricksTemplateBuilderLiveTest.java b/profitbricks/src/test/java/org/jclouds/profitbricks/compute/ProfitBricksTemplateBuilderLiveTest.java deleted file mode 100644 index f81ca28..0000000 --- a/profitbricks/src/test/java/org/jclouds/profitbricks/compute/ProfitBricksTemplateBuilderLiveTest.java +++ /dev/null @@ -1,103 +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.profitbricks.compute; - -import static org.jclouds.profitbricks.BaseProfitBricksLiveTest.testLocation; -import static org.jclouds.profitbricks.config.ProfitBricksComputeProperties.POLL_PREDICATE_DATACENTER; - -import java.util.Objects; -import java.util.Set; - -import com.google.common.base.Predicate; -import com.google.common.base.Supplier; -import com.google.common.collect.FluentIterable; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Key; -import com.google.inject.TypeLiteral; -import com.google.inject.name.Names; - -import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; -import org.jclouds.profitbricks.ProfitBricksApi; -import org.jclouds.profitbricks.domain.DataCenter; -import org.jclouds.profitbricks.features.DataCenterApi; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -@Test(groups = "live", testName = "ProfitBricksTemplateBuilderLiveTest", singleThreaded = true) -public class ProfitBricksTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { - - private static final String TEST_DC_NAME = "templateBuilderLiveTest-" + System.currentTimeMillis(); - - private DataCenter dataCenter; - - public ProfitBricksTemplateBuilderLiveTest() { - this.provider = "profitbricks"; - } - - @BeforeClass - @Override - public void setupContext() { - super.setupContext(); - - final DataCenterApi api = getDataCenterApi(); - final Predicate<String> predicate = getDataCenterPredicate(); - dataCenter = FluentIterable.from(api.getAllDataCenters()).firstMatch(new Predicate<DataCenter>() { - - @Override - public boolean apply(DataCenter input) { - boolean match = Objects.equals(input.name(), TEST_DC_NAME); - if (match && input.location() == testLocation) - return predicate.apply(input.id()); - return match; - } - }).or(new Supplier<DataCenter>() { - - @Override - public DataCenter get() { - DataCenter dataCenter = api.createDataCenter( - DataCenter.Request.creatingPayload(TEST_DC_NAME, testLocation)); - predicate.apply(dataCenter.id()); - - return api.getDataCenter(dataCenter.id()); - } - }); - } - - private Predicate<String> getDataCenterPredicate() { - return view.utils().injector().getInstance(Key.get(new TypeLiteral<Predicate<String>>() { - }, Names.named(POLL_PREDICATE_DATACENTER))); - } - - private DataCenterApi getDataCenterApi() { - return view.unwrapApi(ProfitBricksApi.class).dataCenterApi(); - } - - @AfterClass(groups = {"integration", "live"}, alwaysRun = true) - @Override - protected void tearDownContext() { - super.tearDownContext(); - if (dataCenter != null) - getDataCenterApi().deleteDataCenter(dataCenter.id()); - } - - @Override - protected Set<String> getIso3166Codes() { - return ImmutableSet.of(); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/test/java/org/jclouds/profitbricks/compute/concurrent/ProvisioningManagerTest.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/test/java/org/jclouds/profitbricks/compute/concurrent/ProvisioningManagerTest.java b/profitbricks/src/test/java/org/jclouds/profitbricks/compute/concurrent/ProvisioningManagerTest.java deleted file mode 100644 index dd115cc..0000000 --- a/profitbricks/src/test/java/org/jclouds/profitbricks/compute/concurrent/ProvisioningManagerTest.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.profitbricks.compute.concurrent; - -import static com.google.common.util.concurrent.Uninterruptibles.sleepUninterruptibly; -import static java.util.logging.Logger.getAnonymousLogger; -import static org.testng.Assert.assertEquals; - -import java.io.IOException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - -import org.testng.annotations.Test; - -import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.base.Supplier; -import com.google.common.base.Suppliers; -import com.google.common.base.Throwables; - -@Test(groups = "unit", testName = "ProvisioningManagerTest") -public class ProvisioningManagerTest { - - @Test - public void testProvision() throws IOException { - ProvisioningManager manager = new ProvisioningManager(); - AtomicInteger completedJobs = new AtomicInteger(0); - - try { - for (int i = 0; i < 5; i++) { - manager.provision(new MockJob(200, "slow", completedJobs)); - manager.provision(new MockJob(0, "fast", completedJobs)); - manager.provision(new MockJob(100, "normal", completedJobs)); - } - } finally { - manager.close(); - } - - assertEquals(completedJobs.get(), 15); - } - - @Test - public void testProvisionInterrupted() { - ProvisioningManager manager = new ProvisioningManager(); - AtomicInteger completedJobs = new AtomicInteger(0); - - manager.provision(new ShutdownExecutorJob(manager, completedJobs)); - manager.provision(new MockJob(0, "rejected", completedJobs)); - - assertEquals(completedJobs.get(), 1); - } - - private static class MockJob extends ProvisioningJob { - - private final long delay; - private final AtomicInteger completedJobs; - - public MockJob(long delay, String group, AtomicInteger completedJobs) { - super(sleepPredicate(delay), group, Suppliers.ofInstance((Object) 0)); - this.delay = delay; - this.completedJobs = completedJobs; - } - - @Override - public Integer call() throws Exception { - getAnonymousLogger().info("ProvisioningManagerTest: Starting " + this); - super.call(); - getAnonymousLogger().info("ProvisioningManagerTest: Completed " + this); - return completedJobs.incrementAndGet(); - } - - @Override - public String toString() { - return "MockJob [id=" + hashCode() + ", group=" + getGroup() + ", delay=" + delay + "]"; - } - } - - private static class ShutdownExecutorJob extends ProvisioningJob { - - public ShutdownExecutorJob(final ProvisioningManager manager, final AtomicInteger completedJobs) { - super(Predicates.<String>alwaysTrue(), "shutdown", new Supplier<Object>() { - @Override - public Integer get() { - try { - manager.close(); - return completedJobs.incrementAndGet(); - } catch (IOException ex) { - throw Throwables.propagate(ex); - } - } - }); - } - } - - private static Predicate<String> sleepPredicate(final long delay) { - return new Predicate<String>() { - @Override - public boolean apply(String input) { - sleepUninterruptibly(delay, TimeUnit.MILLISECONDS); - return true; - } - }; - } -}
