Attempt to fix logging tests that fail in CI

This commit is contained in:
Phillip Webb 2013-07-08 17:26:21 -07:00
parent c52972ceec
commit abad5aa8e4
6 changed files with 21 additions and 15 deletions

View File

@ -6,4 +6,6 @@ java.util.logging.FileHandler.pattern = %t/service.log
java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
java.util.logging.FileHandler.level = INFO
java.util.logging.FileHandler.limit = 10485760
java.util.logging.FileHandler.count = 10
java.util.logging.FileHandler.count = 10
java.util.logging.SimpleFormatter.format = {0,date} {0,time}

View File

@ -18,14 +18,15 @@ package org.springframework.bootstrap.logging;
import java.io.ByteArrayOutputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintStream;
import java.util.logging.LogManager;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.springframework.bootstrap.logging.JavaLoggerConfigurer;
import static org.junit.Assert.assertTrue;
@ -40,10 +41,12 @@ public class JavaLoggerConfigurerTests {
private ByteArrayOutputStream output;
@Before
public void init() {
public void init() throws SecurityException, IOException {
this.savedOutput = System.out;
this.output = new ByteArrayOutputStream();
System.setOut(new PrintStream(this.output));
LogManager.getLogManager().readConfiguration(
getClass().getResourceAsStream("logging.properties"));
}
@After
@ -73,11 +76,6 @@ public class JavaLoggerConfigurerTests {
JavaLoggerConfigurer.initLogging("classpath:logging-nonexistent.properties");
}
@Test(expected = IllegalArgumentException.class)
public void testBadUrlConfigLocation() throws Exception {
JavaLoggerConfigurer.initLogging("http://nosuchhost");
}
@Test(expected = IllegalArgumentException.class)
public void testNullConfigLocation() throws Exception {
JavaLoggerConfigurer.initLogging(null);

View File

@ -72,11 +72,6 @@ public class LogbackConfigurerTests {
LogbackConfigurer.initLogging("classpath:logback-nonexistent.xml");
}
@Test(expected = IllegalArgumentException.class)
public void testBadUrlConfigLocation() throws Exception {
LogbackConfigurer.initLogging("http://nosuchhost/foo.xml");
}
@Test(expected = IllegalArgumentException.class)
public void testNullConfigLocation() throws Exception {
LogbackConfigurer.initLogging(null);

View File

@ -17,7 +17,9 @@
package org.springframework.bootstrap.logging;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.logging.LogManager;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -45,10 +47,12 @@ public class LoggingApplicationContextInitializerTests {
private ByteArrayOutputStream output;
@Before
public void init() {
public void init() throws SecurityException, IOException {
this.savedOutput = System.err;
this.output = new ByteArrayOutputStream();
System.setOut(new PrintStream(this.output));
LogManager.getLogManager().readConfiguration(
getClass().getResourceAsStream("logging.properties"));
}
@After

View File

@ -1,3 +1,2 @@
handlers = java.util.logging.ConsoleHandler
.level = INFO
java.util.logging.ConsoleHandler.formatter =

View File

@ -0,0 +1,8 @@
handlers= java.util.logging.ConsoleHandler
.level= INFO
java.util.logging.FileHandler.pattern = %h/java%u.log
java.util.logging.FileHandler.limit = 50000
java.util.logging.FileHandler.count = 1
java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter
java.util.logging.ConsoleHandler.level = INFO
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter