Issue 767: decouple log4j from compute module

This commit is contained in:
Adrian Cole 2012-03-21 13:03:27 -07:00
parent 2dc66ee5e1
commit 8283e3c17e
4 changed files with 24 additions and 20 deletions

View File

@ -51,18 +51,6 @@
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jclouds.driver</groupId>
<artifactId>jclouds-log4j</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>

View File

@ -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<IPSocket>(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.<Module> of(new Log4JLoggingModule()), overrides);
ImmutableSet.<Module> of(getLoggingModule()), overrides);
context.getComputeService().listNodes();
} catch (AuthorizationException e) {
throw e;

View File

@ -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.<Module> of(new Log4JLoggingModule()), setupProperties());
ImmutableSet.<Module> 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.<Module> of(new Log4JLoggingModule()), overrides);
ImmutableSet.<Module> 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.<Module> of(new Log4JLoggingModule()), overrides);
ImmutableSet.<Module> 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.<Module> of(new Log4JLoggingModule()), overrides);
ImmutableSet.<Module> of(getLoggingModule()), overrides);
Iterable<String> userPass = Splitter.on(':').split(login);
String user = Iterables.get(userPass, 0);

View File

@ -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();
}
}