[logback-dev] svn commit: r1798 - in logback/trunk/logback-classic/src: main/java/ch/qos/logback/classic/spi test/java/ch/qos/logback/classic test/java/ch/qos/logback/classic/html test/java/ch/qos/logback/classic/pattern test/java/ch/qos/logback/classic/spi
noreply.ceki at qos.ch
noreply.ceki at qos.ch
Mon Sep 8 20:02:17 CEST 2008
Author: ceki
Date: Mon Sep 8 20:02:17 2008
New Revision: 1798
Modified:
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/ClassPackagingDataCalculator.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/TestConstants.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/html/HTMLLayoutTest.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ConverterTest.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/BasicCPDCTest.java
Log:
- fine tuning tests so that they pass with BEA JRockit
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/ClassPackagingDataCalculator.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/ClassPackagingDataCalculator.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/ClassPackagingDataCalculator.java Mon Sep 8 20:02:17 2008
@@ -46,12 +46,12 @@
void populateFrames(StackTraceElementProxy[] stepArray) {
// in the initial part of this method we populate package informnation for
// common stack frames
- Throwable t = new Throwable("local stack reference");
- StackTraceElement[] localteSTEArray = t.getStackTrace();
- int commonFrames = STEUtil.findNumberOfCommonFrames(localteSTEArray,
+ final Throwable t = new Throwable("local stack reference");
+ final StackTraceElement[] localteSTEArray = t.getStackTrace();
+ final int commonFrames = STEUtil.findNumberOfCommonFrames(localteSTEArray,
stepArray);
- int localFirstCommon = localteSTEArray.length - commonFrames;
- int stepFirstCommon = stepArray.length - commonFrames;
+ final int localFirstCommon = localteSTEArray.length - commonFrames;
+ final int stepFirstCommon = stepArray.length - commonFrames;
ClassLoader lastExactClassLoader = null;
ClassLoader firsExactClassLoader = null;
@@ -79,8 +79,8 @@
populateUncommonFrames(commonFrames, stepArray, firsExactClassLoader);
}
- int findSTEStartIndex(ThrowableDataPoint[] tdpArray, int from) {
- int len = tdpArray.length;
+ int findSTEStartIndex(final ThrowableDataPoint[] tdpArray, final int from) {
+ final int len = tdpArray.length;
if (from < 0 || from >= len) {
return -1;
}
@@ -92,7 +92,7 @@
return -1;
}
- private StackTraceElementProxy[] getSTEPArray(ThrowableDataPoint[] tdpArray, int from) {
+ private StackTraceElementProxy[] getSTEPArray(final ThrowableDataPoint[] tdpArray, final int from) {
List<StackTraceElementProxy> stepList = new LinkedList<StackTraceElementProxy>();
int len = tdpArray.length;
if (from < 0 || from >= len) {
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/TestConstants.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/TestConstants.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/TestConstants.java Mon Sep 8 20:02:17 2008
@@ -12,7 +12,7 @@
public class TestConstants {
final static public String ISO_REGEX = "\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2},\\d{3}";
- final static public String MAIN_REGEX = "\\[[mM]ain(\\sThread)?\\]";
-
+ final static public String NAKED_MAIN_REGEX = "[mM]ain(\\sThread)?";
+ final static public String MAIN_REGEX = "\\["+NAKED_MAIN_REGEX+"\\]";
final static public String JORAN_ONPUT_PREFIX = "src/test/input/joran";
}
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/html/HTMLLayoutTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/html/HTMLLayoutTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/html/HTMLLayoutTest.java Mon Sep 8 20:02:17 2008
@@ -19,6 +19,7 @@
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.LoggerContext;
+import ch.qos.logback.classic.TestConstants;
import ch.qos.logback.classic.spi.LoggingEvent;
import ch.qos.logback.classic.spi.ThrowableDataPoint;
import ch.qos.logback.classic.spi.ThrowableProxy;
@@ -130,7 +131,8 @@
}
{
Element tdElement = (Element) trElement.elements().get(1);
- assertEquals("main", tdElement.getText());
+ String regex = TestConstants.NAKED_MAIN_REGEX;
+ assertTrue(tdElement.getText().toString().matches(regex));
}
{
Element tdElement = (Element) trElement.elements().get(2);
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ConverterTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ConverterTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ConverterTest.java Mon Sep 8 20:02:17 2008
@@ -20,6 +20,7 @@
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.LoggerContext;
+import ch.qos.logback.classic.TestConstants;
import ch.qos.logback.classic.spi.LoggingEvent;
import ch.qos.logback.core.CoreGlobal;
import ch.qos.logback.core.net.SyslogConstants;
@@ -73,7 +74,7 @@
StringBuffer buf = new StringBuffer();
converter.write(buf, le);
// the number below should be the line number of the previous line
- assertEquals("74", buf.toString());
+ assertEquals("75", buf.toString());
}
}
@@ -97,7 +98,8 @@
DynamicConverter<LoggingEvent> converter = new ThreadConverter();
StringBuffer buf = new StringBuffer();
converter.write(buf, le);
- assertEquals("main", buf.toString());
+ String regex = TestConstants.NAKED_MAIN_REGEX;
+ assertTrue(buf.toString().matches(regex));
}
public void testMessage() {
@@ -264,9 +266,11 @@
{
DynamicConverter<LoggingEvent> converter = new RelativeTimeConverter();
StringBuffer buf0 = new StringBuffer();
- converter.write(buf0, makeLoggingEvent(null));
StringBuffer buf1 = new StringBuffer();
- converter.write(buf1, makeLoggingEvent(null));
+ LoggingEvent e0 = makeLoggingEvent(null);
+ LoggingEvent e1 = makeLoggingEvent(null);
+ converter.write(buf0, e0);
+ converter.write(buf1, e1);
assertEquals(buf0.toString(), buf1.toString());
int rt0 = Integer.parseInt(buf0.toString());
if (rt0 < 50) {
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/BasicCPDCTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/BasicCPDCTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/BasicCPDCTest.java Mon Sep 8 20:02:17 2008
@@ -60,7 +60,6 @@
} catch (Throwable e) {
ThrowableProxy tp = new ThrowableProxy(e);
if (withClassPackagingCalculation) {
- tp.getClassPackagingDataCalculator();
ClassPackagingDataCalculator cpdc = tp
.getClassPackagingDataCalculator();
ThrowableDataPoint[] tdpArray = tp.getThrowableDataPointArray();
@@ -79,7 +78,7 @@
@Test
public void perfTest() {
- int len = 500;
+ int len = 1000;
loop(len, false);
loop(len, true);
@@ -89,7 +88,7 @@
double d1 = loop(len, true);
System.out.println("with packaging info " + d1 + " microseconds");
assertTrue("computing class packaging data (" + d1
- + ") should have been less than six times the time it takes to process an exception" + (d0 * 6),
+ + ") should have been less than six times the time it takes to process an exception " + (d0 * 6),
d0 * 6 > d1);
}
}
More information about the logback-dev
mailing list