http://git-wip-us.apache.org/repos/asf/jclouds/blob/83b104d9/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2_0/features/SubnetApiLiveTest.java ---------------------------------------------------------------------- diff --git a/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2_0/features/SubnetApiLiveTest.java b/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2_0/features/SubnetApiLiveTest.java deleted file mode 100644 index a2bf3ec..0000000 --- a/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2_0/features/SubnetApiLiveTest.java +++ /dev/null @@ -1,139 +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.openstack.neutron.v2_0.features; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -import java.util.Set; - -import org.jclouds.openstack.neutron.v2_0.domain.AllocationPool; -import org.jclouds.openstack.neutron.v2_0.domain.BulkSubnet; -import org.jclouds.openstack.neutron.v2_0.domain.HostRoute; -import org.jclouds.openstack.neutron.v2_0.domain.NetworkType; -import org.jclouds.openstack.neutron.v2_0.domain.ReferenceWithName; -import org.jclouds.openstack.neutron.v2_0.domain.Subnet; -import org.jclouds.openstack.neutron.v2_0.internal.BaseNeutronApiLiveTest; -import org.jclouds.openstack.neutron.v2_0.options.CreateNetworkOptions; -import org.jclouds.openstack.neutron.v2_0.options.CreateSubnetBulkOptions; -import org.jclouds.openstack.neutron.v2_0.options.CreateSubnetOptions; -import org.jclouds.openstack.neutron.v2_0.options.UpdateSubnetOptions; -import org.jclouds.openstack.neutron.v2_0.util.PredicateUtil; -import org.testng.annotations.Test; - -import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; - -/** - * Tests subnet api in combination with the network api - * - */ -@Test(groups = "live", testName = "SubnetApiLiveTest", singleThreaded = true) -public class SubnetApiLiveTest extends BaseNeutronApiLiveTest { - - public void testGetAndListSubnets() { - for (String zone : api.getConfiguredZones()) { - Set<? extends ReferenceWithName> references = api.getSubnetApiForZone(zone).list().concat().toSet(); - Set<? extends Subnet> subnets = api.getSubnetApiForZone(zone).listInDetail().concat().toSet(); - - assertNotNull(references); - assertNotNull(subnets); - assertEquals(references.size(), subnets.size()); - - for (Subnet subnet : subnets) { - assertNotNull(subnet.getNetworkId()); - assertTrue(references.contains(ReferenceWithName.builder().id(subnet.getId()).tenantId(subnet.getTenantId()).name(subnet.getName()).build())); - - Subnet retrievedSubnet = api.getSubnetApiForZone(zone).get(subnet.getId()); - assertEquals(retrievedSubnet, subnet); - } - } - } - - public void testCreateUpdateAndDeleteSubnet() { - for (String zone : api.getConfiguredZones()) { - NetworkApi networkApi = api.getNetworkApiForZone(zone); - String networkId = networkApi.create(CreateNetworkOptions.builder().name("jclouds-live-test").networkType(NetworkType.LOCAL).build()).getId(); - - SubnetApi subnetApi = api.getSubnetApiForZone(zone); - Set<AllocationPool> allocationPools = ImmutableSet.of( - AllocationPool.builder().start("a3:bc00::10").end("a3:bc00::20").build(), - AllocationPool.builder().start("a3:bc00::50").end("a3:bc00::90").build() - ); - Set<HostRoute> hostRoutes = ImmutableSet.of( - HostRoute.builder().destinationCidr("a3:bc00::/48").nextHop("a3:bc00::0004").build() - ); - Subnet subnet = subnetApi.create(networkId, 6, "a3:bc00::/48", CreateSubnetOptions.builder().allocationPools(allocationPools).hostRoutes(hostRoutes).build()); - assertNotNull(subnet); - - Subnet retrievedSubnet = subnetApi.get(subnet.getId()); - - assertEquals(retrievedSubnet.getId(), subnet.getId()); - assertEquals(retrievedSubnet.getCidr(), "a3:bc00::/48"); - assertTrue(retrievedSubnet.getDnsNameServers().isEmpty()); - assertEquals(retrievedSubnet.getAllocationPools().size(), 2); - assertEquals(retrievedSubnet.getHostRoutes().size(), 1); - assertTrue(subnetApi.update(retrievedSubnet.getId(), UpdateSubnetOptions.builder().name("jclouds-live-test-update").build())); - - retrievedSubnet = subnetApi.get(retrievedSubnet.getId()); - - assertEquals(retrievedSubnet.getId(), subnet.getId()); - assertEquals(retrievedSubnet.getName(), "jclouds-live-test-update"); - assertTrue(retrievedSubnet.getDnsNameServers().isEmpty()); - - Subnet subnet2 = subnetApi.create(networkId, 6, "a3:bd01::/48"); - assertNotNull(subnet2); - - assertTrue(subnetApi.delete(subnet.getId())); - assertTrue(subnetApi.delete(subnet2.getId())); - assertTrue(networkApi.delete(networkId)); - } - } - - public void testBulkCreateSubnet() { - for (String zone : api.getConfiguredZones()) { - NetworkApi networkApi = api.getNetworkApiForZone(zone); - String networkId = networkApi.create(CreateNetworkOptions.builder().name("jclouds-live-test").networkType(NetworkType.LOCAL).build()).getId(); - - SubnetApi subnetApi = api.getSubnetApiForZone(zone); - Set<? extends Subnet> subnets = subnetApi.createBulk( - CreateSubnetBulkOptions.builder().subnets( - ImmutableList.of( - BulkSubnet.builder().name("jclouds-live-test-1").cidr("a3:bd01::/48").ipVersion(6).networkId(networkId).build(), - BulkSubnet.builder().name("jclouds-live-test-2").cidr("a3:bd02::/48").ipVersion(6).networkId(networkId).build(), - BulkSubnet.builder().name("jclouds-live-test-3").cidr("a3:bd03::/48").ipVersion(6).networkId(networkId).build() - ) - ).build() - ).toSet(); - Set<? extends Subnet> existingSubnets = subnetApi.listInDetail().concat().toSet(); - - assertNotNull(subnets); - assertTrue(!subnets.isEmpty()); - assertEquals(subnets.size(), 3); - - for (Subnet net : subnets) { - Predicate<Subnet> idEqualsPredicate = PredicateUtil.createIdEqualsPredicate(net.getId()); - assertEquals(1, Sets.filter(existingSubnets, idEqualsPredicate).size()); - assertTrue(subnetApi.delete(net.getId())); - } - assertTrue(networkApi.delete(networkId)); - } - } -}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/83b104d9/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2_0/internal/BaseNeutronApiExpectTest.java ---------------------------------------------------------------------- diff --git a/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2_0/internal/BaseNeutronApiExpectTest.java b/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2_0/internal/BaseNeutronApiExpectTest.java deleted file mode 100644 index ff9ffa7..0000000 --- a/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2_0/internal/BaseNeutronApiExpectTest.java +++ /dev/null @@ -1,66 +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.openstack.neutron.v2_0.internal; - -import com.google.common.collect.ImmutableSet; -import org.jclouds.openstack.neutron.v2_0.NeutronApi; -import org.jclouds.openstack.neutron.v2_0.domain.Reference; -import org.jclouds.openstack.neutron.v2_0.domain.ReferenceWithName; - -import java.util.Set; - -/** - * Base class for writing Neutron Rest Api Expect tests - */ -public class BaseNeutronApiExpectTest extends BaseNeutronExpectTest<NeutronApi> { - - protected Set<Reference> listOfReferences() { - return ImmutableSet.of( - Reference.builder().tenantId("1234567890").id("16dba3bc-f3fa-4775-afdc-237e12c72f6a").build(), - Reference.builder().tenantId("1234567890").id("1a104cf5-cb18-4d35-9407-2fd2646d9d0b").build(), - Reference.builder().tenantId("1234567890").id("31083ae2-420d-48b2-ac98-9f7a4fd8dbdc").build(), - Reference.builder().tenantId("1234567890").id("49c6d6fa-ff2a-459d-b975-75a8d31c9a89").build(), - Reference.builder().tenantId("1234567890").id("5cb3d6f4-62cb-41c9-b964-ba7d9df79e4e").build(), - Reference.builder().tenantId("1234567890").id("5d51d012-3491-4db7-b1b5-6f254015015d").build(), - Reference.builder().tenantId("1234567890").id("5f9cf7dc-22ca-4097-8e49-1cc8b23faf17").build(), - Reference.builder().tenantId("1234567890").id("6319ecad-6bff-48b2-9b53-02ede8cb7588").build(), - Reference.builder().tenantId("1234567890").id("6ba4c788-661f-49ab-9bf8-5f10cbbb2f57").build(), - Reference.builder().tenantId("1234567890").id("74ed170b-5069-4353-ab38-9719766dc57e").build(), - Reference.builder().tenantId("1234567890").id("b71fcac1-e864-4031-8c5b-edbecd9ece36").build(), - Reference.builder().tenantId("1234567890").id("c7681895-d84d-4650-9ca0-82c72036b855").build() - ); - } - - protected Set<ReferenceWithName> listOfReferencesWithNames() { - return ImmutableSet.of( - ReferenceWithName.builder().name("jclouds-test").tenantId("1234567890").id("16dba3bc-f3fa-4775-afdc-237e12c72f6a").build(), - ReferenceWithName.builder().name("wibble").tenantId("1234567890").id("1a104cf5-cb18-4d35-9407-2fd2646d9d0b").build(), - ReferenceWithName.builder().name("jclouds-test").tenantId("1234567890").id("31083ae2-420d-48b2-ac98-9f7a4fd8dbdc").build(), - ReferenceWithName.builder().name("jclouds-test").tenantId("1234567890").id("49c6d6fa-ff2a-459d-b975-75a8d31c9a89").build(), - ReferenceWithName.builder().name("wibble").tenantId("1234567890").id("5cb3d6f4-62cb-41c9-b964-ba7d9df79e4e").build(), - ReferenceWithName.builder().name("jclouds-test").tenantId("1234567890").id("5d51d012-3491-4db7-b1b5-6f254015015d").build(), - ReferenceWithName.builder().name("wibble").tenantId("1234567890").id("5f9cf7dc-22ca-4097-8e49-1cc8b23faf17").build(), - ReferenceWithName.builder().name("jclouds-test").tenantId("1234567890").id("6319ecad-6bff-48b2-9b53-02ede8cb7588").build(), - ReferenceWithName.builder().name("jclouds-test").tenantId("1234567890").id("6ba4c788-661f-49ab-9bf8-5f10cbbb2f57").build(), - ReferenceWithName.builder().name("jclouds-test").tenantId("1234567890").id("74ed170b-5069-4353-ab38-9719766dc57e").build(), - ReferenceWithName.builder().name("wibble").tenantId("1234567890").id("b71fcac1-e864-4031-8c5b-edbecd9ece36").build(), - ReferenceWithName.builder().name("jclouds-test").tenantId("1234567890").id("c7681895-d84d-4650-9ca0-82c72036b855").build() - ); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/83b104d9/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2_0/internal/BaseNeutronApiLiveTest.java ---------------------------------------------------------------------- diff --git a/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2_0/internal/BaseNeutronApiLiveTest.java b/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2_0/internal/BaseNeutronApiLiveTest.java deleted file mode 100644 index de5755e..0000000 --- a/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2_0/internal/BaseNeutronApiLiveTest.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.openstack.neutron.v2_0.internal; - -import org.jclouds.apis.BaseApiLiveTest; -import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties; -import org.jclouds.openstack.neutron.v2_0.NeutronApi; -import org.testng.annotations.Test; - -import java.util.Properties; - -/** - * Tests behavior of {@code NeutronApi} - */ -@Test(groups = "live") -public class BaseNeutronApiLiveTest extends BaseApiLiveTest<NeutronApi> { - - public BaseNeutronApiLiveTest() { - provider = "openstack-neutron-legacy"; - } - - @Override - protected Properties setupProperties() { - Properties props = super.setupProperties(); - setIfTestSystemPropertyPresent(props, KeystoneProperties.CREDENTIAL_TYPE); - return props; - } - -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/83b104d9/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2_0/internal/BaseNeutronExpectTest.java ---------------------------------------------------------------------- diff --git a/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2_0/internal/BaseNeutronExpectTest.java b/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2_0/internal/BaseNeutronExpectTest.java deleted file mode 100644 index d8c024c..0000000 --- a/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2_0/internal/BaseNeutronExpectTest.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.openstack.neutron.v2_0.internal; - -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.openstack.keystone.v2_0.internal.KeystoneFixture; -import org.jclouds.rest.internal.BaseRestApiExpectTest; - -import javax.ws.rs.core.MediaType; - -/** - * Base class for writing Neutron Expect tests - */ -public class BaseNeutronExpectTest<T> extends BaseRestApiExpectTest<T> { - protected HttpRequest keystoneAuthWithUsernameAndPassword; - protected HttpRequest keystoneAuthWithUsernameAndPasswordAndTenantName; - protected HttpRequest keystoneAuthWithAccessKeyAndSecretKeyAndTenantName; - protected String authToken; - protected HttpResponse responseWithKeystoneAccess; - protected HttpRequest keystoneAuthWithAccessKeyAndSecretKeyAndTenantId; - protected String identityWithTenantId; - protected String endpoint = "https://csnode.jclouds.org:9696/v2.0"; - - public BaseNeutronExpectTest() { - provider = "openstack-neutron-legacy"; - keystoneAuthWithUsernameAndPassword = KeystoneFixture.INSTANCE.initialAuthWithUsernameAndPassword(identity, - credential); - keystoneAuthWithUsernameAndPasswordAndTenantName = KeystoneFixture.INSTANCE.initialAuthWithUsernameAndPasswordAndTenantName(identity, - credential); - keystoneAuthWithAccessKeyAndSecretKeyAndTenantName = KeystoneFixture.INSTANCE.initialAuthWithAccessKeyAndSecretKeyAndTenantName(identity, - credential); - keystoneAuthWithAccessKeyAndSecretKeyAndTenantId = KeystoneFixture.INSTANCE.initialAuthWithAccessKeyAndSecretKeyAndTenantId(identity, - credential); - - authToken = KeystoneFixture.INSTANCE.getAuthToken(); - responseWithKeystoneAccess = KeystoneFixture.INSTANCE.responseWithAccess(); - // now, createContext arg will need tenant prefix - identityWithTenantId = KeystoneFixture.INSTANCE.getTenantId() + ":" + identity; - identity = KeystoneFixture.INSTANCE.getTenantName() + ":" + identity; - } - - protected HttpRequest.Builder<?> authenticatedGET() { - return HttpRequest.builder() - .method("GET") - .addHeader("Accept", MediaType.APPLICATION_JSON) - .addHeader("X-Auth-Token", authToken); - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/83b104d9/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2_0/parse/ParseNetworkTest.java ---------------------------------------------------------------------- diff --git a/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2_0/parse/ParseNetworkTest.java b/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2_0/parse/ParseNetworkTest.java deleted file mode 100644 index 9509ba3..0000000 --- a/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2_0/parse/ParseNetworkTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jclouds.openstack.neutron.v2_0.parse; - -import org.jclouds.json.BaseItemParserTest; -import org.jclouds.openstack.neutron.v2_0.domain.Network; -import org.jclouds.openstack.neutron.v2_0.domain.NetworkType; -import org.jclouds.openstack.neutron.v2_0.domain.State; -import org.jclouds.rest.annotations.SelectJson; -import org.testng.annotations.Test; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; - -@Test(groups = "unit", testName = "ParseNetworkTest") -public class ParseNetworkTest extends BaseItemParserTest<Network> { - - @Override - public String resource() { - return "/network.json"; - } - - @Override - @SelectJson("network") - @Consumes(MediaType.APPLICATION_JSON) - public Network expected() { - return Network.builder() - .networkType(NetworkType.LOCAL) - .state(State.ACTIVE) - .name("jclouds-wibble") - .tenantId("1234567890") - .id("624312ff-d14b-4ba3-9834-1c78d23d574d") - .build(); - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/83b104d9/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2_0/parse/ParsePortTest.java ---------------------------------------------------------------------- diff --git a/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2_0/parse/ParsePortTest.java b/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2_0/parse/ParsePortTest.java deleted file mode 100644 index b029299..0000000 --- a/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2_0/parse/ParsePortTest.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.openstack.neutron.v2_0.parse; - -import org.jclouds.json.BaseItemParserTest; -import org.jclouds.openstack.neutron.v2_0.domain.Port; -import org.jclouds.openstack.neutron.v2_0.domain.State; -import org.jclouds.rest.annotations.SelectJson; -import org.testng.annotations.Test; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; - -@Test(groups = "unit", testName = "ParsePortTest") -public class ParsePortTest extends BaseItemParserTest<Port> { - - @Override - public String resource() { - return "/port.json"; - } - - @Override - @SelectJson("port") - @Consumes(MediaType.APPLICATION_JSON) - public Port expected() { - return Port.builder() - .state(State.ACTIVE) - .networkId("1234567890") - .name("jclouds-wibble") - .tenantId("1234567890") - .id("624312ff-d14b-4ba3-9834-1c78d23d574d") - .build(); - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/83b104d9/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2_0/parse/ParseRouterTest.java ---------------------------------------------------------------------- diff --git a/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2_0/parse/ParseRouterTest.java b/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2_0/parse/ParseRouterTest.java deleted file mode 100644 index 1787129..0000000 --- a/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2_0/parse/ParseRouterTest.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.openstack.neutron.v2_0.parse; - -import org.jclouds.json.BaseItemParserTest; -import org.jclouds.openstack.neutron.v2_0.domain.ExternalGatewayInfo; -import org.jclouds.openstack.neutron.v2_0.domain.Router; -import org.jclouds.openstack.neutron.v2_0.domain.State; -import org.jclouds.rest.annotations.SelectJson; -import org.testng.annotations.Test; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; - -@Test(groups = "unit", testName = "ParseRouterTest") -public class ParseRouterTest extends BaseItemParserTest<Router> { - - @Override - public String resource() { - return "/router.json"; - } - - @Override - @SelectJson("router") - @Consumes(MediaType.APPLICATION_JSON) - public Router expected() { - return Router.builder() - .externalGatewayInfo(ExternalGatewayInfo.builder().networkId("624312ff-d14b-4ba3-9834-1c78d23d574d").build()) - .state(State.ACTIVE) - .name("jclouds-wibble") - .tenantId("1234567890") - .id("16dba3bc-f3fa-4775-afdc-237e12c72f6a") - .build(); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/83b104d9/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2_0/parse/ParseSubnetTest.java ---------------------------------------------------------------------- diff --git a/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2_0/parse/ParseSubnetTest.java b/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2_0/parse/ParseSubnetTest.java deleted file mode 100644 index afe84b4..0000000 --- a/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2_0/parse/ParseSubnetTest.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.openstack.neutron.v2_0.parse; - -import org.jclouds.json.BaseItemParserTest; -import org.jclouds.openstack.neutron.v2_0.domain.Subnet; -import org.jclouds.rest.annotations.SelectJson; -import org.testng.annotations.Test; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; - -@Test(groups = "unit", testName = "ParseSubnetTest") -public class ParseSubnetTest extends BaseItemParserTest<Subnet> { - - @Override - public String resource() { - return "/subnet.json"; - } - - @Override - @SelectJson("subnet") - @Consumes(MediaType.APPLICATION_JSON) - public Subnet expected() { - return Subnet.builder() - .ipVersion(4) - .cidr("10.0.3.0/24") - .networkId("1234567890") - .name("jclouds-wibble") - .tenantId("1234567890") - .id("624312ff-d14b-4ba3-9834-1c78d23d574d") - .build(); - } -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/83b104d9/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2_0/util/ClassUtil.java ---------------------------------------------------------------------- diff --git a/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2_0/util/ClassUtil.java b/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2_0/util/ClassUtil.java deleted file mode 100644 index 1797fb3..0000000 --- a/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2_0/util/ClassUtil.java +++ /dev/null @@ -1,39 +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.openstack.neutron.v2_0.util; - -import java.lang.reflect.Field; - -public class ClassUtil { - - public static Field findField(Class clazz, String fieldName) { - Field fieldToFind = null; - if (clazz.getSuperclass() != null) - fieldToFind = findField(clazz.getSuperclass(), fieldName); - - if (fieldToFind != null) - return fieldToFind; - - for (Field field : clazz.getDeclaredFields()) { - if (field.getName().equals(fieldName)) - return field; - } - return null; - } - -} http://git-wip-us.apache.org/repos/asf/jclouds/blob/83b104d9/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2_0/util/PredicateUtil.java ---------------------------------------------------------------------- diff --git a/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2_0/util/PredicateUtil.java b/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2_0/util/PredicateUtil.java deleted file mode 100644 index 95ede8f..0000000 --- a/apis/openstack-neutron/src/test/java/org/jclouds/openstack/neutron/v2_0/util/PredicateUtil.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.openstack.neutron.v2_0.util; - -import com.google.common.base.Predicate; -import org.jclouds.javax.annotation.Nullable; - -import java.lang.reflect.Field; - -public class PredicateUtil { - - public static <T> Predicate<T> createIdEqualsPredicate(final String id) { - return new Predicate<T>() { - @Override - public boolean apply(@Nullable T input) { - if (input == null) return false; - - try { - Class clazz = input.getClass(); - Field field = ClassUtil.findField(clazz, "id"); - field.setAccessible(true); - String value = (String) field.get(input); - field.setAccessible(false); - return value != null && value.equals(id); - } catch (IllegalAccessException iae) { - return false; - } - } - }; - } - -}
