From 8283e3c17e932119a8c5eab8b2fadce15703b503 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Wed, 21 Mar 2012 13:03:27 -0700 Subject: [PATCH] Issue 767: decouple log4j from compute module --- compute/pom.xml | 12 ------------ .../compute/BaseComputeServiceLiveTest.java | 11 ++++++++--- .../compute/BaseTemplateBuilderLiveTest.java | 15 ++++++++++----- .../compute/BaseVersionedServiceLiveTest.java | 6 ++++++ 4 files changed, 24 insertions(+), 20 deletions(-) diff --git a/compute/pom.xml b/compute/pom.xml index 2b00a0061e..63facba357 100644 --- a/compute/pom.xml +++ b/compute/pom.xml @@ -51,18 +51,6 @@ test-jar test - - org.jclouds.driver - jclouds-log4j - ${project.version} - test - - - log4j - log4j - 1.2.16 - test - diff --git a/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java b/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java index 6824f909ee..0e892c6603 100644 --- a/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java @@ -83,7 +83,8 @@ import org.jclouds.domain.Credentials; import org.jclouds.domain.Location; import org.jclouds.domain.LocationScope; import org.jclouds.domain.LoginCredentials; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; +import org.jclouds.logging.LoggingModules; +import org.jclouds.logging.config.LoggingModule; import org.jclouds.net.IPSocket; import org.jclouds.predicates.RetryablePredicate; import org.jclouds.predicates.SocketOpen; @@ -158,10 +159,14 @@ public abstract class BaseComputeServiceLiveTest extends BaseVersionedServiceLiv context.close(); Properties props = setupProperties(); context = new ComputeServiceContextFactory(setupRestProperties()).createContext(provider, - ImmutableSet.of(new Log4JLoggingModule(), getSshModule()), props); + ImmutableSet.of(getLoggingModule(), getSshModule()), props); client = context.getComputeService(); } + protected LoggingModule getLoggingModule() { + return LoggingModules.firstOrJDKLoggingModule(); + } + protected void buildSocketTester() { SocketOpen socketOpen = Guice.createInjector(getSshModule()).getInstance(SocketOpen.class); socketTester = new RetryablePredicate(socketOpen, 60, 1, TimeUnit.SECONDS); @@ -184,7 +189,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseVersionedServiceLiv overrides.setProperty(provider + ".identity", "MOMMA"); overrides.setProperty(provider + ".credential", "MIA"); context = new ComputeServiceContextFactory(setupRestProperties()).createContext(provider, - ImmutableSet. of(new Log4JLoggingModule()), overrides); + ImmutableSet. of(getLoggingModule()), overrides); context.getComputeService().listNodes(); } catch (AuthorizationException e) { throw e; diff --git a/compute/src/test/java/org/jclouds/compute/BaseTemplateBuilderLiveTest.java b/compute/src/test/java/org/jclouds/compute/BaseTemplateBuilderLiveTest.java index cfd5d3f852..6b79b46654 100644 --- a/compute/src/test/java/org/jclouds/compute/BaseTemplateBuilderLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/BaseTemplateBuilderLiveTest.java @@ -42,7 +42,8 @@ import org.jclouds.domain.LocationScope; import org.jclouds.domain.LoginCredentials; import org.jclouds.json.Json; import org.jclouds.json.config.GsonModule; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; +import org.jclouds.logging.LoggingModules; +import org.jclouds.logging.config.LoggingModule; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeClass; import org.testng.annotations.DataProvider; @@ -99,7 +100,11 @@ public abstract class BaseTemplateBuilderLiveTest extends BaseVersionedServiceLi public void setupClient() throws InterruptedException, ExecutionException, TimeoutException, IOException { setupCredentials(); context = new ComputeServiceContextFactory(setupRestProperties()).createContext(provider, - ImmutableSet. of(new Log4JLoggingModule()), setupProperties()); + ImmutableSet. of(getLoggingModule()), setupProperties()); + } + + protected LoggingModule getLoggingModule() { + return LoggingModules.firstOrJDKLoggingModule(); } @DataProvider(name = "osSupported") @@ -234,7 +239,7 @@ public abstract class BaseTemplateBuilderLiveTest extends BaseVersionedServiceLi overrides.setProperty("jclouds.image-id", defaultTemplate.getImage().getId()); context = new ComputeServiceContextFactory().createContext(provider, - ImmutableSet. of(new Log4JLoggingModule()), overrides); + ImmutableSet. of(getLoggingModule()), overrides); assertEquals(context.getComputeService().templateBuilder().build().toString(), defaultTemplate.toString()); } finally { @@ -248,7 +253,7 @@ public abstract class BaseTemplateBuilderLiveTest extends BaseVersionedServiceLi overrides.setProperty(provider + ".image-id", defaultTemplate.getImage().getId()); context = new ComputeServiceContextFactory().createContext(provider, - ImmutableSet. of(new Log4JLoggingModule()), overrides); + ImmutableSet. of(getLoggingModule()), overrides); assertEquals(context.getComputeService().templateBuilder().build().toString(), defaultTemplate.toString()); } finally { @@ -273,7 +278,7 @@ public abstract class BaseTemplateBuilderLiveTest extends BaseVersionedServiceLi overrides.setProperty(propertyKey + ".image.authenticate-sudo", auth + ""); context = new ComputeServiceContextFactory().createContext(provider, - ImmutableSet. of(new Log4JLoggingModule()), overrides); + ImmutableSet. of(getLoggingModule()), overrides); Iterable userPass = Splitter.on(':').split(login); String user = Iterables.get(userPass, 0); diff --git a/compute/src/test/java/org/jclouds/compute/BaseVersionedServiceLiveTest.java b/compute/src/test/java/org/jclouds/compute/BaseVersionedServiceLiveTest.java index ea6e592dd8..eca69b2d08 100644 --- a/compute/src/test/java/org/jclouds/compute/BaseVersionedServiceLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/BaseVersionedServiceLiveTest.java @@ -22,6 +22,8 @@ import java.util.Properties; import org.jclouds.domain.LoginCredentials; import org.jclouds.domain.LoginCredentials.Builder; +import org.jclouds.logging.LoggingModules; +import org.jclouds.logging.config.LoggingModule; import org.jclouds.rest.BaseRestClientLiveTest; import org.testng.annotations.BeforeClass; @@ -71,4 +73,8 @@ public abstract class BaseVersionedServiceLiveTest extends BaseRestClientLiveTes } } + protected LoggingModule getLoggingModule() { + return LoggingModules.firstOrJDKLoggingModule(); + } + }