From d38ae1420d89d7ef13b47ac52dbde37d91c8640b Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Tue, 8 Jan 2013 00:32:17 -0800 Subject: [PATCH 1/2] Updated invokable to include enclosing type and started refactoring SyncProxy --- .../concurrent/internal/SyncProxy.java | 238 -------- .../java/org/jclouds/http/HttpCommand.java | 5 +- .../main/java/org/jclouds/http/HttpUtils.java | 2 +- .../ForwardInvocationToInterface.java | 84 --- .../java/org/jclouds/reflect/Element.java | 180 ++++++ .../jclouds/reflect/FunctionalReflection.java | 45 +- .../java/org/jclouds/reflect/Invocation.java | 50 +- .../jclouds/reflect/InvocationSuccess.java | 2 +- .../java/org/jclouds/reflect/Invokable.java | 347 ++++++++++++ .../java/org/jclouds/reflect/Parameter.java | 115 ++++ .../org/jclouds/rest/InputParamValidator.java | 2 +- .../rest/binders/BindMapToStringPayload.java | 2 +- .../rest/config/AsyncClientProvider.java | 6 +- .../org/jclouds/rest/config/BinderUtils.java | 21 +- .../jclouds/rest/config/ClientProvider.java | 13 +- .../jclouds/rest/config/RestClientModule.java | 3 +- .../org/jclouds/rest/config/RestModule.java | 143 ++++- .../rest/internal/AsyncRestClientProxy.java | 529 ------------------ .../rest/internal/BaseInvocationFunction.java | 127 +++++ .../rest/internal/GeneratedHttpRequest.java | 24 +- .../jclouds/rest/internal/InvokeAsyncApi.java | 122 ++++ .../rest/internal/InvokeFutureAndBlock.java | 116 ++++ .../InvokeListenableFutureViaHttp.java | 146 +++++ .../jclouds/rest/internal/InvokeSyncApi.java | 123 ++++ .../internal/RestAnnotationProcessor.java | 145 ++--- .../rest/internal/TransformerForRequest.java | 229 ++++++++ .../java/org/jclouds/util/Optionals2.java | 2 +- .../concurrent/internal/SyncProxyTest.java | 22 +- .../http/functions/BaseHandlerTest.java | 2 +- .../BackoffLimitedRetryHandlerTest.java | 2 +- ...kingJavaUrlHttpCommandExecutorService.java | 2 +- .../java/org/jclouds/json/BaseParserTest.java | 6 +- .../reflect/FunctionalReflectionTest.java | 4 +- .../org/jclouds/reflect/InvokableTest.java | 345 ++++++++++++ .../jclouds/rest/InputParamValidatorTest.java | 2 +- .../binders/BindMapToStringPayloadTest.java | 2 +- ...aphicallyAtOrAfterSinceApiVersionTest.java | 2 +- .../rest/internal/BaseRestApiTest.java | 12 +- .../internal/RestAnnotationProcessorTest.java | 208 +++---- .../java/org/jclouds/util/Optionals2Test.java | 2 +- 40 files changed, 2245 insertions(+), 1187 deletions(-) delete mode 100644 core/src/main/java/org/jclouds/concurrent/internal/SyncProxy.java delete mode 100644 core/src/main/java/org/jclouds/internal/ForwardInvocationToInterface.java create mode 100644 core/src/main/java/org/jclouds/reflect/Element.java create mode 100644 core/src/main/java/org/jclouds/reflect/Invokable.java create mode 100644 core/src/main/java/org/jclouds/reflect/Parameter.java delete mode 100644 core/src/main/java/org/jclouds/rest/internal/AsyncRestClientProxy.java create mode 100644 core/src/main/java/org/jclouds/rest/internal/BaseInvocationFunction.java create mode 100644 core/src/main/java/org/jclouds/rest/internal/InvokeAsyncApi.java create mode 100644 core/src/main/java/org/jclouds/rest/internal/InvokeFutureAndBlock.java create mode 100644 core/src/main/java/org/jclouds/rest/internal/InvokeListenableFutureViaHttp.java create mode 100644 core/src/main/java/org/jclouds/rest/internal/InvokeSyncApi.java create mode 100644 core/src/main/java/org/jclouds/rest/internal/TransformerForRequest.java create mode 100644 core/src/test/java/org/jclouds/reflect/InvokableTest.java diff --git a/core/src/main/java/org/jclouds/concurrent/internal/SyncProxy.java b/core/src/main/java/org/jclouds/concurrent/internal/SyncProxy.java deleted file mode 100644 index d13f62fbd7..0000000000 --- a/core/src/main/java/org/jclouds/concurrent/internal/SyncProxy.java +++ /dev/null @@ -1,238 +0,0 @@ -/** - * 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.concurrent.internal; - -import static com.google.common.base.Optional.fromNullable; -import static com.google.common.base.Preconditions.checkState; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.Arrays; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Named; - -import org.jclouds.internal.ForwardInvocationToInterface; -import org.jclouds.logging.Logger; -import org.jclouds.reflect.FunctionalReflection; -import org.jclouds.reflect.Invocation; -import org.jclouds.reflect.Invocation.Result; -import org.jclouds.reflect.InvocationSuccess; -import org.jclouds.rest.annotations.Delegate; -import org.jclouds.rest.internal.AsyncRestClientProxy; -import org.jclouds.util.Optionals2; - -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Function; -import com.google.common.base.Optional; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.reflect.Invokable; -import com.google.common.util.concurrent.ListenableFuture; -import com.google.inject.assistedinject.Assisted; - -/** - * Generates RESTful clients from appropriately annotated interfaces. - * - * @author Adrian Cole - */ -public final class SyncProxy implements Function { - - public static interface Factory { - /** - * @param declaring - * type of the interface where all invokeds match those of {@code async} except the return values are - * dereferenced - * @param async - * object whose interface matched {@code declaring} except all invokeds return {@link ListenableFuture} - * @return blocking invocation handler - */ - SyncProxy create(Class declaring, Object async); - } - - /** - * CreateClientForCaller is parameterized, so clients it creates aren't singletons. For example, - * CreateClientForCaller satisfies a call like this: - * {@code context.getProviderSpecificContext().getApi().getOrgClientForName(name)} - * - * @author Adrian Cole - */ - public static class CreateClientForCaller implements Function { - private final SyncProxy.Factory factory; - private final AsyncRestClientProxy.Caller.Factory asyncFactory; - - @Inject - private CreateClientForCaller(SyncProxy.Factory factory, AsyncRestClientProxy.Caller.Factory asyncFactory) { - this.factory = factory; - this.asyncFactory = asyncFactory; - } - - @Override - public Object apply(ForwardInvocationToInterface from) { - Object asyncClient = FunctionalReflection.newProxy(from.getInterfaceType(), - asyncFactory.caller(from.getInvocation(), from.getInterfaceType())); - checkState(asyncClient != null, "configuration error, sync client for " + from + " not found"); - Class type = Optionals2.unwrapIfOptional(from.getInvocation().getInvokable().getReturnType()); - return FunctionalReflection.newProxy(type, factory.create(type, asyncClient)); - } - } - - @Resource - private Logger logger = Logger.NULL; - - private final Function> optionalConverter; - private final Object delegate; - private final Class declaring; - private final Map, Invokable>> invokedMap; - private final Map, Invokable> syncMethodMap; - private final Map, Optional> timeoutMap; - private final Function createClientForCaller; - private final Map, Class> sync2Async; - private static final Set objectMethods = ImmutableSet.copyOf(Object.class.getMethods()); - - @SuppressWarnings("unchecked") - @Inject - @VisibleForTesting - SyncProxy(Function> optionalConverter, - Function createClientForCaller, Map, Class> sync2Async, - @Named("TIMEOUTS") Map timeouts, @Assisted Class declaring, @Assisted Object async) - throws SecurityException, NoSuchMethodException { - this.optionalConverter = optionalConverter; - this.createClientForCaller = createClientForCaller; - this.delegate = async; - this.declaring = declaring; - this.sync2Async = ImmutableMap.copyOf(sync2Async); - - ImmutableMap.Builder, Invokable>> invokedMapBuilder = ImmutableMap - .builder(); - ImmutableMap.Builder, Invokable> syncMethodMapBuilder = ImmutableMap.builder(); - - for (Method invoked : declaring.getMethods()) { - if (!objectMethods.contains(invoked)) { - Method delegatedMethod = delegate.getClass().getMethod(invoked.getName(), invoked.getParameterTypes()); - if (!Arrays.equals(delegatedMethod.getExceptionTypes(), invoked.getExceptionTypes())) - throw new IllegalArgumentException(String.format( - "invoked %s has different typed exceptions than delegated invoked %s", invoked, delegatedMethod)); - if (delegatedMethod.getReturnType().isAssignableFrom(ListenableFuture.class)) { - invokedMapBuilder.put(Invokable.from(invoked), Invokable.class.cast(Invokable.from(delegatedMethod))); - } else { - syncMethodMapBuilder.put(Invokable.from(invoked), Invokable.class.cast(Invokable.from(delegatedMethod))); - } - } - } - invokedMap = invokedMapBuilder.build(); - syncMethodMap = syncMethodMapBuilder.build(); - - ImmutableMap.Builder, Optional> timeoutMapBuilder = ImmutableMap.builder(); - for (Invokable invoked : invokedMap.keySet()) { - timeoutMapBuilder.put(invoked, timeoutInNanos(invoked, timeouts)); - } - timeoutMap = timeoutMapBuilder.build(); - } - - @Override - public Result apply(Invocation invocation) { - if (invocation.getInvokable().isAnnotationPresent(Delegate.class)) - return forwardToDelegate(invocation); - if (syncMethodMap.containsKey(invocation.getInvokable())) - return invokeOnDelegate(invocation); - return invokeFutureAndBlock(invocation); - } - - private Result forwardToDelegate(Invocation invocation) { - Class returnType = Optionals2.unwrapIfOptional(invocation.getInvokable().getReturnType()); - // get the return type of the asynchronous class associated with this client - // ex. FloatingIPClient is associated with FloatingIPAsyncClient - Class asyncClass = sync2Async.get(returnType); - checkState(asyncClass != null, "please configure corresponding async class for %s in your RestClientModule", - returnType); - // pass any parameters necessary to get a relevant instance of that async class - // ex. getClientForRegion("north") might return an instance whose endpoint is - // different that "south" - ForwardInvocationToInterface cma = ForwardInvocationToInterface.create(invocation, asyncClass); - Object result = createClientForCaller.apply(cma); - if (Optionals2.isReturnTypeOptional(invocation.getInvokable())) { - result = optionalConverter.apply(InvocationSuccess.create(invocation, result)); - } - return Result.success(result); - } - - private Result invokeFutureAndBlock(Invocation invocation) { - try { - Invokable> asyncMethod = invokedMap.get(invocation.getInvokable()); - ListenableFuture future = asyncMethod.invoke(delegate, invocation.getArgs().toArray()); - Optional timeoutNanos = timeoutMap.get(invocation.getInvokable()); - return block(future, timeoutNanos); - } catch (InvocationTargetException e) { - return Result.fail(e); - } catch (IllegalAccessException e) { - return Result.fail(e); - } - } - - private Result block(ListenableFuture future, Optional timeoutNanos) { - try { - if (timeoutNanos.isPresent()) { - logger.debug(">> blocking on %s for %s", future, timeoutNanos); - return Result.success(future.get(timeoutNanos.get(), TimeUnit.NANOSECONDS)); - } else { - logger.debug(">> blocking on %s", future); - return Result.success(future.get()); - } - } catch (ExecutionException e) { - return Result.fail(e.getCause()); - } catch (InterruptedException e) { - return Result.fail(e); // TODO: should we kill the future? - } catch (TimeoutException e) { - return Result.fail(e); - } - } - - private Result invokeOnDelegate(Invocation invocation) { - Invokable toInvoke = syncMethodMap.get(invocation.getInvokable()); - try { - return Result.success(toInvoke.invoke(delegate, invocation.getArgs().toArray())); - } catch (InvocationTargetException e) { - return Result.fail(e); - } catch (IllegalAccessException e) { - return Result.fail(e); - } - } - - // override timeout by values configured in properties(in ms) - private Optional timeoutInNanos(Invokable invoked, Map timeouts) { - String className = declaring.getSimpleName(); - Optional timeoutMillis = fromNullable(timeouts.get(className + "." + invoked.getName())).or( - fromNullable(timeouts.get(className))).or(fromNullable(timeouts.get("default"))); - if (timeoutMillis.isPresent()) - return Optional.of(TimeUnit.MILLISECONDS.toNanos(timeoutMillis.get())); - return Optional.absent(); - } - - @Override - public String toString() { - return String.format("%s->%s", declaring.getClass().getSimpleName(), delegate.getClass().getSimpleName()); - } -} diff --git a/core/src/main/java/org/jclouds/http/HttpCommand.java b/core/src/main/java/org/jclouds/http/HttpCommand.java index d0eb4bad76..585f224d9a 100644 --- a/core/src/main/java/org/jclouds/http/HttpCommand.java +++ b/core/src/main/java/org/jclouds/http/HttpCommand.java @@ -23,7 +23,6 @@ import static com.google.common.base.Preconditions.checkNotNull; import org.jclouds.rest.internal.GeneratedHttpRequest; import com.google.common.base.Objects; -import com.google.common.reflect.Invokable; /** * Command whose endpoint is an http service. @@ -134,9 +133,7 @@ public class HttpCommand { public String toString() { if (request instanceof GeneratedHttpRequest) { GeneratedHttpRequest gRequest = GeneratedHttpRequest.class.cast(request); - return String.format("[method=%s.%s, request=%s]", - gRequest.getInvocation().getInterfaceType().getSimpleName(), gRequest.getInvocation().getInvokable() - .getName(), gRequest.getRequestLine()); + return String.format("[method=%s, request=%s]", gRequest.getInvocation(), gRequest.getRequestLine()); } return "[request=" + request.getRequestLine() + "]"; } diff --git a/core/src/main/java/org/jclouds/http/HttpUtils.java b/core/src/main/java/org/jclouds/http/HttpUtils.java index d173a2fb32..a2774c8a65 100644 --- a/core/src/main/java/org/jclouds/http/HttpUtils.java +++ b/core/src/main/java/org/jclouds/http/HttpUtils.java @@ -66,7 +66,7 @@ import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Multimap; import com.google.common.collect.ImmutableSet.Builder; -import com.google.common.reflect.Invokable; +import org.jclouds.reflect.Invokable; import com.google.inject.Inject; /** diff --git a/core/src/main/java/org/jclouds/internal/ForwardInvocationToInterface.java b/core/src/main/java/org/jclouds/internal/ForwardInvocationToInterface.java deleted file mode 100644 index 60087d6183..0000000000 --- a/core/src/main/java/org/jclouds/internal/ForwardInvocationToInterface.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * 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.internal; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.reflect.Invocation; - -import com.google.common.annotations.Beta; -import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; - -/** - * internal type to {@link SyncProxy} which is likely to be removed - * - * @author Adrian Cole - */ -@Beta -public final class ForwardInvocationToInterface { - /** - * @param interfaceType - * {@link #getInterfaceType()} - */ - public static ForwardInvocationToInterface create(Invocation invocation, Class interfaceType) { - return new ForwardInvocationToInterface(invocation, interfaceType); - } - - private final Invocation invocation; - private final Class interfaceType; - - private ForwardInvocationToInterface(Invocation invocation, Class interfaceType) { - this.invocation = checkNotNull(invocation, "invocation"); - this.interfaceType = checkNotNull(interfaceType, "interfaceType"); - } - - public Invocation getInvocation() { - return invocation; - } - - public Class getInterfaceType() { - return interfaceType; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - ForwardInvocationToInterface that = ForwardInvocationToInterface.class.cast(o); - return equal(this.invocation, that.invocation) && equal(this.interfaceType, that.interfaceType); - } - - @Override - public int hashCode() { - return Objects.hashCode(invocation, interfaceType); - } - - @Override - public String toString() { - return string().toString(); - } - - protected ToStringHelper string() { - return Objects.toStringHelper("").omitNullValues().add("invocation", invocation).add("interfaceType", interfaceType); - } -} diff --git a/core/src/main/java/org/jclouds/reflect/Element.java b/core/src/main/java/org/jclouds/reflect/Element.java new file mode 100644 index 0000000000..e06cd9d7e5 --- /dev/null +++ b/core/src/main/java/org/jclouds/reflect/Element.java @@ -0,0 +1,180 @@ +/** + * 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.reflect; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.lang.annotation.Annotation; +import java.lang.reflect.AccessibleObject; +import java.lang.reflect.Member; +import java.lang.reflect.Modifier; + +import org.jclouds.javax.annotation.Nullable; + +import org.jclouds.reflect.Invokable; + +/** + * + * based on the {@link com.google.reflect.AccessibleObject} copied in as {@link com.google.reflect.Invokable} is package + * private. + * + * @author Adrian Cole + * @since 1.6 + */ +class Element extends AccessibleObject implements Member { + + private final AccessibleObject accessibleObject; + protected final Member member; + + Element( M member) { + this.member = checkNotNull(member, "member"); + this.accessibleObject = member; + } + + @Override + public final boolean isAnnotationPresent(Class annotationClass) { + return accessibleObject.isAnnotationPresent(annotationClass); + } + + @Override + public final A getAnnotation(Class annotationClass) { + return accessibleObject.getAnnotation(annotationClass); + } + + @Override + public final Annotation[] getAnnotations() { + return accessibleObject.getAnnotations(); + } + + @Override + public final Annotation[] getDeclaredAnnotations() { + return accessibleObject.getDeclaredAnnotations(); + } + + @Override + public final void setAccessible(boolean flag) throws SecurityException { + accessibleObject.setAccessible(flag); + } + + @Override + public final boolean isAccessible() { + return accessibleObject.isAccessible(); + } + + @Override + public Class getDeclaringClass() { + return member.getDeclaringClass(); + } + + @Override + public final String getName() { + return member.getName(); + } + + @Override + public final int getModifiers() { + return member.getModifiers(); + } + + @Override + public final boolean isSynthetic() { + return member.isSynthetic(); + } + + /** Returns true if the element is public. */ + public final boolean isPublic() { + return Modifier.isPublic(getModifiers()); + } + + /** Returns true if the element is protected. */ + public final boolean isProtected() { + return Modifier.isProtected(getModifiers()); + } + + /** Returns true if the element is package-private. */ + public final boolean isPackagePrivate() { + return !isPrivate() && !isPublic() && !isProtected(); + } + + /** Returns true if the element is private. */ + public final boolean isPrivate() { + return Modifier.isPrivate(getModifiers()); + } + + /** Returns true if the element is static. */ + public final boolean isStatic() { + return Modifier.isStatic(getModifiers()); + } + + /** + * Returns {@code true} if this method is final, per {@code Modifier.isFinal(getModifiers())}. + * + *

+ * Note that a method may still be effectively "final", or non-overridable when it has no {@code final} keyword. For + * example, it could be private, or it could be declared by a final class. To tell whether a method is overridable, + * use {@link Invokable#isOverridable}. + */ + public final boolean isFinal() { + return Modifier.isFinal(getModifiers()); + } + + /** Returns true if the method is abstract. */ + public final boolean isAbstract() { + return Modifier.isAbstract(getModifiers()); + } + + /** Returns true if the element is native. */ + public final boolean isNative() { + return Modifier.isNative(getModifiers()); + } + + /** Returns true if the method is synchronized. */ + public final boolean isSynchronized() { + return Modifier.isSynchronized(getModifiers()); + } + + /** Returns true if the field is volatile. */ + final boolean isVolatile() { + return Modifier.isVolatile(getModifiers()); + } + + /** Returns true if the field is transient. */ + final boolean isTransient() { + return Modifier.isTransient(getModifiers()); + } + + @Override + public boolean equals(@Nullable Object obj) { + if (obj instanceof Element) { + Element that = (Element) obj; + return member.equals(that.member); + } + return false; + } + + @Override + public int hashCode() { + return member.hashCode(); + } + + @Override + public String toString() { + return member.toString(); + } +} diff --git a/core/src/main/java/org/jclouds/reflect/FunctionalReflection.java b/core/src/main/java/org/jclouds/reflect/FunctionalReflection.java index a210f51159..0e92fdca5a 100644 --- a/core/src/main/java/org/jclouds/reflect/FunctionalReflection.java +++ b/core/src/main/java/org/jclouds/reflect/FunctionalReflection.java @@ -38,7 +38,7 @@ import com.google.common.annotations.Beta; import com.google.common.base.Function; import com.google.common.base.Objects; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; +import com.google.common.reflect.TypeToken; /** * Static utilities relating to functional Java reflection. @@ -48,8 +48,8 @@ import com.google.common.reflect.Invokable; @Beta public final class FunctionalReflection { /** - * Returns a proxy instance that implements {@code interfaceType} by dispatching method invocations to - * {@code invocationFunction}. The class loader of {@code interfaceType} will be used to define the proxy class. + * Returns a proxy instance that implements {@code enclosingType} by dispatching method invocations to + * {@code invocationFunction}. The class loader of {@code enclosingType} will be used to define the proxy class. *

* Usage example: * @@ -72,26 +72,37 @@ public final class FunctionalReflection { * @param invocationFunction * returns a result or a top-level exception, or result * @throws IllegalArgumentException - * if {@code interfaceType} does not specify the type of a Java interface + * if {@code enclosingType} does not specify the type of a Java interface * @see com.google.common.reflect.AbstractInvocationHandler#invoke(Object, Method, Object[]) * @see com.google.common.reflect.Reflection#newProxy(Class, java.lang.reflect.InvocationHandler) */ - public static T newProxy(Class interfaceType, Function invocationFunction) { - checkNotNull(interfaceType, "interfaceType"); + public static T newProxy(TypeToken enclosingType, Function invocationFunction) { + checkNotNull(enclosingType, "enclosingType"); checkNotNull(invocationFunction, "invocationFunction"); - checkArgument(interfaceType.isInterface(), "%s is not an interface", interfaceType); - Object object = Proxy.newProxyInstance(interfaceType.getClassLoader(), new Class[] { interfaceType }, - new FunctionalInvocationHandler(interfaceType, invocationFunction)); - return interfaceType.cast(object); + return newProxy(enclosingType.getRawType(), new FunctionalInvocationHandler(enclosingType, invocationFunction)); + } + + public static T newProxy(Class enclosingType, Function invocationFunction) { + checkNotNull(invocationFunction, "invocationFunction"); + return newProxy(enclosingType, + new FunctionalInvocationHandler(TypeToken.of(enclosingType), invocationFunction)); + } + + @SuppressWarnings("unchecked") + private static T newProxy(Class enclosingType, FunctionalInvocationHandler invocationHandler) { + checkNotNull(enclosingType, "enclosingType"); + checkArgument(enclosingType.isInterface(), "%s is not an interface", enclosingType); + return (T) Proxy.newProxyInstance(enclosingType.getClassLoader(), new Class[] { enclosingType }, + invocationHandler); } private static final class FunctionalInvocationHandler extends com.google.common.reflect.AbstractInvocationHandler { - private final Class interfaceType; + private final TypeToken enclosingType; private final Function invocationFunction; - private FunctionalInvocationHandler(Class interfaceType, Function invocationFunction) { - this.interfaceType = interfaceType; + private FunctionalInvocationHandler(TypeToken enclosingType, Function invocationFunction) { + this.enclosingType = enclosingType; this.invocationFunction = invocationFunction; } @@ -102,9 +113,9 @@ public final class FunctionalReflection { args = ImmutableList.copyOf(args); else args = Collections.unmodifiableList(args); - Invokable invokable = Invokable.class.cast(Invokable.from(invoked)); + Invokable invokable = Invokable.from(enclosingType, invoked); // not yet support the proxy arg - Invocation invocation = Invocation.create(interfaceType, invokable, args); + Invocation invocation = Invocation.create(invokable, args); Result result; try { result = invocationFunction.apply(invocation); @@ -125,13 +136,13 @@ public final class FunctionalReflection { if (o == null || getClass() != o.getClass()) return false; FunctionalInvocationHandler that = FunctionalInvocationHandler.class.cast(o); - return equal(this.interfaceType, that.interfaceType) + return equal(this.enclosingType, that.enclosingType) && equal(this.invocationFunction, that.invocationFunction); } @Override public int hashCode() { - return Objects.hashCode(interfaceType, invocationFunction); + return Objects.hashCode(enclosingType, invocationFunction); } @Override diff --git a/core/src/main/java/org/jclouds/reflect/Invocation.java b/core/src/main/java/org/jclouds/reflect/Invocation.java index a3e8b289da..cb9168b6d9 100644 --- a/core/src/main/java/org/jclouds/reflect/Invocation.java +++ b/core/src/main/java/org/jclouds/reflect/Invocation.java @@ -19,7 +19,6 @@ package org.jclouds.reflect; import static com.google.common.base.Objects.equal; -import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import java.util.List; @@ -28,12 +27,10 @@ import org.jclouds.javax.annotation.Nullable; import com.google.common.annotations.Beta; import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; import com.google.common.base.Optional; -import com.google.common.reflect.Invokable; /** - * Context needed to call {@link com.google.common.reflect.Invokable#invoke(Object, Object...)} + * Context needed to call {@link org.jclouds.reflect.Invokable#invoke(Object, Object...)} * * @author Adrian Cole */ @@ -41,48 +38,21 @@ import com.google.common.reflect.Invokable; public final class Invocation { /** - * Use this class when the invokable could be inherited. For example, a method is inherited when it cannot be - * retrieved by {@link Class#getDeclaredMethods()}, but it can be retrieved by {@link Class#getMethods()}. - * - * @param interfaceType - * type that either declared or inherited {@code invokable}, or was forwarded a call to it. - * @param args - * as these represent parameters, can contain nulls - */ - public static Invocation create(Class interfaceType, Invokable invokable, List args) { - checkArgument(invokable.getDeclaringClass().isAssignableFrom(interfaceType), "%s isn't assignable from %s", - invokable.getDeclaringClass(), interfaceType); - return new Invocation(interfaceType, invokable, args); - } - - /** - * Note: use {@link #create(Class, Invokable, List)} when the invokable was inherited. - * * @param args * as these represent parameters, can contain nulls */ public static Invocation create(Invokable invokable, List args) { - return new Invocation(invokable.getDeclaringClass(), invokable, args); + return new Invocation(invokable, args); } - private final Class interfaceType; private final Invokable invokable; private final List args; - private Invocation(Class interfaceType, Invokable invokable, List args) { - this.interfaceType = checkNotNull(interfaceType, "interfaceType"); + private Invocation(Invokable invokable, List args) { this.invokable = checkNotNull(invokable, "invokable"); this.args = checkNotNull(args, "args"); } - /** - * different than {@link Invokable#getDeclaringClass()} when {@link #getInvokable()} is a member of a class it was - * not declared in. - */ - public Class getInterfaceType() { - return interfaceType; - } - /** * what we can invoke */ @@ -107,19 +77,17 @@ public final class Invocation { if (o == null || getClass() != o.getClass()) return false; Invocation that = Invocation.class.cast(o); - return equal(this.interfaceType, that.interfaceType) && equal(this.invokable, that.invokable) - && equal(this.args, that.args); + return equal(this.invokable, that.invokable) && equal(this.args, that.args); } @Override public int hashCode() { - return Objects.hashCode(interfaceType, invokable, args); + return Objects.hashCode(invokable, args); } @Override public String toString() { - return Objects.toStringHelper("").omitNullValues().add("interfaceType", interfaceType) - .add("invokable", invokable).add("args", args.size() != 0 ? args : null).toString(); + return String.format("%s%s", invokable, args); } /** @@ -175,12 +143,8 @@ public final class Invocation { @Override public String toString() { - return string().toString(); - } - - protected ToStringHelper string() { return Objects.toStringHelper("").omitNullValues().add("result", result.orNull()) - .add("throwable", throwable.orNull()); + .add("throwable", throwable.orNull()).toString(); } } diff --git a/core/src/main/java/org/jclouds/reflect/InvocationSuccess.java b/core/src/main/java/org/jclouds/reflect/InvocationSuccess.java index fbc018a74c..ff1334728d 100644 --- a/core/src/main/java/org/jclouds/reflect/InvocationSuccess.java +++ b/core/src/main/java/org/jclouds/reflect/InvocationSuccess.java @@ -29,7 +29,7 @@ import com.google.common.base.Objects.ToStringHelper; import com.google.common.base.Optional; /** - * Holds the context of a successful call to {@link com.google.common.reflect.Invokable#invoke(Object, Object...)} + * Holds the context of a successful call to {@link org.jclouds.reflect.Invokable#invoke(Object, Object...)} * * @author Adrian Cole */ diff --git a/core/src/main/java/org/jclouds/reflect/Invokable.java b/core/src/main/java/org/jclouds/reflect/Invokable.java new file mode 100644 index 0000000000..c10bc568f7 --- /dev/null +++ b/core/src/main/java/org/jclouds/reflect/Invokable.java @@ -0,0 +1,347 @@ +/** + * 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.reflect; + +import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.lang.annotation.Annotation; +import java.lang.reflect.AccessibleObject; +import java.lang.reflect.Constructor; +import java.lang.reflect.GenericDeclaration; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Member; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.lang.reflect.Type; +import java.lang.reflect.TypeVariable; +import java.util.Arrays; + +import org.jclouds.javax.annotation.Nullable; + +import com.google.common.annotations.Beta; +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableList; +import com.google.common.reflect.TypeToken; + +/** + * based on the {@link com.google.reflect.AccessibleObject} copied in as {@link com.google.reflect.Invokable} is package + * private. This adds access to {#link {@link #getEnclosingType()} and folds in ability to lookup methods and + * constructors by name. + * + * @author Adrian Cole + * @since 1.6 + */ +@Beta +public abstract class Invokable extends Element implements GenericDeclaration { + protected final TypeToken enclosingType; + + Invokable(TypeToken enclosingType, M member) { + super(member); + this.enclosingType = checkNotNull(enclosingType, "enclosingType"); + } + + /** Returns {@link Invokable} of {@code method}. */ + public static Invokable from(Method method) { + return from(TypeToken.of(method.getDeclaringClass()), method); + } + + /** Returns {@link Invokable} of {@code constructor}. */ + public static Invokable from(Constructor constructor) { + return from(TypeToken.of(constructor.getDeclaringClass()), constructor); + } + + /** Returns {@link Invokable} of {@code method}. */ + public static Invokable from(TypeToken enclosingType, Method method) { + return new MethodInvokable(enclosingType, method); + } + + /** Returns {@link Invokable} of {@code constructor}. */ + public static Invokable from(TypeToken enclosingType, Constructor constructor) { + return new ConstructorInvokable(enclosingType, constructor); + } + + /** + * different than {@link #getDeclaringClass()} when this is a member of a class it was not declared in. + */ + public TypeToken getEnclosingType() { + return enclosingType; + } + + /** + * Returns {@code true} if this is an overridable method. Constructors, private, static or final methods, or methods + * declared by final classes are not overridable. + */ + public abstract boolean isOverridable(); + + /** Returns {@code true} if this was declared to take a variable number of arguments. */ + public abstract boolean isVarArgs(); + + /** + * Invokes with {@code receiver} as 'this' and {@code args} passed to the underlying method and returns the return + * value; or calls the underlying constructor with {@code args} and returns the constructed instance. + * + * @throws IllegalAccessException + * if this {@code Constructor} object enforces Java language access control and the underlying method or + * constructor is inaccessible. + * @throws IllegalArgumentException + * if the number of actual and formal parameters differ; if an unwrapping conversion for primitive + * arguments fails; or if, after possible unwrapping, a parameter value cannot be converted to the + * corresponding formal parameter type by a method invocation conversion. + * @throws InvocationTargetException + * if the underlying method or constructor throws an exception. + */ + // All subclasses are owned by us and we'll make sure to get the R type right. + @SuppressWarnings("unchecked") + public final R invoke(@Nullable T receiver, Object... args) throws InvocationTargetException, IllegalAccessException { + return (R) invokeInternal(receiver, checkNotNull(args, "args")); + } + + /** Returns the return type of this {@code Invokable}. */ + // All subclasses are owned by us and we'll make sure to get the R type right. + @SuppressWarnings("unchecked") + public final TypeToken getReturnType() { + return (TypeToken) TypeToken.of(getGenericReturnType()); + } + + /** + * Returns all declared parameters of this {@code Invokable}. Note that if this is a constructor of a non-static + * inner class, unlike {@link Constructor#getParameterTypes}, the hidden {@code this} parameter of the enclosing + * class is excluded from the returned parameters. + */ + public final ImmutableList getParameters() { + Type[] parameterTypes = getGenericParameterTypes(); + Annotation[][] annotations = getParameterAnnotations(); + ImmutableList.Builder builder = ImmutableList.builder(); + for (int i = 0; i < parameterTypes.length; i++) { + builder.add(new Parameter(this, i, TypeToken.of(parameterTypes[i]), annotations[i])); + } + return builder.build(); + } + + /** Returns all declared exception types of this {@code Invokable}. */ + public final ImmutableList> getExceptionTypes() { + ImmutableList.Builder> builder = ImmutableList.builder(); + for (Type type : getGenericExceptionTypes()) { + // getGenericExceptionTypes() will never return a type that's not exception + @SuppressWarnings("unchecked") + TypeToken exceptionType = (TypeToken) TypeToken.of(type); + builder.add(exceptionType); + } + return builder.build(); + } + + /** + * Explicitly specifies the return type of this {@code Invokable}. For example: + * + *
+    * {
+    *    @code
+    *    Method factoryMethod = Person.class.getMethod("create");
+    *    Invokable<?, Person> factory = Invokable.of(getNameMethod).returning(Person.class);
+    * }
+    * 
+ */ + public final Invokable returning(Class returnType) { + return returning(TypeToken.of(returnType)); + } + + /** Explicitly specifies the return type of this {@code Invokable}. */ + public final Invokable returning(TypeToken returnType) { + if (!returnType.isAssignableFrom(getReturnType())) { + throw new IllegalArgumentException("Invokable is known to return " + getReturnType() + ", not " + returnType); + } + @SuppressWarnings("unchecked") + // guarded by previous check + Invokable specialized = (Invokable) this; + return specialized; + } + + @SuppressWarnings("unchecked") + // The declaring class is T's raw class, or one of its supertypes. + @Override + public final Class getDeclaringClass() { + return (Class) super.getDeclaringClass(); + } + + abstract Object invokeInternal(@Nullable Object receiver, Object[] args) throws InvocationTargetException, + IllegalAccessException; + + abstract Type[] getGenericParameterTypes(); + + /** This should never return a type that's not a subtype of Throwable. */ + abstract Type[] getGenericExceptionTypes(); + + abstract Annotation[][] getParameterAnnotations(); + + abstract Type getGenericReturnType(); + + static class MethodInvokable extends Invokable { + + private final Method method; + + MethodInvokable(TypeToken enclosingType, Method method) { + super(enclosingType, method); + this.method = method; + checkArgument(TypeToken.of(method.getDeclaringClass()).isAssignableFrom(enclosingType), + "%s not declared by %s", method, enclosingType); + } + + @Override + final Object invokeInternal(@Nullable Object receiver, Object[] args) throws InvocationTargetException, + IllegalAccessException { + return method.invoke(receiver, args); + } + + @Override + Type getGenericReturnType() { + return resolveType(method.getGenericReturnType()).getType(); + } + + @Override + Type[] getGenericParameterTypes() { + return resolveInPlace(method.getGenericParameterTypes()); + } + + @Override + Type[] getGenericExceptionTypes() { + return resolveInPlace(method.getGenericExceptionTypes()); + } + + @Override + final Annotation[][] getParameterAnnotations() { + return method.getParameterAnnotations(); + } + + @Override + public final TypeVariable[] getTypeParameters() { + return method.getTypeParameters(); + } + + @Override + public final boolean isOverridable() { + return !(isFinal() || isPrivate() || isStatic() || Modifier.isFinal(getDeclaringClass().getModifiers())); + } + + @Override + public final boolean isVarArgs() { + return method.isVarArgs(); + } + } + + protected TypeToken resolveType(Type type) { + return enclosingType.resolveType(type); + } + + protected Type[] resolveInPlace(Type[] types) { + for (int i = 0; i < types.length; i++) { + types[i] = resolveType(types[i]).getType(); + } + return types; + } + + static class ConstructorInvokable extends Invokable { + + private final Constructor constructor; + + ConstructorInvokable(TypeToken enclosingType, Constructor constructor) { + super(enclosingType, constructor); + this.constructor = constructor; + checkArgument(constructor.getDeclaringClass() == enclosingType.getRawType(), "%s not declared by %s", + constructor, enclosingType.getRawType()); + } + + @Override + final Object invokeInternal(@Nullable Object receiver, Object[] args) throws InvocationTargetException, + IllegalAccessException { + try { + return constructor.newInstance(args); + } catch (InstantiationException e) { + throw new RuntimeException(constructor + " failed.", e); + } + } + + @Override + Type getGenericReturnType() { + return resolveType(constructor.getDeclaringClass()).getType(); + } + + @Override + Type[] getGenericParameterTypes() { + Type[] types = constructor.getGenericParameterTypes(); + Class declaringClass = constructor.getDeclaringClass(); + if (!Modifier.isStatic(declaringClass.getModifiers()) && declaringClass.getEnclosingClass() != null) { + if (types.length == constructor.getParameterTypes().length) { + // first parameter is the hidden 'this' + return Arrays.copyOfRange(types, 1, types.length); + } + } + return resolveInPlace(types); + } + + @Override + Type[] getGenericExceptionTypes() { + return resolveInPlace(constructor.getGenericExceptionTypes()); + } + + @Override + final Annotation[][] getParameterAnnotations() { + return constructor.getParameterAnnotations(); + } + + @Override + public final TypeVariable[] getTypeParameters() { + return constructor.getTypeParameters(); + } + + @Override + public final boolean isOverridable() { + return false; + } + + @Override + public final boolean isVarArgs() { + return constructor.isVarArgs(); + } + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + Invokable that = Invokable.class.cast(o); + return equal(this.enclosingType, that.enclosingType) && super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hashCode(enclosingType, super.hashCode()); + } + + @Override + public String toString() { + int parametersTypeHashCode = 0; + for (Parameter param : getParameters()) + parametersTypeHashCode += param.getType().hashCode(); + return String.format("%s.%s[%s]", enclosingType.getRawType().getSimpleName(), getName(), parametersTypeHashCode); + } +} diff --git a/core/src/main/java/org/jclouds/reflect/Parameter.java b/core/src/main/java/org/jclouds/reflect/Parameter.java new file mode 100644 index 0000000000..7948de399c --- /dev/null +++ b/core/src/main/java/org/jclouds/reflect/Parameter.java @@ -0,0 +1,115 @@ +/** + * 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.reflect; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.lang.annotation.Annotation; +import java.lang.reflect.AnnotatedElement; + +import org.jclouds.javax.annotation.Nullable; + +import com.google.common.annotations.Beta; +import com.google.common.collect.ImmutableList; +import com.google.common.reflect.TypeToken; + +/** + * + * based on the {@link com.google.reflect.AccessibleObject} copied in as {@link com.google.reflect.Parameter} is package + * private and decided not to add {@link #getPosition} + * + * @author Adrian Cole + * @since 1.6 + */ +@Beta +public final class Parameter implements AnnotatedElement { + + private final Invokable declaration; + private final int position; + private final TypeToken type; + private final ImmutableList annotations; + + Parameter(Invokable declaration, int position, TypeToken type, Annotation[] annotations) { + this.declaration = declaration; + this.position = position; + this.type = type; + this.annotations = ImmutableList.copyOf(annotations); + } + + /** Returns the position of the parameter. */ + public int getPosition() { + return position; + } + + /** Returns the type of the parameter. */ + public TypeToken getType() { + return type; + } + + /** Returns the {@link Invokable} that declares this parameter. */ + public Invokable getDeclaringInvokable() { + return declaration; + } + + @Override + public boolean isAnnotationPresent(Class annotationType) { + return getAnnotation(annotationType) != null; + } + + @Override + @Nullable + public A getAnnotation(Class annotationType) { + checkNotNull(annotationType); + for (Annotation annotation : annotations) { + if (annotationType.isInstance(annotation)) { + return annotationType.cast(annotation); + } + } + return null; + } + + @Override + public Annotation[] getAnnotations() { + return getDeclaredAnnotations(); + } + + @Override + public Annotation[] getDeclaredAnnotations() { + return annotations.toArray(new Annotation[annotations.size()]); + } + + @Override + public boolean equals(@Nullable Object obj) { + if (obj instanceof Parameter) { + Parameter that = (Parameter) obj; + return position == that.position && declaration.equals(that.declaration); + } + return false; + } + + @Override + public int hashCode() { + return position; + } + + @Override + public String toString() { + return type + " arg" + position; + } +} diff --git a/core/src/main/java/org/jclouds/rest/InputParamValidator.java b/core/src/main/java/org/jclouds/rest/InputParamValidator.java index f33e4b82ad..fa61c5fef0 100644 --- a/core/src/main/java/org/jclouds/rest/InputParamValidator.java +++ b/core/src/main/java/org/jclouds/rest/InputParamValidator.java @@ -27,12 +27,12 @@ import javax.inject.Inject; import org.jclouds.predicates.Validator; import org.jclouds.reflect.Invocation; +import org.jclouds.reflect.Parameter; import org.jclouds.rest.annotations.ParamValidators; import com.google.common.base.Predicate; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; -import com.google.common.reflect.Parameter; import com.google.inject.Injector; /** diff --git a/core/src/main/java/org/jclouds/rest/binders/BindMapToStringPayload.java b/core/src/main/java/org/jclouds/rest/binders/BindMapToStringPayload.java index cc3332db2d..2be6fc7f45 100644 --- a/core/src/main/java/org/jclouds/rest/binders/BindMapToStringPayload.java +++ b/core/src/main/java/org/jclouds/rest/binders/BindMapToStringPayload.java @@ -32,7 +32,7 @@ import org.jclouds.rest.MapBinder; import org.jclouds.rest.annotations.Payload; import org.jclouds.rest.internal.GeneratedHttpRequest; -import com.google.common.reflect.Invokable; +import org.jclouds.reflect.Invokable; /** * diff --git a/core/src/main/java/org/jclouds/rest/config/AsyncClientProvider.java b/core/src/main/java/org/jclouds/rest/config/AsyncClientProvider.java index 4cb7237e14..e4920d0d52 100644 --- a/core/src/main/java/org/jclouds/rest/config/AsyncClientProvider.java +++ b/core/src/main/java/org/jclouds/rest/config/AsyncClientProvider.java @@ -22,7 +22,7 @@ import javax.inject.Inject; import javax.inject.Singleton; import org.jclouds.reflect.FunctionalReflection; -import org.jclouds.rest.internal.AsyncRestClientProxy; +import org.jclouds.rest.internal.InvokeAsyncApi; import com.google.inject.Provider; import com.google.inject.TypeLiteral; @@ -34,10 +34,10 @@ import com.google.inject.TypeLiteral; @Singleton public class AsyncClientProvider implements Provider { private final Class asyncClientType; - private final AsyncRestClientProxy proxy; + private final InvokeAsyncApi proxy; @Inject - private AsyncClientProvider(AsyncRestClientProxy proxy, TypeLiteral asyncClientType) { + private AsyncClientProvider(InvokeAsyncApi proxy, TypeLiteral asyncClientType) { this.proxy = proxy; this.asyncClientType = asyncClientType.getRawType(); } diff --git a/core/src/main/java/org/jclouds/rest/config/BinderUtils.java b/core/src/main/java/org/jclouds/rest/config/BinderUtils.java index fcb61cee3e..3a8463a600 100644 --- a/core/src/main/java/org/jclouds/rest/config/BinderUtils.java +++ b/core/src/main/java/org/jclouds/rest/config/BinderUtils.java @@ -46,8 +46,10 @@ public class BinderUtils { * type type that returns {@link ListenableFuture} */ public static void bindClientAndAsyncClient(Binder binder, Class sync, Class async) { - bindAsyncClient(binder, async); - bindClient(binder, sync, async); + bindClass(binder, sync); + bindClass(binder, async); + bindAsyncClientProvider(binder, async); + bindClientProvider(binder, sync, async); } /** @@ -64,9 +66,14 @@ public class BinderUtils { * @param async * type type that returns {@link ListenableFuture} */ - @SuppressWarnings("unchecked") public static void bindClient(Binder binder, Class sync, Class async) { bindClass(binder, sync); + bindClass(binder, async); + bindClientProvider(binder, sync, async); + } + + @SuppressWarnings("unchecked") + private static void bindClientProvider(Binder binder, Class sync, Class async) { TypeToken> token = new TypeToken>() { private static final long serialVersionUID = 1L; }.where(new TypeParameter() { @@ -83,9 +90,13 @@ public class BinderUtils { }, sync).getType()))).toInstance(sync); } - @SuppressWarnings("unchecked") - private static void bindAsyncClient(Binder binder, Class async) { + public static void bindAsyncClient(Binder binder, Class async) { bindClass(binder, async); + bindAsyncClientProvider(binder, async); + } + + @SuppressWarnings("unchecked") + private static void bindAsyncClientProvider(Binder binder, Class async) { TypeToken> token = new TypeToken>() { private static final long serialVersionUID = 1L; }.where(new TypeParameter() { diff --git a/core/src/main/java/org/jclouds/rest/config/ClientProvider.java b/core/src/main/java/org/jclouds/rest/config/ClientProvider.java index 9d047e2ef9..ec8487611d 100644 --- a/core/src/main/java/org/jclouds/rest/config/ClientProvider.java +++ b/core/src/main/java/org/jclouds/rest/config/ClientProvider.java @@ -21,9 +21,12 @@ package org.jclouds.rest.config; import javax.inject.Inject; import javax.inject.Singleton; -import org.jclouds.concurrent.internal.SyncProxy; import org.jclouds.reflect.FunctionalReflection; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.InvokeSyncApi; +import com.google.common.cache.Cache; +import com.google.common.reflect.TypeToken; import com.google.inject.Provider; /** @@ -35,20 +38,22 @@ import com.google.inject.Provider; @Singleton public class ClientProvider implements Provider { - private final SyncProxy.Factory factory; + private final InvokeSyncApi.Factory factory; private final Class syncClientType; private final A asyncClient; @Inject - private ClientProvider(SyncProxy.Factory factory, Class syncClientType, A asyncClient) { + private ClientProvider(Cache, Invokable> invokables, InvokeSyncApi.Factory factory, + Class syncClientType, Class asyncClientType, A asyncClient) { this.factory = factory; this.asyncClient = asyncClient; this.syncClientType = syncClientType; + RestModule.putInvokables(TypeToken.of(syncClientType), TypeToken.of(asyncClientType), invokables); } @Override @Singleton public S get() { - return FunctionalReflection.newProxy(syncClientType, factory.create(syncClientType, asyncClient)); + return FunctionalReflection.newProxy(syncClientType, factory.create(asyncClient)); } } diff --git a/core/src/main/java/org/jclouds/rest/config/RestClientModule.java b/core/src/main/java/org/jclouds/rest/config/RestClientModule.java index d1776f3641..9f2b685497 100644 --- a/core/src/main/java/org/jclouds/rest/config/RestClientModule.java +++ b/core/src/main/java/org/jclouds/rest/config/RestClientModule.java @@ -60,6 +60,7 @@ public class RestClientModule extends RestModule { "unbound type variable: %s, use ctor that explicitly assigns this", type); return type; } + /** * @see #RestClientModule(Map) */ @@ -91,8 +92,6 @@ public class RestClientModule extends RestModule { bindRetryHandlers(); } - - /** * overrides this to change the default retry handlers for the http engine * diff --git a/core/src/main/java/org/jclouds/rest/config/RestModule.java b/core/src/main/java/org/jclouds/rest/config/RestModule.java index 4693161eb8..2d4625ca87 100644 --- a/core/src/main/java/org/jclouds/rest/config/RestModule.java +++ b/core/src/main/java/org/jclouds/rest/config/RestModule.java @@ -18,39 +18,60 @@ */ package org.jclouds.rest.config; +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Throwables.propagate; +import static com.google.common.collect.Iterables.any; +import static com.google.common.collect.Maps.transformValues; +import static com.google.common.util.concurrent.Atomics.newReference; import static org.jclouds.Constants.PROPERTY_TIMEOUTS_PREFIX; +import static org.jclouds.http.HttpUtils.tryFindHttpMethod; import static org.jclouds.rest.config.BinderUtils.bindClientAndAsyncClient; +import static org.jclouds.util.Maps2.transformKeys; +import static org.jclouds.util.Predicates2.startsWith; +import java.lang.reflect.Method; import java.net.URI; +import java.util.Arrays; import java.util.Map; +import java.util.Set; import java.util.concurrent.atomic.AtomicReference; import javax.inject.Named; import javax.inject.Singleton; +import javax.ws.rs.Path; -import org.jclouds.concurrent.internal.SyncProxy; -import org.jclouds.concurrent.internal.SyncProxy.CreateClientForCaller; import org.jclouds.functions.IdentityFunction; +import org.jclouds.http.HttpRequest; +import org.jclouds.http.HttpResponse; import org.jclouds.http.functions.config.SaxParserModule; import org.jclouds.internal.FilterStringsBoundToInjectorByName; -import org.jclouds.internal.ForwardInvocationToInterface; import org.jclouds.json.config.GsonModule; import org.jclouds.location.config.LocationModule; +import org.jclouds.reflect.Invocation; +import org.jclouds.reflect.Invokable; +import org.jclouds.reflect.Parameter; import org.jclouds.rest.AuthorizationException; import org.jclouds.rest.HttpAsyncClient; import org.jclouds.rest.HttpClient; import org.jclouds.rest.binders.BindToJsonPayloadWrappedWith; -import org.jclouds.rest.internal.AsyncRestClientProxy; -import org.jclouds.rest.internal.RestAnnotationProcessor; -import org.jclouds.util.Maps2; -import org.jclouds.util.Predicates2; +import org.jclouds.rest.internal.GeneratedHttpRequest; +import org.jclouds.rest.internal.InvokeAsyncApi; +import org.jclouds.rest.internal.InvokeFutureAndBlock; +import org.jclouds.rest.internal.InvokeListenableFutureViaHttp; +import org.jclouds.rest.internal.InvokeSyncApi; +import org.jclouds.rest.internal.TransformerForRequest; import com.google.common.base.Function; +import com.google.common.base.Objects; import com.google.common.base.Predicate; import com.google.common.base.Supplier; +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; +import com.google.common.collect.FluentIterable; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Maps; -import com.google.common.util.concurrent.Atomics; +import com.google.common.collect.ImmutableSet; +import com.google.common.reflect.TypeToken; +import com.google.common.util.concurrent.ListenableFuture; import com.google.inject.AbstractModule; import com.google.inject.Provides; import com.google.inject.TypeLiteral; @@ -60,31 +81,105 @@ public class RestModule extends AbstractModule { public static final TypeLiteral> URI_SUPPLIER_TYPE = new TypeLiteral>() { }; - private final Map, Class> sync2Async; - protected final AtomicReference authException = Atomics.newReference(); + + protected final Map, Class> sync2Async; + protected final AtomicReference authException = newReference(); public RestModule() { this(ImmutableMap., Class> of()); } + private static final Set objectMethods = ImmutableSet.copyOf(Object.class.getMethods()); + public RestModule(Map, Class> sync2Async) { this.sync2Async = sync2Async; } + @Provides + @Singleton + protected Predicate> mapsToAsyncHttpRequest(final Cache, Invokable> backing) { + return new Predicate>() { + public boolean apply(Invokable in) { // TODO: this is dynamic, but perhaps needs to be cached + return FluentIterable.from(backing.asMap().values()).anyMatch(mapsToAsyncHttpRequest(in)); + } + }; + } + + private static Predicate> mapsToAsyncHttpRequest(Invokable toTest) { + final int soughtHash = hashEnclosingTypeNameAndParameters(toTest); + return new Predicate>() { + public boolean apply(Invokable in) { + return in.isAnnotationPresent(Path.class) || tryFindHttpMethod(in).isPresent() + || any(in.getParameters(), new Predicate() { + public boolean apply(Parameter in) { + return in.getType().getRawType().isAssignableFrom(HttpRequest.class); + } + }) && in.getReturnType().getRawType().isAssignableFrom(ListenableFuture.class) + && soughtHash == hashEnclosingTypeNameAndParameters(in); + } + }; + } + + /** + * when looking for a match, we ignore the return type + */ + public static int hashEnclosingTypeNameAndParameters(Invokable in) { + int parametersTypeHashCode = 0; + for (Parameter param : in.getParameters()) + parametersTypeHashCode += param.getType().hashCode(); + return Objects.hashCode(in.getEnclosingType(), in.getName(), parametersTypeHashCode); + } + + /** + * seeds well-known invokables. + */ + @Provides + @Singleton + protected Cache, Invokable> seedKnownSync2AsyncInvokables() { + Cache, Invokable> sync2AsyncBuilder = CacheBuilder.newBuilder().build(); + putInvokables(TypeToken.of(HttpClient.class), TypeToken.of(HttpAsyncClient.class), sync2AsyncBuilder); + for (Class s : sync2Async.keySet()) { + putInvokables(TypeToken.of(s), TypeToken.of(sync2Async.get(s)), sync2AsyncBuilder); + } + return sync2AsyncBuilder; + } + + // accessible for ClientProvider + public static void putInvokables(TypeToken sync, TypeToken async, Cache, Invokable> cache) { + for (Method invoked : sync.getRawType().getMethods()) { + if (!objectMethods.contains(invoked)) { + try { + Method delegatedMethod = async.getRawType().getMethod(invoked.getName(), invoked.getParameterTypes()); + checkArgument(Arrays.equals(delegatedMethod.getExceptionTypes(), invoked.getExceptionTypes()), "invoked %s has different typed exceptions than delegated invoked %s", invoked, + delegatedMethod); + invoked.setAccessible(true); + delegatedMethod.setAccessible(true); + cache.put(Invokable.from(sync, invoked), Invokable.from(async, delegatedMethod)); + } catch (SecurityException e) { + throw propagate(e); + } catch (NoSuchMethodException e) { + throw propagate(e); + } + } + } + } + protected void installLocations() { install(new LocationModule()); } @Override protected void configure() { - bind(new TypeLiteral, Class>>(){}).toInstance(sync2Async); + bind(new TypeLiteral, Class>>() { + }).toInstance(sync2Async); install(new SaxParserModule()); install(new GsonModule()); install(new FactoryModuleBuilder().build(BindToJsonPayloadWrappedWith.Factory.class)); - install(new FactoryModuleBuilder().build(RestAnnotationProcessor.Caller.Factory.class)); - install(new FactoryModuleBuilder().build(AsyncRestClientProxy.Caller.Factory.class)); + install(new FactoryModuleBuilder().build(InvokeAsyncApi.Delegate.Factory.class)); + install(new FactoryModuleBuilder().build(InvokeFutureAndBlock.Factory.class)); + install(new FactoryModuleBuilder().build(InvokeListenableFutureViaHttp.Caller.Factory.class)); bind(IdentityFunction.class).toInstance(IdentityFunction.INSTANCE); - install(new FactoryModuleBuilder().build(SyncProxy.Factory.class)); + install(new FactoryModuleBuilder().build(InvokeSyncApi.Factory.class)); bindClientAndAsyncClient(binder(), HttpClient.class, HttpAsyncClient.class); // this will help short circuit scenarios that can otherwise lock out users bind(new TypeLiteral>() { @@ -93,8 +188,10 @@ public class RestModule extends AbstractModule { }).to(FilterStringsBoundToInjectorByName.class); bind(new TypeLiteral, Map>>() { }).to(FilterStringsBoundToInjectorByName.class); - bind(new TypeLiteral>() { - }).to(CreateClientForCaller.class); + bind(new TypeLiteral>>() { + }).to(InvokeListenableFutureViaHttp.class); + bind(new TypeLiteral>>() { + }).to(TransformerForRequest.class); installLocations(); } @@ -102,22 +199,16 @@ public class RestModule extends AbstractModule { @Singleton @Named("TIMEOUTS") protected Map timeouts(Function, Map> filterStringsBoundByName) { - Map stringBoundWithTimeoutPrefix = filterStringsBoundByName.apply(Predicates2.startsWith(PROPERTY_TIMEOUTS_PREFIX)); - Map longsByName = Maps.transformValues(stringBoundWithTimeoutPrefix, new Function() { - - @Override + Map stringBoundWithTimeoutPrefix = filterStringsBoundByName.apply(startsWith(PROPERTY_TIMEOUTS_PREFIX)); + Map longsByName = transformValues(stringBoundWithTimeoutPrefix, new Function() { public Long apply(String input) { return Long.valueOf(String.valueOf(input)); } - }); - return Maps2.transformKeys(longsByName, new Function() { - - @Override + return transformKeys(longsByName, new Function() { public String apply(String input) { return input.replaceFirst(PROPERTY_TIMEOUTS_PREFIX, ""); } - }); } diff --git a/core/src/main/java/org/jclouds/rest/internal/AsyncRestClientProxy.java b/core/src/main/java/org/jclouds/rest/internal/AsyncRestClientProxy.java deleted file mode 100644 index 425ef969f9..0000000000 --- a/core/src/main/java/org/jclouds/rest/internal/AsyncRestClientProxy.java +++ /dev/null @@ -1,529 +0,0 @@ -/** - * 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.rest.internal; - -import static com.google.common.base.Functions.compose; -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Predicates.in; -import static com.google.common.base.Predicates.not; -import static com.google.common.base.Throwables.propagate; -import static com.google.common.collect.Iterables.any; -import static com.google.common.collect.Iterables.find; -import static com.google.common.util.concurrent.Futures.immediateFailedFuture; -import static com.google.common.util.concurrent.Futures.transform; -import static com.google.common.util.concurrent.Futures.withFallback; -import static com.google.inject.util.Types.newParameterizedType; -import static javax.ws.rs.core.MediaType.APPLICATION_JSON; -import static javax.ws.rs.core.MediaType.APPLICATION_XML; -import static org.jclouds.concurrent.Futures.makeListenable; -import static org.jclouds.http.HttpUtils.tryFindHttpMethod; -import static org.jclouds.util.Optionals2.isReturnTypeOptional; -import static org.jclouds.util.Optionals2.unwrapIfOptional; -import static org.jclouds.util.Throwables2.getFirstThrowableOfType; - -import java.io.InputStream; -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; -import java.lang.reflect.WildcardType; -import java.net.URI; -import java.util.Set; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Qualifier; -import javax.inject.Singleton; -import javax.lang.model.type.NullType; -import javax.ws.rs.Path; - -import org.jclouds.Constants; -import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions; -import org.jclouds.functions.IdentityFunction; -import org.jclouds.functions.OnlyElementOrNull; -import org.jclouds.http.HttpCommand; -import org.jclouds.http.HttpCommandExecutorService; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.functions.ParseFirstJsonValueNamed; -import org.jclouds.http.functions.ParseJson; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.http.functions.ParseSax.HandlerWithResult; -import org.jclouds.http.functions.ParseURIFromListOrLocationHeaderIf20x; -import org.jclouds.http.functions.ParseXMLWithJAXB; -import org.jclouds.http.functions.ReleasePayloadAndReturn; -import org.jclouds.http.functions.ReturnInputStream; -import org.jclouds.http.functions.ReturnStringIf2xx; -import org.jclouds.http.functions.ReturnTrueIf2xx; -import org.jclouds.http.functions.UnwrapOnlyJsonValue; -import org.jclouds.json.internal.GsonWrapper; -import org.jclouds.logging.Logger; -import org.jclouds.reflect.FunctionalReflection; -import org.jclouds.reflect.Invocation; -import org.jclouds.reflect.Invocation.Result; -import org.jclouds.reflect.InvocationSuccess; -import org.jclouds.rest.AuthorizationException; -import org.jclouds.rest.InvocationContext; -import org.jclouds.rest.annotations.Delegate; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.JAXBResponseParser; -import org.jclouds.rest.annotations.OnlyElement; -import org.jclouds.rest.annotations.ResponseParser; -import org.jclouds.rest.annotations.SelectJson; -import org.jclouds.rest.annotations.Transform; -import org.jclouds.rest.annotations.Unwrap; -import org.jclouds.rest.annotations.XMLResponseParser; - -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Function; -import com.google.common.base.Objects; -import com.google.common.base.Optional; -import com.google.common.base.Predicate; -import com.google.common.base.Supplier; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import com.google.common.collect.FluentIterable; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableSet; -import com.google.common.reflect.Invokable; -import com.google.common.reflect.Parameter; -import com.google.common.reflect.TypeToken; -import com.google.common.util.concurrent.FutureFallback; -import com.google.common.util.concurrent.ListenableFuture; -import com.google.inject.Binding; -import com.google.inject.ConfigurationException; -import com.google.inject.Injector; -import com.google.inject.Key; -import com.google.inject.Provides; -import com.google.inject.ProvisionException; -import com.google.inject.TypeLiteral; -import com.google.inject.assistedinject.Assisted; - -/** - * Generates RESTful clients from appropriately annotated interfaces. - *

- * Particularly, this code delegates calls to other things. - *

    - *
  1. if the invoked has a {@link Provides} annotation, it responds via a {@link Injector} lookup
  2. - *
  3. if the invoked has a {@link Delegate} annotation, it responds with an instance of interface set in returnVal, - * adding the current JAXrs annotations to whatever are on that class.
  4. - *
      - *
    • ex. if the invoked with {@link Delegate} has a {@code Path} annotation, and the returnval interface also has - * {@code Path}, these values are combined.
    • - *
    - *
  5. if {@link RestAnnotationProcessor#delegationMap} contains a mapping for this, and the returnVal is properly - * assigned as a {@link ListenableFuture}, it responds with an http implementation.
  6. - *
  7. otherwise a RuntimeException is thrown with a message including: - * {@code invoked is intended solely to set constants}
  8. - *
- * - * @author Adrian Cole - */ -@Singleton -public class AsyncRestClientProxy implements Function { - - public final static class Caller extends AsyncRestClientProxy { - - public static interface Factory { - Caller caller(Invocation caller, Class interfaceType); - } - - @Inject - private Caller(Injector injector, Function> optionalConverter, - HttpCommandExecutorService http, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService userThreads, - Caller.Factory factory, RestAnnotationProcessor.Caller.Factory rap, ParseSax.Factory parserFactory, - @Assisted Invocation caller) { - super(injector, optionalConverter, http, userThreads, factory, rap.caller(caller), parserFactory); - } - } - - @Resource - private Logger logger = Logger.NULL; - - private final Injector injector; - private final HttpCommandExecutorService http; - private final ExecutorService userThreads; - private final Function> optionalConverter; - private final Caller.Factory factory; - private final RestAnnotationProcessor annotationProcessor; - private final ParseSax.Factory parserFactory; - - private static final LoadingCache, Set> delegationMapCache = CacheBuilder - .newBuilder().build(new CacheLoader, Set>() { - public Set load(final Class interfaceType) throws ExecutionException { - return FluentIterable.from(ImmutableSet.copyOf(interfaceType.getMethods())) - .filter(not(in(ImmutableSet.copyOf(Object.class.getMethods())))) - .transform(new Function>() { - public Invokable apply(Method in) { - return Invokable.from(in); - } - }).filter(new Predicate>() { - public boolean apply(Invokable in) { - return in.isAnnotationPresent(Path.class) || tryFindHttpMethod(in).isPresent() - || any(in.getParameters(), new Predicate() { - public boolean apply(Parameter in) { - return in.getType().getRawType().isAssignableFrom(HttpRequest.class); - } - }); - } - }).filter(new Predicate>() { - public boolean apply(Invokable in) { - return in.getReturnType().getRawType().isAssignableFrom(ListenableFuture.class); - } - }).transform(new Function, InterfaceNameAndParameters>() { - public InterfaceNameAndParameters apply(Invokable in) { - return new InterfaceNameAndParameters(interfaceType, in.getName(), in.getParameters()); - } - }).toSet(); - } - }); - - private static final class InterfaceNameAndParameters { - private final Class interfaceType; - private final String name; - private final int parametersTypeHashCode; - - private InterfaceNameAndParameters(Class interfaceType, String name, ImmutableList parameters) { - this.interfaceType = interfaceType; - this.name = name; - int parametersTypeHashCode = 0; - for (Parameter param : parameters) - parametersTypeHashCode += param.getType().hashCode(); - this.parametersTypeHashCode = parametersTypeHashCode; - } - - public int hashCode() { - return Objects.hashCode(interfaceType, name, parametersTypeHashCode); - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - InterfaceNameAndParameters that = InterfaceNameAndParameters.class.cast(o); - return equal(this.interfaceType, that.interfaceType) && equal(this.name, that.name) - && equal(this.parametersTypeHashCode, that.parametersTypeHashCode); - } - } - - @Inject - private AsyncRestClientProxy(Injector injector, Function> optionalConverter, - HttpCommandExecutorService http, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService userThreads, - Caller.Factory factory, RestAnnotationProcessor annotationProcessor, ParseSax.Factory parserFactory) { - this.injector = injector; - this.optionalConverter = optionalConverter; - this.http = http; - this.userThreads = userThreads; - this.factory = factory; - this.annotationProcessor = annotationProcessor; - this.parserFactory = parserFactory; - } - - private static final Predicate isQualifierPresent = new Predicate() { - public boolean apply(Annotation input) { - return input.annotationType().isAnnotationPresent(Qualifier.class); - } - }; - - @Override - public Result apply(Invocation invocation) { - if (invocation.getInvokable().isAnnotationPresent(Provides.class)) { - return Result.success(lookupValueFromGuice(invocation.getInvokable())); - } else if (invocation.getInvokable().isAnnotationPresent(Delegate.class)) { - return Result.success(propagateContextToDelegate(invocation)); - } else if (isAsyncOrDelegate(invocation)) { - return Result.success(createListenableFutureForHttpRequestMappedToMethodAndArgs(invocation)); - } else { - return Result.fail(new IllegalStateException(String.format( - "Method is not annotated as either http or provider invoked: %s", invocation.getInvokable()))); - } - } - - private boolean isAsyncOrDelegate(Invocation invocation) { - return delegationMapCache.getUnchecked(invocation.getInterfaceType()).contains( - new InterfaceNameAndParameters(invocation.getInterfaceType(), invocation.getInvokable().getName(), - invocation.getInvokable().getParameters())); - } - - private Object propagateContextToDelegate(Invocation invocation) { - Class returnType = unwrapIfOptional(invocation.getInvokable().getReturnType()); - Object result = FunctionalReflection.newProxy(returnType, factory.caller(invocation, returnType)); - if (isReturnTypeOptional(invocation.getInvokable())) { - return optionalConverter.apply(InvocationSuccess.create(invocation, result)); - } - return result; - } - - private Object lookupValueFromGuice(Invokable invoked) { - try { - Type genericReturnType = invoked.getReturnType().getType(); - try { - Annotation qualifier = find(ImmutableList.copyOf(invoked.getAnnotations()), isQualifierPresent); - return getInstanceOfTypeWithQualifier(genericReturnType, qualifier); - } catch (ProvisionException e) { - throw propagate(e.getCause()); - } catch (RuntimeException e) { - return instanceOfTypeOrPropagate(genericReturnType, e); - } - } catch (ProvisionException e) { - AuthorizationException aex = getFirstThrowableOfType(e, AuthorizationException.class); - if (aex != null) - throw aex; - throw e; - } - } - - private Object instanceOfTypeOrPropagate(Type genericReturnType, RuntimeException e) { - try { - // look for an existing binding - Binding binding = injector.getExistingBinding(Key.get(genericReturnType)); - if (binding != null) - return binding.getProvider().get(); - - // then, try looking via supplier - binding = injector.getExistingBinding(Key.get(newParameterizedType(Supplier.class, genericReturnType))); - if (binding != null) - return Supplier.class.cast(binding.getProvider().get()).get(); - - // else try to create an instance - return injector.getInstance(Key.get(genericReturnType)); - } catch (ConfigurationException ce) { - throw e; - } - } - - private Object getInstanceOfTypeWithQualifier(Type genericReturnType, Annotation qualifier) { - // look for an existing binding - Binding binding = injector.getExistingBinding(Key.get(genericReturnType, qualifier)); - if (binding != null) - return binding.getProvider().get(); - - // then, try looking via supplier - binding = injector - .getExistingBinding(Key.get(newParameterizedType(Supplier.class, genericReturnType), qualifier)); - if (binding != null) - return Supplier.class.cast(binding.getProvider().get()).get(); - - // else try to create an instance - return injector.getInstance(Key.get(genericReturnType, qualifier)); - } - - @SuppressWarnings("unchecked") - @VisibleForTesting - static Function createResponseParser(ParseSax.Factory parserFactory, Injector injector, - Invocation invocation, HttpRequest request) { - Function transformer; - Class> handler = getSaxResponseParserClassOrNull(invocation.getInvokable()); - if (handler != null) { - transformer = parserFactory.create(injector.getInstance(handler)); - } else { - transformer = getTransformerForMethod(invocation, injector); - } - if (transformer instanceof InvocationContext) { - ((InvocationContext) transformer).setContext(request); - } - if (invocation.getInvokable().isAnnotationPresent(Transform.class)) { - Function wrappingTransformer = injector.getInstance(invocation.getInvokable() - .getAnnotation(Transform.class).value()); - if (wrappingTransformer instanceof InvocationContext) { - ((InvocationContext) wrappingTransformer).setContext(request); - } - transformer = compose(Function.class.cast(wrappingTransformer), transformer); - } - return transformer; - } - - private static Class> getSaxResponseParserClassOrNull(Invokable invoked) { - XMLResponseParser annotation = invoked.getAnnotation(XMLResponseParser.class); - if (annotation != null) { - return annotation.value(); - } - return null; - } - - // TODO: refactor this out of here - @VisibleForTesting - @SuppressWarnings({ "rawtypes", "unchecked" }) - public static Function getTransformerForMethod(Invocation invocation, Injector injector) { - Invokable invoked = invocation.getInvokable(); - Function transformer; - if (invoked.isAnnotationPresent(SelectJson.class)) { - Type returnVal = getReturnTypeFor(invoked.getReturnType()); - if (invoked.isAnnotationPresent(OnlyElement.class)) - returnVal = newParameterizedType(Set.class, returnVal); - transformer = new ParseFirstJsonValueNamed(injector.getInstance(GsonWrapper.class), - TypeLiteral.get(returnVal), invoked.getAnnotation(SelectJson.class).value()); - if (invoked.isAnnotationPresent(OnlyElement.class)) - transformer = compose(new OnlyElementOrNull(), transformer); - } else { - transformer = injector.getInstance(getParserOrThrowException(invocation)); - } - return transformer; - } - - private ListenableFuture createListenableFutureForHttpRequestMappedToMethodAndArgs(Invocation invocation) { - String name = invocation.getInterfaceType().getSimpleName() + "." + invocation.getInvokable().getName(); - logger.trace(">> converting %s", name); - FutureFallback fallback = fallbacks.getUnchecked(invocation.getInvokable()); - // in case there is an exception creating the request, we should at least pass in args - if (fallback instanceof InvocationContext) { - InvocationContext.class.cast(fallback).setContext((HttpRequest) null); - } - ListenableFuture result; - try { - GeneratedHttpRequest request = annotationProcessor.apply(invocation); - if (fallback instanceof InvocationContext) { - InvocationContext.class.cast(fallback).setContext(request); - } - logger.trace("<< converted %s to %s", name, request.getRequestLine()); - - Function transformer = createResponseParser(parserFactory, injector, invocation, request); - logger.trace("<< response from %s is parsed by %s", name, transformer.getClass().getSimpleName()); - - logger.debug(">> invoking %s", name); - result = transform(makeListenable(http.submit(new HttpCommand(request)), userThreads), transformer); - } catch (RuntimeException e) { - AuthorizationException aex = getFirstThrowableOfType(e, AuthorizationException.class); - if (aex != null) - e = aex; - try { - return fallback.create(e); - } catch (Exception ex) { - return immediateFailedFuture(ex); - } - } - logger.trace("<< exceptions from %s are parsed by %s", name, fallback.getClass().getSimpleName()); - return withFallback(result, fallback); - } - - @Override - public String toString() { - return String.format("async->http"); - } - - private final LoadingCache, FutureFallback> fallbacks = CacheBuilder.newBuilder().build( - new CacheLoader, FutureFallback>() { - - @Override - public FutureFallback load(Invokable key) throws Exception { - Fallback annotation = key.getAnnotation(Fallback.class); - if (annotation != null) { - return injector.getInstance(annotation.value()); - } - return injector.getInstance(MapHttp4xxCodesToExceptions.class); - } - - }); - - private static final TypeToken> futureBooleanLiteral = new TypeToken>() { - private static final long serialVersionUID = 1L; - }; - private static final TypeToken> futureStringLiteral = new TypeToken>() { - private static final long serialVersionUID = 1L; - }; - private static final TypeToken> futureVoidLiteral = new TypeToken>() { - private static final long serialVersionUID = 1L; - }; - private static final TypeToken> futureURILiteral = new TypeToken>() { - private static final long serialVersionUID = 1L; - }; - private static final TypeToken> futureInputStreamLiteral = new TypeToken>() { - private static final long serialVersionUID = 1L; - }; - private static final TypeToken> futureHttpResponseLiteral = new TypeToken>() { - private static final long serialVersionUID = 1L; - }; - - @SuppressWarnings("unchecked") - @VisibleForTesting - static Key> getParserOrThrowException(Invocation invocation) { - Invokable invoked = invocation.getInvokable(); - ResponseParser annotation = invoked.getAnnotation(ResponseParser.class); - if (annotation == null) { - if (invoked.getReturnType().equals(void.class) || invoked.getReturnType().equals(futureVoidLiteral)) { - return Key.get(ReleasePayloadAndReturn.class); - } else if (invoked.getReturnType().equals(boolean.class) || invoked.getReturnType().equals(Boolean.class) - || invoked.getReturnType().equals(futureBooleanLiteral)) { - return Key.get(ReturnTrueIf2xx.class); - } else if (invoked.getReturnType().equals(InputStream.class) - || invoked.getReturnType().equals(futureInputStreamLiteral)) { - return Key.get(ReturnInputStream.class); - } else if (invoked.getReturnType().equals(HttpResponse.class) - || invoked.getReturnType().equals(futureHttpResponseLiteral)) { - return Key.get(Class.class.cast(IdentityFunction.class)); - } else if (RestAnnotationProcessor.getAcceptHeaders(invocation).contains(APPLICATION_JSON)) { - return getJsonParserKeyForMethod(invoked); - } else if (RestAnnotationProcessor.getAcceptHeaders(invocation).contains(APPLICATION_XML) - || invoked.isAnnotationPresent(JAXBResponseParser.class)) { - return getJAXBParserKeyForMethod(invoked); - } else if (invoked.getReturnType().equals(String.class) || invoked.getReturnType().equals(futureStringLiteral)) { - return Key.get(ReturnStringIf2xx.class); - } else if (invoked.getReturnType().equals(URI.class) || invoked.getReturnType().equals(futureURILiteral)) { - return Key.get(ParseURIFromListOrLocationHeaderIf20x.class); - } else { - throw new IllegalStateException("You must specify a ResponseParser annotation on: " + invoked.toString()); - } - } - return Key.get(annotation.value()); - } - - @SuppressWarnings("unchecked") - private static Key> getJAXBParserKeyForMethod(Invokable invoked) { - Optional configuredReturnVal = Optional.absent(); - if (invoked.isAnnotationPresent(JAXBResponseParser.class)) { - Type configuredClass = invoked.getAnnotation(JAXBResponseParser.class).value(); - configuredReturnVal = configuredClass.equals(NullType.class) ? Optional. absent() : Optional - . of(configuredClass); - } - Type returnVal = configuredReturnVal.or(getReturnTypeFor(invoked.getReturnType())); - Type parserType = newParameterizedType(ParseXMLWithJAXB.class, returnVal); - return (Key>) Key.get(parserType); - } - - @SuppressWarnings({ "unchecked" }) - private static Key> getJsonParserKeyForMethod(Invokable invoked) { - ParameterizedType parserType; - if (invoked.isAnnotationPresent(Unwrap.class)) { - parserType = newParameterizedType(UnwrapOnlyJsonValue.class, getReturnTypeFor(invoked.getReturnType())); - } else { - parserType = newParameterizedType(ParseJson.class, getReturnTypeFor(invoked.getReturnType())); - } - return (Key>) Key.get(parserType); - } - - private static Type getReturnTypeFor(TypeToken typeToken) { - Type returnVal = typeToken.getType(); - if (typeToken.getRawType().getTypeParameters().length == 0) { - returnVal = typeToken.getRawType(); - } else if (typeToken.getRawType().equals(ListenableFuture.class)) { - ParameterizedType futureType = (ParameterizedType) typeToken.getType(); - returnVal = futureType.getActualTypeArguments()[0]; - if (returnVal instanceof WildcardType) - returnVal = WildcardType.class.cast(returnVal).getUpperBounds()[0]; - } - return returnVal; - } - -} diff --git a/core/src/main/java/org/jclouds/rest/internal/BaseInvocationFunction.java b/core/src/main/java/org/jclouds/rest/internal/BaseInvocationFunction.java new file mode 100644 index 0000000000..e06a77c995 --- /dev/null +++ b/core/src/main/java/org/jclouds/rest/internal/BaseInvocationFunction.java @@ -0,0 +1,127 @@ +package org.jclouds.rest.internal; + +import static com.google.common.base.Throwables.propagate; +import static com.google.common.collect.Iterables.find; +import static com.google.inject.util.Types.newParameterizedType; +import static org.jclouds.util.Optionals2.isReturnTypeOptional; +import static org.jclouds.util.Optionals2.unwrapIfOptional; +import static org.jclouds.util.Throwables2.getFirstThrowableOfType; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Type; + +import javax.inject.Qualifier; + +import org.jclouds.reflect.FunctionalReflection; +import org.jclouds.reflect.Invocation; +import org.jclouds.reflect.Invocation.Result; +import org.jclouds.reflect.InvocationSuccess; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.AuthorizationException; +import org.jclouds.rest.annotations.Delegate; + +import com.google.common.annotations.Beta; +import com.google.common.base.Function; +import com.google.common.base.Optional; +import com.google.common.base.Predicate; +import com.google.common.base.Supplier; +import com.google.common.collect.ImmutableList; +import com.google.inject.Binding; +import com.google.inject.ConfigurationException; +import com.google.inject.Injector; +import com.google.inject.Key; +import com.google.inject.Provides; +import com.google.inject.ProvisionException; + +@Beta +abstract class BaseInvocationFunction implements Function { + protected final Injector injector; + protected final Function> optionalConverter; + + protected BaseInvocationFunction(Injector injector, Function> optionalConverter) { + this.injector = injector; + this.optionalConverter = optionalConverter; + } + + protected abstract Result invoke(Invocation in); + + protected abstract Function forwardInvocations(Invocation invocation, Class returnType); + + @Override + public Result apply(Invocation invocation) { + if (invocation.getInvokable().isAnnotationPresent(Provides.class)) + return Result.success(lookupValueFromGuice(invocation.getInvokable())); + else if (invocation.getInvokable().isAnnotationPresent(Delegate.class)) + return Result.success(propagateContextToDelegate(invocation)); + return invoke(invocation); + } + + private Object propagateContextToDelegate(Invocation invocation) { + Class returnType = unwrapIfOptional(invocation.getInvokable().getReturnType()); + Object result = FunctionalReflection.newProxy(returnType, forwardInvocations(invocation, returnType)); + if (isReturnTypeOptional(invocation.getInvokable())) { + result = optionalConverter.apply(InvocationSuccess.create(invocation, result)); + } + return result; + } + + static final Predicate isQualifierPresent = new Predicate() { + public boolean apply(Annotation input) { + return input.annotationType().isAnnotationPresent(Qualifier.class); + } + }; + + private Object lookupValueFromGuice(Invokable invoked) { + try { + Type genericReturnType = invoked.getReturnType().getType(); + try { + Annotation qualifier = find(ImmutableList.copyOf(invoked.getAnnotations()), isQualifierPresent); + return getInstanceOfTypeWithQualifier(genericReturnType, qualifier); + } catch (ProvisionException e) { + throw propagate(e.getCause()); + } catch (RuntimeException e) { + return instanceOfTypeOrPropagate(genericReturnType, e); + } + } catch (ProvisionException e) { + AuthorizationException aex = getFirstThrowableOfType(e, AuthorizationException.class); + if (aex != null) + throw aex; + throw e; + } + } + + Object instanceOfTypeOrPropagate(Type genericReturnType, RuntimeException e) { + try { + // look for an existing binding + Binding binding = injector.getExistingBinding(Key.get(genericReturnType)); + if (binding != null) + return binding.getProvider().get(); + + // then, try looking via supplier + binding = injector.getExistingBinding(Key.get(newParameterizedType(Supplier.class, genericReturnType))); + if (binding != null) + return Supplier.class.cast(binding.getProvider().get()).get(); + + // else try to create an instance + return injector.getInstance(Key.get(genericReturnType)); + } catch (ConfigurationException ce) { + throw e; + } + } + + Object getInstanceOfTypeWithQualifier(Type genericReturnType, Annotation qualifier) { + // look for an existing binding + Binding binding = injector.getExistingBinding(Key.get(genericReturnType, qualifier)); + if (binding != null) + return binding.getProvider().get(); + + // then, try looking via supplier + binding = injector + .getExistingBinding(Key.get(newParameterizedType(Supplier.class, genericReturnType), qualifier)); + if (binding != null) + return Supplier.class.cast(binding.getProvider().get()).get(); + + // else try to create an instance + return injector.getInstance(Key.get(genericReturnType, qualifier)); + } +} \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/rest/internal/GeneratedHttpRequest.java b/core/src/main/java/org/jclouds/rest/internal/GeneratedHttpRequest.java index 2db7a528a4..3970eb61a4 100644 --- a/core/src/main/java/org/jclouds/rest/internal/GeneratedHttpRequest.java +++ b/core/src/main/java/org/jclouds/rest/internal/GeneratedHttpRequest.java @@ -37,15 +37,15 @@ import com.google.common.collect.Multimap; * @author Adrian Cole */ public final class GeneratedHttpRequest extends HttpRequest { - public static Builder builder() { + public static Builder builder() { return new Builder(); } - - public Builder toBuilder() { + + public Builder toBuilder() { return new Builder().fromGeneratedHttpRequest(this); } - public final static class Builder extends HttpRequest.Builder { + public final static class Builder extends HttpRequest.Builder { protected Invocation invocation; protected Optional caller = Optional.absent(); @@ -57,7 +57,7 @@ public final class GeneratedHttpRequest extends HttpRequest { return this; } - /** + /** * @see GeneratedHttpRequest#getCaller() */ public Builder caller(@Nullable Invocation caller) { @@ -71,9 +71,15 @@ public final class GeneratedHttpRequest extends HttpRequest { } public Builder fromGeneratedHttpRequest(GeneratedHttpRequest in) { - return super.fromHttpRequest(in) - .invocation(in.invocation) - .caller(in.getCaller().orNull()); + return super.fromHttpRequest(in).invocation(in.invocation).caller(in.getCaller().orNull()); + } + + Invocation getInvocation() { + return invocation; + } + + Optional getCaller() { + return caller; } @Override @@ -81,7 +87,7 @@ public final class GeneratedHttpRequest extends HttpRequest { return this; } } - + private final Invocation invocation; private final Optional caller; diff --git a/core/src/main/java/org/jclouds/rest/internal/InvokeAsyncApi.java b/core/src/main/java/org/jclouds/rest/internal/InvokeAsyncApi.java new file mode 100644 index 0000000000..4686085854 --- /dev/null +++ b/core/src/main/java/org/jclouds/rest/internal/InvokeAsyncApi.java @@ -0,0 +1,122 @@ +/** + * 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.rest.internal; + +import static com.google.common.base.Preconditions.checkState; + +import javax.annotation.Resource; +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.logging.Logger; +import org.jclouds.reflect.Invocation; +import org.jclouds.reflect.Invocation.Result; +import org.jclouds.reflect.InvocationSuccess; +import org.jclouds.reflect.Invokable; + +import com.google.common.base.Function; +import com.google.common.base.Optional; +import com.google.common.base.Predicate; +import com.google.common.util.concurrent.ListenableFuture; +import com.google.inject.Injector; +import com.google.inject.Provides; +import com.google.inject.assistedinject.Assisted; + +/** + * Generates RESTful clients from appropriately annotated interfaces. + *

+ * Particularly, this code delegates calls to other things. + *

    + *
  1. if the invoked has a {@link Provides} annotation, it responds via a {@link Injector} lookup
  2. + *
  3. if the invoked has a {@link Delegate} annotation, it responds with an instance of interface set in returnVal, + * adding the current JAXrs annotations to whatever are on that class.
  4. + *
      + *
    • ex. if the invoked with {@link Delegate} has a {@code Path} annotation, and the returnval interface also has + * {@code Path}, these values are combined.
    • + *
    + *
  5. if {@link RestAnnotationProcessor#delegationMap} contains a mapping for this, and the returnVal is properly + * assigned as a {@link ListenableFuture}, it responds with an http implementation.
  6. + *
  7. otherwise a RuntimeException is thrown with a message including: + * {@code invoked is intended solely to set constants}
  8. + *
+ * + * @author Adrian Cole + */ +@Singleton +public class InvokeAsyncApi extends BaseInvocationFunction { + + public final static class Delegate extends InvokeAsyncApi { + + public static interface Factory { + Delegate caller(Invocation caller); + } + + private final String string; + + @Inject + private Delegate(Injector injector, Function> optionalConverter, + Predicate> mapsToAsyncHttpRequest, + InvokeListenableFutureViaHttp.Caller.Factory httpCallerFactory, Delegate.Factory factory, + @Assisted Invocation caller) { + super(injector, optionalConverter, mapsToAsyncHttpRequest, httpCallerFactory.caller(caller), factory); + this.string = String.format("%s->%s", caller, caller.getInvokable().getReturnType().getRawType() + .getSimpleName()); + } + + @Override + public String toString() { + return string; + } + } + + @Resource + private Logger logger = Logger.NULL; + + private final Predicate> mapsToAsyncHttpRequest; + private final Function> invokeMethod; + private final Delegate.Factory factory; + + @Inject + private InvokeAsyncApi(Injector injector, Function> optionalConverter, + Predicate> mapsToAsyncHttpRequest, Function> invokeMethod, + Delegate.Factory factory) { + super(injector, optionalConverter); + this.mapsToAsyncHttpRequest = mapsToAsyncHttpRequest; + this.invokeMethod = invokeMethod; + this.factory = factory; + } + + @Override + protected Result invoke(Invocation invocation) { + checkState(mapsToAsyncHttpRequest.apply(invocation.getInvokable()), + "please configure corresponding async class for %s in your RestClientModule", invocation.getInvokable()); + return Result.success(invokeMethod.apply(invocation)); + } + + @Override + protected Function forwardInvocations(Invocation invocation, Class returnType) { + return factory.caller(invocation); + } + + @Override + public String toString() { + return String.format("async->http"); + } + +} diff --git a/core/src/main/java/org/jclouds/rest/internal/InvokeFutureAndBlock.java b/core/src/main/java/org/jclouds/rest/internal/InvokeFutureAndBlock.java new file mode 100644 index 0000000000..46ffdadc5d --- /dev/null +++ b/core/src/main/java/org/jclouds/rest/internal/InvokeFutureAndBlock.java @@ -0,0 +1,116 @@ +/** + * 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.rest.internal; + +import static com.google.common.base.Optional.fromNullable; + +import java.lang.reflect.InvocationTargetException; +import java.util.Map; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +import javax.annotation.Resource; +import javax.inject.Inject; +import javax.inject.Named; + +import org.jclouds.logging.Logger; +import org.jclouds.reflect.Invocation; +import org.jclouds.reflect.Invocation.Result; +import org.jclouds.reflect.Invokable; + +import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Function; +import com.google.common.base.Optional; +import com.google.common.cache.Cache; +import com.google.common.util.concurrent.ListenableFuture; +import com.google.inject.assistedinject.Assisted; + +public class InvokeFutureAndBlock implements Function { + + public static interface Factory { + /** + * @param receiver + * object whose interface matched {@code declaring} except all invokeds return {@link ListenableFuture} + * @return blocking invocation handler + */ + InvokeFutureAndBlock create(Object async); + } + + @Resource + private Logger logger = Logger.NULL; + + private final Cache, Invokable> sync2AsyncInvokables; + private final Map timeouts; + private final Object receiver; + + @Inject + @VisibleForTesting + InvokeFutureAndBlock(Cache, Invokable> sync2AsyncInvokables, + @Named("TIMEOUTS") Map timeouts, @Assisted Object receiver) { + this.receiver = receiver; + this.sync2AsyncInvokables = sync2AsyncInvokables; + this.timeouts = timeouts; + } + + @Override + public Result apply(Invocation invocation) { + @SuppressWarnings("unchecked") + Invokable> asyncMethod = Invokable.class.cast(sync2AsyncInvokables + .getIfPresent(invocation.getInvokable())); + try { + ListenableFuture future = asyncMethod.invoke(receiver, invocation.getArgs().toArray()); + Optional timeoutNanos = timeoutInNanos(invocation.getInvokable(), timeouts); + return block(future, timeoutNanos); + } catch (InvocationTargetException e) { + return Result.fail(e); + } catch (IllegalAccessException e) { + return Result.fail(e); + } + + } + + private Result block(ListenableFuture future, Optional timeoutNanos) { + try { + if (timeoutNanos.isPresent()) { + logger.debug(">> blocking on %s for %s", future, timeoutNanos); + return Result.success(future.get(timeoutNanos.get(), TimeUnit.NANOSECONDS)); + } else { + logger.debug(">> blocking on %s", future); + return Result.success(future.get()); + } + } catch (ExecutionException e) { + return Result.fail(e.getCause()); + } catch (InterruptedException e) { + return Result.fail(e); // TODO: should we kill the future? + } catch (TimeoutException e) { + return Result.fail(e); + } + } + + // override timeout by values configured in properties(in ms) + private Optional timeoutInNanos(Invokable invoked, Map timeouts) { + String className = invoked.getEnclosingType().getRawType().getSimpleName(); + Optional timeoutMillis = fromNullable(timeouts.get(className + "." + invoked.getName())).or( + fromNullable(timeouts.get(className))).or(fromNullable(timeouts.get("default"))); + if (timeoutMillis.isPresent()) + return Optional.of(TimeUnit.MILLISECONDS.toNanos(timeoutMillis.get())); + return Optional.absent(); + } +} \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/rest/internal/InvokeListenableFutureViaHttp.java b/core/src/main/java/org/jclouds/rest/internal/InvokeListenableFutureViaHttp.java new file mode 100644 index 0000000000..b73f4cd5a7 --- /dev/null +++ b/core/src/main/java/org/jclouds/rest/internal/InvokeListenableFutureViaHttp.java @@ -0,0 +1,146 @@ +/** + * 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.rest.internal; + +import static com.google.common.base.Objects.equal; +import static com.google.common.util.concurrent.Futures.transform; +import static com.google.common.util.concurrent.Futures.withFallback; +import static org.jclouds.concurrent.Futures.makeListenable; + +import java.util.concurrent.ExecutorService; + +import javax.annotation.Resource; +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + +import org.jclouds.Constants; +import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions; +import org.jclouds.http.HttpCommand; +import org.jclouds.http.HttpCommandExecutorService; +import org.jclouds.http.HttpResponse; +import org.jclouds.logging.Logger; +import org.jclouds.reflect.Invocation; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.InvocationContext; +import org.jclouds.rest.annotations.Fallback; + +import com.google.common.base.Function; +import com.google.common.base.Objects; +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.CacheLoader; +import com.google.common.cache.LoadingCache; +import com.google.common.util.concurrent.FutureFallback; +import com.google.common.util.concurrent.ListenableFuture; +import com.google.inject.Injector; +import com.google.inject.assistedinject.Assisted; + +@Singleton +public class InvokeListenableFutureViaHttp implements Function> { + + public final static class Caller extends InvokeListenableFutureViaHttp { + + public static interface Factory { + Caller caller(Invocation caller); + } + + @Inject + private Caller(Injector injector, RestAnnotationProcessor annotationProcessor, HttpCommandExecutorService http, + Function> transformerForRequest, + @Named(Constants.PROPERTY_USER_THREADS) ExecutorService userThreads, @Assisted Invocation caller) { + super(injector, annotationProcessor.caller(caller), http, transformerForRequest, userThreads); + } + } + + @Resource + private Logger logger = Logger.NULL; + + private final Injector injector; + private final RestAnnotationProcessor annotationProcessor; + private final HttpCommandExecutorService http; + private final Function> transformerForRequest; + private final ExecutorService userThreads; + + @Inject + private InvokeListenableFutureViaHttp(Injector injector, RestAnnotationProcessor annotationProcessor, + HttpCommandExecutorService http, + Function> transformerForRequest, + @Named(Constants.PROPERTY_USER_THREADS) ExecutorService userThreads) { + this.injector = injector; + this.annotationProcessor = annotationProcessor; + this.http = http; + this.userThreads = userThreads; + this.transformerForRequest = transformerForRequest; + } + + private final LoadingCache, FutureFallback> fallbacks = CacheBuilder.newBuilder().build( + new CacheLoader, FutureFallback>() { + + @Override + public FutureFallback load(Invokable key) throws Exception { + Fallback annotation = key.getAnnotation(Fallback.class); + if (annotation != null) { + return injector.getInstance(annotation.value()); + } + return injector.getInstance(MapHttp4xxCodesToExceptions.class); + } + + }); + + @Override + public ListenableFuture apply(Invocation invocation) { + String name = invocation.getInvokable().toString(); + logger.trace(">> converting %s", name); + GeneratedHttpRequest request = annotationProcessor.apply(invocation); + logger.trace("<< converted %s to %s", name, request.getRequestLine()); + + Function transformer = transformerForRequest.apply(request); + logger.trace("<< response from %s is parsed by %s", name, transformer.getClass().getSimpleName()); + + logger.debug(">> invoking %s", name); + ListenableFuture result = transform(makeListenable(http.submit(new HttpCommand(request)), userThreads), transformer); + + FutureFallback fallback = fallbacks.getUnchecked(invocation.getInvokable()); + if (fallback instanceof InvocationContext) { + InvocationContext.class.cast(fallback).setContext(request); + } + logger.trace("<< exceptions from %s are parsed by %s", name, fallback.getClass().getSimpleName()); + return withFallback(result, fallback); + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + InvokeListenableFutureViaHttp that = InvokeListenableFutureViaHttp.class.cast(o); + return equal(this.annotationProcessor, that.annotationProcessor); + } + + @Override + public int hashCode() { + return Objects.hashCode(annotationProcessor); + } + + @Override + public String toString() { + return Objects.toStringHelper("").omitNullValues().add("annotationParser", annotationProcessor).toString(); + } +} \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/rest/internal/InvokeSyncApi.java b/core/src/main/java/org/jclouds/rest/internal/InvokeSyncApi.java new file mode 100644 index 0000000000..aed156243f --- /dev/null +++ b/core/src/main/java/org/jclouds/rest/internal/InvokeSyncApi.java @@ -0,0 +1,123 @@ +/** + * 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.rest.internal; + +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; + +import java.lang.reflect.InvocationTargetException; +import java.util.Map; + +import javax.annotation.Resource; +import javax.inject.Inject; + +import org.jclouds.logging.Logger; +import org.jclouds.reflect.FunctionalReflection; +import org.jclouds.reflect.Invocation; +import org.jclouds.reflect.Invocation.Result; +import org.jclouds.reflect.InvocationSuccess; +import org.jclouds.reflect.Invokable; + +import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Function; +import com.google.common.base.Optional; +import com.google.common.cache.Cache; +import com.google.common.util.concurrent.ListenableFuture; +import com.google.inject.Injector; +import com.google.inject.assistedinject.Assisted; + +/** + * + * @author Adrian Cole + */ +public final class InvokeSyncApi extends BaseInvocationFunction { + + public static interface Factory { + /** + * @param receiver + * object whose interface matched {@code declaring} except all invokeds return {@link ListenableFuture} + * @return blocking invocation handler + */ + InvokeSyncApi create(Object receiver); + } + + @Resource + private Logger logger = Logger.NULL; + + private final InvokeSyncApi.Factory factory; + private final InvokeAsyncApi.Delegate.Factory asyncFactory; + private final Map, Class> sync2Async; + private final Cache, Invokable> sync2AsyncInvokables; + private final InvokeFutureAndBlock.Factory blocker; + private final Object receiver; + + @Inject + @VisibleForTesting + InvokeSyncApi(Injector injector, Function> optionalConverter, + InvokeSyncApi.Factory factory, InvokeAsyncApi.Delegate.Factory asyncFactory, + Map, Class> sync2Async, Cache, Invokable> sync2AsyncInvokables, + InvokeFutureAndBlock.Factory blocker, @Assisted Object receiver) { + super(injector, optionalConverter); + this.factory = factory; + this.asyncFactory = asyncFactory; + this.sync2Async = sync2Async; + this.sync2AsyncInvokables = sync2AsyncInvokables; + this.blocker = blocker; + this.receiver = receiver; + } + + @SuppressWarnings("unchecked") + @Override + protected Result invoke(Invocation in) { + @SuppressWarnings("rawtypes") + Invokable async = checkNotNull(sync2AsyncInvokables.getIfPresent(in.getInvokable()), "invokable %s not in %s", + in.getInvokable(), sync2AsyncInvokables); + if (async.getReturnType().getRawType().isAssignableFrom(ListenableFuture.class)) { + return blocker.create(receiver).apply(in); + } + try { // try any method + return Result.success(async.invoke(receiver, in.getArgs().toArray())); + } catch (InvocationTargetException e) { + return Result.fail(e); + } catch (IllegalAccessException e) { + return Result.fail(e); + } + } + + @Override + protected Function forwardInvocations(Invocation invocation, Class returnType) { + // get the return type of the asynchronous class associated with this client + // ex. FloatingIPClient is associated with FloatingIPAsyncClient + Class asyncClass = sync2Async.get(returnType); + checkState(asyncClass != null, "please configure corresponding async class for %s in your RestClientModule", + returnType); + // pass any parameters necessary to get a relevant instance of that async class + // ex. getClientForRegion("north") might return an instance whose endpoint is + // different that "south" + Object asyncProxy = FunctionalReflection.newProxy(asyncClass, asyncFactory.caller(invocation)); + checkState(asyncProxy != null, "configuration error, sync client for " + invocation + " not found"); + return factory.create(asyncProxy); + } + + @Override + public String toString() { + return String.format("syncProxy(%s)", receiver); + } + +} diff --git a/core/src/main/java/org/jclouds/rest/internal/RestAnnotationProcessor.java b/core/src/main/java/org/jclouds/rest/internal/RestAnnotationProcessor.java index b786bd9d31..1847420d3b 100644 --- a/core/src/main/java/org/jclouds/rest/internal/RestAnnotationProcessor.java +++ b/core/src/main/java/org/jclouds/rest/internal/RestAnnotationProcessor.java @@ -78,6 +78,8 @@ import org.jclouds.io.payloads.Part.PartOptions; import org.jclouds.javax.annotation.Nullable; import org.jclouds.logging.Logger; import org.jclouds.reflect.Invocation; +import org.jclouds.reflect.Invokable; +import org.jclouds.reflect.Parameter; import org.jclouds.rest.Binder; import org.jclouds.rest.InputParamValidator; import org.jclouds.rest.annotations.ApiVersion; @@ -119,13 +121,10 @@ import com.google.common.collect.LinkedListMultimap; import com.google.common.collect.Maps; import com.google.common.collect.Multimap; import com.google.common.primitives.Chars; -import com.google.common.reflect.Invokable; -import com.google.common.reflect.Parameter; import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.TypeLiteral; -import com.google.inject.assistedinject.Assisted; /** * Creates http invocation.getInvoked()s based on annotations on a class or interface. @@ -134,44 +133,6 @@ import com.google.inject.assistedinject.Assisted; */ public class RestAnnotationProcessor implements Function { - public static final class Caller extends RestAnnotationProcessor { - - public static interface Factory { - Caller caller(Invocation caller); - } - - private final Invocation caller; - - @Inject - private Caller(Injector injector, @ApiVersion String apiVersion, @BuildVersion String buildVersion, - HttpUtils utils, ContentMetadataCodec contentMetadataCodec, InputParamValidator inputParamValidator, - @Assisted Invocation caller) { - super(injector, apiVersion, buildVersion, utils, contentMetadataCodec, inputParamValidator); - this.caller = caller; - } - - @Override - protected GeneratedHttpRequest.Builder requestBuilder() { - return super.requestBuilder().caller(caller); - } - - @Override - protected Optional findEndpoint(Invocation invocation) { - Optional endpoint = getEndpointFor(caller); - if (endpoint.isPresent()) - logger.trace("using endpoint %s from caller %s for %s", endpoint, caller, invocation); - else - endpoint = super.findEndpoint(invocation); - return endpoint; - } - - @Override - protected Multimap addPathAndGetTokens(Invocation invocation, UriBuilder uriBuilder) { - return ImmutableMultimap. builder().putAll(super.addPathAndGetTokens(caller, uriBuilder)) - .putAll(super.addPathAndGetTokens(invocation, uriBuilder)).build(); - } - } - @Resource protected Logger logger = Logger.NULL; @@ -208,6 +169,13 @@ public class RestAnnotationProcessor implements Function invokable, List args) { return apply(Invocation.create(invokable, args)); } + + private Invocation caller; + + RestAnnotationProcessor caller(Invocation caller) { + this.caller = caller; + return this; + } @Override public GeneratedHttpRequest apply(Invocation invocation) { @@ -220,14 +188,20 @@ public class RestAnnotationProcessor implements Function formParams = addFormParams(tokenValues, invocation); @@ -353,9 +329,9 @@ public class RestAnnotationProcessor implements Function addPathAndGetTokens(Invocation invocation, UriBuilder uriBuilder) { - if (invocation.getInterfaceType().isAnnotationPresent(Path.class)) - uriBuilder.appendPath(invocation.getInterfaceType().getAnnotation(Path.class).value()); + private Multimap addPathAndGetTokens(Invocation invocation, UriBuilder uriBuilder) { + if (invocation.getInvokable().getEnclosingType().getRawType().isAnnotationPresent(Path.class)) + uriBuilder.appendPath(invocation.getInvokable().getEnclosingType().getRawType().getAnnotation(Path.class) + .value()); if (invocation.getInvokable().isAnnotationPresent(Path.class)) uriBuilder.appendPath(invocation.getInvokable().getAnnotation(Path.class).value()); return getPathParamKeyValues(invocation); @@ -397,8 +374,8 @@ public class RestAnnotationProcessor implements Function addFormParams(Multimap tokenValues, Invocation invocation) { Multimap formMap = LinkedListMultimap.create(); - if (invocation.getInterfaceType().isAnnotationPresent(FormParams.class)) { - FormParams form = invocation.getInterfaceType().getAnnotation(FormParams.class); + if (invocation.getInvokable().getEnclosingType().getRawType().isAnnotationPresent(FormParams.class)) { + FormParams form = invocation.getInvokable().getEnclosingType().getRawType().getAnnotation(FormParams.class); addForm(formMap, form, tokenValues); } @@ -415,8 +392,8 @@ public class RestAnnotationProcessor implements Function addQueryParams(Multimap tokenValues, Invocation invocation) { Multimap queryMap = LinkedListMultimap.create(); - if (invocation.getInterfaceType().isAnnotationPresent(QueryParams.class)) { - QueryParams query = invocation.getInterfaceType().getAnnotation(QueryParams.class); + if (invocation.getInvokable().getEnclosingType().getRawType().isAnnotationPresent(QueryParams.class)) { + QueryParams query = invocation.getInvokable().getEnclosingType().getRawType().getAnnotation(QueryParams.class); addQuery(queryMap, query, tokenValues); } @@ -466,12 +443,13 @@ public class RestAnnotationProcessor implements Function getFiltersIfAnnotated(Invocation invocation) { List filters = newArrayList(); - if (invocation.getInterfaceType().isAnnotationPresent(RequestFilters.class)) { - for (Class clazz : invocation.getInterfaceType() + if (invocation.getInvokable().getEnclosingType().getRawType().isAnnotationPresent(RequestFilters.class)) { + for (Class clazz : invocation.getInvokable().getEnclosingType().getRawType() .getAnnotation(RequestFilters.class).value()) { HttpRequestFilter instance = injector.getInstance(clazz); filters.add(instance); - logger.trace("adding filter %s from annotation on %s", instance, invocation.getInterfaceType().getName()); + logger.trace("adding filter %s from annotation on %s", instance, invocation.getInvokable() + .getEnclosingType().getRawType().getName()); } } if (invocation.getInvokable().isAnnotationPresent(RequestFilters.class)) { @@ -526,8 +504,8 @@ public class RestAnnotationProcessor implements Function= position + 1 && arg != null) { Class parameterType = entry.getType().getRawType(); Class argType = arg.getClass(); - if (!argType.isArray() && parameterType.isArray()) { // TODO && varinvocation.getArgs() guava issue 1244 + if (!argType.isArray() && parameterType.isArray() && invocation.getInvokable().isVarArgs()) { int arrayLength = args.size() - invocation.getInvokable().getParameters().size() + 1; if (arrayLength == 0) break OUTER; arg = (Object[]) Array.newInstance(arg.getClass(), arrayLength); System.arraycopy(args.toArray(), position, arg, 0, arrayLength); shouldBreak = true; - } else if (argType.isArray() && parameterType.isArray()) { // TODO && varinvocation.getArgs() guava issue - // 1244 + } else if (argType.isArray() && parameterType.isArray() && invocation.getInvokable().isVarArgs()) { } else { if (arg.getClass().isArray()) { Object[] payloadArray = (Object[]) arg; @@ -631,8 +608,9 @@ public class RestAnnotationProcessor implements Function type = param.getType().getRawType(); if (HttpRequestOptions.class.isAssignableFrom(type) || HttpRequestOptions[].class.isAssignableFrom(type)) - toReturn.add(param.hashCode()); // TODO position guava issue 1243 + toReturn.add(param.getPosition()); } return toReturn.build(); } @@ -685,7 +663,7 @@ public class RestAnnotationProcessor implements Function getAcceptHeaders(Invocation invocation) { Optional accept = Optional.fromNullable(invocation.getInvokable().getAnnotation(Consumes.class)).or( - Optional.fromNullable(invocation.getInterfaceType().getAnnotation(Consumes.class))); + Optional.fromNullable(invocation.getInvokable().getEnclosingType().getRawType() + .getAnnotation(Consumes.class))); return (accept.isPresent()) ? ImmutableSet.copyOf(accept.get().value()) : ImmutableSet. of(); } private static void addProducesIfPresentOnTypeOrMethod(Multimap headers, Invocation invocation) { - if (invocation.getInterfaceType().isAnnotationPresent(Produces.class)) { - Produces header = invocation.getInterfaceType().getAnnotation(Produces.class); + if (invocation.getInvokable().getEnclosingType().getRawType().isAnnotationPresent(Produces.class)) { + Produces header = invocation.getInvokable().getEnclosingType().getRawType().getAnnotation(Produces.class); headers.replaceValues(CONTENT_TYPE, asList(header.value())); } if (invocation.getInvokable().isAnnotationPresent(Produces.class)) { @@ -720,8 +699,8 @@ public class RestAnnotationProcessor implements Function headers, Invocation invocation, Multimap tokenValues) { - if (invocation.getInterfaceType().isAnnotationPresent(Headers.class)) { - Headers header = invocation.getInterfaceType().getAnnotation(Headers.class); + if (invocation.getInvokable().getEnclosingType().getRawType().isAnnotationPresent(Headers.class)) { + Headers header = invocation.getInvokable().getEnclosingType().getRawType().getAnnotation(Headers.class); addHeader(headers, header, tokenValues); } if (invocation.getInvokable().isAnnotationPresent(Headers.class)) { @@ -747,7 +726,7 @@ public class RestAnnotationProcessor implements Function paramValue = getParamValue(invocation, param.getAnnotation(ParamParser.class), param.hashCode(), - paramKey); // TODO position guava issue 1243 + Optional paramValue = getParamValue(invocation, param.getAnnotation(ParamParser.class), + param.getPosition(), paramKey); if (paramValue.isPresent()) pathParamValues.put(paramKey, paramValue.get().toString()); } @@ -780,8 +759,8 @@ public class RestAnnotationProcessor implements Function paramValue = getParamValue(invocation, param.getAnnotation(ParamParser.class), param.hashCode(), - paramKey); // TODO position guava issue 1243 + Optional paramValue = getParamValue(invocation, param.getAnnotation(ParamParser.class), + param.getPosition(), paramKey); if (paramValue.isPresent()) formParamValues.put(paramKey, paramValue.get().toString()); } @@ -803,8 +782,8 @@ public class RestAnnotationProcessor implements Function paramValue = getParamValue(invocation, param.getAnnotation(ParamParser.class), param.hashCode(), - paramKey); // TODO position guava issue 1243 + Optional paramValue = getParamValue(invocation, param.getAnnotation(ParamParser.class), + param.getPosition(), paramKey); if (paramValue.isPresent()) if (paramValue.get() instanceof Iterable) { @SuppressWarnings("unchecked") @@ -822,8 +801,8 @@ public class RestAnnotationProcessor implements Function paramValue = getParamValue(invocation, param.getAnnotation(ParamParser.class), param.hashCode(), - paramKey); // TODO position guava issue 1243 + Optional paramValue = getParamValue(invocation, param.getAnnotation(ParamParser.class), + param.getPosition(), paramKey); if (paramValue.isPresent()) payloadParamValues.put(paramKey, paramValue.get()); } diff --git a/core/src/main/java/org/jclouds/rest/internal/TransformerForRequest.java b/core/src/main/java/org/jclouds/rest/internal/TransformerForRequest.java new file mode 100644 index 0000000000..acf3bbfdb2 --- /dev/null +++ b/core/src/main/java/org/jclouds/rest/internal/TransformerForRequest.java @@ -0,0 +1,229 @@ +/** + * 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.rest.internal; + +import static com.google.common.base.Functions.compose; +import static com.google.inject.util.Types.newParameterizedType; +import static javax.ws.rs.core.MediaType.APPLICATION_JSON; +import static javax.ws.rs.core.MediaType.APPLICATION_XML; + +import java.io.InputStream; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.lang.reflect.WildcardType; +import java.net.URI; +import java.util.Set; + +import javax.inject.Inject; +import javax.lang.model.type.NullType; + +import org.jclouds.functions.IdentityFunction; +import org.jclouds.functions.OnlyElementOrNull; +import org.jclouds.http.HttpResponse; +import org.jclouds.http.functions.ParseFirstJsonValueNamed; +import org.jclouds.http.functions.ParseJson; +import org.jclouds.http.functions.ParseSax; +import org.jclouds.http.functions.ParseSax.Factory; +import org.jclouds.http.functions.ParseSax.HandlerWithResult; +import org.jclouds.http.functions.ParseURIFromListOrLocationHeaderIf20x; +import org.jclouds.http.functions.ParseXMLWithJAXB; +import org.jclouds.http.functions.ReleasePayloadAndReturn; +import org.jclouds.http.functions.ReturnInputStream; +import org.jclouds.http.functions.ReturnStringIf2xx; +import org.jclouds.http.functions.ReturnTrueIf2xx; +import org.jclouds.http.functions.UnwrapOnlyJsonValue; +import org.jclouds.json.internal.GsonWrapper; +import org.jclouds.reflect.Invocation; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.InvocationContext; +import org.jclouds.rest.annotations.JAXBResponseParser; +import org.jclouds.rest.annotations.OnlyElement; +import org.jclouds.rest.annotations.ResponseParser; +import org.jclouds.rest.annotations.SelectJson; +import org.jclouds.rest.annotations.Transform; +import org.jclouds.rest.annotations.Unwrap; +import org.jclouds.rest.annotations.XMLResponseParser; + +import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Function; +import com.google.common.base.Optional; +import com.google.common.reflect.TypeToken; +import com.google.common.util.concurrent.ListenableFuture; +import com.google.inject.Injector; +import com.google.inject.Key; +import com.google.inject.TypeLiteral; + +public class TransformerForRequest implements Function> { + private final ParseSax.Factory parserFactory; + private final Injector injector; + + @Inject + TransformerForRequest(Injector injector, Factory parserFactory) { + this.injector = injector; + this.parserFactory = parserFactory; + } + + @Override + public Function apply(GeneratedHttpRequest request) { + return createResponseParser(parserFactory, injector, request); + } + + private static final TypeToken> futureBooleanLiteral = new TypeToken>() { + private static final long serialVersionUID = 1L; + }; + private static final TypeToken> futureStringLiteral = new TypeToken>() { + private static final long serialVersionUID = 1L; + }; + private static final TypeToken> futureVoidLiteral = new TypeToken>() { + private static final long serialVersionUID = 1L; + }; + private static final TypeToken> futureURILiteral = new TypeToken>() { + private static final long serialVersionUID = 1L; + }; + private static final TypeToken> futureInputStreamLiteral = new TypeToken>() { + private static final long serialVersionUID = 1L; + }; + private static final TypeToken> futureHttpResponseLiteral = new TypeToken>() { + private static final long serialVersionUID = 1L; + }; + + @SuppressWarnings("unchecked") + @VisibleForTesting + protected static Key> getParserOrThrowException(Invocation invocation) { + Invokable invoked = invocation.getInvokable(); + ResponseParser annotation = invoked.getAnnotation(ResponseParser.class); + if (annotation == null) { + if (invoked.getReturnType().equals(void.class) || invoked.getReturnType().equals(futureVoidLiteral)) { + return Key.get(ReleasePayloadAndReturn.class); + } else if (invoked.getReturnType().equals(boolean.class) || invoked.getReturnType().equals(Boolean.class) + || invoked.getReturnType().equals(futureBooleanLiteral)) { + return Key.get(ReturnTrueIf2xx.class); + } else if (invoked.getReturnType().equals(InputStream.class) + || invoked.getReturnType().equals(futureInputStreamLiteral)) { + return Key.get(ReturnInputStream.class); + } else if (invoked.getReturnType().equals(HttpResponse.class) + || invoked.getReturnType().equals(futureHttpResponseLiteral)) { + return Key.get(Class.class.cast(IdentityFunction.class)); + } else if (RestAnnotationProcessor.getAcceptHeaders(invocation).contains(APPLICATION_JSON)) { + return getJsonParserKeyForMethod(invoked); + } else if (RestAnnotationProcessor.getAcceptHeaders(invocation).contains(APPLICATION_XML) + || invoked.isAnnotationPresent(JAXBResponseParser.class)) { + return getJAXBParserKeyForMethod(invoked); + } else if (invoked.getReturnType().equals(String.class) || invoked.getReturnType().equals(futureStringLiteral)) { + return Key.get(ReturnStringIf2xx.class); + } else if (invoked.getReturnType().equals(URI.class) || invoked.getReturnType().equals(futureURILiteral)) { + return Key.get(ParseURIFromListOrLocationHeaderIf20x.class); + } else { + throw new IllegalStateException("You must specify a ResponseParser annotation on: " + invoked.toString()); + } + } + return Key.get(annotation.value()); + } + + @SuppressWarnings("unchecked") + private static Key> getJAXBParserKeyForMethod(Invokable invoked) { + Optional configuredReturnVal = Optional.absent(); + if (invoked.isAnnotationPresent(JAXBResponseParser.class)) { + Type configuredClass = invoked.getAnnotation(JAXBResponseParser.class).value(); + configuredReturnVal = configuredClass.equals(NullType.class) ? Optional. absent() : Optional + . of(configuredClass); + } + Type returnVal = configuredReturnVal.or(getReturnTypeFor(invoked.getReturnType())); + Type parserType = newParameterizedType(ParseXMLWithJAXB.class, returnVal); + return (Key>) Key.get(parserType); + } + + @SuppressWarnings({ "unchecked" }) + private static Key> getJsonParserKeyForMethod(Invokable invoked) { + ParameterizedType parserType; + if (invoked.isAnnotationPresent(Unwrap.class)) { + parserType = newParameterizedType(UnwrapOnlyJsonValue.class, getReturnTypeFor(invoked.getReturnType())); + } else { + parserType = newParameterizedType(ParseJson.class, getReturnTypeFor(invoked.getReturnType())); + } + return (Key>) Key.get(parserType); + } + + static Type getReturnTypeFor(TypeToken typeToken) { + Type returnVal = typeToken.getType(); + if (typeToken.getRawType().getTypeParameters().length == 0) { + returnVal = typeToken.getRawType(); + } else if (typeToken.getRawType().equals(ListenableFuture.class)) { + ParameterizedType futureType = (ParameterizedType) typeToken.getType(); + returnVal = futureType.getActualTypeArguments()[0]; + if (returnVal instanceof WildcardType) + returnVal = WildcardType.class.cast(returnVal).getUpperBounds()[0]; + } + return returnVal; + } + + // TODO: refactor this out of here + @VisibleForTesting + @SuppressWarnings({ "rawtypes", "unchecked" }) + public static Function getTransformerForMethod(Invocation invocation, Injector injector) { + Invokable invoked = invocation.getInvokable(); + Function transformer; + if (invoked.isAnnotationPresent(SelectJson.class)) { + Type returnVal = getReturnTypeFor(invoked.getReturnType()); + if (invoked.isAnnotationPresent(OnlyElement.class)) + returnVal = newParameterizedType(Set.class, returnVal); + transformer = new ParseFirstJsonValueNamed(injector.getInstance(GsonWrapper.class), + TypeLiteral.get(returnVal), invoked.getAnnotation(SelectJson.class).value()); + if (invoked.isAnnotationPresent(OnlyElement.class)) + transformer = compose(new OnlyElementOrNull(), transformer); + } else { + transformer = injector.getInstance(getParserOrThrowException(invocation)); + } + return transformer; + } + + @SuppressWarnings("unchecked") + @Deprecated + public static Function createResponseParser(ParseSax.Factory parserFactory, Injector injector, + GeneratedHttpRequest request) { + Function transformer; + Class> handler = TransformerForRequest.getSaxResponseParserClassOrNull(request + .getInvocation().getInvokable()); + if (handler != null) { + transformer = parserFactory.create(injector.getInstance(handler)); + } else { + transformer = getTransformerForMethod(request.getInvocation(), injector); + } + if (transformer instanceof InvocationContext) { + ((InvocationContext) transformer).setContext(request); + } + if (request.getInvocation().getInvokable().isAnnotationPresent(Transform.class)) { + Function wrappingTransformer = injector.getInstance(request.getInvocation().getInvokable() + .getAnnotation(Transform.class).value()); + if (wrappingTransformer instanceof InvocationContext) { + ((InvocationContext) wrappingTransformer).setContext(request); + } + transformer = compose(Function.class.cast(wrappingTransformer), transformer); + } + return transformer; + } + + static Class> getSaxResponseParserClassOrNull(Invokable invoked) { + XMLResponseParser annotation = invoked.getAnnotation(XMLResponseParser.class); + if (annotation != null) { + return annotation.value(); + } + return null; + } +} \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/util/Optionals2.java b/core/src/main/java/org/jclouds/util/Optionals2.java index c572194f37..ee3f0b9cf7 100644 --- a/core/src/main/java/org/jclouds/util/Optionals2.java +++ b/core/src/main/java/org/jclouds/util/Optionals2.java @@ -23,7 +23,7 @@ import java.lang.reflect.Type; import java.lang.reflect.WildcardType; import com.google.common.base.Optional; -import com.google.common.reflect.Invokable; +import org.jclouds.reflect.Invokable; import com.google.common.reflect.TypeToken; /** diff --git a/core/src/test/java/org/jclouds/concurrent/internal/SyncProxyTest.java b/core/src/test/java/org/jclouds/concurrent/internal/SyncProxyTest.java index 4cccc58f06..0b5d6fea87 100644 --- a/core/src/test/java/org/jclouds/concurrent/internal/SyncProxyTest.java +++ b/core/src/test/java/org/jclouds/concurrent/internal/SyncProxyTest.java @@ -28,16 +28,9 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import org.jclouds.internal.ForwardInvocationToInterface; -import org.jclouds.reflect.FunctionalReflection; -import org.jclouds.rest.functions.AlwaysPresentImplicitOptionalConverter; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import com.google.common.base.Functions; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; import com.google.common.collect.ImmutableMap; import com.google.common.util.concurrent.ListenableFuture; @@ -46,7 +39,7 @@ import com.google.common.util.concurrent.ListenableFuture; * * @author Adrian Cole */ -@Test(groups = "unit", singleThreaded = true) +@Test(groups = "unit", enabled = false, singleThreaded = true) public class SyncProxyTest { static ListenableFuture future; @@ -100,10 +93,15 @@ public class SyncProxyTest { } private Sync syncProxyForTimeouts(ImmutableMap timeouts) throws NoSuchMethodException { - LoadingCache cache = CacheBuilder.newBuilder().build( - CacheLoader.from(Functions. constant(null))); - return FunctionalReflection.newProxy(Sync.class, new SyncProxy(new AlwaysPresentImplicitOptionalConverter(), - cache, ImmutableMap., Class> of(Sync.class, Async.class), timeouts, Sync.class, new Async())); +// LoadingCache cache = CacheBuilder.newBuilder().build( +// CacheLoader.from(Functions. constant(null))); +// return FunctionalReflection.newProxy(Sync.class, new SyncProxy(new AlwaysPresentImplicitOptionalConverter(), +// cache, ImmutableMap., Class> of(Sync.class, Async.class), timeouts, Sync.class, new Async())); +//// +// Function> optionalConverter, SyncProxy.Factory factory, +// AsyncRestClientProxy.Caller.Factory asyncFactory, Map, Class> sync2Async, +// @Named("TIMEOUTS") Map timeouts, @Assisted Class declaring, @Assisted Object async + return null; } } diff --git a/core/src/test/java/org/jclouds/http/functions/BaseHandlerTest.java b/core/src/test/java/org/jclouds/http/functions/BaseHandlerTest.java index 612e68b4f5..c8fc129860 100644 --- a/core/src/test/java/org/jclouds/http/functions/BaseHandlerTest.java +++ b/core/src/test/java/org/jclouds/http/functions/BaseHandlerTest.java @@ -29,7 +29,7 @@ import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeTest; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; +import org.jclouds.reflect.Invokable; import com.google.inject.Guice; import com.google.inject.Injector; diff --git a/core/src/test/java/org/jclouds/http/handlers/BackoffLimitedRetryHandlerTest.java b/core/src/test/java/org/jclouds/http/handlers/BackoffLimitedRetryHandlerTest.java index e7cd0b4d59..a3c5fca4bb 100644 --- a/core/src/test/java/org/jclouds/http/handlers/BackoffLimitedRetryHandlerTest.java +++ b/core/src/test/java/org/jclouds/http/handlers/BackoffLimitedRetryHandlerTest.java @@ -50,7 +50,7 @@ import org.testng.annotations.Test; import com.google.common.base.Supplier; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; +import org.jclouds.reflect.Invokable; @Test(groups = "unit", testName = "BackoffLimitedRetryHandlerTest") public class BackoffLimitedRetryHandlerTest { diff --git a/core/src/test/java/org/jclouds/http/internal/TrackingJavaUrlHttpCommandExecutorService.java b/core/src/test/java/org/jclouds/http/internal/TrackingJavaUrlHttpCommandExecutorService.java index fd5d869a09..441213c1b5 100644 --- a/core/src/test/java/org/jclouds/http/internal/TrackingJavaUrlHttpCommandExecutorService.java +++ b/core/src/test/java/org/jclouds/http/internal/TrackingJavaUrlHttpCommandExecutorService.java @@ -41,7 +41,7 @@ import org.jclouds.rest.internal.GeneratedHttpRequest; import com.google.common.base.Supplier; import com.google.common.collect.Iterables; -import com.google.common.reflect.Invokable; +import org.jclouds.reflect.Invokable; import com.google.inject.AbstractModule; import com.google.inject.Module; import com.google.inject.TypeLiteral; diff --git a/core/src/test/java/org/jclouds/json/BaseParserTest.java b/core/src/test/java/org/jclouds/json/BaseParserTest.java index e6552a397f..a9118433e4 100644 --- a/core/src/test/java/org/jclouds/json/BaseParserTest.java +++ b/core/src/test/java/org/jclouds/json/BaseParserTest.java @@ -32,13 +32,13 @@ import org.jclouds.io.Payload; import org.jclouds.io.Payloads; import org.jclouds.json.config.GsonModule; import org.jclouds.reflect.Invocation; -import org.jclouds.rest.internal.AsyncRestClientProxy; +import org.jclouds.rest.internal.TransformerForRequest; import org.testng.annotations.Test; import com.google.common.base.Function; import com.google.common.base.Throwables; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; +import org.jclouds.reflect.Invokable; import com.google.inject.Guice; import com.google.inject.Injector; @@ -58,7 +58,7 @@ public abstract class BaseParserTest { @SuppressWarnings("unchecked") protected Function parser(Injector i) { try { - return (Function) AsyncRestClientProxy.getTransformerForMethod( + return (Function) TransformerForRequest.getTransformerForMethod( Invocation.create(Invokable.from(getClass().getMethod("expected")), ImmutableList.of()), i); } catch (Exception e) { throw Throwables.propagate(e); diff --git a/core/src/test/java/org/jclouds/reflect/FunctionalReflectionTest.java b/core/src/test/java/org/jclouds/reflect/FunctionalReflectionTest.java index cf0ef71398..98f06c9c10 100644 --- a/core/src/test/java/org/jclouds/reflect/FunctionalReflectionTest.java +++ b/core/src/test/java/org/jclouds/reflect/FunctionalReflectionTest.java @@ -48,11 +48,11 @@ public class FunctionalReflectionTest { * access to the actual proxied interface */ @SuppressWarnings("unchecked") - public void testCanAccessInterfaceTypeInsideFunction() { + public void testCanAccessContravariantTypeInsideFunction() { final Function test = new Function() { public Result apply(Invocation e) { assertEquals(e.getInvokable().getDeclaringClass(), Set.class); - assertEquals(e.getInterfaceType(), SortedSet.class); + assertEquals(e.getInvokable().getEnclosingType().getRawType(), SortedSet.class); return Result.success(true); } }; diff --git a/core/src/test/java/org/jclouds/reflect/InvokableTest.java b/core/src/test/java/org/jclouds/reflect/InvokableTest.java new file mode 100644 index 0000000000..d52c454c1e --- /dev/null +++ b/core/src/test/java/org/jclouds/reflect/InvokableTest.java @@ -0,0 +1,345 @@ +/** + * 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.reflect; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertTrue; +import static org.testng.Assert.fail; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.lang.reflect.TypeVariable; +import java.util.Collections; + +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Iterables; +import com.google.common.reflect.TypeToken; + +/** + * ported from {@link com.google.common.reflect.InvokableTest} + * + */ +@Test +@SuppressWarnings("serial") +public class InvokableTest { + + public void testConstructor_returnType() throws Exception { + assertEquals(Prepender.class, Prepender.constructor().getReturnType().getType()); + } + + public void testConstructor_exceptionTypes() throws Exception { + assertEquals(ImmutableList.of(TypeToken.of(NullPointerException.class)), + Prepender.constructor(String.class, int.class).getExceptionTypes()); + } + + public void testConstructor_typeParameters() throws Exception { + TypeVariable[] variables = Prepender.constructor().getTypeParameters(); + assertEquals(1, variables.length); + assertEquals("A", variables[0].getName()); + } + + public void testConstructor_parameters() throws Exception { + Invokable delegate = Prepender.constructor(String.class, int.class); + ImmutableList parameters = delegate.getParameters(); + assertEquals(2, parameters.size()); + assertEquals(String.class, parameters.get(0).getType().getType()); + assertTrue(parameters.get(0).isAnnotationPresent(NotBlank.class)); + assertEquals(int.class, parameters.get(1).getType().getType()); + assertFalse(parameters.get(1).isAnnotationPresent(NotBlank.class)); + } + + public void testConstructor_call() throws Exception { + Invokable delegate = Prepender.constructor(String.class, int.class); + Prepender prepender = delegate.invoke(null, "a", 1); + assertEquals("a", prepender.prefix); + assertEquals(1, prepender.times); + } + + public void testConstructor_returning() throws Exception { + Invokable delegate = Prepender.constructor(String.class, int.class).returning(Prepender.class); + Prepender prepender = delegate.invoke(null, "a", 1); + assertEquals("a", prepender.prefix); + assertEquals(1, prepender.times); + } + + public void testConstructor_invalidReturning() throws Exception { + Invokable delegate = Prepender.constructor(String.class, int.class); + try { + delegate.returning(SubPrepender.class); + fail(); + } catch (IllegalArgumentException expected) { + } + } + + public void testStaticMethod_returnType() throws Exception { + Invokable delegate = Prepender.method("prepend", String.class, Iterable.class); + assertEquals(new TypeToken>() { + }, delegate.getReturnType()); + } + + public void testStaticMethod_exceptionTypes() throws Exception { + Invokable delegate = Prepender.method("prepend", String.class, Iterable.class); + assertEquals(ImmutableList.of(), delegate.getExceptionTypes()); + } + + public void testStaticMethod_typeParameters() throws Exception { + Invokable delegate = Prepender.method("prepend", String.class, Iterable.class); + TypeVariable[] variables = delegate.getTypeParameters(); + assertEquals(1, variables.length); + assertEquals("T", variables[0].getName()); + } + + public void testStaticMethod_parameters() throws Exception { + Invokable delegate = Prepender.method("prepend", String.class, Iterable.class); + ImmutableList parameters = delegate.getParameters(); + assertEquals(2, parameters.size()); + assertEquals(String.class, parameters.get(0).getType().getType()); + assertTrue(parameters.get(0).isAnnotationPresent(NotBlank.class)); + assertEquals(new TypeToken>() { + }, parameters.get(1).getType()); + assertFalse(parameters.get(1).isAnnotationPresent(NotBlank.class)); + } + + public void testStaticMethod_call() throws Exception { + Invokable delegate = Prepender.method("prepend", String.class, Iterable.class); + @SuppressWarnings("unchecked") + // prepend() returns Iterable + Iterable result = (Iterable) delegate.invoke(null, "a", ImmutableList.of("b", "c")); + assertEquals(ImmutableList.of("a", "b", "c"), ImmutableList.copyOf(result)); + } + + public void testStaticMethod_returning() throws Exception { + Invokable> delegate = Prepender.method("prepend", String.class, Iterable.class).returning( + new TypeToken>() { + }); + assertEquals(new TypeToken>() { + }, delegate.getReturnType()); + Iterable result = delegate.invoke(null, "a", ImmutableList.of("b", "c")); + assertEquals(ImmutableList.of("a", "b", "c"), ImmutableList.copyOf(result)); + } + + public void testStaticMethod_returningRawType() throws Exception { + @SuppressWarnings("rawtypes") + // the purpose is to test raw type + Invokable delegate = Prepender.method("prepend", String.class, Iterable.class).returning( + Iterable.class); + assertEquals(new TypeToken>() { + }, delegate.getReturnType()); + @SuppressWarnings("unchecked") + // prepend() returns Iterable + Iterable result = delegate.invoke(null, "a", ImmutableList.of("b", "c")); + assertEquals(ImmutableList.of("a", "b", "c"), ImmutableList.copyOf(result)); + } + + public void testStaticMethod_invalidReturning() throws Exception { + Invokable delegate = Prepender.method("prepend", String.class, Iterable.class); + try { + delegate.returning(new TypeToken>() { + }); + fail(); + } catch (IllegalArgumentException expected) { + } + } + + public void testInstanceMethod_returnType() throws Exception { + Invokable delegate = Prepender.method("prepend", Iterable.class); + assertEquals(new TypeToken>() { + }, delegate.getReturnType()); + } + + public void testInstanceMethod_exceptionTypes() throws Exception { + Invokable delegate = Prepender.method("prepend", Iterable.class); + assertEquals( + ImmutableList.of(TypeToken.of(IllegalArgumentException.class), TypeToken.of(NullPointerException.class)), + delegate.getExceptionTypes()); + } + + public void testInstanceMethod_typeParameters() throws Exception { + Invokable delegate = Prepender.method("prepend", Iterable.class); + assertEquals(0, delegate.getTypeParameters().length); + } + + public void testInstanceMethod_parameters() throws Exception { + Invokable delegate = Prepender.method("prepend", Iterable.class); + ImmutableList parameters = delegate.getParameters(); + assertEquals(1, parameters.size()); + assertEquals(new TypeToken>() { + }, parameters.get(0).getType()); + assertEquals(0, parameters.get(0).getAnnotations().length); + } + + public void testInstanceMethod_call() throws Exception { + Invokable delegate = Prepender.method("prepend", Iterable.class); + @SuppressWarnings("unchecked") + // prepend() returns Iterable + Iterable result = (Iterable) delegate.invoke(new Prepender("a", 2), ImmutableList.of("b", "c")); + assertEquals(ImmutableList.of("a", "a", "b", "c"), ImmutableList.copyOf(result)); + } + + public void testInstanceMethod_returning() throws Exception { + Invokable> delegate = Prepender.method("prepend", Iterable.class).returning( + new TypeToken>() { + }); + assertEquals(new TypeToken>() { + }, delegate.getReturnType()); + Iterable result = delegate.invoke(new Prepender("a", 2), ImmutableList.of("b", "c")); + assertEquals(ImmutableList.of("a", "a", "b", "c"), ImmutableList.copyOf(result)); + } + + public void testInstanceMethod_returningRawType() throws Exception { + @SuppressWarnings("rawtypes") + // the purpose is to test raw type + Invokable delegate = Prepender.method("prepend", Iterable.class).returning(Iterable.class); + assertEquals(new TypeToken>() { + }, delegate.getReturnType()); + @SuppressWarnings("unchecked") + // prepend() returns Iterable + Iterable result = delegate.invoke(new Prepender("a", 2), ImmutableList.of("b", "c")); + assertEquals(ImmutableList.of("a", "a", "b", "c"), ImmutableList.copyOf(result)); + } + + public void testInstanceMethod_invalidReturning() throws Exception { + Invokable delegate = Prepender.method("prepend", Iterable.class); + try { + delegate.returning(new TypeToken>() { + }); + fail(); + } catch (IllegalArgumentException expected) { + } + } + + public void testPrivateInstanceMethod_isOverridable() throws Exception { + Invokable delegate = Prepender.method("privateMethod"); + assertTrue(delegate.isPrivate()); + assertFalse(delegate.isOverridable()); + } + + public void testPrivateFinalInstanceMethod_isOverridable() throws Exception { + Invokable delegate = Prepender.method("privateFinalMethod"); + assertTrue(delegate.isPrivate()); + assertTrue(delegate.isFinal()); + assertFalse(delegate.isOverridable()); + } + + public void testStaticMethod_isOverridable() throws Exception { + Invokable delegate = Prepender.method("staticMethod"); + assertTrue(delegate.isStatic()); + assertFalse(delegate.isOverridable()); + } + + public void testStaticFinalMethod_isFinal() throws Exception { + Invokable delegate = Prepender.method("staticFinalMethod"); + assertTrue(delegate.isStatic()); + assertTrue(delegate.isFinal()); + assertFalse(delegate.isOverridable()); + } + + static class Foo { + } + + public void testConstructor_isOverridablel() throws Exception { + Invokable delegate = Invokable.from(Foo.class.getDeclaredConstructor()); + assertFalse(delegate.isOverridable()); + } + + private static final class FinalClass { + @SuppressWarnings("unused") + // used by reflection + void notFinalMethod() { + } + } + + public void testNonFinalMethodInFinalClass_isOverridable() throws Exception { + Invokable delegate = Invokable.from(FinalClass.class.getDeclaredMethod("notFinalMethod")); + assertFalse(delegate.isOverridable()); + } + + @Retention(RetentionPolicy.RUNTIME) + private @interface NotBlank { + } + + /** Class for testing construcrtor, static method and instance method. */ + @SuppressWarnings("unused") + // most are called by reflection + private static class Prepender { + + private final String prefix; + private final int times; + + Prepender(@NotBlank String prefix, int times) throws NullPointerException { + this.prefix = prefix; + this.times = times; + } + + // just for testing + private Prepender() { + this(null, 0); + } + + static Iterable prepend(@NotBlank String first, Iterable tail) { + return Iterables.concat(ImmutableList.of(first), tail); + } + + Iterable prepend(Iterable tail) throws IllegalArgumentException, NullPointerException { + return Iterables.concat(Collections.nCopies(times, prefix), tail); + } + + static Invokable constructor(Class... parameterTypes) throws Exception { + Constructor constructor = Prepender.class.getDeclaredConstructor(parameterTypes); + return Invokable.from(constructor); + } + + static Invokable method(String name, Class... parameterTypes) { + try { + Method method = Prepender.class.getDeclaredMethod(name, parameterTypes); + @SuppressWarnings("unchecked") + // The method is from Prepender. + Invokable invokable = (Invokable) Invokable.from(method); + return invokable; + } catch (NoSuchMethodException e) { + throw new IllegalArgumentException(e); + } + } + + private void privateMethod() { + } + + private final void privateFinalMethod() { + } + + static void staticMethod() { + } + + static final void staticFinalMethod() { + } + } + + private static class SubPrepender extends Prepender { + @SuppressWarnings("unused") + // needed to satisfy compiler, never called + public SubPrepender() throws NullPointerException { + throw new AssertionError(); + } + } +} diff --git a/core/src/test/java/org/jclouds/rest/InputParamValidatorTest.java b/core/src/test/java/org/jclouds/rest/InputParamValidatorTest.java index bbdfc7c4f1..7506757aa6 100644 --- a/core/src/test/java/org/jclouds/rest/InputParamValidatorTest.java +++ b/core/src/test/java/org/jclouds/rest/InputParamValidatorTest.java @@ -34,7 +34,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; +import org.jclouds.reflect.Invokable; import com.google.inject.Injector; @Test(groups = "unit") diff --git a/core/src/test/java/org/jclouds/rest/binders/BindMapToStringPayloadTest.java b/core/src/test/java/org/jclouds/rest/binders/BindMapToStringPayloadTest.java index 87c7ca0873..3f0a9865fc 100644 --- a/core/src/test/java/org/jclouds/rest/binders/BindMapToStringPayloadTest.java +++ b/core/src/test/java/org/jclouds/rest/binders/BindMapToStringPayloadTest.java @@ -33,7 +33,7 @@ import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import com.google.common.reflect.Invokable; +import org.jclouds.reflect.Invokable; /** * Tests behavior of {@code BindMapToStringPayload} diff --git a/core/src/test/java/org/jclouds/rest/functions/PresentWhenApiVersionLexicographicallyAtOrAfterSinceApiVersionTest.java b/core/src/test/java/org/jclouds/rest/functions/PresentWhenApiVersionLexicographicallyAtOrAfterSinceApiVersionTest.java index 6acd1bc26e..fa602b895d 100644 --- a/core/src/test/java/org/jclouds/rest/functions/PresentWhenApiVersionLexicographicallyAtOrAfterSinceApiVersionTest.java +++ b/core/src/test/java/org/jclouds/rest/functions/PresentWhenApiVersionLexicographicallyAtOrAfterSinceApiVersionTest.java @@ -35,7 +35,7 @@ import org.testng.annotations.Test; import com.google.common.base.Optional; import com.google.common.base.Stopwatch; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; +import org.jclouds.reflect.Invokable; /** * Allows you to use simple api version comparison to determine if a feature is diff --git a/core/src/test/java/org/jclouds/rest/internal/BaseRestApiTest.java b/core/src/test/java/org/jclouds/rest/internal/BaseRestApiTest.java index 57c91b784d..613453b3cc 100644 --- a/core/src/test/java/org/jclouds/rest/internal/BaseRestApiTest.java +++ b/core/src/test/java/org/jclouds/rest/internal/BaseRestApiTest.java @@ -40,17 +40,15 @@ import org.jclouds.http.config.ConfiguresHttpCommandExecutorService; import org.jclouds.http.functions.ParseSax; import org.jclouds.io.MutableContentMetadata; import org.jclouds.javax.annotation.Nullable; -import org.jclouds.reflect.Invocation; +import org.jclouds.reflect.Invokable; import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.XMLResponseParser; import org.jclouds.util.Strings2; import org.testng.annotations.Test; -import com.google.common.collect.ImmutableList; import com.google.common.collect.Multimap; import com.google.common.collect.SortedSetMultimap; import com.google.common.collect.TreeMultimap; -import com.google.common.reflect.Invokable; import com.google.inject.AbstractModule; import com.google.inject.Injector; import com.google.inject.name.Names; @@ -177,9 +175,9 @@ public abstract class BaseRestApiTest { assertEquals(expected, parserClass); } - protected void assertResponseParserClassEquals(Invokable method, HttpRequest request, @Nullable Class parserClass) { - assertEquals( - AsyncRestClientProxy.createResponseParser(parserFactory, injector, - Invocation.create(method, ImmutableList.of()), request).getClass(), parserClass); + protected void assertResponseParserClassEquals(Invokable method, GeneratedHttpRequest request, + @Nullable Class parserClass) { + assertEquals(TransformerForRequest.createResponseParser(parserFactory, injector, request).getClass(), + parserClass); } } diff --git a/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java b/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java index 436cfb38f6..4cf3fad888 100644 --- a/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java +++ b/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java @@ -143,7 +143,7 @@ import com.google.common.collect.ImmutableSortedSet; import com.google.common.collect.Lists; import com.google.common.collect.Multimap; import com.google.common.io.Files; -import com.google.common.reflect.Invokable; +import org.jclouds.reflect.Invokable; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.inject.AbstractModule; @@ -492,7 +492,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testQuery() throws SecurityException, NoSuchMethodException { Invokable method = Invokable.from(TestQuery.class.getMethod("foo")); - HttpRequest request = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertEquals(request.getEndpoint().getHost(), "localhost"); assertEquals(request.getEndpoint().getPath(), "/"); assertEquals(request.getEndpoint().getQuery(), "x-ms-version=2009-07-17&x-ms-rubbish=bin"); @@ -501,7 +501,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testQuery2() throws SecurityException, NoSuchMethodException { Invokable method = Invokable.from(TestQuery.class.getMethod("foo2")); - HttpRequest request = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertEquals(request.getEndpoint().getHost(), "localhost"); assertEquals(request.getEndpoint().getPath(), "/"); assertEquals(request.getEndpoint().getQuery(), "x-ms-version=2009-07-17&foo=bar&fooble=baz"); @@ -510,7 +510,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testQuery3() throws SecurityException, NoSuchMethodException { Invokable method = Invokable.from(TestQuery.class.getMethod("foo3", String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("wonder")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("wonder")); assertEquals(request.getEndpoint().getHost(), "localhost"); assertEquals(request.getEndpoint().getPath(), "/"); assertEquals(request.getEndpoint().getQuery(), "x-ms-version=2009-07-17&foo=bar&fooble=baz&robbie=wonder"); @@ -525,7 +525,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testNoNPEOnQueryParamWithNullable() throws SecurityException, NoSuchMethodException { Invokable method = Invokable.from(TestQuery.class.getMethod("foo3Nullable", String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); assertEquals(request.getEndpoint().getHost(), "localhost"); assertEquals(request.getEndpoint().getPath(), "/"); assertEquals(request.getEndpoint().getQuery(), "x-ms-version=2009-07-17&foo=bar&fooble=baz"); @@ -535,7 +535,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testQueryParamIterableOneString() throws SecurityException, NoSuchMethodException { Invokable method = Invokable.from(TestQuery.class.getMethod("queryParamIterable", Iterable.class)); Set bars = ImmutableSortedSet. of("1"); - HttpRequest request = processor.createRequest(method, ImmutableList. of(bars)); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(bars)); assertEquals(request.getEndpoint().getHost(), "localhost"); assertEquals(request.getEndpoint().getPath(), "/"); assertEquals(request.getEndpoint().getQuery(), "x-ms-version=2009-07-17&foo=1"); @@ -545,7 +545,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testQueryParamIterableString() throws SecurityException, NoSuchMethodException { Invokable method = Invokable.from(TestQuery.class.getMethod("queryParamIterable", Iterable.class)); Set bars = ImmutableSortedSet. of("1", "2", "3"); - HttpRequest request = processor.createRequest(method, ImmutableList. of(bars)); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(bars)); assertEquals(request.getEndpoint().getHost(), "localhost"); assertEquals(request.getEndpoint().getPath(), "/"); assertEquals(request.getEndpoint().getQuery(), "x-ms-version=2009-07-17&foo=1&foo=2&foo=3"); @@ -555,7 +555,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testQueryParamIterableInteger() throws SecurityException, NoSuchMethodException { Invokable method = Invokable.from(TestQuery.class.getMethod("queryParamIterable", Iterable.class)); Set bars = ImmutableSortedSet. of(1, 2, 3); - HttpRequest request = processor.createRequest(method, ImmutableList. of(bars)); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(bars)); assertEquals(request.getEndpoint().getHost(), "localhost"); assertEquals(request.getEndpoint().getPath(), "/"); assertEquals(request.getEndpoint().getQuery(), "x-ms-version=2009-07-17&foo=1&foo=2&foo=3"); @@ -565,7 +565,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testQueryParamIterableEmpty() throws SecurityException, NoSuchMethodException { Invokable method = Invokable.from(TestQuery.class.getMethod("queryParamIterable", Iterable.class)); Set bars = Collections.emptySet(); - HttpRequest request = processor.createRequest(method, ImmutableList. of(bars)); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(bars)); assertEquals(request.getEndpoint().getHost(), "localhost"); assertEquals(request.getEndpoint().getPath(), "/"); assertEquals(request.getEndpoint().getQuery(), "x-ms-version=2009-07-17"); @@ -574,7 +574,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testQueryParamIterableNull() throws SecurityException, NoSuchMethodException { Invokable method = Invokable.from(TestQuery.class.getMethod("queryParamIterable", Iterable.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); assertEquals(request.getEndpoint().getHost(), "localhost"); assertEquals(request.getEndpoint().getPath(), "/"); assertEquals(request.getEndpoint().getQuery(), "x-ms-version=2009-07-17"); @@ -602,7 +602,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testHttpRequestOptionsNoPayloadParam() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TestPayloadParamVarargs.class.getMethod("post")); - HttpRequest request = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(request, "POST http://localhost:9999 HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); assertPayloadEquals(request, "", "application/octet-stream", false); @@ -616,7 +616,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testHttpRequestOptionsPayloadParam() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TestPayloadParamVarargs.class.getMethod("post", Payload.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(Payloads.newStringPayload("foo"))); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(Payloads.newStringPayload("foo"))); assertRequestLineEquals(request, "POST http://localhost:9999 HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); assertPayloadEquals(request, "foo", "application/octet-stream", false); @@ -624,7 +624,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testHttpRequestWithOnlyContentType() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TestPayloadParamVarargs.class.getMethod("post", HttpRequestOptions.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(new TestHttpRequestOptions().payload("fooya"))); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(new TestHttpRequestOptions().payload("fooya"))); assertRequestLineEquals(request, "POST http://localhost:9999 HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); assertPayloadEquals(request, "fooya", "application/unknown", false); @@ -632,7 +632,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testHeaderAndQueryVarargs() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TestPayloadParamVarargs.class.getMethod("varargs", HttpRequestOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of( + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of( new TestHttpRequestOptions().payload("fooya"), new TestHttpRequestOptions().headerParams(ImmutableMultimap.of("X-header-1", "fooya")), new TestHttpRequestOptions().queryParams(ImmutableMultimap.of("key", "value")))); @@ -643,7 +643,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testHeaderAndQueryVarargsPlusReq() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TestPayloadParamVarargs.class.getMethod("varargsWithReq", String.class, HttpRequestOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("required param", + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("required param", new TestHttpRequestOptions().payload("fooya"), new TestHttpRequestOptions().headerParams(ImmutableMultimap.of("X-header-1", "fooya")), new TestHttpRequestOptions().queryParams(ImmutableMultimap.of("key", "value")))); @@ -654,7 +654,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testDuplicateHeaderAndQueryVarargs() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TestPayloadParamVarargs.class.getMethod("varargs", HttpRequestOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of( + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of( new TestHttpRequestOptions().queryParams(ImmutableMultimap.of("key", "value")), new TestHttpRequestOptions().payload("fooya"), new TestHttpRequestOptions().headerParams(ImmutableMultimap.of("X-header-1", "fooya")), @@ -674,7 +674,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testCustomMethod() throws SecurityException, NoSuchMethodException { Invokable method = Invokable.from(TestCustomMethod.class.getMethod("foo")); - HttpRequest request = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertEquals(request.getEndpoint().getHost(), "localhost"); assertEquals(request.getEndpoint().getPath(), ""); assertEquals(request.getMethod(), "FOO"); @@ -692,7 +692,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testOverriddenMethod() throws SecurityException, NoSuchMethodException { Invokable method = Invokable.from(TestOverridden.class.getMethod("foo")); - HttpRequest request = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertEquals(request.getEndpoint().getHost(), "localhost"); assertEquals(request.getEndpoint().getPath(), ""); assertEquals(request.getMethod(), "POST"); @@ -712,7 +712,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testOverriddenEndpointMethod() throws SecurityException, NoSuchMethodException { Invokable method = Invokable.from(TestOverriddenEndpoint.class.getMethod("foo")); - HttpRequest request = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertEquals(request.getEndpoint().getHost(), "localhost"); assertEquals(request.getEndpoint().getPort(), 1111); assertEquals(request.getEndpoint().getPath(), ""); @@ -721,7 +721,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testOverriddenEndpointParameter() throws SecurityException, NoSuchMethodException { Invokable method = Invokable.from(TestOverriddenEndpoint.class.getMethod("foo", URI.class)); - HttpRequest request = processor.createRequest(method, + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("http://wowsa:8001"))); assertEquals(request.getEndpoint().getHost(), "wowsa"); assertEquals(request.getEndpoint().getPort(), 8001); @@ -764,7 +764,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testCreatePostRequest() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TestPost.class.getMethod("post", String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("data")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("data")); assertRequestLineEquals(request, "POST http://localhost:9999 HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); @@ -773,7 +773,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testCreatePostRequestNullOk1() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TestPost.class.getMethod("post", String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(request, "POST http://localhost:9999 HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); @@ -782,7 +782,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testCreatePostRequestNullOk2() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TestPost.class.getMethod("post", String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); assertRequestLineEquals(request, "POST http://localhost:9999 HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); @@ -792,7 +792,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testCreatePostRequestNullNotOk1() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TestPost.class.getMethod("postNonnull", String.class)); try { - HttpRequest request = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); Assert.fail("call should have failed with illegal null parameter, not permitted " + request + " to be created"); } catch (NullPointerException e) { Assert.assertTrue(e.toString().indexOf("postNonnull parameter 1") >= 0, @@ -808,7 +808,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testCreatePostJsonRequest() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TestPost.class.getMethod("postAsJson", String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("data")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("data")); assertRequestLineEquals(request, "POST http://localhost:9999 HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); @@ -817,7 +817,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testCreatePostWithPathRequest() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TestPost.class.getMethod("postWithPath", String.class, MapBinder.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("data", new org.jclouds.rest.MapBinder() { + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("data", new org.jclouds.rest.MapBinder() { @Override public R bindToRequest(R request, Map postParams) { request.setPayload((String) postParams.get("fooble")); @@ -835,7 +835,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testCreatePostWithMethodBinder() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TestPost.class.getMethod("postWithMethodBinder", String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("data")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("data")); assertRequestLineEquals(request, "POST http://localhost:9999/data HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); @@ -844,7 +844,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testCreatePostWithMethodBinderAndDefaults() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TestPost.class.getMethod("postWithMethodBinderAndDefaults", String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("data")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("data")); assertRequestLineEquals(request, "POST http://localhost:9999/data HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); @@ -853,7 +853,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testCreatePostWithPayload() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TestPost.class.getMethod("testPayload", String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("data")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("data")); assertRequestLineEquals(request, "POST http://localhost:9999/data HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); @@ -1101,7 +1101,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testAlternateHttpMethod() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TestPut.class.getMethod("rowdy", String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("data")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("data")); assertRequestLineEquals(request, "ROWDY http://localhost:9999/strings/data HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); @@ -1110,7 +1110,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testAlternateHttpMethodSameArity() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TestPut.class.getMethod("rowdy", int.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("data")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("data")); assertRequestLineEquals(request, "ROWDY http://localhost:9999/ints/data HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); @@ -1119,7 +1119,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testCreatePutWithMethodBinder() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TestPut.class.getMethod("putWithMethodBinder", String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("data")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("data")); assertRequestLineEquals(request, "PUT http://localhost:9999/data HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); @@ -1128,7 +1128,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testCreatePutWithMethodProduces() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TestPut.class.getMethod("putWithMethodBinderProduces", String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("data")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("data")); assertRequestLineEquals(request, "PUT http://localhost:9999/data HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); @@ -1138,7 +1138,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @SuppressWarnings("unchecked") public void testCreatePutWithMethodConsumes() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TestPut.class.getMethod("putWithMethodBinderConsumes", String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("data")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("data")); assertRequestLineEquals(request, "PUT http://localhost:9999/data HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); @@ -1147,8 +1147,8 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { assertResponseParserClassEquals(method, request, ParseJson.class); // now test that it works! - Function parser = (Function) AsyncRestClientProxy - .createResponseParser(parserFactory, injector, Invocation.create(method, ImmutableList.of()), request); + Function parser = (Function) TransformerForRequest + .createResponseParser(parserFactory, injector, request); assertEquals(parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload("{ foo:\"bar\"}").build()).foo, "bar"); @@ -1157,13 +1157,13 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @SuppressWarnings("unchecked") public void testGeneric1() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TestPut.class.getMethod("testGeneric")); - HttpRequest request = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertResponseParserClassEquals(method, request, ParseJson.class); // now test that it works! - Function> parser = (Function>) AsyncRestClientProxy - .createResponseParser(parserFactory, injector, Invocation.create(method, ImmutableList.of()), request); + Function> parser = (Function>) TransformerForRequest + .createResponseParser(parserFactory, injector, request); assertEquals(parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload("{ foo:\"bar\"}").build()), ImmutableMap.of("foo", "bar")); @@ -1173,13 +1173,13 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @SuppressWarnings("unchecked") public void testGeneric2() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TestPut.class.getMethod("testGeneric2")); - HttpRequest request = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertResponseParserClassEquals(method, request, ParseJson.class); // now test that it works! - Function> parser = (Function>) AsyncRestClientProxy - .createResponseParser(parserFactory, injector, Invocation.create(method, ImmutableList.of()), request); + Function> parser = (Function>) TransformerForRequest + .createResponseParser(parserFactory, injector, request); assertEquals(parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload("{ foo:\"bar\"}").build()), ImmutableMap.of("foo", "bar")); @@ -1189,13 +1189,13 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @SuppressWarnings("unchecked") public void testGeneric3() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TestPut.class.getMethod("testGeneric3")); - HttpRequest request = processor.createRequest(method ,ImmutableList.of()); + GeneratedHttpRequest request = processor.createRequest(method ,ImmutableList.of()); assertResponseParserClassEquals(method, request, ParseJson.class); // now test that it works! - Function> parser = (Function>) AsyncRestClientProxy - .createResponseParser(parserFactory, injector, Invocation.create(method, ImmutableList.of()), request); + Function> parser = (Function>) TransformerForRequest + .createResponseParser(parserFactory, injector, request); assertEquals(parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload("{ foo:\"bar\"}").build()), ImmutableMap.of("foo", "bar")); @@ -1205,13 +1205,13 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @SuppressWarnings("unchecked") public void testUnwrap1() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TestPut.class.getMethod("testUnwrap")); - HttpRequest request = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); // now test that it works! - Function> parser = (Function>) AsyncRestClientProxy - .createResponseParser(parserFactory, injector, Invocation.create(method, ImmutableList.of()), request); + Function> parser = (Function>) TransformerForRequest + .createResponseParser(parserFactory, injector, request); assertEquals(parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload("{ foo:\"bar\"}").build()), "bar"); @@ -1220,13 +1220,13 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @SuppressWarnings("unchecked") public void testUnwrapValueNamed() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TestPut.class.getMethod("testUnwrapValueNamed")); - HttpRequest request = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertResponseParserClassEquals(method, request, ParseFirstJsonValueNamed.class); // now test that it works! - Function> parser = (Function>) AsyncRestClientProxy - .createResponseParser(parserFactory, injector, Invocation.create(method, ImmutableList.of()), request); + Function> parser = (Function>) TransformerForRequest + .createResponseParser(parserFactory, injector, request); assertEquals(parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload("{ foo:\"bar\"}").build()), "bar"); @@ -1234,20 +1234,20 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testWrapWith() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TestPut.class.getMethod("testWrapWith", String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("bar")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bar")); assertPayloadEquals(request, "{\"foo\":\"bar\"}", "application/json", false); } @SuppressWarnings("unchecked") public void testUnwrap2() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TestPut.class.getMethod("testUnwrap2")); - HttpRequest request = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); // now test that it works! - Function> parser = (Function>) AsyncRestClientProxy - .createResponseParser(parserFactory, injector, Invocation.create(method, ImmutableList.of()), request); + Function> parser = (Function>) TransformerForRequest + .createResponseParser(parserFactory, injector, request); assertEquals(parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload("{ foo:\"bar\"}").build()), "bar"); @@ -1256,13 +1256,13 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @SuppressWarnings("unchecked") public void testUnwrap3() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TestPut.class.getMethod("testUnwrap3")); - HttpRequest request = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); // now test that it works! - Function> parser = (Function>) AsyncRestClientProxy - .createResponseParser(parserFactory, injector, Invocation.create(method, ImmutableList.of()), request); + Function> parser = (Function>) TransformerForRequest + .createResponseParser(parserFactory, injector, request); assertEquals(parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload("{\"runit\":[\"0.7.0\",\"0.7.1\"]}").build()), ImmutableSet.of("0.7.0", "0.7.1")); @@ -1271,13 +1271,13 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @SuppressWarnings("unchecked") public void testUnwrap4() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TestPut.class.getMethod("testUnwrap4")); - HttpRequest request = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class); // now test that it works! - Function> parser = (Function>) AsyncRestClientProxy - .createResponseParser(parserFactory, injector, Invocation.create(method, ImmutableList.of()), request); + Function> parser = (Function>) TransformerForRequest + .createResponseParser(parserFactory, injector, request); assertEquals(parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload("{\"runit\":[\"0.7.0\",\"0.7.1\"]}").build()), ImmutableSet.of("0.7.0", "0.7.1")); @@ -1286,13 +1286,13 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @SuppressWarnings("unchecked") public void selectLong() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TestPut.class.getMethod("selectLong")); - HttpRequest request = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertResponseParserClassEquals(method, request, ParseFirstJsonValueNamed.class); // now test that it works! - Function> parser = (Function>) AsyncRestClientProxy - .createResponseParser(parserFactory, injector, Invocation.create(method, ImmutableList.of()), request); + Function> parser = (Function>) TransformerForRequest + .createResponseParser(parserFactory, injector, request); assertEquals(parser.apply(HttpResponse.builder().statusCode(200).message("ok") .payload("{ \"destroyvirtualmachineresponse\" : {\"jobid\":4} }").build()), Long.valueOf(4)); @@ -1301,10 +1301,10 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @SuppressWarnings("unchecked") public void selectLongAddOne() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TestPut.class.getMethod("selectLongAddOne")); - HttpRequest request = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); - Function> parser = (Function>) AsyncRestClientProxy - .createResponseParser(parserFactory, injector, Invocation.create(method, ImmutableList.of()), request); + Function> parser = (Function>) TransformerForRequest + .createResponseParser(parserFactory, injector, request); assertEquals(parser.apply(HttpResponse.builder().statusCode(200).message("ok") .payload("{ \"destroyvirtualmachineresponse\" : {\"jobid\":4} }").build()), Long.valueOf(5)); @@ -1341,7 +1341,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test public void testRequestFilter() throws SecurityException, NoSuchMethodException { Invokable method = Invokable.from(TestRequestFilter.class.getMethod("get")); - HttpRequest request = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertEquals(request.getFilters().size(), 2); assertEquals(request.getFilters().get(0).getClass(), TestRequestFilter1.class); assertEquals(request.getFilters().get(1).getClass(), TestRequestFilter2.class); @@ -1349,14 +1349,14 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testRequestFilterOverride() throws SecurityException, NoSuchMethodException { Invokable method = Invokable.from(TestRequestFilter.class.getMethod("getOverride")); - HttpRequest request = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertEquals(request.getFilters().size(), 1); assertEquals(request.getFilters().get(0).getClass(), TestRequestFilter2.class); } public void testRequestFilterOverrideOnRequest() throws SecurityException, NoSuchMethodException { Invokable method = Invokable.from(TestRequestFilter.class.getMethod("getOverride", HttpRequest.class)); - HttpRequest request = processor.createRequest( + GeneratedHttpRequest request = processor.createRequest( method, ImmutableList. of( HttpRequest.builder().method("GET").endpoint("http://localhost") .addHeader("foo", "bar").build())); @@ -1375,7 +1375,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test public void testSkipEncoding() throws SecurityException, NoSuchMethodException { Invokable method = Invokable.from(TestEncoding.class.getMethod("twoPaths", String.class, String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("1", "localhost")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("1", "localhost")); assertEquals(request.getEndpoint().getPath(), "/1/localhost"); assertEquals(request.getMethod(), HttpMethod.GET); assertEquals(request.getHeaders().size(), 0); @@ -1384,7 +1384,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test public void testEncodingPath() throws SecurityException, NoSuchMethodException { Invokable method = Invokable.from(TestEncoding.class.getMethod("twoPaths", String.class, String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("/", "localhost" )); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("/", "localhost" )); assertEquals(request.getEndpoint().getPath(), "///localhost"); assertEquals(request.getMethod(), HttpMethod.GET); assertEquals(request.getHeaders().size(), 0); @@ -1404,7 +1404,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test(enabled = false) public void testConstantPathParam() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TestConstantPathParam.class.getMethod("twoPaths", String.class, String.class)); - HttpRequest request = processor.createRequest(method, + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("1", "localhost")); assertRequestLineEquals(request, "GET http://localhost:9999/v1/ralphie/1/localhost HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); @@ -1457,7 +1457,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test public void testPathParamExtractor() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TestPath.class.getMethod("onePathParamExtractor", String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("localhost")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("localhost")); assertRequestLineEquals(request, "GET http://localhost:9999/l HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); assertPayloadEquals(request, null, null, false); @@ -1466,7 +1466,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test public void testQueryParamExtractor() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TestPath.class.getMethod("oneQueryParamExtractor", String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("localhost")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("localhost")); assertRequestLineEquals(request, "GET http://localhost:9999/?one=l HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); assertPayloadEquals(request, null, null, false); @@ -1475,7 +1475,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test public void testFormParamExtractor() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TestPath.class.getMethod("oneFormParamExtractor", String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("localhost")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("localhost")); assertRequestLineEquals(request, "POST http://localhost:9999/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); assertPayloadEquals(request, "one=l", "application/x-www-form-urlencoded", false); @@ -1704,7 +1704,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testPutPayloadEnclosing() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TestTransformers.class.getMethod("put", PayloadEnclosing.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of( + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of( new PayloadEnclosingImpl(newStringPayload("whoops")))); assertRequestLineEquals(request, "PUT http://localhost:9999 HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); @@ -1715,7 +1715,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { Invokable method = Invokable.from(TestTransformers.class.getMethod("put", PayloadEnclosing.class)); PayloadEnclosing payloadEnclosing = new PayloadEnclosingImpl(newStringPayload("whoops")); calculateMD5(payloadEnclosing); - HttpRequest request = processor.createRequest(method, ImmutableList. of(payloadEnclosing)); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(payloadEnclosing)); assertRequestLineEquals(request, "PUT http://localhost:9999 HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); @@ -1729,7 +1729,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { newInputStreamPayload(Strings2.toInputStream("whoops"))); calculateMD5(payloadEnclosing); - HttpRequest request = processor.createRequest(method, ImmutableList. of(payloadEnclosing)); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(payloadEnclosing)); assertRequestLineEquals(request, "PUT http://localhost:9999 HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); @@ -1738,7 +1738,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testPutPayloadChunkedNoContentLength() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TestTransformers.class.getMethod("putXfer", Payload.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(newStringPayload("whoops"))); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(newStringPayload("whoops"))); assertRequestLineEquals(request, "PUT http://localhost:9999 HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Transfer-Encoding: chunked\n"); assertPayloadEquals(request, "whoops", "application/unknown", false); @@ -1746,7 +1746,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testPutPayload() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TestTransformers.class.getMethod("put", Payload.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(newStringPayload("whoops"))); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(newStringPayload("whoops"))); assertRequestLineEquals(request, "PUT http://localhost:9999 HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); assertPayloadEquals(request, "whoops", "application/unknown", false); @@ -1756,7 +1756,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { Invokable method = Invokable.from(TestTransformers.class.getMethod("put", Payload.class)); Payload payload = newStringPayload("whoops"); payload.getContentMetadata().setContentDisposition("attachment; filename=photo.jpg"); - HttpRequest request = processor.createRequest(method, ImmutableList. of(payload)); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(payload)); assertRequestLineEquals(request, "PUT http://localhost:9999 HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); assertPayloadEquals(request, "whoops", "application/unknown", "attachment; filename=photo.jpg", null, null, false); @@ -1766,7 +1766,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { Invokable method = Invokable.from(TestTransformers.class.getMethod("put", Payload.class)); Payload payload = newStringPayload("whoops"); payload.getContentMetadata().setContentEncoding("gzip"); - HttpRequest request = processor.createRequest(method, ImmutableList. of(payload)); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(payload)); assertRequestLineEquals(request, "PUT http://localhost:9999 HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); assertPayloadEquals(request, "whoops", "application/unknown", null, "gzip", null, false); @@ -1776,7 +1776,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { Invokable method = Invokable.from(TestTransformers.class.getMethod("put", Payload.class)); Payload payload = newStringPayload("whoops"); payload.getContentMetadata().setContentLanguage("en"); - HttpRequest request = processor.createRequest(method, ImmutableList. of(payload)); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(payload)); assertRequestLineEquals(request, "PUT http://localhost:9999 HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); assertPayloadEquals(request, "whoops", "application/unknown", null, null, "en", false); @@ -1787,7 +1787,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { Payload payload = newStringPayload("whoops"); calculateMD5(payload); Invokable method = Invokable.from(TestTransformers.class.getMethod("put", Payload.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(payload)); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(payload)); assertRequestLineEquals(request, "PUT http://localhost:9999 HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); assertPayloadEquals(request, "whoops", "application/unknown", true); @@ -1797,7 +1797,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { Payload payload = newInputStreamPayload(Strings2.toInputStream("whoops")); payload.getContentMetadata().setContentLength((long) "whoops".length()); Invokable method = Invokable.from(TestTransformers.class.getMethod("put", Payload.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(payload)); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(payload)); assertRequestLineEquals(request, "PUT http://localhost:9999 HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); assertPayloadEquals(request, "whoops", "application/unknown", false); @@ -1808,7 +1808,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { Payload payload = newStringPayload("whoops"); calculateMD5(payload); Invokable method = Invokable.from(TestTransformers.class.getMethod("put", Payload.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(payload)); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(payload)); assertRequestLineEquals(request, "PUT http://localhost:9999 HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); assertPayloadEquals(request, "whoops", "application/unknown", true); @@ -1822,7 +1822,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @SuppressWarnings("unchecked") public static Class> unwrap(RestAnnotationProcessor processor, Invokable method) { - return (Class>) AsyncRestClientProxy + return (Class>) TransformerForRequest .getParserOrThrowException(Invocation.create(method, ImmutableList.of())).getTypeLiteral().getRawType(); } @@ -1847,7 +1847,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test(expectedExceptions = { RuntimeException.class }) public void testNoTransformer() throws SecurityException, NoSuchMethodException { Invokable method = Invokable.from(TestTransformers.class.getMethod("noTransformer")); - AsyncRestClientProxy.getParserOrThrowException(Invocation.create(method, ImmutableList.of())); + TransformerForRequest.getParserOrThrowException(Invocation.create(method, ImmutableList.of())); } public void oneTransformerWithContext() throws SecurityException, NoSuchMethodException { @@ -1859,8 +1859,8 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { Invocation.create(Invokable.from(TestTransformers.class.getMethod("oneTransformerWithContext")), ImmutableList.of())) .build(); - Function transformer = AsyncRestClientProxy.createResponseParser(parserFactory, injector, - request.getInvocation(), request); + Function transformer = TransformerForRequest.createResponseParser(parserFactory, injector, + request); assertEquals(transformer.getClass(), ReturnStringIf200Context.class); assertEquals(((ReturnStringIf200Context) transformer).request, request); } @@ -1924,7 +1924,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { Date date = new Date(); GetOptions options = GetOptions.Builder.ifModifiedSince(date); Invokable method = Invokable.from(TestRequest.class.getMethod("get", String.class, HttpRequestOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("1", options)); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("1", options)); assertEquals(request.getEndpoint().getHost(), "localhost"); assertEquals(request.getEndpoint().getPath(), "/1"); assertEquals(request.getMethod(), HttpMethod.GET); @@ -1938,7 +1938,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { Date date = new Date(); GetOptions options = GetOptions.Builder.ifModifiedSince(date); Invokable method = Invokable.from(TestRequest.class.getMethod("get", String.class, HttpRequestOptions.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("1", options)); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("1", options)); assertEquals(request.getEndpoint().getHost(), "localhost"); assertEquals(request.getEndpoint().getPath(), "/1"); assertEquals(request.getMethod(), HttpMethod.GET); @@ -1958,7 +1958,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testCreateGetOptionsThatProducesQuery() throws SecurityException, NoSuchMethodException, IOException { PrefixOptions options = new PrefixOptions().withPrefix("1"); Invokable method = Invokable.from(TestRequest.class.getMethod("get", String.class, HttpRequestOptions.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("1", options)); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("1", options)); assertRequestLineEquals(request, "GET http://localhost:9999/1?prefix=1 HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: localhost:9999\n"); assertPayloadEquals(request, null, null, false); @@ -1966,7 +1966,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testCreateGetQuery() throws SecurityException, NoSuchMethodException { Invokable method = Invokable.from(TestRequest.class.getMethod("getQuery", String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("1")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("1")); assertEquals(request.getEndpoint().getHost(), "localhost"); assertEquals(request.getEndpoint().getPath(), "/1"); assertEquals(request.getEndpoint().getQuery(), "max-keys=0"); @@ -1976,7 +1976,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testCreateGetQueryNull() throws SecurityException, NoSuchMethodException { Invokable method = Invokable.from(TestRequest.class.getMethod("getQueryNull", String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("1")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("1")); assertEquals(request.getEndpoint().getHost(), "localhost"); assertEquals(request.getEndpoint().getPath(), "/1"); assertEquals(request.getEndpoint().getQuery(), "acl"); @@ -1986,7 +1986,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testCreateGetQueryEmpty() throws SecurityException, NoSuchMethodException { Invokable method = Invokable.from(TestRequest.class.getMethod("getQueryEmpty", String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("1")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("1")); assertEquals(request.getEndpoint().getHost(), "localhost"); assertEquals(request.getEndpoint().getPath(), "/1"); assertEquals(request.getEndpoint().getQuery(), "acl="); @@ -2004,7 +2004,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testCreateGetOptionsThatProducesPayload() throws SecurityException, NoSuchMethodException, IOException { PayloadOptions options = new PayloadOptions(); Invokable method = Invokable.from(TestRequest.class.getMethod("putOptions", String.class, HttpRequestOptions.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("1", options)); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("1", options)); assertRequestLineEquals(request, "PUT http://localhost:9999/1 HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: localhost:9999\n"); @@ -2020,7 +2020,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testCreateGetRequest(String key) throws SecurityException, NoSuchMethodException, UnsupportedEncodingException { Invokable method = Invokable.from(TestRequest.class.getMethod("get", String.class, String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(key, "localhost")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(key, "localhost")); assertEquals(request.getEndpoint().getHost(), "localhost"); String expectedPath = "/" + URLEncoder.encode(key, "UTF-8").replaceAll("\\+", "%20"); assertEquals(request.getEndpoint().getRawPath(), expectedPath); @@ -2032,7 +2032,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testCreatePutRequest() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TestRequest.class.getMethod("put", String.class, String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("111", "data")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("111", "data")); assertRequestLineEquals(request, "PUT http://localhost:9999/1 HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); @@ -2041,7 +2041,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { public void testCreatePutHeader() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TestRequest.class.getMethod("putHeader", String.class, String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("1", "data")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("1", "data")); assertRequestLineEquals(request, "PUT http://localhost:9999/1 HTTP/1.1"); assertNonPayloadHeadersEqual(request, "foo: --1--\n"); @@ -2060,7 +2060,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test public void testVirtualHostMethod() throws SecurityException, NoSuchMethodException { Invokable method = Invokable.from(TestVirtualHostMethod.class.getMethod("get", String.class, String.class)); - HttpRequest request = processor.createRequest(method, + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("1", "localhost")); assertEquals(request.getEndpoint().getHost(), "localhost"); assertEquals(request.getEndpoint().getPath(), "/1"); @@ -2084,7 +2084,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test public void testVirtualHost() throws SecurityException, NoSuchMethodException { Invokable method = Invokable.from(TestVirtualHost.class.getMethod("get", String.class, String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("1", "localhost")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("1", "localhost")); assertEquals(request.getEndpoint().getHost(), "localhost"); assertEquals(request.getEndpoint().getPath(), "/1"); assertEquals(request.getMethod(), HttpMethod.GET); @@ -2095,7 +2095,7 @@ public class RestAnnotationProcessorTest extends BaseRestApiTest { @Test public void testHostPrefix() throws SecurityException, NoSuchMethodException { Invokable method = Invokable.from(TestVirtualHost.class.getMethod("getPrefix", String.class, String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("1", "holy")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("1", "holy")); assertEquals(request.getEndpoint().getHost(), "holy.localhost"); assertEquals(request.getEndpoint().getPath(), "/1"); assertEquals(request.getMethod(), HttpMethod.GET); diff --git a/core/src/test/java/org/jclouds/util/Optionals2Test.java b/core/src/test/java/org/jclouds/util/Optionals2Test.java index 5f156176f4..2f6fb4348c 100644 --- a/core/src/test/java/org/jclouds/util/Optionals2Test.java +++ b/core/src/test/java/org/jclouds/util/Optionals2Test.java @@ -25,7 +25,7 @@ import static org.testng.Assert.assertTrue; import org.testng.annotations.Test; import com.google.common.base.Optional; -import com.google.common.reflect.Invokable; +import org.jclouds.reflect.Invokable; /** * @author Adrian Cole From 248048183596511a5eef55bcfae70e60840a316c Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Tue, 8 Jan 2013 00:32:45 -0800 Subject: [PATCH 2/2] dependent changes on tests and internal classes --- .../blobstore/AtmosBlobRequestSigner.java | 14 ++- .../jclouds/atmos/AtmosAsyncClientTest.java | 31 +++--- .../CloudServersAsyncClientTest.java | 99 ++++++++++--------- .../jclouds/cloudsigma/CloudSigmaClient.java | 1 + .../config/CloudSigmaRestClientModule.java | 2 +- .../cloudsigma/functions/MapToDevices.java | 2 +- .../org/jclouds/cloudsigma/util/Servers.java | 1 + .../cloudsigma/CloudSigmaAsyncClientTest.java | 85 ++++++++-------- ...loneDriveOptionsToPlainTextStringTest.java | 2 +- .../features/AccountAsyncClientTest.java | 10 +- .../features/AddressAsyncClientTest.java | 14 +-- .../features/AsyncJobAsyncClientTest.java | 10 +- .../ConfigurationAsyncClientTest.java | 6 +- .../DomainAccountAsyncClientTest.java | 8 +- .../features/DomainLimitAsyncClientTest.java | 6 +- .../features/EventAsyncClientTest.java | 10 +- .../features/FirewallAsyncClientTest.java | 12 +-- .../GlobalAccountAsyncClientTest.java | 9 +- .../features/GlobalAlertAsyncClientTest.java | 8 +- .../GlobalCapacityAsyncClientTest.java | 8 +- .../features/GlobalHostAsyncClientTest.java | 6 +- .../GlobalOfferingAsyncClientTest.java | 17 ++-- .../GlobalStoragePoolAsyncClientTest.java | 8 +- .../features/GlobalUsageAsyncClientTest.java | 12 +-- .../features/GlobalUserAsyncClientTest.java | 9 +- .../features/GuestOSAsyncClientTest.java | 14 +-- .../features/HypervisorAsyncClientTest.java | 8 +- .../features/ISOAsyncClientTest.java | 29 +++--- .../features/LimitAsyncClientTest.java | 8 +- .../features/LoadBalancerAsyncClientTest.java | 15 +-- .../features/NATAsyncClientTest.java | 19 ++-- .../features/NetworkAsyncClientTest.java | 15 +-- .../features/OfferingAsyncClientTest.java | 22 ++--- .../features/SSHKeyPairAsyncClientTest.java | 14 +-- .../SecurityGroupAsyncClientTest.java | 23 ++--- .../features/SnapshotAsyncClientTest.java | 25 ++--- .../features/TemplateAsyncClientTest.java | 39 ++++---- .../features/VMGroupAsyncClientTest.java | 18 ++-- .../VirtualMachineAsyncClientTest.java | 27 ++--- .../features/VolumeAsyncClientTest.java | 17 ++-- .../features/ZoneAsyncClientTest.java | 14 +-- .../ec2/services/AMIAsyncClientTest.java | 59 +++++------ ...ilabilityZoneAndRegionAsyncClientTest.java | 12 +-- .../ElasticBlockStoreAsyncClientTest.java | 43 ++++---- .../ElasticIPAddressAsyncClientTest.java | 15 +-- .../ec2/services/InstanceAsyncClientTest.java | 63 ++++++------ .../ec2/services/KeyPairAsyncClientTest.java | 10 +- .../SecurityGroupAsyncClientTest.java | 25 ++--- .../ec2/services/WindowsAsyncClientTest.java | 15 +-- .../ElasticStackAsyncClientTest.java | 55 ++++++----- ...EqualsAnyNamespaceInExtensionsSetTest.java | 2 +- .../s3/blobstore/S3BlobRequestSigner.java | 18 ++-- .../org/jclouds/s3/S3AsyncClientTest.java | 50 +++++----- ...indAsHostPrefixIfConfiguredNoPathTest.java | 2 +- .../BindAsHostPrefixIfConfiguredTest.java | 2 +- ...rOperationAbortedWhenBucketExistsTest.java | 2 +- .../RequestAuthorizeSignatureTest.java | 6 +- .../swift/blobstore/SwiftBlobSigner.java | 23 +++-- .../swift/internal/BasePayloadTest.java | 2 +- .../vcloud/VCloudVersionsAsyncClientTest.java | 5 +- .../features/CatalogAsyncClientTest.java | 14 +-- .../features/NetworkAsyncClientTest.java | 8 +- .../vcloud/features/OrgAsyncClientTest.java | 10 +- .../vcloud/features/TaskAsyncClientTest.java | 12 +-- .../vcloud/features/VAppAsyncClientTest.java | 34 +++---- .../features/VAppTemplateAsyncClientTest.java | 22 ++--- .../vcloud/features/VDCAsyncClientTest.java | 10 +- .../vcloud/features/VmAsyncClientTest.java | 34 +++---- .../vcloud/internal/BasePayloadTest.java | 2 +- .../internal/VCloudLoginAsyncClientTest.java | 5 +- .../blobstore/util/BlobStoreUtilsTest.java | 2 +- .../OpenStackAuthAsyncClientTest.java | 7 +- .../vcloud_0_8/internal/BasePayloadTest.java | 2 +- .../TerremarkVCloudLoginAsyncClientTest.java | 5 +- ...erremarkVCloudVersionsAsyncClientTest.java | 5 +- .../abiquo/binders/BindToPathTest.java | 2 +- .../cloud/BindMoveVolumeToPathTest.java | 2 +- ...dNetworkConfigurationRefToPayloadTest.java | 2 +- .../BindSupportedDevicesLinkToPathTest.java | 2 +- .../abiquo/features/AdminAsyncApiTest.java | 2 +- .../abiquo/features/CloudAsyncApiTest.java | 2 +- .../abiquo/features/ConfigAsyncApiTest.java | 2 +- .../features/EnterpriseAsyncApiTest.java | 2 +- .../abiquo/features/EventAsyncApiTest.java | 2 +- .../features/InfrastructureAsyncApiTest.java | 2 +- .../abiquo/features/PricingAsyncApiTest.java | 2 +- .../abiquo/features/TaskAsyncApiTest.java | 2 +- .../VirtualMachineTemplateAsyncApiTest.java | 2 +- .../internal/AbiquoHttpAsyncClientTest.java | 2 +- .../oauth/v2/functions/BuildTokenRequest.java | 4 +- .../vpdc/features/BrowsingAsyncApiTest.java | 28 +++--- .../vpdc/features/FirewallAsyncApiTest.java | 8 +- .../ServiceManagementAsyncApiTest.java | 12 +-- .../savvis/vpdc/features/VMAsyncApiTest.java | 24 ++--- .../DescribeSecurityGroupsResponseTest.java | 2 +- .../ec2/services/AWSAMIAsyncClientTest.java | 65 ++++++------ .../services/AWSInstanceAsyncClientTest.java | 61 ++++++------ .../services/AWSKeyPairAsyncClientTest.java | 15 +-- .../AWSSecurityGroupAsyncClientTest.java | 21 ++-- .../services/MonitoringAsyncClientTest.java | 8 +- .../PlacementGroupAsyncClientTest.java | 15 +-- .../services/SpotInstanceAsyncClientTest.java | 21 ++-- .../jclouds/aws/s3/AWSS3AsyncClientTest.java | 26 ++--- .../blobstore/AzureBlobRequestSigner.java | 15 +-- .../azureblob/AzureBlobAsyncClientTest.java | 33 ++++--- .../services/GridImageAsyncClientTest.java | 26 ++--- .../services/GridIpAsyncClientTest.java | 12 +-- .../services/GridJobAsyncClientTest.java | 18 ++-- .../GridLoadBalancerAsyncClientTest.java | 27 ++--- .../services/GridServerAsyncClientTest.java | 44 ++++----- ...HPCloudObjectStorageBlobRequestSigner.java | 31 +++--- .../features/AccountAsyncClientTest.java | 6 +- .../features/DatacenterAsyncClientTest.java | 12 +-- .../ProductPackageAsyncClientTest.java | 6 +- .../features/VirtualGuestAsyncClientTest.java | 22 ++--- .../TerremarkECloudAsyncClientTest.java | 56 +++++------ .../DataCenterOperationsAsyncClientTest.java | 8 +- .../TagOperationsAsyncClientTest.java | 8 +- ...TerremarkVCloudExpressAsyncClientTest.java | 57 +++++------ .../nirvanix/sdn/SDNAsyncClientTest.java | 10 +- .../nirvanix/sdn/SDNAuthAsyncClientTest.java | 2 +- .../InsertUserContextIntoPathTest.java | 6 +- .../jclouds/mezeo/pcs/PCSAsyncClientTest.java | 22 ++--- .../mezeo/pcs/PCSCloudAsyncClientTest.java | 2 +- .../simpledb/SimpleDBAsyncClientTest.java | 6 +- .../azurequeue/AzureQueueAsyncClientTest.java | 20 ++-- .../boxdotnet/BoxDotNetAsyncClientTest.java | 6 +- .../IBMSmartCloudAsyncClientTest.java | 68 ++++++------- .../twitter/TwitterAsyncClientTest.java | 6 +- 129 files changed, 1092 insertions(+), 1053 deletions(-) diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosBlobRequestSigner.java b/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosBlobRequestSigner.java index 057957d8e6..79e56fe38c 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosBlobRequestSigner.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosBlobRequestSigner.java @@ -37,7 +37,9 @@ import org.jclouds.reflect.Invocation; import org.jclouds.rest.internal.RestAnnotationProcessor; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; +import com.google.common.reflect.TypeToken; + +import org.jclouds.reflect.Invokable; /** * @@ -59,10 +61,12 @@ public class AtmosBlobRequestSigner implements BlobRequestSigner { this.processor = checkNotNull(processor, "processor"); this.blobToObject = checkNotNull(blobToObject, "blobToObject"); this.blob2ObjectGetOptions = checkNotNull(blob2ObjectGetOptions, "blob2ObjectGetOptions"); - this.getMethod = Invokable.from(AtmosAsyncClient.class.getMethod("readFile", String.class, GetOptions[].class)); - this.deleteMethod = Invokable.from(AtmosAsyncClient.class.getMethod("deletePath", String.class)); - this.createMethod = Invokable.from(AtmosAsyncClient.class.getMethod("createFile", String.class, - AtmosObject.class, PutOptions[].class)); + this.getMethod = Invokable.from(TypeToken.of(AtmosAsyncClient.class), + AtmosAsyncClient.class.getMethod("readFile", String.class, GetOptions[].class)); + this.deleteMethod = Invokable.from(TypeToken.of(AtmosAsyncClient.class), + AtmosAsyncClient.class.getMethod("deletePath", String.class)); + this.createMethod = Invokable.from(TypeToken.of(AtmosAsyncClient.class), + AtmosAsyncClient.class.getMethod("createFile", String.class, AtmosObject.class, PutOptions[].class)); } @Override diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/AtmosAsyncClientTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/AtmosAsyncClientTest.java index 55967cfc57..f84c79a8ce 100644 --- a/apis/atmos/src/test/java/org/jclouds/atmos/AtmosAsyncClientTest.java +++ b/apis/atmos/src/test/java/org/jclouds/atmos/AtmosAsyncClientTest.java @@ -47,14 +47,15 @@ import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseURIFromListOrLocationHeaderIf20x; import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.http.options.GetOptions; +import org.jclouds.reflect.Invokable; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.internal.BaseAsyncClientTest; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import com.google.common.base.Supplier; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; import com.google.inject.Module; /** @@ -70,7 +71,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest public void testListDirectories() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(AtmosAsyncClient.class.getMethod("listDirectories", ListOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(request, "GET https://accesspoint.atmosonline.com/rest/namespace HTTP/1.1"); assertNonPayloadHeadersEqual(request, HttpHeaders.ACCEPT + ": text/xml\n"); @@ -85,7 +86,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest public void testListDirectory() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(AtmosAsyncClient.class.getMethod("listDirectory", String.class, ListOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("directory")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("directory")); assertRequestLineEquals(request, "GET https://accesspoint.atmosonline.com/rest/namespace/directory/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, HttpHeaders.ACCEPT + ": text/xml\n"); @@ -100,7 +101,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest public void testListDirectoriesOptions() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(AtmosAsyncClient.class.getMethod("listDirectories", ListOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(new ListOptions().limit(1).token("asda"))); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(new ListOptions().limit(1).token("asda"))); assertRequestLineEquals(request, "GET https://accesspoint.atmosonline.com/rest/namespace HTTP/1.1"); assertNonPayloadHeadersEqual(request, HttpHeaders.ACCEPT + ": text/xml\nx-emc-limit: 1\nx-emc-token: asda\n"); @@ -115,7 +116,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest public void testListDirectoryOptions() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(AtmosAsyncClient.class.getMethod("listDirectory", String.class, ListOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("directory", new ListOptions().limit(1).token("asda"))); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("directory", new ListOptions().limit(1).token("asda"))); assertRequestLineEquals(request, "GET https://accesspoint.atmosonline.com/rest/namespace/directory/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, HttpHeaders.ACCEPT + ": text/xml\nx-emc-limit: 1\nx-emc-token: asda\n"); @@ -130,7 +131,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest public void testCreateDirectory() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(AtmosAsyncClient.class.getMethod("createDirectory", String.class, PutOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("dir")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("dir")); assertRequestLineEquals(request, "POST https://accesspoint.atmosonline.com/rest/namespace/dir/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, HttpHeaders.ACCEPT + ": */*\n"); @@ -145,7 +146,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest public void testCreateDirectoryOptions() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(AtmosAsyncClient.class.getMethod("createDirectory", String.class, PutOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("dir", PutOptions.Builder.publicRead())); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("dir", PutOptions.Builder.publicRead())); assertRequestLineEquals(request, "POST https://accesspoint.atmosonline.com/rest/namespace/dir/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, HttpHeaders.ACCEPT @@ -162,7 +163,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest public void testCreateFile() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(AtmosAsyncClient.class.getMethod("createFile", String.class, AtmosObject.class, PutOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("dir", blobToObject + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("dir", blobToObject .apply(BindBlobToMultipartFormTest.TEST_BLOB))); assertRequestLineEquals(request, "POST https://accesspoint.atmosonline.com/rest/namespace/dir/hello HTTP/1.1"); @@ -179,7 +180,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest public void testCreateFileOptions() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(AtmosAsyncClient.class.getMethod("createFile", String.class, AtmosObject.class, PutOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("dir", blobToObject + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("dir", blobToObject .apply(BindBlobToMultipartFormTest.TEST_BLOB), PutOptions.Builder.publicRead())); assertRequestLineEquals(request, "POST https://accesspoint.atmosonline.com/rest/namespace/dir/hello HTTP/1.1"); @@ -197,7 +198,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest public void testUpdateFile() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(AtmosAsyncClient.class.getMethod("updateFile", String.class, AtmosObject.class, PutOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("dir", blobToObject + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("dir", blobToObject .apply(BindBlobToMultipartFormTest.TEST_BLOB))); assertRequestLineEquals(request, "PUT https://accesspoint.atmosonline.com/rest/namespace/dir/hello HTTP/1.1"); @@ -214,7 +215,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest public void testUpdateFileOptions() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(AtmosAsyncClient.class.getMethod("updateFile", String.class, AtmosObject.class, PutOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("dir", blobToObject + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("dir", blobToObject .apply(BindBlobToMultipartFormTest.TEST_BLOB), PutOptions.Builder.publicRead())); assertRequestLineEquals(request, "PUT https://accesspoint.atmosonline.com/rest/namespace/dir/hello HTTP/1.1"); @@ -231,7 +232,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest public void testReadFile() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(AtmosAsyncClient.class.getMethod("readFile", String.class, GetOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("dir/file")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("dir/file")); assertRequestLineEquals(request, "GET https://accesspoint.atmosonline.com/rest/namespace/dir/file HTTP/1.1"); assertNonPayloadHeadersEqual(request, HttpHeaders.ACCEPT + ": */*\n"); @@ -246,7 +247,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest public void testGetSystemMetadata() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(AtmosAsyncClient.class.getMethod("getSystemMetadata", String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("dir/file")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("dir/file")); assertRequestLineEquals(request, "HEAD https://accesspoint.atmosonline.com/rest/namespace/dir/file HTTP/1.1"); assertNonPayloadHeadersEqual(request, HttpHeaders.ACCEPT + ": */*\n"); @@ -261,7 +262,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest public void testDeletePath() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(AtmosAsyncClient.class.getMethod("deletePath", String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("dir/file")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("dir/file")); assertRequestLineEquals(request, "DELETE https://accesspoint.atmosonline.com/rest/namespace/dir/file HTTP/1.1"); assertNonPayloadHeadersEqual(request, HttpHeaders.ACCEPT + ": */*\n"); @@ -276,7 +277,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest public void testIsPublic() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(AtmosAsyncClient.class.getMethod("isPublic", String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("dir/file")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("dir/file")); assertRequestLineEquals(request, "HEAD https://accesspoint.atmosonline.com/rest/namespace/dir/file HTTP/1.1"); assertNonPayloadHeadersEqual(request, HttpHeaders.ACCEPT + ": */*\n"); diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersAsyncClientTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersAsyncClientTest.java index b5da99a4c4..03356a36bc 100644 --- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersAsyncClientTest.java +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersAsyncClientTest.java @@ -62,13 +62,14 @@ import org.jclouds.openstack.filters.AuthenticateRequest; import org.jclouds.openstack.keystone.v1_1.config.AuthenticationServiceModule.GetAuth; import org.jclouds.openstack.keystone.v1_1.domain.Auth; import org.jclouds.openstack.keystone.v1_1.parse.ParseAuthTest; +import org.jclouds.reflect.Invokable; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.internal.BaseAsyncClientTest; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import com.google.common.reflect.Invokable; import com.google.inject.Module; import com.google.inject.Provides; @@ -85,7 +86,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("createServer", String.class, int.class, int.class, CreateServerOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("ralphie", 2, 1)); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("ralphie", 2, 1)); assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers?format=json HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); @@ -103,7 +104,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("createServer", String.class, int.class, int.class, CreateServerOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("ralphie", 2, 1, withSharedIpGroup(2))); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("ralphie", 2, 1, withSharedIpGroup(2))); assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers?format=json HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); @@ -121,7 +122,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("createServer", String.class, int.class, int.class, CreateServerOptions[].class)); - HttpRequest request = processor + GeneratedHttpRequest request = processor .createRequest(method, ImmutableList. of("ralphie", 2, 1, withFile("/etc/jclouds", "foo".getBytes()))); assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers?format=json HTTP/1.1"); @@ -142,7 +143,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("createServer", String.class, int.class, int.class, CreateServerOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("ralphie", 2, 1, + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("ralphie", 2, 1, withMetadata(ImmutableMap.of("foo", "bar")))); assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers?format=json HTTP/1.1"); @@ -163,7 +164,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("createServer", String.class, int.class, int.class, CreateServerOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("ralphie", 2, 1, + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("ralphie", 2, 1, withSharedIpGroup(2).withSharedIp("127.0.0.1"))); assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers?format=json HTTP/1.1"); @@ -182,7 +183,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("deleteImage", int.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(2)); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2)); assertRequestLineEquals(request, "DELETE https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images/2 HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); @@ -197,7 +198,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("getLimits")); - HttpRequest request = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/limits?format=json HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); @@ -212,7 +213,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("listServers", ListOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers?format=json HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); @@ -229,7 +230,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("listServers", ListOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(changesSince(now).maxResults(1).startAt(2))); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(changesSince(now).maxResults(1).startAt(2))); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers?format=json&changes-since=10000&limit=1&offset=2 HTTP/1.1"); @@ -245,7 +246,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("listServers", ListOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(withDetails())); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(withDetails())); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/detail?format=json HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); @@ -260,7 +261,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("getServer", int.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(2)); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2)); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2?format=json HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); @@ -275,7 +276,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("listFlavors", ListOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/flavors?format=json HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); @@ -290,7 +291,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("listFlavors", ListOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(changesSince(now).maxResults(1).startAt(2))); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(changesSince(now).maxResults(1).startAt(2))); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/flavors?format=json&changes-since=10000&limit=1&offset=2 HTTP/1.1"); @@ -306,7 +307,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("listFlavors", ListOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(withDetails())); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(withDetails())); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/flavors/detail?format=json HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); @@ -321,7 +322,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("listFlavors", ListOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(withDetails().changesSince(now).maxResults(1).startAt(2))); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(withDetails().changesSince(now).maxResults(1).startAt(2))); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/flavors/detail?format=json&changes-since=10000&limit=1&offset=2 HTTP/1.1"); @@ -337,7 +338,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("getFlavor", int.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(2)); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2)); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/flavors/2?format=json HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); @@ -352,7 +353,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("listImages", ListOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images?format=json HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); @@ -367,7 +368,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("listImages", ListOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(withDetails())); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(withDetails())); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images/detail?format=json HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); @@ -382,7 +383,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("listImages", ListOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(changesSince(now).maxResults(1).startAt(2))); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(changesSince(now).maxResults(1).startAt(2))); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images?format=json&changes-since=10000&limit=1&offset=2 HTTP/1.1"); @@ -398,7 +399,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("listImages", ListOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(withDetails().changesSince(now).maxResults(1).startAt(2))); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(withDetails().changesSince(now).maxResults(1).startAt(2))); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images/detail?format=json&changes-since=10000&limit=1&offset=2 HTTP/1.1"); @@ -414,7 +415,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("getImage", int.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(2)); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2)); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images/2?format=json HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); @@ -429,7 +430,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("deleteServer", int.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(2)); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2)); assertRequestLineEquals(request, "DELETE https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2 HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); @@ -445,7 +446,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("shareIp", String.class, int.class, int.class, boolean.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("127.0.0.1", 2, 3, false)); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("127.0.0.1", 2, 3, false)); assertRequestLineEquals(request, "PUT https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/ips/public/127.0.0.1 HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); @@ -463,7 +464,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("shareIp", String.class, int.class, int.class, boolean.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("127.0.0.1", 2, 3, true)); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("127.0.0.1", 2, 3, true)); assertRequestLineEquals(request, "PUT https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/ips/public/127.0.0.1 HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); @@ -481,7 +482,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("unshareIp", String.class, int.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("127.0.0.1", 2, 3, false)); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("127.0.0.1", 2, 3, false)); assertRequestLineEquals(request, "DELETE https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/ips/public/127.0.0.1 HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); @@ -497,7 +498,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("replaceBackupSchedule", int.class, BackupSchedule.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(2, BackupSchedule.builder().weekly(WeeklyBackup.MONDAY) + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2, BackupSchedule.builder().weekly(WeeklyBackup.MONDAY) .daily(DailyBackup.H_0800_1000).enabled(true).build())); assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/backup_schedule HTTP/1.1"); @@ -516,7 +517,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("deleteBackupSchedule", int.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(2)); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2)); assertRequestLineEquals(request, "DELETE https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/backup_schedule HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); @@ -532,7 +533,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("changeAdminPass", int.class, String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(2, "foo")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2, "foo")); assertRequestLineEquals(request, "PUT https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2 HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); @@ -548,7 +549,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("renameServer", int.class, String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(2, "foo")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2, "foo")); assertRequestLineEquals(request, "PUT https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2 HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); @@ -564,7 +565,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("listSharedIpGroups", ListOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/shared_ip_groups?format=json HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); @@ -579,7 +580,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("listSharedIpGroups", ListOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(changesSince(now).maxResults(1).startAt(2))); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(changesSince(now).maxResults(1).startAt(2))); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/shared_ip_groups?format=json&changes-since=10000&limit=1&offset=2 HTTP/1.1"); @@ -595,7 +596,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("listSharedIpGroups", ListOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(withDetails())); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(withDetails())); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/shared_ip_groups/detail?format=json HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); @@ -610,7 +611,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("listSharedIpGroups", ListOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(withDetails().changesSince(now).maxResults(1).startAt(2))); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(withDetails().changesSince(now).maxResults(1).startAt(2))); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/shared_ip_groups/detail?format=json&changes-since=10000&limit=1&offset=2 HTTP/1.1"); @@ -626,7 +627,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("getSharedIpGroup", int.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(2)); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2)); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/shared_ip_groups/2?format=json HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); @@ -642,7 +643,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("createSharedIpGroup", String.class, CreateSharedIpGroupOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("ralphie")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("ralphie")); assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/shared_ip_groups?format=json HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); @@ -659,7 +660,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("createSharedIpGroup", String.class, CreateSharedIpGroupOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("ralphie", withServer(2))); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("ralphie", withServer(2))); assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/shared_ip_groups?format=json HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); @@ -675,7 +676,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("deleteSharedIpGroup", int.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(2)); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2)); assertRequestLineEquals(request, "DELETE https://lon.servers.api.rackspacecloud.com/v1.0/10001786/shared_ip_groups/2 HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); @@ -690,7 +691,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("getAddresses", int.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(2)); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2)); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/ips?format=json HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); @@ -705,7 +706,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("listPublicAddresses", int.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(2)); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2)); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/ips/public?format=json HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); @@ -720,7 +721,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("listPrivateAddresses", int.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(2)); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2)); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/ips/private?format=json HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); @@ -735,7 +736,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("getBackupSchedule", int.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(2)); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2)); assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/backup_schedule?format=json HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); @@ -750,7 +751,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("createImageFromServer", String.class, int.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("ralphie", 2)); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("ralphie", 2)); assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images?format=json HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/json\n"); @@ -768,7 +769,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("rebuildServer", int.class, RebuildServerOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(3)); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(3)); assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/3/action?format=json HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); @@ -784,7 +785,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("rebuildServer", int.class, RebuildServerOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(3, withImage(2))); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(3, withImage(2))); assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/3/action?format=json HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); @@ -799,7 +800,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("rebootServer", int.class, RebootType.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(2, RebootType.HARD)); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2, RebootType.HARD)); assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/action?format=json HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); @@ -814,7 +815,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("resizeServer", int.class, int.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(2, 3)); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2, 3)); assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/action?format=json HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); @@ -830,7 +831,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("confirmResizeServer", int.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(2)); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2)); assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/action?format=json HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); @@ -845,7 +846,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudServersAsyncClient.class.getMethod("revertResizeServer", int.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(2)); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2)); assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/action?format=json HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaClient.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaClient.java index 47d3f72a38..5be68bcd1b 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaClient.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaClient.java @@ -19,6 +19,7 @@ package org.jclouds.cloudsigma; import java.util.Set; + import org.jclouds.cloudsigma.domain.Drive; import org.jclouds.cloudsigma.domain.DriveData; import org.jclouds.cloudsigma.domain.DriveInfo; diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/config/CloudSigmaRestClientModule.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/config/CloudSigmaRestClientModule.java index a8ca588291..7b22cf3f17 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/config/CloudSigmaRestClientModule.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/config/CloudSigmaRestClientModule.java @@ -33,11 +33,11 @@ import org.jclouds.cloudsigma.domain.ServerMetrics; import org.jclouds.cloudsigma.functions.BaseDriveToMap; import org.jclouds.cloudsigma.functions.DriveDataToMap; import org.jclouds.cloudsigma.functions.MapToDevices; +import org.jclouds.cloudsigma.functions.MapToDevices.DeviceToId; import org.jclouds.cloudsigma.functions.MapToDriveMetrics; import org.jclouds.cloudsigma.functions.MapToNICs; import org.jclouds.cloudsigma.functions.MapToServerMetrics; import org.jclouds.cloudsigma.functions.ServerToMap; -import org.jclouds.cloudsigma.functions.MapToDevices.DeviceToId; import org.jclouds.cloudsigma.handlers.CloudSigmaErrorHandler; import org.jclouds.http.HttpErrorHandler; import org.jclouds.http.annotation.ClientError; diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToDevices.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToDevices.java index 4dd8dfba42..bb33990be9 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToDevices.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToDevices.java @@ -31,8 +31,8 @@ import org.jclouds.cloudsigma.domain.SCSIDevice; import com.google.common.base.Function; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Maps; import com.google.common.collect.ImmutableSet.Builder; +import com.google.common.collect.Maps; /** * diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/util/Servers.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/util/Servers.java index 7fec06cf39..9f3cb51427 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/util/Servers.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/util/Servers.java @@ -18,6 +18,7 @@ */ package org.jclouds.cloudsigma.util; +import org.jclouds.cloudsigma.CloudSigmaClient; import org.jclouds.cloudsigma.domain.IDEDevice; import org.jclouds.cloudsigma.domain.Model; import org.jclouds.cloudsigma.domain.NIC; diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaAsyncClientTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaAsyncClientTest.java index d2d0387b3d..b28ddb19e5 100644 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaAsyncClientTest.java +++ b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaAsyncClientTest.java @@ -46,12 +46,13 @@ import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions; import org.jclouds.http.HttpRequest; import org.jclouds.http.filters.BasicAuthentication; import org.jclouds.http.functions.ReleasePayloadAndReturn; +import org.jclouds.reflect.Invokable; import org.jclouds.rest.internal.BaseAsyncClientTest; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code CloudSigmaAsyncClient} @@ -64,7 +65,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("getProfileInfo")); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/profile/info HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); @@ -80,7 +81,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("listStandardDrives")); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/standard/list HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); @@ -95,7 +96,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("listStandardCds")); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/standard/cd/list HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); @@ -110,7 +111,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("listStandardImages")); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/standard/img/list HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); @@ -125,7 +126,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("listDriveInfo")); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/info HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); @@ -140,7 +141,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("getDriveInfo", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/uuid/info HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); @@ -156,7 +157,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("createDrive", Drive.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of( + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of( new CreateDriveRequest.Builder().name("foo").use(ImmutableList.of("production", "candy")).size(10000l) .build())); @@ -175,7 +176,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("cloneDrive", String.class, String.class, CloneDriveOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("sourceid", "newname")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("sourceid", "newname")); assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/drives/sourceid/clone HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); @@ -192,7 +193,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("cloneDrive", String.class, String.class, CloneDriveOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("sourceid", "newname", + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("sourceid", "newname", new CloneDriveOptions().size(1024l))); assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/drives/sourceid/clone HTTP/1.1"); @@ -209,7 +210,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("setDriveData", String.class, DriveData.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("100", new DriveData.Builder().name("foo").size(10000l) + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("100", new DriveData.Builder().name("foo").size(10000l) .use(ImmutableList.of("production", "candy")).build())); assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/drives/100/set HTTP/1.1"); @@ -226,15 +227,15 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("listServers")); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/servers/list HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); assertPayloadEquals(httpRequest, null, null, false); // now make sure request filters apply by replaying - httpRequest = Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest); - httpRequest = Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest); + httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest); + httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest); assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/servers/list HTTP/1.1"); // for example, using basic authentication, we should get "only one" @@ -253,7 +254,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("listServerInfo")); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/servers/info HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); @@ -268,7 +269,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("getServerInfo", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/servers/uuid/info HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); @@ -284,7 +285,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("createServer", Server.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(BindServerToPlainTextStringTest.SERVER)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(BindServerToPlainTextStringTest.SERVER)); assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/servers/create HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); @@ -300,7 +301,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("setServerConfiguration", String.class, Server.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("100", BindServerToPlainTextStringTest.SERVER)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("100", BindServerToPlainTextStringTest.SERVER)); assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/servers/100/set HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); @@ -316,7 +317,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("destroyServer", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/servers/uuid/destroy HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); @@ -332,7 +333,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("startServer", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/servers/uuid/start HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); @@ -348,7 +349,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("stopServer", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/servers/uuid/stop HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); @@ -364,7 +365,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("shutdownServer", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/servers/uuid/shutdown HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); @@ -380,7 +381,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("resetServer", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/servers/uuid/reset HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); @@ -396,15 +397,15 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("listDrives")); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/list HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); assertPayloadEquals(httpRequest, null, null, false); // now make sure request filters apply by replaying - httpRequest = Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest); - httpRequest = Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest); + httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest); + httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest); assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/list HTTP/1.1"); // for example, using basic authentication, we should get "only one" @@ -423,7 +424,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("destroyDrive", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/uuid/destroy HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); @@ -439,15 +440,15 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("listVLANs")); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/vlan/list HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); assertPayloadEquals(httpRequest, null, null, false); // now make sure request filters apply by replaying - httpRequest = Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest); - httpRequest = Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest); + httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest); + httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest); assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/vlan/list HTTP/1.1"); // for example, using basic authentication, we should get "only one" @@ -466,7 +467,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("listVLANInfo")); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/vlan/info HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); @@ -481,7 +482,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("getVLANInfo", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/vlan/uuid/info HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); @@ -497,7 +498,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("createVLAN", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("poohbear")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("poohbear")); assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/resources/vlan/create HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); @@ -513,7 +514,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("renameVLAN", String.class, String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("100", "poohbear")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("100", "poohbear")); assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/resources/vlan/100/set HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); @@ -529,7 +530,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("destroyVLAN", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/vlan/uuid/destroy HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); @@ -545,15 +546,15 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("listStaticIPs")); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/ip/list HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); assertPayloadEquals(httpRequest, null, null, false); // now make sure request filters apply by replaying - httpRequest = Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest); - httpRequest = Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest); + httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest); + httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest); assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/ip/list HTTP/1.1"); // for example, using basic authentication, we should get "only one" @@ -572,7 +573,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("listStaticIPInfo")); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/ip/info HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); @@ -587,7 +588,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("getStaticIPInfo", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/ip/uuid/info HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); @@ -603,7 +604,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("createStaticIP")); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/resources/ip/create HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); @@ -619,7 +620,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(CloudSigmaAsyncClient.class.getMethod("destroyStaticIP", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/ip/uuid/destroy HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/binders/BindCloneDriveOptionsToPlainTextStringTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/binders/BindCloneDriveOptionsToPlainTextStringTest.java index d661c78db9..2cf9eec8d3 100644 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/binders/BindCloneDriveOptionsToPlainTextStringTest.java +++ b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/binders/BindCloneDriveOptionsToPlainTextStringTest.java @@ -27,13 +27,13 @@ import java.util.Map; import org.jclouds.cloudsigma.options.CloneDriveOptions; import org.jclouds.reflect.Invocation; +import org.jclouds.reflect.Invokable; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.base.Throwables; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import com.google.common.reflect.Invokable; import com.google.inject.Guice; /** diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/AccountAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/AccountAsyncClientTest.java index cb27b3ed97..f4745d51a9 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/AccountAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/AccountAsyncClientTest.java @@ -25,13 +25,13 @@ import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest; import org.jclouds.cloudstack.options.ListAccountsOptions; import org.jclouds.functions.IdentityFunction; -import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseFirstJsonValueNamed; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.base.Functions; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code AccountAsyncClient} @@ -45,7 +45,7 @@ public class AccountAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(AccountAsyncClient.class.getMethod("listAccounts", ListAccountsOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listAccounts&listAll=true HTTP/1.1"); @@ -62,7 +62,7 @@ public class AccountAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(AccountAsyncClient.class.getMethod("listAccounts", ListAccountsOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of( + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of( ListAccountsOptions.Builder.accountInDomain("jclouds", "123"))); assertRequestLineEquals(httpRequest, @@ -80,7 +80,7 @@ public class AccountAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(AccountAsyncClient.class.getMethod("getAccount", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("3")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("3")); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listAccounts&listAll=true&id=3 HTTP/1.1"); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/AddressAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/AddressAsyncClientTest.java index 9d873adaac..faa19dcbc4 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/AddressAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/AddressAsyncClientTest.java @@ -28,15 +28,15 @@ import org.jclouds.cloudstack.options.AssociateIPAddressOptions; import org.jclouds.cloudstack.options.ListPublicIPAddressesOptions; import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions; import org.jclouds.functions.IdentityFunction; -import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseFirstJsonValueNamed; import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.http.functions.UnwrapOnlyJsonValue; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.base.Functions; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code AddressAsyncClient} @@ -49,7 +49,7 @@ import com.google.common.reflect.Invokable; public class AddressAsyncClientTest extends BaseCloudStackAsyncClientTest { public void testListPublicIPAddresses() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(AddressAsyncClient.class.getMethod("listPublicIPAddresses", ListPublicIPAddressesOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listPublicIpAddresses&listAll=true HTTP/1.1"); @@ -66,7 +66,7 @@ public class AddressAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(AddressAsyncClient.class.getMethod("listPublicIPAddresses", ListPublicIPAddressesOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of( + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of( ListPublicIPAddressesOptions.Builder.accountInDomain("adrian", "6").usesVirtualNetwork(true))); assertRequestLineEquals( @@ -85,7 +85,7 @@ public class AddressAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(AddressAsyncClient.class.getMethod("getPublicIPAddress", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listPublicIpAddresses&listAll=true&id=5 HTTP/1.1"); @@ -104,7 +104,7 @@ public class AddressAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(AddressAsyncClient.class.getMethod("associateIPAddressInZone", String.class, AssociateIPAddressOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(6)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(6)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=associateIpAddress&zoneid=6 HTTP/1.1"); @@ -121,7 +121,7 @@ public class AddressAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(AddressAsyncClient.class.getMethod("disassociateIPAddress", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=disassociateIpAddress&id=5 HTTP/1.1"); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/AsyncJobAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/AsyncJobAsyncClientTest.java index 635a1d9ce6..04d32a8b54 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/AsyncJobAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/AsyncJobAsyncClientTest.java @@ -26,11 +26,11 @@ import org.jclouds.cloudstack.functions.ParseAsyncJobFromHttpResponse; import org.jclouds.cloudstack.functions.ParseAsyncJobsFromHttpResponse; import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest; import org.jclouds.cloudstack.options.ListAsyncJobsOptions; -import org.jclouds.http.HttpRequest; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code AsyncJobAsyncClient} @@ -44,7 +44,7 @@ public class AsyncJobAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(AsyncJobAsyncClient.class.getMethod("getAsyncJob", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(11l)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(11l)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=queryAsyncJobResult&jobid=11 HTTP/1.1"); @@ -61,7 +61,7 @@ public class AsyncJobAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(AsyncJobAsyncClient.class.getMethod("listAsyncJobs", ListAsyncJobsOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listAsyncJobs&listAll=true HTTP/1.1"); @@ -78,7 +78,7 @@ public class AsyncJobAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(AsyncJobAsyncClient.class.getMethod("listAsyncJobs", ListAsyncJobsOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of( + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of( ListAsyncJobsOptions.Builder.accountInDomain("adrian", "5"))); assertRequestLineEquals(httpRequest, diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/ConfigurationAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/ConfigurationAsyncClientTest.java index a9bbc1b4a4..2b99018274 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/ConfigurationAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/ConfigurationAsyncClientTest.java @@ -22,12 +22,12 @@ import java.io.IOException; import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest; import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions; -import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseFirstJsonValueNamed; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code ConfigurationAsyncClient} @@ -41,7 +41,7 @@ public class ConfigurationAsyncClientTest extends BaseCloudStackAsyncClientTest< public void testListCapabilities() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(ConfigurationAsyncClient.class.getMethod("listCapabilities")); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&listAll=true&command=listCapabilities HTTP/1.1"); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/DomainAccountAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/DomainAccountAsyncClientTest.java index 0bc6a99826..19f6647cf4 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/DomainAccountAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/DomainAccountAsyncClientTest.java @@ -20,13 +20,13 @@ package org.jclouds.cloudstack.features; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest; -import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseFirstJsonValueNamed; import org.jclouds.http.functions.UnwrapOnlyJsonValue; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code DomainAccountAsyncClient} @@ -38,7 +38,7 @@ public class DomainAccountAsyncClientTest extends BaseCloudStackAsyncClientTest< public void testEnableAccount() throws Exception { Invokable method = Invokable.from(DomainAccountAsyncClient.class.getMethod("enableAccount", String.class, String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("goo", "2")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("goo", "2")); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=enableAccount&account=goo&domainid=2 HTTP/1.1"); @@ -54,7 +54,7 @@ public class DomainAccountAsyncClientTest extends BaseCloudStackAsyncClientTest< public void testDisableAccount() throws Exception { Invokable method = Invokable.from(DomainAccountAsyncClient.class.getMethod("disableAccount", String.class, String.class, boolean.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("1", "2", true)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("1", "2", true)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=disableAccount&account=1&domainid=2&lock=true HTTP/1.1"); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/DomainLimitAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/DomainLimitAsyncClientTest.java index ab40a533d1..5eede90ed4 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/DomainLimitAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/DomainLimitAsyncClientTest.java @@ -24,12 +24,12 @@ import org.jclouds.cloudstack.domain.ResourceLimit; import org.jclouds.cloudstack.domain.ResourceLimit.ResourceType; import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest; import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions; -import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseFirstJsonValueNamed; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code DomainLimitAsyncClient} @@ -41,7 +41,7 @@ public class DomainLimitAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(DomainLimitAsyncClient.class.getMethod("updateResourceLimit", ResourceLimit.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of( + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of( ResourceLimit.builder().resourceType(ResourceType.SNAPSHOT).account("foo").domainId("100").max(101).build())); assertRequestLineEquals( diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/EventAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/EventAsyncClientTest.java index e6d6cd076b..fe7499faca 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/EventAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/EventAsyncClientTest.java @@ -24,12 +24,12 @@ import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; import org.jclouds.cloudstack.functions.ParseEventTypesFromHttpResponse; import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest; import org.jclouds.cloudstack.options.ListEventsOptions; -import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseFirstJsonValueNamed; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code EventAsyncClient} @@ -43,7 +43,7 @@ public class EventAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(EventAsyncClient.class.getMethod("listEventTypes")); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&listAll=true&command=listEventTypes HTTP/1.1"); @@ -59,7 +59,7 @@ public class EventAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(EventAsyncClient.class.getMethod("listEvents", ListEventsOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&listAll=true&command=listEvents HTTP/1.1"); @@ -76,7 +76,7 @@ public class EventAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(EventAsyncClient.class.getMethod("listEvents", ListEventsOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ListEventsOptions.Builder.account("jclouds"))); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ListEventsOptions.Builder.account("jclouds"))); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&listAll=true&command=listEvents&account=jclouds HTTP/1.1"); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/FirewallAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/FirewallAsyncClientTest.java index c8c50cfc34..d9c00e4707 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/FirewallAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/FirewallAsyncClientTest.java @@ -26,14 +26,14 @@ import org.jclouds.cloudstack.domain.PortForwardingRule; import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest; import org.jclouds.cloudstack.options.ListPortForwardingRulesOptions; import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions; -import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseFirstJsonValueNamed; import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.http.functions.UnwrapOnlyJsonValue; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code FirewallAsyncClient} @@ -47,7 +47,7 @@ public class FirewallAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(FirewallAsyncClient.class.getMethod("listPortForwardingRules", ListPortForwardingRulesOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listPortForwardingRules&listAll=true HTTP/1.1"); @@ -65,7 +65,7 @@ public class FirewallAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(FirewallAsyncClient.class.getMethod("listPortForwardingRules", ListPortForwardingRulesOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ListPortForwardingRulesOptions.Builder.ipAddressId("3"))); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ListPortForwardingRulesOptions.Builder.ipAddressId("3"))); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listPortForwardingRules&listAll=true&ipaddressid=3 HTTP/1.1"); @@ -84,7 +84,7 @@ public class FirewallAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(FirewallAsyncClient.class.getMethod("createPortForwardingRuleForVirtualMachine", String.class, PortForwardingRule.Protocol.class, int.class, String.class, int.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("6", PortForwardingRule.Protocol.TCP, 22, "7", 22)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("6", PortForwardingRule.Protocol.TCP, 22, "7", 22)); assertRequestLineEquals( httpRequest, @@ -102,7 +102,7 @@ public class FirewallAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(FirewallAsyncClient.class.getMethod("deletePortForwardingRule", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=deletePortForwardingRule&id=5 HTTP/1.1"); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalAccountAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalAccountAsyncClientTest.java index 849dfe8b55..d1f499b6f7 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalAccountAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalAccountAsyncClientTest.java @@ -26,10 +26,11 @@ import org.jclouds.cloudstack.options.UpdateAccountOptions; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseFirstJsonValueNamed; import org.jclouds.http.functions.ReleasePayloadAndReturn; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code GlobalAccountAsyncClient} @@ -54,7 +55,7 @@ public class GlobalAccountAsyncClientTest extends BaseCloudStackAsyncClientTest< public void testCreateAccount() throws Exception { Invokable method = Invokable.from(GlobalAccountAsyncClient.class.getMethod("createAccount", String.class, Account.Type.class, String.class, String.class, String.class, String.class, CreateAccountOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("user", Account.Type.USER, "email@example.com", + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("user", Account.Type.USER, "email@example.com", "FirstName", "LastName", "hashed-password")); assertRequestLineEquals(httpRequest, create.getRequestLine()); @@ -80,7 +81,7 @@ public class GlobalAccountAsyncClientTest extends BaseCloudStackAsyncClientTest< public void testUpdateAccount() throws Exception { Invokable method = Invokable.from(GlobalAccountAsyncClient.class.getMethod("updateAccount", String.class, String.class, String.class, UpdateAccountOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("account", 42L, "new-account-name")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("account", 42L, "new-account-name")); assertRequestLineEquals(httpRequest, update.getRequestLine()); assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); @@ -95,7 +96,7 @@ public class GlobalAccountAsyncClientTest extends BaseCloudStackAsyncClientTest< public void testDeleteAccount() throws Exception { Invokable method = Invokable.from(GlobalAccountAsyncClient.class.getMethod("deleteAccount", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(42L)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(42L)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=deleteAccount&id=42 HTTP/1.1"); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalAlertAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalAlertAsyncClientTest.java index 1f910a4272..854b2be078 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalAlertAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalAlertAsyncClientTest.java @@ -23,12 +23,12 @@ import java.io.IOException; import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest; import org.jclouds.cloudstack.options.ListAlertsOptions; -import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseFirstJsonValueNamed; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code GlobalAlertsAsyncClient} @@ -42,7 +42,7 @@ public class GlobalAlertAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(GlobalAlertAsyncClient.class.getMethod("listAlerts", ListAlertsOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listAlerts&listAll=true HTTP/1.1"); @@ -59,7 +59,7 @@ public class GlobalAlertAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(GlobalAlertAsyncClient.class.getMethod("listAlerts", ListAlertsOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ListAlertsOptions.Builder.id("42").keyword("jclouds").type("TEMPLATE"))); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ListAlertsOptions.Builder.id("42").keyword("jclouds").type("TEMPLATE"))); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listAlerts&listAll=true&id=42&keyword=jclouds&type=TEMPLATE HTTP/1.1"); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalCapacityAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalCapacityAsyncClientTest.java index 51c412a04d..3cda712a29 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalCapacityAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalCapacityAsyncClientTest.java @@ -24,12 +24,12 @@ import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; import org.jclouds.cloudstack.domain.Capacity; import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest; import org.jclouds.cloudstack.options.ListCapacityOptions; -import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseFirstJsonValueNamed; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code GlobalCapacityAsyncClient} @@ -43,7 +43,7 @@ public class GlobalCapacityAsyncClientTest extends BaseCloudStackAsyncClientTest public void testListCapacity() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(GlobalCapacityAsyncClient.class.getMethod("listCapacity", ListCapacityOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listCapacity&listAll=true HTTP/1.1"); @@ -59,7 +59,7 @@ public class GlobalCapacityAsyncClientTest extends BaseCloudStackAsyncClientTest public void testListCapacityOptions() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(GlobalCapacityAsyncClient.class.getMethod("listCapacity", ListCapacityOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ListCapacityOptions.Builder.hostId("3").keyword("fred").podId("4").type(Capacity.Type.CPU_ALLOCATED_MHZ).zoneId("6"))); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ListCapacityOptions.Builder.hostId("3").keyword("fred").podId("4").type(Capacity.Type.CPU_ALLOCATED_MHZ).zoneId("6"))); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listCapacity&listAll=true&hostid=3&keyword=fred&podid=4&type=1&zoneid=6 HTTP/1.1"); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalHostAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalHostAsyncClientTest.java index 647c3e22a9..9edf2980e7 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalHostAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalHostAsyncClientTest.java @@ -21,12 +21,12 @@ package org.jclouds.cloudstack.features; import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest; import org.jclouds.cloudstack.options.ListHostsOptions; -import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseFirstJsonValueNamed; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code GlobalHostAsyncClient} @@ -38,7 +38,7 @@ public class GlobalHostAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(GlobalHostAsyncClient.class.getMethod("listHosts", ListHostsOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listHosts&listAll=true HTTP/1.1"); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalOfferingAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalOfferingAsyncClientTest.java index d986ab3fb0..5bfceb2216 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalOfferingAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalOfferingAsyncClientTest.java @@ -28,10 +28,11 @@ import org.jclouds.cloudstack.options.UpdateServiceOfferingOptions; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseFirstJsonValueNamed; import org.jclouds.http.functions.ReleasePayloadAndReturn; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code GlobalOfferingAsyncClient} @@ -54,7 +55,7 @@ public class GlobalOfferingAsyncClientTest extends BaseCloudStackAsyncClientTest public void testCreateServiceOffering() throws Exception { Invokable method = Invokable.from(GlobalOfferingAsyncClient.class.getMethod("createServiceOffering", String.class, String.class, int.class, int.class, int.class, CreateServiceOfferingOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("name", "displayText", 1, 2, 3)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("name", "displayText", 1, 2, 3)); assertRequestLineEquals(httpRequest, createServiceOffering.getRequestLine()); assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); @@ -70,7 +71,7 @@ public class GlobalOfferingAsyncClientTest extends BaseCloudStackAsyncClientTest public void testUpdateServiceOffering() throws Exception { Invokable method = Invokable.from(GlobalOfferingAsyncClient.class.getMethod("updateServiceOffering", String.class, UpdateServiceOfferingOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1L)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1L)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=updateServiceOffering&id=1 HTTP/1.1"); @@ -86,7 +87,7 @@ public class GlobalOfferingAsyncClientTest extends BaseCloudStackAsyncClientTest public void testDeleteServiceOffering() throws Exception { Invokable method = Invokable.from(GlobalOfferingAsyncClient.class.getMethod("deleteServiceOffering", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1L)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1L)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=deleteServiceOffering&id=1 HTTP/1.1"); @@ -103,7 +104,7 @@ public class GlobalOfferingAsyncClientTest extends BaseCloudStackAsyncClientTest public void testCreateDiskOffering() throws Exception { Invokable method = Invokable.from(GlobalOfferingAsyncClient.class.getMethod("createDiskOffering", String.class, String.class, CreateDiskOfferingOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("name", "displayText")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("name", "displayText")); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=createDiskOffering&name=name&displaytext=displayText HTTP/1.1"); @@ -120,7 +121,7 @@ public class GlobalOfferingAsyncClientTest extends BaseCloudStackAsyncClientTest public void testUpdateDiskOffering() throws Exception { Invokable method = Invokable.from(GlobalOfferingAsyncClient.class.getMethod("updateDiskOffering", String.class, UpdateDiskOfferingOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1L)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1L)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=updateDiskOffering&id=1 HTTP/1.1"); @@ -136,7 +137,7 @@ public class GlobalOfferingAsyncClientTest extends BaseCloudStackAsyncClientTest public void testDeleteDiskOffering() throws Exception { Invokable method = Invokable.from(GlobalOfferingAsyncClient.class.getMethod("deleteDiskOffering", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1L)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1L)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=deleteDiskOffering&id=1 HTTP/1.1"); @@ -153,7 +154,7 @@ public class GlobalOfferingAsyncClientTest extends BaseCloudStackAsyncClientTest public void testUpdateNetworkOffering() throws Exception { Invokable method = Invokable.from(GlobalOfferingAsyncClient.class.getMethod("updateNetworkOffering", String.class, UpdateNetworkOfferingOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1L)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1L)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=updateNetworkOffering&id=1 HTTP/1.1"); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalStoragePoolAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalStoragePoolAsyncClientTest.java index bba4286845..47d9f696f0 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalStoragePoolAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalStoragePoolAsyncClientTest.java @@ -21,12 +21,12 @@ package org.jclouds.cloudstack.features; import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest; import org.jclouds.cloudstack.options.ListStoragePoolsOptions; import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions; -import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseFirstJsonValueNamed; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code GlobalStoragePoolAsyncClient} @@ -38,7 +38,7 @@ public class GlobalStoragePoolAsyncClientTest extends BaseCloudStackAsyncClientT public void testListStoragePools() throws NoSuchMethodException { Invokable method = Invokable.from(GlobalStoragePoolAsyncClient.class.getMethod("listStoragePools", ListStoragePoolsOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listStoragePools&listAll=true HTTP/1.1"); @@ -54,7 +54,7 @@ public class GlobalStoragePoolAsyncClientTest extends BaseCloudStackAsyncClientT public void testListStoragePoolsOptions() throws NoSuchMethodException { Invokable method = Invokable.from(GlobalStoragePoolAsyncClient.class.getMethod("listStoragePools", ListStoragePoolsOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ListStoragePoolsOptions.Builder.clusterId("3").id("4").ipAddress("192.168.42.42").keyword("fred").name("bob").path("/mnt/store42").podId("4").zoneId("5"))); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ListStoragePoolsOptions.Builder.clusterId("3").id("4").ipAddress("192.168.42.42").keyword("fred").name("bob").path("/mnt/store42").podId("4").zoneId("5"))); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listStoragePools&listAll=true&clusterid=3&id=4&ipaddress=192.168.42.42&keyword=fred&name=bob&path=/mnt/store42&podid=4&zoneid=5 HTTP/1.1"); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalUsageAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalUsageAsyncClientTest.java index b193272fe1..a731be6338 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalUsageAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalUsageAsyncClientTest.java @@ -25,12 +25,12 @@ import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest; import org.jclouds.cloudstack.options.GenerateUsageRecordsOptions; import org.jclouds.cloudstack.options.ListUsageRecordsOptions; import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions; -import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseFirstJsonValueNamed; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code GlobalUsageAsyncClient} @@ -51,7 +51,7 @@ public class GlobalUsageAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(GlobalUsageAsyncClient.class.getMethod("generateUsageRecords", Date.class, Date.class, GenerateUsageRecordsOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(start, end)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(start, end)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=generateUsageRecords&startdate=2012-01-01&enddate=2012-01-31 HTTP/1.1"); @@ -76,7 +76,7 @@ public class GlobalUsageAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(GlobalUsageAsyncClient.class.getMethod("generateUsageRecords", Date.class, Date.class, GenerateUsageRecordsOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(start, end, GenerateUsageRecordsOptions.Builder.domainId("42"))); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(start, end, GenerateUsageRecordsOptions.Builder.domainId("42"))); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=generateUsageRecords&startdate=2012-01-01&enddate=2012-01-31&domainid=42 HTTP/1.1"); @@ -101,7 +101,7 @@ public class GlobalUsageAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(GlobalUsageAsyncClient.class.getMethod("listUsageRecords", Date.class, Date.class, ListUsageRecordsOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(start, end)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(start, end)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listUsageRecords&listAll=true&startdate=2012-01-01&enddate=2012-01-31 HTTP/1.1"); @@ -126,7 +126,7 @@ public class GlobalUsageAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(GlobalUsageAsyncClient.class.getMethod("listUsageRecords", Date.class, Date.class, ListUsageRecordsOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(start, end, ListUsageRecordsOptions.Builder.accountInDomain("fred", "42").accountId("41").keyword("bob"))); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(start, end, ListUsageRecordsOptions.Builder.accountInDomain("fred", "42").accountId("41").keyword("bob"))); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listUsageRecords&listAll=true&startdate=2012-01-01&enddate=2012-01-31&account=fred&domainid=42&accountid=41&keyword=bob HTTP/1.1"); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalUserAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalUserAsyncClientTest.java index a91d8418cf..18e3b0e728 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalUserAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalUserAsyncClientTest.java @@ -25,10 +25,11 @@ import org.jclouds.cloudstack.options.UpdateUserOptions; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseFirstJsonValueNamed; import org.jclouds.http.functions.ReleasePayloadAndReturn; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code GlobalUserAsyncClient} @@ -50,7 +51,7 @@ public class GlobalUserAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(GlobalUserAsyncClient.class.getMethod("createUser", String.class, String.class, String.class, String.class, String.class, String.class, CreateUserOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("user", "account", "email@example.com", + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("user", "account", "email@example.com", "hashed-password", "FirstName", "LastName")); assertRequestLineEquals(httpRequest, createUser.getRequestLine()); @@ -66,7 +67,7 @@ public class GlobalUserAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(GlobalUserAsyncClient.class.getMethod("updateUser", String.class, UpdateUserOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(42L)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(42L)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=updateUser&id=42 HTTP/1.1"); @@ -82,7 +83,7 @@ public class GlobalUserAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(GlobalUserAsyncClient.class.getMethod("deleteUser", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(42L)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(42L)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=deleteUser&id=42 HTTP/1.1"); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GuestOSAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GuestOSAsyncClientTest.java index f9b0c6450e..dee8be6c21 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GuestOSAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GuestOSAsyncClientTest.java @@ -27,13 +27,13 @@ import org.jclouds.cloudstack.functions.ParseIdToNameFromHttpResponse; import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest; import org.jclouds.cloudstack.options.ListOSTypesOptions; import org.jclouds.functions.IdentityFunction; -import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseFirstJsonValueNamed; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.base.Functions; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code GuestOSAsyncClient} @@ -47,7 +47,7 @@ public class GuestOSAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(GuestOSAsyncClient.class.getMethod("getOSCategory", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(11l)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(11l)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listOsCategories&listAll=true&id=11 HTTP/1.1"); @@ -64,7 +64,7 @@ public class GuestOSAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(GuestOSAsyncClient.class.getMethod("listOSCategories")); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listOsCategories&listAll=true HTTP/1.1"); @@ -81,7 +81,7 @@ public class GuestOSAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(GuestOSAsyncClient.class.getMethod("getOSType", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(11l)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(11l)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listOsTypes&listAll=true&id=11 HTTP/1.1"); @@ -99,7 +99,7 @@ public class GuestOSAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(GuestOSAsyncClient.class.getMethod("listOSTypes", ListOSTypesOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listOsTypes&listAll=true HTTP/1.1"); @@ -116,7 +116,7 @@ public class GuestOSAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(GuestOSAsyncClient.class.getMethod("listOSTypes", ListOSTypesOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ListOSTypesOptions.Builder.OSCategoryId("11"))); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ListOSTypesOptions.Builder.OSCategoryId("11"))); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listOsTypes&listAll=true&oscategoryid=11 HTTP/1.1"); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/HypervisorAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/HypervisorAsyncClientTest.java index 89164a686a..2135a0b12b 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/HypervisorAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/HypervisorAsyncClientTest.java @@ -23,11 +23,11 @@ import java.io.IOException; import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; import org.jclouds.cloudstack.functions.ParseNamesFromHttpResponse; import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest; -import org.jclouds.http.HttpRequest; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code HypervisorAsyncClient} @@ -41,7 +41,7 @@ public class HypervisorAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(HypervisorAsyncClient.class.getMethod("listHypervisors")); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listHypervisors&listAll=true HTTP/1.1"); @@ -58,7 +58,7 @@ public class HypervisorAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(HypervisorAsyncClient.class.getMethod("listHypervisorsInZone", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(11)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(11)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listHypervisors&listAll=true&zoneid=11 HTTP/1.1"); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/ISOAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/ISOAsyncClientTest.java index 55d8314e2f..c0fc96a049 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/ISOAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/ISOAsyncClientTest.java @@ -31,11 +31,12 @@ import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseFirstJsonValueNamed; import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.http.functions.UnwrapOnlyJsonValue; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; -import com.google.common.reflect.Invokable; /** * Tests the behaviour of ISOAsyncClient. * @@ -48,7 +49,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(ISOAsyncClient.class.getMethod("attachISO", String.class, String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("3", "5")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("3", "5")); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=attachIso&id=3&virtualmachineid=5 HTTP/1.1"); @@ -64,7 +65,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(ISOAsyncClient.class.getMethod("detachISO", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(3)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(3)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=detachIso&virtualmachineid=3 HTTP/1.1"); @@ -80,7 +81,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(ISOAsyncClient.class.getMethod("updateISO", String.class, UpdateISOOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(3)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(3)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=updateIso&id=3 HTTP/1.1"); @@ -96,7 +97,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(ISOAsyncClient.class.getMethod("updateISO", String.class, UpdateISOOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(3, UpdateISOOptions.Builder.bootable(true).displayText("robert").format("format").name("bob").osTypeId("9").passwordEnabled(true))); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(3, UpdateISOOptions.Builder.bootable(true).displayText("robert").format("format").name("bob").osTypeId("9").passwordEnabled(true))); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=updateIso&id=3&bootable=true&displaytext=robert&format=format&name=bob&ostypeid=9&passwordenabled=true HTTP/1.1"); @@ -112,7 +113,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(ISOAsyncClient.class.getMethod("deleteISO", String.class, DeleteISOOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(3)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(3)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=deleteIso&id=3 HTTP/1.1"); @@ -128,7 +129,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(ISOAsyncClient.class.getMethod("deleteISO", String.class, DeleteISOOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(3, DeleteISOOptions.Builder.zoneId("5"))); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(3, DeleteISOOptions.Builder.zoneId("5"))); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=deleteIso&id=3&zoneid=5 HTTP/1.1"); @@ -153,7 +154,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(ISOAsyncClient.class.getMethod("copyISO", String.class, String.class, String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(3, 5, 7)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(3, 5, 7)); assertRequestLineEquals(httpRequest, copyIso.getRequestLine()); assertPayloadEquals(httpRequest, null, null, false); @@ -167,7 +168,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(ISOAsyncClient.class.getMethod("updateISOPermissions", String.class, UpdateISOPermissionsOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(3)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(3)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=updateIsoPermissions&id=3 HTTP/1.1"); @@ -183,7 +184,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(ISOAsyncClient.class.getMethod("updateISOPermissions", String.class, UpdateISOPermissionsOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(3, UpdateISOPermissionsOptions.Builder.accounts(ImmutableSet.of("fred", "bob")).isExtractable(true).isFeatured(true).isPublic(true).operation(PermissionOperation.add))); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(3, UpdateISOPermissionsOptions.Builder.accounts(ImmutableSet.of("fred", "bob")).isExtractable(true).isFeatured(true).isPublic(true).operation(PermissionOperation.add))); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=updateIsoPermissions&id=3&accounts=fred,bob&isextractable=true&isfeatured=true&ispublic=true&op=add HTTP/1.1"); @@ -199,7 +200,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(ISOAsyncClient.class.getMethod("listISOPermissions", String.class, AccountInDomainOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(3)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(3)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listIsoPermissions&listAll=true&id=3 HTTP/1.1"); @@ -215,7 +216,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(ISOAsyncClient.class.getMethod("listISOPermissions", String.class, AccountInDomainOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(3, AccountInDomainOptions.Builder.accountInDomain("fred", "5"))); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(3, AccountInDomainOptions.Builder.accountInDomain("fred", "5"))); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listIsoPermissions&listAll=true&id=3&account=fred&domainid=5 HTTP/1.1"); @@ -240,7 +241,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(ISOAsyncClient.class.getMethod("extractISO", String.class, ExtractMode.class, String.class, ExtractISOOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(3, ExtractMode.HTTP_DOWNLOAD, 5)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(3, ExtractMode.HTTP_DOWNLOAD, 5)); assertRequestLineEquals(httpRequest, extractIso.getRequestLine()); assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); @@ -265,7 +266,7 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(ISOAsyncClient.class.getMethod("extractISO", String.class, ExtractMode.class, String.class, ExtractISOOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(3, ExtractMode.HTTP_DOWNLOAD, 5, ExtractISOOptions.Builder.url("http://example.com/"))); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(3, ExtractMode.HTTP_DOWNLOAD, 5, ExtractISOOptions.Builder.url("http://example.com/"))); assertRequestLineEquals(httpRequest, extractIsoOptions.getRequestLine()); assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/LimitAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/LimitAsyncClientTest.java index 50887e119f..dfb3249f6f 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/LimitAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/LimitAsyncClientTest.java @@ -23,12 +23,12 @@ import java.io.IOException; import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest; import org.jclouds.cloudstack.options.ListResourceLimitsOptions; -import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseFirstJsonValueNamed; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code LimitAsyncClient} @@ -40,7 +40,7 @@ public class LimitAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(LimitAsyncClient.class.getMethod("listResourceLimits", ListResourceLimitsOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listResourceLimits&listAll=true HTTP/1.1"); @@ -57,7 +57,7 @@ public class LimitAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(LimitAsyncClient.class.getMethod("listResourceLimits", ListResourceLimitsOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ListResourceLimitsOptions.Builder.account("jclouds" , "23"))); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ListResourceLimitsOptions.Builder.account("jclouds" , "23"))); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listResourceLimits&listAll=true&account=jclouds&domainid=23 HTTP/1.1"); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/LoadBalancerAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/LoadBalancerAsyncClientTest.java index d236541004..850a8b3114 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/LoadBalancerAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/LoadBalancerAsyncClientTest.java @@ -30,10 +30,11 @@ import org.jclouds.cloudstack.options.UpdateLoadBalancerRuleOptions; import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseFirstJsonValueNamed; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code LoadBalancerAsyncClient} @@ -47,7 +48,7 @@ public class LoadBalancerAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(LoadBalancerAsyncClient.class.getMethod("listLoadBalancerRules", ListLoadBalancerRulesOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listLoadBalancerRules&listAll=true HTTP/1.1"); @@ -65,7 +66,7 @@ public class LoadBalancerAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(LoadBalancerAsyncClient.class.getMethod("listLoadBalancerRules", ListLoadBalancerRulesOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ListLoadBalancerRulesOptions.Builder.publicIPId("3"))); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ListLoadBalancerRulesOptions.Builder.publicIPId("3"))); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listLoadBalancerRules&listAll=true&publicipid=3 HTTP/1.1"); @@ -93,7 +94,7 @@ public class LoadBalancerAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(LoadBalancerAsyncClient.class.getMethod("createLoadBalancerRuleForPublicIP", String.class, Algorithm.class, String.class, int.class, int.class, CreateLoadBalancerRuleOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(6, Algorithm.LEASTCONN, "tcp", 22, 22)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(6, Algorithm.LEASTCONN, "tcp", 22, 22)); assertRequestLineEquals(httpRequest, createLoadBalancerRule.getRequestLine()); assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); @@ -109,7 +110,7 @@ public class LoadBalancerAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(LoadBalancerAsyncClient.class.getMethod("updateLoadBalancerRule", String.class, UpdateLoadBalancerRuleOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=updateLoadBalancerRule&id=5 HTTP/1.1"); @@ -125,7 +126,7 @@ public class LoadBalancerAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(LoadBalancerAsyncClient.class.getMethod("deleteLoadBalancerRule", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=deleteLoadBalancerRule&id=5 HTTP/1.1"); @@ -144,7 +145,7 @@ public class LoadBalancerAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(LoadBalancerAsyncClient.class.getMethod("listVirtualMachinesAssignedToLoadBalancerRule", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listLoadBalancerRuleInstances&listAll=true&id=5 HTTP/1.1"); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/NATAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/NATAsyncClientTest.java index 7306aee232..a8609bd1aa 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/NATAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/NATAsyncClientTest.java @@ -30,10 +30,11 @@ import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseFirstJsonValueNamed; import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.http.functions.UnwrapOnlyJsonValue; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code NATAsyncClient} @@ -46,7 +47,7 @@ import com.google.common.reflect.Invokable; public class NATAsyncClientTest extends BaseCloudStackAsyncClientTest { public void testListIPForwardingRules() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(NATAsyncClient.class.getMethod("listIPForwardingRules", ListIPForwardingRulesOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listIpForwardingRules&listAll=true HTTP/1.1"); @@ -63,7 +64,7 @@ public class NATAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(NATAsyncClient.class.getMethod("listIPForwardingRules", ListIPForwardingRulesOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of( + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of( ListIPForwardingRulesOptions.Builder.virtualMachineId("3"))); assertRequestLineEquals(httpRequest, @@ -81,7 +82,7 @@ public class NATAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(NATAsyncClient.class.getMethod("getIPForwardingRule", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listIpForwardingRules&listAll=true&id=5 HTTP/1.1"); @@ -107,7 +108,7 @@ public class NATAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(NATAsyncClient.class.getMethod("createIPForwardingRule", String.class, String.class, int.class, CreateIPForwardingRuleOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(7, "tcp", 22)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(7, "tcp", 22)); assertRequestLineEquals(httpRequest, createIpForwardingRule.getRequestLine()); assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); @@ -134,7 +135,7 @@ public class NATAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(NATAsyncClient.class.getMethod("createIPForwardingRule", String.class, String.class, int.class, CreateIPForwardingRuleOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(7, "tcp", 22, + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(7, "tcp", 22, CreateIPForwardingRuleOptions.Builder.endPort(22))); assertRequestLineEquals(httpRequest, createIpForwardingRuleOptions.getRequestLine()); @@ -151,7 +152,7 @@ public class NATAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(NATAsyncClient.class.getMethod("enableStaticNATForVirtualMachine", String.class, String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5, 6)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5, 6)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=enableStaticNat&virtualmachineid=5&ipaddressid=6 HTTP/1.1"); @@ -168,7 +169,7 @@ public class NATAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(NATAsyncClient.class.getMethod("disableStaticNATOnPublicIP", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=disableStaticNat&ipaddressid=5 HTTP/1.1"); @@ -185,7 +186,7 @@ public class NATAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(NATAsyncClient.class.getMethod("deleteIPForwardingRule", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=deleteIpForwardingRule&id=5 HTTP/1.1"); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/NetworkAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/NetworkAsyncClientTest.java index ef480f3182..0bb6ed1725 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/NetworkAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/NetworkAsyncClientTest.java @@ -30,11 +30,12 @@ import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions; import org.jclouds.functions.IdentityFunction; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseFirstJsonValueNamed; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.base.Functions; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code NetworkAsyncClient} @@ -47,7 +48,7 @@ import com.google.common.reflect.Invokable; public class NetworkAsyncClientTest extends BaseCloudStackAsyncClientTest { public void testListNetworks() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(NetworkAsyncClient.class.getMethod("listNetworks", ListNetworksOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listNetworks&listAll=true HTTP/1.1"); @@ -64,7 +65,7 @@ public class NetworkAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(NetworkAsyncClient.class.getMethod("listNetworks", ListNetworksOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ListNetworksOptions.Builder.type(NetworkType.ADVANCED) + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ListNetworksOptions.Builder.type(NetworkType.ADVANCED) .domainId("6").id("5"))); assertRequestLineEquals(httpRequest, @@ -82,7 +83,7 @@ public class NetworkAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(NetworkAsyncClient.class.getMethod("getNetwork", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("id")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("id")); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listNetworks&listAll=true&id=id HTTP/1.1"); @@ -110,7 +111,7 @@ public class NetworkAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(NetworkAsyncClient.class.getMethod("createNetworkInZone", String.class, String.class, String.class, String.class, CreateNetworkOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1, 2, "named", "lovely")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1, 2, "named", "lovely")); assertRequestLineEquals(httpRequest, createNetwork.getRequestLine()); assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); @@ -139,7 +140,7 @@ public class NetworkAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(NetworkAsyncClient.class.getMethod("createNetworkInZone", String.class, String.class, String.class, String.class, CreateNetworkOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1, 2, "named", "lovely", CreateNetworkOptions.Builder + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1, 2, "named", "lovely", CreateNetworkOptions.Builder .netmask("255.255.255.0").domainId("6"))); assertRequestLineEquals(httpRequest, createNetworkOptions.getRequestLine()); @@ -156,7 +157,7 @@ public class NetworkAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(NetworkAsyncClient.class.getMethod("deleteNetwork", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=deleteNetwork&id=5 HTTP/1.1"); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/OfferingAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/OfferingAsyncClientTest.java index 1c685eb1ad..73a81a651f 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/OfferingAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/OfferingAsyncClientTest.java @@ -29,13 +29,13 @@ import org.jclouds.cloudstack.options.ListDiskOfferingsOptions; import org.jclouds.cloudstack.options.ListNetworkOfferingsOptions; import org.jclouds.cloudstack.options.ListServiceOfferingsOptions; import org.jclouds.functions.IdentityFunction; -import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseFirstJsonValueNamed; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.base.Functions; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code OfferingAsyncClient} @@ -48,7 +48,7 @@ import com.google.common.reflect.Invokable; public class OfferingAsyncClientTest extends BaseCloudStackAsyncClientTest { public void testListDiskOfferings() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(OfferingAsyncClient.class.getMethod("listDiskOfferings", ListDiskOfferingsOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listDiskOfferings&listAll=true HTTP/1.1"); @@ -65,7 +65,7 @@ public class OfferingAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(OfferingAsyncClient.class.getMethod("listDiskOfferings", ListDiskOfferingsOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ListDiskOfferingsOptions.Builder.domainId("6").id("5"))); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ListDiskOfferingsOptions.Builder.domainId("6").id("5"))); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listDiskOfferings&listAll=true&domainid=6&id=5 HTTP/1.1"); @@ -82,7 +82,7 @@ public class OfferingAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(OfferingAsyncClient.class.getMethod("getDiskOffering", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("5")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("5")); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listDiskOfferings&listAll=true&id=5 HTTP/1.1"); @@ -100,7 +100,7 @@ public class OfferingAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(OfferingAsyncClient.class.getMethod("listNetworkOfferings", ListNetworkOfferingsOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listNetworkOfferings&listAll=true HTTP/1.1"); @@ -117,7 +117,7 @@ public class OfferingAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(OfferingAsyncClient.class.getMethod("listNetworkOfferings", ListNetworkOfferingsOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of( + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of( ListNetworkOfferingsOptions.Builder.availability(DEFAULT).isShared(true).id("6"))); assertRequestLineEquals( @@ -136,7 +136,7 @@ public class OfferingAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(OfferingAsyncClient.class.getMethod("getNetworkOffering", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("5")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("5")); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listNetworkOfferings&listAll=true&id=5 HTTP/1.1"); @@ -154,7 +154,7 @@ public class OfferingAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(OfferingAsyncClient.class.getMethod("listServiceOfferings", ListServiceOfferingsOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listServiceOfferings&listAll=true HTTP/1.1"); @@ -171,7 +171,7 @@ public class OfferingAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(OfferingAsyncClient.class.getMethod("listServiceOfferings", ListServiceOfferingsOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ListServiceOfferingsOptions.Builder.virtualMachineId("4") + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ListServiceOfferingsOptions.Builder.virtualMachineId("4") .domainId("5").id("6"))); assertRequestLineEquals( @@ -190,7 +190,7 @@ public class OfferingAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(OfferingAsyncClient.class.getMethod("getServiceOffering", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("5")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("5")); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listServiceOfferings&listAll=true&id=5 HTTP/1.1"); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairAsyncClientTest.java index a0f4f1ffc3..54b5b1056b 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SSHKeyPairAsyncClientTest.java @@ -32,14 +32,14 @@ import org.jclouds.cloudstack.options.ListSSHKeyPairsOptions; import org.jclouds.crypto.SshKeys; import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions; import org.jclouds.functions.IdentityFunction; -import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseFirstJsonValueNamed; import org.jclouds.http.functions.ReleasePayloadAndReturn; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.base.Functions; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code SSHKeyPairAsyncClient} @@ -51,7 +51,7 @@ public class SSHKeyPairAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(SSHKeyPairAsyncClient.class.getMethod("listSSHKeyPairs", ListSSHKeyPairsOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listSSHKeyPairs&listAll=true HTTP/1.1"); @@ -68,7 +68,7 @@ public class SSHKeyPairAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(SSHKeyPairAsyncClient.class.getMethod("listSSHKeyPairs", ListSSHKeyPairsOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ListSSHKeyPairsOptions.Builder.name("jclouds"))); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ListSSHKeyPairsOptions.Builder.name("jclouds"))); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listSSHKeyPairs&listAll=true&name=jclouds HTTP/1.1"); @@ -85,7 +85,7 @@ public class SSHKeyPairAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(SSHKeyPairAsyncClient.class.getMethod("getSSHKeyPair", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("jclouds-keypair")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("jclouds-keypair")); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listSSHKeyPairs&listAll=true&name=jclouds-keypair HTTP/1.1"); @@ -104,7 +104,7 @@ public class SSHKeyPairAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(SSHKeyPairAsyncClient.class.getMethod("registerSSHKeyPair", String.class, String.class)); String publicKey = URLEncoder.encode(SshKeys.generate().get("public"), "UTF-8"); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("jclouds-keypair", publicKey)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("jclouds-keypair", publicKey)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=registerSSHKeyPair&name=jclouds-keypair&publickey=" + publicKey @@ -123,7 +123,7 @@ public class SSHKeyPairAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(SSHKeyPairAsyncClient.class.getMethod("deleteSSHKeyPair", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("jclouds-keypair")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("jclouds-keypair")); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=deleteSSHKeyPair&name=jclouds-keypair HTTP/1.1"); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SecurityGroupAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SecurityGroupAsyncClientTest.java index 2c3b982ce4..354ca027bf 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SecurityGroupAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SecurityGroupAsyncClientTest.java @@ -31,6 +31,8 @@ import org.jclouds.functions.IdentityFunction; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseFirstJsonValueNamed; import org.jclouds.http.functions.ReleasePayloadAndReturn; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.base.Functions; @@ -38,7 +40,6 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Multimap; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code SecurityGroupAsyncClient} @@ -52,7 +53,7 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest< public void testListSecurityGroups() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("listSecurityGroups", ListSecurityGroupsOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listSecurityGroups&listAll=true HTTP/1.1"); @@ -69,7 +70,7 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest< public void testListSecurityGroupsOptions() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("listSecurityGroups", ListSecurityGroupsOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ListSecurityGroupsOptions.Builder.virtualMachineId("4") + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ListSecurityGroupsOptions.Builder.virtualMachineId("4") .domainId("5").id("6"))); assertRequestLineEquals( @@ -88,7 +89,7 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest< public void testGetSecurityGroup() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("getSecurityGroup", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listSecurityGroups&listAll=true&id=5 HTTP/1.1"); @@ -106,7 +107,7 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest< public void testCreateSecurityGroup() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("createSecurityGroup", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("goo")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("goo")); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=createSecurityGroup&name=goo HTTP/1.1"); @@ -134,7 +135,7 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest< public void testAuthorizeIngressPortsToCIDRs() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("authorizeIngressPortsToCIDRs", String.class, String.class, int.class, int.class, Iterable.class, AccountInDomainOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(2, "tcp", 22, 22, + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(2, "tcp", 22, 22, ImmutableSet.of("1.1.1.1/24", "1.2.2.2/16"))); assertRequestLineEquals(httpRequest, authorizeSecurityGroupIngress3.getRequestLine()); @@ -167,7 +168,7 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest< public void testAuthorizeIngressPortsToSecurityGroups() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("authorizeIngressPortsToSecurityGroups", String.class, String.class, int.class, int.class, Multimap.class, AccountInDomainOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(2, "tcp", 22, 22, + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(2, "tcp", 22, 22, ImmutableMultimap.of("adrian", "group1", "adrian", "group2", "bob", "group1"))); assertRequestLineEquals(httpRequest, authorizeSecurityGroupIngress4.getRequestLine()); @@ -195,7 +196,7 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest< public void testAuthorizeIngressICMPToCIDRs() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("authorizeIngressICMPToCIDRs", String.class , int.class, int.class, Iterable.class, AccountInDomainOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(2, 22, 22, ImmutableSet.of("1.1.1.1/24", "1.2.2.2/16"))); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(2, 22, 22, ImmutableSet.of("1.1.1.1/24", "1.2.2.2/16"))); assertRequestLineEquals(httpRequest, authorizeSecurityGroupIngress1.getRequestLine()); assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); @@ -227,7 +228,7 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest< public void testAuthorizeIngressICMPToSecurityGroups() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("authorizeIngressICMPToSecurityGroups", String.class, int.class, int.class, Multimap.class, AccountInDomainOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(2, 22, 22, + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(2, 22, 22, ImmutableMultimap.of("adrian", "group1", "adrian", "group2", "bob", "group1"))); assertRequestLineEquals(httpRequest, authorizeSecurityGroupIngress2.getRequestLine()); @@ -245,7 +246,7 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest< public void testRevokeIngressRule() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("revokeIngressRule", String.class, AccountInDomainOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5, + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5, AccountInDomainOptions.Builder.accountInDomain("adrian", "1"))); assertRequestLineEquals( @@ -264,7 +265,7 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest< public void testDeleteSecurityGroup() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("deleteSecurityGroup", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=deleteSecurityGroup&id=5 HTTP/1.1"); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SnapshotAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SnapshotAsyncClientTest.java index 68a3744b20..96cc0ed27d 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SnapshotAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SnapshotAsyncClientTest.java @@ -34,12 +34,13 @@ import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseFirstJsonValueNamed; import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.http.functions.UnwrapOnlyJsonValue; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.base.Functions; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; -import com.google.common.reflect.Invokable; /** * Tests the behaviour of SnapshotAsyncClient. @@ -54,7 +55,7 @@ public class SnapshotAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(SnapshotAsyncClient.class.getMethod("createSnapshot", String.class, CreateSnapshotOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=createSnapshot&volumeid=5 HTTP/1.1"); @@ -70,7 +71,7 @@ public class SnapshotAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(SnapshotAsyncClient.class.getMethod("createSnapshot", String.class, CreateSnapshotOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5, CreateSnapshotOptions.Builder.accountInDomain("acc", "7").policyId("9"))); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5, CreateSnapshotOptions.Builder.accountInDomain("acc", "7").policyId("9"))); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=createSnapshot&volumeid=5&account=acc&domainid=7&policyid=9 HTTP/1.1"); @@ -86,7 +87,7 @@ public class SnapshotAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(SnapshotAsyncClient.class.getMethod("listSnapshots", ListSnapshotsOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listSnapshots&listAll=true HTTP/1.1"); @@ -102,7 +103,7 @@ public class SnapshotAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(SnapshotAsyncClient.class.getMethod("getSnapshot", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listSnapshots&listAll=true&id=5 HTTP/1.1"); @@ -119,7 +120,7 @@ public class SnapshotAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(SnapshotAsyncClient.class.getMethod("listSnapshots", ListSnapshotsOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ListSnapshotsOptions.Builder.accountInDomain("acc", "7").id("5").interval(Snapshot.Interval.MONTHLY).isRecursive(true).keyword("fred").name("fred's snapshot").snapshotType(Snapshot.Type.RECURRING).volumeId("11"))); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ListSnapshotsOptions.Builder.accountInDomain("acc", "7").id("5").interval(Snapshot.Interval.MONTHLY).isRecursive(true).keyword("fred").name("fred's snapshot").snapshotType(Snapshot.Type.RECURRING).volumeId("11"))); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listSnapshots&listAll=true&account=acc&domainid=7&id=5&intervaltype=MONTHLY&isrecursive=true&keyword=fred&name=fred%27s%20snapshot&snapshottype=RECURRING&volumeid=11 HTTP/1.1"); @@ -135,7 +136,7 @@ public class SnapshotAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(SnapshotAsyncClient.class.getMethod("deleteSnapshot", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(14)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(14)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=deleteSnapshot&id=14 HTTP/1.1"); @@ -161,7 +162,7 @@ public class SnapshotAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(SnapshotAsyncClient.class.getMethod("createSnapshotPolicy", SnapshotPolicySchedule.class, String.class, String.class, String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(SnapshotPolicySchedules.monthly(5, 6, 7), 10, "UTC", 12)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(SnapshotPolicySchedules.monthly(5, 6, 7), 10, "UTC", 12)); assertRequestLineEquals(httpRequest,extractIso.getRequestLine()); assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); @@ -176,7 +177,7 @@ public class SnapshotAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(SnapshotAsyncClient.class.getMethod("deleteSnapshotPolicy", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(7)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(7)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=deleteSnapshotPolicies&id=7 HTTP/1.1"); @@ -193,7 +194,7 @@ public class SnapshotAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(SnapshotAsyncClient.class.getMethod("deleteSnapshotPolicies", Iterable.class)); Iterable ids = ImmutableSet.of("3", "5", "7"); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ids)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ids)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=deleteSnapshotPolicies&ids=3,5,7 HTTP/1.1"); @@ -209,7 +210,7 @@ public class SnapshotAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(SnapshotAsyncClient.class.getMethod("listSnapshotPolicies", String.class, ListSnapshotPoliciesOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(10)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(10)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listSnapshotPolicies&listAll=true&volumeid=10 HTTP/1.1"); @@ -225,7 +226,7 @@ public class SnapshotAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(SnapshotAsyncClient.class.getMethod("listSnapshotPolicies", String.class, ListSnapshotPoliciesOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(10, ListSnapshotPoliciesOptions.Builder.accountInDomain("fred", "4").keyword("bob"))); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(10, ListSnapshotPoliciesOptions.Builder.accountInDomain("fred", "4").keyword("bob"))); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listSnapshotPolicies&listAll=true&volumeid=10&account=fred&domainid=4&keyword=bob HTTP/1.1"); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/TemplateAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/TemplateAsyncClientTest.java index a5b8f2fbe2..3b0fdf61da 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/TemplateAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/TemplateAsyncClientTest.java @@ -41,12 +41,13 @@ import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseFirstJsonValueNamed; import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.http.functions.UnwrapOnlyJsonValue; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.base.Functions; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code TemplateAsyncClient} @@ -60,7 +61,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(TemplateAsyncClient.class.getMethod("createTemplate", TemplateMetadata.class, CreateTemplateOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(TemplateMetadata.builder().name("thename").osTypeId("10").displayText("description").build())); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(TemplateMetadata.builder().name("thename").osTypeId("10").displayText("description").build())); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=createTemplate&name=thename&ostypeid=10&displaytext=description HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); @@ -75,7 +76,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(TemplateAsyncClient.class.getMethod("createTemplate", TemplateMetadata.class, CreateTemplateOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(TemplateMetadata.builder().name("thename").osTypeId("10").displayText("description").build(), CreateTemplateOptions.Builder.bits(32).isFeatured(true).isPublic(true).passwordEnabled(true).requiresHVM(true).snapshotId("11").volumeId("12"))); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(TemplateMetadata.builder().name("thename").osTypeId("10").displayText("description").build(), CreateTemplateOptions.Builder.bits(32).isFeatured(true).isPublic(true).passwordEnabled(true).requiresHVM(true).snapshotId("11").volumeId("12"))); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=createTemplate&bits=32&isfeatured=true&ispublic=true&passwordenabled=true&requireshvm=true&snapshotid=11&volumeid=12&name=thename&ostypeid=10&displaytext=description HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); @@ -102,7 +103,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(TemplateAsyncClient.class.getMethod("registerTemplate", TemplateMetadata.class, String.class, String.class, String.class, String.class, RegisterTemplateOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(TemplateMetadata.builder().name("thename").osTypeId("10").displayText("description").build(), Template.Format.QCOW2, "xen", "http://example.com/", 20)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(TemplateMetadata.builder().name("thename").osTypeId("10").displayText("description").build(), Template.Format.QCOW2, "xen", "http://example.com/", 20)); assertRequestLineEquals(httpRequest, registerTemplate.getRequestLine()); assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); @@ -138,7 +139,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(TemplateAsyncClient.class.getMethod("registerTemplate", TemplateMetadata.class, String.class, String.class, String.class, String.class, RegisterTemplateOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(TemplateMetadata.builder().name("thename").osTypeId("10").displayText("description").build(), Template.Format.QCOW2, "xen", "http://example.com/", 20, + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(TemplateMetadata.builder().name("thename").osTypeId("10").displayText("description").build(), Template.Format.QCOW2, "xen", "http://example.com/", 20, RegisterTemplateOptions.Builder.accountInDomain("mydomain", "3").bits(32).checksum("ABC").isExtractable(true).isFeatured(true).isPublic(true).passwordEnabled(true).requiresHVM(true))); assertRequestLineEquals(httpRequest, registerTemplateOptions.getRequestLine()); @@ -154,7 +155,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(TemplateAsyncClient.class.getMethod("updateTemplate", String.class, UpdateTemplateOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(17)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(17)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=updateTemplate&id=17 HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); @@ -169,7 +170,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(TemplateAsyncClient.class.getMethod("updateTemplate", String.class, UpdateTemplateOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(17, UpdateTemplateOptions.Builder.bootable(true).displayText("description").format(Template.Format.VHD).name("thename").osTypeId("12").passwordEnabled(true))); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(17, UpdateTemplateOptions.Builder.bootable(true).displayText("description").format(Template.Format.VHD).name("thename").osTypeId("12").passwordEnabled(true))); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=updateTemplate&id=17&bootable=true&displaytext=description&format=VHD&name=thename&ostypeid=12&passwordenabled=true HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); @@ -192,7 +193,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(TemplateAsyncClient.class.getMethod("copyTemplateToZone", String.class, String.class, String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(17, 18, 19)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(17, 18, 19)); assertRequestLineEquals(httpRequest,copyTemplate.getRequestLine()); assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); @@ -207,7 +208,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(TemplateAsyncClient.class.getMethod("deleteTemplate", String.class, DeleteTemplateOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(17)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(17)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=deleteTemplate&id=17 HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); @@ -222,7 +223,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(TemplateAsyncClient.class.getMethod("deleteTemplate", String.class, DeleteTemplateOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(17, DeleteTemplateOptions.Builder.zoneId("8"))); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(17, DeleteTemplateOptions.Builder.zoneId("8"))); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=deleteTemplate&id=17&zoneid=8 HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); @@ -237,7 +238,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(TemplateAsyncClient.class.getMethod("listTemplates")); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listTemplates&listAll=true&templatefilter=executable HTTP/1.1"); @@ -254,7 +255,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(TemplateAsyncClient.class.getMethod("listTemplates", ListTemplatesOptions.class)); - HttpRequest httpRequest = processor + GeneratedHttpRequest httpRequest = processor .createRequest( method, ImmutableList. of( ListTemplatesOptions.Builder.accountInDomain("adrian", "6").hypervisor("xen") @@ -276,7 +277,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(TemplateAsyncClient.class.getMethod("getTemplateInZone", String.class, String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5, 1)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5, 1)); assertRequestLineEquals( httpRequest, @@ -295,7 +296,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(TemplateAsyncClient.class.getMethod("updateTemplatePermissions", String.class, UpdateTemplatePermissionsOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(17)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(17)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=updateTemplatePermissions&id=17 HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, ""); @@ -310,7 +311,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(TemplateAsyncClient.class.getMethod("updateTemplatePermissions", String.class, UpdateTemplatePermissionsOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(17, UpdateTemplatePermissionsOptions.Builder.accounts(ImmutableSet.of("5", "6")).isExtractable(true).isFeatured(true).isPublic(true).op(UpdateTemplatePermissionsOptions.Operation.add))); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(17, UpdateTemplatePermissionsOptions.Builder.accounts(ImmutableSet.of("5", "6")).isExtractable(true).isFeatured(true).isPublic(true).op(UpdateTemplatePermissionsOptions.Operation.add))); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=updateTemplatePermissions&id=17&accounts=5,6&isextractable=true&isfeatured=true&ispublic=true&op=add HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, ""); @@ -325,7 +326,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(TemplateAsyncClient.class.getMethod("listTemplatePermissions", String.class, AccountInDomainOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(17)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(17)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listTemplatePermissions&listAll=true&id=17 HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); @@ -340,7 +341,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(TemplateAsyncClient.class.getMethod("listTemplatePermissions", String.class, AccountInDomainOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(17, AccountInDomainOptions.Builder.accountInDomain("fred", "8"))); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(17, AccountInDomainOptions.Builder.accountInDomain("fred", "8"))); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listTemplatePermissions&listAll=true&id=17&account=fred&domainid=8 HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); @@ -363,7 +364,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(TemplateAsyncClient.class.getMethod("extractTemplate", String.class, ExtractMode.class, String.class, ExtractTemplateOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(3, ExtractMode.HTTP_DOWNLOAD, 5)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(3, ExtractMode.HTTP_DOWNLOAD, 5)); assertRequestLineEquals(httpRequest, extractTemplate.getRequestLine()); assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); @@ -387,7 +388,7 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(TemplateAsyncClient.class.getMethod("extractTemplate", String.class, ExtractMode.class, String.class, ExtractTemplateOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(3, ExtractMode.HTTP_DOWNLOAD, 5, ExtractTemplateOptions.Builder.url("http://example.com/"))); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(3, ExtractMode.HTTP_DOWNLOAD, 5, ExtractTemplateOptions.Builder.url("http://example.com/"))); assertRequestLineEquals(httpRequest, extractTemplateOptions.getRequestLine()); assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/VMGroupAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/VMGroupAsyncClientTest.java index a4dec5c804..befb57d6ff 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/VMGroupAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/VMGroupAsyncClientTest.java @@ -29,14 +29,14 @@ import org.jclouds.cloudstack.options.ListVMGroupsOptions; import org.jclouds.cloudstack.options.UpdateVMGroupOptions; import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions; import org.jclouds.functions.IdentityFunction; -import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseFirstJsonValueNamed; import org.jclouds.http.functions.ReleasePayloadAndReturn; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.base.Functions; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code VMGroupAsyncClient} @@ -50,7 +50,7 @@ public class VMGroupAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(VMGroupAsyncClient.class.getMethod("listInstanceGroups", ListVMGroupsOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listInstanceGroups&listAll=true HTTP/1.1"); @@ -67,7 +67,7 @@ public class VMGroupAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(VMGroupAsyncClient.class.getMethod("listInstanceGroups", ListVMGroupsOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ListVMGroupsOptions.Builder.account("fred") + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ListVMGroupsOptions.Builder.account("fred") .domainId("5").id("6"))); assertRequestLineEquals( @@ -86,7 +86,7 @@ public class VMGroupAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(VMGroupAsyncClient.class.getMethod("getInstanceGroup", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listInstanceGroups&listAll=true&id=5 HTTP/1.1"); @@ -104,7 +104,7 @@ public class VMGroupAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(VMGroupAsyncClient.class.getMethod("createInstanceGroup", String.class, CreateVMGroupOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("goo")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("goo")); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=createInstanceGroup&name=goo HTTP/1.1"); @@ -121,7 +121,7 @@ public class VMGroupAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(VMGroupAsyncClient.class.getMethod("createInstanceGroup", String.class, CreateVMGroupOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("goo", CreateVMGroupOptions.Builder.account("foo").domainId("42"))); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("goo", CreateVMGroupOptions.Builder.account("foo").domainId("42"))); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=createInstanceGroup&name=goo&account=foo&domainid=42 HTTP/1.1"); @@ -138,7 +138,7 @@ public class VMGroupAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(VMGroupAsyncClient.class.getMethod("updateInstanceGroup", String.class, UpdateVMGroupOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5, UpdateVMGroupOptions.Builder.name("fred"))); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5, UpdateVMGroupOptions.Builder.name("fred"))); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=updateInstanceGroup&id=5&name=fred HTTP/1.1"); @@ -155,7 +155,7 @@ public class VMGroupAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(VMGroupAsyncClient.class.getMethod("deleteInstanceGroup", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=deleteInstanceGroup&id=5 HTTP/1.1"); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/VirtualMachineAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/VirtualMachineAsyncClientTest.java index 11279c92ba..11d608da6c 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/VirtualMachineAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/VirtualMachineAsyncClientTest.java @@ -31,11 +31,12 @@ import org.jclouds.functions.IdentityFunction; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseFirstJsonValueNamed; import org.jclouds.http.functions.UnwrapOnlyJsonValue; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.base.Functions; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code VirtualMachineAsyncClient} @@ -49,7 +50,7 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest public void testListVirtualMachines() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(VirtualMachineAsyncClient.class.getMethod("listVirtualMachines", ListVirtualMachinesOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listVirtualMachines&listAll=true HTTP/1.1"); @@ -67,7 +68,7 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest public void testListVirtualMachinesOptions() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(VirtualMachineAsyncClient.class.getMethod("listVirtualMachines", ListVirtualMachinesOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of( + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of( ListVirtualMachinesOptions.Builder.accountInDomain("adrian", "6").usesVirtualNetwork(true))); assertRequestLineEquals( @@ -86,7 +87,7 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest public void testGetVirtualMachine() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(VirtualMachineAsyncClient.class.getMethod("getVirtualMachine", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listVirtualMachines&listAll=true&id=5 HTTP/1.1"); @@ -113,7 +114,7 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest public void testDeployVirtualMachineInZone() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(VirtualMachineAsyncClient.class.getMethod("deployVirtualMachineInZone", String.class, String.class, String.class, DeployVirtualMachineOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(6, 4, 5)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(6, 4, 5)); assertRequestLineEquals(httpRequest, deployVirtualMachine.getRequestLine()); assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); @@ -129,7 +130,7 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest public void testRebootVirtualMachine() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(VirtualMachineAsyncClient.class.getMethod("rebootVirtualMachine", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=rebootVirtualMachine&id=5 HTTP/1.1"); @@ -146,7 +147,7 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest public void testStartVirtualMachine() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(VirtualMachineAsyncClient.class.getMethod("startVirtualMachine", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=startVirtualMachine&id=5 HTTP/1.1"); @@ -163,7 +164,7 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest public void testStopVirtualMachine() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(VirtualMachineAsyncClient.class.getMethod("stopVirtualMachine", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=stopVirtualMachine&id=5 HTTP/1.1"); @@ -180,7 +181,7 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest public void testResetPasswordForVirtualMachine() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(VirtualMachineAsyncClient.class.getMethod("resetPasswordForVirtualMachine", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=resetPasswordForVirtualMachine&id=5 HTTP/1.1"); @@ -197,7 +198,7 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest public void testChangeServiceForVirtualMachine() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(VirtualMachineAsyncClient.class.getMethod("changeServiceForVirtualMachine", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=changeServiceForVirtualMachine&id=5 HTTP/1.1"); @@ -214,7 +215,7 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest public void testUpdateVirtualMachine() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(VirtualMachineAsyncClient.class.getMethod("updateVirtualMachine", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=updateVirtualMachine&id=5 HTTP/1.1"); @@ -231,7 +232,7 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest public void testDestroyVirtualMachine() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(VirtualMachineAsyncClient.class.getMethod("destroyVirtualMachine", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(5)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=destroyVirtualMachine&id=5 HTTP/1.1"); @@ -249,7 +250,7 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest public void testAssignVirtualMachine() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(VirtualMachineAsyncClient.class.getMethod("assignVirtualMachine", String.class, AssignVirtualMachineOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("abcd", + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("abcd", AssignVirtualMachineOptions.Builder.accountInDomain("adrian", "6"))); assertRequestLineEquals( diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/VolumeAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/VolumeAsyncClientTest.java index f0b4369f77..9df61ea41e 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/VolumeAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/VolumeAsyncClientTest.java @@ -26,10 +26,11 @@ import org.jclouds.Fallbacks.VoidOnNotFoundOr404; import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest; import org.jclouds.cloudstack.options.ListVolumesOptions; import org.jclouds.http.HttpRequest; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code EventAsyncClient} @@ -43,7 +44,7 @@ public class VolumeAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(VolumeAsyncClient.class.getMethod("listVolumes", ListVolumesOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listVolumes&listAll=true HTTP/1.1"); @@ -59,7 +60,7 @@ public class VolumeAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(VolumeAsyncClient.class.getMethod("getVolume", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(111L)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(111L)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listVolumes&listAll=true&id=111 HTTP/1.1"); @@ -84,7 +85,7 @@ public class VolumeAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(VolumeAsyncClient.class.getMethod("createVolumeFromSnapshotInZone", String.class, String.class, String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("jclouds-volume", 999L, 111l)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("jclouds-volume", 999L, 111l)); assertRequestLineEquals(httpRequest, createVolumeFromSnapshot.getRequestLine()); assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); @@ -107,7 +108,7 @@ public class VolumeAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(VolumeAsyncClient.class.getMethod("createVolumeFromDiskOfferingInZone", String.class, String.class, String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("jclouds-volume", 999L, 111L)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("jclouds-volume", 999L, 111L)); assertRequestLineEquals(httpRequest, createVolumeFromDiskOffering.getRequestLine()); assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); @@ -121,7 +122,7 @@ public class VolumeAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(VolumeAsyncClient.class.getMethod("attachVolume", String.class, String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(111L, 999L)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(111L, 999L)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=attachVolume&id=111&virtualmachineid=999 HTTP/1.1"); @@ -136,7 +137,7 @@ public class VolumeAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(VolumeAsyncClient.class.getMethod("detachVolume", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(111L)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(111L)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=detachVolume&id=111 HTTP/1.1"); @@ -150,7 +151,7 @@ public class VolumeAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(VolumeAsyncClient.class.getMethod("deleteVolume", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(111L)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(111L)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=deleteVolume&id=111 HTTP/1.1"); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/ZoneAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/ZoneAsyncClientTest.java index bf92b63863..ece5b02fd2 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/ZoneAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/ZoneAsyncClientTest.java @@ -25,14 +25,14 @@ import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest; import org.jclouds.cloudstack.options.ListZonesOptions; import org.jclouds.functions.IdentityFunction; -import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseFirstJsonValueNamed; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.base.Functions; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code ZoneAsyncClient} @@ -45,7 +45,7 @@ import com.google.common.reflect.Invokable; public class ZoneAsyncClientTest extends BaseCloudStackAsyncClientTest { public void testListZones() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(ZoneAsyncClient.class.getMethod("listZones", ListZonesOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listZones&listAll=true HTTP/1.1"); @@ -53,8 +53,8 @@ public class ZoneAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(ZoneAsyncClient.class.getMethod("listZones", ListZonesOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ListZonesOptions.Builder.available(true).domainId("5") + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(ListZonesOptions.Builder.available(true).domainId("5") .id("6"))); assertRequestLineEquals(httpRequest, @@ -90,7 +90,7 @@ public class ZoneAsyncClientTest extends BaseCloudStackAsyncClientTest method = Invokable.from(ZoneAsyncClient.class.getMethod("getZone", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(6)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(6)); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/client/api?response=json&command=listZones&listAll=true&id=6 HTTP/1.1"); diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/AMIAsyncClientTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/services/AMIAsyncClientTest.java index 3e029f18a9..b425babc94 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/AMIAsyncClientTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/services/AMIAsyncClientTest.java @@ -34,11 +34,12 @@ import org.jclouds.ec2.xml.PermissionHandler; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code AMIAsyncClient} @@ -65,9 +66,9 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest { public void testCreateImage() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(AMIAsyncClient.class.getMethod("createImageInRegion", String.class, String.class, String.class, CreateImageOptions[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name", "instanceId")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name", "instanceId")); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -98,10 +99,10 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest { public void testCreateImageOptions() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(AMIAsyncClient.class.getMethod("createImageInRegion", String.class, String.class, String.class, CreateImageOptions[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name", "instanceId", new CreateImageOptions() + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name", "instanceId", new CreateImageOptions() .withDescription("description").noReboot())); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -129,9 +130,9 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest { public void testDescribeImages() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(AMIAsyncClient.class.getMethod("describeImagesInRegion", String.class, DescribeImagesOptions[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -164,10 +165,10 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest { public void testDescribeImagesOptions() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(AMIAsyncClient.class.getMethod("describeImagesInRegion", String.class, DescribeImagesOptions[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, executableBy("me").ownedBy("fred", "nancy").imageIds( + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, executableBy("me").ownedBy("fred", "nancy").imageIds( "1", "2"))); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -195,9 +196,9 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest { public void testDeregisterImage() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(AMIAsyncClient.class.getMethod("deregisterImageInRegion", String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageId")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageId")); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -227,9 +228,9 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest { public void testRegisterImageFromManifest() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(AMIAsyncClient.class.getMethod("registerImageFromManifestInRegion", String.class, String.class, String.class, RegisterImageOptions[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name", "pathToManifest")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name", "pathToManifest")); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -259,10 +260,10 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest { public void testRegisterImageFromManifestOptions() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(AMIAsyncClient.class.getMethod("registerImageFromManifestInRegion", String.class, String.class, String.class, RegisterImageOptions[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name", "pathToManifest", new RegisterImageOptions() + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name", "pathToManifest", new RegisterImageOptions() .withDescription("description"))); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -294,9 +295,9 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest { public void testRegisterImageBackedByEBS() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(AMIAsyncClient.class.getMethod("registerUnixImageBackedByEbsInRegion", String.class, String.class, String.class, RegisterImageBackedByEbsOptions[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageName", "snapshotId")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageName", "snapshotId")); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -335,11 +336,11 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest { public void testRegisterImageBackedByEBSOptions() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(AMIAsyncClient.class.getMethod("registerUnixImageBackedByEbsInRegion", String.class, String.class, String.class, RegisterImageBackedByEbsOptions[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageName", "snapshotId", + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageName", "snapshotId", new RegisterImageBackedByEbsOptions().withDescription("description").addBlockDeviceFromSnapshot( "/dev/device", null, "snapshot").addNewBlockDevice("/dev/newdevice", "newblock", 100))); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -369,9 +370,9 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest { public void testGetBlockDeviceMappingsForImage() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(AMIAsyncClient.class.getMethod("getBlockDeviceMappingsForImageInRegion", String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageId")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageId")); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -400,9 +401,9 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest { public void testGetLaunchPermissionForImage() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(AMIAsyncClient.class.getMethod("getLaunchPermissionForImageInRegion", String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageId")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageId")); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -436,10 +437,10 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest { public void testAddLaunchPermissionsToImage() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(AMIAsyncClient.class.getMethod("addLaunchPermissionsToImageInRegion", String.class, Iterable.class, Iterable.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, ImmutableList.of("bob", "sue"), ImmutableList + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, ImmutableList.of("bob", "sue"), ImmutableList .of("all"), "imageId")); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -473,10 +474,10 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest { public void testRemoveLaunchPermissionsFromImage() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(AMIAsyncClient.class.getMethod("removeLaunchPermissionsFromImageInRegion", String.class, Iterable.class, Iterable.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, ImmutableList.of("bob", "sue"), ImmutableList + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, ImmutableList.of("bob", "sue"), ImmutableList .of("all"), "imageId")); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -505,9 +506,9 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest { public void testResetLaunchPermissionsOnImage() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(AMIAsyncClient.class.getMethod("resetLaunchPermissionsOnImageInRegion", String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageId")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageId")); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/AvailabilityZoneAndRegionAsyncClientTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/services/AvailabilityZoneAndRegionAsyncClientTest.java index dff4d6ea6b..776a3c57e3 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/AvailabilityZoneAndRegionAsyncClientTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/services/AvailabilityZoneAndRegionAsyncClientTest.java @@ -29,12 +29,12 @@ import org.jclouds.ec2.options.DescribeAvailabilityZonesOptions; import org.jclouds.ec2.options.DescribeRegionsOptions; import org.jclouds.ec2.xml.DescribeAvailabilityZonesResponseHandler; import org.jclouds.ec2.xml.DescribeRegionsResponseHandler; -import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code AvailabilityZoneAndRegionAsyncClient} @@ -49,7 +49,7 @@ public class AvailabilityZoneAndRegionAsyncClientTest extends public void testDescribeAvailabilityZones() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeAvailabilityZonesInRegion", String.class, DescribeAvailabilityZonesOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(Region.US_WEST_1)); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(Region.US_WEST_1)); assertRequestLineEquals(request, "POST https://ec2.us-west-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-west-1.amazonaws.com\n"); @@ -66,7 +66,7 @@ public class AvailabilityZoneAndRegionAsyncClientTest extends public void testDescribeAvailabilityZonesOptions() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeAvailabilityZonesInRegion", String.class, DescribeAvailabilityZonesOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("us-east-1", availabilityZones("us-east-1a", "us-east-1b"))); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("us-east-1", availabilityZones("us-east-1a", "us-east-1b"))); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -84,7 +84,7 @@ public class AvailabilityZoneAndRegionAsyncClientTest extends public void testDescribeRegions() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeRegions", DescribeRegionsOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -101,7 +101,7 @@ public class AvailabilityZoneAndRegionAsyncClientTest extends public void testDescribeRegionsOptions() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeRegions", DescribeRegionsOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(regions(Region.US_EAST_1, Region.US_WEST_1))); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(regions(Region.US_EAST_1, Region.US_WEST_1))); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticBlockStoreAsyncClientTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticBlockStoreAsyncClientTest.java index 6839708036..9d82575a21 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticBlockStoreAsyncClientTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticBlockStoreAsyncClientTest.java @@ -36,11 +36,12 @@ import org.jclouds.ec2.xml.SnapshotHandler; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code ElasticBlockStoreAsyncClient} @@ -53,7 +54,7 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(ElasticBlockStoreAsyncClient.class.getMethod("deleteVolumeInRegion", String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "id")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "id")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -81,9 +82,9 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(ElasticBlockStoreAsyncClient.class.getMethod("describeVolumesInRegion", String.class, String[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -100,7 +101,7 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(ElasticBlockStoreAsyncClient.class.getMethod("describeVolumesInRegion", String.class, String[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -131,9 +132,9 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(ElasticBlockStoreAsyncClient.class.getMethod("attachVolumeInRegion", String.class, String.class, String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "id", "instanceId", "/device")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "id", "instanceId", "/device")); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -163,9 +164,9 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(ElasticBlockStoreAsyncClient.class.getMethod("detachVolumeInRegion", String.class, String.class, boolean.class, DetachVolumeOptions[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "id", false)); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "id", false)); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -197,10 +198,10 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(ElasticBlockStoreAsyncClient.class.getMethod("detachVolumeInRegion", String.class, String.class, boolean.class, DetachVolumeOptions[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "id", true, fromInstance("instanceId").fromDevice( + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "id", true, fromInstance("instanceId").fromDevice( "/device"))); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -217,7 +218,7 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(ElasticBlockStoreAsyncClient.class.getMethod("createSnapshotInRegion", String.class, String.class, CreateSnapshotOptions[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "volumeId")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "volumeId")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -234,7 +235,7 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(ElasticBlockStoreAsyncClient.class.getMethod("createSnapshotInRegion", String.class, String.class, CreateSnapshotOptions[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "volumeId", CreateSnapshotOptions.Builder + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "volumeId", CreateSnapshotOptions.Builder .withDescription("description"))); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -253,7 +254,7 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(ElasticBlockStoreAsyncClient.class.getMethod("describeSnapshotsInRegion", String.class, DescribeSnapshotsOptions[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -270,7 +271,7 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(ElasticBlockStoreAsyncClient.class.getMethod("describeSnapshotsInRegion", String.class, DescribeSnapshotsOptions[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, ownedBy("o1", "o2").restorableBy("r1", "r2") + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, ownedBy("o1", "o2").restorableBy("r1", "r2") .snapshotIds("s1", "s2"))); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -290,7 +291,7 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(ElasticBlockStoreAsyncClient.class.getMethod("getCreateVolumePermissionForSnapshotInRegion", String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "snapshotId")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "snapshotId")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -326,10 +327,10 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(ElasticBlockStoreAsyncClient.class.getMethod("addCreateVolumePermissionsToSnapshotInRegion", String.class, Iterable.class, Iterable.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, ImmutableList.of("bob", "sue"), ImmutableList + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, ImmutableList.of("bob", "sue"), ImmutableList .of("all"), "snapshotId")); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -364,10 +365,10 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(ElasticBlockStoreAsyncClient.class.getMethod("removeCreateVolumePermissionsFromSnapshotInRegion", String.class, Iterable.class, Iterable.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, ImmutableList.of("bob", "sue"), ImmutableList + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, ImmutableList.of("bob", "sue"), ImmutableList .of("all"), "snapshotId")); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -385,7 +386,7 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(ElasticBlockStoreAsyncClient.class.getMethod("resetCreateVolumePermissionsOnSnapshotInRegion", String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "snapshotId")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "snapshotId")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticIPAddressAsyncClientTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticIPAddressAsyncClientTest.java index e1c03033b7..17a32052d9 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticIPAddressAsyncClientTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticIPAddressAsyncClientTest.java @@ -26,10 +26,11 @@ import org.jclouds.ec2.xml.DescribeAddressesResponseHandler; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.Lists; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code ElasticIPAddressAsyncClient} @@ -43,7 +44,7 @@ public class ElasticIPAddressAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(ElasticIPAddressAsyncClient.class.getMethod("disassociateAddressInRegion", String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "127.0.0.1")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "127.0.0.1")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -73,9 +74,9 @@ public class ElasticIPAddressAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(ElasticIPAddressAsyncClient.class.getMethod("associateAddressInRegion", String.class, String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "127.0.0.1", "me")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "127.0.0.1", "me")); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -91,7 +92,7 @@ public class ElasticIPAddressAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(ElasticIPAddressAsyncClient.class.getMethod("releaseAddressInRegion", String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "127.0.0.1")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "127.0.0.1")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -108,7 +109,7 @@ public class ElasticIPAddressAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(ElasticIPAddressAsyncClient.class.getMethod("describeAddressesInRegion", String.class, String[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "127.0.0.1")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "127.0.0.1")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -124,7 +125,7 @@ public class ElasticIPAddressAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(ElasticIPAddressAsyncClient.class.getMethod("allocateAddressInRegion", String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/InstanceAsyncClientTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/services/InstanceAsyncClientTest.java index 4944a250da..bf76868f2f 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/InstanceAsyncClientTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/services/InstanceAsyncClientTest.java @@ -39,12 +39,13 @@ import org.jclouds.ec2.xml.UnencodeStringValueHandler; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.google.common.collect.Maps; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code InstanceAsyncClient} @@ -56,7 +57,7 @@ import com.google.common.reflect.Invokable; public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest { public void testDescribeInstances() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(InstanceAsyncClient.class.getMethod("describeInstancesInRegion", String.class, String[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -72,7 +73,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(InstanceAsyncClient.class.getMethod("describeInstancesInRegion", String.class, String[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -89,7 +90,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(InstanceAsyncClient.class.getMethod("terminateInstancesInRegion", String.class, String[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -106,7 +107,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(InstanceAsyncClient.class.getMethod("runInstancesInRegion", String.class, String.class, String.class, int.class, int.class, RunInstancesOptions[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, null, "ami-voo", 1, 1)); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, null, "ami-voo", 1, 1)); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -128,7 +129,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(InstanceAsyncClient.class.getMethod("runInstancesInRegion", String.class, String.class, String.class, int.class, int.class, RunInstancesOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("eu-west-1", "eu-west-1a", "ami-voo", + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("eu-west-1", "eu-west-1a", "ami-voo", 1, 5, new RunInstancesOptions().withKernelId("kernelId").withSecurityGroups("group1", "group2"))); assertRequestLineEquals(request, "POST https://ec2.eu-west-1.amazonaws.com/ HTTP/1.1"); @@ -155,7 +156,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(InstanceAsyncClient.class.getMethod("stopInstancesInRegion", String.class, boolean.class, String[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, true, "1", "2")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, true, "1", "2")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -171,7 +172,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(InstanceAsyncClient.class.getMethod("rebootInstancesInRegion", String.class, String[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -187,7 +188,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(InstanceAsyncClient.class.getMethod("startInstancesInRegion", String.class, String[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -203,7 +204,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(InstanceAsyncClient.class.getMethod("getUserDataForInstanceInRegion", String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -221,7 +222,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(InstanceAsyncClient.class.getMethod("getRootDeviceNameForInstanceInRegion", String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -238,7 +239,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(InstanceAsyncClient.class.getMethod("getRamdiskForInstanceInRegion", String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -257,7 +258,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(InstanceAsyncClient.class.getMethod("isApiTerminationDisabledForInstanceInRegion", String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -274,7 +275,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(InstanceAsyncClient.class.getMethod("getKernelForInstanceInRegion", String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -291,7 +292,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(InstanceAsyncClient.class.getMethod("getInstanceTypeForInstanceInRegion", String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -310,7 +311,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(InstanceAsyncClient.class.getMethod("getInstanceInitiatedShutdownBehaviorForInstanceInRegion", String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -330,7 +331,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(InstanceAsyncClient.class.getMethod("getBlockDeviceMappingForInstanceInRegion", String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -362,9 +363,9 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(InstanceAsyncClient.class.getMethod("setUserDataForInstanceInRegion", String.class, String.class, byte[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "test".getBytes())); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "test".getBytes())); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -395,9 +396,9 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(InstanceAsyncClient.class.getMethod("setRamdiskForInstanceInRegion", String.class, String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "test")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "test")); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -428,9 +429,9 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(InstanceAsyncClient.class.getMethod("setKernelForInstanceInRegion", String.class, String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "test")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "test")); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -462,9 +463,9 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(InstanceAsyncClient.class.getMethod("setApiTerminationDisabledForInstanceInRegion", String.class, String.class, boolean.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", true)); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", true)); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -495,9 +496,9 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(InstanceAsyncClient.class.getMethod("setInstanceTypeForInstanceInRegion", String.class, String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", InstanceType.C1_MEDIUM)); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", InstanceType.C1_MEDIUM)); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -529,9 +530,9 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(InstanceAsyncClient.class.getMethod("setInstanceInitiatedShutdownBehaviorForInstanceInRegion", String.class, String.class, InstanceInitiatedShutdownBehavior.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", InstanceInitiatedShutdownBehavior.TERMINATE)); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", InstanceInitiatedShutdownBehavior.TERMINATE)); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -552,7 +553,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest mapping = Maps.newLinkedHashMap(); mapping.put("/dev/sda1", new BlockDevice("vol-test1", true)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", mapping)); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", mapping)); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -574,7 +575,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(InstanceAsyncClient.class.getMethod("getConsoleOutputForInstanceInRegion", String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/KeyPairAsyncClientTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/services/KeyPairAsyncClientTest.java index d06513a81f..1bad2f6f37 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/KeyPairAsyncClientTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/services/KeyPairAsyncClientTest.java @@ -22,13 +22,13 @@ import java.io.IOException; import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; import org.jclouds.ec2.xml.DescribeKeyPairsResponseHandler; -import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.Lists; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code KeyPairAsyncClient} @@ -41,7 +41,7 @@ public class KeyPairAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(KeyPairAsyncClient.class.getMethod("deleteKeyPairInRegion", String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "mykey")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "mykey")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -57,7 +57,7 @@ public class KeyPairAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(KeyPairAsyncClient.class.getMethod("describeKeyPairsInRegion", String.class, String[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -73,7 +73,7 @@ public class KeyPairAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(KeyPairAsyncClient.class.getMethod("describeKeyPairsInRegion", String.class, String[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/SecurityGroupAsyncClientTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/services/SecurityGroupAsyncClientTest.java index cc0fb4daef..f261219ee5 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/SecurityGroupAsyncClientTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/services/SecurityGroupAsyncClientTest.java @@ -28,10 +28,11 @@ import org.jclouds.ec2.xml.DescribeSecurityGroupsResponseHandler; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.Lists; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code SecurityGroupAsyncClient} @@ -45,7 +46,7 @@ public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("deleteSecurityGroupInRegion", String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -75,9 +76,9 @@ public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("createSecurityGroupInRegion", String.class, String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name", "description")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name", "description")); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -94,7 +95,7 @@ public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("describeSecurityGroupsInRegion", String.class, String[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -111,7 +112,7 @@ public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("describeSecurityGroupsInRegion", String.class, String[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -128,7 +129,7 @@ public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("authorizeSecurityGroupIngressInRegion", String.class, String.class, UserIdGroupPair.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "group", new UserIdGroupPair("sourceUser", + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "group", new UserIdGroupPair("sourceUser", "sourceGroup"))); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -164,9 +165,9 @@ public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("authorizeSecurityGroupIngressInRegion", String.class, String.class, IpProtocol.class, int.class, int.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "group", IpProtocol.TCP, 6000, 7000, "0.0.0.0/0")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "group", IpProtocol.TCP, 6000, 7000, "0.0.0.0/0")); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertPayloadEquals(request, authorizeSecurityGroupIngressCidr.getPayload().getRawContent().toString(), @@ -182,7 +183,7 @@ public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("revokeSecurityGroupIngressInRegion", String.class, String.class, UserIdGroupPair.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "group", new UserIdGroupPair("sourceUser", + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "group", new UserIdGroupPair("sourceUser", "sourceGroup"))); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -218,9 +219,9 @@ public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(SecurityGroupAsyncClient.class.getMethod("revokeSecurityGroupIngressInRegion", String.class, String.class, IpProtocol.class, int.class, int.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "group", IpProtocol.TCP, 6000, 7000, "0.0.0.0/0")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "group", IpProtocol.TCP, 6000, 7000, "0.0.0.0/0")); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/WindowsAsyncClientTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/services/WindowsAsyncClientTest.java index f17480a761..58147f71b6 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/WindowsAsyncClientTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/services/WindowsAsyncClientTest.java @@ -26,10 +26,11 @@ import org.jclouds.ec2.xml.BundleTaskHandler; import org.jclouds.ec2.xml.DescribeBundleTasksResponseHandler; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.Lists; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code WindowsAsyncClient} @@ -59,7 +60,7 @@ public class WindowsAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(WindowsAsyncClient.class.getMethod("bundleInstanceInRegion", String.class, String.class, String.class, String.class, String.class, BundleInstanceS3StorageOptions[].class)); - HttpRequest request = processor + GeneratedHttpRequest request = processor .createRequest( method, Lists. newArrayList( @@ -69,7 +70,7 @@ public class WindowsAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(WindowsAsyncClient.class.getMethod("bundleInstanceInRegion", String.class, String.class, String.class, String.class, String.class, BundleInstanceS3StorageOptions[].class)); - HttpRequest request = processor + GeneratedHttpRequest request = processor .createRequest( method, Lists. newArrayList( @@ -114,7 +115,7 @@ public class WindowsAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(WindowsAsyncClient.class.getMethod("describeBundleTasksInRegion", String.class, String[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -146,7 +147,7 @@ public class WindowsAsyncClientTest extends BaseEC2AsyncClientTest method = Invokable.from(WindowsAsyncClient.class.getMethod("describeBundleTasksInRegion", String.class, String[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); diff --git a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackAsyncClientTest.java b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackAsyncClientTest.java index 20f6684788..0cc5a4c25f 100644 --- a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackAsyncClientTest.java +++ b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackAsyncClientTest.java @@ -45,12 +45,13 @@ import org.jclouds.http.filters.BasicAuthentication; import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.io.Payload; import org.jclouds.io.Payloads; +import org.jclouds.reflect.Invokable; import org.jclouds.rest.internal.BaseAsyncClientTest; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code ElasticStackAsyncClient} @@ -62,15 +63,15 @@ import com.google.common.reflect.Invokable; public class ElasticStackAsyncClientTest extends BaseAsyncClientTest { public void testListServers() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(ElasticStackAsyncClient.class.getMethod("listServers")); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET https://api-lon-p.elastichosts.com/servers/list HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); assertPayloadEquals(httpRequest, null, null, false); // now make sure request filters apply by replaying - httpRequest = Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest); - httpRequest = Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest); + httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest); + httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest); assertRequestLineEquals(httpRequest, "GET https://api-lon-p.elastichosts.com/servers/list HTTP/1.1"); // for example, using basic authentication, we should get "only one" @@ -89,7 +90,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(ElasticStackAsyncClient.class.getMethod("listServerInfo")); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET https://api-lon-p.elastichosts.com/servers/info HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); @@ -104,7 +105,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(ElasticStackAsyncClient.class.getMethod("getServerInfo", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); assertRequestLineEquals(httpRequest, "GET https://api-lon-p.elastichosts.com/servers/uuid/info HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); @@ -120,7 +121,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(ElasticStackAsyncClient.class.getMethod("createAndStartServer", Server.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of( + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of( BindServerToPlainTextStringTest.SERVER)); assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/servers/create HTTP/1.1"); @@ -137,7 +138,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(ElasticStackAsyncClient.class.getMethod("createServer", Server.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of( + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of( BindServerToPlainTextStringTest.SERVER)); assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/servers/create/stopped HTTP/1.1"); @@ -154,7 +155,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(ElasticStackAsyncClient.class.getMethod("setServerConfiguration", String.class, Server.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("100", + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("100", BindServerToPlainTextStringTest.SERVER)); assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/servers/100/set HTTP/1.1"); @@ -171,7 +172,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(ElasticStackAsyncClient.class.getMethod("destroyServer", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/servers/uuid/destroy HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); @@ -187,7 +188,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(ElasticStackAsyncClient.class.getMethod("startServer", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/servers/uuid/start HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); @@ -203,7 +204,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(ElasticStackAsyncClient.class.getMethod("stopServer", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/servers/uuid/stop HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); @@ -219,7 +220,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(ElasticStackAsyncClient.class.getMethod("shutdownServer", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/servers/uuid/shutdown HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); @@ -235,7 +236,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(ElasticStackAsyncClient.class.getMethod("resetServer", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/servers/uuid/reset HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); @@ -251,15 +252,15 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(ElasticStackAsyncClient.class.getMethod("listDrives")); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET https://api-lon-p.elastichosts.com/drives/list HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); assertPayloadEquals(httpRequest, null, null, false); // now make sure request filters apply by replaying - httpRequest = Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest); - httpRequest = Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest); + httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest); + httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest); assertRequestLineEquals(httpRequest, "GET https://api-lon-p.elastichosts.com/drives/list HTTP/1.1"); // for example, using basic authentication, we should get "only one" @@ -278,7 +279,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(ElasticStackAsyncClient.class.getMethod("listDriveInfo")); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET https://api-lon-p.elastichosts.com/drives/info HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); @@ -293,7 +294,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(ElasticStackAsyncClient.class.getMethod("getDriveInfo", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); assertRequestLineEquals(httpRequest, "GET https://api-lon-p.elastichosts.com/drives/uuid/info HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); @@ -309,7 +310,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(ElasticStackAsyncClient.class.getMethod("createDrive", Drive.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of( + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of( new CreateDriveRequest.Builder().name("foo").size(10000l).build())); assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/drives/create HTTP/1.1"); @@ -326,7 +327,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(ElasticStackAsyncClient.class.getMethod("setDriveData", String.class, DriveData.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("100", + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("100", new DriveData.Builder().name("foo").size(10000l).tags(ImmutableList.of("production", "candy")).build())); assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/drives/100/set HTTP/1.1"); @@ -343,7 +344,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(ElasticStackAsyncClient.class.getMethod("destroyDrive", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("uuid")); assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/drives/uuid/destroy HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); @@ -359,7 +360,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(ElasticStackAsyncClient.class.getMethod("imageDrive", String.class, String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("100", "200")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("100", "200")); assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/drives/200/image/100 HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n"); @@ -376,7 +377,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(ElasticStackAsyncClient.class.getMethod("imageDrive", String.class, String.class, ImageConversionType.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("100", "200", + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("100", "200", ImageConversionType.GUNZIP)); assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/drives/200/image/100/gunzip HTTP/1.1"); @@ -393,7 +394,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(ElasticStackAsyncClient.class.getMethod("readDrive", String.class, long.class, long.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("100", 1024, 2048)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("100", 1024, 2048)); assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/drives/100/read/1024/2048 HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: application/octet-stream\n"); @@ -408,7 +409,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(ElasticStackAsyncClient.class.getMethod("writeDrive", String.class, Payload.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("100", + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("100", Payloads.newStringPayload("foo"))); assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/drives/100/write HTTP/1.1"); @@ -424,7 +425,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(ElasticStackAsyncClient.class.getMethod("writeDrive", String.class, Payload.class, long.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("100", + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("100", Payloads.newStringPayload("foo"), 2048)); assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/drives/100/write/2048 HTTP/1.1"); diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/v2_0/functions/PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSetTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/v2_0/functions/PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSetTest.java index 4fbead7325..573d7bb195 100644 --- a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/v2_0/functions/PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSetTest.java +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/v2_0/functions/PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSetTest.java @@ -24,7 +24,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Multimap; -import com.google.common.reflect.Invokable; +import org.jclouds.reflect.Invokable; import com.google.inject.AbstractModule; import com.google.inject.Guice; import com.google.inject.Provides; diff --git a/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3BlobRequestSigner.java b/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3BlobRequestSigner.java index 6c1757f304..4f657e6542 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3BlobRequestSigner.java +++ b/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3BlobRequestSigner.java @@ -30,6 +30,7 @@ import org.jclouds.blobstore.functions.BlobToHttpGetOptions; import org.jclouds.http.HttpRequest; import org.jclouds.http.options.GetOptions; import org.jclouds.reflect.Invocation; +import org.jclouds.reflect.Invokable; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.s3.S3AsyncClient; import org.jclouds.s3.blobstore.functions.BlobToObject; @@ -37,7 +38,6 @@ import org.jclouds.s3.domain.S3Object; import org.jclouds.s3.options.PutObjectOptions; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; import com.google.common.reflect.TypeToken; /** @@ -53,21 +53,19 @@ public class S3BlobRequestSigner implements BlobRequest private final Invokable getMethod; private final Invokable deleteMethod; private final Invokable createMethod; - private final Class interfaceType; @Inject public S3BlobRequestSigner(RestAnnotationProcessor processor, BlobToObject blobToObject, BlobToHttpGetOptions blob2HttpGetOptions, Class interfaceType) throws SecurityException, NoSuchMethodException { this.processor = checkNotNull(processor, "processor"); - this.interfaceType = checkNotNull(interfaceType, "interfaceType"); this.blobToObject = checkNotNull(blobToObject, "blobToObject"); this.blob2HttpGetOptions = checkNotNull(blob2HttpGetOptions, "blob2HttpGetOptions"); - this.getMethod = TypeToken.of(interfaceType).method( + this.getMethod = Invokable.from(TypeToken.of(interfaceType), interfaceType.getMethod("getObject", String.class, String.class, GetOptions[].class)); - this.deleteMethod = TypeToken.of(interfaceType).method( + this.deleteMethod = Invokable.from(TypeToken.of(interfaceType), interfaceType.getMethod("deleteObject", String.class, String.class)); - this.createMethod = TypeToken.of(interfaceType).method( + this.createMethod = Invokable.from(TypeToken.of(interfaceType), interfaceType.getMethod("putObject", String.class, S3Object.class, PutObjectOptions[].class)); } @@ -75,7 +73,7 @@ public class S3BlobRequestSigner implements BlobRequest public HttpRequest signGetBlob(String container, String name) { checkNotNull(container, "container"); checkNotNull(name, "name"); - return cleanRequest(processor.apply(Invocation.create(interfaceType, getMethod, + return cleanRequest(processor.apply(Invocation.create( getMethod, ImmutableList. of(container, name)))); } @@ -88,7 +86,7 @@ public class S3BlobRequestSigner implements BlobRequest public HttpRequest signPutBlob(String container, Blob blob) { checkNotNull(container, "container"); checkNotNull(blob, "blob"); - return cleanRequest(processor.apply(Invocation.create(interfaceType, createMethod, + return cleanRequest(processor.apply(Invocation.create( createMethod, ImmutableList. of(container, blobToObject.apply(blob))))); } @@ -101,7 +99,7 @@ public class S3BlobRequestSigner implements BlobRequest public HttpRequest signRemoveBlob(String container, String name) { checkNotNull(container, "container"); checkNotNull(name, "name"); - return cleanRequest(processor.apply(Invocation.create(interfaceType, deleteMethod, + return cleanRequest(processor.apply(Invocation.create( deleteMethod, ImmutableList. of(container, name)))); } @@ -109,7 +107,7 @@ public class S3BlobRequestSigner implements BlobRequest public HttpRequest signGetBlob(String container, String name, org.jclouds.blobstore.options.GetOptions options) { checkNotNull(container, "container"); checkNotNull(name, "name"); - return cleanRequest(processor.apply(Invocation.create(interfaceType, getMethod, + return cleanRequest(processor.apply(Invocation.create( getMethod, ImmutableList.of(container, name, blob2HttpGetOptions.apply(checkNotNull(options, "options")))))); } } diff --git a/apis/s3/src/test/java/org/jclouds/s3/S3AsyncClientTest.java b/apis/s3/src/test/java/org/jclouds/s3/S3AsyncClientTest.java index a8e4910756..2beb3ac58e 100644 --- a/apis/s3/src/test/java/org/jclouds/s3/S3AsyncClientTest.java +++ b/apis/s3/src/test/java/org/jclouds/s3/S3AsyncClientTest.java @@ -31,13 +31,14 @@ import org.jclouds.blobstore.BlobStoreFallbacks.ThrowContainerNotFoundOn404; import org.jclouds.blobstore.BlobStoreFallbacks.ThrowKeyNotFoundOn404; import org.jclouds.blobstore.binders.BindBlobToMultipartFormTest; import org.jclouds.date.TimeStamp; -import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseETagHeader; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.http.functions.ReturnTrueIf2xx; import org.jclouds.http.options.GetOptions; +import org.jclouds.reflect.Invokable; import org.jclouds.rest.ConfiguresRestClient; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.s3.S3Fallbacks.TrueOn404OrNotFoundFalseOnIllegalState; import org.jclouds.s3.config.S3RestClientModule; import org.jclouds.s3.domain.AccessControlList; @@ -70,7 +71,6 @@ import com.google.common.base.Supplier; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; -import com.google.common.reflect.Invokable; import com.google.inject.Module; /** @@ -94,13 +94,13 @@ public class S3AsyncClientTest extends BaseS3AsyncClien public void testGetBucketLocation() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(S3AsyncClient.class.getMethod("getBucketLocation", String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("bucket")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket")); assertRequestLineEquals(request, "GET https://bucket." + url + "/?location HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n"); assertPayloadEquals(request, null, null, false); - request = filter.filter(request); + request = (GeneratedHttpRequest) filter.filter(request); assertRequestLineEquals(request, "GET https://bucket." + url + "/?location HTTP/1.1"); assertNonPayloadHeadersEqual(request, @@ -117,7 +117,7 @@ public class S3AsyncClientTest extends BaseS3AsyncClien public void testGetBucketPayer() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(S3AsyncClient.class.getMethod("getBucketPayer", String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("bucket")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket")); assertRequestLineEquals(request, "GET https://bucket." + url + "/?requestPayment HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n"); @@ -132,7 +132,7 @@ public class S3AsyncClientTest extends BaseS3AsyncClien public void testSetBucketPayerOwner() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(S3AsyncClient.class.getMethod("setBucketPayer", String.class, Payer.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("bucket", Payer.BUCKET_OWNER)); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket", Payer.BUCKET_OWNER)); assertRequestLineEquals(request, "PUT https://bucket." + url + "/?requestPayment HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n"); @@ -148,7 +148,7 @@ public class S3AsyncClientTest extends BaseS3AsyncClien public void testSetBucketPayerRequester() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(S3AsyncClient.class.getMethod("setBucketPayer", String.class, Payer.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("bucket", Payer.REQUESTER)); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket", Payer.REQUESTER)); assertRequestLineEquals(request, "PUT https://bucket." + url + "/?requestPayment HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n"); @@ -165,7 +165,7 @@ public class S3AsyncClientTest extends BaseS3AsyncClien public void testListBucket() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(S3AsyncClient.class.getMethod("listBucket", String.class, ListBucketOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("bucket")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket")); assertRequestLineEquals(request, "GET https://bucket." + url + "/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n"); @@ -180,7 +180,7 @@ public class S3AsyncClientTest extends BaseS3AsyncClien public void testBucketExists() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(S3AsyncClient.class.getMethod("bucketExists", String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("bucket")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket")); assertRequestLineEquals(request, "GET https://bucket." + url + "/?max-keys=0 HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n"); @@ -206,7 +206,7 @@ public class S3AsyncClientTest extends BaseS3AsyncClien NoSuchMethodException, IOException { Invokable method = Invokable.from(S3AsyncClient.class.getMethod("copyObject", String.class, String.class, String.class, String.class, CopyObjectOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("sourceBucket", "sourceObject", "destinationbucket", + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("sourceBucket", "sourceObject", "destinationbucket", "destinationObject")); assertRequestLineEquals(request, "PUT https://destinationbucket." + url + "/destinationObject HTTP/1.1"); @@ -223,7 +223,7 @@ public class S3AsyncClientTest extends BaseS3AsyncClien public void testDeleteBucketIfEmpty() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(S3AsyncClient.class.getMethod("deleteBucketIfEmpty", String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("bucket")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket")); assertRequestLineEquals(request, "DELETE https://bucket." + url + "/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n"); @@ -238,7 +238,7 @@ public class S3AsyncClientTest extends BaseS3AsyncClien public void testDeleteObject() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(S3AsyncClient.class.getMethod("deleteObject", String.class, String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("bucket", "object")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket", "object")); assertRequestLineEquals(request, "DELETE https://bucket." + url + "/object HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n"); @@ -254,7 +254,7 @@ public class S3AsyncClientTest extends BaseS3AsyncClien public void testGetBucketACL() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(S3AsyncClient.class.getMethod("getBucketACL", String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("bucket")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket")); assertRequestLineEquals(request, "GET https://bucket." + url + "/?acl HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n"); @@ -270,7 +270,7 @@ public class S3AsyncClientTest extends BaseS3AsyncClien public void testGetObject() throws ArrayIndexOutOfBoundsException, SecurityException, IllegalArgumentException, NoSuchMethodException, IOException { Invokable method = Invokable.from(S3AsyncClient.class.getMethod("getObject", String.class, String.class, GetOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("bucket", "object")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket", "object")); assertRequestLineEquals(request, "GET https://bucket." + url + "/object HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n"); @@ -286,7 +286,7 @@ public class S3AsyncClientTest extends BaseS3AsyncClien public void testGetObjectACL() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(S3AsyncClient.class.getMethod("getObjectACL", String.class, String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("bucket", "object")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket", "object")); assertRequestLineEquals(request, "GET https://bucket." + url + "/object?acl HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n"); @@ -302,7 +302,7 @@ public class S3AsyncClientTest extends BaseS3AsyncClien public void testObjectExists() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(S3AsyncClient.class.getMethod("objectExists", String.class, String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("bucket", "object")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket", "object")); assertRequestLineEquals(request, "HEAD https://bucket." + url + "/object HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n"); @@ -318,7 +318,7 @@ public class S3AsyncClientTest extends BaseS3AsyncClien public void testHeadObject() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(S3AsyncClient.class.getMethod("headObject", String.class, String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("bucket", "object")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket", "object")); assertRequestLineEquals(request, "HEAD https://bucket." + url + "/object HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n"); @@ -333,7 +333,7 @@ public class S3AsyncClientTest extends BaseS3AsyncClien public void testListOwnedBuckets() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(S3AsyncClient.class.getMethod("listOwnedBuckets")); - HttpRequest request = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(request, "GET https://" + url + "/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: " + url + "\n"); @@ -353,7 +353,7 @@ public class S3AsyncClientTest extends BaseS3AsyncClien public void testPutBucketACL() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(S3AsyncClient.class.getMethod("putBucketACL", String.class, AccessControlList.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("bucket", AccessControlList.fromCannedAccessPolicy( + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket", AccessControlList.fromCannedAccessPolicy( CannedAccessPolicy.PRIVATE, "1234"))); assertRequestLineEquals(request, "PUT https://bucket." + url + "/?acl HTTP/1.1"); @@ -376,7 +376,7 @@ public class S3AsyncClientTest extends BaseS3AsyncClien IllegalArgumentException, NoSuchMethodException, IOException { Invokable method = Invokable.from(S3AsyncClient.class.getMethod("putBucketInRegion", String.class, String.class, PutBucketOptions[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null, "bucket")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null, "bucket")); assertRequestLineEquals(request, "PUT https://bucket." + url + "/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n"); @@ -394,7 +394,7 @@ public class S3AsyncClientTest extends BaseS3AsyncClien Invokable method = Invokable.from(S3AsyncClient.class .getMethod("putObject", String.class, S3Object.class, PutObjectOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("bucket", blobToS3Object + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket", blobToS3Object .apply(BindBlobToMultipartFormTest.TEST_BLOB))); assertRequestLineEquals(request, "PUT https://bucket." + url + "/hello HTTP/1.1"); @@ -411,7 +411,7 @@ public class S3AsyncClientTest extends BaseS3AsyncClien public void testPutObjectACL() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(S3AsyncClient.class .getMethod("putObjectACL", String.class, String.class, AccessControlList.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("bucket", "key", AccessControlList.fromCannedAccessPolicy( + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket", "key", AccessControlList.fromCannedAccessPolicy( CannedAccessPolicy.PRIVATE, "1234"))); assertRequestLineEquals(request, "PUT https://bucket." + url + "/key?acl HTTP/1.1"); @@ -432,7 +432,7 @@ public class S3AsyncClientTest extends BaseS3AsyncClien public void testGetBucketLogging() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(S3AsyncClient.class.getMethod("getBucketLogging", String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("bucket")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket")); assertRequestLineEquals(request, "GET https://bucket." + url + "/?logging HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n"); @@ -447,7 +447,7 @@ public class S3AsyncClientTest extends BaseS3AsyncClien public void testDisableBucketLogging() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(S3AsyncClient.class.getMethod("disableBucketLogging", String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("bucket")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket")); assertRequestLineEquals(request, "PUT https://bucket." + url + "/?logging HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n"); @@ -463,7 +463,7 @@ public class S3AsyncClientTest extends BaseS3AsyncClien public void testEnableBucketLoggingOwner() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(S3AsyncClient.class.getMethod("enableBucketLogging", String.class, BucketLogging.class)); - HttpRequest request = processor + GeneratedHttpRequest request = processor .createRequest(method, ImmutableList. of("bucket", new BucketLogging("mylogs", "access_log-", ImmutableSet . of(new Grant(new EmailAddressGrantee("adrian@jclouds.org"), Permission.FULL_CONTROL))))); diff --git a/apis/s3/src/test/java/org/jclouds/s3/binders/BindAsHostPrefixIfConfiguredNoPathTest.java b/apis/s3/src/test/java/org/jclouds/s3/binders/BindAsHostPrefixIfConfiguredNoPathTest.java index 148b932075..b280cfbcbd 100644 --- a/apis/s3/src/test/java/org/jclouds/s3/binders/BindAsHostPrefixIfConfiguredNoPathTest.java +++ b/apis/s3/src/test/java/org/jclouds/s3/binders/BindAsHostPrefixIfConfiguredNoPathTest.java @@ -29,7 +29,7 @@ import org.jclouds.s3.internal.BaseS3AsyncClientTest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; +import org.jclouds.reflect.Invokable; /** * Tests behavior of {@code BindAsHostPrefixIfConfigured} diff --git a/apis/s3/src/test/java/org/jclouds/s3/binders/BindAsHostPrefixIfConfiguredTest.java b/apis/s3/src/test/java/org/jclouds/s3/binders/BindAsHostPrefixIfConfiguredTest.java index d1687ff39e..23b2fb50b8 100644 --- a/apis/s3/src/test/java/org/jclouds/s3/binders/BindAsHostPrefixIfConfiguredTest.java +++ b/apis/s3/src/test/java/org/jclouds/s3/binders/BindAsHostPrefixIfConfiguredTest.java @@ -32,7 +32,7 @@ import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; +import org.jclouds.reflect.Invokable; /** * Tests behavior of {@code BindAsHostPrefixIfConfigured} diff --git a/apis/s3/src/test/java/org/jclouds/s3/fallbacks/FalseIfBucketAlreadyOwnedByYouOrOperationAbortedWhenBucketExistsTest.java b/apis/s3/src/test/java/org/jclouds/s3/fallbacks/FalseIfBucketAlreadyOwnedByYouOrOperationAbortedWhenBucketExistsTest.java index 1885e738af..48223d8d57 100644 --- a/apis/s3/src/test/java/org/jclouds/s3/fallbacks/FalseIfBucketAlreadyOwnedByYouOrOperationAbortedWhenBucketExistsTest.java +++ b/apis/s3/src/test/java/org/jclouds/s3/fallbacks/FalseIfBucketAlreadyOwnedByYouOrOperationAbortedWhenBucketExistsTest.java @@ -35,7 +35,7 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import com.google.common.collect.Lists; -import com.google.common.reflect.Invokable; +import org.jclouds.reflect.Invokable; /** * @author Adrian Cole diff --git a/apis/s3/src/test/java/org/jclouds/s3/filters/RequestAuthorizeSignatureTest.java b/apis/s3/src/test/java/org/jclouds/s3/filters/RequestAuthorizeSignatureTest.java index d827a5706b..c00c3dfb2f 100644 --- a/apis/s3/src/test/java/org/jclouds/s3/filters/RequestAuthorizeSignatureTest.java +++ b/apis/s3/src/test/java/org/jclouds/s3/filters/RequestAuthorizeSignatureTest.java @@ -41,7 +41,7 @@ import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.collect.SortedSetMultimap; import com.google.common.collect.TreeMultimap; -import com.google.common.reflect.Invokable; +import org.jclouds.reflect.Invokable; /** * Tests behavior of {@code RequestAuthorizeSignature} @@ -87,7 +87,7 @@ public class RequestAuthorizeSignatureTest extends BaseS3AsyncClientTest of("bucket")); StringBuilder builder = new StringBuilder(); @@ -144,7 +144,7 @@ public class RequestAuthorizeSignatureTest extends BaseS3AsyncClientTest of("bucket")); assertEquals(request.getEndpoint().getHost(), "bucket.s3.amazonaws.com"); diff --git a/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftBlobSigner.java b/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftBlobSigner.java index 0306f74e5c..b44c0ea38c 100644 --- a/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftBlobSigner.java +++ b/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftBlobSigner.java @@ -46,6 +46,8 @@ import org.jclouds.openstack.swift.TemporaryUrlKey; import org.jclouds.openstack.swift.blobstore.functions.BlobToObject; import org.jclouds.openstack.swift.domain.SwiftObject; import org.jclouds.reflect.Invocation; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.rest.internal.RestAnnotationProcessor; import com.google.common.base.Supplier; @@ -53,7 +55,6 @@ import com.google.common.base.Throwables; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.io.ByteProcessor; -import com.google.common.reflect.Invokable; import com.google.common.reflect.TypeToken; import com.google.inject.Provider; @@ -75,7 +76,6 @@ public class SwiftBlobSigner implements BlobRe private final Invokable getMethod; private final Invokable deleteMethod; private final Invokable createMethod; - private final Class interfaceType; /** * create a signer for this subtype of swift @@ -89,7 +89,6 @@ public class SwiftBlobSigner implements BlobRe @TemporaryUrlKey Supplier temporaryUrlKeySupplier, RestAnnotationProcessor processor, Class interfaceType) throws SecurityException, NoSuchMethodException { this.processor = checkNotNull(processor, "processor"); - this.interfaceType = checkNotNull(interfaceType, "interfaceType"); this.crypto = checkNotNull(crypto, "crypto"); this.unixEpochTimestampProvider = checkNotNull(unixEpochTimestampProvider, "unixEpochTimestampProvider"); @@ -98,11 +97,11 @@ public class SwiftBlobSigner implements BlobRe this.blobToObject = checkNotNull(blobToObject, "blobToObject"); this.blob2HttpGetOptions = checkNotNull(blob2HttpGetOptions, "blob2HttpGetOptions"); - this.getMethod = TypeToken.of(interfaceType).method( + this.getMethod = Invokable.from(TypeToken.of(interfaceType), interfaceType.getMethod("getObject", String.class, String.class, GetOptions[].class)); - this.deleteMethod = TypeToken.of(interfaceType).method( + this.deleteMethod = Invokable.from(TypeToken.of(interfaceType), interfaceType.getMethod("removeObject", String.class, String.class)); - this.createMethod = TypeToken.of(interfaceType).method( + this.createMethod = Invokable.from(TypeToken.of(interfaceType), interfaceType.getMethod("putObject", String.class, SwiftObject.class)); } @@ -110,7 +109,7 @@ public class SwiftBlobSigner implements BlobRe public HttpRequest signGetBlob(String container, String name) { checkNotNull(container, "container"); checkNotNull(name, "name"); - return cleanRequest(processor.apply(Invocation.create(interfaceType, getMethod, + return cleanRequest(processor.apply(Invocation.create(getMethod, ImmutableList. of(container, name)))); } @@ -118,7 +117,7 @@ public class SwiftBlobSigner implements BlobRe public HttpRequest signGetBlob(String container, String name, long timeInSeconds) { checkNotNull(container, "container"); checkNotNull(name, "name"); - HttpRequest request = processor.apply(Invocation.create(interfaceType, getMethod, + GeneratedHttpRequest request = processor.apply(Invocation.create(getMethod, ImmutableList. of(container, name))); return cleanRequest(signForTemporaryAccess(request, timeInSeconds)); } @@ -127,7 +126,7 @@ public class SwiftBlobSigner implements BlobRe public HttpRequest signGetBlob(String container, String name, org.jclouds.blobstore.options.GetOptions options) { checkNotNull(container, "container"); checkNotNull(name, "name"); - return cleanRequest(processor.apply(Invocation.create(interfaceType, getMethod, + return cleanRequest(processor.apply(Invocation.create(getMethod, ImmutableList.of(container, name, blob2HttpGetOptions.apply(checkNotNull(options, "options")))))); } @@ -135,7 +134,7 @@ public class SwiftBlobSigner implements BlobRe public HttpRequest signPutBlob(String container, Blob blob) { checkNotNull(container, "container"); checkNotNull(blob, "blob"); - return cleanRequest(processor.apply(Invocation.create(interfaceType, createMethod, + return cleanRequest(processor.apply(Invocation.create(createMethod, ImmutableList. of(container, blobToObject.apply(blob))))); } @@ -143,7 +142,7 @@ public class SwiftBlobSigner implements BlobRe public HttpRequest signPutBlob(String container, Blob blob, long timeInSeconds) { checkNotNull(container, "container"); checkNotNull(blob, "blob"); - HttpRequest request = processor.apply(Invocation.create(interfaceType, createMethod, + GeneratedHttpRequest request = processor.apply(Invocation.create(createMethod, ImmutableList. of(container, blobToObject.apply(blob)))); return cleanRequest(signForTemporaryAccess(request, timeInSeconds)); } @@ -152,7 +151,7 @@ public class SwiftBlobSigner implements BlobRe public HttpRequest signRemoveBlob(String container, String name) { checkNotNull(container, "container"); checkNotNull(name, "name"); - return cleanRequest(processor.apply(Invocation.create(interfaceType, deleteMethod, + return cleanRequest(processor.apply(Invocation.create(deleteMethod, ImmutableList. of(container, name)))); } diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/internal/BasePayloadTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/internal/BasePayloadTest.java index 9503cbac6b..41b1abf161 100644 --- a/apis/swift/src/test/java/org/jclouds/openstack/swift/internal/BasePayloadTest.java +++ b/apis/swift/src/test/java/org/jclouds/openstack/swift/internal/BasePayloadTest.java @@ -31,7 +31,7 @@ import org.nnsoft.guice.rocoto.Rocoto; import org.nnsoft.guice.rocoto.configuration.ConfigurationModule; import com.google.common.base.Throwables; -import com.google.common.reflect.Invokable; +import org.jclouds.reflect.Invokable; import com.google.inject.Guice; import com.google.inject.Injector; diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudVersionsAsyncClientTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudVersionsAsyncClientTest.java index b57029f531..deeb155fd4 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudVersionsAsyncClientTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudVersionsAsyncClientTest.java @@ -26,12 +26,13 @@ import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; import org.jclouds.providers.AnonymousProviderMetadata; import org.jclouds.providers.ProviderMetadata; +import org.jclouds.reflect.Invokable; import org.jclouds.rest.internal.BaseAsyncClientTest; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.vcloud.xml.SupportedVersionsHandler; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code VCloudVersionsAsyncClient} @@ -44,7 +45,7 @@ public class VCloudVersionsAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(VCloudVersionsAsyncClient.class.getMethod("getSupportedVersions")); - HttpRequest request = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertEquals(request.getRequestLine(), "GET http://localhost:8080/versions HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/CatalogAsyncClientTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/CatalogAsyncClientTest.java index b5de94f6e1..11616704d7 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/CatalogAsyncClientTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/CatalogAsyncClientTest.java @@ -22,8 +22,9 @@ import java.io.IOException; import java.net.URI; import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.vcloud.internal.BaseVCloudAsyncClientTest; import org.jclouds.vcloud.options.CatalogItemOptions; import org.jclouds.vcloud.xml.CatalogHandler; @@ -31,7 +32,6 @@ import org.jclouds.vcloud.xml.CatalogItemHandler; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code CatalogAsyncClient} @@ -45,7 +45,7 @@ public class CatalogAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(CatalogAsyncClient.class.getMethod("getCatalog", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1"))); assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/catalog/1 HTTP/1.1"); @@ -61,7 +61,7 @@ public class CatalogAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(CatalogAsyncClient.class.getMethod("findCatalogInOrgNamed", String.class, String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("org", "catalog")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("org", "catalog")); assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/catalog/1 HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalog+xml\n"); @@ -76,7 +76,7 @@ public class CatalogAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(CatalogAsyncClient.class.getMethod("getCatalogItem", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2"))); assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2 HTTP/1.1"); @@ -93,7 +93,7 @@ public class CatalogAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(CatalogAsyncClient.class.getMethod("findCatalogItemInOrgCatalogNamed", String.class, String.class, String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("org", "catalog", "item")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("org", "catalog", "item")); assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/catalogItem/1 HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalogItem+xml\n"); @@ -110,7 +110,7 @@ public class CatalogAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(CatalogAsyncClient.class.getMethod("addVAppTemplateOrMediaImageToCatalogAndNameItem", URI.class, URI.class, String.class, CatalogItemOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("http://fooentity"), URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("http://fooentity"), URI .create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1"), "myname", CatalogItemOptions.Builder .description("mydescription"))); diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/NetworkAsyncClientTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/NetworkAsyncClientTest.java index 989a37a830..5c2696f85f 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/NetworkAsyncClientTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/NetworkAsyncClientTest.java @@ -22,14 +22,14 @@ import java.io.IOException; import java.net.URI; import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.vcloud.internal.BaseVCloudAsyncClientTest; import org.jclouds.vcloud.xml.OrgNetworkHandler; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code NetworkAsyncClient} @@ -43,7 +43,7 @@ public class NetworkAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(NetworkAsyncClient.class.getMethod("getNetwork", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/network/2"))); assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/network/2 HTTP/1.1"); @@ -60,7 +60,7 @@ public class NetworkAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(NetworkAsyncClient.class.getMethod("findNetworkInOrgVDCNamed", String.class, String.class, String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("org", "vdc", "network")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("org", "vdc", "network")); assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/network/1990 HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.network+xml\n"); diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/OrgAsyncClientTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/OrgAsyncClientTest.java index 971c645a26..6dde3eca0c 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/OrgAsyncClientTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/OrgAsyncClientTest.java @@ -23,15 +23,15 @@ import java.net.URI; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions; -import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.vcloud.internal.BaseVCloudAsyncClientTest; import org.jclouds.vcloud.xml.OrgHandler; import org.jclouds.vcloud.xml.OrgListHandler; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code OrgAsyncClient} @@ -45,7 +45,7 @@ public class OrgAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(OrgAsyncClient.class.getMethod("listOrgs")); - HttpRequest request = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/org HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.orgList+xml\n"); @@ -60,7 +60,7 @@ public class OrgAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(OrgAsyncClient.class.getMethod("getOrg", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/org/1"))); assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/org/1 HTTP/1.1"); @@ -76,7 +76,7 @@ public class OrgAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(OrgAsyncClient.class.getMethod("findOrgNamed", String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("org")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("org")); assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/org/1 HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.org+xml\n"); diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/TaskAsyncClientTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/TaskAsyncClientTest.java index a36c27681c..e770f2ad0a 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/TaskAsyncClientTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/TaskAsyncClientTest.java @@ -22,16 +22,16 @@ import java.io.IOException; import java.net.URI; import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.vcloud.internal.BaseVCloudAsyncClientTest; import org.jclouds.vcloud.xml.TaskHandler; import org.jclouds.vcloud.xml.TasksListHandler; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code TaskAsyncClient} @@ -45,7 +45,7 @@ public class TaskAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(TaskAsyncClient.class.getMethod("getTasksList", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/tasksList/1"))); assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/tasksList/1 HTTP/1.1"); @@ -61,7 +61,7 @@ public class TaskAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(TaskAsyncClient.class.getMethod("findTasksListInOrgNamed", String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("org")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("org")); assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/tasksList/1 HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.tasksList+xml\n"); @@ -76,7 +76,7 @@ public class TaskAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(TaskAsyncClient.class.getMethod("getTask", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/task/1"))); assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/task/1 HTTP/1.1"); @@ -92,7 +92,7 @@ public class TaskAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(TaskAsyncClient.class.getMethod("cancelTask", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/task/1"))); assertRequestLineEquals(request, "POST https://vcenterprise.bluelock.com/api/v1.0/task/1/action/cancel HTTP/1.1"); diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppAsyncClientTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppAsyncClientTest.java index e205c0e484..b6a57e83d1 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppAsyncClientTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppAsyncClientTest.java @@ -23,9 +23,10 @@ import java.net.URI; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.Fallbacks.VoidOnNotFoundOr404; -import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.util.Strings2; import org.jclouds.vcloud.internal.BaseVCloudAsyncClientTest; import org.jclouds.vcloud.options.CloneVAppOptions; @@ -34,7 +35,6 @@ import org.jclouds.vcloud.xml.VAppHandler; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code VAppAsyncClient} @@ -49,7 +49,7 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VAppAsyncClient.class.getMethod("copyVAppToVDCAndName", URI.class, URI.class, String.class, CloneVAppOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vapp/4181"), URI .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "my-vapp")); @@ -69,7 +69,7 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VAppAsyncClient.class.getMethod("copyVAppToVDCAndName", URI.class, URI.class, String.class, CloneVAppOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vapp/201"), URI .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "new-linux-server", new CloneVAppOptions() .deploy().powerOn().description("The description of the new vApp"))); @@ -90,7 +90,7 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VAppAsyncClient.class.getMethod("moveVAppToVDCAndRename", URI.class, URI.class, String.class, CloneVAppOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vapp/201"), URI .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "new-linux-server", new CloneVAppOptions() .deploy().powerOn().description("The description of the new vApp"))); @@ -110,7 +110,7 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VAppAsyncClient.class.getMethod("deployVApp", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); assertRequestLineEquals(request, "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/deploy HTTP/1.1"); @@ -127,7 +127,7 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VAppAsyncClient.class.getMethod("deployAndPowerOnVApp", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); assertRequestLineEquals(request, "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/deploy HTTP/1.1"); @@ -144,7 +144,7 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VAppAsyncClient.class.getMethod("getVApp", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vApp/1 HTTP/1.1"); @@ -160,7 +160,7 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VAppAsyncClient.class.getMethod("rebootVApp", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); assertRequestLineEquals(request, @@ -177,7 +177,7 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VAppAsyncClient.class.getMethod("undeployVApp", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); assertRequestLineEquals(request, @@ -195,7 +195,7 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VAppAsyncClient.class.getMethod("undeployAndSaveStateOfVApp", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); assertRequestLineEquals(request, @@ -214,7 +214,7 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VAppAsyncClient.class.getMethod("deleteVApp", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); assertRequestLineEquals(request, "DELETE https://vcenterprise.bluelock.com/api/v1.0/vApp/1 HTTP/1.1"); @@ -230,7 +230,7 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VAppAsyncClient.class.getMethod("powerOnVApp", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); assertRequestLineEquals(request, @@ -247,7 +247,7 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VAppAsyncClient.class.getMethod("powerOffVApp", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); assertRequestLineEquals(request, @@ -264,7 +264,7 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VAppAsyncClient.class.getMethod("resetVApp", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); assertRequestLineEquals(request, @@ -281,7 +281,7 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VAppAsyncClient.class.getMethod("suspendVApp", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); assertRequestLineEquals(request, @@ -298,7 +298,7 @@ public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VAppAsyncClient.class.getMethod("shutdownVApp", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); assertRequestLineEquals(request, diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppTemplateAsyncClientTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppTemplateAsyncClientTest.java index d98e13fc77..48a442f0f3 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppTemplateAsyncClientTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppTemplateAsyncClientTest.java @@ -24,9 +24,10 @@ import java.io.IOException; import java.net.URI; import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; import org.jclouds.ovf.xml.EnvelopeHandler; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.util.Strings2; import org.jclouds.vcloud.domain.network.FenceMode; import org.jclouds.vcloud.domain.network.NetworkConfig; @@ -40,7 +41,6 @@ import org.jclouds.vcloud.xml.VAppTemplateHandler; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code VAppTemplateAsyncClient} @@ -56,7 +56,7 @@ public class VAppTemplateAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VAppTemplateAsyncClient.class.getMethod("createVAppInVDCByInstantiatingTemplate", String.class, URI.class, URI.class, InstantiateVAppTemplateOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("my-vapp", URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("my-vapp", URI .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), URI .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3"), addNetworkConfig(new NetworkConfig("aloha", URI @@ -89,7 +89,7 @@ public class VAppTemplateAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VAppTemplateAsyncClient.class.getMethod("copyVAppTemplateToVDCAndName", URI.class, URI.class, String.class, CloneVAppTemplateOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/4181"), URI .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "my-vapptemplate")); @@ -109,7 +109,7 @@ public class VAppTemplateAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VAppTemplateAsyncClient.class.getMethod("copyVAppTemplateToVDCAndName", URI.class, URI.class, String.class, CloneVAppTemplateOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/201"), URI .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "new-linux-server", new CloneVAppTemplateOptions().description("The description of the new vAppTemplate"))); @@ -130,7 +130,7 @@ public class VAppTemplateAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VAppTemplateAsyncClient.class.getMethod("moveVAppTemplateToVDCAndRename", URI.class, URI.class, String.class, CloneVAppTemplateOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/201"), URI .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "new-linux-server", new CloneVAppTemplateOptions().description("The description of the new vAppTemplate"))); @@ -151,7 +151,7 @@ public class VAppTemplateAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VAppTemplateAsyncClient.class.getMethod("captureVAppAsTemplateInVDC", URI.class, String.class, URI.class, CaptureVAppOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vapp/4181"), "my-template", URI .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"))); @@ -172,7 +172,7 @@ public class VAppTemplateAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VAppTemplateAsyncClient.class.getMethod("captureVAppAsTemplateInVDC", URI.class, String.class, URI.class, CaptureVAppOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vapp/201"), "my-template", URI .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), new CaptureVAppOptions() .withDescription("The description of the new vApp Template"))); @@ -193,7 +193,7 @@ public class VAppTemplateAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VAppTemplateAsyncClient.class.getMethod("findVAppTemplateInOrgCatalogNamed", String.class, String.class, String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("org", "catalog", "template")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("org", "catalog", "template")); assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2 HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vAppTemplate+xml\n"); @@ -208,7 +208,7 @@ public class VAppTemplateAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VAppTemplateAsyncClient.class.getMethod("getVAppTemplate", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2"))); assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2 HTTP/1.1"); @@ -224,7 +224,7 @@ public class VAppTemplateAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VAppTemplateAsyncClient.class.getMethod("getOvfEnvelopeForVAppTemplate", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2"))); assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2/ovf HTTP/1.1"); diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VDCAsyncClientTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VDCAsyncClientTest.java index 011cef6f3b..5f0e59f505 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VDCAsyncClientTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VDCAsyncClientTest.java @@ -23,15 +23,15 @@ import java.net.URI; import java.util.NoSuchElementException; import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.vcloud.internal.BaseVCloudAsyncClientTest; import org.jclouds.vcloud.xml.VDCHandler; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code VDCAsyncClient} @@ -57,7 +57,7 @@ public class VDCAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VDCAsyncClient.class.getMethod("findVDCInOrgNamed", String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "vdc")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "vdc")); assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vdc/1 HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vdc+xml\n"); @@ -72,7 +72,7 @@ public class VDCAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VDCAsyncClient.class.getMethod("findVDCInOrgNamed", String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, null)); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, null)); assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vdc/1 HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vdc+xml\n"); @@ -87,7 +87,7 @@ public class VDCAsyncClientTest extends BaseVCloudAsyncClientTest method = Invokable.from(VDCAsyncClient.class.getMethod("getVDC", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"))); assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vdc/1 HTTP/1.1"); diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VmAsyncClientTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VmAsyncClientTest.java index ecbee19b20..792d8f5982 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VmAsyncClientTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VmAsyncClientTest.java @@ -22,10 +22,11 @@ import java.io.IOException; import java.net.URI; import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.http.functions.ReturnInputStream; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.util.Strings2; import org.jclouds.vcloud.domain.GuestCustomizationSection; import org.jclouds.vcloud.internal.BaseVCloudAsyncClientTest; @@ -36,7 +37,6 @@ import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code VmAsyncClient} @@ -50,7 +50,7 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest public void testGetThumbnailOfVm() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(VmAsyncClient.class.getMethod("getScreenThumbnailForVm", URI.class)); - HttpRequest request = processor + GeneratedHttpRequest request = processor .createRequest(method, ImmutableList. of(URI.create("http://vcloud.example.com/api/v1.0/vApp/vm-12"))); assertRequestLineEquals(request, "GET http://vcloud.example.com/api/v1.0/vApp/vm-12/screen HTTP/1.1"); @@ -71,7 +71,7 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest GuestCustomizationSection guest = new GuestCustomizationSection(URI .create("http://vcloud.example.com/api/v1.0/vApp/vm-12/guestCustomizationSection")); guest.setCustomizationScript("cat > /tmp/foo.txt< of(guest, URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(guest, URI .create("http://vcloud.example.com/api/v1.0/vApp/vm-12"))); assertRequestLineEquals(request, @@ -89,7 +89,7 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest public void testUpdateCPUCountOfVm() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(VmAsyncClient.class.getMethod("updateCPUCountOfVm", int.class, URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(2, URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(2, URI .create("http://vcloud.example.com/api/v1.0/vApp/vm-12"))); assertRequestLineEquals(request, @@ -107,7 +107,7 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest public void testUpdateMemoryMBOfVm() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(VmAsyncClient.class.getMethod("updateMemoryMBOfVm", int.class, URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(512, URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(512, URI .create("http://vcloud.example.com/api/v1.0/vApp/vm-12"))); assertRequestLineEquals(request, @@ -125,7 +125,7 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest public void testDeployVm() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(VmAsyncClient.class.getMethod("deployVm", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); assertRequestLineEquals(request, "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/deploy HTTP/1.1"); @@ -142,7 +142,7 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest public void testDeployAndPowerOnVm() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(VmAsyncClient.class.getMethod("deployAndPowerOnVm", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); assertRequestLineEquals(request, "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/deploy HTTP/1.1"); @@ -159,7 +159,7 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest public void testGetVm() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(VmAsyncClient.class.getMethod("getVm", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vm/1"))); assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vm/1 HTTP/1.1"); @@ -175,7 +175,7 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest public void testRebootVm() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(VmAsyncClient.class.getMethod("rebootVm", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); assertRequestLineEquals(request, @@ -192,7 +192,7 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest public void testUndeployVm() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(VmAsyncClient.class.getMethod("undeployVm", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); assertRequestLineEquals(request, @@ -210,7 +210,7 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest public void testUndeployAndSaveStateOfVmSaveState() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(VmAsyncClient.class.getMethod("undeployAndSaveStateOfVm", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); assertRequestLineEquals(request, @@ -229,7 +229,7 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest public void testPowerOnVm() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(VmAsyncClient.class.getMethod("powerOnVm", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); assertRequestLineEquals(request, @@ -246,7 +246,7 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest public void testPowerOffVm() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(VmAsyncClient.class.getMethod("powerOffVm", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); assertRequestLineEquals(request, @@ -263,7 +263,7 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest public void testResetVm() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(VmAsyncClient.class.getMethod("resetVm", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); assertRequestLineEquals(request, @@ -280,7 +280,7 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest public void testSuspendVm() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(VmAsyncClient.class.getMethod("suspendVm", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); assertRequestLineEquals(request, @@ -297,7 +297,7 @@ public class VmAsyncClientTest extends BaseVCloudAsyncClientTest public void testShutdownVm() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(VmAsyncClient.class.getMethod("shutdownVm", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1"))); assertRequestLineEquals(request, diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BasePayloadTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BasePayloadTest.java index cdde41b161..65f0b3010c 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BasePayloadTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BasePayloadTest.java @@ -28,7 +28,7 @@ import org.nnsoft.guice.rocoto.Rocoto; import org.nnsoft.guice.rocoto.configuration.ConfigurationModule; import com.google.common.base.Throwables; -import com.google.common.reflect.Invokable; +import org.jclouds.reflect.Invokable; import com.google.inject.Guice; import com.google.inject.Injector; diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/VCloudLoginAsyncClientTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/VCloudLoginAsyncClientTest.java index 2fa716e7f2..3db64e2008 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/VCloudLoginAsyncClientTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/VCloudLoginAsyncClientTest.java @@ -30,14 +30,15 @@ import org.jclouds.http.filters.BasicAuthentication; import org.jclouds.location.Provider; import org.jclouds.providers.AnonymousProviderMetadata; import org.jclouds.providers.ProviderMetadata; +import org.jclouds.reflect.Invokable; import org.jclouds.rest.internal.BaseAsyncClientTest; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.vcloud.endpoints.VCloudLogin; import org.jclouds.vcloud.functions.ParseLoginResponseFromHeaders; import org.testng.annotations.Test; import com.google.common.base.Supplier; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; import com.google.inject.Binder; import com.google.inject.Module; import com.google.inject.Provides; @@ -53,7 +54,7 @@ public class VCloudLoginAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(VCloudLoginAsyncClient.class.getMethod("login")); - HttpRequest request = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertEquals(request.getRequestLine(), "POST http://localhost:8080/login HTTP/1.1"); assertNonPayloadHeadersEqual(request, HttpHeaders.ACCEPT + ": application/vnd.vmware.vcloud.orgList+xml\n"); diff --git a/blobstore/src/test/java/org/jclouds/blobstore/util/BlobStoreUtilsTest.java b/blobstore/src/test/java/org/jclouds/blobstore/util/BlobStoreUtilsTest.java index 23fb4aabdd..7682426812 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/util/BlobStoreUtilsTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/util/BlobStoreUtilsTest.java @@ -40,7 +40,7 @@ import org.testng.annotations.Test; import com.google.common.base.Throwables; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; -import com.google.common.reflect.Invokable; +import org.jclouds.reflect.Invokable; /** * Tests behavior of {@code BlobStoreUtils} diff --git a/common/openstack/src/test/java/org/jclouds/openstack/internal/OpenStackAuthAsyncClientTest.java b/common/openstack/src/test/java/org/jclouds/openstack/internal/OpenStackAuthAsyncClientTest.java index 7b968e9dc8..0805583846 100644 --- a/common/openstack/src/test/java/org/jclouds/openstack/internal/OpenStackAuthAsyncClientTest.java +++ b/common/openstack/src/test/java/org/jclouds/openstack/internal/OpenStackAuthAsyncClientTest.java @@ -26,12 +26,13 @@ import org.jclouds.http.HttpRequest; import org.jclouds.http.IntegrationTestAsyncClient; import org.jclouds.http.IntegrationTestClient; import org.jclouds.openstack.functions.ParseAuthenticationResponseFromHeaders; +import org.jclouds.reflect.Invokable; import org.jclouds.rest.AnonymousRestApiMetadata; import org.jclouds.rest.internal.BaseAsyncClientTest; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code OpenStackAuthAsyncClient} @@ -44,7 +45,7 @@ public class OpenStackAuthAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(OpenStackAuthAsyncClient.class.getMethod("authenticate", String.class, String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("foo", "bar")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("foo", "bar")); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/v1.0 HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: */*\nHost: localhost:8080\nX-Auth-Key: bar\nX-Auth-User: foo\n"); @@ -58,7 +59,7 @@ public class OpenStackAuthAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(OpenStackAuthAsyncClient.class.getMethod("authenticateStorage", String.class, String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("foo", "bar")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("foo", "bar")); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/v1.0 HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: */*\nHost: localhost:8080\nX-Storage-Pass: bar\nX-Storage-User: foo\n"); diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/BasePayloadTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/BasePayloadTest.java index 82708e4cbe..464e86de4d 100644 --- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/BasePayloadTest.java +++ b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/BasePayloadTest.java @@ -25,7 +25,7 @@ import org.jclouds.reflect.Invocation; import org.jclouds.rest.internal.GeneratedHttpRequest; import com.google.common.base.Throwables; -import com.google.common.reflect.Invokable; +import org.jclouds.reflect.Invokable; public class BasePayloadTest { diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudLoginAsyncClientTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudLoginAsyncClientTest.java index 0c413405cc..62ba6718b3 100644 --- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudLoginAsyncClientTest.java +++ b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudLoginAsyncClientTest.java @@ -30,14 +30,15 @@ import org.jclouds.http.filters.BasicAuthentication; import org.jclouds.location.Provider; import org.jclouds.providers.AnonymousProviderMetadata; import org.jclouds.providers.ProviderMetadata; +import org.jclouds.reflect.Invokable; import org.jclouds.rest.internal.BaseAsyncClientTest; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.trmk.vcloud_0_8.endpoints.VCloudLogin; import org.jclouds.trmk.vcloud_0_8.functions.ParseLoginResponseFromHeaders; import org.testng.annotations.Test; import com.google.common.base.Supplier; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; import com.google.inject.Binder; import com.google.inject.Module; import com.google.inject.Provides; @@ -54,7 +55,7 @@ public class TerremarkVCloudLoginAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudLoginAsyncClient.class.getMethod("login")); - HttpRequest request = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertEquals(request.getRequestLine(), "POST http://localhost:8080/login HTTP/1.1"); assertNonPayloadHeadersEqual(request, HttpHeaders.ACCEPT + ": application/vnd.vmware.vcloud.orgList+xml\n"); diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudVersionsAsyncClientTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudVersionsAsyncClientTest.java index 81fc2170d9..01b6cc79e6 100644 --- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudVersionsAsyncClientTest.java +++ b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudVersionsAsyncClientTest.java @@ -26,12 +26,13 @@ import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; import org.jclouds.providers.AnonymousProviderMetadata; import org.jclouds.providers.ProviderMetadata; +import org.jclouds.reflect.Invokable; import org.jclouds.rest.internal.BaseAsyncClientTest; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.trmk.vcloud_0_8.xml.SupportedVersionsHandler; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code VCloudVersionsAsyncClient} @@ -44,7 +45,7 @@ public class TerremarkVCloudVersionsAsyncClientTest extends BaseAsyncClientTest< public void testVersions() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TerremarkVCloudVersionsAsyncClient.class.getMethod("getSupportedVersions")); - HttpRequest request = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertEquals(request.getRequestLine(), "GET http://localhost:8080/versions HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/BindToPathTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/BindToPathTest.java index fd0c20a3d3..3ab5f3f66c 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/BindToPathTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/BindToPathTest.java @@ -37,7 +37,7 @@ import org.testng.annotations.Test; import com.abiquo.model.rest.RESTLink; import com.abiquo.model.transport.SingleResourceTransportDto; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; +import org.jclouds.reflect.Invokable; /** * Unit tests for the {@link BindToPath} binder. diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindMoveVolumeToPathTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindMoveVolumeToPathTest.java index ee0231d19a..20e0a7eed4 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindMoveVolumeToPathTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindMoveVolumeToPathTest.java @@ -34,7 +34,7 @@ import org.testng.annotations.Test; import com.abiquo.server.core.cloud.VirtualDatacenterDto; import com.abiquo.server.core.infrastructure.storage.VolumeManagementDto; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; +import org.jclouds.reflect.Invokable; /** * Unit tests for the {@link BindMoveVolumeToPath} binder. diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindNetworkConfigurationRefToPayloadTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindNetworkConfigurationRefToPayloadTest.java index 49b41d7d00..6ae521ee57 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindNetworkConfigurationRefToPayloadTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/cloud/BindNetworkConfigurationRefToPayloadTest.java @@ -42,7 +42,7 @@ import com.abiquo.server.core.cloud.VirtualMachineDto; import com.abiquo.server.core.infrastructure.network.VLANNetworkDto; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; -import com.google.common.reflect.Invokable; +import org.jclouds.reflect.Invokable; /** * Unit tests for the {@link BindNetworkConfigurationRefToPayload} binder. diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/infrastructure/BindSupportedDevicesLinkToPathTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/infrastructure/BindSupportedDevicesLinkToPathTest.java index e7cd227b2d..8aea9d92e3 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/infrastructure/BindSupportedDevicesLinkToPathTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/binders/infrastructure/BindSupportedDevicesLinkToPathTest.java @@ -33,7 +33,7 @@ import org.testng.annotations.Test; import com.abiquo.model.rest.RESTLink; import com.abiquo.server.core.infrastructure.DatacenterDto; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; +import org.jclouds.reflect.Invokable; /** * Unit tests for the {@link BindSupportedDevicesLinkToPath} class. diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/AdminAsyncApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/AdminAsyncApiTest.java index 7fb153836e..622184949d 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/AdminAsyncApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/AdminAsyncApiTest.java @@ -36,7 +36,7 @@ import com.abiquo.server.core.enterprise.RoleDto; import com.abiquo.server.core.enterprise.RolesDto; import com.abiquo.server.core.enterprise.UserDto; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; +import org.jclouds.reflect.Invokable; /** * Tests annotation parsing of {@code AdminAsyncApi} diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/CloudAsyncApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/CloudAsyncApiTest.java index 98617ac2a2..ecafc10602 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/CloudAsyncApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/CloudAsyncApiTest.java @@ -77,7 +77,7 @@ import com.abiquo.server.core.infrastructure.storage.TiersDto; import com.abiquo.server.core.infrastructure.storage.VolumeManagementDto; import com.abiquo.server.core.infrastructure.storage.VolumesManagementDto; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; +import org.jclouds.reflect.Invokable; /** * Tests annotation parsing of {@code CloudAsyncApi} diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/ConfigAsyncApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/ConfigAsyncApiTest.java index fcd4c844df..d4061f7392 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/ConfigAsyncApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/ConfigAsyncApiTest.java @@ -41,7 +41,7 @@ import com.abiquo.server.core.config.SystemPropertyDto; import com.abiquo.server.core.enterprise.PrivilegeDto; import com.abiquo.server.core.enterprise.PrivilegesDto; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; +import org.jclouds.reflect.Invokable; /** * Tests annotation parsing of {@code AdminAsyncApi}. diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/EnterpriseAsyncApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/EnterpriseAsyncApiTest.java index be6cf8232a..8fb341e38d 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/EnterpriseAsyncApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/EnterpriseAsyncApiTest.java @@ -53,7 +53,7 @@ import com.abiquo.server.core.infrastructure.DatacentersDto; import com.abiquo.server.core.infrastructure.MachinesDto; import com.abiquo.server.core.infrastructure.network.VLANNetworksDto; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; +import org.jclouds.reflect.Invokable; /** * Tests annotation parsing of {@code EnterpriseAsyncApi} diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/EventAsyncApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/EventAsyncApiTest.java index 4a9e964327..3cbf91ad7c 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/EventAsyncApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/EventAsyncApiTest.java @@ -27,7 +27,7 @@ import org.testng.annotations.Test; import com.abiquo.server.core.event.EventsDto; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; +import org.jclouds.reflect.Invokable; /** * Tests annotation parsing of {@code EventAsyncApi} diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/InfrastructureAsyncApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/InfrastructureAsyncApiTest.java index 681338a1ec..b614566436 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/InfrastructureAsyncApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/InfrastructureAsyncApiTest.java @@ -89,7 +89,7 @@ import com.abiquo.server.core.infrastructure.storage.StoragePoolsDto; import com.abiquo.server.core.infrastructure.storage.TierDto; import com.abiquo.server.core.infrastructure.storage.TiersDto; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; +import org.jclouds.reflect.Invokable; /** * Tests annotation parsing of {@code InfrastructureAsyncApi} diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/PricingAsyncApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/PricingAsyncApiTest.java index 978a3d0f85..961639ec77 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/PricingAsyncApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/PricingAsyncApiTest.java @@ -42,7 +42,7 @@ import com.abiquo.server.core.pricing.PricingTemplatesDto; import com.abiquo.server.core.pricing.PricingTierDto; import com.abiquo.server.core.pricing.PricingTiersDto; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; +import org.jclouds.reflect.Invokable; /** * Tests annotation parsing of {@code PricingAsyncApi}. diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/TaskAsyncApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/TaskAsyncApiTest.java index b215ddb3fc..fce66f5b53 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/TaskAsyncApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/TaskAsyncApiTest.java @@ -33,7 +33,7 @@ import com.abiquo.model.transport.SingleResourceTransportDto; import com.abiquo.server.core.task.TaskDto; import com.abiquo.server.core.task.TasksDto; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; +import org.jclouds.reflect.Invokable; /** * Tests annotation parsing of {@code TaskAsyncApi} diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/VirtualMachineTemplateAsyncApiTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/VirtualMachineTemplateAsyncApiTest.java index 1c0b47562c..e74a07637e 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/features/VirtualMachineTemplateAsyncApiTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/features/VirtualMachineTemplateAsyncApiTest.java @@ -43,7 +43,7 @@ import com.abiquo.server.core.appslibrary.VirtualMachineTemplateDto; import com.abiquo.server.core.appslibrary.VirtualMachineTemplatePersistentDto; import com.abiquo.server.core.appslibrary.VirtualMachineTemplatesDto; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; +import org.jclouds.reflect.Invokable; /** * Tests annotation parsing of {@code VirtualMachineTemplateAsyncApi} diff --git a/labs/abiquo/src/test/java/org/jclouds/abiquo/rest/internal/AbiquoHttpAsyncClientTest.java b/labs/abiquo/src/test/java/org/jclouds/abiquo/rest/internal/AbiquoHttpAsyncClientTest.java index 2151e3e204..68341bcf63 100644 --- a/labs/abiquo/src/test/java/org/jclouds/abiquo/rest/internal/AbiquoHttpAsyncClientTest.java +++ b/labs/abiquo/src/test/java/org/jclouds/abiquo/rest/internal/AbiquoHttpAsyncClientTest.java @@ -30,7 +30,7 @@ import org.testng.annotations.Test; import com.abiquo.model.rest.RESTLink; import com.abiquo.server.core.infrastructure.DatacentersDto; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; +import org.jclouds.reflect.Invokable; /** * Tests annotation parsing of {@code AbiquoHttpAsyncApi}. diff --git a/labs/oauth/src/main/java/org/jclouds/oauth/v2/functions/BuildTokenRequest.java b/labs/oauth/src/main/java/org/jclouds/oauth/v2/functions/BuildTokenRequest.java index 77d2fa8e20..53e582312a 100644 --- a/labs/oauth/src/main/java/org/jclouds/oauth/v2/functions/BuildTokenRequest.java +++ b/labs/oauth/src/main/java/org/jclouds/oauth/v2/functions/BuildTokenRequest.java @@ -43,7 +43,7 @@ import com.google.common.base.Joiner; import com.google.common.base.Supplier; import com.google.common.base.Ticker; import com.google.common.collect.ImmutableMap; -import com.google.common.reflect.Invokable; +import org.jclouds.reflect.Invokable; import com.google.inject.Inject; import com.google.inject.name.Named; @@ -116,7 +116,7 @@ public class BuildTokenRequest implements Function invokable = request.getInvocation().getInvokable(); - Class interfaceType = request.getInvocation().getInterfaceType(); + Class interfaceType = invokable.getEnclosingType().getRawType(); OAuthScopes classScopes = interfaceType.getAnnotation(OAuthScopes.class); OAuthScopes methodScopes = invokable.getAnnotation(OAuthScopes.class); diff --git a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingAsyncApiTest.java b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingAsyncApiTest.java index 7e923ebcdb..de627749d7 100644 --- a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingAsyncApiTest.java +++ b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingAsyncApiTest.java @@ -22,8 +22,9 @@ import java.io.IOException; import java.net.URI; import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.savvis.vpdc.options.GetVMOptions; import org.jclouds.savvis.vpdc.xml.FirewallServiceHandler; import org.jclouds.savvis.vpdc.xml.NetworkHandler; @@ -35,7 +36,6 @@ import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; -import com.google.common.reflect.Invokable; /** * Tests annotation parsing of {@code BrowsingAsyncApi} @@ -47,7 +47,7 @@ public class BrowsingAsyncApiTest extends BaseVPDCAsyncApiTest public void testOrg() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(BrowsingAsyncApi.class.getMethod("getOrg", String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("11")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("11")); assertRequestLineEquals(request, "GET https://api.savvis.net/vpdc/v1.0/org/11 HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); @@ -62,7 +62,7 @@ public class BrowsingAsyncApiTest extends BaseVPDCAsyncApiTest public void testOrgNull() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(BrowsingAsyncApi.class.getMethod("getOrg", String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); assertRequestLineEquals(request, "GET https://api.savvis.net/vpdc/v1.0/org/1 HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); @@ -77,7 +77,7 @@ public class BrowsingAsyncApiTest extends BaseVPDCAsyncApiTest public void testVDC() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(BrowsingAsyncApi.class.getMethod("getVDCInOrg", String.class, String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("11", "22")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("11", "22")); assertRequestLineEquals(request, "GET https://api.savvis.net/vpdc/v1.0/org/11/vdc/22 HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); @@ -92,7 +92,7 @@ public class BrowsingAsyncApiTest extends BaseVPDCAsyncApiTest public void testVDCWhenOrgNull() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(BrowsingAsyncApi.class.getMethod("getVDCInOrg", String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null, "22")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null, "22")); assertRequestLineEquals(request, "GET https://api.savvis.net/vpdc/v1.0/org/1/vdc/22 HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); @@ -107,7 +107,7 @@ public class BrowsingAsyncApiTest extends BaseVPDCAsyncApiTest public void testNetwork() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(BrowsingAsyncApi.class.getMethod("getNetworkInVDC", String.class, String.class, String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("11", "22", "VM-Tier01")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("11", "22", "VM-Tier01")); assertRequestLineEquals(request, "GET https://api.savvis.net/vpdc/v1.0/org/11/vdc/22/network/VM-Tier01 HTTP/1.1"); @@ -123,7 +123,7 @@ public class BrowsingAsyncApiTest extends BaseVPDCAsyncApiTest public void testNetworkWhenOrgNull() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(BrowsingAsyncApi.class.getMethod("getNetworkInVDC", String.class, String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null, "22", "VM-Tier01")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null, "22", "VM-Tier01")); assertRequestLineEquals(request, "GET https://api.savvis.net/vpdc/v1.0/org/1/vdc/22/network/VM-Tier01 HTTP/1.1"); @@ -140,7 +140,7 @@ public class BrowsingAsyncApiTest extends BaseVPDCAsyncApiTest public void testVMVDC() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(BrowsingAsyncApi.class.getMethod("getVMInVDC", String.class, String.class, String.class, GetVMOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("11", "22", "33")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("11", "22", "33")); assertRequestLineEquals(request, "GET https://api.savvis.net/vpdc/v1.0/org/11/vdc/22/vApp/33 HTTP/1.1"); @@ -156,7 +156,7 @@ public class BrowsingAsyncApiTest extends BaseVPDCAsyncApiTest public void testVM() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(BrowsingAsyncApi.class.getMethod("getVM", URI.class, GetVMOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://api.savvis.net/vpdc/v1.0/org/11/vdc/22/vApp/33"))); assertRequestLineEquals(request, @@ -174,7 +174,7 @@ public class BrowsingAsyncApiTest extends BaseVPDCAsyncApiTest public void testVMWithPowerState() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(BrowsingAsyncApi.class.getMethod("getVMInVDC", String.class, String.class, String.class, GetVMOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("11", "22", "VM-Tier01", GetVMOptions.Builder + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("11", "22", "VM-Tier01", GetVMOptions.Builder .withPowerState())); assertRequestLineEquals(request, @@ -192,7 +192,7 @@ public class BrowsingAsyncApiTest extends BaseVPDCAsyncApiTest public void testVMWhenOrgNull() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(BrowsingAsyncApi.class.getMethod("getVMInVDC", String.class, String.class, String.class, GetVMOptions[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null, "22", "VM-Tier01")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null, "22", "VM-Tier01")); assertRequestLineEquals(request, "GET https://api.savvis.net/vpdc/v1.0/org/1/vdc/22/vApp/VM-Tier01 HTTP/1.1"); @@ -208,7 +208,7 @@ public class BrowsingAsyncApiTest extends BaseVPDCAsyncApiTest public void testGetTask() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(BrowsingAsyncApi.class.getMethod("getTask", String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("1")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("1")); assertRequestLineEquals(request, "GET https://api.savvis.net/vpdc/v1.0/task/1 HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); @@ -223,7 +223,7 @@ public class BrowsingAsyncApiTest extends BaseVPDCAsyncApiTest public void testListFirewallRules() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(BrowsingAsyncApi.class.getMethod("listFirewallRules", String.class, String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("11", "22")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("11", "22")); assertRequestLineEquals(request, "GET https://api.savvis.net/vpdc/v1.0/org/11/vdc/22/FirewallService HTTP/1.1"); diff --git a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/FirewallAsyncApiTest.java b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/FirewallAsyncApiTest.java index ef66d67c03..ac5961039a 100644 --- a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/FirewallAsyncApiTest.java +++ b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/FirewallAsyncApiTest.java @@ -21,15 +21,15 @@ package org.jclouds.savvis.vpdc.features; import java.io.IOException; import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.savvis.vpdc.domain.FirewallRule; import org.jclouds.savvis.vpdc.xml.TaskHandler; import org.jclouds.util.Strings2; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; /** * Tests annotation parsing of {@code FirewallAsyncApi} @@ -42,7 +42,7 @@ public class FirewallAsyncApiTest extends BaseVPDCAsyncApiTest public void testAddFirewallRule() throws NoSuchMethodException, IOException { Invokable method = Invokable.from(FirewallAsyncApi.class.getMethod("addFirewallRule", String.class, String.class, FirewallRule.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("11", "22", FirewallRule.builder().firewallType( + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("11", "22", FirewallRule.builder().firewallType( "SERVER_TIER_FIREWALL").isEnabled(true).source("internet").destination("VM Tier01").port("22").protocol( "Tcp").policy("allow").description("Server Tier Firewall Rule").isLogged(false).build())); @@ -61,7 +61,7 @@ public class FirewallAsyncApiTest extends BaseVPDCAsyncApiTest public void testDeleteFirewallRule() throws NoSuchMethodException, IOException { Invokable method = Invokable.from(FirewallAsyncApi.class.getMethod("deleteFirewallRule", String.class, String.class, FirewallRule.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("11", "22", FirewallRule.builder().firewallType( + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("11", "22", FirewallRule.builder().firewallType( "SERVER_TIER_FIREWALL").isEnabled(true).source("internet").destination("VM Tier01").port("22").protocol( "Tcp").policy("allow").description("Server Tier Firewall Rule").isLogged(false).build())); diff --git a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/ServiceManagementAsyncApiTest.java b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/ServiceManagementAsyncApiTest.java index 3a697c5d54..1692b6b330 100644 --- a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/ServiceManagementAsyncApiTest.java +++ b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/ServiceManagementAsyncApiTest.java @@ -22,13 +22,13 @@ import java.io.IOException; import java.net.URI; import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions; -import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.savvis.vpdc.xml.TaskHandler; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; /** * Tests annotation parsing of {@code ServiceManagementAsyncApi} @@ -41,7 +41,7 @@ public class ServiceManagementAsyncApiTest extends BaseVPDCAsyncApiTest method = Invokable.from(ServiceManagementAsyncApi.class.getMethod("powerOnVMInVDC", String.class, String.class, String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("11", "22", "33")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("11", "22", "33")); assertRequestLineEquals(request, "POST https://api.savvis.net/vpdc/v1.0/org/11/vdc/22/vApp/33/action/powerOn HTTP/1.1"); @@ -57,7 +57,7 @@ public class ServiceManagementAsyncApiTest extends BaseVPDCAsyncApiTest method = Invokable.from(ServiceManagementAsyncApi.class.getMethod("powerOnVM", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://api.savvis.net/vpdc/v1.0/org/11/vdc/22/vApp/33"))); assertRequestLineEquals(request, @@ -75,7 +75,7 @@ public class ServiceManagementAsyncApiTest extends BaseVPDCAsyncApiTest method = Invokable.from(ServiceManagementAsyncApi.class.getMethod("powerOffVMInVDC", String.class, String.class, String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("11", "22", "33")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("11", "22", "33")); assertRequestLineEquals(request, "POST https://api.savvis.net/vpdc/v1.0/org/11/vdc/22/vApp/33/action/powerOff HTTP/1.1"); @@ -91,7 +91,7 @@ public class ServiceManagementAsyncApiTest extends BaseVPDCAsyncApiTest method = Invokable.from(ServiceManagementAsyncApi.class.getMethod("powerOffVM", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://api.savvis.net/vpdc/v1.0/org/11/vdc/22/vApp/33"))); assertRequestLineEquals(request, diff --git a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMAsyncApiTest.java b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMAsyncApiTest.java index 418b2feb7b..a3e0e1f202 100644 --- a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMAsyncApiTest.java +++ b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMAsyncApiTest.java @@ -26,8 +26,9 @@ import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.cim.OSType; import org.jclouds.compute.domain.CIMOperatingSystem; import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions; -import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.savvis.vpdc.domain.VMSpec; import org.jclouds.savvis.vpdc.xml.TaskHandler; import org.jclouds.savvis.vpdc.xml.TasksListHandler; @@ -38,7 +39,6 @@ import com.google.common.base.Predicate; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; -import com.google.common.reflect.Invokable; import com.google.inject.Key; import com.google.inject.TypeLiteral; @@ -63,7 +63,7 @@ public class VMAsyncApiTest extends BaseVPDCAsyncApiTest { }); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://api.savvis.net/rest/api/v0.8/org/11/vdc/22"), VMSpec.builder().name( "DemoHost-1").networkTierName("VM Tier01").operatingSystem(os).build())); @@ -93,7 +93,7 @@ public class VMAsyncApiTest extends BaseVPDCAsyncApiTest { }); - HttpRequest request = processor.createRequest(method, ImmutableList. of("11", "22", VMSpec.builder().operatingSystem(os).name( + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("11", "22", VMSpec.builder().operatingSystem(os).name( "DemoHost-1").networkTierName("VM Tier01").build())); assertRequestLineEquals(request, "GET https://api.savvis.net/vpdc/v1.0/org/11/vdc/22/vApp/ HTTP/1.1"); @@ -110,7 +110,7 @@ public class VMAsyncApiTest extends BaseVPDCAsyncApiTest { public void testCaptureVApp() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(VMAsyncApi.class.getMethod("captureVApp", String.class, String.class, URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("100000.0", "2736", URI.create("https://api.savvis.net/vpdc/v1.0/org/100000.0/vdc/2736/vApp/1001"))); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("100000.0", "2736", URI.create("https://api.savvis.net/vpdc/v1.0/org/100000.0/vdc/2736/vApp/1001"))); assertRequestLineEquals(request, "POST https://api.savvis.net/vpdc/v1.0/org/100000.0/vdc/2736/action/captureVApp HTTP/1.1"); @@ -126,7 +126,7 @@ public class VMAsyncApiTest extends BaseVPDCAsyncApiTest { public void testCloneVApp() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(VMAsyncApi.class.getMethod("cloneVApp", URI.class, String.class, String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://api.savvis.net/vpdc/v1.0/org/100000.0/vdc/2736/vApp/1001"), "clonedvm", "VM Tier01")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://api.savvis.net/vpdc/v1.0/org/100000.0/vdc/2736/vApp/1001"), "clonedvm", "VM Tier01")); assertRequestLineEquals(request, "POST https://api.savvis.net/vpdc/v1.0/org/100000.0/vdc/2736/vApp/1001/action/cloneVApp HTTP/1.1"); @@ -153,7 +153,7 @@ public class VMAsyncApiTest extends BaseVPDCAsyncApiTest { }); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://api.savvis.net/rest/api/v0.8/org/11/vdc/22"), ImmutableSet.of(VMSpec .builder().name("Test VM").networkTierName("VM Tier01").operatingSystem(os).build()))); @@ -184,7 +184,7 @@ public class VMAsyncApiTest extends BaseVPDCAsyncApiTest { }); - HttpRequest request = processor.createRequest(method, ImmutableList. of("11", "22", ImmutableSet.of(VMSpec.builder() + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("11", "22", ImmutableSet.of(VMSpec.builder() .operatingSystem(os).name("Test VM").networkTierName("VM Tier01").build()))); assertRequestLineEquals(request, "GET https://api.savvis.net/vpdc/v1.0/org/11/vdc/22/vApp/ HTTP/1.1"); @@ -201,7 +201,7 @@ public class VMAsyncApiTest extends BaseVPDCAsyncApiTest { public void testRemoveVMFromVDC() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(VMAsyncApi.class.getMethod("removeVMFromVDC", String.class, String.class, String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("11", "22", "33")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("11", "22", "33")); assertRequestLineEquals(request, "DELETE https://api.savvis.net/vpdc/v1.0/org/11/vdc/22/vApp/33 HTTP/1.1"); @@ -217,7 +217,7 @@ public class VMAsyncApiTest extends BaseVPDCAsyncApiTest { public void testRemoveVM() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(VMAsyncApi.class.getMethod("removeVM", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://api.savvis.net/rest/api/v0.8/org/11/vdc/22/vApp/33"))); assertRequestLineEquals(request, @@ -234,7 +234,7 @@ public class VMAsyncApiTest extends BaseVPDCAsyncApiTest { public void testPowerOffVM() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(VMAsyncApi.class.getMethod("powerOffVM", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://api.savvis.net/rest/api/v0.8/org/11/vdc/22/vApp/33"))); assertRequestLineEquals(request, @@ -251,7 +251,7 @@ public class VMAsyncApiTest extends BaseVPDCAsyncApiTest { public void testPowerOnVM() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(VMAsyncApi.class.getMethod("powerOnVM", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://api.savvis.net/rest/api/v0.8/org/11/vdc/22/vApp/33"))); assertRequestLineEquals(request, diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/parse/DescribeSecurityGroupsResponseTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/parse/DescribeSecurityGroupsResponseTest.java index 8463dfc076..0cb647dc89 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/parse/DescribeSecurityGroupsResponseTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/parse/DescribeSecurityGroupsResponseTest.java @@ -38,7 +38,7 @@ import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableSet; -import com.google.common.reflect.Invokable; +import org.jclouds.reflect.Invokable; /** * diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSAMIAsyncClientTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSAMIAsyncClientTest.java index 42b36ed3d4..3c8dffbc96 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSAMIAsyncClientTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSAMIAsyncClientTest.java @@ -35,11 +35,12 @@ import org.jclouds.ec2.xml.PermissionHandler; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code AWSAMIAsyncClient} @@ -69,9 +70,9 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSAMIAsyncClient.class.getMethod("createImageInRegion", String.class, String.class, String.class, CreateImageOptions[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name", "instanceId")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name", "instanceId")); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -102,10 +103,10 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSAMIAsyncClient.class.getMethod("createImageInRegion", String.class, String.class, String.class, CreateImageOptions[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name", "instanceId", new CreateImageOptions() + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name", "instanceId", new CreateImageOptions() .withDescription("description").noReboot())); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -133,9 +134,9 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSAMIAsyncClient.class.getMethod("describeImagesInRegion", String.class, DescribeImagesOptions[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -168,10 +169,10 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSAMIAsyncClient.class.getMethod("describeImagesInRegion", String.class, DescribeImagesOptions[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, executableBy("me").ownedBy("fred", "nancy").imageIds( + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, executableBy("me").ownedBy("fred", "nancy").imageIds( "1", "2"))); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -199,9 +200,9 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSAMIAsyncClient.class.getMethod("deregisterImageInRegion", String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageId")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageId")); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -231,9 +232,9 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSAMIAsyncClient.class.getMethod("registerImageFromManifestInRegion", String.class, String.class, String.class, RegisterImageOptions[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name", "pathToManifest")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name", "pathToManifest")); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -263,10 +264,10 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSAMIAsyncClient.class.getMethod("registerImageFromManifestInRegion", String.class, String.class, String.class, RegisterImageOptions[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name", "pathToManifest", new RegisterImageOptions() + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name", "pathToManifest", new RegisterImageOptions() .withDescription("description"))); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -298,9 +299,9 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSAMIAsyncClient.class.getMethod("registerUnixImageBackedByEbsInRegion", String.class, String.class, String.class, RegisterImageBackedByEbsOptions[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageName", "snapshotId")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageName", "snapshotId")); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -339,11 +340,11 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSAMIAsyncClient.class.getMethod("registerUnixImageBackedByEbsInRegion", String.class, String.class, String.class, RegisterImageBackedByEbsOptions[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageName", "snapshotId", + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageName", "snapshotId", new RegisterImageBackedByEbsOptions().withDescription("description").addBlockDeviceFromSnapshot( "/dev/device", null, "snapshot").addNewBlockDevice("/dev/newdevice", "newblock", 100))); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -373,9 +374,9 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSAMIAsyncClient.class.getMethod("getBlockDeviceMappingsForImageInRegion", String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageId")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageId")); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -404,9 +405,9 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSAMIAsyncClient.class.getMethod("getLaunchPermissionForImageInRegion", String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageId")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageId")); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -440,10 +441,10 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSAMIAsyncClient.class.getMethod("addLaunchPermissionsToImageInRegion", String.class, Iterable.class, Iterable.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, ImmutableList.of("bob", "sue"), ImmutableList + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, ImmutableList.of("bob", "sue"), ImmutableList .of("all"), "imageId")); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -477,10 +478,10 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSAMIAsyncClient.class.getMethod("removeLaunchPermissionsFromImageInRegion", String.class, Iterable.class, Iterable.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, ImmutableList.of("bob", "sue"), ImmutableList + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, ImmutableList.of("bob", "sue"), ImmutableList .of("all"), "imageId")); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -509,9 +510,9 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSAMIAsyncClient.class.getMethod("resetLaunchPermissionsOnImageInRegion", String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageId")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageId")); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -526,7 +527,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSAMIAsyncClient.class.getMethod("getProductCodesForImageInRegion", String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageId")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageId")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -544,7 +545,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSAMIAsyncClient.class.getMethod("addProductCodesToImageInRegion", String.class, Iterable.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, ImmutableList.of("code1", "code2"), "imageId")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, ImmutableList.of("code1", "code2"), "imageId")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -563,7 +564,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSAMIAsyncClient.class.getMethod("removeProductCodesFromImageInRegion", String.class, Iterable.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, ImmutableList.of("code1", "code2"), "imageId")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, ImmutableList.of("code1", "code2"), "imageId")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSInstanceAsyncClientTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSInstanceAsyncClientTest.java index 76964a6b19..e471b9e36b 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSInstanceAsyncClientTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSInstanceAsyncClientTest.java @@ -39,11 +39,12 @@ import org.jclouds.ec2.xml.UnencodeStringValueHandler; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.Lists; import com.google.common.collect.Maps; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code AWSInstanceAsyncClient} @@ -56,7 +57,7 @@ import com.google.common.reflect.Invokable; public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest { public void testDescribeInstances() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(AWSInstanceAsyncClient.class.getMethod("describeInstancesInRegion", String.class, String[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -72,7 +73,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSInstanceAsyncClient.class.getMethod("describeInstancesInRegion", String.class, String[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -88,7 +89,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSInstanceAsyncClient.class.getMethod("terminateInstancesInRegion", String.class, String[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -105,7 +106,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSInstanceAsyncClient.class.getMethod("runInstancesInRegion", String.class, String.class, String.class, int.class, int.class, RunInstancesOptions[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, null, "ami-voo", 1, 1)); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, null, "ami-voo", 1, 1)); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -121,7 +122,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSInstanceAsyncClient.class.getMethod("runInstancesInRegion", String.class, String.class, String.class, int.class, int.class, RunInstancesOptions[].class)); - HttpRequest request = processor.createRequest( + GeneratedHttpRequest request = processor.createRequest( method, Lists. newArrayList("us-east-1", "us-east-1a", @@ -147,7 +148,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSInstanceAsyncClient.class.getMethod("stopInstancesInRegion", String.class, boolean.class, String[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, true, "1", "2")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, true, "1", "2")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -164,7 +165,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSInstanceAsyncClient.class.getMethod("rebootInstancesInRegion", String.class, String[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -181,7 +182,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSInstanceAsyncClient.class.getMethod("startInstancesInRegion", String.class, String[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -198,7 +199,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSInstanceAsyncClient.class.getMethod("getUserDataForInstanceInRegion", String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -216,7 +217,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSInstanceAsyncClient.class.getMethod("getRootDeviceNameForInstanceInRegion", String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -234,7 +235,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSInstanceAsyncClient.class.getMethod("getRamdiskForInstanceInRegion", String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -253,7 +254,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSInstanceAsyncClient.class.getMethod("isApiTerminationDisabledForInstanceInRegion", String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -271,7 +272,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSInstanceAsyncClient.class .getMethod("getKernelForInstanceInRegion", String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -288,7 +289,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSInstanceAsyncClient.class.getMethod("getInstanceTypeForInstanceInRegion", String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -307,7 +308,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSInstanceAsyncClient.class.getMethod("getInstanceInitiatedShutdownBehaviorForInstanceInRegion", String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -327,7 +328,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSInstanceAsyncClient.class.getMethod("getBlockDeviceMappingForInstanceInRegion", String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -359,9 +360,9 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSInstanceAsyncClient.class.getMethod("setUserDataForInstanceInRegion", String.class, String.class, byte[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "test".getBytes())); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "test".getBytes())); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -392,9 +393,9 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSInstanceAsyncClient.class.getMethod("setRamdiskForInstanceInRegion", String.class, String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "test")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "test")); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -425,9 +426,9 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSInstanceAsyncClient.class.getMethod("setKernelForInstanceInRegion", String.class, String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "test")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "test")); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -459,9 +460,9 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSInstanceAsyncClient.class.getMethod("setApiTerminationDisabledForInstanceInRegion", String.class, String.class, boolean.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", true)); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", true)); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -492,9 +493,9 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSInstanceAsyncClient.class.getMethod("setInstanceTypeForInstanceInRegion", String.class, String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", InstanceType.C1_MEDIUM)); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", InstanceType.C1_MEDIUM)); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -526,9 +527,9 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSInstanceAsyncClient.class.getMethod("setInstanceInitiatedShutdownBehaviorForInstanceInRegion", String.class, String.class, InstanceInitiatedShutdownBehavior.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", InstanceInitiatedShutdownBehavior.TERMINATE)); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", InstanceInitiatedShutdownBehavior.TERMINATE)); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -549,7 +550,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest mapping = Maps.newLinkedHashMap(); mapping.put("/dev/sda1", new BlockDevice("vol-test1", true)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", mapping)); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", mapping)); filter.filter(request); diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSKeyPairAsyncClientTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSKeyPairAsyncClientTest.java index c18cb61b31..cc0763fa52 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSKeyPairAsyncClientTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSKeyPairAsyncClientTest.java @@ -26,10 +26,11 @@ import org.jclouds.ec2.xml.KeyPairResponseHandler; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.Lists; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code AWSKeyPairAsyncClient} @@ -42,7 +43,7 @@ public class AWSKeyPairAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSKeyPairAsyncClient.class.getMethod("createKeyPairInRegion", String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "mykey")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "mykey")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -72,9 +73,9 @@ public class AWSKeyPairAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSKeyPairAsyncClient.class.getMethod("importKeyPairInRegion", String.class, String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "mykey", "ssh-rsa AA")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "mykey", "ssh-rsa AA")); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -90,7 +91,7 @@ public class AWSKeyPairAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSKeyPairAsyncClient.class.getMethod("deleteKeyPairInRegion", String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "mykey")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "mykey")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -107,7 +108,7 @@ public class AWSKeyPairAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSKeyPairAsyncClient.class.getMethod("describeKeyPairsInRegion", String.class, String[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -124,7 +125,7 @@ public class AWSKeyPairAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSKeyPairAsyncClient.class.getMethod("describeKeyPairsInRegion", String.class, String[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSSecurityGroupAsyncClientTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSSecurityGroupAsyncClientTest.java index d7bac90bbd..d0897f764a 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSSecurityGroupAsyncClientTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSSecurityGroupAsyncClientTest.java @@ -29,11 +29,12 @@ import org.jclouds.ec2.xml.DescribeSecurityGroupsResponseHandler; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code AWSSecurityGroupAsyncClient} @@ -51,7 +52,7 @@ public class AWSSecurityGroupAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSSecurityGroupAsyncClient.class.getMethod("deleteSecurityGroupInRegionById", String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "id")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "id")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -68,7 +69,7 @@ public class AWSSecurityGroupAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSSecurityGroupAsyncClient.class.getMethod("describeSecurityGroupsInRegionById", String.class, String[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -85,7 +86,7 @@ public class AWSSecurityGroupAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSSecurityGroupAsyncClient.class.getMethod("describeSecurityGroupsInRegionById", String.class, String[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -115,9 +116,9 @@ public class AWSSecurityGroupAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSSecurityGroupAsyncClient.class.getMethod("createSecurityGroupInRegion", String.class, String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name", "description")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name", "description")); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -134,7 +135,7 @@ public class AWSSecurityGroupAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSSecurityGroupAsyncClient.class.getMethod("authorizeSecurityGroupIngressInRegion", String.class, String.class, IpPermission.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "group", IpPermissions.permitAnyProtocol())); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "group", IpPermissions.permitAnyProtocol())); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -153,7 +154,7 @@ public class AWSSecurityGroupAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSSecurityGroupAsyncClient.class.getMethod("authorizeSecurityGroupIngressInRegion", String.class, String.class, Iterable.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "group", ImmutableSet. of(IpPermissions + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "group", ImmutableSet. of(IpPermissions .permit(IpProtocol.TCP).originatingFromCidrBlock("1.1.1.1/32"), IpPermissions.permitICMP().type(8).andCode(0) .originatingFromSecurityGroupId("groupId")))); @@ -174,7 +175,7 @@ public class AWSSecurityGroupAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSSecurityGroupAsyncClient.class.getMethod("revokeSecurityGroupIngressInRegion", String.class, String.class, IpPermission.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "group", IpPermissions.permitAnyProtocol())); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "group", IpPermissions.permitAnyProtocol())); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -193,7 +194,7 @@ public class AWSSecurityGroupAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(AWSSecurityGroupAsyncClient.class.getMethod("revokeSecurityGroupIngressInRegion", String.class, String.class, Iterable.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "group", ImmutableSet. of(IpPermissions + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "group", ImmutableSet. of(IpPermissions .permit(IpProtocol.TCP).originatingFromCidrBlock("1.1.1.1/32"), IpPermissions.permitICMP().type(8).andCode(0) .originatingFromSecurityGroupId("groupId")))); diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/MonitoringAsyncClientTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/MonitoringAsyncClientTest.java index 596648a57a..9c300895d3 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/MonitoringAsyncClientTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/MonitoringAsyncClientTest.java @@ -21,12 +21,12 @@ package org.jclouds.aws.ec2.services; import java.io.IOException; import org.jclouds.aws.ec2.xml.MonitoringStateHandler; -import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.Lists; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code MonitoringAsyncClient} @@ -40,7 +40,7 @@ public class MonitoringAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(MonitoringAsyncClient.class.getMethod("unmonitorInstancesInRegion", String.class, String.class, String[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "instance1", "instance2")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "instance1", "instance2")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); String payload = "Action=UnmonitorInstances&InstanceId.0=instance1&InstanceId.1=instance2"; @@ -57,7 +57,7 @@ public class MonitoringAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(MonitoringAsyncClient.class.getMethod("monitorInstancesInRegion", String.class, String.class, String[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "instance1", "instance2")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "instance1", "instance2")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupAsyncClientTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupAsyncClientTest.java index 3603f97078..035407227e 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupAsyncClientTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupAsyncClientTest.java @@ -26,10 +26,11 @@ import org.jclouds.aws.ec2.xml.DescribePlacementGroupsResponseHandler; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.Lists; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code PlacementGroupAsyncClient} @@ -43,7 +44,7 @@ public class PlacementGroupAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(PlacementGroupAsyncClient.class.getMethod("deletePlacementGroupInRegion", String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -73,9 +74,9 @@ public class PlacementGroupAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(PlacementGroupAsyncClient.class.getMethod("createPlacementGroupInRegion", String.class, String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name", "cluster")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name", "cluster")); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -92,7 +93,7 @@ public class PlacementGroupAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(PlacementGroupAsyncClient.class.getMethod("createPlacementGroupInRegion", String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -109,7 +110,7 @@ public class PlacementGroupAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(PlacementGroupAsyncClient.class.getMethod("describePlacementGroupsInRegion", String.class, String[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -126,7 +127,7 @@ public class PlacementGroupAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(PlacementGroupAsyncClient.class.getMethod("describePlacementGroupsInRegion", String.class, String[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/SpotInstanceAsyncClientTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/SpotInstanceAsyncClientTest.java index 75c84671fd..a544902b45 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/SpotInstanceAsyncClientTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/SpotInstanceAsyncClientTest.java @@ -32,11 +32,12 @@ import org.jclouds.aws.ec2.xml.SpotInstancesHandler; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code SpotInstanceAsyncClient} @@ -64,9 +65,9 @@ public class SpotInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(SpotInstanceAsyncClient.class.getMethod("requestSpotInstanceInRegion", String.class, float.class, String.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, 0.01f, "m1.small", "ami-voo")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, 0.01f, "m1.small", "ami-voo")); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -105,12 +106,12 @@ public class SpotInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(SpotInstanceAsyncClient.class.getMethod("requestSpotInstancesInRegion", String.class, float.class, int.class, LaunchSpecification.class, RequestSpotInstancesOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("eu-west-1", 0.01, 3, + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("eu-west-1", 0.01, 3, LaunchSpecification.builder().instanceType("m1.small").imageId("ami-voo").availabilityZone("eu-west-1a") .kernelId("kernelId").securityGroupName("group1").build(), new RequestSpotInstancesOptions().validFrom(from) .validUntil(to).availabilityZoneGroup("availabilityZoneGroup").launchGroup("launchGroup"))); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://ec2.eu-west-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.eu-west-1.amazonaws.com\n"); @@ -127,7 +128,7 @@ public class SpotInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(SpotInstanceAsyncClient.class.getMethod("cancelSpotInstanceRequestsInRegion", String.class, String[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "id")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "id")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -144,7 +145,7 @@ public class SpotInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(SpotInstanceAsyncClient.class.getMethod("describeSpotInstanceRequestsInRegion", String.class, String[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -161,7 +162,7 @@ public class SpotInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(SpotInstanceAsyncClient.class.getMethod("describeSpotInstanceRequestsInRegion", String.class, String[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -180,7 +181,7 @@ public class SpotInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(SpotInstanceAsyncClient.class.getMethod("describeSpotPriceHistoryInRegion", String.class, DescribeSpotPriceHistoryOptions[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n"); @@ -200,7 +201,7 @@ public class SpotInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = Invokable.from(SpotInstanceAsyncClient.class.getMethod("describeSpotPriceHistoryInRegion", String.class, DescribeSpotPriceHistoryOptions[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(null, DescribeSpotPriceHistoryOptions.Builder.from(from) + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, DescribeSpotPriceHistoryOptions.Builder.from(from) .to(to).productDescription("description").instanceType("m1.small"))); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); diff --git a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3AsyncClientTest.java b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3AsyncClientTest.java index 35e5d4595a..b7c67b6d02 100644 --- a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3AsyncClientTest.java +++ b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3AsyncClientTest.java @@ -29,7 +29,6 @@ import org.jclouds.aws.s3.functions.UploadIdFromHttpResponseViaRegex; import org.jclouds.blobstore.binders.BindBlobToMultipartFormTest; import org.jclouds.date.TimeStamp; import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions; -import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseETagHeader; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; @@ -37,7 +36,9 @@ import org.jclouds.http.functions.ReturnTrueIf2xx; import org.jclouds.io.Payload; import org.jclouds.io.Payloads; import org.jclouds.location.Region; +import org.jclouds.reflect.Invokable; import org.jclouds.rest.ConfiguresRestClient; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.s3.S3AsyncClient; import org.jclouds.s3.S3AsyncClientTest; import org.jclouds.s3.S3Client; @@ -58,7 +59,6 @@ import com.google.common.cache.CacheLoader; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; -import com.google.common.reflect.Invokable; import com.google.inject.Module; /** @@ -81,7 +81,7 @@ public class AWSS3AsyncClientTest extends S3AsyncClientTest { public void testGetBucketLocationEUIsStillDefault() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(AWSS3AsyncClient.class.getMethod("getBucketLocation", String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("bucket-eu-west-1")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket-eu-west-1")); assertRequestLineEquals(request, "GET https://bucket-eu-west-1.s3.amazonaws.com/?location HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: bucket-eu-west-1.s3.amazonaws.com\n"); @@ -100,7 +100,7 @@ public class AWSS3AsyncClientTest extends S3AsyncClientTest { Invokable method = Invokable.from(AWSS3AsyncClient.class.getMethod("putObject", String.class, S3Object.class, PutObjectOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("bucket", + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket", blobToS3Object.apply(BindBlobToMultipartFormTest.TEST_BLOB))); assertRequestLineEquals(request, "PUT https://bucket." + url + "/hello HTTP/1.1"); @@ -117,13 +117,13 @@ public class AWSS3AsyncClientTest extends S3AsyncClientTest { @Override public void testGetBucketLocation() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(AWSS3AsyncClient.class.getMethod("getBucketLocation", String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("bucket")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket")); assertRequestLineEquals(request, "GET https://bucket.s3.amazonaws.com/?location HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: bucket.s3.amazonaws.com\n"); assertPayloadEquals(request, null, null, false); - request = filter.filter(request); + request = (GeneratedHttpRequest) filter.filter(request); assertRequestLineEquals(request, "GET https://bucket.s3.amazonaws.com/?location HTTP/1.1"); assertNonPayloadHeadersEqual( @@ -143,7 +143,7 @@ public class AWSS3AsyncClientTest extends S3AsyncClientTest { IllegalArgumentException, NoSuchMethodException, IOException { Invokable method = Invokable.from(AWSS3AsyncClient.class.getMethod("putBucketInRegion", String.class, String.class, PutBucketOptions[].class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null, "bucket")); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null, "bucket")); assertRequestLineEquals(request, "PUT https://bucket.s3.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: bucket.s3.amazonaws.com\n"); @@ -160,7 +160,7 @@ public class AWSS3AsyncClientTest extends S3AsyncClientTest { NoSuchMethodException { Invokable method = Invokable.from(AWSS3AsyncClient.class.getMethod("initiateMultipartUpload", String.class, ObjectMetadata.class, PutObjectOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("bucket", ObjectMetadataBuilder.create().key("foo") + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket", ObjectMetadataBuilder.create().key("foo") .contentMD5(new byte[] { 1, 2, 3, 4 }).build())); assertRequestLineEquals(request, "POST https://bucket." + url + "/foo?uploads HTTP/1.1"); @@ -171,7 +171,7 @@ public class AWSS3AsyncClientTest extends S3AsyncClientTest { // as this is a payload-related command, but with no payload, be careful // that we check // filtering and do not ignore if this fails later. - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, "POST https://bucket." + url + "/foo?uploads HTTP/1.1"); assertNonPayloadHeadersEqual(request, @@ -189,7 +189,7 @@ public class AWSS3AsyncClientTest extends S3AsyncClientTest { public void testAbortMultipartUpload() throws SecurityException, NegativeArraySizeException, NoSuchMethodException { Invokable method = Invokable.from(AWSS3AsyncClient.class .getMethod("abortMultipartUpload", String.class, String.class, String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("bucket", "foo", "asdsadasdas", 1, + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket", "foo", "asdsadasdas", 1, Payloads.newStringPayload(""))); assertRequestLineEquals(request, "DELETE https://bucket." + url + "/foo?uploadId=asdsadasdas HTTP/1.1"); @@ -206,7 +206,7 @@ public class AWSS3AsyncClientTest extends S3AsyncClientTest { public void testUploadPart() throws SecurityException, NegativeArraySizeException, NoSuchMethodException { Invokable method = Invokable.from(AWSS3AsyncClient.class.getMethod("uploadPart", String.class, String.class, int.class, String.class, Payload.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("bucket", "foo", 1, "asdsadasdas", + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket", "foo", 1, "asdsadasdas", Payloads.newStringPayload(""))); assertRequestLineEquals(request, "PUT https://bucket." + url + "/foo?partNumber=1&uploadId=asdsadasdas HTTP/1.1"); @@ -224,7 +224,7 @@ public class AWSS3AsyncClientTest extends S3AsyncClientTest { NoSuchMethodException { Invokable method = Invokable.from(AWSS3AsyncClient.class.getMethod("completeMultipartUpload", String.class, String.class, String.class, Map.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("bucket", "foo", "asdsadasdas", + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("bucket", "foo", "asdsadasdas", ImmutableMap. of(1, "\"a54357aff0632cce46d942af68356b38\""))); assertRequestLineEquals(request, "POST https://bucket." + url + "/foo?uploadId=asdsadasdas HTTP/1.1"); @@ -245,7 +245,7 @@ public class AWSS3AsyncClientTest extends S3AsyncClientTest { NoSuchMethodException, IOException { Invokable method = Invokable.from(AWSS3AsyncClient.class.getMethod("putBucketInRegion", String.class, String.class, PutBucketOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("EU", "bucket")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("EU", "bucket")); assertRequestLineEquals(request, "PUT https://bucket.s3.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: bucket.s3.amazonaws.com\n"); diff --git a/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/AzureBlobRequestSigner.java b/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/AzureBlobRequestSigner.java index 934f7a8e44..d9d172ed4d 100644 --- a/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/AzureBlobRequestSigner.java +++ b/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/AzureBlobRequestSigner.java @@ -33,10 +33,11 @@ import org.jclouds.blobstore.functions.BlobToHttpGetOptions; import org.jclouds.http.HttpRequest; import org.jclouds.http.options.GetOptions; import org.jclouds.reflect.Invocation; +import org.jclouds.reflect.Invokable; import org.jclouds.rest.internal.RestAnnotationProcessor; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; +import com.google.common.reflect.TypeToken; /** * @@ -58,12 +59,12 @@ public class AzureBlobRequestSigner implements BlobRequestSigner { this.processor = checkNotNull(processor, "processor"); this.blobToBlob = checkNotNull(blobToBlob, "blobToBlob"); this.blob2HttpGetOptions = checkNotNull(blob2HttpGetOptions, "blob2HttpGetOptions"); - this.getMethod = Invokable.from(AzureBlobAsyncClient.class.getMethod("getBlob", String.class, String.class, - GetOptions[].class)); - this.deleteMethod = Invokable - .from(AzureBlobAsyncClient.class.getMethod("deleteBlob", String.class, String.class)); - this.createMethod = Invokable - .from(AzureBlobAsyncClient.class.getMethod("putBlob", String.class, AzureBlob.class)); + this.getMethod = Invokable.from(TypeToken.of(AzureBlobAsyncClient.class), + AzureBlobAsyncClient.class.getMethod("getBlob", String.class, String.class, GetOptions[].class)); + this.deleteMethod = Invokable.from(TypeToken.of(AzureBlobAsyncClient.class), + AzureBlobAsyncClient.class.getMethod("deleteBlob", String.class, String.class)); + this.createMethod = Invokable.from(TypeToken.of(AzureBlobAsyncClient.class), + AzureBlobAsyncClient.class.getMethod("putBlob", String.class, AzureBlob.class)); } @Override diff --git a/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobAsyncClientTest.java b/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobAsyncClientTest.java index 3714a8fc74..83696e8a38 100644 --- a/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobAsyncClientTest.java +++ b/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobAsyncClientTest.java @@ -45,13 +45,14 @@ import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.http.functions.ReturnTrueIf2xx; import org.jclouds.http.options.GetOptions; +import org.jclouds.reflect.Invokable; import org.jclouds.rest.internal.BaseAsyncClientTest; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMultimap; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code AzureBlobAsyncClient} @@ -64,7 +65,7 @@ public class AzureBlobAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(AzureBlobAsyncClient.class.getMethod("listContainers", ListOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(request, "GET https://identity.blob.core.windows.net/?comp=list HTTP/1.1"); assertNonPayloadHeadersEqual(request, "x-ms-version: 2009-09-19\n"); @@ -78,7 +79,7 @@ public class AzureBlobAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(AzureBlobAsyncClient.class.getMethod("listContainers", ListOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(maxResults(1).marker("marker").prefix("prefix"))); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(maxResults(1).marker("marker").prefix("prefix"))); assertRequestLineEquals(request, "GET https://identity.blob.core.windows.net/?comp=list&maxresults=1&marker=marker&prefix=prefix HTTP/1.1"); @@ -93,7 +94,7 @@ public class AzureBlobAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(AzureBlobAsyncClient.class.getMethod("createContainer", String.class, CreateContainerOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("container")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("container")); assertRequestLineEquals(request, "PUT https://identity.blob.core.windows.net/container?restype=container HTTP/1.1"); @@ -107,7 +108,7 @@ public class AzureBlobAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(AzureBlobAsyncClient.class.getMethod("deleteContainer", String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("container")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("container")); assertRequestLineEquals(request, "DELETE https://identity.blob.core.windows.net/container?restype=container HTTP/1.1"); @@ -122,7 +123,7 @@ public class AzureBlobAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(AzureBlobAsyncClient.class.getMethod("createContainer", String.class, CreateContainerOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("container", withPublicAccess(PublicAccess.BLOB) + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("container", withPublicAccess(PublicAccess.BLOB) .withMetadata(ImmutableMultimap.of("foo", "bar")))); assertRequestLineEquals(request, @@ -139,7 +140,7 @@ public class AzureBlobAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(AzureBlobAsyncClient.class.getMethod("createRootContainer", CreateContainerOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(request, "PUT https://identity.blob.core.windows.net/$root?restype=container HTTP/1.1"); assertNonPayloadHeadersEqual(request, "x-ms-version: 2009-09-19\n"); @@ -152,7 +153,7 @@ public class AzureBlobAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(AzureBlobAsyncClient.class.getMethod("deleteRootContainer")); - HttpRequest request = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(request, "DELETE https://identity.blob.core.windows.net/$root?restype=container HTTP/1.1"); assertNonPayloadHeadersEqual(request, "x-ms-version: 2009-09-19\n"); @@ -165,7 +166,7 @@ public class AzureBlobAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(AzureBlobAsyncClient.class.getMethod("createRootContainer", CreateContainerOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(withPublicAccess(PublicAccess.BLOB).withMetadata( + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(withPublicAccess(PublicAccess.BLOB).withMetadata( ImmutableMultimap.of("foo", "bar")))); assertRequestLineEquals(request, "PUT https://identity.blob.core.windows.net/$root?restype=container HTTP/1.1"); @@ -180,7 +181,7 @@ public class AzureBlobAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(AzureBlobAsyncClient.class.getMethod("listBlobs", String.class, ListBlobsOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("container")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("container")); assertRequestLineEquals(request, "GET https://identity.blob.core.windows.net/container?restype=container&comp=list HTTP/1.1"); @@ -194,7 +195,7 @@ public class AzureBlobAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(AzureBlobAsyncClient.class.getMethod("listBlobs", ListBlobsOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(request, "GET https://identity.blob.core.windows.net/$root?restype=container&comp=list HTTP/1.1"); @@ -208,7 +209,7 @@ public class AzureBlobAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(AzureBlobAsyncClient.class.getMethod("getContainerProperties", String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("container")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("container")); assertRequestLineEquals(request, "HEAD https://identity.blob.core.windows.net/container?restype=container HTTP/1.1"); @@ -222,7 +223,7 @@ public class AzureBlobAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(AzureBlobAsyncClient.class.getMethod("getPublicAccessForContainer", String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("container")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("container")); assertRequestLineEquals(request, "HEAD https://identity.blob.core.windows.net/container?restype=container&comp=acl HTTP/1.1"); @@ -236,7 +237,7 @@ public class AzureBlobAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(AzureBlobAsyncClient.class.getMethod("setResourceMetadata", String.class, Map.class)); - HttpRequest request = processor.createRequest(method, + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("container", ImmutableMap.of("key", "value"))); assertRequestLineEquals(request, @@ -251,7 +252,7 @@ public class AzureBlobAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(AzureBlobAsyncClient.class.getMethod("getBlob", String.class, String.class, GetOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("container", "blob")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("container", "blob")); assertRequestLineEquals(request, "GET https://identity.blob.core.windows.net/container/blob HTTP/1.1"); assertNonPayloadHeadersEqual(request, "x-ms-version: 2009-09-19\n"); @@ -264,7 +265,7 @@ public class AzureBlobAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(AzureBlobAsyncClient.class.getMethod("setBlobMetadata", String.class, String.class, Map.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("container", "blob", ImmutableMap.of("key", "value"))); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("container", "blob", ImmutableMap.of("key", "value"))); assertRequestLineEquals(request, "PUT https://identity.blob.core.windows.net/container/blob?comp=metadata HTTP/1.1"); diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridImageAsyncClientTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridImageAsyncClientTest.java index 82627e11c2..526f7d97a9 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridImageAsyncClientTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridImageAsyncClientTest.java @@ -27,12 +27,12 @@ import org.jclouds.gogrid.functions.ParseImageFromJsonResponse; import org.jclouds.gogrid.functions.ParseImageListFromJsonResponse; import org.jclouds.gogrid.options.GetImageListOptions; import org.jclouds.gogrid.options.SaveImageOptions; -import org.jclouds.http.HttpRequest; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code GridImageAsyncClient} @@ -47,7 +47,7 @@ public class GridImageAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridImageAsyncClient.class.getMethod("getImageList", GetImageListOptions[].class)); - HttpRequest httpRequest = processor.createRequest( + GeneratedHttpRequest httpRequest = processor.createRequest( method, ImmutableList. of( new GetImageListOptions().onlyPublic().setState(ServerImageState.AVAILABLE) .setType(ServerImageType.WEB_APPLICATION_SERVER))); @@ -62,7 +62,7 @@ public class GridImageAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridImageAsyncClient.class.getMethod("getImagesByName", String[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("name1", "name2")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("name1", "name2")); assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/get?v=1.5&" + "name=name1&name=name2 HTTP/1.1"); @@ -86,7 +86,7 @@ public class GridImageAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridImageAsyncClient.class.getMethod("editImageDescription", String.class, String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("imageName", "newDesc")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("imageName", "newDesc")); assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/edit?v=1.5&" + "image=imageName&description=newDesc HTTP/1.1"); @@ -109,7 +109,7 @@ public class GridImageAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridImageAsyncClient.class.getMethod("editImageFriendlyName", String.class, String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("imageName", "newFriendlyName")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("imageName", "newFriendlyName")); assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/edit?v=1.5&" + "image=imageName&friendlyName=newFriendlyName HTTP/1.1"); @@ -132,7 +132,7 @@ public class GridImageAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridImageAsyncClient.class.getMethod("deleteById", long.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(11l)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(11l)); assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/delete?v=1.5&id=11 HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, ""); @@ -159,7 +159,7 @@ public class GridImageAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridImageAsyncClient.class.getMethod("saveImageFromServer", String.class, String.class, SaveImageOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("friendly", "serverName")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("friendly", "serverName")); assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/save?v=1.5&friendlyName=friendly&server=serverName HTTP/1.1"); @@ -176,7 +176,7 @@ public class GridImageAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridImageAsyncClient.class.getMethod("saveImageFromServer", String.class, String.class, SaveImageOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("friendly", "serverName", + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("friendly", "serverName", new SaveImageOptions().withDescription("fooy"))); assertRequestLineEquals( diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridIpAsyncClientTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridIpAsyncClientTest.java index 15baeb4659..b2559d666e 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridIpAsyncClientTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridIpAsyncClientTest.java @@ -23,12 +23,12 @@ import java.io.IOException; import org.jclouds.gogrid.domain.IpType; import org.jclouds.gogrid.functions.ParseIpListFromJsonResponse; import org.jclouds.gogrid.options.GetIpListOptions; -import org.jclouds.http.HttpRequest; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code GridIpAsyncClient} @@ -42,7 +42,7 @@ public class GridIpAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridIpAsyncClient.class.getMethod("getIpList", GetIpListOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(new GetIpListOptions() + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(new GetIpListOptions() .onlyUnassigned().onlyWithType(IpType.PUBLIC))); assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/ip/list?v=1.5&ip.state=Unassigned&" @@ -55,7 +55,7 @@ public class GridIpAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridIpAsyncClient.class.getMethod("getAssignedIpList")); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/ip/list?v=1.5&ip.state=Assigned HTTP/1.1"); @@ -78,7 +78,7 @@ public class GridIpAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridJobAsyncClient.class.getMethod("getJobList", GetJobListOptions[].class)); - HttpRequest httpRequest = processor + GeneratedHttpRequest httpRequest = processor .createRequest(method, ImmutableList. of(startDate(new Date(1267385381770L)).withEndDate(new Date(1267385382770L)) .onlyForObjectType(ObjectType.VIRTUAL_SERVER).onlyForState(JobState.PROCESSING))); @@ -61,7 +61,7 @@ public class GridJobAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridJobAsyncClient.class.getMethod("getJobList", GetJobListOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/job/list?v=1.5 HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, ""); @@ -84,7 +84,7 @@ public class GridJobAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridJobAsyncClient.class.getMethod("getJobsForObjectName", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("MyServer")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("MyServer")); assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/job/list?v=1.5&" + "object=MyServer HTTP/1.1"); @@ -96,7 +96,7 @@ public class GridJobAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridJobAsyncClient.class.getMethod("getJobsById", long[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(123L, 456L)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(123L, 456L)); assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/job/get?v=1.5&" + "id=123&id=456 HTTP/1.1"); @@ -119,7 +119,7 @@ public class GridJobAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridLoadBalancerAsyncClient.class.getMethod("getLoadBalancerList")); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/list?v=1.5 HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, ""); @@ -58,7 +59,7 @@ public class GridLoadBalancerAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridLoadBalancerAsyncClient.class.getMethod("addLoadBalancer", String.class, IpPortPair.class, List.class, AddLoadBalancerOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("BalanceIt", + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("BalanceIt", IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(80).build(), ImmutableList.of(IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(8080).build(), IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(9090).build()), new AddLoadBalancerOptions.Builder().create( LoadBalancerType.LEAST_CONNECTED, LoadBalancerPersistenceType.SSL_STICKY))); - request = request.getFilters().get(0).filter(request); + request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); assertRequestLineEquals(request, addLoadBalancer.getRequestLine()); assertNonPayloadHeadersEqual(request, ""); @@ -108,7 +109,7 @@ public class GridLoadBalancerAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridLoadBalancerAsyncClient.class.getMethod("editLoadBalancer", long.class, List.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1l, ImmutableList.of( + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1l, ImmutableList.of( IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(8080).build(), IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(9090).build()))); @@ -123,7 +124,7 @@ public class GridLoadBalancerAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridLoadBalancerAsyncClient.class.getMethod("editLoadBalancerNamed", String.class, List.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("BalanceIt", ImmutableList.of( + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("BalanceIt", ImmutableList.of( IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(8080).build(), IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(9090).build()))); @@ -150,7 +151,7 @@ public class GridLoadBalancerAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridLoadBalancerAsyncClient.class.getMethod("getLoadBalancersByName", String[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of( + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of( "My Load Balancer", "My Load Balancer 2")); assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/" @@ -175,7 +176,7 @@ public class GridLoadBalancerAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridLoadBalancerAsyncClient.class.getMethod("deleteById", Long.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(55L)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(55L)); assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/" + "delete?v=1.5&id=55 HTTP/1.1"); @@ -199,7 +200,7 @@ public class GridLoadBalancerAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridServerAsyncClient.class.getMethod("getServerList", GetServerListOptions[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of( + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of( new GetServerListOptions.Builder().onlySandboxServers())); assertRequestLineEquals(httpRequest, @@ -57,7 +57,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridServerAsyncClient.class.getMethod("getServersByName", String[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("server1")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("server1")); assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/get?v=1.6&name=server1 HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, ""); @@ -78,7 +78,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridServerAsyncClient.class.getMethod("getServersById", long[].class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(123L)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(123L)); assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/get?v=1.6&id=123 HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, ""); @@ -99,7 +99,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridServerAsyncClient.class.getMethod("power", String.class, PowerCommand.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("PowerServer", + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("PowerServer", PowerCommand.RESTART)); assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/power?v=1.6&" @@ -123,7 +123,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridServerAsyncClient.class.getMethod("deleteByName", String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("PowerServer")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of("PowerServer")); assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/delete?v=1.6&" + "name=PowerServer " + "HTTP/1.1"); @@ -145,7 +145,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridServerAsyncClient.class.getMethod("getRamSizes")); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/common/lookup/list?v=1.6&lookup=server.ram " + "HTTP/1.1"); @@ -168,7 +168,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridServerAsyncClient.class.getMethod("getServerCredentials", long.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1)); assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/support/grid/password/get?v=1.6&id=1 HTTP/1.1"); @@ -194,7 +194,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridServerAsyncClient.class.getMethod("getTypes")); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/common/lookup/list?v=1.6&lookup=server.type HTTP/1.1"); @@ -209,7 +209,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridServerAsyncClient.class.getMethod("editServerDescription", long.class, String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(2, "newDesc")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(2, "newDesc")); assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/edit?v=1.6&" + "id=2&description=newDesc HTTP/1.1"); @@ -220,7 +220,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridServerAsyncClient.class.getMethod("editServerRam", long.class, String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(2, "1GB")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(2, "1GB")); assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/edit?v=1.6&" + "id=2&server.ram=1GB HTTP/1.1"); @@ -242,7 +242,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest method = Invokable.from(GridServerAsyncClient.class.getMethod("editServerType", long.class, String.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(2, "web")); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(2, "web")); assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/edit?v=1.6&" + "id=2&server.type=web HTTP/1.1"); @@ -264,7 +264,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest of(container, name)))); + return cleanRequest(processor.apply(Invocation.create(getMethod, ImmutableList. of(container, name)))); } @Override public HttpRequest signGetBlob(String container, String name, long timeInSeconds) { checkNotNull(container, "container"); checkNotNull(name, "name"); - HttpRequest request = processor.apply(Invocation.create(HPCloudObjectStorageAsyncApi.class, getMethod, - ImmutableList. of(container, name))); + GeneratedHttpRequest request = processor.apply(Invocation.create(getMethod, ImmutableList. of(container, name))); return cleanRequest(signForTemporaryAccess(request, timeInSeconds)); } @@ -137,7 +137,7 @@ public class HPCloudObjectStorageBlobRequestSigner implements BlobRequestSigner public HttpRequest signGetBlob(String container, String name, org.jclouds.blobstore.options.GetOptions options) { checkNotNull(container, "container"); checkNotNull(name, "name"); - return cleanRequest(processor.apply(Invocation.create(HPCloudObjectStorageAsyncApi.class, getMethod, + return cleanRequest(processor.apply(Invocation.create(getMethod, ImmutableList.of(container, name, blob2HttpGetOptions.apply(checkNotNull(options, "options")))))); } @@ -145,7 +145,7 @@ public class HPCloudObjectStorageBlobRequestSigner implements BlobRequestSigner public HttpRequest signPutBlob(String container, Blob blob) { checkNotNull(container, "container"); checkNotNull(blob, "blob"); - return cleanRequest(processor.apply(Invocation.create(HPCloudObjectStorageAsyncApi.class, createMethod, + return cleanRequest(processor.apply(Invocation.create(createMethod, ImmutableList. of(container, blobToObject.apply(blob))))); } @@ -153,7 +153,7 @@ public class HPCloudObjectStorageBlobRequestSigner implements BlobRequestSigner public HttpRequest signPutBlob(String container, Blob blob, long timeInSeconds) { checkNotNull(container, "container"); checkNotNull(blob, "blob"); - HttpRequest request = processor.apply(Invocation.create(HPCloudObjectStorageAsyncApi.class, createMethod, + GeneratedHttpRequest request = processor.apply(Invocation.create(createMethod, ImmutableList. of(container, blobToObject.apply(blob)))); return cleanRequest(signForTemporaryAccess(request, timeInSeconds)); } @@ -162,8 +162,7 @@ public class HPCloudObjectStorageBlobRequestSigner implements BlobRequestSigner public HttpRequest signRemoveBlob(String container, String name) { checkNotNull(container, "container"); checkNotNull(name, "name"); - return cleanRequest(processor.apply(Invocation.create(HPCloudObjectStorageAsyncApi.class, deleteMethod, - ImmutableList. of(container, name)))); + return cleanRequest(processor.apply(Invocation.create(deleteMethod, ImmutableList. of(container, name)))); } private HttpRequest signForTemporaryAccess(HttpRequest request, long timeInSeconds) { diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/AccountAsyncClientTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/AccountAsyncClientTest.java index 1b59b3feb2..e6cc9e2660 100644 --- a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/AccountAsyncClientTest.java +++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/AccountAsyncClientTest.java @@ -21,12 +21,12 @@ package org.jclouds.softlayer.features; import java.io.IOException; import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseJson; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; /** * Tests annotation parsing of {@code AccountAsyncClient} @@ -38,7 +38,7 @@ public class AccountAsyncClientTest extends BaseSoftLayerAsyncClientTest method = Invokable.from(AccountAsyncClient.class.getMethod("getActivePackages")); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals( httpRequest, diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/DatacenterAsyncClientTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/DatacenterAsyncClientTest.java index 5d5743d7fe..fdfe028137 100644 --- a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/DatacenterAsyncClientTest.java +++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/DatacenterAsyncClientTest.java @@ -22,13 +22,13 @@ import java.io.IOException; import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseJson; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; -import com.google.common.reflect.Invokable; /** * Tests annotation parsing of {@code DatacenterAsyncClient} @@ -40,7 +40,7 @@ public class DatacenterAsyncClientTest extends BaseSoftLayerAsyncClientTest method = Invokable.from(DatacenterAsyncClient.class.getMethod("listDatacenters")); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, "GET https://api.softlayer.com/rest/v3/SoftLayer_Location_Datacenter/Datacenters.json?objectMask=locationAddress%3Bregions HTTP/1.1"); @@ -48,8 +48,8 @@ public class DatacenterAsyncClientTest extends BaseSoftLayerAsyncClientTest method = Invokable.from(DatacenterAsyncClient.class.getMethod("getDatacenter", long.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1234)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1234)); assertRequestLineEquals(httpRequest, "GET https://api.softlayer.com/rest/v3/SoftLayer_Location_Datacenter/1234.json?objectMask=locationAddress%3Bregions HTTP/1.1"); diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/ProductPackageAsyncClientTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/ProductPackageAsyncClientTest.java index 1ad0dba81c..f4b3c2e331 100644 --- a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/ProductPackageAsyncClientTest.java +++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/ProductPackageAsyncClientTest.java @@ -21,12 +21,12 @@ package org.jclouds.softlayer.features; import java.io.IOException; import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseJson; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; /** * Tests annotation parsing of {@code ProductPackageAsyncClient} @@ -38,7 +38,7 @@ public class ProductPackageAsyncClientTest extends BaseSoftLayerAsyncClientTest< public void testGetProductPackage() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(ProductPackageAsyncClient.class.getMethod("getProductPackage", long.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1234)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1234)); assertRequestLineEquals( httpRequest, diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/VirtualGuestAsyncClientTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/VirtualGuestAsyncClientTest.java index 2d3162a1f9..36e22d9290 100644 --- a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/VirtualGuestAsyncClientTest.java +++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/VirtualGuestAsyncClientTest.java @@ -23,14 +23,14 @@ import java.io.IOException; import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.Fallbacks.VoidOnNotFoundOr404; -import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseJson; import org.jclouds.http.functions.ReleasePayloadAndReturn; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; -import com.google.common.reflect.Invokable; /** * Tests annotation parsing of {@code VirtualGuestAsyncClient} @@ -42,7 +42,7 @@ public class VirtualGuestAsyncClientTest extends BaseSoftLayerAsyncClientTest method = Invokable.from(VirtualGuestAsyncClient.class.getMethod("listVirtualGuests")); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals( httpRequest, @@ -51,8 +51,8 @@ public class VirtualGuestAsyncClientTest extends BaseSoftLayerAsyncClientTest method = Invokable.from(VirtualGuestAsyncClient.class.getMethod("getVirtualGuest", long.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1234)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1234)); assertRequestLineEquals( httpRequest, @@ -91,7 +91,7 @@ public class VirtualGuestAsyncClientTest extends BaseSoftLayerAsyncClientTest method = Invokable.from(VirtualGuestAsyncClient.class.getMethod("rebootHardVirtualGuest", long.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1234)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1234)); assertRequestLineEquals(httpRequest, "GET https://api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/1234/rebootHard.json HTTP/1.1"); @@ -108,7 +108,7 @@ public class VirtualGuestAsyncClientTest extends BaseSoftLayerAsyncClientTest method = Invokable.from(VirtualGuestAsyncClient.class.getMethod("powerOffVirtualGuest", long.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1234)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1234)); assertRequestLineEquals(httpRequest, "GET https://api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/1234/powerOff.json HTTP/1.1"); @@ -125,7 +125,7 @@ public class VirtualGuestAsyncClientTest extends BaseSoftLayerAsyncClientTest method = Invokable.from(VirtualGuestAsyncClient.class.getMethod("powerOnVirtualGuest", long.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1234)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1234)); assertRequestLineEquals(httpRequest, "GET https://api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/1234/powerOn.json HTTP/1.1"); @@ -142,7 +142,7 @@ public class VirtualGuestAsyncClientTest extends BaseSoftLayerAsyncClientTest method = Invokable.from(VirtualGuestAsyncClient.class.getMethod("pauseVirtualGuest", long.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1234)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1234)); assertRequestLineEquals(httpRequest, "GET https://api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/1234/pause.json HTTP/1.1"); @@ -159,7 +159,7 @@ public class VirtualGuestAsyncClientTest extends BaseSoftLayerAsyncClientTest method = Invokable.from(VirtualGuestAsyncClient.class.getMethod("resumeVirtualGuest", long.class)); - HttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1234)); + GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1234)); assertRequestLineEquals(httpRequest, "GET https://api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/1234/resume.json HTTP/1.1"); diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/TerremarkECloudAsyncClientTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/TerremarkECloudAsyncClientTest.java index 3c3418c514..e368de2780 100644 --- a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/TerremarkECloudAsyncClientTest.java +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/TerremarkECloudAsyncClientTest.java @@ -27,10 +27,11 @@ import java.net.URI; import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.Fallbacks.VoidOnNotFoundOr404; -import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; +import org.jclouds.reflect.Invokable; import org.jclouds.rest.ResourceNotFoundException; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.trmk.vcloud_0_8.domain.Protocol; import org.jclouds.trmk.vcloud_0_8.functions.ParseTaskFromLocationHeader; import org.jclouds.trmk.vcloud_0_8.options.AddInternetServiceOptions; @@ -57,7 +58,6 @@ import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code TerremarkECloudAsyncClient} @@ -76,7 +76,7 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie public void testNetwork() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("getNetwork", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of( + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of( URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdcItem/2"))); assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/vdcItem/2 HTTP/1.1"); @@ -92,7 +92,7 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie public void testDelete() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("deleteVApp", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of( + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of( URI.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/1"))); assertRequestLineEquals(request, "DELETE https://vcloud.safesecureweb.com/api/v0.8/vApp/1 HTTP/1.1"); @@ -109,7 +109,7 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie public void testFindNetworkInOrgVDCNamed() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("findNetworkInOrgVDCNamed", String.class, String.class, String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("org", "vdc", "network")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("org", "vdc", "network")); assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/network/1990 HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.network+xml\n"); @@ -127,7 +127,7 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie */ public void testCatalog() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("getCatalog", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://catalog"))); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://catalog"))); assertRequestLineEquals(request, "GET https://catalog HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalog+xml\n"); @@ -142,7 +142,7 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie public void testGetVDC() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("getVDC", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/vdc/1"))); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/vdc/1"))); assertRequestLineEquals(request, "GET https://vcloud/vdc/1 HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vdc+xml\n"); @@ -158,7 +158,7 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie public void testInstantiateVAppTemplateInVDCURI() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", URI.class, URI.class, String.class, InstantiateVAppTemplateOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of( + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of( URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), URI.create("https://vcloud/vAppTemplate/3"), "name")); @@ -180,7 +180,7 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie IOException { Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", URI.class, URI.class, String.class, InstantiateVAppTemplateOptions[].class)); - HttpRequest request = processor.createRequest( + GeneratedHttpRequest request = processor.createRequest( method, ImmutableList. of( URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), URI.create("https://vcloud/vAppTemplate/3"), @@ -205,7 +205,7 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie public void testActivatePublicIpInVDC() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("activatePublicIpInVDC", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of( + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of( URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"))); assertRequestLineEquals(request, "POST https://vcloud.safesecureweb.com/api/v0.8/publicIps/1 HTTP/1.1"); @@ -221,7 +221,7 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie public void testGetAllInternetServices() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("getAllInternetServicesInVDC", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of( + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of( URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"))); assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/internetServices/1 HTTP/1.1"); @@ -237,7 +237,7 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie public void testGetInternetService() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("getInternetService", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/internetService/12"))); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/internetService/12"))); assertRequestLineEquals(request, "GET https://vcloud/extensions/internetService/12 HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.ecloud.internetServicesList+xml\n"); @@ -252,7 +252,7 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie public void testDeleteInternetService() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("deleteInternetService", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/internetService/12"))); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/internetService/12"))); assertRequestLineEquals(request, "DELETE https://vcloud/extensions/internetService/12 HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); @@ -268,7 +268,7 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie public void testAddInternetServiceToExistingIp() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("addInternetServiceToExistingIp", URI.class, String.class, Protocol.class, int.class, AddInternetServiceOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/publicIp/12"), + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/publicIp/12"), "name", Protocol.TCP, 22)); assertRequestLineEquals(request, "POST https://vcloud/extensions/publicIp/12/internetServices HTTP/1.1"); @@ -289,7 +289,7 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie public void testAddInternetServiceToExistingIpOptions() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("addInternetServiceToExistingIp", URI.class, String.class, Protocol.class, int.class, AddInternetServiceOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/publicIp/12"), + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/publicIp/12"), "name", Protocol.TCP, 22, disabled().withDescription("yahoo").monitorDisabled())); assertRequestLineEquals(request, "POST https://vcloud/extensions/publicIp/12/internetServices HTTP/1.1"); @@ -308,7 +308,7 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie public void testAddNode() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("addNode", URI.class, String.class, String.class, int.class, AddNodeOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/internetService/12"), + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/internetService/12"), "10.2.2.2", "name", 22)); assertRequestLineEquals(request, "POST https://vcloud/extensions/internetService/12/nodeServices HTTP/1.1"); @@ -329,7 +329,7 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie public void testAddNodeOptions() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("addNode", URI.class, String.class, String.class, int.class, AddNodeOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/internetService/12"), + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/internetService/12"), "10.2.2.2", "name", 22, AddNodeOptions.Builder.disabled().withDescription("yahoo"))); assertRequestLineEquals(request, "POST https://vcloud/extensions/internetService/12/nodeServices HTTP/1.1"); @@ -349,7 +349,7 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie public void testGetKeyPairInOrg() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("findKeyPairInOrg", URI.class, String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of( + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of( URI.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"), "keyPair")); assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/keysList/1 HTTP/1.1"); @@ -366,7 +366,7 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie public void testConfigureNodeWithDescription() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("configureNode", URI.class, String.class, boolean.class, String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/nodeService/12"), + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/nodeService/12"), "name", true, "eggs")); assertRequestLineEquals(request, "PUT https://vcloud/extensions/nodeService/12 HTTP/1.1"); @@ -385,7 +385,7 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie public void testConfigureNodeNoDescription() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("configureNode", URI.class, String.class, boolean.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(URI.create("https://vcloud/extensions/nodeService/12"), + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(URI.create("https://vcloud/extensions/nodeService/12"), "name", true, null)); assertRequestLineEquals(request, "PUT https://vcloud/extensions/nodeService/12 HTTP/1.1"); @@ -403,7 +403,7 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie public void testGetNodes() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("getNodes", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/internetService/12"))); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/internetService/12"))); assertRequestLineEquals(request, "GET https://vcloud/extensions/internetService/12/nodeServices HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.vCloud.nodeService+xml\n"); @@ -418,7 +418,7 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie public void testDeleteNode() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("deleteNode", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/nodeService/12"))); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/nodeService/12"))); assertRequestLineEquals(request, "DELETE https://vcloud/extensions/nodeService/12 HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); @@ -433,7 +433,7 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie public void testGetCustomizationOptionsOfCatalogItem() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("getCustomizationOptions", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/template/12"))); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/template/12"))); assertRequestLineEquals(request, "GET https://vcloud/extensions/template/12 HTTP/1.1"); assertNonPayloadHeadersEqual(request, @@ -449,7 +449,7 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie public void testListKeyPairsInOrg() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("listKeyPairsInOrg", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of( + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of( URI.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"))); assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/keysList/1 HTTP/1.1"); @@ -471,7 +471,7 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie public void testGetKeyPair() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("getKeyPair", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/key/12"))); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/key/12"))); assertRequestLineEquals(request, "GET https://vcloud/extensions/key/12 HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/xml\n"); @@ -486,7 +486,7 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie public void testDeleteKeyPair() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("deleteKeyPair", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/key/12"))); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/key/12"))); assertRequestLineEquals(request, "DELETE https://vcloud/extensions/key/12 HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); @@ -501,7 +501,7 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie public void testGetNode() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("getNode", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/nodeService/12"))); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/nodeService/12"))); assertRequestLineEquals(request, "GET https://vcloud/extensions/nodeService/12 HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.vCloud.nodeService+xml\n"); @@ -516,7 +516,7 @@ public class TerremarkECloudAsyncClientTest extends BaseTerremarkECloudAsyncClie public void testGetExtendedInfo() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TerremarkECloudAsyncClient.class.getMethod("getVAppExtendedInfo", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/vapp/12"))); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/vapp/12"))); assertRequestLineEquals(request, "GET https://vcloud/extensions/vapp/12 HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.ecloud.vApp+xml\n"); diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/features/DataCenterOperationsAsyncClientTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/features/DataCenterOperationsAsyncClientTest.java index 59f9a0c3e4..73b97c776f 100644 --- a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/features/DataCenterOperationsAsyncClientTest.java +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/features/DataCenterOperationsAsyncClientTest.java @@ -22,14 +22,14 @@ import java.io.IOException; import java.net.URI; import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; -import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.trmk.ecloud.BaseTerremarkECloudAsyncClientTest; import org.jclouds.trmk.vcloud_0_8.xml.DataCentersHandler; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code DataCenterOperationsAsyncClient} @@ -44,7 +44,7 @@ public class DataCenterOperationsAsyncClientTest extends public void testlistDataCenters() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(DataCenterOperationsAsyncClient.class.getMethod("listDataCenters", URI.class)); - HttpRequest request = processor + GeneratedHttpRequest request = processor .createRequest( method, ImmutableList. of( URI.create("https://services.enterprisecloud.terremark.com/api/v0.8b-ext2.8/extensions/org/1910324/dataCenters"))); @@ -63,7 +63,7 @@ public class DataCenterOperationsAsyncClientTest extends public void testlistDataCentersInOrg() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(DataCenterOperationsAsyncClient.class.getMethod("listDataCentersInOrg", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of( + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of( URI.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"))); assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/datacentersList/1 HTTP/1.1"); diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/features/TagOperationsAsyncClientTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/features/TagOperationsAsyncClientTest.java index 64243a77d9..c52fd41ea5 100644 --- a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/features/TagOperationsAsyncClientTest.java +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/features/TagOperationsAsyncClientTest.java @@ -22,14 +22,14 @@ import java.io.IOException; import java.net.URI; import org.jclouds.Fallbacks.EmptyMapOnNotFoundOr404; -import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; +import org.jclouds.reflect.Invokable; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.trmk.ecloud.BaseTerremarkECloudAsyncClientTest; import org.jclouds.trmk.ecloud.xml.TagNameToUsageCountHandler; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.Invokable; /** * Tests behavior of {@code TagOperationsAsyncClient} @@ -43,7 +43,7 @@ public class TagOperationsAsyncClientTest extends BaseTerremarkECloudAsyncClient public void testgetTagNameToUsageCount() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TagOperationsAsyncClient.class.getMethod("getTagNameToUsageCount", URI.class)); - HttpRequest request = processor + GeneratedHttpRequest request = processor .createRequest( method, ImmutableList. of( URI.create("https://services.enterprisecloud.terremark.com/api/v0.8b-ext2.8/extensions/org/1910324/deviceTags"))); @@ -62,7 +62,7 @@ public class TagOperationsAsyncClientTest extends BaseTerremarkECloudAsyncClient public void testgetTagNameToUsageCountInOrg() throws SecurityException, NoSuchMethodException, IOException { Invokable method = Invokable.from(TagOperationsAsyncClient.class.getMethod("getTagNameToUsageCountInOrg", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of( + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of( URI.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"))); assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/deviceTags/1 HTTP/1.1"); diff --git a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressAsyncClientTest.java b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressAsyncClientTest.java index 2a42406c87..3829a96f79 100644 --- a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressAsyncClientTest.java +++ b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressAsyncClientTest.java @@ -43,10 +43,12 @@ import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.providers.ProviderMetadata; +import org.jclouds.reflect.Invokable; import org.jclouds.rest.AuthorizationException; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.ResourceNotFoundException; import org.jclouds.rest.internal.BaseAsyncClientTest; +import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.trmk.vcloud_0_8.domain.Org; import org.jclouds.trmk.vcloud_0_8.domain.Protocol; import org.jclouds.trmk.vcloud_0_8.domain.ReferenceType; @@ -86,7 +88,6 @@ import com.google.common.base.Suppliers; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; -import com.google.common.reflect.Invokable; import com.google.inject.AbstractModule; import com.google.inject.Module; import com.google.inject.TypeLiteral; @@ -108,7 +109,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("getCatalogItem", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of( + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of( URI.create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/2"))); assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/catalogItem/2 HTTP/1.1"); @@ -124,7 +125,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("deleteVApp", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of( + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of( URI.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/1"))); assertRequestLineEquals(request, "DELETE https://vcloud.safesecureweb.com/api/v0.8/vApp/1 HTTP/1.1"); @@ -141,7 +142,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("findCatalogItemInOrgCatalogNamed", String.class, String.class, String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of("org", "catalog", "item")); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("org", "catalog", "item")); assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/catalogItem/1 HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalogItem+xml\n"); @@ -159,7 +160,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("getCatalog", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://catalog"))); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://catalog"))); assertRequestLineEquals(request, "GET https://catalog HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalog+xml\n"); @@ -174,7 +175,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("getVDC", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/vdc/1"))); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/vdc/1"))); assertRequestLineEquals(request, "GET https://vcloud/vdc/1 HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vdc+xml\n"); @@ -190,7 +191,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", URI.class, URI.class, String.class, InstantiateVAppTemplateOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of( + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of( URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), URI.create("https://vcloud/vAppTemplate/3"), "name")); @@ -212,7 +213,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", URI.class, URI.class, String.class, InstantiateVAppTemplateOptions[].class)); - HttpRequest request = processor.createRequest( + GeneratedHttpRequest request = processor.createRequest( method, ImmutableList. of( URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), URI.create("https://vcloud/vAppTemplate/3"), @@ -238,7 +239,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("addInternetServiceToVDC", URI.class, String.class, Protocol.class, int.class, AddInternetServiceOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of( + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of( URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), "name", Protocol.TCP, 22)); assertRequestLineEquals(request, "POST https://vcloud.safesecureweb.com/api/v0.8/internetServices/1 HTTP/1.1"); @@ -257,7 +258,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("addInternetServiceToVDC", URI.class, String.class, Protocol.class, int.class, AddInternetServiceOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI .create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), "name", Protocol.TCP, 22, disabled() .withDescription("yahoo"))); @@ -275,7 +276,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("getAllInternetServicesInVDC", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of( + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of( URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"))); assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/internetServices/1 HTTP/1.1"); @@ -291,7 +292,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("getInternetService", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/internetService/12"))); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/internetService/12"))); assertRequestLineEquals(request, "GET https://vcloud/extensions/internetService/12 HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.vCloud.internetServicesList+xml\n"); @@ -306,7 +307,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("deleteInternetService", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/internetService/12"))); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/internetService/12"))); assertRequestLineEquals(request, "DELETE https://vcloud/extensions/internetService/12 HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); @@ -322,7 +323,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("addInternetServiceToExistingIp", URI.class, String.class, Protocol.class, int.class, AddInternetServiceOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/publicIp/12"), + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/publicIp/12"), "name", Protocol.TCP, 22)); assertRequestLineEquals(request, "POST https://vcloud/extensions/publicIp/12/internetServices HTTP/1.1"); @@ -341,7 +342,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("addInternetServiceToExistingIp", URI.class, String.class, Protocol.class, int.class, AddInternetServiceOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/publicIp/12"), + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/publicIp/12"), "name", Protocol.TCP, 22, disabled().withDescription("yahoo"))); assertRequestLineEquals(request, "POST https://vcloud/extensions/publicIp/12/internetServices HTTP/1.1"); @@ -359,7 +360,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("addNode", URI.class, String.class, String.class, int.class, AddNodeOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/internetService/12"), + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/internetService/12"), "10.2.2.2", "name", 22)); assertRequestLineEquals(request, "POST https://vcloud/extensions/internetService/12/nodeServices HTTP/1.1"); @@ -378,7 +379,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("addNode", URI.class, String.class, String.class, int.class, AddNodeOptions[].class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/internetService/12"), + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/internetService/12"), "10.2.2.2", "name", 22, AddNodeOptions.Builder.disabled().withDescription("yahoo"))); assertRequestLineEquals(request, "POST https://vcloud/extensions/internetService/12/nodeServices HTTP/1.1"); @@ -396,7 +397,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("findKeyPairInOrg", URI.class, String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of( + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of( URI.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"), "keyPair")); assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/keysList/1 HTTP/1.1"); @@ -413,7 +414,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("configureNode", URI.class, String.class, boolean.class, String.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/nodeService/12"), + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/nodeService/12"), "name", true, "eggs")); assertRequestLineEquals(request, "PUT https://vcloud/extensions/nodeService/12 HTTP/1.1"); @@ -432,7 +433,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("configureNode", URI.class, String.class, boolean.class, String.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList(URI.create("https://vcloud/extensions/nodeService/12"), + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(URI.create("https://vcloud/extensions/nodeService/12"), "name", true, null)); assertRequestLineEquals(request, "PUT https://vcloud/extensions/nodeService/12 HTTP/1.1"); @@ -450,7 +451,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("getNodes", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/internetService/12"))); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/internetService/12"))); assertRequestLineEquals(request, "GET https://vcloud/extensions/internetService/12/nodeServices HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.vCloud.nodeService+xml\n"); @@ -465,7 +466,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("deleteNode", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/nodeService/12"))); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/nodeService/12"))); assertRequestLineEquals(request, "DELETE https://vcloud/extensions/nodeService/12 HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); @@ -480,7 +481,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("getCustomizationOptions", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of( + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of( URI.create("https://vcloud/extensions/template/12/options/customization"))); assertRequestLineEquals(request, "GET https://vcloud/extensions/template/12/options/customization HTTP/1.1"); @@ -497,7 +498,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("listKeyPairsInOrg", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of( + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of( URI.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"))); assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/keysList/1 HTTP/1.1"); @@ -513,7 +514,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("listKeyPairsInOrg", URI.class)); - HttpRequest request = processor.createRequest(method, Lists. newArrayList((URI) null)); + GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((URI) null)); assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/keysList/1 HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.vcloudExpress.keysList+xml\n"); @@ -534,7 +535,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("getNode", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/nodeService/12"))); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/nodeService/12"))); assertRequestLineEquals(request, "GET https://vcloud/extensions/nodeService/12 HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.vCloud.nodeService+xml\n"); @@ -549,7 +550,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("getKeyPair", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/key/12"))); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/key/12"))); assertRequestLineEquals(request, "GET https://vcloud/extensions/key/12 HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Accept: application/xml\n"); @@ -564,7 +565,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest method = Invokable.from(TerremarkVCloudExpressAsyncClient.class.getMethod("deleteKeyPair", URI.class)); - HttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/key/12"))); + GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(URI.create("https://vcloud/extensions/key/12"))); assertRequestLineEquals(request, "DELETE https://vcloud/extensions/key/12 HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); diff --git a/sandbox-apis/nirvanix/src/test/java/org/jclouds/nirvanix/sdn/SDNAsyncClientTest.java b/sandbox-apis/nirvanix/src/test/java/org/jclouds/nirvanix/sdn/SDNAsyncClientTest.java index 0a00db3f99..b4620aebd6 100644 --- a/sandbox-apis/nirvanix/src/test/java/org/jclouds/nirvanix/sdn/SDNAsyncClientTest.java +++ b/sandbox-apis/nirvanix/src/test/java/org/jclouds/nirvanix/sdn/SDNAsyncClientTest.java @@ -60,7 +60,7 @@ public class SDNAsyncClientTest extends RestClientTest { public void testGetStorageNode() throws SecurityException, NoSuchMethodException, IOException { Method method = SDNAsyncClient.class.getMethod("getStorageNode", String.class, long.class); - HttpRequest request = processor.createRequest(method, "adriansmovies", 734859264); + GeneratedHttpRequest request = processor.createRequest(method, "adriansmovies", 734859264); assertRequestLineEquals( request, @@ -79,7 +79,7 @@ public class SDNAsyncClientTest extends RestClientTest { public void testUpload() throws SecurityException, NoSuchMethodException, IOException { Method method = SDNAsyncClient.class.getMethod("upload", URI.class, String.class, String.class, Blob.class); Blob blob = BindBlobToMultipartFormTest.TEST_BLOB; - HttpRequest request = processor.createRequest(method, URI.create("http://uploader"), "token", "adriansmovies", + GeneratedHttpRequest request = processor.createRequest(method, URI.create("http://uploader"), "token", "adriansmovies", blob); assertRequestLineEquals(request, @@ -103,7 +103,7 @@ public class SDNAsyncClientTest extends RestClientTest { public void testSetMetadata() throws SecurityException, NoSuchMethodException, IOException { Method method = SDNAsyncClient.class.getMethod("setMetadata", String.class, Map.class); - HttpRequest request = processor.createRequest(method, "adriansmovies/sushi.avi", ImmutableMap.of("Chef", + GeneratedHttpRequest request = processor.createRequest(method, "adriansmovies/sushi.avi", ImmutableMap.of("Chef", "Kawasaki")); assertRequestLineEquals( @@ -121,7 +121,7 @@ public class SDNAsyncClientTest extends RestClientTest { public void testGetMetadata() throws SecurityException, NoSuchMethodException, IOException { Method method = SDNAsyncClient.class.getMethod("getMetadata", String.class); - HttpRequest request = processor.createRequest(method, "adriansmovies/sushi.avi"); + GeneratedHttpRequest request = processor.createRequest(method, "adriansmovies/sushi.avi"); assertRequestLineEquals(request, "GET http://services.nirvanix.com/ws/Metadata/GetMetadata.ashx?output=json&path=adriansmovies/sushi.avi HTTP/1.1"); @@ -137,7 +137,7 @@ public class SDNAsyncClientTest extends RestClientTest { public void testGetFile() throws SecurityException, NoSuchMethodException, IOException { Method method = SDNAsyncClient.class.getMethod("getFile", String.class); - HttpRequest request = processor.createRequest(method, "adriansmovies/sushi.avi"); + GeneratedHttpRequest request = processor.createRequest(method, "adriansmovies/sushi.avi"); assertRequestLineEquals(request, "GET http://services.nirvanix.com/adriansmovies/sushi.avi?output=json HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); diff --git a/sandbox-apis/nirvanix/src/test/java/org/jclouds/nirvanix/sdn/SDNAuthAsyncClientTest.java b/sandbox-apis/nirvanix/src/test/java/org/jclouds/nirvanix/sdn/SDNAuthAsyncClientTest.java index 3e47746bdd..3243ffd95f 100644 --- a/sandbox-apis/nirvanix/src/test/java/org/jclouds/nirvanix/sdn/SDNAuthAsyncClientTest.java +++ b/sandbox-apis/nirvanix/src/test/java/org/jclouds/nirvanix/sdn/SDNAuthAsyncClientTest.java @@ -44,7 +44,7 @@ public class SDNAuthAsyncClientTest extends RestClientTest { public void testAuthenticate() throws SecurityException, NoSuchMethodException, IOException { Method method = SDNAuthAsyncClient.class.getMethod("authenticate", String.class, String.class, String.class); - HttpRequest httpRequest = processor.createRequest(method, "apple", "foo", "bar"); + GeneratedHttpRequest httpRequest = processor.createRequest(method, "apple", "foo", "bar"); assertRequestLineEquals(httpRequest, "GET http://localhost:8080/ws/Authentication/Login.ashx?output=json&appKey=apple&password=bar&username=foo HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, ""); diff --git a/sandbox-apis/nirvanix/src/test/java/org/jclouds/nirvanix/sdn/filters/InsertUserContextIntoPathTest.java b/sandbox-apis/nirvanix/src/test/java/org/jclouds/nirvanix/sdn/filters/InsertUserContextIntoPathTest.java index 96fbf2f89a..3d278d6a85 100644 --- a/sandbox-apis/nirvanix/src/test/java/org/jclouds/nirvanix/sdn/filters/InsertUserContextIntoPathTest.java +++ b/sandbox-apis/nirvanix/src/test/java/org/jclouds/nirvanix/sdn/filters/InsertUserContextIntoPathTest.java @@ -55,7 +55,7 @@ public class InsertUserContextIntoPathTest extends RestClientTest { private Method method; public void testRequestInvalid() { - HttpRequest request = processor.createRequest(method, URI.create("https://host/path")); + GeneratedHttpRequest request = processor.createRequest(method, URI.create("https://host/path")); request = filter.filter(request); request = filter.filter(request); assertEquals(request.getEndpoint().getPath(), "/sessiontoken/appname/username/path"); @@ -63,14 +63,14 @@ public class InsertUserContextIntoPathTest extends RestClientTest { } public void testRequestNoSession() { - HttpRequest request = processor.createRequest(method, URI.create("https://host/path")); + GeneratedHttpRequest request = processor.createRequest(method, URI.create("https://host/path")); request = filter.filter(request); assertEquals(request.getEndpoint().getPath(), "/sessiontoken/appname/username/path"); assertEquals(request.getEndpoint().getHost(), "host"); } public void testRequestAlreadyHasSession() { - HttpRequest request = processor.createRequest(method, URI.create("https://host/sessiontoken/appname/username/path")); + GeneratedHttpRequest request = processor.createRequest(method, URI.create("https://host/sessiontoken/appname/username/path")); request = filter.filter(request); assertEquals(request.getEndpoint().getPath(), "/sessiontoken/appname/username/path"); assertEquals(request.getEndpoint().getHost(), "host"); diff --git a/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/PCSAsyncClientTest.java b/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/PCSAsyncClientTest.java index b9f19688a1..3e4614e569 100644 --- a/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/PCSAsyncClientTest.java +++ b/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/PCSAsyncClientTest.java @@ -70,7 +70,7 @@ public class PCSAsyncClientTest extends RestClientTest { public void testList() throws SecurityException, NoSuchMethodException, IOException { Method method = PCSAsyncClient.class.getMethod("list"); - HttpRequest request = processor.createRequest(method); + GeneratedHttpRequest request = processor.createRequest(method); assertRequestLineEquals(request, "GET http://root HTTP/1.1"); assertNonPayloadHeadersEqual(request, "X-Cloud-Depth: 2\n"); @@ -85,7 +85,7 @@ public class PCSAsyncClientTest extends RestClientTest { public void testCreateContainer() throws SecurityException, NoSuchMethodException, IOException { Method method = PCSAsyncClient.class.getMethod("createContainer", String.class); - HttpRequest request = processor.createRequest(method, "container"); + GeneratedHttpRequest request = processor.createRequest(method, "container"); assertRequestLineEquals(request, "POST http://root/contents HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); @@ -102,7 +102,7 @@ public class PCSAsyncClientTest extends RestClientTest { public void testDeleteContainer() throws SecurityException, NoSuchMethodException, IOException { Method method = PCSAsyncClient.class.getMethod("deleteContainer", URI.class); - HttpRequest request = processor.createRequest(method, URI.create("http://localhost/container/1234")); + GeneratedHttpRequest request = processor.createRequest(method, URI.create("http://localhost/container/1234")); assertRequestLineEquals(request, "DELETE http://localhost/container/1234 HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); @@ -117,7 +117,7 @@ public class PCSAsyncClientTest extends RestClientTest { public void testListURI() throws SecurityException, NoSuchMethodException, IOException { Method method = PCSAsyncClient.class.getMethod("list", URI.class); - HttpRequest request = processor.createRequest(method, URI.create("http://localhost/mycontainer")); + GeneratedHttpRequest request = processor.createRequest(method, URI.create("http://localhost/mycontainer")); assertRequestLineEquals(request, "GET http://localhost/mycontainer HTTP/1.1"); assertNonPayloadHeadersEqual(request, "X-Cloud-Depth: 2\n"); @@ -132,7 +132,7 @@ public class PCSAsyncClientTest extends RestClientTest { public void testGetFileInfo() throws SecurityException, NoSuchMethodException, IOException { Method method = PCSAsyncClient.class.getMethod("getFileInfo", URI.class); - HttpRequest request = processor.createRequest(method, URI.create("http://localhost/myfile")); + GeneratedHttpRequest request = processor.createRequest(method, URI.create("http://localhost/myfile")); assertRequestLineEquals(request, "GET http://localhost/myfile HTTP/1.1"); assertNonPayloadHeadersEqual(request, "X-Cloud-Depth: 2\n"); @@ -147,7 +147,7 @@ public class PCSAsyncClientTest extends RestClientTest { public void testUploadFile() throws SecurityException, NoSuchMethodException, IOException { Method method = PCSAsyncClient.class.getMethod("uploadFile", URI.class, PCSFile.class); - HttpRequest request = processor.createRequest(method, URI.create("http://localhost/mycontainer"), blobToPCSFile + GeneratedHttpRequest request = processor.createRequest(method, URI.create("http://localhost/mycontainer"), blobToPCSFile .apply(BindBlobToMultipartFormTest.TEST_BLOB)); assertRequestLineEquals(request, "POST http://localhost/mycontainer/contents HTTP/1.1"); @@ -166,7 +166,7 @@ public class PCSAsyncClientTest extends RestClientTest { public void testUploadBlock() throws SecurityException, NoSuchMethodException, IOException { Method method = PCSAsyncClient.class.getMethod("uploadBlock", URI.class, PCSFile.class, Array.newInstance( PutBlockOptions.class, 0).getClass()); - HttpRequest request = processor.createRequest(method, URI.create("http://localhost/mycontainer"), blobToPCSFile + GeneratedHttpRequest request = processor.createRequest(method, URI.create("http://localhost/mycontainer"), blobToPCSFile .apply(BindBlobToMultipartFormTest.TEST_BLOB)); assertRequestLineEquals(request, "PUT http://localhost/mycontainer/content HTTP/1.1"); @@ -182,7 +182,7 @@ public class PCSAsyncClientTest extends RestClientTest { public void testDownloadFile() throws SecurityException, NoSuchMethodException, IOException { Method method = PCSAsyncClient.class.getMethod("downloadFile", URI.class); - HttpRequest request = processor.createRequest(method, URI.create("http://localhost/container")); + GeneratedHttpRequest request = processor.createRequest(method, URI.create("http://localhost/container")); assertRequestLineEquals(request, "GET http://localhost/container/content HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); @@ -198,7 +198,7 @@ public class PCSAsyncClientTest extends RestClientTest { public void testDeleteFile() throws SecurityException, NoSuchMethodException, IOException { Method method = PCSAsyncClient.class.getMethod("deleteFile", URI.class); - HttpRequest request = processor.createRequest(method, + GeneratedHttpRequest request = processor.createRequest(method, new Object[] { URI.create("http://localhost/contents/file") }); assertRequestLineEquals(request, "DELETE http://localhost/contents/file HTTP/1.1"); @@ -214,7 +214,7 @@ public class PCSAsyncClientTest extends RestClientTest { public void testPutMetadata() throws SecurityException, NoSuchMethodException, IOException { Method method = PCSAsyncClient.class.getMethod("putMetadataItem", URI.class, String.class, String.class); - HttpRequest request = processor.createRequest(method, URI.create("http://localhost/contents/file"), "pow", "bar"); + GeneratedHttpRequest request = processor.createRequest(method, URI.create("http://localhost/contents/file"), "pow", "bar"); assertRequestLineEquals(request, "PUT http://localhost/contents/file/metadata/pow HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); @@ -230,7 +230,7 @@ public class PCSAsyncClientTest extends RestClientTest { public void testAddEntryToMap() throws SecurityException, NoSuchMethodException, IOException { Method method = PCSAsyncClient.class.getMethod("addMetadataItemToMap", URI.class, String.class, Map.class); - HttpRequest request = processor.createRequest(method, URI.create("http://localhost/pow"), "newkey", ImmutableMap + GeneratedHttpRequest request = processor.createRequest(method, URI.create("http://localhost/pow"), "newkey", ImmutableMap .of("key", "value")); assertRequestLineEquals(request, "GET http://localhost/pow/metadata/newkey HTTP/1.1"); diff --git a/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/PCSCloudAsyncClientTest.java b/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/PCSCloudAsyncClientTest.java index 0a06eb983f..d23b5816d2 100644 --- a/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/PCSCloudAsyncClientTest.java +++ b/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/PCSCloudAsyncClientTest.java @@ -47,7 +47,7 @@ public class PCSCloudAsyncClientTest extends RestClientTest public void testAuthenticate() throws SecurityException, NoSuchMethodException, IOException { Method method = PCSCloudAsyncClient.class.getMethod("authenticate"); - HttpRequest request = processor.createRequest(method); + GeneratedHttpRequest request = processor.createRequest(method); assertRequestLineEquals(request, "GET http://localhost:8080/v3 HTTP/1.1"); assertNonPayloadHeadersEqual(request, ""); diff --git a/sandbox-apis/simpledb/src/test/java/org/jclouds/simpledb/SimpleDBAsyncClientTest.java b/sandbox-apis/simpledb/src/test/java/org/jclouds/simpledb/SimpleDBAsyncClientTest.java index 8cf7eec063..105df02838 100644 --- a/sandbox-apis/simpledb/src/test/java/org/jclouds/simpledb/SimpleDBAsyncClientTest.java +++ b/sandbox-apis/simpledb/src/test/java/org/jclouds/simpledb/SimpleDBAsyncClientTest.java @@ -62,7 +62,7 @@ public class SimpleDBAsyncClientTest extends RestClientTest public void testListDomainsInRegion() throws SecurityException, NoSuchMethodException, IOException { Method method = SimpleDBAsyncClient.class.getMethod("listDomainsInRegion", String.class, ListDomainsOptions[].class); - HttpRequest request = processor.createRequest(method); + GeneratedHttpRequest request = processor.createRequest(method); assertRequestLineEquals(request, "POST https://sdb.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: sdb.amazonaws.com\n"); @@ -77,7 +77,7 @@ public class SimpleDBAsyncClientTest extends RestClientTest public void testCreateDomainInRegion() throws SecurityException, NoSuchMethodException, IOException { Method method = SimpleDBAsyncClient.class.getMethod("createDomainInRegion", String.class, String.class); - HttpRequest request = processor.createRequest(method, null, "domainName"); + GeneratedHttpRequest request = processor.createRequest(method, null, "domainName"); assertRequestLineEquals(request, "POST https://sdb.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: sdb.amazonaws.com\n"); @@ -95,7 +95,7 @@ public class SimpleDBAsyncClientTest extends RestClientTest @Test(enabled = false) public void testPutAttributes() throws SecurityException, NoSuchMethodException, IOException { Method method = SimpleDBAsyncClient.class.getMethod("putAttributes", String.class, String.class, Map.class); - HttpRequest request = processor.createRequest(method, null, "domainName"); + GeneratedHttpRequest request = processor.createRequest(method, null, "domainName"); assertRequestLineEquals(request, "POST https://sdb.amazonaws.com/ HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: sdb.amazonaws.com\n"); diff --git a/sandbox-providers/azurequeue/src/test/java/org/jclouds/azurequeue/AzureQueueAsyncClientTest.java b/sandbox-providers/azurequeue/src/test/java/org/jclouds/azurequeue/AzureQueueAsyncClientTest.java index dd3c9e4290..7b240eb1c5 100644 --- a/sandbox-providers/azurequeue/src/test/java/org/jclouds/azurequeue/AzureQueueAsyncClientTest.java +++ b/sandbox-providers/azurequeue/src/test/java/org/jclouds/azurequeue/AzureQueueAsyncClientTest.java @@ -59,7 +59,7 @@ public class AzureQueueAsyncClientTest extends RestClientTest { public void testGetMyMentions() throws SecurityException, NoSuchMethodException, IOException { Method method = TwitterAsyncClient.class.getMethod("getMyMentions"); - HttpRequest httpRequest = processor.createRequest(method); + GeneratedHttpRequest httpRequest = processor.createRequest(method); assertRequestLineEquals(httpRequest, "GET http://api.twitter.com/statuses/mentions.json HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n"); assertPayloadEquals(httpRequest, null, null, false); // now make sure request filters apply by replaying - httpRequest = Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest); - httpRequest = Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest); + httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest); + httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest); assertRequestLineEquals(httpRequest, "GET http://api.twitter.com/statuses/mentions.json HTTP/1.1"); // for example, using basic authentication, we should get "only one"