svn commit: r693 - in logback/trunk: logback-core/src/test/java/ch/qos/logback/core/rolling logback-core/src/test/witness/rolling logback-site/src/site/xdocTemplates logback-site/src/site/xdocTemplates/manual

Author: seb Date: Mon Oct 16 16:54:52 2006 New Revision: 693 Added: logback/trunk/logback-core/src/test/witness/rolling/tbr-test3.2 logback/trunk/logback-core/src/test/witness/rolling/tbr-test6.2 Removed: logback/trunk/logback-core/src/test/witness/rolling/tbr-test1.3 logback/trunk/logback-core/src/test/witness/rolling/tbr-test2.3 logback/trunk/logback-core/src/test/witness/rolling/tbr-test3.2.gz logback/trunk/logback-core/src/test/witness/rolling/tbr-test3.3 logback/trunk/logback-core/src/test/witness/rolling/tbr-test4.3 logback/trunk/logback-core/src/test/witness/rolling/tbr-test5.3 logback/trunk/logback-core/src/test/witness/rolling/tbr-test6.2.gz logback/trunk/logback-core/src/test/witness/rolling/tbr-test6.3 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/TimeBasedRollingTest.java logback/trunk/logback-core/src/test/witness/rolling/tbr-test1.1 logback/trunk/logback-core/src/test/witness/rolling/tbr-test1.2 logback/trunk/logback-core/src/test/witness/rolling/tbr-test2.1 logback/trunk/logback-core/src/test/witness/rolling/tbr-test2.2 logback/trunk/logback-core/src/test/witness/rolling/tbr-test3.0.gz logback/trunk/logback-core/src/test/witness/rolling/tbr-test3.1.gz logback/trunk/logback-core/src/test/witness/rolling/tbr-test4.1 logback/trunk/logback-core/src/test/witness/rolling/tbr-test4.2 logback/trunk/logback-core/src/test/witness/rolling/tbr-test5.1 logback/trunk/logback-core/src/test/witness/rolling/tbr-test5.2 logback/trunk/logback-core/src/test/witness/rolling/tbr-test6.1.gz logback/trunk/logback-site/src/site/xdocTemplates/joran.xml logback/trunk/logback-site/src/site/xdocTemplates/manual/layouts.xml Log: faster tests. 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 Mon Oct 16 16:54:52 2006 @@ -134,7 +134,7 @@ // } for (int i = 0; i < 45; i++) { - Thread.sleep(100); + Thread.sleep(10); rfa.doAppend("hello"); } @@ -201,7 +201,7 @@ // } for (int i = 0; i < 45; i++) { - Thread.sleep(100); + Thread.sleep(10); rfa.doAppend("hello"); } 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 Mon Oct 16 16:54:52 2006 @@ -91,11 +91,11 @@ rfa.start(); SimpleDateFormat sdf = new SimpleDateFormat(DATE_PATTERN); - String[] filenames = new String[4]; + String[] filenames = new String[3]; Calendar cal = Calendar.getInstance(); - for (int i = 0; i < 4; i++) { + for (int i = 0; i < 3; i++) { filenames[i] = Constants.TEST_DIR_PREFIX + "output/test1-" + sdf.format(cal.getTime()); cal.add(Calendar.SECOND, 1); @@ -105,16 +105,16 @@ delayUntilNextSecond(100); System.out.println("Done waiting."); - for (int i = 0; i < 5; i++) { + for (int i = 0; i < 20; i++) { rfa.doAppend("Hello---" + i); - Thread.sleep(500); + Thread.sleep(50); } - for (int i = 0; i < 4; i++) { - // System.out.println(i + " expected filename [" + filenames[i] + "]."); - } +// for (int i = 0; i < 3; i++) { +// System.out.println(i + " expected filename [" + filenames[i] + "]."); +// } - for (int i = 0; i < 4; i++) { + for (int i = 0; i < 3; i++) { assertTrue(Compare.compare(filenames[i], Constants.TEST_DIR_PREFIX + "witness/rolling/tbr-test1." + i)); } @@ -135,11 +135,11 @@ rfa1.start(); SimpleDateFormat sdf = new SimpleDateFormat(DATE_PATTERN); - String[] filenames = new String[4]; + String[] filenames = new String[3]; Calendar cal = Calendar.getInstance(); - for (int i = 0; i < 4; i++) { + for (int i = 0; i < 3; i++) { filenames[i] = Constants.TEST_DIR_PREFIX + "output/test2-" + sdf.format(cal.getTime()); cal.add(Calendar.SECOND, 1); @@ -149,9 +149,9 @@ delayUntilNextSecond(100); System.out.println("Done waiting."); - for (int i = 0; i <= 2; i++) { + for (int i = 0; i <= 10; i++) { rfa1.doAppend("Hello---" + i); - Thread.sleep(500); + Thread.sleep(50); } rfa1.stop(); @@ -166,12 +166,12 @@ rfa2.setRollingPolicy(tbrp2); rfa2.start(); - for (int i = 3; i <= 4; i++) { + for (int i = 3; i <= 10; i++) { rfa2.doAppend("Hello---" + i); - Thread.sleep(500); + Thread.sleep(50); } - for (int i = 0; i < 4; i++) { + for (int i = 0; i < 3; i++) { assertTrue(Compare.compare(filenames[i], Constants.TEST_DIR_PREFIX + "witness/rolling/tbr-test2." + i)); } @@ -196,7 +196,7 @@ Calendar cal = Calendar.getInstance(); - for (int i = 0; i < 3; i++) { + for (int i = 0; i < 2; i++) { filenames[i] = Constants.TEST_DIR_PREFIX + "output/test3-" + sdf.format(cal.getTime()) + ".gz"; cal.add(Calendar.SECOND, 1); @@ -208,22 +208,22 @@ delayUntilNextSecond(100); System.out.println("Done waiting."); - for (int i = 0; i < 5; i++) { + for (int i = 0; i < 20; i++) { rfa.doAppend("Hello---" + i); - Thread.sleep(500); + Thread.sleep(50); } - for (int i = 0; i < 4; i++) { - // System.out.println(i + " expected filename [" + filenames[i] + "]."); - } +// for (int i = 0; i < 3; i++) { +// System.out.println(i + " expected filename [" + filenames[i] + "]."); +// } - for (int i = 0; i < 3; i++) { + for (int i = 0; i < 2; i++) { assertTrue(Compare.gzCompare(filenames[i], Constants.TEST_DIR_PREFIX + "witness/rolling/tbr-test3." + i + ".gz")); } assertTrue(Compare.compare(filenames[3], Constants.TEST_DIR_PREFIX - + "witness/rolling/tbr-test3.3")); + + "witness/rolling/tbr-test3.2")); } /** @@ -242,24 +242,24 @@ rfa1.start(); SimpleDateFormat sdf = new SimpleDateFormat(DATE_PATTERN); - String[] filenames = new String[4]; + String[] filenames = new String[3]; Calendar cal = Calendar.getInstance(); - for (int i = 0; i < 3; i++) { + for (int i = 0; i < 2; i++) { filenames[i] = Constants.TEST_DIR_PREFIX + "output/test4-" + sdf.format(cal.getTime()); cal.add(Calendar.SECOND, 1); } - filenames[3] = Constants.TEST_DIR_PREFIX + "output/test4.log"; + filenames[2] = Constants.TEST_DIR_PREFIX + "output/test4.log"; System.out.println("Waiting until next second and 100 millis."); delayUntilNextSecond(100); System.out.println("Done waiting."); - for (int i = 0; i <= 2; i++) { + for (int i = 0; i <= 22; i++) { rfa1.doAppend("Hello---" + i); - Thread.sleep(500); + Thread.sleep(50); } rfa1.stop(); @@ -275,12 +275,12 @@ rfa2.setRollingPolicy(tbrp2); rfa2.start(); - for (int i = 3; i <= 4; i++) { + for (int i = 3; i <= 5; i++) { rfa2.doAppend("Hello---" + i); - Thread.sleep(500); + Thread.sleep(20); } - for (int i = 0; i < 4; i++) { + for (int i = 0; i < 3; i++) { assertTrue(Compare.compare(filenames[i], Constants.TEST_DIR_PREFIX + "witness/rolling/tbr-test4." + i)); } @@ -306,24 +306,24 @@ Calendar cal = Calendar.getInstance(); - for (int i = 0; i < 3; i++) { + for (int i = 0; i < 2; i++) { filenames[i] = Constants.TEST_DIR_PREFIX + "output/test5-" + sdf.format(cal.getTime()); cal.add(Calendar.SECOND, 1); } - filenames[3] = Constants.TEST_DIR_PREFIX + "output/test5.log"; + filenames[2] = Constants.TEST_DIR_PREFIX + "output/test5.log"; System.out.println("Waiting until next second and 100 millis."); delayUntilNextSecond(100); System.out.println("Done waiting."); - for (int i = 0; i < 5; i++) { + for (int i = 0; i < 20; i++) { rfa.doAppend("Hello---" + i); - Thread.sleep(500); + Thread.sleep(50); } - for (int i = 0; i < 4; i++) { + for (int i = 0; i < 3; i++) { assertTrue(Compare.compare(filenames[i], Constants.TEST_DIR_PREFIX + "witness/rolling/tbr-test5." + i)); } @@ -349,34 +349,34 @@ Calendar cal = Calendar.getInstance(); - for (int i = 0; i < 3; i++) { + for (int i = 0; i < 2; i++) { filenames[i] = Constants.TEST_DIR_PREFIX + "output/test6-" + sdf.format(cal.getTime()) + ".gz"; cal.add(Calendar.SECOND, 1); } - filenames[3] = Constants.TEST_DIR_PREFIX + "output/test6.log"; + filenames[2] = Constants.TEST_DIR_PREFIX + "output/test6.log"; System.out.println("Waiting until next second and 100 millis."); delayUntilNextSecond(100); System.out.println("Done waiting."); - for (int i = 0; i < 5; i++) { + for (int i = 0; i < 20; i++) { rfa.doAppend("Hello---" + i); - Thread.sleep(500); + Thread.sleep(50); } for (int i = 0; i < 4; i++) { // System.out.println(i + " expected filename [" + filenames[i] + "]."); } - for (int i = 0; i < 3; i++) { + for (int i = 0; i < 2; i++) { assertTrue(Compare.gzCompare(filenames[i], Constants.TEST_DIR_PREFIX + "witness/rolling/tbr-test6." + i + ".gz")); } - assertTrue(Compare.compare(filenames[3], Constants.TEST_DIR_PREFIX - + "witness/rolling/tbr-test6.3")); + assertTrue(Compare.compare(filenames[2], Constants.TEST_DIR_PREFIX + + "witness/rolling/tbr-test6.2")); } // public void testWithJoran1() throws Exception { Modified: logback/trunk/logback-core/src/test/witness/rolling/tbr-test1.1 ============================================================================== --- logback/trunk/logback-core/src/test/witness/rolling/tbr-test1.1 (original) +++ logback/trunk/logback-core/src/test/witness/rolling/tbr-test1.1 Mon Oct 16 16:54:52 2006 @@ -1,2 +1,15 @@ -Hello---0 -Hello---1 +Hello---0 +Hello---1 +Hello---2 +Hello---3 +Hello---4 +Hello---5 +Hello---6 +Hello---7 +Hello---8 +Hello---9 +Hello---10 +Hello---11 +Hello---12 +Hello---13 +Hello---14 Modified: logback/trunk/logback-core/src/test/witness/rolling/tbr-test1.2 ============================================================================== --- logback/trunk/logback-core/src/test/witness/rolling/tbr-test1.2 (original) +++ logback/trunk/logback-core/src/test/witness/rolling/tbr-test1.2 Mon Oct 16 16:54:52 2006 @@ -1,2 +1,5 @@ -Hello---2 -Hello---3 +Hello---15 +Hello---16 +Hello---17 +Hello---18 +Hello---19 Modified: logback/trunk/logback-core/src/test/witness/rolling/tbr-test2.1 ============================================================================== --- logback/trunk/logback-core/src/test/witness/rolling/tbr-test2.1 (original) +++ logback/trunk/logback-core/src/test/witness/rolling/tbr-test2.1 Mon Oct 16 16:54:52 2006 @@ -1,2 +1,15 @@ -Hello---0 -Hello---1 +Hello---0 +Hello---1 +Hello---2 +Hello---3 +Hello---4 +Hello---5 +Hello---6 +Hello---7 +Hello---8 +Hello---9 +Hello---10 +Hello---3 +Hello---4 +Hello---5 +Hello---6 Modified: logback/trunk/logback-core/src/test/witness/rolling/tbr-test2.2 ============================================================================== --- logback/trunk/logback-core/src/test/witness/rolling/tbr-test2.2 (original) +++ logback/trunk/logback-core/src/test/witness/rolling/tbr-test2.2 Mon Oct 16 16:54:52 2006 @@ -1,2 +1,4 @@ -Hello---2 -Hello---3 +Hello---7 +Hello---8 +Hello---9 +Hello---10 Modified: logback/trunk/logback-core/src/test/witness/rolling/tbr-test3.0.gz ============================================================================== Binary files. No diff available. Modified: logback/trunk/logback-core/src/test/witness/rolling/tbr-test3.1.gz ============================================================================== Binary files. No diff available. Added: logback/trunk/logback-core/src/test/witness/rolling/tbr-test3.2 ============================================================================== --- (empty file) +++ logback/trunk/logback-core/src/test/witness/rolling/tbr-test3.2 Mon Oct 16 16:54:52 2006 @@ -0,0 +1,5 @@ +Hello---15 +Hello---16 +Hello---17 +Hello---18 +Hello---19 Modified: logback/trunk/logback-core/src/test/witness/rolling/tbr-test4.1 ============================================================================== --- logback/trunk/logback-core/src/test/witness/rolling/tbr-test4.1 (original) +++ logback/trunk/logback-core/src/test/witness/rolling/tbr-test4.1 Mon Oct 16 16:54:52 2006 @@ -1,2 +1,15 @@ -Hello---0 -Hello---1 +Hello---0 +Hello---1 +Hello---2 +Hello---3 +Hello---4 +Hello---5 +Hello---6 +Hello---7 +Hello---8 +Hello---9 +Hello---10 +Hello---11 +Hello---12 +Hello---13 +Hello---14 Modified: logback/trunk/logback-core/src/test/witness/rolling/tbr-test4.2 ============================================================================== --- logback/trunk/logback-core/src/test/witness/rolling/tbr-test4.2 (original) +++ logback/trunk/logback-core/src/test/witness/rolling/tbr-test4.2 Mon Oct 16 16:54:52 2006 @@ -1,2 +1,11 @@ -Hello---2 -Hello---3 +Hello---15 +Hello---16 +Hello---17 +Hello---18 +Hello---19 +Hello---20 +Hello---21 +Hello---22 +Hello---3 +Hello---4 +Hello---5 \ No newline at end of file Modified: logback/trunk/logback-core/src/test/witness/rolling/tbr-test5.1 ============================================================================== --- logback/trunk/logback-core/src/test/witness/rolling/tbr-test5.1 (original) +++ logback/trunk/logback-core/src/test/witness/rolling/tbr-test5.1 Mon Oct 16 16:54:52 2006 @@ -1,2 +1,15 @@ -Hello---0 -Hello---1 +Hello---0 +Hello---1 +Hello---2 +Hello---3 +Hello---4 +Hello---5 +Hello---6 +Hello---7 +Hello---8 +Hello---9 +Hello---10 +Hello---11 +Hello---12 +Hello---13 +Hello---14 Modified: logback/trunk/logback-core/src/test/witness/rolling/tbr-test5.2 ============================================================================== --- logback/trunk/logback-core/src/test/witness/rolling/tbr-test5.2 (original) +++ logback/trunk/logback-core/src/test/witness/rolling/tbr-test5.2 Mon Oct 16 16:54:52 2006 @@ -1,2 +1,5 @@ -Hello---2 -Hello---3 +Hello---15 +Hello---16 +Hello---17 +Hello---18 +Hello---19 Modified: logback/trunk/logback-core/src/test/witness/rolling/tbr-test6.1.gz ============================================================================== Binary files. No diff available. Added: logback/trunk/logback-core/src/test/witness/rolling/tbr-test6.2 ============================================================================== --- (empty file) +++ logback/trunk/logback-core/src/test/witness/rolling/tbr-test6.2 Mon Oct 16 16:54:52 2006 @@ -0,0 +1,5 @@ +Hello---15 +Hello---16 +Hello---17 +Hello---18 +Hello---19 Modified: logback/trunk/logback-site/src/site/xdocTemplates/joran.xml ============================================================================== --- logback/trunk/logback-site/src/site/xdocTemplates/joran.xml (original) +++ logback/trunk/logback-site/src/site/xdocTemplates/joran.xml Mon Oct 16 16:54:52 2006 @@ -237,7 +237,7 @@ What is interesting here is the way that the Actions collaborate. The <code>LiteralAction</code> reads a literal value and pushes it in the object stack maintained by the <code>ExecutionContext</code>. Once done, -any other action can pop the value back to read or modify it. Here, the +any other action can pop the value to read or modify it. Here, the <code>end()</code> method of the <code>ComputationAction1</code> class pops the value from the stack and prints it. </p> @@ -303,6 +303,31 @@ and a <em>actionClass</em> attribute. The action class is then instanciated and added to the <code>RuleStore</code>, along with its corresponding pattern.</p> +<p>Here is how new rules can be declared in an xml file:</p> + +<div class="source"><new-rule pattern="*/computation/literal" actionClass="joran.calculator.LiteralAction"/></div> + +<p>Using new rule declarations, the preceding example, involving the calculation, could be +expressed this way:</p> + +<div class="source"><computation name="toto"> + <new-rule pattern="*/computation/literal" + actionClass="joran.calculator.LiteralAction"/> + <new-rule pattern="*/computation/add" + actionClass="joran.calculator.AddAction"/> + <new-rule pattern="*/computation/multiply" + actionClass="joran.calculator.MultiplyAction"/> + + <computation> + <literal value="7"/> + <literal value="3"/> + <add/> + </computation> + + <literal value="3"/> + <multiply/> +</computation></div> + <a name="implicit" /> <h3>Implicit actions </h3> <p>The rules defined thus far are called explicit rules because they @@ -357,11 +382,11 @@ directory for an example of an implicit action. </p> -<p>In that directory, you will find two actions, one xml file and one +<p>In that directory, you will find two actions classes, one xml file and one class containing the setup of Joran.</p> <p>The <code>NOPAction</code> class does nothing. It is used to set -the context of the <em>foo</em> element, using that line:</p> +the context of the <em>foo</em> element, using this line:</p> <source>ruleStore.addRule(new Pattern("*/foo"), new NOPAction());</source> @@ -399,6 +424,16 @@ we added a <code>NOPAction</code> with the <em>*/foo</em> pattern, it will be used instead of the <code>PrintMeImplicitAction</code>.</p> +<p>Running the example yields the following output:</p> + +<div class="source">Element <xyz> asked to be printed. +Element <abc> asked to be printed. +ERROR in ch.qos.logback.core.joran.spi.ExecutionContext@1c5c1 - no applicable action \ +for <xyz>, current pattern is [/foo/xyz]</div> + +<p>The last line was printed because of a call to <code>StatusPrinter</code> at the end +of the main class.</p> + <h3>Non goals</h3> <p>The Joran API is not intended to be used to parse documents with Modified: logback/trunk/logback-site/src/site/xdocTemplates/manual/layouts.xml ============================================================================== --- logback/trunk/logback-site/src/site/xdocTemplates/manual/layouts.xml (original) +++ logback/trunk/logback-site/src/site/xdocTemplates/manual/layouts.xml Mon Oct 16 16:54:52 2006 @@ -704,7 +704,7 @@ </em> <div class="source"><configuration> <b><evaluator name="DISP_CALLER_EVAL"> - <Expression>logger.getName().contains("chapter5") && \ + <Expression>logger.getName().contains("chapter5") && \ message.contains("stacktrace")</Expression> </evaluator></b> @@ -720,6 +720,8 @@ <appender-ref ref="STDOUT" /> </root> </configuration></div> + <p>Please note that & value cannot be written like one would in a java + class, because of XML format encoding.</p> <p>Let's test this configuration with the following code.</p> <em> Example 5.2: Sample usage of EventEvaluators
participants (1)
-
noreply.seb@qos.ch