mirror of https://github.com/apache/jclouds.git
Issue 695: Added createInternetService and fixed Consumes type on editInternetService
This commit is contained in:
parent
4e5b1e96cd
commit
a352dc89c8
|
@ -0,0 +1,37 @@
|
||||||
|
/**
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. jclouds 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.tmrk.enterprisecloud.binders;
|
||||||
|
|
||||||
|
import org.jclouds.rest.binders.BindToStringPayload;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For use with {@see org.jclouds.tmrk.enterprisecloud.features.InternetServiceClient#createInternetService}
|
||||||
|
* @author Jason King
|
||||||
|
*/
|
||||||
|
@Singleton
|
||||||
|
public class BindCreateInternetServiceToXmlPayload extends BindInternetServiceToXmlPayload {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
BindCreateInternetServiceToXmlPayload(BindToStringPayload stringBinder) {
|
||||||
|
super(stringBinder, "CreateInternetService");
|
||||||
|
}
|
||||||
|
}
|
|
@ -23,6 +23,7 @@ import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.rest.Binder;
|
import org.jclouds.rest.Binder;
|
||||||
import org.jclouds.rest.binders.BindToStringPayload;
|
import org.jclouds.rest.binders.BindToStringPayload;
|
||||||
import org.jclouds.tmrk.enterprisecloud.domain.NamedResource;
|
import org.jclouds.tmrk.enterprisecloud.domain.NamedResource;
|
||||||
|
import org.jclouds.tmrk.enterprisecloud.domain.service.Protocol;
|
||||||
import org.jclouds.tmrk.enterprisecloud.domain.service.internet.InternetService;
|
import org.jclouds.tmrk.enterprisecloud.domain.service.internet.InternetService;
|
||||||
import org.jclouds.tmrk.enterprisecloud.domain.service.internet.InternetServicePersistenceType;
|
import org.jclouds.tmrk.enterprisecloud.domain.service.internet.InternetServicePersistenceType;
|
||||||
|
|
||||||
|
@ -36,17 +37,23 @@ import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For use with {@see VirtualMachineClient#createVirtualMachineFromTemplate}
|
* For use with {@see org.jclouds.tmrk.enterprisecloud.features.InternetServiceClient#editInternetService}
|
||||||
* @author Jason King
|
* @author Jason King
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class BindInternetServiceToXmlPayload implements Binder {
|
public class BindInternetServiceToXmlPayload implements Binder {
|
||||||
|
|
||||||
private final BindToStringPayload stringBinder;
|
private final BindToStringPayload stringBinder;
|
||||||
|
private final String rootElement;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
BindInternetServiceToXmlPayload(BindToStringPayload stringBinder) {
|
BindInternetServiceToXmlPayload(BindToStringPayload stringBinder) {
|
||||||
|
this(stringBinder,"InternetService");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BindInternetServiceToXmlPayload(BindToStringPayload stringBinder, String rootElement) {
|
||||||
this.stringBinder = stringBinder;
|
this.stringBinder = stringBinder;
|
||||||
|
this.rootElement = rootElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -65,6 +72,8 @@ public class BindInternetServiceToXmlPayload implements Binder {
|
||||||
outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
|
outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
|
||||||
|
|
||||||
final String name = checkNotNull(data.getName(), "name");
|
final String name = checkNotNull(data.getName(), "name");
|
||||||
|
final Protocol protocol = data.getProtocol();
|
||||||
|
final int port = data.getPort();
|
||||||
final String enabled = Boolean.toString(data.isEnabled());
|
final String enabled = Boolean.toString(data.isEnabled());
|
||||||
final String description = data.getDescription();
|
final String description = data.getDescription();
|
||||||
final InternetServicePersistenceType persistence = data.getPersistence();
|
final InternetServicePersistenceType persistence = data.getPersistence();
|
||||||
|
@ -72,19 +81,30 @@ public class BindInternetServiceToXmlPayload implements Binder {
|
||||||
final NamedResource trustedNetworkGroup = data.getTrustedNetworkGroup();
|
final NamedResource trustedNetworkGroup = data.getTrustedNetworkGroup();
|
||||||
final NamedResource backupInternetService = data.getBackupInternetService();
|
final NamedResource backupInternetService = data.getBackupInternetService();
|
||||||
|
|
||||||
|
XMLBuilder builder = XMLBuilder.create(rootElement).a("name", name);
|
||||||
|
|
||||||
|
if(protocol!=null) {
|
||||||
|
builder = builder.e("Protocol").t(protocol.value()).up();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(port>0) {
|
||||||
|
builder = builder.e("Port").t(Integer.toString(port)).up();
|
||||||
|
}
|
||||||
|
|
||||||
|
builder = builder.e("Enabled").t(enabled).up();
|
||||||
|
|
||||||
XMLBuilder builder = XMLBuilder.create("InternetService").a("name", name)
|
|
||||||
.e("Enabled").t(enabled).up();
|
|
||||||
if(description!=null) {
|
if(description!=null) {
|
||||||
builder = builder.e("Description").t(description).up();
|
builder = builder.e("Description").t(description).up();
|
||||||
}
|
}
|
||||||
|
//TODO: Public IP
|
||||||
builder = persistence(builder,persistence);
|
builder = persistence(builder,persistence);
|
||||||
|
|
||||||
if(redirectUrl!=null) {
|
if(redirectUrl!=null) {
|
||||||
builder = builder.e("RedirectUrl").t(redirectUrl);
|
builder = builder.e("RedirectUrl").t(redirectUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: Monitor
|
||||||
|
|
||||||
if(trustedNetworkGroup!=null) {
|
if(trustedNetworkGroup!=null) {
|
||||||
final String href = trustedNetworkGroup.getHref().toString();
|
final String href = trustedNetworkGroup.getHref().toString();
|
||||||
String groupName = trustedNetworkGroup.getName();
|
String groupName = trustedNetworkGroup.getName();
|
||||||
|
@ -99,6 +119,8 @@ public class BindInternetServiceToXmlPayload implements Binder {
|
||||||
builder = builder.e("BackupInternetService").a("href",href).a("name",groupName).a("type",type).up();
|
builder = builder.e("BackupInternetService").a("href",href).a("name",groupName).a("type",type).up();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: NodeServices
|
||||||
|
|
||||||
return builder.asString(outputProperties);
|
return builder.asString(outputProperties);
|
||||||
} catch (ParserConfigurationException e) {
|
} catch (ParserConfigurationException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
|
|
@ -6,21 +6,39 @@ import javax.xml.bind.annotation.XmlEnumValue;
|
||||||
@XmlEnum
|
@XmlEnum
|
||||||
public enum Protocol {
|
public enum Protocol {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HyperText Transfer Protocol
|
||||||
|
*/
|
||||||
@XmlEnumValue("HTTP")
|
@XmlEnumValue("HTTP")
|
||||||
HTTP,
|
HTTP,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HyperText Transfer Protocol Secure
|
||||||
|
*/
|
||||||
@XmlEnumValue("HTTPS")
|
@XmlEnumValue("HTTPS")
|
||||||
HTTPS,
|
HTTPS,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transmission Control Protocol
|
||||||
|
*/
|
||||||
@XmlEnumValue("TCP")
|
@XmlEnumValue("TCP")
|
||||||
TCP,
|
TCP,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User Datagram Protocol
|
||||||
|
*/
|
||||||
@XmlEnumValue("UDP")
|
@XmlEnumValue("UDP")
|
||||||
UDP,
|
UDP,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internet Protocol security
|
||||||
|
*/
|
||||||
@XmlEnumValue("IPSEC")
|
@XmlEnumValue("IPSEC")
|
||||||
IPSEC,
|
IPSEC,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* File Transfer Protocol
|
||||||
|
*/
|
||||||
@XmlEnumValue("FTP")
|
@XmlEnumValue("FTP")
|
||||||
FTP,
|
FTP,
|
||||||
|
|
||||||
|
@ -31,4 +49,8 @@ public enum Protocol {
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return name();
|
return name();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String value() {
|
||||||
|
return name();
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -22,13 +22,14 @@ import com.google.common.util.concurrent.ListenableFuture;
|
||||||
import org.jclouds.http.filters.BasicAuthentication;
|
import org.jclouds.http.filters.BasicAuthentication;
|
||||||
import org.jclouds.rest.annotations.*;
|
import org.jclouds.rest.annotations.*;
|
||||||
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||||
|
import org.jclouds.tmrk.enterprisecloud.binders.BindCreateInternetServiceToXmlPayload;
|
||||||
|
import org.jclouds.tmrk.enterprisecloud.binders.BindInternetServiceToXmlPayload;
|
||||||
import org.jclouds.tmrk.enterprisecloud.domain.Task;
|
import org.jclouds.tmrk.enterprisecloud.domain.Task;
|
||||||
import org.jclouds.tmrk.enterprisecloud.domain.service.internet.InternetService;
|
import org.jclouds.tmrk.enterprisecloud.domain.service.internet.InternetService;
|
||||||
import org.jclouds.tmrk.enterprisecloud.functions.URISource;
|
import org.jclouds.tmrk.enterprisecloud.functions.URISource;
|
||||||
|
|
||||||
import javax.ws.rs.Consumes;
|
import javax.ws.rs.*;
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.core.MediaType;
|
||||||
import javax.ws.rs.PUT;
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -58,8 +59,19 @@ public interface InternetServiceAsyncClient {
|
||||||
* @see org.jclouds.tmrk.enterprisecloud.features.InternetServiceClient#editInternetService
|
* @see org.jclouds.tmrk.enterprisecloud.features.InternetServiceClient#editInternetService
|
||||||
*/
|
*/
|
||||||
@PUT
|
@PUT
|
||||||
|
@Produces(MediaType.APPLICATION_XML)
|
||||||
|
@Consumes("application/vnd.tmrk.cloud.task")
|
||||||
|
@JAXBResponseParser
|
||||||
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
|
ListenableFuture<Task> editInternetService(@EndpointParam(parser = URISource.GetURI.class) @BinderParam(BindInternetServiceToXmlPayload.class) InternetService internetService);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.jclouds.tmrk.enterprisecloud.features.InternetServiceClient#editInternetService
|
||||||
|
*/
|
||||||
|
@POST
|
||||||
|
@Produces(MediaType.APPLICATION_XML)
|
||||||
@Consumes("application/vnd.tmrk.cloud.internetService")
|
@Consumes("application/vnd.tmrk.cloud.internetService")
|
||||||
@JAXBResponseParser
|
@JAXBResponseParser
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
ListenableFuture<Task> editInternetService(@EndpointParam(parser = URISource.GetURI.class) InternetService internetService);
|
InternetService createInternetService(@EndpointParam URI uri, @BinderParam(BindCreateInternetServiceToXmlPayload.class)InternetService data);
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,4 +75,27 @@ public interface InternetServiceClient {
|
||||||
* @return the Task representing the create action
|
* @return the Task representing the create action
|
||||||
*/
|
*/
|
||||||
Task editInternetService(InternetService service);
|
Task editInternetService(InternetService service);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The createInternetService call creates an Internet service on a public IP address in an environment.
|
||||||
|
* If successful, the call returns information regarding the Internet service that was created.
|
||||||
|
* Input InternetService object Properties:
|
||||||
|
* The name is required and may not be that of another Internet service.
|
||||||
|
* Protocol is required.
|
||||||
|
* Port is required and must be in the range of 1 to 65535.
|
||||||
|
* Enabled is required.
|
||||||
|
* Type refers to the method for persisting a connection session.
|
||||||
|
* If Timeout is absent with a type of SourceIp then Timeout defaults to 2 minutes.
|
||||||
|
* Omit Timeout if type is None.
|
||||||
|
*
|
||||||
|
* Note: The href of the InternetService data parameter is not used.
|
||||||
|
* When creating the input object you may use any value or an empty URI
|
||||||
|
* e.g. java.net.URI.create("")
|
||||||
|
*
|
||||||
|
* @param uri The uri of the call based on the public IP identifier
|
||||||
|
* e.g. /cloudapi/ecloud/internetServices/publicIps/{public IP identifier}/action/createInternetService
|
||||||
|
* @param data The input internet service data used to create the service
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
InternetService createInternetService(URI uri, InternetService data);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,74 @@
|
||||||
|
/**
|
||||||
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. jclouds 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.tmrk.enterprisecloud.binders;
|
||||||
|
|
||||||
|
import com.google.inject.AbstractModule;
|
||||||
|
import com.google.inject.Guice;
|
||||||
|
import com.google.inject.Injector;
|
||||||
|
import org.jclouds.http.HttpRequest;
|
||||||
|
import org.jclouds.tmrk.enterprisecloud.domain.service.Protocol;
|
||||||
|
import org.jclouds.tmrk.enterprisecloud.domain.service.internet.InternetService;
|
||||||
|
import org.jclouds.tmrk.enterprisecloud.domain.service.internet.InternetServicePersistenceType;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests behavior of {@code BindCreateInternetServiceToXmlPayload}
|
||||||
|
* @author Jason King
|
||||||
|
*/
|
||||||
|
@Test(groups = "unit", testName = "BindCreateInternetServiceToXmlPayloadTest")
|
||||||
|
public class BindCreateInternetServiceToXmlPayloadTest {
|
||||||
|
Injector injector = Guice.createInjector(new AbstractModule() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void configure() {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
public void testPayloadMinimalXmlContent() throws IOException {
|
||||||
|
String expected =
|
||||||
|
"<CreateInternetService name='testName'>" +
|
||||||
|
"<Protocol>HTTP</Protocol>" +
|
||||||
|
"<Port>2020</Port>" +
|
||||||
|
"<Enabled>true</Enabled>" +
|
||||||
|
"<Persistence>" +
|
||||||
|
"<Type>None</Type>" +
|
||||||
|
"</Persistence>" +
|
||||||
|
"</CreateInternetService>";
|
||||||
|
|
||||||
|
HttpRequest request = new HttpRequest("GET", URI.create("http://test"));
|
||||||
|
BindInternetServiceToXmlPayload binder = injector
|
||||||
|
.getInstance(BindCreateInternetServiceToXmlPayload.class);
|
||||||
|
|
||||||
|
InternetService.Builder builder = InternetService.builder()
|
||||||
|
.href(URI.create(""))
|
||||||
|
.name("testName")
|
||||||
|
.protocol(Protocol.HTTP)
|
||||||
|
.port(2020)
|
||||||
|
.enabled(true)
|
||||||
|
.persistence(InternetServicePersistenceType.builder().persistenceType(InternetServicePersistenceType.PersistenceType.NONE).build());
|
||||||
|
|
||||||
|
binder.bindToRequest(request, builder.build());
|
||||||
|
assertEquals(request.getPayload().getRawContent(), expected.replaceAll("'","\""));
|
||||||
|
}
|
||||||
|
}
|
|
@ -23,9 +23,13 @@ import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseXMLWithJAXB;
|
import org.jclouds.http.functions.ParseXMLWithJAXB;
|
||||||
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
|
import org.jclouds.tmrk.enterprisecloud.domain.service.Protocol;
|
||||||
import org.jclouds.tmrk.enterprisecloud.domain.service.internet.InternetService;
|
import org.jclouds.tmrk.enterprisecloud.domain.service.internet.InternetService;
|
||||||
|
import org.jclouds.tmrk.enterprisecloud.domain.service.internet.InternetServicePersistenceType;
|
||||||
|
import org.testng.annotations.BeforeMethod;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
@ -39,6 +43,21 @@ import java.net.URISyntaxException;
|
||||||
@Test(groups = "unit", testName = "LayoutAsyncClientTest")
|
@Test(groups = "unit", testName = "LayoutAsyncClientTest")
|
||||||
public class InternetServiceAsyncClientTest extends BaseTerremarkEnterpriseCloudAsyncClientTest<InternetServiceAsyncClient> {
|
public class InternetServiceAsyncClientTest extends BaseTerremarkEnterpriseCloudAsyncClientTest<InternetServiceAsyncClient> {
|
||||||
|
|
||||||
|
private URI uri = URI.create("/cloudapi/ecloud/internetservices/797");
|
||||||
|
private InternetServicePersistenceType persistenceType;
|
||||||
|
private InternetService service;
|
||||||
|
|
||||||
|
@BeforeMethod
|
||||||
|
public void setUp() {
|
||||||
|
|
||||||
|
persistenceType = InternetServicePersistenceType.builder().persistenceType(InternetServicePersistenceType.PersistenceType.NONE).build();
|
||||||
|
|
||||||
|
service = InternetService.builder().href(uri)
|
||||||
|
.name("testName")
|
||||||
|
.enabled(true)
|
||||||
|
.persistence(persistenceType).build();
|
||||||
|
}
|
||||||
|
|
||||||
public void testGetInternetService() throws SecurityException, NoSuchMethodException, IOException, URISyntaxException {
|
public void testGetInternetService() throws SecurityException, NoSuchMethodException, IOException, URISyntaxException {
|
||||||
Method method = InternetServiceAsyncClient.class.getMethod("getInternetService", URI.class);
|
Method method = InternetServiceAsyncClient.class.getMethod("getInternetService", URI.class);
|
||||||
HttpRequest httpRequest = processor.createRequest(method, URI.create("/cloudapi/ecloud/internetservices/797"));
|
HttpRequest httpRequest = processor.createRequest(method, URI.create("/cloudapi/ecloud/internetservices/797"));
|
||||||
|
@ -58,16 +77,36 @@ public class InternetServiceAsyncClientTest extends BaseTerremarkEnterpriseCloud
|
||||||
public void testEditInternetService() throws SecurityException, NoSuchMethodException, IOException, URISyntaxException {
|
public void testEditInternetService() throws SecurityException, NoSuchMethodException, IOException, URISyntaxException {
|
||||||
Method method = InternetServiceAsyncClient.class.getMethod("editInternetService", InternetService.class);
|
Method method = InternetServiceAsyncClient.class.getMethod("editInternetService", InternetService.class);
|
||||||
|
|
||||||
URI uri = URI.create("/cloudapi/ecloud/internetservices/797");
|
|
||||||
InternetService service = InternetService.builder().href(uri).build();
|
|
||||||
|
|
||||||
HttpRequest httpRequest = processor.createRequest(method, service);
|
HttpRequest httpRequest = processor.createRequest(method, service);
|
||||||
|
|
||||||
String requestLine = "PUT https://services-beta.enterprisecloud.terremark.com/cloudapi/ecloud/internetservices/797 HTTP/1.1";
|
String requestLine = "PUT https://services-beta.enterprisecloud.terremark.com/cloudapi/ecloud/internetservices/797 HTTP/1.1";
|
||||||
|
String payload = "<InternetService name='testName'><Enabled>true</Enabled><Persistence><Type>None</Type></Persistence></InternetService>".replaceAll("'","\"");
|
||||||
|
assertRequestLineEquals(httpRequest, requestLine);
|
||||||
|
assertNonPayloadHeadersEqual(httpRequest,
|
||||||
|
"Accept: application/vnd.tmrk.cloud.task\nx-tmrk-version: 2011-07-01\n");
|
||||||
|
assertPayloadEquals(httpRequest, payload, MediaType.APPLICATION_XML, false);
|
||||||
|
|
||||||
|
assertResponseParserClassEquals(method, httpRequest, ParseXMLWithJAXB.class);
|
||||||
|
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
||||||
|
|
||||||
|
checkFilters(httpRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void testCreateInternetService() throws SecurityException, NoSuchMethodException, IOException, URISyntaxException {
|
||||||
|
Method method = InternetServiceAsyncClient.class.getMethod("createInternetService", URI.class, InternetService.class);
|
||||||
|
|
||||||
|
URI uri = URI.create("/cloudapi/ecloud/internetServices/publicIps/123/action/createInternetService");
|
||||||
|
InternetService createData = service.toBuilder().href(URI.create("")).protocol(Protocol.HTTP).port(2020).build();
|
||||||
|
|
||||||
|
HttpRequest httpRequest = processor.createRequest(method, uri, createData);
|
||||||
|
|
||||||
|
String requestLine = "POST https://services-beta.enterprisecloud.terremark.com/cloudapi/ecloud/internetServices/publicIps/123/action/createInternetService HTTP/1.1";
|
||||||
|
String payload = "<CreateInternetService name='testName'><Protocol>HTTP</Protocol><Port>2020</Port><Enabled>true</Enabled><Persistence><Type>None</Type></Persistence></CreateInternetService>".replaceAll("'","\"");
|
||||||
assertRequestLineEquals(httpRequest, requestLine);
|
assertRequestLineEquals(httpRequest, requestLine);
|
||||||
assertNonPayloadHeadersEqual(httpRequest,
|
assertNonPayloadHeadersEqual(httpRequest,
|
||||||
"Accept: application/vnd.tmrk.cloud.internetService\nx-tmrk-version: 2011-07-01\n");
|
"Accept: application/vnd.tmrk.cloud.internetService\nx-tmrk-version: 2011-07-01\n");
|
||||||
assertPayloadEquals(httpRequest, null, null, false);
|
assertPayloadEquals(httpRequest, payload, MediaType.APPLICATION_XML, false);
|
||||||
|
|
||||||
assertResponseParserClassEquals(method, httpRequest, ParseXMLWithJAXB.class);
|
assertResponseParserClassEquals(method, httpRequest, ParseXMLWithJAXB.class);
|
||||||
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
||||||
|
|
Loading…
Reference in New Issue