mirror of https://github.com/apache/jclouds.git
Issue 64: started logging integration tests
git-svn-id: http://jclouds.googlecode.com/svn/trunk@1480 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
parent
344cf6a3a7
commit
917dae7c21
|
@ -0,0 +1,46 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
|
||||||
|
|
||||||
|
<!--
|
||||||
|
For more configuration infromation and examples see the Apache Log4j website: http://logging.apache.org/log4j/
|
||||||
|
-->
|
||||||
|
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
|
||||||
|
|
||||||
|
<!-- A time/date based rolling appender -->
|
||||||
|
<appender name="FILE" class="org.apache.log4j.DailyRollingFileAppender">
|
||||||
|
<param name="File" value="target/test-data/jclouds.log"/>
|
||||||
|
<param name="Append" value="true"/>
|
||||||
|
|
||||||
|
<!-- Rollover at midnight each day -->
|
||||||
|
<param name="DatePattern" value="'.'yyyy-MM-dd"/>
|
||||||
|
|
||||||
|
<param name="Threshold" value="TRACE"/>
|
||||||
|
|
||||||
|
<layout class="org.apache.log4j.PatternLayout">
|
||||||
|
<!-- The default pattern: Date Priority [Category] Message\n -->
|
||||||
|
<param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n"/>
|
||||||
|
|
||||||
|
<!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n
|
||||||
|
<param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
|
||||||
|
-->
|
||||||
|
</layout>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- ================ -->
|
||||||
|
<!-- Limit categories -->
|
||||||
|
<!-- ================ -->
|
||||||
|
|
||||||
|
<category name="org.jclouds">
|
||||||
|
<priority value="TRACE"/>
|
||||||
|
</category>
|
||||||
|
|
||||||
|
<!-- ======================= -->
|
||||||
|
<!-- Setup the Root category -->
|
||||||
|
<!-- ======================= -->
|
||||||
|
|
||||||
|
<root>
|
||||||
|
<priority value="WARN"/>
|
||||||
|
<appender-ref ref="FILE"/>
|
||||||
|
</root>
|
||||||
|
|
||||||
|
</log4j:configuration>
|
12
aws/pom.xml
12
aws/pom.xml
|
@ -58,6 +58,18 @@
|
||||||
<type>test-jar</type>
|
<type>test-jar</type>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>log4j</groupId>
|
||||||
|
<artifactId>log4j</artifactId>
|
||||||
|
<version>1.2.14</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>jclouds-log4j</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<profiles>
|
<profiles>
|
||||||
<profile>
|
<profile>
|
||||||
|
|
|
@ -54,6 +54,7 @@ import org.jclouds.aws.s3.internal.StubS3Connection;
|
||||||
import org.jclouds.aws.s3.reference.S3Constants;
|
import org.jclouds.aws.s3.reference.S3Constants;
|
||||||
import org.jclouds.aws.s3.util.S3Utils;
|
import org.jclouds.aws.s3.util.S3Utils;
|
||||||
import org.jclouds.http.config.JavaUrlHttpFutureCommandClientModule;
|
import org.jclouds.http.config.JavaUrlHttpFutureCommandClientModule;
|
||||||
|
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||||
import org.jclouds.util.Utils;
|
import org.jclouds.util.Utils;
|
||||||
import org.testng.ITestContext;
|
import org.testng.ITestContext;
|
||||||
import org.testng.annotations.AfterGroups;
|
import org.testng.annotations.AfterGroups;
|
||||||
|
@ -218,7 +219,7 @@ public class S3IntegrationTest {
|
||||||
|
|
||||||
protected void createLiveS3Context(String AWSAccessKeyId, String AWSSecretAccessKey) {
|
protected void createLiveS3Context(String AWSAccessKeyId, String AWSSecretAccessKey) {
|
||||||
context = buildS3ContextFactory(AWSAccessKeyId, AWSSecretAccessKey).withModule(
|
context = buildS3ContextFactory(AWSAccessKeyId, AWSSecretAccessKey).withModule(
|
||||||
createHttpModule()).build();
|
createHttpModule()).withModule(new Log4JLoggingModule()).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getBucketName() throws InterruptedException, ExecutionException, TimeoutException {
|
public String getBucketName() throws InterruptedException, ExecutionException, TimeoutException {
|
||||||
|
|
|
@ -61,10 +61,11 @@ public abstract class BaseHttpFutureCommandClient<Q> implements HttpFutureComman
|
||||||
public void submit(HttpFutureCommand<?> command) {
|
public void submit(HttpFutureCommand<?> command) {
|
||||||
HttpRequest request = command.getRequest();
|
HttpRequest request = command.getRequest();
|
||||||
|
|
||||||
Q nativeRequest = null;
|
|
||||||
try {
|
try {
|
||||||
HttpResponse response = null;
|
HttpResponse response = null;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
Q nativeRequest = null;
|
||||||
|
try {
|
||||||
logger.trace("%s - converting request %s", request.getEndPoint(), request);
|
logger.trace("%s - converting request %s", request.getEndPoint(), request);
|
||||||
for (HttpRequestFilter filter : requestFilters) {
|
for (HttpRequestFilter filter : requestFilters) {
|
||||||
filter.filter(request);
|
filter.filter(request);
|
||||||
|
@ -79,16 +80,18 @@ public abstract class BaseHttpFutureCommandClient<Q> implements HttpFutureComman
|
||||||
errorHandler.handleError(command, response);
|
errorHandler.handleError(command, response);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
processResponse(response, command);
|
processResponse(response, command);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
cleanup(nativeRequest);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
command.setException(new ExecutionException(String.format("error invoking request %s",
|
command.setException(new ExecutionException(String.format("error invoking request %s",
|
||||||
request), e));
|
request), e));
|
||||||
} finally {
|
|
||||||
cleanup(nativeRequest);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,10 +57,10 @@ public class JavaUrlHttpFutureCommandClient extends BaseHttpFutureCommandClient<
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected HttpResponse invoke(HttpURLConnection connection) throws IOException {
|
protected HttpResponse invoke(HttpURLConnection connection) throws IOException {
|
||||||
HttpResponse response = new HttpResponse();
|
|
||||||
if (logger.isTraceEnabled())
|
if (logger.isTraceEnabled())
|
||||||
logger.trace("%1$s - submitting request %2$s, headers: %3$s", connection.getURL()
|
logger.trace("%1$s - submitting request %2$s", connection.getURL().getHost(), connection
|
||||||
.getHost(), connection.getURL(), connection.getRequestProperties());
|
.getURL());
|
||||||
|
HttpResponse response = new HttpResponse();
|
||||||
InputStream in;
|
InputStream in;
|
||||||
try {
|
try {
|
||||||
in = connection.getInputStream();
|
in = connection.getInputStream();
|
||||||
|
@ -132,5 +132,4 @@ public class JavaUrlHttpFutureCommandClient extends BaseHttpFutureCommandClient<
|
||||||
if (connection != null && connection.getContentLength() == 0)
|
if (connection != null && connection.getContentLength() == 0)
|
||||||
connection.disconnect();
|
connection.disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue