2015-08-18 13:48 GMT+03:00 <ma...@apache.org>: > Author: markt > Date: Tue Aug 18 10:48:27 2015 > New Revision: 1696390 > > URL: http://svn.apache.org/r1696390 > Log: > Try and make logging available for all tests in a class, not just the first. > > Modified: > tomcat/trunk/test/org/apache/catalina/startup/LoggingBaseTest.java > > Modified: tomcat/trunk/test/org/apache/catalina/startup/LoggingBaseTest.java > URL: > http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/startup/LoggingBaseTest.java?rev=1696390&r1=1696389&r2=1696390&view=diff > ============================================================================== > --- tomcat/trunk/test/org/apache/catalina/startup/LoggingBaseTest.java > (original) > +++ tomcat/trunk/test/org/apache/catalina/startup/LoggingBaseTest.java Tue > Aug 18 10:48:27 2015 > @@ -27,7 +27,9 @@ import java.util.logging.LogManager; > import static org.junit.Assert.fail; > > import org.junit.After; > +import org.junit.AfterClass; > import org.junit.Before; > +import org.junit.BeforeClass; > import org.junit.Rule; > import org.junit.rules.TestName; > > @@ -99,6 +101,16 @@ public abstract class LoggingBaseTest { > deleteOnTearDown.add(file); > } > > + @BeforeClass > + public void setUpPerTestClass() throws Exception {
Shouldn't this method be "static", as it is run one per class (instead of one per test instance, each test = a separate instance of test class)? The same for @AfterClass one. > + // Configure logging > + System.setProperty("java.util.logging.manager", > + "org.apache.juli.ClassLoaderLogManager"); > + System.setProperty("java.util.logging.config.file", new File( > + getBuildDirectory(), "conf/logging.properties").toString()); > + > + } > + > @Before > public void setUp() throws Exception { > // Create catalina.base directory > @@ -111,13 +123,6 @@ public abstract class LoggingBaseTest { > > System.setProperty("catalina.base", tempDir.getAbsolutePath()); > > - // Configure logging > - System.setProperty("java.util.logging.manager", > - "org.apache.juli.ClassLoaderLogManager"); > - System.setProperty("java.util.logging.config.file", new File( > - getBuildDirectory(), "conf/logging.properties").toString()); > - > - // Get log instance after logging has been configured > log = LogFactory.getLog(getClass()); > log.info("Starting test case [" + testName.getMethodName() + "]"); > } > @@ -129,12 +134,16 @@ public abstract class LoggingBaseTest { > } > deleteOnTearDown.clear(); > > + ExpandWar.deleteDir(tempDir); > + } > + > + @AfterClass > + public void tearDownPerTestClass() throws Exception { > LogManager logManager = LogManager.getLogManager(); > if (logManager instanceof ClassLoaderLogManager) { > ((ClassLoaderLogManager) logManager).shutdown(); > } else { > logManager.reset(); > } > - ExpandWar.deleteDir(tempDir); > } > } > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org > For additional commands, e-mail: dev-h...@tomcat.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org