http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/test/java/org/jclouds/profitbricks/features/StorageApiMockTest.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/test/java/org/jclouds/profitbricks/features/StorageApiMockTest.java b/profitbricks/src/test/java/org/jclouds/profitbricks/features/StorageApiMockTest.java deleted file mode 100644 index 10a4a49..0000000 --- a/profitbricks/src/test/java/org/jclouds/profitbricks/features/StorageApiMockTest.java +++ /dev/null @@ -1,285 +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.features; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; - -import java.util.List; - -import org.jclouds.profitbricks.ProfitBricksApi; -import org.jclouds.profitbricks.domain.Storage; -import org.jclouds.profitbricks.internal.BaseProfitBricksMockTest; -import org.testng.annotations.Test; - -import com.squareup.okhttp.mockwebserver.MockResponse; -import com.squareup.okhttp.mockwebserver.MockWebServer; - -@Test(groups = "unit", testName = "StorageApiMockTest") -public class StorageApiMockTest extends BaseProfitBricksMockTest { - - @Test - public void testGetAllStorages() throws Exception { - MockWebServer server = mockWebServer(); - server.enqueue(new MockResponse().setBody(payloadFromResource("/storage/storages.xml"))); - - ProfitBricksApi pbApi = api(server.getUrl(rootUrl)); - StorageApi api = pbApi.storageApi(); - - try { - List<Storage> storages = api.getAllStorages(); - assertRequestHasCommonProperties(server.takeRequest(), "<ws:getAllStorages/>"); - assertNotNull(storages); - assertTrue(storages.size() == 2); - } finally { - pbApi.close(); - server.shutdown(); - } - } - - @Test - public void testGetAllStoragesReturning404() throws Exception { - MockWebServer server = mockWebServer(); - server.enqueue(new MockResponse().setResponseCode(404)); - - ProfitBricksApi pbApi = api(server.getUrl(rootUrl)); - StorageApi api = pbApi.storageApi(); - - try { - List<Storage> storages = api.getAllStorages(); - assertRequestHasCommonProperties(server.takeRequest()); - assertTrue(storages.isEmpty()); - } finally { - pbApi.close(); - server.shutdown(); - } - } - - @Test - public void testGetStorage() throws Exception { - MockWebServer server = mockWebServer(); - server.enqueue(new MockResponse().setBody(payloadFromResource("/storage/storage.xml"))); - - ProfitBricksApi pbApi = api(server.getUrl(rootUrl)); - StorageApi api = pbApi.storageApi(); - - String id = "qswdefrg-qaws-qaws-defe-rgrgdsvcxbrh"; - - String content = "<ws:getStorage><storageId>" + id + "</storageId></ws:getStorage>"; - try { - Storage storage = api.getStorage(id); - assertRequestHasCommonProperties(server.takeRequest(), content); - assertNotNull(storage); - assertEquals(storage.id(), id); - } finally { - pbApi.close(); - server.shutdown(); - } - } - - @Test - public void testGetNonExistingStorage() throws Exception { - MockWebServer server = mockWebServer(); - server.enqueue(new MockResponse().setResponseCode(404)); - - ProfitBricksApi pbApi = api(server.getUrl(rootUrl)); - StorageApi api = pbApi.storageApi(); - - String id = "random-non-existing-id"; - try { - Storage storage = api.getStorage(id); - assertRequestHasCommonProperties(server.takeRequest()); - assertNull(storage); - } finally { - pbApi.close(); - server.shutdown(); - } - } - - @Test - public void testConnectStorageToServer() throws Exception { - MockWebServer server = mockWebServer(); - server.enqueue(new MockResponse().setBody(payloadFromResource("/storage/storage-connect.xml"))); - - ProfitBricksApi pbApi = api(server.getUrl(rootUrl)); - StorageApi api = pbApi.storageApi(); - - String storageId = "qswdefrg-qaws-qaws-defe-rgrgdsvcxbrh"; - String serverId = "qwertyui-qwer-qwer-qwer-qwertyyuiiop"; - - String content = "<ws:connectStorageToServer><request>" - + "<storageId>" + storageId + "</storageId>" - + "<serverId>" + serverId + "</serverId>" - + "<busType>VIRTIO</busType>" - + "<deviceNumber>2</deviceNumber>" - + "</request></ws:connectStorageToServer>"; - try { - String requestId = api.connectStorageToServer( - Storage.Request.connectingBuilder() - .serverId(serverId) - .storageId(storageId) - .busType(Storage.BusType.VIRTIO) - .deviceNumber(2) - .build() - ); - assertRequestHasCommonProperties(server.takeRequest(), content); - assertEquals(requestId, "16463317"); - } finally { - pbApi.close(); - server.shutdown(); - } - } - - @Test - public void testDisconnectStorageFromServer() throws Exception { - MockWebServer server = mockWebServer(); - server.enqueue(new MockResponse().setBody(payloadFromResource("/storage/storage-disconnect.xml"))); - - ProfitBricksApi pbApi = api(server.getUrl(rootUrl)); - StorageApi api = pbApi.storageApi(); - - String storageId = "qswdefrg-qaws-qaws-defe-rgrgdsvcxbrh"; - String serverId = "qwertyui-qwer-qwer-qwer-qwertyyuiiop"; - - String content = "<ws:disconnectStorageFromServer>" - + "<storageId>" + storageId + "</storageId>" - + "<serverId>" + serverId + "</serverId>" - + "</ws:disconnectStorageFromServer>"; - - try { - String requestId = api.disconnectStorageFromServer(storageId, serverId); - assertRequestHasCommonProperties(server.takeRequest(), content); - assertEquals(requestId, "16463318"); - } finally { - pbApi.close(); - server.shutdown(); - } - } - - @Test - public void testCreateStorage() throws Exception { - MockWebServer server = mockWebServer(); - server.enqueue(new MockResponse().setBody(payloadFromResource("/storage/storage-create.xml"))); - - ProfitBricksApi pbApi = api(server.getUrl(rootUrl)); - StorageApi api = pbApi.storageApi(); - - String dataCenterId = "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"; - String imageId = "f0a59a5c-7940-11e4-8053-52540066fee9"; - - String content = "<ws:createStorage><request>" - + "<dataCenterId>" + dataCenterId + "</dataCenterId>" - + "<storageName>hdd-1</storageName>" + "<size>80</size>" - + "<mountImageId>" + imageId + "</mountImageId>" - + "<profitBricksImagePassword>qqqqqqqqq</profitBricksImagePassword>" - + "</request></ws:createStorage>"; - try { - String storageId = api.createStorage( - Storage.Request.creatingBuilder() - .dataCenterId(dataCenterId) - .name("hdd-1") - .size(80f) - .mountImageId(imageId) - .imagePassword("qqqqqqqqq") - .build()); - assertRequestHasCommonProperties(server.takeRequest(), content); - assertNotNull(storageId); - assertEquals(storageId, "qswdefrg-qaws-qaws-defe-rgrgdsvcxbrh"); - } finally { - pbApi.close(); - server.shutdown(); - } - } - - @Test - public void testUpdateStorage() throws Exception { - MockWebServer server = mockWebServer(); - server.enqueue(new MockResponse().setBody(payloadFromResource("/storage/storage-update.xml"))); - - ProfitBricksApi pbApi = api(server.getUrl(rootUrl)); - StorageApi api = pbApi.storageApi(); - - String storageId = "qswdefrg-qaws-qaws-defe-rgrgdsvcxbrh"; - String imageId = "f4742db0-9160-11e4-9d74-52540066fee9"; - - String content = "<ws:updateStorage><request>" - + "<storageId>" + storageId + "</storageId>" - + "<size>20</size><storageName>hdd-2</storageName>" - + "<mountImageId>" + imageId + "</mountImageId>" - + "</request></ws:updateStorage>"; - try { - String requestId = api.updateStorage( - Storage.Request.updatingBuilder() - .id(storageId) - .size(20f) - .name("hdd-2") - .mountImageId(imageId) - .build()); - - assertRequestHasCommonProperties(server.takeRequest(), content); - assertNotNull(requestId); - assertEquals(requestId, "1234568"); - } finally { - pbApi.close(); - server.shutdown(); - } - } - - @Test - public void testDeleteStorage() throws Exception { - MockWebServer server = mockWebServer(); - server.enqueue(new MockResponse().setBody(payloadFromResource("/storage/storage-delete.xml"))); - - ProfitBricksApi pbApi = api(server.getUrl(rootUrl)); - StorageApi api = pbApi.storageApi(); - - String storageId = "qswdefrg-qaws-qaws-defe-rgrgdsvcxbrh"; - - String content = "<ws:deleteStorage><storageId>" + storageId + "</storageId></ws:deleteStorage>"; - - try { - boolean result = api.deleteStorage(storageId); - assertRequestHasCommonProperties(server.takeRequest(), content); - assertTrue(result); - } finally { - pbApi.close(); - server.shutdown(); - } - } - - @Test - public void testDeleteNonExistingStorage() throws Exception { - MockWebServer server = mockWebServer(); - server.enqueue(new MockResponse().setResponseCode(404)); - - ProfitBricksApi pbApi = api(server.getUrl(rootUrl)); - StorageApi api = pbApi.storageApi(); - - String id = "random-non-existing-id"; - try { - boolean result = api.deleteStorage(id); - assertRequestHasCommonProperties(server.takeRequest()); - assertFalse(result); - } finally { - pbApi.close(); - server.shutdown(); - } - } -}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/test/java/org/jclouds/profitbricks/http/ResponseStatusFromPayloadHttpCommandExecutorServiceTest.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/test/java/org/jclouds/profitbricks/http/ResponseStatusFromPayloadHttpCommandExecutorServiceTest.java b/profitbricks/src/test/java/org/jclouds/profitbricks/http/ResponseStatusFromPayloadHttpCommandExecutorServiceTest.java deleted file mode 100644 index bb92109..0000000 --- a/profitbricks/src/test/java/org/jclouds/profitbricks/http/ResponseStatusFromPayloadHttpCommandExecutorServiceTest.java +++ /dev/null @@ -1,149 +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.http; - -import static org.jclouds.profitbricks.internal.BaseProfitBricksMockTest.mockWebServer; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; - -import org.jclouds.http.HttpResponseException; -import org.jclouds.profitbricks.ProfitBricksApi; -import org.jclouds.profitbricks.domain.DataCenter; -import org.jclouds.profitbricks.domain.Location; -import org.jclouds.profitbricks.domain.Server; -import org.jclouds.profitbricks.features.DataCenterApi; -import org.jclouds.profitbricks.features.ServerApi; -import org.jclouds.profitbricks.internal.BaseProfitBricksMockTest; -import org.jclouds.rest.AuthorizationException; -import org.jclouds.rest.InsufficientResourcesException; -import org.jclouds.rest.ResourceNotFoundException; -import org.testng.annotations.Test; - -import com.squareup.okhttp.mockwebserver.MockResponse; -import com.squareup.okhttp.mockwebserver.MockWebServer; - -/** - * Mock tests for the {@link ResponseStatusFromPayloadHttpCommandExecutorService} class. - */ -@Test(groups = "unit", testName = "ResponseStatusFromPayloadHttpCommandExecutorServiceTest") -public class ResponseStatusFromPayloadHttpCommandExecutorServiceTest extends BaseProfitBricksMockTest { - - private final int MAX_RETRIES = 5; - - @Test - public void testNotFound() throws Exception { - MockWebServer server = mockWebServer(); - server.enqueue(new MockResponse().setResponseCode(500).setBody(payloadFromResource("/fault-404.xml"))); - - ProfitBricksApi pbApi = api(server.getUrl("/")); - DataCenterApi api = pbApi.dataCenterApi(); - - String id = "random-non-existing-id"; - try { - api.clearDataCenter(id); - fail("Request should have failed"); - } catch (Exception ex) { - assertTrue(ex instanceof ResourceNotFoundException, "Exception should be an ResourceNotFoundException"); - } finally { - pbApi.close(); - server.shutdown(); - } - } - - @Test - public void testBadRequest() throws Exception { - MockWebServer server = mockWebServer(); - server.enqueue(new MockResponse().setResponseCode(500).setBody(payloadFromResource("/fault-400.xml"))); - - ProfitBricksApi pbApi = api(server.getUrl("/")); - DataCenterApi api = pbApi.dataCenterApi(); - - try { - api.createDataCenter(DataCenter.Request.creatingPayload("D@tacenter", Location.DE_FKB)); - fail("Request should have failed"); - } catch (Exception ex) { - assertTrue(ex instanceof IllegalArgumentException, "Exception should be an IllegalArgumentException"); - } finally { - pbApi.close(); - server.shutdown(); - } - } - - @Test - public void testUnauthorized() throws Exception { - MockWebServer server = mockWebServer(); - server.enqueue(new MockResponse().setResponseCode(401).setBody(payloadFromResource("/fault-401.html"))); - - ProfitBricksApi pbApi = api(server.getUrl("/")); - DataCenterApi api = pbApi.dataCenterApi(); - - try { - api.clearDataCenter("some-datacenter-id"); - fail("Request should have failed"); - } catch (Exception ex) { - assertTrue(ex instanceof AuthorizationException, "Exception should be an AuthorizationException"); - } finally { - pbApi.close(); - server.shutdown(); - } - } - - @Test - public void testOverLimitSettings() throws Exception { - MockWebServer server = mockWebServer(); - server.enqueue(new MockResponse().setResponseCode(503).setBody(payloadFromResource("/fault-413.xml"))); - - ProfitBricksApi pbApi = api(server.getUrl("/")); - ServerApi api = pbApi.serverApi(); - - try { - api.createServer( - Server.Request.creatingBuilder() - .dataCenterId("some-datacenter-id") - .name("node1") - .cores(99) - .ram(12800) - .build()); - fail("Request should have failed."); - } catch (Exception ex) { - assertTrue(ex instanceof InsufficientResourcesException, "Exception should be InsufficientResourcesException"); - } finally { - pbApi.close(); - server.shutdown(); - } - } - - @Test - public void testServiceUnderMaintenance() throws Exception { - MockWebServer server = mockWebServer(); - for (int i = 0; i <= MAX_RETRIES; i++) // jclouds retries 5 times - server.enqueue(new MockResponse().setResponseCode(503).setBody(payloadFromResource("/maintenance-503.html"))); - - ProfitBricksApi pbApi = api(server.getUrl("/")); - DataCenterApi api = pbApi.dataCenterApi(); - - try { - api.clearDataCenter("some-datacenter-id"); - fail("Request should have failed."); - } catch (Exception ex) { - assertTrue(ex instanceof HttpResponseException, "Exception should be HttpResponseException"); - } finally { - pbApi.close(); - server.shutdown(); - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/test/java/org/jclouds/profitbricks/http/filters/ProfitBricksSoapMessageEnvelopeTest.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/test/java/org/jclouds/profitbricks/http/filters/ProfitBricksSoapMessageEnvelopeTest.java b/profitbricks/src/test/java/org/jclouds/profitbricks/http/filters/ProfitBricksSoapMessageEnvelopeTest.java deleted file mode 100644 index f6892b7..0000000 --- a/profitbricks/src/test/java/org/jclouds/profitbricks/http/filters/ProfitBricksSoapMessageEnvelopeTest.java +++ /dev/null @@ -1,57 +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.http.filters; - -import static org.testng.Assert.assertEquals; - -import org.jclouds.http.HttpRequest; -import org.testng.annotations.Test; - -/** - * Unit tests for the {@link ProfitBricksSoapMessageEnvelope} class. - */ -@Test(groups = "unit", testName = "ProfitBricksSoapMessageEnvelopeTest") -public class ProfitBricksSoapMessageEnvelopeTest { - - private final String SOAP_PREFIX - = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ws=\"http://ws.api.profitbricks.com/\">" - + "<soapenv:Header/>" - + "<soapenv:Body>"; - private final String SOAP_SUFFIX = "</soapenv:Body></soapenv:Envelope>"; - private final String endpoint = "https://api.profitbricks.com/1.3"; - - @Test - public void testPayloadEnclosedWithSoapTags() { - String requestBody = "<ws:getAllDataCenters/>"; - String expectedPayload = SOAP_PREFIX.concat(requestBody).concat(SOAP_SUFFIX); - - HttpRequest request = HttpRequest.builder().method("POST").endpoint(endpoint).payload(requestBody).build(); - - ProfitBricksSoapMessageEnvelope soapEnvelope = new ProfitBricksSoapMessageEnvelope(); - HttpRequest filtered = soapEnvelope.filter(request); - - assertEquals(filtered.getPayload().getRawContent(), expectedPayload); - assertEquals(filtered.getPayload().getContentMetadata().getContentLength(), Long.valueOf(expectedPayload.getBytes().length)); - } - - @Test(expectedExceptions = NullPointerException.class, expectedExceptionsMessageRegExp = ".*must contain payload message.*") - public void testNullRequest() { - HttpRequest request = HttpRequest.builder().method("POST").endpoint(endpoint).build(); - new ProfitBricksSoapMessageEnvelope().filter(request); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/BaseResponseHandlerTest.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/BaseResponseHandlerTest.java b/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/BaseResponseHandlerTest.java deleted file mode 100644 index d481735..0000000 --- a/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/BaseResponseHandlerTest.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.http.parser; - -import static org.jclouds.util.Strings2.toStringAndClose; - -import java.io.IOException; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.http.functions.config.SaxParserModule; -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.testng.annotations.AfterTest; -import org.testng.annotations.BeforeTest; - -import com.google.common.base.Throwables; -import com.google.inject.Guice; -import com.google.inject.Injector; - -public abstract class BaseResponseHandlerTest<T> { - - protected Injector injector = null; - protected ParseSax.Factory factory; - protected GeneratedHttpRequest request; - - protected abstract ParseSax<T> createParser(); - - @BeforeTest - protected void setUpInjector() { - injector = Guice.createInjector(new SaxParserModule()); - factory = injector.getInstance(ParseSax.Factory.class); - assert factory != null; - } - - protected String payloadFromResource(String resource) { - try { - return toStringAndClose(getClass().getResourceAsStream(resource)); - } catch (IOException e) { - throw Throwables.propagate(e); - } - } - - @AfterTest - protected void tearDownInjector() { - factory = null; - injector = null; - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/RequestIdOnlyResponseHandlerTest.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/RequestIdOnlyResponseHandlerTest.java b/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/RequestIdOnlyResponseHandlerTest.java deleted file mode 100644 index 3ea9ed8..0000000 --- a/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/RequestIdOnlyResponseHandlerTest.java +++ /dev/null @@ -1,76 +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.http.parser; - -import org.jclouds.http.functions.ParseSax; -import static org.testng.Assert.assertEquals; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "RequestIdOnlyResponseHandlerTest") -public class RequestIdOnlyResponseHandlerTest extends BaseResponseHandlerTest<String> { - - @Override - protected ParseSax<String> createParser() { - return factory.create(injector.getInstance(RequestIdOnlyResponseHandler.class)); - } - - @Test - public void testParseResponseFromStartServer() { - ParseSax<String> parser = createParser(); - - String requestId = parser.parse(payloadFromResource("/server/server-start.xml")); - - assertEquals(requestId, "123456"); - } - - @Test - public void testParseResponseFromStopServer() { - ParseSax<String> parser = createParser(); - - String requestId = parser.parse(payloadFromResource("/server/server-stop.xml")); - - assertEquals(requestId, "123456"); - } - - @Test - public void testParseResponseFromResetServer() { - ParseSax<String> parser = createParser(); - - String requestId = parser.parse(payloadFromResource("/server/server-reset.xml")); - - assertEquals(requestId, "123456"); - } - - @Test - public void testParseResponseFromUpdateServer() { - ParseSax<String> parser = createParser(); - - String requestId = parser.parse(payloadFromResource("/server/server-update.xml")); - - assertEquals(requestId, "102458"); - } - - @Test - public void testParseResponseFromDeleteServer() { - ParseSax<String> parser = createParser(); - - String requestId = parser.parse(payloadFromResource("/server/server-delete.xml")); - - assertEquals(requestId, "102459"); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/ServiceFaultResponseHandlerTest.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/ServiceFaultResponseHandlerTest.java b/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/ServiceFaultResponseHandlerTest.java deleted file mode 100644 index 2b54dd5..0000000 --- a/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/ServiceFaultResponseHandlerTest.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.http.parser; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.profitbricks.domain.ServiceFault; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "ServiceFaultResponseHandlerTest") -public class ServiceFaultResponseHandlerTest extends BaseResponseHandlerTest<ServiceFault> { - - @Override - protected ParseSax<ServiceFault> createParser() { - return factory.create(injector.getInstance(ServiceFaultResponseHandler.class)); - } - - @Test - public void testParseSoapServiceFault() { - ParseSax<ServiceFault> parser = createParser(); - ServiceFault actual = parser.parse(payloadFromResource("/fault-404.xml")); - assertNotNull(actual, "Parsed content returned null"); - - ServiceFault expected = ServiceFault.builder() - .faultCode(ServiceFault.FaultCode.RESOURCE_NOT_FOUND) - .httpCode(404) - .message("The requested resource could not be found. Please refer to Request Id : 16370720. [VDC-6-404] The requested resource does not exist or already deleted by the users. ResourceId random-non-existing-id") - .requestId(16370720) - .build(); - - assertEquals(expected, actual); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/datacenter/DataCenterInfoResponseHandlerTest.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/datacenter/DataCenterInfoResponseHandlerTest.java b/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/datacenter/DataCenterInfoResponseHandlerTest.java deleted file mode 100644 index 3cb15a5..0000000 --- a/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/datacenter/DataCenterInfoResponseHandlerTest.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.profitbricks.http.parser.datacenter; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import org.jclouds.date.DateService; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.profitbricks.domain.AvailabilityZone; -import org.jclouds.profitbricks.domain.DataCenter; -import org.jclouds.profitbricks.domain.Firewall; -import org.jclouds.profitbricks.domain.Location; -import org.jclouds.profitbricks.domain.Nic; -import org.jclouds.profitbricks.domain.OsType; -import org.jclouds.profitbricks.domain.ProvisioningState; -import org.jclouds.profitbricks.domain.Server; -import org.jclouds.profitbricks.domain.Storage; -import org.jclouds.profitbricks.http.parser.BaseResponseHandlerTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; - -@Test(groups = "unit", testName = "DataCenterInfoResponseHandlerTest") -public class DataCenterInfoResponseHandlerTest extends BaseResponseHandlerTest<DataCenter> { - - @Override - protected ParseSax<DataCenter> createParser() { - return factory.create(injector.getInstance(DataCenterInfoResponseHandler.class)); - } - - protected DateService createDateParser() { - return injector.getInstance(DateService.class); - } - - @Test - public void testParseResponseFromGetDataCenter() { - ParseSax<DataCenter> parser = createParser(); - - DataCenter actual = parser.parse(payloadFromResource("/datacenter/datacenter.xml")); - assertNotNull(actual, "Parsed content returned null"); - - DateService dateParser = createDateParser(); - - DataCenter expected = DataCenter.builder() - .id("12345678-abcd-efgh-ijkl-987654321000") - .version(10) - .name("JClouds-DC") - .state(ProvisioningState.AVAILABLE) - .location(Location.US_LAS) - .servers(ImmutableList.<Server>of( - Server.builder() - .dataCenter(DataCenter.builder() - .id("12345678-abcd-efgh-ijkl-987654321000") - .version(10) - .build() - ) - .id("qqqqqqqq-wwww-eeee-rrrr-tttttttttttt") - .name("jnode1") - .cores(4) - .ram(4096) - .hasInternetAccess(true) - .state(ProvisioningState.AVAILABLE) - .status(Server.Status.RUNNING) - .creationTime(dateParser.iso8601DateOrSecondsDateParse("2014-12-04T07:09:23.138Z")) - .lastModificationTime(dateParser.iso8601DateOrSecondsDateParse("2014-12-12T03:08:35.629Z")) - .osType(OsType.LINUX) - .availabilityZone(AvailabilityZone.AUTO) - .isCpuHotPlug(true) - .isRamHotPlug(true) - .isNicHotPlug(true) - .isNicHotUnPlug(true) - .isDiscVirtioHotPlug(true) - .isDiscVirtioHotUnPlug(true) - .storages(ImmutableList.<Storage>of( - Storage.builder() - .bootDevice(Boolean.TRUE) - .id("ssssssss-aaaa-ffff-gggg-hhhhhhhhhhhh") - .busType(Storage.BusType.VIRTIO) - .deviceNumber(1) - .size(40f) - .name("jnode1-disk1") - .build() - ) - ) - .nics(ImmutableList.<Nic>of( - Nic.builder() - .dataCenterId("12345678-abcd-efgh-ijkl-987654321000") - .id("zzzzzzzz-xxxx-cccc-vvvv-bbbbbbbbbbbb") - .lanId(1) - .internetAccess(true) - .serverId("qqqqqqqq-wwww-eeee-rrrr-tttttttttttt") - .ips(ImmutableList.of("202.94.38.12")) - .macAddress("02:01:09:cd:f0:b0") - .firewall( - Firewall.builder() - .active(false) - .id("llllllll-kkkk-jjjj-hhhh-gggggggggggg") - .nicId("zzzzzzzz-xxxx-cccc-vvvv-bbbbbbbbbbbb") - .state(ProvisioningState.AVAILABLE) - .build() - ) - .dhcpActive(true) - .gatewayIp("202.94.38.1") - .state(ProvisioningState.AVAILABLE) - .build() - ) - ) - .build() - ) - ) - .storages(ImmutableList.<Storage>of( - Storage.builder() - .id("ssssssss-aaaa-ffff-gggg-hhhhhhhhhhhh") - .size(40) - .name("jnode1-disk1") - .state(ProvisioningState.AVAILABLE) - .creationTime(dateParser.iso8601DateOrSecondsDateParse("2014-12-04T07:09:23.138Z")) - .lastModificationTime(dateParser.iso8601DateOrSecondsDateParse("2014-12-12T03:14:48.316Z")) - .serverIds(ImmutableList.of( - "qqqqqqqq-wwww-eeee-rrrr-tttttttttttt" - )) - .build() - )) - .build(); - assertEquals(actual, expected); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/datacenter/DataCenterListResponseHandlerTest.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/datacenter/DataCenterListResponseHandlerTest.java b/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/datacenter/DataCenterListResponseHandlerTest.java deleted file mode 100644 index 7e738ae..0000000 --- a/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/datacenter/DataCenterListResponseHandlerTest.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.http.parser.datacenter; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import java.util.List; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.profitbricks.domain.DataCenter; -import org.jclouds.profitbricks.domain.ProvisioningState; -import org.jclouds.profitbricks.http.parser.BaseResponseHandlerTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; - -@Test(groups = "unit", testName = "DataCenterListResponseHandlerTest") -public class DataCenterListResponseHandlerTest extends BaseResponseHandlerTest<List<DataCenter>> { - - @Override - protected ParseSax<List<DataCenter>> createParser() { - return factory.create(injector.getInstance(DataCenterListResponseHandler.class)); - } - - @Test - public void testParseResponseFromGetAllDataCenter() { - ParseSax<List<DataCenter>> parser = createParser(); - - List<DataCenter> actual = parser.parse(payloadFromResource("/datacenter/datacenters.xml")); - assertNotNull(actual, "Parsed content returned null"); - - List<DataCenter> expected = ImmutableList.<DataCenter>of( - DataCenter.builder().id("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee").name("JClouds-DC").version(10).state(ProvisioningState.AVAILABLE).build(), - DataCenter.builder().id("qqqqqqqq-wwww-rrrr-tttt-yyyyyyyyyyyy").name("Random DC").version(238).state(ProvisioningState.INPROCESS).build() - ); - assertEquals(expected, actual); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/firewall/FirewallListResponseHandlerTest.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/firewall/FirewallListResponseHandlerTest.java b/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/firewall/FirewallListResponseHandlerTest.java deleted file mode 100644 index a5fc74d..0000000 --- a/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/firewall/FirewallListResponseHandlerTest.java +++ /dev/null @@ -1,87 +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.http.parser.firewall; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import java.util.List; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.profitbricks.domain.Firewall; -import org.jclouds.profitbricks.domain.ProvisioningState; -import org.jclouds.profitbricks.http.parser.BaseResponseHandlerTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; - -@Test(groups = "unit", testName = "FirewallListResponseHandlerTest") -public class FirewallListResponseHandlerTest extends BaseResponseHandlerTest<List<Firewall>> { - - @Override - protected ParseSax<List<Firewall>> createParser() { - return factory.create(injector.getInstance(FirewallListResponseHandler.class)); - } - - @Test - public void testParseResponseFromGetAllFirewalls() { - ParseSax<List<Firewall>> parser = createParser(); - List<Firewall> actual = parser.parse(payloadFromResource("/firewall/firewalls.xml")); - assertNotNull(actual, "Parsed content returned null"); - - List<Firewall> expected = ImmutableList.of( - Firewall.builder() - .active(true) - .id("firewall-id") - .nicId("nic-id") - .state(ProvisioningState.AVAILABLE) - .rules(ImmutableList.of( - Firewall.Rule.builder() - .id("firewall-rule-id") - .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() - )) - .build(), - Firewall.builder() - .active(true) - .id("firewall-id2") - .nicId("nic-id") - .state(ProvisioningState.AVAILABLE) - .rules(ImmutableList.of( - Firewall.Rule.builder() - .id("firewall-rule-id2") - .name("name") - .portRangeEnd(56789) - .portRangeStart(23456) - .protocol(Firewall.Protocol.TCP) - .sourceIp("192.168.0.2") - .sourceMac("aa:bb:cc:dd:ee:ff") - .targetIp("192.168.0.3") - .build() - )) - .build() - ); - - assertEquals(actual, expected); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/firewall/FirewallResponseHandlerTest.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/firewall/FirewallResponseHandlerTest.java b/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/firewall/FirewallResponseHandlerTest.java deleted file mode 100644 index eeb4cba..0000000 --- a/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/firewall/FirewallResponseHandlerTest.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.profitbricks.http.parser.firewall; - -import java.util.List; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.profitbricks.domain.Firewall; -import org.jclouds.profitbricks.domain.ProvisioningState; -import org.jclouds.profitbricks.http.parser.BaseResponseHandlerTest; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import org.jclouds.profitbricks.domain.Firewall.Protocol; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; - -@Test(groups = "unit", testName = "FirewallResponseHandlerTest") -public class FirewallResponseHandlerTest extends BaseResponseHandlerTest<Firewall> { - - @Override - protected ParseSax<Firewall> createParser() { - return factory.create(injector.getInstance(FirewallResponseHandler.class)); - } - - @Test - public void testParseResponseFromGetFirewall() { - ParseSax<Firewall> parser = createParser(); - Firewall actual = parser.parse(payloadFromResource("/firewall/firewall.xml")); - assertNotNull(actual, "Parsed content returned null"); - List<Firewall.Rule> firewallRules = ImmutableList.of( - Firewall.Rule.builder() - .id("firewall-rule-id") - .name("name") - .portRangeEnd(45678) - .portRangeStart(12345) - .protocol(Protocol.TCP) - .sourceIp("192.168.0.1") - .sourceMac("aa:bb:cc:dd:ee:ff") - .targetIp("192.168.0.2") - .build()); - - Firewall expected = Firewall.builder() - .active(true) - .id("firewall-id") - .nicId("nic-id") - .state(ProvisioningState.AVAILABLE) - .rules(firewallRules) - .build(); - - assertEquals(expected, actual); - - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/image/ImageInfoResponseHandlerTest.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/image/ImageInfoResponseHandlerTest.java b/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/image/ImageInfoResponseHandlerTest.java deleted file mode 100644 index fb2e33d..0000000 --- a/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/image/ImageInfoResponseHandlerTest.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.http.parser.image; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.profitbricks.domain.Image; -import org.jclouds.profitbricks.domain.Location; -import org.jclouds.profitbricks.domain.OsType; -import org.jclouds.profitbricks.http.parser.BaseResponseHandlerTest; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "ImageInfoResponseHandlerTest") -public class ImageInfoResponseHandlerTest extends BaseResponseHandlerTest<Image> { - - @Override - protected ParseSax<Image> createParser() { - return factory.create(injector.getInstance(ImageInfoResponseHandler.class)); - } - - @Test - public void testParseResponseFromGetImage() { - ParseSax<Image> parser = createParser(); - Image actual = parser.parse(payloadFromResource("/image/image.xml")); - assertNotNull(actual, "Parsed content returned null"); - - Image expected = Image.builder() - .isBootable(true) - .isCpuHotPlug(true) - .isCpuHotUnPlug(false) - .isDiscVirtioHotPlug(true) - .isDiscVirtioHotUnPlug(true) - .id("5ad99c9e-9166-11e4-9d74-52540066fee9") - .name("Ubuntu-14.04-LTS-server-2015-01-01") - .size(2048f) - .type(Image.Type.HDD) - .location(Location.US_LAS) - .isNicHotPlug(true) - .isNicHotUnPlug(true) - .osType(OsType.LINUX) - .isPublic(true) - .isRamHotPlug(true) - .isRamHotUnPlug(false) - .isWriteable(true) - .build(); - - assertEquals(expected, actual); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/image/ImageListResponseHandlerTest.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/image/ImageListResponseHandlerTest.java b/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/image/ImageListResponseHandlerTest.java deleted file mode 100644 index e954fb0..0000000 --- a/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/image/ImageListResponseHandlerTest.java +++ /dev/null @@ -1,183 +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.http.parser.image; - -import com.google.common.collect.ImmutableList; -import java.util.List; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.profitbricks.domain.Image; -import org.jclouds.profitbricks.domain.Location; -import org.jclouds.profitbricks.domain.OsType; -import org.jclouds.profitbricks.http.parser.BaseResponseHandlerTest; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "ImageListResponseHandlerTest") -public class ImageListResponseHandlerTest extends BaseResponseHandlerTest<List<Image>> { - - @Override - protected ParseSax<List<Image>> createParser() { - return factory.create(injector.getInstance(ImageListResponseHandler.class)); - } - - @Test - public void testParseResponseFromGetAllImages() { - ParseSax<List<Image>> parser = createParser(); - - List<Image> actual = parser.parse(payloadFromResource("/image/images.xml")); - assertNotNull(actual, "Parsed content returned null"); - - List<Image> expected = ImmutableList.<Image>of( - Image.builder() - .isBootable(true) - .isCpuHotPlug(true) - .isCpuHotUnPlug(false) - .isDiscVirtioHotPlug(true) - .isDiscVirtioHotUnPlug(true) - .id("e4f73936-9161-11e4-9d74-52540066fee9") - .name("Ubuntu-12.04-LTS-server-2015-01-01") - .size(2048f) - .type(Image.Type.HDD) - .location(Location.DE_FRA) - .isNicHotPlug(true) - .isNicHotUnPlug(true) - .osType(OsType.LINUX) - .isPublic(true) - .isRamHotPlug(true) - .isRamHotUnPlug(false) - .isWriteable(true) - .build(), - Image.builder() - .isBootable(true) - .isCpuHotPlug(true) - .isCpuHotUnPlug(false) - .isDiscVirtioHotPlug(true) - .isDiscVirtioHotUnPlug(true) - .id("a984a5d3-9163-11e4-9d74-52540066fee9") - .name("Ubuntu-14.04-LTS-server-2015-01-01") - .size(2048f) - .type(Image.Type.HDD) - .location(Location.DE_FRA) - .isNicHotPlug(true) - .isNicHotUnPlug(true) - .osType(OsType.LINUX) - .isPublic(true) - .isRamHotPlug(true) - .isRamHotUnPlug(false) - .isWriteable(true) - .build(), - Image.builder() - .isBootable(true) - .isCpuHotPlug(true) - .isCpuHotUnPlug(false) - .isDiscVirtioHotPlug(true) - .isDiscVirtioHotUnPlug(true) - .id("5f3cac96-915f-11e4-9d74-52540066fee9") - .name("Debian-jessie-prerelease-server-2015-01-01") - .size(2048f) - .type(Image.Type.HDD) - .location(Location.US_LASDEV) - .isNicHotPlug(true) - .isNicHotUnPlug(true) - .osType(OsType.LINUX) - .isPublic(true) - .isRamHotPlug(true) - .isRamHotUnPlug(false) - .isWriteable(true) - .build(), - Image.builder() - .isBootable(true) - .isCpuHotPlug(true) - .isCpuHotUnPlug(false) - .isDiscVirtioHotPlug(true) - .isDiscVirtioHotUnPlug(true) - .id("f4742db0-9160-11e4-9d74-52540066fee9") - .name("Fedora-19-server-2015-01-01") - .size(2048f) - .type(Image.Type.HDD) - .location(Location.US_LASDEV) - .isNicHotPlug(true) - .isNicHotUnPlug(true) - .osType(OsType.LINUX) - .isPublic(true) - .isRamHotPlug(true) - .isRamHotUnPlug(false) - .isWriteable(true) - .build(), - Image.builder() - .isBootable(true) - .isCpuHotPlug(true) - .isCpuHotUnPlug(false) - .isDiscVirtioHotPlug(true) - .isDiscVirtioHotUnPlug(true) - .id("86902c18-9164-11e4-9d74-52540066fee9") - .name("Ubuntu-12.04-LTS-server-2015-01-01") - .size(2048f) - .type(Image.Type.HDD) - .location(Location.US_LASDEV) - .isNicHotPlug(true) - .isNicHotUnPlug(true) - .osType(OsType.LINUX) - .isPublic(true) - .isRamHotPlug(true) - .isRamHotUnPlug(false) - .isWriteable(true) - .build(), - Image.builder() - .isBootable(true) - .isCpuHotPlug(true) - .isCpuHotUnPlug(false) - .isDiscVirtioHotPlug(true) - .isDiscVirtioHotUnPlug(true) - .id("3b48e3ff-9163-11e4-9d74-52540066fee9") - .name("Ubuntu-14.04-LTS-server-2015-01-01") - .size(2048f) - .type(Image.Type.HDD) - .location(Location.DE_FKB) - .isNicHotPlug(true) - .isNicHotUnPlug(true) - .osType(OsType.LINUX) - .isPublic(true) - .isRamHotPlug(true) - .isRamHotUnPlug(false) - .isWriteable(true) - .build(), - Image.builder() - .isBootable(true) - .isCpuHotPlug(true) - .isCpuHotUnPlug(false) - .isDiscVirtioHotPlug(true) - .isDiscVirtioHotUnPlug(true) - .id("6ce17716-9164-11e4-9d74-52540066fee9") - .name("Ubuntu-12.04-LTS-server-2015-01-01") - .size(2048f) - .type(Image.Type.HDD) - .location(Location.US_LAS) - .isNicHotPlug(true) - .isNicHotUnPlug(true) - .osType(OsType.LINUX) - .isPublic(true) - .isRamHotPlug(true) - .isRamHotUnPlug(false) - .isWriteable(true) - .build() - ); - - assertEquals(expected, actual); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/ipblock/IpBlockListResponseHandlerTest.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/ipblock/IpBlockListResponseHandlerTest.java b/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/ipblock/IpBlockListResponseHandlerTest.java deleted file mode 100644 index 1bd3518..0000000 --- a/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/ipblock/IpBlockListResponseHandlerTest.java +++ /dev/null @@ -1,76 +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.http.parser.ipblock; - -import com.google.common.collect.ImmutableList; -import java.util.List; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.profitbricks.domain.IpBlock; -import org.jclouds.profitbricks.domain.Location; -import org.jclouds.profitbricks.domain.IpBlock.PublicIp; -import org.jclouds.profitbricks.http.parser.BaseResponseHandlerTest; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "IpBlockListResponseHandlerTest") -public class IpBlockListResponseHandlerTest extends BaseResponseHandlerTest<List<IpBlock>> { - - @Override - protected ParseSax<List<IpBlock>> createParser() { - return factory.create(injector.getInstance(IpBlockListResponseHandler.class)); - } - - @Test - public void testParseResponseFromGetAllIpBlock() { - ParseSax<List<IpBlock>> parser = createParser(); - - List<IpBlock> actual = parser.parse(payloadFromResource("/ipblock/ipblocks.xml")); - assertNotNull(actual, "Parsed content returned null"); - - List<IpBlock> expected = ImmutableList.<IpBlock>of( - IpBlock.builder() - .id("block-id-1") - .location(Location.US_LAS) - .publicIps(ImmutableList.<PublicIp>of( - PublicIp.builder() - .ip("10.0.0.2") - .nicId("nic-id-1") - .build(), - PublicIp.builder() - .ip("10.0.0.3") - .nicId("nic-id-2") - .build())) - .build(), - IpBlock.builder() - .id("block-id-2") - .location(Location.US_LAS) - .publicIps(ImmutableList.<PublicIp>of( - PublicIp.builder() - .ip("10.0.0.4") - .build(), - PublicIp.builder() - .ip("10.0.0.5") - .nicId("nic-id-4") - .build())) - .build() - ); - - assertEquals(actual, expected); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/ipblock/IpBlockResponseHandlerTest.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/ipblock/IpBlockResponseHandlerTest.java b/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/ipblock/IpBlockResponseHandlerTest.java deleted file mode 100644 index 053f0ae..0000000 --- a/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/ipblock/IpBlockResponseHandlerTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.profitbricks.http.parser.ipblock; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; -import java.util.List; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.profitbricks.domain.IpBlock; -import org.jclouds.profitbricks.domain.Location; -import org.jclouds.profitbricks.domain.IpBlock.PublicIp; -import org.jclouds.profitbricks.http.parser.BaseResponseHandlerTest; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "IpBlockResponseHandlerTest") -public class IpBlockResponseHandlerTest extends BaseResponseHandlerTest<IpBlock> { - - @Override - protected ParseSax<IpBlock> createParser() { - return factory.create(injector.getInstance(IpBlockResponseHandler.class)); - } - - @Test - public void testParseResponseFromGetIpBlock() { - ParseSax<IpBlock> parser = createParser(); - - IpBlock actual = parser.parse(payloadFromResource("/ipblock/ipblock.xml")); - assertNotNull(actual, "Parsed content returned null"); - List<String> emptyIpList = Lists.newArrayList(); - - IpBlock expected = IpBlock.builder() - .id("qwertyui-qwer-qwer-qwer-qwertyyuiiop") - .location(Location.US_LAS) - .publicIps(ImmutableList.<PublicIp>of( - PublicIp.builder() - .ip("10.0.0.2") - .nicId("nic-id") - .build(), - PublicIp.builder() - .ip("10.0.0.3") - .build())) - .ips(emptyIpList) - .build(); - assertEquals(actual, expected); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/loadbalancer/LoadBalancerIdOnlyResponseHandlerTest.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/loadbalancer/LoadBalancerIdOnlyResponseHandlerTest.java b/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/loadbalancer/LoadBalancerIdOnlyResponseHandlerTest.java deleted file mode 100644 index 9aa18ef..0000000 --- a/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/loadbalancer/LoadBalancerIdOnlyResponseHandlerTest.java +++ /dev/null @@ -1,41 +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.http.parser.loadbalancer; - -import static org.testng.Assert.assertEquals; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.profitbricks.http.parser.BaseResponseHandlerTest; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "LoadBalancerIdOnlyResponseHandlerTest") -public class LoadBalancerIdOnlyResponseHandlerTest extends BaseResponseHandlerTest<String> { - - @Override - protected ParseSax<String> createParser() { - return factory.create(injector.getInstance(LoadBalancerIdOnlyResponseHandler.class)); - } - - @Test - public void testParseResponseFromCreateLoadBalancer() { - ParseSax<String> parser = createParser(); - - String loadBalancerId = parser.parse(payloadFromResource("/loadbalancer/loadbalancer-create.xml")); - - assertEquals("1234-1234-1234-1234", loadBalancerId); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/loadbalancer/LoadBalancerListResponseHandlerTest.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/loadbalancer/LoadBalancerListResponseHandlerTest.java b/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/loadbalancer/LoadBalancerListResponseHandlerTest.java deleted file mode 100644 index 3c9e082..0000000 --- a/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/loadbalancer/LoadBalancerListResponseHandlerTest.java +++ /dev/null @@ -1,124 +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.http.parser.loadbalancer; - -import com.google.common.collect.ImmutableList; - -import java.util.List; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.profitbricks.domain.Firewall; -import org.jclouds.profitbricks.domain.LoadBalancer; -import org.jclouds.profitbricks.domain.LoadBalancer.Algorithm; -import org.jclouds.profitbricks.domain.ProvisioningState; -import org.jclouds.profitbricks.domain.Server; -import org.jclouds.profitbricks.http.parser.BaseResponseHandlerTest; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import org.jclouds.date.DateService; -import org.jclouds.profitbricks.domain.DataCenter; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "LoadBalancerListResponseHandlerTest") -public class LoadBalancerListResponseHandlerTest extends BaseResponseHandlerTest<List<LoadBalancer>> { - - @Override - protected ParseSax<List<LoadBalancer>> createParser() { - return factory.create(injector.getInstance(LoadBalancerListResponseHandler.class)); - } - - protected DateService createDateParser() { - return injector.getInstance(DateService.class); - } - - @Test - public void testParseResponseFromGetAllLoadbalancer() { - ParseSax<List<LoadBalancer>> parser = createParser(); - - List<LoadBalancer> actual = parser.parse(payloadFromResource("/loadbalancer/loadbalancers.xml")); - assertNotNull(actual, "Parsed content returned null"); - - DateService dateParser = createDateParser(); - - List<LoadBalancer> expected = ImmutableList.<LoadBalancer>of( - LoadBalancer.builder() - .id("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .algorithm(Algorithm.ROUND_ROBIN) - .name("load-1234567890-name") - .dataCenter(DataCenter.builder() - .id("datacenter-id") - .version(4) - .build()) - .internetAccess(true) - .ip("192.168.0.1") - .lanId(1) - .state(ProvisioningState.AVAILABLE) - .creationTime(dateParser.iso8601DateOrSecondsDateParse("2014-12-04T07:09:23.138Z")) - .lastModificationTime(dateParser.iso8601DateOrSecondsDateParse("2014-12-04T07:09:23.138Z")) - .firewalls(ImmutableList.<Firewall>of( - Firewall.builder() - .id("firewall-id") - .nicId("nic-id") - .active(false) - .state(ProvisioningState.AVAILABLE) - .build() - )) - .balancedServers(ImmutableList.<Server>of( - Server.builder() - .loadBalanced(true) - .balancedNicId("balanced-nic-id") - .id("server-id") - .name("server-name") - .build() - )).build(), - LoadBalancer.builder() - .id("qqqqqqqq-wwww-rrrr-tttt-yyyyyyyyyyyy") - .algorithm(Algorithm.ROUND_ROBIN) - .name("load-balancer-name") - .dataCenter(DataCenter.builder() - .id("datacenter-id") - .version(4) - .build()) - .internetAccess(false) - .ip("192.168.0.1") - .lanId(2) - .state(ProvisioningState.AVAILABLE) - .creationTime(dateParser.iso8601DateOrSecondsDateParse("2014-12-04T07:09:23.138Z")) - .lastModificationTime(dateParser.iso8601DateOrSecondsDateParse("2014-12-04T07:09:23.138Z")) - .firewalls(ImmutableList.<Firewall>of( - Firewall.builder() - .id("firewall-id") - .nicId("nic-id") - .active(false) - .state(ProvisioningState.AVAILABLE) - .build() - )) - .balancedServers(ImmutableList.<Server>of( - Server.builder() - .loadBalanced(false) - .balancedNicId("balanced-nic-id") - .id("server-id") - .name("server-name") - .build() - )) - .build() - ); - assertEquals(actual, expected); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/loadbalancer/LoadBalancerResponseHandlerTest.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/loadbalancer/LoadBalancerResponseHandlerTest.java b/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/loadbalancer/LoadBalancerResponseHandlerTest.java deleted file mode 100644 index 0971e21..0000000 --- a/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/loadbalancer/LoadBalancerResponseHandlerTest.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.profitbricks.http.parser.loadbalancer; - -import com.google.common.collect.Lists; - -import java.util.List; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.profitbricks.domain.Firewall; -import org.jclouds.profitbricks.domain.LoadBalancer; -import org.jclouds.profitbricks.domain.LoadBalancer.Algorithm; -import org.jclouds.profitbricks.domain.ProvisioningState; -import org.jclouds.profitbricks.domain.Server; -import org.jclouds.profitbricks.domain.Storage; -import org.jclouds.profitbricks.http.parser.BaseResponseHandlerTest; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import org.jclouds.date.DateService; -import org.jclouds.profitbricks.domain.DataCenter; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "LoadBalancerResponseHandlerTest") -public class LoadBalancerResponseHandlerTest extends BaseResponseHandlerTest<LoadBalancer> { - - @Override - protected ParseSax<LoadBalancer> createParser() { - return factory.create(injector.getInstance(LoadBalancerResponseHandler.class)); - } - - protected DateService createDateParser() { - return injector.getInstance(DateService.class); - } - - @Test - public void testParseResponseFromGetLoadbalancer() { - ParseSax<LoadBalancer> parser = createParser(); - - LoadBalancer actual = parser.parse(payloadFromResource("/loadbalancer/loadbalancer.xml")); - assertNotNull(actual, "Parsed content returned null"); - - DateService dateParser = createDateParser(); - - List<Storage> emptyStorages = Lists.newArrayList(); - - List<Server> balancedServers = Lists.newArrayList(); - balancedServers.add(Server.builder() - .loadBalanced(true) - .balancedNicId("balanced-nic-id") - .id("server-id") - .name("server-name") - .storages(emptyStorages) - .build()); - List<Firewall> firewalls = Lists.newArrayList(); - firewalls.add(Firewall.builder() - .id("firewall-id") - .nicId("nic-id") - .active(false) - .state(ProvisioningState.AVAILABLE) - .build()); - - LoadBalancer expected = LoadBalancer.builder() - .id("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .algorithm(Algorithm.ROUND_ROBIN) - .name("load-balancer-name") - .dataCenter(DataCenter.builder() - .id("datacenter-id") - .version(4) - .build()) - .internetAccess(true) - .ip("192.168.0.1") - .lanId(2) - .state(ProvisioningState.AVAILABLE) - .creationTime(dateParser.iso8601DateOrSecondsDateParse("2014-12-12T03:08:35.629Z")) - .lastModificationTime(dateParser.iso8601DateOrSecondsDateParse("2014-12-12T03:08:35.629Z")) - .firewalls(firewalls) - .balancedServers(balancedServers) - .build(); - - assertEquals(actual, expected); - - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/nic/NicIdOnlyResponseHandlerTest.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/nic/NicIdOnlyResponseHandlerTest.java b/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/nic/NicIdOnlyResponseHandlerTest.java deleted file mode 100644 index 23b9c4c..0000000 --- a/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/nic/NicIdOnlyResponseHandlerTest.java +++ /dev/null @@ -1,40 +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.http.parser.nic; - -import static org.testng.Assert.assertEquals; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.profitbricks.http.parser.BaseResponseHandlerTest; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "NicIdOnlyResponseHandlerTest") -public class NicIdOnlyResponseHandlerTest extends BaseResponseHandlerTest<String> { - - @Override - protected ParseSax<String> createParser() { - return factory.create(injector.getInstance(NicIdOnlyResponseHandler.class)); - } - - @Test - public void testParseResponseFromCreateNic() { - ParseSax<String> parser = createParser(); - String nicId = parser.parse(payloadFromResource("/nic/nic-create.xml")); - assertEquals("nic-id", nicId); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/93aff921/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/nic/NicListResponseHandlerTest.java ---------------------------------------------------------------------- diff --git a/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/nic/NicListResponseHandlerTest.java b/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/nic/NicListResponseHandlerTest.java deleted file mode 100644 index aa1975d..0000000 --- a/profitbricks/src/test/java/org/jclouds/profitbricks/http/parser/nic/NicListResponseHandlerTest.java +++ /dev/null @@ -1,95 +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.http.parser.nic; - -import com.google.common.collect.ImmutableList; -import java.util.List; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.profitbricks.domain.Firewall; -import org.jclouds.profitbricks.domain.Nic; -import org.jclouds.profitbricks.domain.ProvisioningState; -import org.jclouds.profitbricks.http.parser.BaseResponseHandlerTest; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "NicListResponseHandlerTest") -public class NicListResponseHandlerTest extends BaseResponseHandlerTest<List<Nic>> { - - @Override - protected ParseSax<List<Nic>> createParser() { - return factory.create(injector.getInstance(NicListResponseHandler.class)); - } - - @Test - public void testParseResponseFromGetAllNic() { - ParseSax<List<Nic>> parser = createParser(); - List<Nic> actual = parser.parse(payloadFromResource("/nic/nics.xml")); - assertNotNull(actual, "Parsed content returned null"); - - List<Nic> expected = ImmutableList.of( - Nic.builder() - .dataCenterId("datacenter-id") - .id("nic-id") - .name("nic-name") - .lanId(1) - .internetAccess(true) - .serverId("server-id") - .ips(ImmutableList.of("192.168.0.1")) - .macAddress("aa:bb:cc:dd:ee:f1") - .firewall( - Firewall.builder() - .active(true) - .id("firewall-id") - .nicId("nic-id") - .state(ProvisioningState.AVAILABLE) - .build() - ) - .dhcpActive(true) - .gatewayIp("192.168.0.0") - .state(ProvisioningState.AVAILABLE) - .build(), - Nic.builder() - .dataCenterId("datacenter-id") - .id("nic-id2") - .name("nick") - .lanId(1) - .internetAccess(false) - .serverId("server-id") - .ips(ImmutableList.of( - "192.168.0.2", - "192.168.0.3", - "192.168.0.4" - )) - .macAddress("aa:bb:cc:dd:ee:f2") - .firewall( - Firewall.builder() - .active(false) - .id("firewall-id2") - .nicId("nic-id") - .state(ProvisioningState.AVAILABLE) - .build() - ) - .dhcpActive(false) - .gatewayIp("192.168.0.0") - .state(ProvisioningState.AVAILABLE) - .build() - ); - - assertEquals(actual, expected); - } -}
