[logback-dev] svn commit: r2321 - in logback/trunk: logback-core/src/main/java/ch/qos/logback/core/joran logback-core/src/test/java/ch/qos/logback/core/appender logback-core/src/test/java/ch/qos/logback/core/joran logback-core/src/test/java/ch/qos/logback/core/joran/action logback-core/src/test/java/ch/qos/logback/core/joran/event logback-core/src/test/java/ch/qos/logback/core/joran/implicitAction logback-core/src/test/java/ch/qos/logback/core/joran/replay logback-core/src/test/java/ch/qos/logback/core/rolling logback-core/src/test/java/ch/qos/logback/core/rolling/helper logback-core/src/test/java/ch/qos/logback/core/util logback-site/src/site/pages
noreply.ceki at qos.ch
noreply.ceki at qos.ch
Tue Jul 7 20:22:05 CEST 2009
Author: ceki
Date: Tue Jul 7 20:22:04 2009
New Revision: 2321
Added:
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/CoreTestConstants.java
- copied, changed from r2315, /logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/Constants.java
Removed:
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/Constants.java
Modified:
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/GenericConfigurator.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/appender/FileAppenderTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/SkippingInInterpreterTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/TrivialcConfiguratorTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/PropertyActionTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/EventRecorderTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/InPlayFireTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/implicitAction/ImplicitActionTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitConfigurationTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/RenamingTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/SizeBasedRollingTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingWithCleanTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/CompressTest.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/FileUtilTest.java
logback/trunk/logback-site/src/site/pages/news.html
Log:
- Renamed Constants as CoreTestConstants
- Fixed LBCORE-105 Configuration files placed in jar files will no longer
lock the jar file.
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/GenericConfigurator.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/GenericConfigurator.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/GenericConfigurator.java Tue Jul 7 20:22:04 2009
@@ -14,6 +14,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
+import java.net.URLConnection;
import java.util.List;
import org.xml.sax.InputSource;
@@ -36,7 +37,10 @@
final public void doConfigure(URL url) throws JoranException {
try {
- InputStream in = url.openStream();
+ URLConnection urlConnection = url.openConnection();
+ // per http://jira.qos.ch/browse/LBCORE-105
+ urlConnection.setDefaultUseCaches(false);
+ InputStream in = urlConnection.getInputStream();
doConfigure(in);
in.close();
} catch (IOException ioe) {
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/appender/FileAppenderTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/appender/FileAppenderTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/appender/FileAppenderTest.java Tue Jul 7 20:22:04 2009
@@ -27,7 +27,7 @@
import ch.qos.logback.core.layout.NopLayout;
import ch.qos.logback.core.status.Status;
import ch.qos.logback.core.status.StatusManager;
-import ch.qos.logback.core.util.Constants;
+import ch.qos.logback.core.util.CoreTestConstants;
import ch.qos.logback.core.util.FileUtil;
public class FileAppenderTest extends AbstractAppenderTest<Object> {
@@ -51,7 +51,7 @@
@Test
public void smoke() {
- String filename = Constants.OUTPUT_DIR_PREFIX + "temp.log";
+ String filename = CoreTestConstants.OUTPUT_DIR_PREFIX + "temp.log";
FileAppender<Object> appender = new FileAppender<Object>();
appender.setLayout(new DummyLayout<Object>());
@@ -70,7 +70,7 @@
@Test
public void testCreateParentFolders() {
- String filename = Constants.OUTPUT_DIR_PREFIX + "/fat" + diff
+ String filename = CoreTestConstants.OUTPUT_DIR_PREFIX + "/fat" + diff
+ "/testing.txt";
File file = new File(filename);
FileAppender<Object> appender = new FileAppender<Object>();
@@ -93,7 +93,7 @@
@Test
public void testPrudentModeLogicalImplications() {
- String filename = Constants.OUTPUT_DIR_PREFIX + diff + "testing.txt";
+ String filename = CoreTestConstants.OUTPUT_DIR_PREFIX + diff + "testing.txt";
File file = new File(filename);
FileAppender<Object> appender = new FileAppender<Object>();
appender.setLayout(new DummyLayout<Object>());
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/SkippingInInterpreterTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/SkippingInInterpreterTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/SkippingInInterpreterTest.java Tue Jul 7 20:22:04 2009
@@ -33,7 +33,7 @@
import ch.qos.logback.core.joran.spi.Pattern;
import ch.qos.logback.core.status.Status;
import ch.qos.logback.core.status.StatusManager;
-import ch.qos.logback.core.util.Constants;
+import ch.qos.logback.core.util.CoreTestConstants;
/**
* Test the way Interpreter skips child elements in case of exceptions thrown by
@@ -70,7 +70,7 @@
TrivialConfigurator tc = new TrivialConfigurator(rulesMap);
tc.setContext(context);
- tc.doConfigure(Constants.TEST_DIR_PREFIX + "input/joran/skip/" + filename);
+ tc.doConfigure(CoreTestConstants.TEST_DIR_PREFIX + "input/joran/skip/" + filename);
String str = context.getProperty(HelloAction.PROPERTY_KEY);
assertEquals("Hello John Doe.", str);
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/TrivialcConfiguratorTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/TrivialcConfiguratorTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/TrivialcConfiguratorTest.java Tue Jul 7 20:22:04 2009
@@ -11,9 +11,16 @@
package ch.qos.logback.core.joran;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.URL;
import java.util.HashMap;
+import java.util.jar.JarOutputStream;
+import java.util.zip.ZipEntry;
import org.junit.Test;
@@ -21,24 +28,27 @@
import ch.qos.logback.core.ContextBase;
import ch.qos.logback.core.joran.action.Action;
import ch.qos.logback.core.joran.action.ext.IncAction;
+import ch.qos.logback.core.joran.spi.JoranException;
import ch.qos.logback.core.joran.spi.Pattern;
import ch.qos.logback.core.status.Status;
import ch.qos.logback.core.status.TrivialStatusListener;
-import ch.qos.logback.core.util.Constants;
+import ch.qos.logback.core.testUtil.RandomUtil;
+import ch.qos.logback.core.util.CoreTestConstants;
public class TrivialcConfiguratorTest {
Context context = new ContextBase();
+ HashMap<Pattern, Action> rulesMap = new HashMap<Pattern, Action>();
public void doTest(String filename) throws Exception {
- HashMap<Pattern, Action> rulesMap = new HashMap<Pattern, Action>();
rulesMap.put(new Pattern("x/inc"), new IncAction());
TrivialConfigurator gc = new TrivialConfigurator(rulesMap);
gc.setContext(context);
- gc.doConfigure(Constants.TEST_DIR_PREFIX + "input/joran/" + filename);
+ gc.doConfigure(CoreTestConstants.TEST_DIR_PREFIX + "input/joran/"
+ + filename);
}
@Test
@@ -86,4 +96,41 @@
.startsWith(
"Problem parsing XML document. See previously reported errors. Abandoning all further processing."));
}
+
+ @Test
+ public void lbcore105() throws IOException, JoranException {
+ String jarEntry = "buzz.xml";
+ File jarFile = makeJarFile();
+ fillInJarFile(jarFile, jarEntry);
+ URL url = asURL(jarFile, jarEntry);
+ TrivialConfigurator tc = new TrivialConfigurator(rulesMap);
+ tc.setContext(context);
+ tc.doConfigure(url);
+ // deleting an open file fails
+ assertTrue(jarFile.delete());
+ assertFalse(jarFile.exists());
+ }
+
+ File makeJarFile() {
+ File outputDir = new File(CoreTestConstants.OUTPUT_DIR_PREFIX);
+ outputDir.mkdirs();
+ int randomInt = RandomUtil.getPositiveInt();
+ return new File(CoreTestConstants.OUTPUT_DIR_PREFIX + "foo-" + randomInt
+ + ".jar");
+ }
+
+ private void fillInJarFile(File jarFile, String jarEntryName)
+ throws IOException {
+ JarOutputStream jos = new JarOutputStream(new FileOutputStream(jarFile));
+ jos.putNextEntry(new ZipEntry(jarEntryName));
+ jos.write("<x/>".getBytes());
+ jos.closeEntry();
+ jos.close();
+ }
+
+ URL asURL(File jarFile, String jarEntryName) throws IOException {
+ URL innerURL = jarFile.toURI().toURL();
+ return new URL("jar:" + innerURL + "!/" + jarEntryName);
+ }
+
}
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/PropertyActionTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/PropertyActionTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/PropertyActionTest.java Tue Jul 7 20:22:04 2009
@@ -13,7 +13,7 @@
import ch.qos.logback.core.ContextBase;
import ch.qos.logback.core.joran.spi.InterpretationContext;
import ch.qos.logback.core.status.ErrorStatus;
-import ch.qos.logback.core.util.Constants;
+import ch.qos.logback.core.util.CoreTestConstants;
import ch.qos.logback.core.util.StatusPrinter;
public class PropertyActionTest {
@@ -90,7 +90,7 @@
@Test
public void testLoadFileWithPrerequisiteSubsitution() {
- context.putProperty("STEM", Constants.TEST_DIR_PREFIX + "input/joran");
+ context.putProperty("STEM", CoreTestConstants.TEST_DIR_PREFIX + "input/joran");
atts.setValue("file", "${STEM}/propertyActionTest.properties");
spAction.begin(ec, null, atts);
assertEquals("tata", ec.getProperty("v1"));
@@ -99,7 +99,7 @@
@Test
public void testLoadFile() {
- atts.setValue("file", Constants.TEST_DIR_PREFIX + "input/joran/propertyActionTest.properties");
+ atts.setValue("file", CoreTestConstants.TEST_DIR_PREFIX + "input/joran/propertyActionTest.properties");
spAction.begin(ec, null, atts);
assertEquals("tata", ec.getProperty("v1"));
assertEquals("toto", ec.getProperty("v2"));
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/EventRecorderTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/EventRecorderTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/EventRecorderTest.java Tue Jul 7 20:22:04 2009
@@ -24,7 +24,7 @@
import ch.qos.logback.core.ContextBase;
import ch.qos.logback.core.status.Status;
import ch.qos.logback.core.status.StatusManager;
-import ch.qos.logback.core.util.Constants;
+import ch.qos.logback.core.util.CoreTestConstants;
/**
* Test whether SaxEventRecorder does a good job.
@@ -44,7 +44,7 @@
public List<SaxEvent> doTest(String filename) throws Exception {
SaxEventRecorder recorder = new SaxEventRecorder();
recorder.setContext(context);
- FileInputStream fis = new FileInputStream(Constants.TEST_DIR_PREFIX
+ FileInputStream fis = new FileInputStream(CoreTestConstants.TEST_DIR_PREFIX
+ "input/joran/"+ filename);
recorder.recordEvents(fis);
return recorder.getSaxEventList();
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/InPlayFireTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/InPlayFireTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/event/InPlayFireTest.java Tue Jul 7 20:22:04 2009
@@ -22,7 +22,7 @@
import ch.qos.logback.core.joran.action.Action;
import ch.qos.logback.core.joran.spi.JoranException;
import ch.qos.logback.core.joran.spi.Pattern;
-import ch.qos.logback.core.util.Constants;
+import ch.qos.logback.core.util.CoreTestConstants;
public class InPlayFireTest {
@@ -37,7 +37,7 @@
TrivialConfigurator gc = new TrivialConfigurator(rulesMap);
gc.setContext(context);
- gc.doConfigure(Constants.TEST_DIR_PREFIX + "input/joran/fire1.xml");
+ gc.doConfigure(CoreTestConstants.TEST_DIR_PREFIX + "input/joran/fire1.xml");
//for(SaxEvent se: listenAction.getSeList()) {
// System.out.println(se);
@@ -57,7 +57,7 @@
TrivialConfigurator gc = new TrivialConfigurator(rulesMap);
gc.setContext(context);
- gc.doConfigure(Constants.TEST_DIR_PREFIX + "input/joran/fire1.xml");
+ gc.doConfigure(CoreTestConstants.TEST_DIR_PREFIX + "input/joran/fire1.xml");
// for(SaxEvent se: listenAction.getSeList()) {
// System.out.println(se);
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/implicitAction/ImplicitActionTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/implicitAction/ImplicitActionTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/implicitAction/ImplicitActionTest.java Tue Jul 7 20:22:04 2009
@@ -12,12 +12,12 @@
import ch.qos.logback.core.joran.SimpleConfigurator;
import ch.qos.logback.core.joran.action.Action;
import ch.qos.logback.core.joran.spi.Pattern;
-import ch.qos.logback.core.util.Constants;
+import ch.qos.logback.core.util.CoreTestConstants;
import ch.qos.logback.core.util.StatusPrinter;
public class ImplicitActionTest {
- static final String IMPLCIT_DIR = Constants.TEST_DIR_PREFIX
+ static final String IMPLCIT_DIR = CoreTestConstants.TEST_DIR_PREFIX
+ "input/joran/implicitAction/";
FruitContext fruitContext = new FruitContext();
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitConfigurationTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitConfigurationTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitConfigurationTest.java Tue Jul 7 20:22:04 2009
@@ -22,7 +22,7 @@
import ch.qos.logback.core.joran.action.Action;
import ch.qos.logback.core.joran.action.NOPAction;
import ch.qos.logback.core.joran.spi.Pattern;
-import ch.qos.logback.core.util.Constants;
+import ch.qos.logback.core.util.CoreTestConstants;
import ch.qos.logback.core.util.StatusPrinter;
/**
@@ -44,7 +44,7 @@
simpleConfigurator.setContext(fruitContext);
- simpleConfigurator.doConfigure(Constants.TEST_DIR_PREFIX + "input/joran/replay/"
+ simpleConfigurator.doConfigure(CoreTestConstants.TEST_DIR_PREFIX + "input/joran/replay/"
+ filename);
return fruitContext.getFruitShellList();
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/RenamingTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/RenamingTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/RenamingTest.java Tue Jul 7 20:22:04 2009
@@ -24,7 +24,7 @@
import ch.qos.logback.core.Layout;
import ch.qos.logback.core.layout.EchoLayout;
import ch.qos.logback.core.util.Compare;
-import ch.qos.logback.core.util.Constants;
+import ch.qos.logback.core.util.CoreTestConstants;
/**
*
@@ -43,7 +43,7 @@
public void setUp() throws Exception {
layout = new EchoLayout<Object>();
- File target = new File(Constants.OUTPUT_DIR_PREFIX + "test.log");
+ File target = new File(CoreTestConstants.OUTPUT_DIR_PREFIX + "test.log");
target.mkdirs();
target.delete();
}
@@ -54,7 +54,7 @@
RollingFileAppender<Object> rfa = new RollingFileAppender<Object>();
rfa.setLayout(layout);
rfa.setContext(context);
- rfa.setFile(Constants.OUTPUT_DIR_PREFIX + "test.log");
+ rfa.setFile(CoreTestConstants.OUTPUT_DIR_PREFIX + "test.log");
// rollover by the second
String datePattern = "yyyy-MM-dd_HH_mm_ss";
@@ -62,7 +62,7 @@
String[] filenames = new String[2];
TimeBasedRollingPolicy tbrp = new TimeBasedRollingPolicy();
- tbrp.setFileNamePattern(Constants.OUTPUT_DIR_PREFIX + "test-%d{"
+ tbrp.setFileNamePattern(CoreTestConstants.OUTPUT_DIR_PREFIX + "test-%d{"
+ datePattern + "}");
// tbrp.setActiveFileName("src/test/output/test.log");
tbrp.setContext(context);
@@ -79,13 +79,13 @@
DelayerUtil.delayUntilNextSecond(50);
rfa.doAppend("Hello 1");
- filenames[0] = Constants.OUTPUT_DIR_PREFIX + "test-"
+ filenames[0] = CoreTestConstants.OUTPUT_DIR_PREFIX + "test-"
+ sdf.format(cal.getTime());
- filenames[1] = Constants.OUTPUT_DIR_PREFIX + "test.log";
+ filenames[1] = CoreTestConstants.OUTPUT_DIR_PREFIX + "test.log";
for (int i = 0; i < filenames.length; i++) {
// System.out.println("before i=" + i);
- assertTrue(Compare.compare(filenames[i], Constants.TEST_DIR_PREFIX
+ assertTrue(Compare.compare(filenames[i], CoreTestConstants.TEST_DIR_PREFIX
+ "witness/rolling/renaming." + i));
// System.out.println("post i=" + i);
}
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/SizeBasedRollingTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/SizeBasedRollingTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/SizeBasedRollingTest.java Tue Jul 7 20:22:04 2009
@@ -31,7 +31,7 @@
import ch.qos.logback.core.layout.DummyLayout;
import ch.qos.logback.core.testUtil.Env;
import ch.qos.logback.core.util.Compare;
-import ch.qos.logback.core.util.Constants;
+import ch.qos.logback.core.util.CoreTestConstants;
/**
*
@@ -47,13 +47,13 @@
@Before
public void setUp() {
{
- File target = new File(Constants.OUTPUT_DIR_PREFIX
+ File target = new File(CoreTestConstants.OUTPUT_DIR_PREFIX
+ "sizeBased-test2.log");
target.mkdirs();
target.delete();
}
{
- File target = new File(Constants.OUTPUT_DIR_PREFIX + "sbr-test3.log");
+ File target = new File(CoreTestConstants.OUTPUT_DIR_PREFIX + "sbr-test3.log");
target.mkdirs();
target.delete();
}
@@ -85,7 +85,7 @@
sbtp.setMaxFileSize("100");
sbtp.start();
- fwrp.setFileNamePattern(Constants.OUTPUT_DIR_PREFIX
+ fwrp.setFileNamePattern(CoreTestConstants.OUTPUT_DIR_PREFIX
+ "sizeBased-test1.%i");
try {
fwrp.start();
@@ -109,7 +109,7 @@
rfa.setName("ROLLING");
rfa.setLayout(layout);
rfa.setContext(context);
- rfa.setFile(Constants.OUTPUT_DIR_PREFIX
+ rfa.setFile(CoreTestConstants.OUTPUT_DIR_PREFIX
+ "sizeBased-test2.log");
FixedWindowRollingPolicy swrp = new FixedWindowRollingPolicy();
@@ -122,7 +122,7 @@
// swrp.setActiveFileName(Constants.TEST_DIR_PREFIX
// + "output/sizeBased-test2.log");
- swrp.setFileNamePattern(Constants.OUTPUT_DIR_PREFIX
+ swrp.setFileNamePattern(CoreTestConstants.OUTPUT_DIR_PREFIX
+ "sizeBased-test2.%i");
swrp.setParent(rfa);
swrp.start();
@@ -148,25 +148,25 @@
rfa.doAppend("hello");
}
- assertTrue(new File(Constants.OUTPUT_DIR_PREFIX
+ assertTrue(new File(CoreTestConstants.OUTPUT_DIR_PREFIX
+ "sizeBased-test2.log").exists());
- assertTrue(new File(Constants.OUTPUT_DIR_PREFIX + "sizeBased-test2.0")
+ assertTrue(new File(CoreTestConstants.OUTPUT_DIR_PREFIX + "sizeBased-test2.0")
.exists());
- assertTrue(new File(Constants.OUTPUT_DIR_PREFIX + "sizeBased-test2.1")
+ assertTrue(new File(CoreTestConstants.OUTPUT_DIR_PREFIX + "sizeBased-test2.1")
.exists());
// The File.length() method is not accurate under Windows
if (!Env.isWindows()) {
- assertTrue(Compare.compare(Constants.OUTPUT_DIR_PREFIX
- + "sizeBased-test2.log", Constants.TEST_DIR_PREFIX
+ assertTrue(Compare.compare(CoreTestConstants.OUTPUT_DIR_PREFIX
+ + "sizeBased-test2.log", CoreTestConstants.TEST_DIR_PREFIX
+ "witness/rolling/sbr-test2.l"));
- assertTrue(Compare.compare(Constants.OUTPUT_DIR_PREFIX
- + "sizeBased-test2.0", Constants.TEST_DIR_PREFIX
+ assertTrue(Compare.compare(CoreTestConstants.OUTPUT_DIR_PREFIX
+ + "sizeBased-test2.0", CoreTestConstants.TEST_DIR_PREFIX
+ "witness/rolling/sbr-test2.0"));
- assertTrue(Compare.compare(Constants.OUTPUT_DIR_PREFIX
- + "sizeBased-test2.1", Constants.TEST_DIR_PREFIX
+ assertTrue(Compare.compare(CoreTestConstants.OUTPUT_DIR_PREFIX
+ + "sizeBased-test2.1", CoreTestConstants.TEST_DIR_PREFIX
+ "witness/rolling/sbr-test2.1"));
}
@@ -183,7 +183,7 @@
RollingFileAppender<Object> rfa = new RollingFileAppender<Object>();
rfa.setLayout(layout);
rfa.setContext(context);
- rfa.setFile(Constants.OUTPUT_DIR_PREFIX + "sbr-test3.log");
+ rfa.setFile(CoreTestConstants.OUTPUT_DIR_PREFIX + "sbr-test3.log");
FixedWindowRollingPolicy fwrp = new FixedWindowRollingPolicy();
fwrp.setContext(context);
@@ -193,7 +193,7 @@
sbtp.setMaxFileSize("100");
fwrp.setMinIndex(0);
//fwrp.setActiveFileName(Constants.TEST_DIR_PREFIX + "output/sbr-test3.log");
- fwrp.setFileNamePattern(Constants.OUTPUT_DIR_PREFIX
+ fwrp.setFileNamePattern(CoreTestConstants.OUTPUT_DIR_PREFIX
+ "sbr-test3.%i.gz");
fwrp.setParent(rfa);
fwrp.start();
@@ -218,24 +218,24 @@
rfa.doAppend("hello");
}
- assertTrue(new File(Constants.OUTPUT_DIR_PREFIX + "sbr-test3.log")
+ assertTrue(new File(CoreTestConstants.OUTPUT_DIR_PREFIX + "sbr-test3.log")
.exists());
- assertTrue(new File(Constants.OUTPUT_DIR_PREFIX + "sbr-test3.0.gz")
+ assertTrue(new File(CoreTestConstants.OUTPUT_DIR_PREFIX + "sbr-test3.0.gz")
.exists());
- assertTrue(new File(Constants.OUTPUT_DIR_PREFIX + "sbr-test3.1.gz")
+ assertTrue(new File(CoreTestConstants.OUTPUT_DIR_PREFIX + "sbr-test3.1.gz")
.exists());
if (!Env.isWindows()) {
assertTrue(Compare.compare(
- Constants.OUTPUT_DIR_PREFIX+"sbr-test3.log",
- Constants.TEST_DIR_PREFIX + "witness/rolling/sbr-test3.l"));
+ CoreTestConstants.OUTPUT_DIR_PREFIX+"sbr-test3.log",
+ CoreTestConstants.TEST_DIR_PREFIX + "witness/rolling/sbr-test3.l"));
assertTrue(Compare.gzCompare(
- Constants.OUTPUT_DIR_PREFIX+"sbr-test3.0.gz",
- Constants.TEST_DIR_PREFIX + "witness/rolling/sbr-test3.0.gz"));
+ CoreTestConstants.OUTPUT_DIR_PREFIX+"sbr-test3.0.gz",
+ CoreTestConstants.TEST_DIR_PREFIX + "witness/rolling/sbr-test3.0.gz"));
assertTrue(Compare.gzCompare(
- Constants.OUTPUT_DIR_PREFIX+"sbr-test3.1.gz",
- Constants.TEST_DIR_PREFIX + "witness/rolling/sbr-test3.1.gz"));
+ CoreTestConstants.OUTPUT_DIR_PREFIX+"sbr-test3.1.gz",
+ CoreTestConstants.TEST_DIR_PREFIX + "witness/rolling/sbr-test3.1.gz"));
}
// StatusPrinter.print(context.getStatusManager());
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingTest.java Tue Jul 7 20:22:04 2009
@@ -28,7 +28,7 @@
import ch.qos.logback.core.ContextBase;
import ch.qos.logback.core.layout.EchoLayout;
import ch.qos.logback.core.util.Compare;
-import ch.qos.logback.core.util.Constants;
+import ch.qos.logback.core.util.CoreTestConstants;
/**
* A rather exhaustive set of tests. Tests include leaving the file option
@@ -86,7 +86,7 @@
}
void deleteStaleLogFile(String filename) {
- File target = new File(Constants.OUTPUT_DIR_PREFIX + filename);
+ File target = new File(CoreTestConstants.OUTPUT_DIR_PREFIX + filename);
target.mkdirs();
target.delete();
}
@@ -124,7 +124,7 @@
public void noCompression_FileBlank_NoRestart_1() throws Exception {
String testId = "test1";
initRFA(rfa1, null);
- initTRBP(rfa1, tbrp1, Constants.OUTPUT_DIR_PREFIX + testId + "-%d{"
+ initTRBP(rfa1, tbrp1, CoreTestConstants.OUTPUT_DIR_PREFIX + testId + "-%d{"
+ DATE_PATTERN + "}", currentTime, 0);
// compute the current filename
@@ -142,7 +142,7 @@
int i = 0;
for (String fn : expectedFilenameList) {
- assertTrue(Compare.compare(fn, Constants.TEST_DIR_PREFIX
+ assertTrue(Compare.compare(fn, CoreTestConstants.TEST_DIR_PREFIX
+ "witness/rolling/tbr-" + testId + "." + i++));
}
}
@@ -155,7 +155,7 @@
String testId = "test2";
initRFA(rfa1, null);
- initTRBP(rfa1, tbrp1, Constants.OUTPUT_DIR_PREFIX + testId + "-%d{"
+ initTRBP(rfa1, tbrp1, CoreTestConstants.OUTPUT_DIR_PREFIX + testId + "-%d{"
+ DATE_PATTERN + "}", currentTime, 0);
// a new file is created by virtue of rfa.start();
@@ -174,7 +174,7 @@
rfa1.stop();
initRFA(rfa2, null);
- initTRBP(rfa2, tbrp2, Constants.OUTPUT_DIR_PREFIX + testId + "-%d{"
+ initTRBP(rfa2, tbrp2, CoreTestConstants.OUTPUT_DIR_PREFIX + testId + "-%d{"
+ DATE_PATTERN + "}", tbrp1.getCurrentTime(), 0);
for (int i = 0; i <= 2; i++) {
@@ -186,7 +186,7 @@
int i = 0;
for (String fn : expectedFilenameList) {
- assertTrue(Compare.compare(fn, Constants.TEST_DIR_PREFIX
+ assertTrue(Compare.compare(fn, CoreTestConstants.TEST_DIR_PREFIX
+ "witness/rolling/tbr-" + testId + "." + i++));
}
}
@@ -198,7 +198,7 @@
public void withCompression_FileBlank_NoRestart_3() throws Exception {
String testId = "test3";
initRFA(rfa1, null);
- initTRBP(rfa1, tbrp1, Constants.OUTPUT_DIR_PREFIX + testId + "-%d{"
+ initTRBP(rfa1, tbrp1, CoreTestConstants.OUTPUT_DIR_PREFIX + testId + "-%d{"
+ DATE_PATTERN + "}.gz", currentTime, 0);
addExpectedFileName_ByDate(testId, getDateOfCurrentPeriodsStart(), true);
@@ -217,7 +217,7 @@
int i = 0;
for (String fn : expectedFilenameList) {
- assertTrue(Compare.compare(fn, Constants.TEST_DIR_PREFIX
+ assertTrue(Compare.compare(fn, CoreTestConstants.TEST_DIR_PREFIX
+ "witness/rolling/tbr-" + testId + "." + i + addGZIfNotLast(i)));
i++;
}
@@ -230,7 +230,7 @@
public void noCompression_FileSet_StopRestart_4() throws Exception {
String testId = "test4";
initRFA(rfa1, testId2FileName(testId));
- initTRBP(rfa1, tbrp1, Constants.OUTPUT_DIR_PREFIX + testId + "-%d{"
+ initTRBP(rfa1, tbrp1, CoreTestConstants.OUTPUT_DIR_PREFIX + testId + "-%d{"
+ DATE_PATTERN + "}", currentTime, 0);
addExpectedFileName_ByDate(testId, getDateOfCurrentPeriodsStart(), false);
@@ -248,7 +248,7 @@
rfa1.stop();
initRFA(rfa2, testId2FileName(testId));
- initTRBP(rfa2, tbrp2, Constants.OUTPUT_DIR_PREFIX + testId + "-%d{"
+ initTRBP(rfa2, tbrp2, CoreTestConstants.OUTPUT_DIR_PREFIX + testId + "-%d{"
+ DATE_PATTERN + "}", currentTime, currentTime);
for (int i = 0; i <= 2; i++) {
@@ -262,7 +262,7 @@
int i = 0;
for (String fn : expectedFilenameList) {
- assertTrue(Compare.compare(fn, Constants.TEST_DIR_PREFIX
+ assertTrue(Compare.compare(fn, CoreTestConstants.TEST_DIR_PREFIX
+ "witness/rolling/tbr-" + testId + "." + i++));
}
}
@@ -272,7 +272,7 @@
throws Exception {
String testId = "test4B";
initRFA(rfa1, testId2FileName(testId));
- initTRBP(rfa1, tbrp1, Constants.OUTPUT_DIR_PREFIX + testId + "-%d{"
+ initTRBP(rfa1, tbrp1, CoreTestConstants.OUTPUT_DIR_PREFIX + testId + "-%d{"
+ DATE_PATTERN + "}", currentTime, 0);
addExpectedFileName_ByDate(testId, getDateOfCurrentPeriodsStart(), false);
@@ -292,8 +292,8 @@
long fileTimestamp = currentTime;
incCurrentTime(2000);
- initRFA(rfa2, Constants.OUTPUT_DIR_PREFIX + "test4B.log");
- initTRBP(rfa2, tbrp2, Constants.OUTPUT_DIR_PREFIX + testId +"-%d{"
+ initRFA(rfa2, CoreTestConstants.OUTPUT_DIR_PREFIX + "test4B.log");
+ initTRBP(rfa2, tbrp2, CoreTestConstants.OUTPUT_DIR_PREFIX + testId +"-%d{"
+ DATE_PATTERN + "}", currentTime, fileTimestamp);
for (int i = 0; i <= 2; i++) {
@@ -307,7 +307,7 @@
int i = 0;
for (String fn : expectedFilenameList) {
- assertTrue(Compare.compare(fn, Constants.TEST_DIR_PREFIX
+ assertTrue(Compare.compare(fn, CoreTestConstants.TEST_DIR_PREFIX
+ "witness/rolling/tbr-test4B." + i++));
}
@@ -321,7 +321,7 @@
String testId = "test5";
initRFA(rfa1, testId2FileName(testId));
- initTRBP(rfa1, tbrp1, Constants.OUTPUT_DIR_PREFIX + testId + "-%d{"
+ initTRBP(rfa1, tbrp1, CoreTestConstants.OUTPUT_DIR_PREFIX + testId + "-%d{"
+ DATE_PATTERN + "}", currentTime, 0);
addExpectedFileName_ByDate(testId, getDateOfCurrentPeriodsStart(), false);
@@ -340,7 +340,7 @@
int i = 0;
for (String fn : expectedFilenameList) {
- assertTrue(Compare.compare(fn, Constants.TEST_DIR_PREFIX
+ assertTrue(Compare.compare(fn, CoreTestConstants.TEST_DIR_PREFIX
+ "witness/rolling/tbr-test5." + i++));
}
}
@@ -354,7 +354,7 @@
String testId = "test6";
initRFA(rfa1, testId2FileName(testId));
- initTRBP(rfa1, tbrp1, Constants.OUTPUT_DIR_PREFIX + testId + "-%d{"
+ initTRBP(rfa1, tbrp1, CoreTestConstants.OUTPUT_DIR_PREFIX + testId + "-%d{"
+ DATE_PATTERN + "}.gz", currentTime, 0);
addExpectedFileName_ByDate(testId, getDateOfCurrentPeriodsStart(), true);
@@ -376,7 +376,7 @@
int i = 0;
for (String fn : expectedFilenameList) {
- assertTrue(Compare.compare(fn, Constants.TEST_DIR_PREFIX
+ assertTrue(Compare.compare(fn, CoreTestConstants.TEST_DIR_PREFIX
+ "witness/rolling/tbr-" + testId + "." + i + addGZIfNotLast(i)));
i++;
}
@@ -387,7 +387,7 @@
// =========================================================================
String testId2FileName(String testId) {
- return Constants.OUTPUT_DIR_PREFIX + testId + ".log";
+ return CoreTestConstants.OUTPUT_DIR_PREFIX + testId + ".log";
}
void massageExpectedFilesToCorresponToCurrentTarget(String file) {
@@ -407,7 +407,7 @@
}
void addExpectedFileName_ByDate(String testId, Date date, boolean gzExtension) {
- String fn = Constants.OUTPUT_DIR_PREFIX + testId + "-" + sdf.format(date);
+ String fn = CoreTestConstants.OUTPUT_DIR_PREFIX + testId + "-" + sdf.format(date);
if (gzExtension) {
fn += ".gz";
}
@@ -423,7 +423,7 @@
}
void addExpectedFileName_ByFile(String filenameSuffix) {
- String fn = Constants.OUTPUT_DIR_PREFIX + filenameSuffix;
+ String fn = CoreTestConstants.OUTPUT_DIR_PREFIX + filenameSuffix;
expectedFilenameList.add(fn);
}
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingWithCleanTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingWithCleanTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/TimeBasedRollingWithCleanTest.java Tue Jul 7 20:22:04 2009
@@ -13,7 +13,7 @@
import ch.qos.logback.core.Context;
import ch.qos.logback.core.ContextBase;
import ch.qos.logback.core.layout.EchoLayout;
-import ch.qos.logback.core.util.Constants;
+import ch.qos.logback.core.util.CoreTestConstants;
public class TimeBasedRollingWithCleanTest {
@@ -33,7 +33,7 @@
context.setName("test");
// remove all files containing the string 'clean'
- File dir = new File(Constants.OUTPUT_DIR_PREFIX);
+ File dir = new File(CoreTestConstants.OUTPUT_DIR_PREFIX);
if (dir.isDirectory()) {
File[] toDelete = dir.listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
@@ -53,14 +53,14 @@
@Test
public void montlyRollover() throws Exception {
- doRollover(Constants.OUTPUT_DIR_PREFIX + "clean-%d{" + MONTHLY_DATE_PATTERN
+ doRollover(CoreTestConstants.OUTPUT_DIR_PREFIX + "clean-%d{" + MONTHLY_DATE_PATTERN
+ "}.txt", MILLIS_IN_MONTH, 20);
}
@Test
public void dailyRollover() throws Exception {
- doRollover(Constants.OUTPUT_DIR_PREFIX + "clean-%d{" + DAILY_DATE_PATTERN
+ doRollover(CoreTestConstants.OUTPUT_DIR_PREFIX + "clean-%d{" + DAILY_DATE_PATTERN
+ "}.txt.zip", MILLIS_IN_DAY, 5);
}
@@ -96,7 +96,7 @@
void check(int expectedCount) {
// remove all files containing the string 'clean'
- File dir = new File(Constants.OUTPUT_DIR_PREFIX);
+ File dir = new File(CoreTestConstants.OUTPUT_DIR_PREFIX);
if (dir.isDirectory()) {
File[] match = dir.listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/CompressTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/CompressTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/rolling/helper/CompressTest.java Tue Jul 7 20:22:04 2009
@@ -25,7 +25,7 @@
import ch.qos.logback.core.Context;
import ch.qos.logback.core.ContextBase;
import ch.qos.logback.core.util.Compare;
-import ch.qos.logback.core.util.Constants;
+import ch.qos.logback.core.util.CoreTestConstants;
import ch.qos.logback.core.util.StatusPrinter;
/**
@@ -40,29 +40,29 @@
// Copy source files
// Delete output files
{
- File source = new File(Constants.TEST_DIR_PREFIX + "input/compress1.copy");
- File dest = new File(Constants.TEST_DIR_PREFIX + "input/compress1.txt");
+ File source = new File(CoreTestConstants.TEST_DIR_PREFIX + "input/compress1.copy");
+ File dest = new File(CoreTestConstants.TEST_DIR_PREFIX + "input/compress1.txt");
copy(source, dest);
- File target = new File(Constants.OUTPUT_DIR_PREFIX
+ File target = new File(CoreTestConstants.OUTPUT_DIR_PREFIX
+ "compress1.txt.gz");
target.mkdirs();
target.delete();
}
{
- File source = new File(Constants.TEST_DIR_PREFIX + "input/compress2.copy");
- File dest = new File(Constants.TEST_DIR_PREFIX + "input/compress2.txt");
+ File source = new File(CoreTestConstants.TEST_DIR_PREFIX + "input/compress2.copy");
+ File dest = new File(CoreTestConstants.TEST_DIR_PREFIX + "input/compress2.txt");
copy(source, dest);
- File target = new File(Constants.OUTPUT_DIR_PREFIX
+ File target = new File(CoreTestConstants.OUTPUT_DIR_PREFIX
+ "compress2.txt.gz");
target.mkdirs();
target.delete();
}
{
- File source = new File(Constants.TEST_DIR_PREFIX + "input/compress3.copy");
- File dest = new File(Constants.TEST_DIR_PREFIX + "input/compress3.txt");
+ File source = new File(CoreTestConstants.TEST_DIR_PREFIX + "input/compress3.copy");
+ File dest = new File(CoreTestConstants.TEST_DIR_PREFIX + "input/compress3.txt");
copy(source, dest);
- File target = new File(Constants.OUTPUT_DIR_PREFIX
+ File target = new File(CoreTestConstants.OUTPUT_DIR_PREFIX
+ "compress3.txt.zip");
target.mkdirs();
target.delete();
@@ -73,38 +73,38 @@
@Test
public void test1() throws Exception {
Compressor compressor = new Compressor(CompressionMode.GZ,
- Constants.TEST_DIR_PREFIX + "input/compress1.txt",
- Constants.OUTPUT_DIR_PREFIX + "compress1.txt.gz");
+ CoreTestConstants.TEST_DIR_PREFIX + "input/compress1.txt",
+ CoreTestConstants.OUTPUT_DIR_PREFIX + "compress1.txt.gz");
compressor.setContext(context);
compressor.compress();
StatusPrinter.print(context.getStatusManager());
assertEquals(0, context.getStatusManager().getCount());
- assertTrue(Compare.gzCompare(Constants.OUTPUT_DIR_PREFIX
- + "compress1.txt.gz", Constants.TEST_DIR_PREFIX
+ assertTrue(Compare.gzCompare(CoreTestConstants.OUTPUT_DIR_PREFIX
+ + "compress1.txt.gz", CoreTestConstants.TEST_DIR_PREFIX
+ "witness/compress1.txt.gz"));
}
@Test
public void test2() throws Exception {
Compressor compressor = new Compressor(CompressionMode.GZ,
- Constants.TEST_DIR_PREFIX + "input/compress2.txt",
- Constants.OUTPUT_DIR_PREFIX + "compress2.txt");
+ CoreTestConstants.TEST_DIR_PREFIX + "input/compress2.txt",
+ CoreTestConstants.OUTPUT_DIR_PREFIX + "compress2.txt");
compressor.setContext(context);
compressor.compress();
StatusPrinter.print(context.getStatusManager());
assertEquals(0, context.getStatusManager().getCount());
- assertTrue(Compare.gzCompare(Constants.OUTPUT_DIR_PREFIX
- + "compress2.txt.gz", Constants.TEST_DIR_PREFIX
+ assertTrue(Compare.gzCompare(CoreTestConstants.OUTPUT_DIR_PREFIX
+ + "compress2.txt.gz", CoreTestConstants.TEST_DIR_PREFIX
+ "witness/compress2.txt.gz"));
}
@Test
public void test3() throws Exception {
Compressor compressor = new Compressor(CompressionMode.ZIP,
- Constants.TEST_DIR_PREFIX + "input/compress3.txt",
- Constants.OUTPUT_DIR_PREFIX + "compress3.txt");
+ CoreTestConstants.TEST_DIR_PREFIX + "input/compress3.txt",
+ CoreTestConstants.OUTPUT_DIR_PREFIX + "compress3.txt");
compressor.setContext(context);
compressor.compress();
StatusPrinter.print(context.getStatusManager());
Copied: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/CoreTestConstants.java (from r2315, /logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/Constants.java)
==============================================================================
--- /logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/Constants.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/CoreTestConstants.java Tue Jul 7 20:22:04 2009
@@ -1,7 +1,7 @@
package ch.qos.logback.core.util;
-public class Constants {
+public class CoreTestConstants {
public static final String TEST_DIR_PREFIX = "src/test/";
public static final String OUTPUT_DIR_PREFIX = "target/test-output/";
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/FileUtilTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/FileUtilTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/FileUtilTest.java Tue Jul 7 20:22:04 2009
@@ -42,7 +42,7 @@
@Test
public void smoke() {
int diff = new Random().nextInt(100);
- File file = new File(Constants.OUTPUT_DIR_PREFIX+"/fu"+diff+"/testing.txt");
+ File file = new File(CoreTestConstants.OUTPUT_DIR_PREFIX+"/fu"+diff+"/testing.txt");
// these will be deleted later
cleanupList.add(file);
cleanupList.add(file.getParentFile());
@@ -55,7 +55,7 @@
@Test
public void smokeII() {
int diff = new Random().nextInt(100);
- File file = new File(Constants.OUTPUT_DIR_PREFIX+"/fu"+diff+"/bla/testing.txt");
+ File file = new File(CoreTestConstants.OUTPUT_DIR_PREFIX+"/fu"+diff+"/bla/testing.txt");
// these will be deleted later
cleanupList.add(file);
cleanupList.add(file.getParentFile());
Modified: logback/trunk/logback-site/src/site/pages/news.html
==============================================================================
--- logback/trunk/logback-site/src/site/pages/news.html (original)
+++ logback/trunk/logback-site/src/site/pages/news.html Tue Jul 7 20:22:04 2009
@@ -71,6 +71,14 @@
reported by Johan Bos.
</p>
+ <p>Fixed <a
+ href="http://jira.qos.ch/browse/LBCORE-105">LBCORE-105</a>. Configuration
+ files placed in jar files will no longer lock the jar file. This
+ issue was initially reported for log4j in <a
+ href="https://issues.apache.org/bugzilla/show_bug.cgi?id=47465">bug
+ 47465</a> Mark Thomas.
+ </p>
+
<hr width="80%" align="center" />
<h3>12th of February 2009 - Release of version 0.9.15</h3>
More information about the logback-dev
mailing list