mirror of https://github.com/apache/jclouds.git
changed ultradns to use https and added error handling
This commit is contained in:
parent
e18ef518fb
commit
ef862775ec
|
@ -34,7 +34,7 @@
|
|||
<packaging>bundle</packaging>
|
||||
|
||||
<properties>
|
||||
<test.ultradns-ws.endpoint>http://ultra-api.ultradns.com:8008/UltraDNS_WS/v01</test.ultradns-ws.endpoint>
|
||||
<test.ultradns-ws.endpoint>https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01</test.ultradns-ws.endpoint>
|
||||
<test.ultradns-ws.api-version>v01</test.ultradns-ws.api-version>
|
||||
<test.ultradns-ws.build-version></test.ultradns-ws.build-version>
|
||||
<test.ultradns-ws.identity></test.ultradns-ws.identity>
|
||||
|
|
|
@ -33,5 +33,4 @@ public interface UltraDNSWSApi {
|
|||
* Returns the account of the current user.
|
||||
*/
|
||||
Account getCurrentAccount();
|
||||
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ public class UltraDNSWSApiMetadata extends BaseRestApiMetadata {
|
|||
.credentialName("Password")
|
||||
.version("v01")
|
||||
.documentation(URI.create("https://www.ultradns.net/api/NUS_API_XML_SOAP.pdf"))
|
||||
.defaultEndpoint("http://ultra-api.ultradns.com:8008/UltraDNS_WS/v01")
|
||||
.defaultEndpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01")
|
||||
.defaultProperties(UltraDNSWSApiMetadata.defaultProperties())
|
||||
.defaultModule(UltraDNSWSRestClientModule.class);
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ package org.jclouds.ultradns.ws;
|
|||
|
||||
import javax.inject.Named;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
|
||||
import org.jclouds.rest.annotations.Payload;
|
||||
import org.jclouds.rest.annotations.RequestFilters;
|
||||
|
@ -36,6 +35,7 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||
* Provides access to Neustar UltraDNS via the SOAP API
|
||||
* <p/>
|
||||
*
|
||||
* @see <a href="https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01?wsdl" />
|
||||
* @see <a href="https://www.ultradns.net/api/NUS_API_XML_SOAP.pdf" />
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
|
@ -48,9 +48,7 @@ public interface UltraDNSWSAsyncApi {
|
|||
*/
|
||||
@Named("getAccountsListOfUser")
|
||||
@POST
|
||||
@Path("/")
|
||||
@XMLResponseParser(AccountHandler.class)
|
||||
@Payload("<getAccountsListOfUser/>")
|
||||
@Payload("<v01:getAccountsListOfUser/>")
|
||||
ListenableFuture<Account> getCurrentAccount();
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
/**
|
||||
* 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.ultradns.ws;
|
||||
|
||||
import static com.google.common.base.Objects.equal;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public final class UltraDNSWSError {
|
||||
public static UltraDNSWSError fromCodeAndDescription(int code, String description) {
|
||||
return new UltraDNSWSError(code, description);
|
||||
}
|
||||
|
||||
private final int code;
|
||||
private final String description;
|
||||
|
||||
private UltraDNSWSError(int code, String description) {
|
||||
this.code = code;
|
||||
this.description = checkNotNull(description, "description for code %s", code);
|
||||
}
|
||||
|
||||
/**
|
||||
* The error code. ex {@code 1801}
|
||||
*/
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
/**
|
||||
* The description of the error. ex {@code Zone does not exist in the system.}
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null || getClass() != obj.getClass())
|
||||
return false;
|
||||
UltraDNSWSError that = UltraDNSWSError.class.cast(obj);
|
||||
return equal(this.code, that.code) && equal(this.description, that.description);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("Error %s: %s", code, description);
|
||||
}
|
||||
}
|
|
@ -63,7 +63,7 @@ public class UltraDNSWSProviderMetadata extends BaseProviderMetadata {
|
|||
.homepage(URI.create("http://www.neustar.biz/enterprise/dns-services/what-is-external-dns"))
|
||||
.console(URI.create("https://www.ultradns.net"))
|
||||
.iso3166Codes("US-CA", "US-VA") // TODO
|
||||
.endpoint("http://ultra-api.ultradns.com:8008/UltraDNS_WS/v01")
|
||||
.endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01")
|
||||
.defaultProperties(UltraDNSWSProviderMetadata.defaultProperties());
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
/**
|
||||
* 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.ultradns.ws;
|
||||
|
||||
import org.jclouds.http.HttpCommand;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.http.HttpResponseException;
|
||||
|
||||
/**
|
||||
* @see UltraDNSWSError
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class UltraDNSWSResponseException extends HttpResponseException {
|
||||
|
||||
private static final long serialVersionUID = 5493782874839736777L;
|
||||
|
||||
private final UltraDNSWSError error;
|
||||
|
||||
public UltraDNSWSResponseException(HttpCommand command, HttpResponse response, UltraDNSWSError error) {
|
||||
super(error.toString(), command, response);
|
||||
this.error = error;
|
||||
}
|
||||
|
||||
public UltraDNSWSError getError() {
|
||||
return error;
|
||||
}
|
||||
|
||||
}
|
|
@ -20,10 +20,16 @@ package org.jclouds.ultradns.ws.config;
|
|||
|
||||
import java.util.Map;
|
||||
|
||||
import org.jclouds.http.HttpErrorHandler;
|
||||
import org.jclouds.http.HttpRetryHandler;
|
||||
import org.jclouds.http.annotation.ClientError;
|
||||
import org.jclouds.http.annotation.Redirection;
|
||||
import org.jclouds.http.annotation.ServerError;
|
||||
import org.jclouds.rest.ConfiguresRestClient;
|
||||
import org.jclouds.rest.config.RestClientModule;
|
||||
import org.jclouds.ultradns.ws.UltraDNSWSApi;
|
||||
import org.jclouds.ultradns.ws.UltraDNSWSAsyncApi;
|
||||
import org.jclouds.ultradns.ws.handlers.UltraDNSWSErrorHandler;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
|
@ -34,11 +40,23 @@ import com.google.common.collect.ImmutableMap;
|
|||
*/
|
||||
@ConfiguresRestClient
|
||||
public class UltraDNSWSRestClientModule extends RestClientModule<UltraDNSWSApi, UltraDNSWSAsyncApi> {
|
||||
|
||||
public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>>builder()
|
||||
|
||||
public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()
|
||||
.build();
|
||||
|
||||
|
||||
public UltraDNSWSRestClientModule() {
|
||||
super(DELEGATE_MAP);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bindErrorHandlers() {
|
||||
bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(UltraDNSWSErrorHandler.class);
|
||||
bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(UltraDNSWSErrorHandler.class);
|
||||
bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(UltraDNSWSErrorHandler.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bindRetryHandlers() {
|
||||
bind(HttpRetryHandler.class).annotatedWith(ServerError.class).toInstance(HttpRetryHandler.NEVER_RETRY);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public final class Account {
|
|||
}
|
||||
|
||||
/**
|
||||
* The id of the account. ex {@code 01233CB945FAC523}
|
||||
* The id of the account. ex {@code AAAAAAAAAAAAAAAA}
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
|
|
|
@ -39,7 +39,7 @@ public class SOAPWrapWithPasswordAuth implements HttpRequestFilter {
|
|||
static final String WSSE_NS = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";
|
||||
static final String SOAP_PREFIX = new StringBuilder()
|
||||
.append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" ")
|
||||
.append("xmlns=\"http://webservice.api.ultra.neustar.com/v01/\"><soapenv:Header>")
|
||||
.append("xmlns:v01=\"http://webservice.api.ultra.neustar.com/v01/\"><soapenv:Header>")
|
||||
.append("<wsse:Security xmlns:wsse=\"").append(WSSE_NS).append("\"><wsse:UsernameToken>")
|
||||
.append("<wsse:Username>%s</wsse:Username><wsse:Password>%s</wsse:Password>")
|
||||
.append("</wsse:UsernameToken></wsse:Security></soapenv:Header><soapenv:Body>").toString();
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
/**
|
||||
* 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.ultradns.ws.handlers;
|
||||
|
||||
import static org.jclouds.http.HttpUtils.closeClientButKeepContentStream;
|
||||
import static org.jclouds.http.HttpUtils.releasePayload;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Provider;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.http.HttpCommand;
|
||||
import org.jclouds.http.HttpErrorHandler;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.http.HttpResponseException;
|
||||
import org.jclouds.http.functions.ParseSax.Factory;
|
||||
import org.jclouds.rest.ResourceNotFoundException;
|
||||
import org.jclouds.ultradns.ws.UltraDNSWSError;
|
||||
import org.jclouds.ultradns.ws.UltraDNSWSResponseException;
|
||||
import org.jclouds.ultradns.ws.xml.UltraWSExceptionHandler;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class UltraDNSWSErrorHandler implements HttpErrorHandler {
|
||||
|
||||
private final Factory factory;
|
||||
private final Provider<UltraWSExceptionHandler> handlers;
|
||||
|
||||
@Inject
|
||||
UltraDNSWSErrorHandler(Factory factory, Provider<UltraWSExceptionHandler> handlers) {
|
||||
this.factory = factory;
|
||||
this.handlers = handlers;
|
||||
}
|
||||
|
||||
public void handleError(HttpCommand command, HttpResponse response) {
|
||||
Exception exception = new HttpResponseException(command, response);
|
||||
try {
|
||||
byte[] data = closeClientButKeepContentStream(response);
|
||||
String message = data != null ? new String(data) : null;
|
||||
if (message != null) {
|
||||
exception = new HttpResponseException(command, response, message);
|
||||
String contentType = response.getPayload().getContentMetadata().getContentType();
|
||||
if (contentType != null && (contentType.indexOf("xml") != -1 || contentType.indexOf("unknown") != -1)) {
|
||||
UltraDNSWSError error = factory.create(handlers.get()).parse(message);
|
||||
if (error != null) {
|
||||
exception = refineException(new UltraDNSWSResponseException(command, response, error));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
exception = new HttpResponseException(command, response);
|
||||
}
|
||||
} finally {
|
||||
releasePayload(response);
|
||||
command.setException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
private Exception refineException(UltraDNSWSResponseException exception) {
|
||||
switch (exception.getError().getCode()) {
|
||||
case 2401:
|
||||
return new ResourceNotFoundException(exception.getError().getDescription(), exception);
|
||||
}
|
||||
return exception;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
/**
|
||||
* 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.ultradns.ws.xml;
|
||||
|
||||
import static org.jclouds.util.SaxUtils.currentOrNull;
|
||||
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.ultradns.ws.UltraDNSWSError;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class UltraWSExceptionHandler extends ParseSax.HandlerForGeneratedRequestWithResult<UltraDNSWSError> {
|
||||
|
||||
private StringBuilder currentText = new StringBuilder();
|
||||
private int code = -1;
|
||||
private String description;
|
||||
|
||||
@Override
|
||||
public UltraDNSWSError getResult() {
|
||||
try {
|
||||
return code > 0 ? UltraDNSWSError.fromCodeAndDescription(code, description) : null;
|
||||
} finally {
|
||||
code = -1;
|
||||
description = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endElement(String uri, String name, String qName) {
|
||||
if (qName.equals("errorCode")) {
|
||||
code = Integer.parseInt(currentOrNull(currentText));
|
||||
} else if (qName.equals("errorDescription")) {
|
||||
description = currentOrNull(currentText);
|
||||
}
|
||||
currentText = new StringBuilder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void characters(char ch[], int start, int length) {
|
||||
currentText.append(ch, start, length);
|
||||
}
|
||||
|
||||
}
|
|
@ -33,8 +33,8 @@ import org.testng.annotations.Test;
|
|||
public class UltraDNSWSApiExpectTest extends BaseUltraDNSWSApiExpectTest {
|
||||
|
||||
HttpRequest getCurrentAccount = HttpRequest.builder().method("POST")
|
||||
.endpoint("http://ultra-api.ultradns.com:8008/UltraDNS_WS/v01/")
|
||||
.addHeader("Host", "ultra-api.ultradns.com:8008")
|
||||
.endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01")
|
||||
.addHeader("Host", "ultra-api.ultradns.com:8443")
|
||||
.payload(payloadFromResourceWithContentType("/get_current_account.xml", "application/xml")).build();
|
||||
|
||||
HttpResponse getCurrentAccountResponse = HttpResponse.builder().statusCode(200)
|
||||
|
@ -42,10 +42,10 @@ public class UltraDNSWSApiExpectTest extends BaseUltraDNSWSApiExpectTest {
|
|||
|
||||
public void testGetCurrentAccountWhenResponseIs2xx() {
|
||||
|
||||
UltraDNSWSApi apiWhenWithOptionsExist = requestSendsResponse(getCurrentAccount, getCurrentAccountResponse);
|
||||
UltraDNSWSApi success = requestSendsResponse(getCurrentAccount, getCurrentAccountResponse);
|
||||
|
||||
assertEquals(
|
||||
apiWhenWithOptionsExist.getCurrentAccount().toString(),
|
||||
success.getCurrentAccount().toString(),
|
||||
new GetAccountsListOfUserResponseTest().expected().toString());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
/**
|
||||
* 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.ultradns.ws.handlers;
|
||||
|
||||
import static com.google.common.base.Throwables.propagate;
|
||||
import static org.jclouds.rest.internal.BaseRestApiExpectTest.payloadFromStringWithContentType;
|
||||
import static org.jclouds.util.Strings2.toStringAndClose;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jclouds.http.HttpCommand;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.http.functions.config.SaxParserModule;
|
||||
import org.jclouds.io.Payload;
|
||||
import org.jclouds.rest.ResourceNotFoundException;
|
||||
import org.jclouds.ultradns.ws.UltraDNSWSResponseException;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit" )
|
||||
public class UltraDNSWSErrorHandlerTest {
|
||||
UltraDNSWSErrorHandler function = Guice.createInjector(new SaxParserModule()).getInstance(
|
||||
UltraDNSWSErrorHandler.class);
|
||||
|
||||
@Test
|
||||
public void testCode2401SetsResourceNotFoundException() throws IOException {
|
||||
HttpRequest request = HttpRequest.builder().method("POST")
|
||||
.endpoint("https://ultra-api.ultradns.com:8443/UltraDNS_WS/v01")
|
||||
.addHeader("Host", "ultra-api.ultradns.com:8443")
|
||||
.payload(payloadFromResource("/list_zones_by_account.xml")).build();
|
||||
HttpCommand command = new HttpCommand(request);
|
||||
HttpResponse response = HttpResponse.builder().message("Server Error").statusCode(500)
|
||||
.payload(payloadFromResource("/account_doesnt_exist.xml")).build();
|
||||
|
||||
function.handleError(command, response);
|
||||
|
||||
assertEquals(command.getException().getClass(), ResourceNotFoundException.class);
|
||||
assertEquals(command.getException().getMessage(), "Account not found in the system. ID: AAAAAAAAAAAAAAAA");
|
||||
|
||||
UltraDNSWSResponseException exception = UltraDNSWSResponseException.class.cast(command.getException().getCause());
|
||||
|
||||
assertEquals(exception.getMessage(), "Error 2401: Account not found in the system. ID: AAAAAAAAAAAAAAAA");
|
||||
assertEquals(exception.getError().getDescription(), "Account not found in the system. ID: AAAAAAAAAAAAAAAA");
|
||||
assertEquals(exception.getError().getCode(), 2401);
|
||||
|
||||
}
|
||||
|
||||
private Payload payloadFromResource(String resource) {
|
||||
try {
|
||||
return payloadFromStringWithContentType(toStringAndClose(getClass().getResourceAsStream(resource)),
|
||||
"application/xml");
|
||||
} catch (IOException e) {
|
||||
throw propagate(e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -30,7 +30,7 @@ import org.testng.annotations.Test;
|
|||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test
|
||||
@Test(testName = "GetAccountsListOfUserResponseTest")
|
||||
public class GetAccountsListOfUserResponseTest extends BaseHandlerTest {
|
||||
|
||||
public void test() {
|
||||
|
@ -45,7 +45,7 @@ public class GetAccountsListOfUserResponseTest extends BaseHandlerTest {
|
|||
}
|
||||
|
||||
public Account expected() {
|
||||
return Account.fromIdAndName("01233CB945FAC523", "jclouds");
|
||||
return Account.fromIdAndName("AAAAAAAAAAAAAAAA", "jclouds");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
/**
|
||||
* 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.ultradns.ws.parse;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.jclouds.http.functions.BaseHandlerTest;
|
||||
import org.jclouds.ultradns.ws.UltraDNSWSError;
|
||||
import org.jclouds.ultradns.ws.xml.UltraWSExceptionHandler;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(testName = "UltraWSExceptionTest")
|
||||
public class UltraWSExceptionTest extends BaseHandlerTest {
|
||||
|
||||
public void test() {
|
||||
InputStream is = getClass().getResourceAsStream("/zone_doesnt_exist.xml");
|
||||
|
||||
UltraDNSWSError expected = expected();
|
||||
|
||||
UltraWSExceptionHandler handler = injector.getInstance(UltraWSExceptionHandler.class);
|
||||
UltraDNSWSError result = factory.create(handler).parse(is);
|
||||
|
||||
assertEquals(result, expected);
|
||||
}
|
||||
|
||||
public UltraDNSWSError expected() {
|
||||
return UltraDNSWSError.fromCodeAndDescription(1801, "Zone does not exist in the system.");
|
||||
}
|
||||
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
<ns1:getAccountsListOfUserResponse
|
||||
xmlns:ns1="http://webservice.api.ultra.neustar.com/v01/">
|
||||
<AccountsList xmlns:ns2="http://schema.ultraservice.neustar.com/v01/">
|
||||
<ns2:AccountDetailsData accountID="01233CB945FAC523"
|
||||
<ns2:AccountDetailsData accountID="AAAAAAAAAAAAAAAA"
|
||||
accountName="jclouds" />
|
||||
</AccountsList>
|
||||
</ns1:getAccountsListOfUserResponse>
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
||||
<soap:Body>
|
||||
<soap:Fault>
|
||||
<faultcode>soap:Server</faultcode>
|
||||
<faultstring>Fault occurred while processing.</faultstring>
|
||||
<detail>
|
||||
<ns1:UltraWSException xmlns:ns1="http://webservice.api.ultra.neustar.com/v01/">
|
||||
<errorCode xsi:type="xs:int" xmlns:ns2="http://schema.ultraservice.neustar.com/v01/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">2401</errorCode>
|
||||
<errorDescription xmlns:ns2="http://schema.ultraservice.neustar.com/v01/">Account not found in the system. ID: AAAAAAAAAAAAAAAA</errorDescription>
|
||||
</ns1:UltraWSException>
|
||||
</detail>
|
||||
</soap:Fault>
|
||||
</soap:Body>
|
||||
</soap:Envelope>
|
|
@ -1 +1 @@
|
|||
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://webservice.api.ultra.neustar.com/v01/"><soapenv:Header><wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><wsse:UsernameToken><wsse:Username>identity</wsse:Username><wsse:Password>credential</wsse:Password></wsse:UsernameToken></wsse:Security></soapenv:Header><soapenv:Body><getAccountsListOfUser/></soapenv:Body></soapenv:Envelope>
|
||||
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v01="http://webservice.api.ultra.neustar.com/v01/"><soapenv:Header><wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><wsse:UsernameToken><wsse:Username>identity</wsse:Username><wsse:Password>credential</wsse:Password></wsse:UsernameToken></wsse:Security></soapenv:Header><soapenv:Body><v01:getAccountsListOfUser/></soapenv:Body></soapenv:Envelope>
|
|
@ -0,0 +1 @@
|
|||
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v01="http://webservice.api.ultra.neustar.com/v01/"><soapenv:Header><wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><wsse:UsernameToken><wsse:Username>identity</wsse:Username><wsse:Password>credential</wsse:Password></wsse:UsernameToken></wsse:Security></soapenv:Header><soapenv:Body><v01:getZonesOfAccount><accountId>AAAAAAAAAAAAAAAA</accountId><zoneType>all</zoneType></v01:getZonesOfAccount></soapenv:Body></soapenv:Envelope>
|
|
@ -0,0 +1,14 @@
|
|||
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
||||
<soap:Body>
|
||||
<soap:Fault>
|
||||
<faultcode>soap:Server</faultcode>
|
||||
<faultstring>Fault occurred while processing.</faultstring>
|
||||
<detail>
|
||||
<ns1:UltraWSException xmlns:ns1="http://webservice.api.ultra.neustar.com/v01/">
|
||||
<errorCode xsi:type="xs:int" xmlns:ns2="http://schema.ultraservice.neustar.com/v01/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">1801</errorCode>
|
||||
<errorDescription xmlns:ns2="http://schema.ultraservice.neustar.com/v01/">Zone does not exist in the system.</errorDescription>
|
||||
</ns1:UltraWSException>
|
||||
</detail>
|
||||
</soap:Fault>
|
||||
</soap:Body>
|
||||
</soap:Envelope>
|
Loading…
Reference in New Issue