diff --git a/atmosonline/saas/core/src/main/java/org/jclouds/atmosonline/saas/filters/SignRequest.java b/atmosonline/saas/core/src/main/java/org/jclouds/atmosonline/saas/filters/SignRequest.java index 8bb6769639..cd439c342d 100644 --- a/atmosonline/saas/core/src/main/java/org/jclouds/atmosonline/saas/filters/SignRequest.java +++ b/atmosonline/saas/core/src/main/java/org/jclouds/atmosonline/saas/filters/SignRequest.java @@ -34,12 +34,14 @@ import javax.inject.Provider; import javax.inject.Singleton; import javax.ws.rs.core.HttpHeaders; +import org.apache.commons.io.IOUtils; import org.jclouds.atmosonline.saas.reference.AtmosStorageConstants; import org.jclouds.atmosonline.saas.reference.AtmosStorageHeaders; import org.jclouds.http.HttpException; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequestFilter; import org.jclouds.http.HttpUtils; +import org.jclouds.http.internal.SignatureWire; import org.jclouds.util.TimeStamp; import com.google.common.annotations.VisibleForTesting; @@ -54,14 +56,17 @@ import com.google.common.annotations.VisibleForTesting; @Singleton public class SignRequest implements HttpRequestFilter { + private final SignatureWire signatureWire; private final String uid; private final byte[] key; private final Provider timeStampProvider; @Inject - public SignRequest(@Named(AtmosStorageConstants.PROPERTY_EMCSAAS_UID) String uid, + public SignRequest(SignatureWire signatureWire, + @Named(AtmosStorageConstants.PROPERTY_EMCSAAS_UID) String uid, @Named(AtmosStorageConstants.PROPERTY_EMCSAAS_KEY) String encodedKey, @TimeStamp Provider timeStampProvider) { + this.signatureWire = signatureWire; this.uid = uid; this.key = HttpUtils.fromBase64String(encodedKey); this.timeStampProvider = timeStampProvider; @@ -80,12 +85,16 @@ public class SignRequest implements HttpRequestFilter { appendHttpHeaders(request, buffer); appendCanonicalizedResource(request, buffer); appendCanonicalizedHeaders(request, buffer); + if (signatureWire.enabled()) + signatureWire.output(buffer.toString()); return buffer.toString(); } private void calculateAndReplaceAuthHeader(HttpRequest request, String toSign) throws HttpException { String signature = signString(toSign); + if (signatureWire.enabled()) + signatureWire.input(IOUtils.toInputStream(signature)); request.getHeaders().replaceValues(AtmosStorageHeaders.SIGNATURE, Collections.singletonList(signature)); } diff --git a/atmosonline/saas/core/src/test/resources/log4j.xml b/atmosonline/saas/core/src/test/resources/log4j.xml index 204069364f..533b777a7e 100755 --- a/atmosonline/saas/core/src/test/resources/log4j.xml +++ b/atmosonline/saas/core/src/test/resources/log4j.xml @@ -1,37 +1,35 @@ - + 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. + ==================================================================== + --> - + + debug="false"> @@ -48,52 +46,52 @@ - - - - + + + + - - + + - + - - - + + + - - - - - - - + + + + + + + - - - - - + - - + + + + + + - - + + @@ -104,12 +102,18 @@ - - - + + + + - - - + + + + + + + + diff --git a/aws/s3/core/src/main/java/org/jclouds/aws/s3/filters/RequestAuthorizeSignature.java b/aws/s3/core/src/main/java/org/jclouds/aws/s3/filters/RequestAuthorizeSignature.java index 2ec0860934..43f88373e5 100644 --- a/aws/s3/core/src/main/java/org/jclouds/aws/s3/filters/RequestAuthorizeSignature.java +++ b/aws/s3/core/src/main/java/org/jclouds/aws/s3/filters/RequestAuthorizeSignature.java @@ -36,11 +36,13 @@ import javax.inject.Provider; import javax.inject.Singleton; import javax.ws.rs.core.HttpHeaders; +import org.apache.commons.io.IOUtils; import org.jclouds.aws.s3.reference.S3Constants; import org.jclouds.http.HttpException; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequestFilter; import org.jclouds.http.HttpUtils; +import org.jclouds.http.internal.SignatureWire; import org.jclouds.util.TimeStamp; import com.google.common.annotations.VisibleForTesting; @@ -57,14 +59,16 @@ public class RequestAuthorizeSignature implements HttpRequestFilter { private final String[] firstHeadersToSign = new String[] { "Content-MD5", HttpHeaders.CONTENT_TYPE, HttpHeaders.DATE }; + private final SignatureWire signatureWire; private final String accessKey; private final String secretKey; private final Provider timeStampProvider; @Inject - public RequestAuthorizeSignature(@Named(S3Constants.PROPERTY_AWS_ACCESSKEYID) String accessKey, + public RequestAuthorizeSignature(SignatureWire signatureWire, @Named(S3Constants.PROPERTY_AWS_ACCESSKEYID) String accessKey, @Named(S3Constants.PROPERTY_AWS_SECRETACCESSKEY) String secretKey, @TimeStamp Provider timeStampProvider) { + this.signatureWire = signatureWire; this.accessKey = accessKey; this.secretKey = secretKey; this.timeStampProvider = timeStampProvider; @@ -84,12 +88,16 @@ public class RequestAuthorizeSignature implements HttpRequestFilter { appendAmzHeaders(request, buffer); appendBucketName(request, buffer); appendUriPath(request, buffer); + if(signatureWire.enabled()) + signatureWire.output(buffer.toString()); return buffer.toString(); } private void calculateAndReplaceAuthHeader(HttpRequest request, String toSign) throws HttpException { String signature = signString(toSign); + if (signatureWire.enabled()) + signatureWire.input(IOUtils.toInputStream(signature)); request.getHeaders().replaceValues(HttpHeaders.AUTHORIZATION, Collections.singletonList("AWS " + accessKey + ":" + signature)); } diff --git a/azure/storage/core/src/main/java/org/jclouds/azure/storage/filters/SharedKeyAuthentication.java b/azure/storage/core/src/main/java/org/jclouds/azure/storage/filters/SharedKeyAuthentication.java index 94f14cefff..f3ddc8928a 100644 --- a/azure/storage/core/src/main/java/org/jclouds/azure/storage/filters/SharedKeyAuthentication.java +++ b/azure/storage/core/src/main/java/org/jclouds/azure/storage/filters/SharedKeyAuthentication.java @@ -34,11 +34,13 @@ import javax.inject.Provider; import javax.inject.Singleton; import javax.ws.rs.core.HttpHeaders; +import org.apache.commons.io.IOUtils; import org.jclouds.azure.storage.reference.AzureStorageConstants; import org.jclouds.http.HttpException; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequestFilter; import org.jclouds.http.HttpUtils; +import org.jclouds.http.internal.SignatureWire; import org.jclouds.util.TimeStamp; import com.google.common.annotations.VisibleForTesting; @@ -55,15 +57,17 @@ public class SharedKeyAuthentication implements HttpRequestFilter { private final String[] firstHeadersToSign = new String[] { "Content-MD5", HttpHeaders.CONTENT_TYPE, HttpHeaders.DATE }; + private final SignatureWire signatureWire; private final String account; private final byte[] key; private final Provider timeStampProvider; @Inject - public SharedKeyAuthentication( + public SharedKeyAuthentication(SignatureWire signatureWire, @Named(AzureStorageConstants.PROPERTY_AZURESTORAGE_ACCOUNT) String account, @Named(AzureStorageConstants.PROPERTY_AZURESTORAGE_KEY) String encodedKey, @TimeStamp Provider timeStampProvider) { + this.signatureWire = signatureWire; this.account = account; this.key = HttpUtils.fromBase64String(encodedKey); this.timeStampProvider = timeStampProvider; @@ -82,12 +86,16 @@ public class SharedKeyAuthentication implements HttpRequestFilter { appendHttpHeaders(request, buffer); appendCanonicalizedHeaders(request, buffer); appendCanonicalizedResource(request, buffer); + if (signatureWire.enabled()) + signatureWire.output(buffer.toString()); return buffer.toString(); } private void calculateAndReplaceAuthHeader(HttpRequest request, String toSign) throws HttpException { String signature = signString(toSign); + if (signatureWire.enabled()) + signatureWire.input(IOUtils.toInputStream(signature)); request.getHeaders().replaceValues(HttpHeaders.AUTHORIZATION, Collections.singletonList("SharedKey " + account + ":" + signature)); } diff --git a/core/src/main/java/org/jclouds/http/HttpConstants.java b/core/src/main/java/org/jclouds/http/HttpConstants.java index daeac7142e..5a260c54b4 100644 --- a/core/src/main/java/org/jclouds/http/HttpConstants.java +++ b/core/src/main/java/org/jclouds/http/HttpConstants.java @@ -33,6 +33,7 @@ public interface HttpConstants { public static final String PROPERTY_HTTP_MAX_REDIRECTS = "jclouds.http.max-redirects"; public static final String HTTP_HEADERS_LOGGER = "jclouds.http.headers"; public static final String HTTP_WIRE_LOGGER = "jclouds.http.wire"; + public static final String SIGNATURE_WIRE_LOGGER = "jclouds.signature.wire"; /** * longest time a single request can take before throwing an exception. diff --git a/core/src/main/java/org/jclouds/http/internal/BaseHttpCommandExecutorService.java b/core/src/main/java/org/jclouds/http/internal/BaseHttpCommandExecutorService.java index f107e7c260..93d11b20ba 100644 --- a/core/src/main/java/org/jclouds/http/internal/BaseHttpCommandExecutorService.java +++ b/core/src/main/java/org/jclouds/http/internal/BaseHttpCommandExecutorService.java @@ -54,10 +54,10 @@ public abstract class BaseHttpCommandExecutorService implements HttpCommandEx @Named(HttpConstants.HTTP_HEADERS_LOGGER) protected Logger headerLog = Logger.NULL; - private final Wire wire; + private final HttpWire wire; protected BaseHttpCommandExecutorService(ExecutorService executorService, - DelegatingRetryHandler retryHandler, DelegatingErrorHandler errorHandler, Wire wire) { + DelegatingRetryHandler retryHandler, DelegatingErrorHandler errorHandler, HttpWire wire) { this.retryHandler = retryHandler; this.errorHandler = errorHandler; this.executorService = executorService; diff --git a/core/src/main/java/org/jclouds/http/internal/HttpWire.java b/core/src/main/java/org/jclouds/http/internal/HttpWire.java new file mode 100644 index 0000000000..e8460617f3 --- /dev/null +++ b/core/src/main/java/org/jclouds/http/internal/HttpWire.java @@ -0,0 +1,57 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ +package org.jclouds.http.internal; + +import java.util.concurrent.ExecutorService; + +import javax.annotation.Resource; +import javax.inject.Inject; +import javax.inject.Named; + +import org.jclouds.http.HttpConstants; +import org.jclouds.logging.Logger; +import org.jclouds.logging.internal.Wire; + +/** + * Logs data to the wire LOG. + * + * @author Adrian Cole + * @see org.apache.HttpWire.impl.conn.Wire + */ +public class HttpWire extends Wire { + + @Resource + @Named(HttpConstants.HTTP_WIRE_LOGGER) + Logger wireLog = Logger.NULL; + + @Inject + public HttpWire(ExecutorService exec) { + super(exec); + } + + public Logger getWireLog() { + return wireLog; + } + +} diff --git a/core/src/main/java/org/jclouds/http/internal/JavaUrlHttpCommandExecutorService.java b/core/src/main/java/org/jclouds/http/internal/JavaUrlHttpCommandExecutorService.java index d8ab97d0dd..18eba40ff9 100644 --- a/core/src/main/java/org/jclouds/http/internal/JavaUrlHttpCommandExecutorService.java +++ b/core/src/main/java/org/jclouds/http/internal/JavaUrlHttpCommandExecutorService.java @@ -66,7 +66,7 @@ public class JavaUrlHttpCommandExecutorService extends @Inject public JavaUrlHttpCommandExecutorService(ExecutorService executorService, - DelegatingRetryHandler retryHandler, DelegatingErrorHandler errorHandler, Wire wire) { + DelegatingRetryHandler retryHandler, DelegatingErrorHandler errorHandler, HttpWire wire) { super(executorService, retryHandler, errorHandler, wire); sslMap = Maps.newHashMap(); } diff --git a/core/src/main/java/org/jclouds/http/internal/SignatureWire.java b/core/src/main/java/org/jclouds/http/internal/SignatureWire.java new file mode 100644 index 0000000000..2f859c0db9 --- /dev/null +++ b/core/src/main/java/org/jclouds/http/internal/SignatureWire.java @@ -0,0 +1,57 @@ +/** + * + * Copyright (C) 2009 Cloud Conscious, LLC. + * + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + */ +package org.jclouds.http.internal; + +import java.util.concurrent.ExecutorService; + +import javax.annotation.Resource; +import javax.inject.Inject; +import javax.inject.Named; + +import org.jclouds.http.HttpConstants; +import org.jclouds.logging.Logger; +import org.jclouds.logging.internal.Wire; + +/** + * Logs data to the wire LOG. + * + * @author Adrian Cole + * @see org.apache.HttpWire.impl.conn.Wire + */ +public class SignatureWire extends Wire { + + @Resource + @Named(HttpConstants.SIGNATURE_WIRE_LOGGER) + Logger wireLog = Logger.NULL; + + @Inject + public SignatureWire(ExecutorService exec) { + super(exec); + } + + public Logger getWireLog() { + return wireLog; + } + +} diff --git a/core/src/main/java/org/jclouds/http/internal/Wire.java b/core/src/main/java/org/jclouds/logging/internal/Wire.java similarity index 90% rename from core/src/main/java/org/jclouds/http/internal/Wire.java rename to core/src/main/java/org/jclouds/logging/internal/Wire.java index 64a2fc09b0..b44a831466 100644 --- a/core/src/main/java/org/jclouds/http/internal/Wire.java +++ b/core/src/main/java/org/jclouds/logging/internal/Wire.java @@ -1,6 +1,6 @@ /** * - * Copyright (C) 2009 Cloud Conscious, LLC. + * Copyright (C) 2009 Global Cloud Specialists, Inc. * * ==================================================================== * Licensed to the Apache Software Foundation (ASF) under one @@ -21,7 +21,7 @@ * under the License. * ==================================================================== */ -package org.jclouds.http.internal; +package org.jclouds.logging.internal; import static com.google.common.base.Preconditions.checkNotNull; @@ -37,34 +37,28 @@ import java.util.concurrent.ExecutorService; import javax.annotation.Resource; import javax.inject.Inject; -import javax.inject.Named; import org.apache.commons.io.IOUtils; import org.apache.commons.io.input.TeeInputStream; import org.jclouds.concurrent.SingleThreaded; -import org.jclouds.http.HttpConstants; import org.jclouds.logging.Logger; - /** * Logs data to the wire LOG. * * @author Adrian Cole - * @see org.apache.http.impl.conn.Wire + * @see org.apache.HttpWire.impl.conn.Wire */ -public class Wire { +public abstract class Wire { - @Resource - @Named(HttpConstants.HTTP_WIRE_LOGGER) - protected Logger wireLog = Logger.NULL; @Resource protected Logger logger = Logger.NULL; - - private final ExecutorService exec; + protected final ExecutorService exec; @Inject public Wire(ExecutorService exec) { this.exec = checkNotNull(exec, "executor"); } + protected abstract Logger getWireLog(); private void wire(String header, InputStream instream) { StringBuilder buffer = new StringBuilder(); @@ -77,7 +71,7 @@ public class Wire { buffer.append("[\\n]\""); buffer.insert(0, "\""); buffer.insert(0, header); - wireLog.debug(buffer.toString()); + getWireLog().debug(buffer.toString()); buffer.setLength(0); } else if ((ch < 32) || (ch > 127)) { buffer.append("[0x"); @@ -91,7 +85,7 @@ public class Wire { buffer.append('\"'); buffer.insert(0, '\"'); buffer.insert(0, header); - wireLog.debug(buffer.toString()); + getWireLog().debug(buffer.toString()); } } catch (IOException e) { logger.error(e, "Error tapping line"); @@ -99,7 +93,7 @@ public class Wire { } public boolean enabled() { - return wireLog.isDebugEnabled(); + return getWireLog().isDebugEnabled(); } public InputStream copy(final String header, InputStream instream) { @@ -141,7 +135,7 @@ public class Wire { @SuppressWarnings("unchecked") public T output(T data) { - checkNotNull(data, "data must be set before calling generateETag()"); + checkNotNull(data, "data"); if (data instanceof InputStream) { if (exec.getClass().isAnnotationPresent(SingleThreaded.class)) return (T) copy(">> ", (InputStream) data); @@ -186,4 +180,4 @@ public class Wire { output(checkNotNull(s, "output").getBytes()); } -} +} \ No newline at end of file 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 b90a191d7d..9740905582 100644 --- a/core/src/test/java/org/jclouds/http/handlers/BackoffLimitedRetryHandlerTest.java +++ b/core/src/test/java/org/jclouds/http/handlers/BackoffLimitedRetryHandlerTest.java @@ -39,7 +39,7 @@ import org.jclouds.http.TransformingHttpCommandExecutorServiceImpl; import org.jclouds.http.TransformingHttpCommandImpl; import org.jclouds.http.functions.ReturnStringIf200; import org.jclouds.http.internal.JavaUrlHttpCommandExecutorService; -import org.jclouds.http.internal.Wire; +import org.jclouds.http.internal.HttpWire; import org.jclouds.logging.Logger; import org.jclouds.logging.Logger.LoggerFactory; import org.testng.annotations.BeforeTest; @@ -93,7 +93,7 @@ public class BackoffLimitedRetryHandlerTest { void setupExecutorService() throws Exception { ExecutorService execService = Executors.newCachedThreadPool(); JavaUrlHttpCommandExecutorService httpService = new JavaUrlHttpCommandExecutorService( - execService, new DelegatingRetryHandler(), new DelegatingErrorHandler(), new Wire( + execService, new DelegatingRetryHandler(), new DelegatingErrorHandler(), new HttpWire( Executors.newCachedThreadPool())); executorService = new TransformingHttpCommandExecutorServiceImpl(httpService, execService, new LoggerFactory() { diff --git a/core/src/test/java/org/jclouds/http/internal/WireLiveTest.java b/core/src/test/java/org/jclouds/http/internal/WireLiveTest.java index 0dfb691a64..ec68dd9943 100644 --- a/core/src/test/java/org/jclouds/http/internal/WireLiveTest.java +++ b/core/src/test/java/org/jclouds/http/internal/WireLiveTest.java @@ -40,6 +40,7 @@ import java.util.concurrent.TimeUnit; import org.apache.commons.io.IOUtils; import org.jclouds.concurrent.WithinThreadExecutorService; import org.jclouds.http.HttpUtils; +import org.jclouds.http.internal.HttpWire; import org.jclouds.logging.Logger; import org.testng.annotations.Test; @@ -61,7 +62,7 @@ public class WireLiveTest { } public Void call() throws Exception { - Wire wire = setUp(); + HttpWire wire = setUp(); InputStream in = wire.input(fromServer); ByteArrayOutputStream out = new ByteArrayOutputStream(); IOUtils.copy(in, out); @@ -69,7 +70,7 @@ public class WireLiveTest { Thread.sleep(100); assertEquals(HttpUtils.toHexString(compare), checkNotNull(sysHttpStreamMd5, sysHttpStreamMd5)); - assertEquals(((BufferLogger) wire.wireLog).buff.toString().getBytes().length, 3331484); + assertEquals(((BufferLogger) wire.getWireLog()).buff.toString().getBytes().length, 3331484); return null; } } @@ -125,19 +126,19 @@ public class WireLiveTest { } - public static Wire setUp() throws Exception { + public static HttpWire setUp() throws Exception { ExecutorService service = Executors.newCachedThreadPool(); BufferLogger bufferLogger = new BufferLogger(); - Wire wire = new Wire(service); - wire.wireLog = bufferLogger; + HttpWire wire = new HttpWire(service); + wire.wireLog = (bufferLogger); return wire; } - public Wire setUpSynch() throws Exception { + public HttpWire setUpSynch() throws Exception { ExecutorService service = new WithinThreadExecutorService(); BufferLogger bufferLogger = new BufferLogger(); - Wire wire = new Wire(service); - wire.wireLog = bufferLogger; + HttpWire wire = new HttpWire(service); + wire.wireLog = (bufferLogger); return wire; } @@ -145,12 +146,12 @@ public class WireLiveTest { public void testRemoteInputInputStream() throws Exception { URL url = new URL(checkNotNull(sysHttpStreamUrl, "sysHttpStreamUrl")); URLConnection connection = url.openConnection(); - Wire wire = setUp(); + HttpWire wire = setUp(); InputStream in = wire.input(connection.getInputStream()); byte[] compare = HttpUtils.md5(in); Thread.sleep(100); assertEquals(HttpUtils.toHexString(compare), checkNotNull(sysHttpStreamMd5, sysHttpStreamMd5)); - assertEquals(((BufferLogger) wire.wireLog).buff.toString().getBytes().length, 3331484); + assertEquals(((BufferLogger) wire.getWireLog()).buff.toString().getBytes().length, 3331484); } @Test(groups = "live") @@ -166,12 +167,12 @@ public class WireLiveTest { public void testRemoteInputInputStreamSynch() throws Exception { URL url = new URL(checkNotNull(sysHttpStreamUrl, "sysHttpStreamUrl")); URLConnection connection = url.openConnection(); - Wire wire = setUpSynch(); + HttpWire wire = setUpSynch(); InputStream in = wire.input(connection.getInputStream()); byte[] compare = HttpUtils.md5(in); Thread.sleep(100); assertEquals(HttpUtils.toHexString(compare), checkNotNull(sysHttpStreamMd5, sysHttpStreamMd5)); - assertEquals(((BufferLogger) wire.wireLog).buff.toString().getBytes().length, 3331484); + assertEquals(((BufferLogger) wire.getWireLog()).buff.toString().getBytes().length, 3331484); } } diff --git a/core/src/test/java/org/jclouds/http/internal/WireTest.java b/core/src/test/java/org/jclouds/http/internal/WireTest.java index 3959da343f..568dd85423 100644 --- a/core/src/test/java/org/jclouds/http/internal/WireTest.java +++ b/core/src/test/java/org/jclouds/http/internal/WireTest.java @@ -31,6 +31,7 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import org.jclouds.concurrent.WithinThreadExecutorService; +import org.jclouds.http.internal.HttpWire; import org.jclouds.logging.Logger; import org.jclouds.util.Utils; import org.testng.annotations.Test; @@ -93,57 +94,57 @@ public class WireTest { } - public Wire setUp() throws Exception { + public HttpWire setUp() throws Exception { ExecutorService service = Executors.newCachedThreadPool(); BufferLogger bufferLogger = new BufferLogger(); - Wire wire = new Wire(service); - wire.wireLog = bufferLogger; + HttpWire wire = new HttpWire(service); + wire.wireLog = (bufferLogger); return wire; } - public Wire setUpSynch() throws Exception { + public HttpWire setUpSynch() throws Exception { ExecutorService service = new WithinThreadExecutorService(); BufferLogger bufferLogger = new BufferLogger(); - Wire wire = new Wire(service); - wire.wireLog = bufferLogger; + HttpWire wire = new HttpWire(service); + wire.wireLog = (bufferLogger); return wire; } public void testInputInputStream() throws Exception { - Wire wire = setUp(); + HttpWire wire = setUp(); InputStream in = wire.input(new ByteArrayInputStream("foo".getBytes())); String compare = Utils.toStringAndClose(in); Thread.sleep(100); assertEquals(compare, "foo"); - assertEquals(((BufferLogger) wire.wireLog).buff.toString(), "<< \"foo\""); + assertEquals(((BufferLogger) wire.getWireLog()).buff.toString(), "<< \"foo\""); } public void testInputInputStreamSynch() throws Exception { - Wire wire = setUpSynch(); + HttpWire wire = setUpSynch(); InputStream in = wire.input(new ByteArrayInputStream("foo".getBytes())); String compare = Utils.toStringAndClose(in); assertEquals(compare, "foo"); - assertEquals(((BufferLogger) wire.wireLog).buff.toString(), "<< \"foo\""); + assertEquals(((BufferLogger) wire.getWireLog()).buff.toString(), "<< \"foo\""); } public void testOutputInputStream() throws Exception { - Wire wire = setUp(); + HttpWire wire = setUp(); InputStream in = wire.output(new ByteArrayInputStream("foo".getBytes())); String compare = Utils.toStringAndClose(in); Thread.sleep(100); assertEquals(compare, "foo"); - assertEquals(((BufferLogger) wire.wireLog).buff.toString(), ">> \"foo\""); + assertEquals(((BufferLogger) wire.getWireLog()).buff.toString(), ">> \"foo\""); } public void testOutputBytes() throws Exception { - Wire wire = setUp(); + HttpWire wire = setUp(); wire.output("foo".getBytes()); - assertEquals(((BufferLogger) wire.wireLog).buff.toString(), ">> \"foo\""); + assertEquals(((BufferLogger) wire.getWireLog()).buff.toString(), ">> \"foo\""); } public void testOutputString() throws Exception { - Wire wire = setUp(); + HttpWire wire = setUp(); wire.output("foo"); - assertEquals(((BufferLogger) wire.wireLog).buff.toString(), ">> \"foo\""); + assertEquals(((BufferLogger) wire.getWireLog()).buff.toString(), ">> \"foo\""); } } diff --git a/extensions/gae/src/main/java/org/jclouds/gae/GaeHttpCommandExecutorService.java b/extensions/gae/src/main/java/org/jclouds/gae/GaeHttpCommandExecutorService.java index a8c5dba4bc..b12ccd0cfd 100644 --- a/extensions/gae/src/main/java/org/jclouds/gae/GaeHttpCommandExecutorService.java +++ b/extensions/gae/src/main/java/org/jclouds/gae/GaeHttpCommandExecutorService.java @@ -46,7 +46,7 @@ import org.jclouds.http.HttpResponse; import org.jclouds.http.handlers.DelegatingErrorHandler; import org.jclouds.http.handlers.DelegatingRetryHandler; import org.jclouds.http.internal.BaseHttpCommandExecutorService; -import org.jclouds.http.internal.Wire; +import org.jclouds.http.internal.HttpWire; import com.google.appengine.api.urlfetch.FetchOptions; import com.google.appengine.api.urlfetch.HTTPHeader; @@ -68,7 +68,7 @@ public class GaeHttpCommandExecutorService extends BaseHttpCommandExecutorServic @Inject public GaeHttpCommandExecutorService(URLFetchService urlFetchService, ExecutorService executorService, DelegatingRetryHandler retryHandler, - DelegatingErrorHandler errorHandler, Wire wire) { + DelegatingErrorHandler errorHandler, HttpWire wire) { super(executorService, retryHandler, errorHandler, wire); this.urlFetchService = urlFetchService; } diff --git a/extensions/gae/src/test/java/org/jclouds/gae/GaeHttpCommandExecutorServiceTest.java b/extensions/gae/src/test/java/org/jclouds/gae/GaeHttpCommandExecutorServiceTest.java index 8503c98d6d..dfe27319bd 100644 --- a/extensions/gae/src/test/java/org/jclouds/gae/GaeHttpCommandExecutorServiceTest.java +++ b/extensions/gae/src/test/java/org/jclouds/gae/GaeHttpCommandExecutorServiceTest.java @@ -47,7 +47,7 @@ import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; import org.jclouds.http.handlers.DelegatingErrorHandler; import org.jclouds.http.handlers.DelegatingRetryHandler; -import org.jclouds.http.internal.Wire; +import org.jclouds.http.internal.HttpWire; import org.testng.annotations.BeforeTest; import org.testng.annotations.Parameters; import org.testng.annotations.Test; @@ -71,7 +71,7 @@ public class GaeHttpCommandExecutorServiceTest { endPoint = URI.create("http://localhost:80/foo"); client = new GaeHttpCommandExecutorService(createNiceMock(URLFetchService.class), createNiceMock(ExecutorService.class), createNiceMock(DelegatingRetryHandler.class), - createNiceMock(DelegatingErrorHandler.class), createNiceMock(Wire.class)); + createNiceMock(DelegatingErrorHandler.class), createNiceMock(HttpWire.class)); } @Test diff --git a/extensions/httpnio/src/main/java/org/jclouds/http/httpnio/pool/NioHttpCommandExecutionHandler.java b/extensions/httpnio/src/main/java/org/jclouds/http/httpnio/pool/NioHttpCommandExecutionHandler.java index 8c9175a4b9..81f8519007 100644 --- a/extensions/httpnio/src/main/java/org/jclouds/http/httpnio/pool/NioHttpCommandExecutionHandler.java +++ b/extensions/httpnio/src/main/java/org/jclouds/http/httpnio/pool/NioHttpCommandExecutionHandler.java @@ -45,7 +45,7 @@ import org.jclouds.http.HttpRequestFilter; import org.jclouds.http.handlers.DelegatingErrorHandler; import org.jclouds.http.handlers.DelegatingRetryHandler; import org.jclouds.http.httpnio.util.NioHttpUtils; -import org.jclouds.http.internal.Wire; +import org.jclouds.http.internal.HttpWire; import org.jclouds.logging.Logger; /** @@ -57,7 +57,7 @@ public class NioHttpCommandExecutionHandler implements NHttpRequestExecutionHand private final ConsumingNHttpEntityFactory entityFactory; private final DelegatingRetryHandler retryHandler; private final DelegatingErrorHandler errorHandler; - private final Wire wire; + private final HttpWire wire; /** * inputOnly: nothing is taken from this queue. @@ -73,7 +73,7 @@ public class NioHttpCommandExecutionHandler implements NHttpRequestExecutionHand @Inject public NioHttpCommandExecutionHandler(ConsumingNHttpEntityFactory entityFactory, BlockingQueue> resubmitQueue, - DelegatingRetryHandler retryHandler, DelegatingErrorHandler errorHandler, Wire wire) { + DelegatingRetryHandler retryHandler, DelegatingErrorHandler errorHandler, HttpWire wire) { this.entityFactory = entityFactory; this.resubmitQueue = resubmitQueue; this.retryHandler = retryHandler;