Output fixes

This commit is contained in:
Bruce Eckel 2015-12-16 13:50:01 -08:00
parent cdc6ddb331
commit 5f1059da6f
31 changed files with 259 additions and 166 deletions

View File

@ -17,6 +17,7 @@
<include name="**/*.err" /> <include name="**/*.err" />
<include name="**/*.dat" /> <include name="**/*.dat" />
<include name="**/*.log" /> <include name="**/*.log" />
<include name="**/*.serialized" />
<include name="**/failures" /> <include name="**/failures" />
<include name="**/test.gz" /> <include name="**/test.gz" />
<include name="**/test.zip" /> <include name="**/test.zip" />

View File

@ -176,7 +176,9 @@
<fileset dir="${basedir}" casesensitive="yes"> <fileset dir="${basedir}" casesensitive="yes">
<include name="**/update_output.bat" /> <include name="**/update_output.bat" />
<include name="**/validate_failures.txt" /> <include name="**/validate_failures.txt" />
<include name="**/validate_successes.txt" />
<include name="**/strategies.txt" /> <include name="**/strategies.txt" />
<include name="**/edit_errors.bat" />
</fileset> </fileset>
</delete> </delete>
<echo message="verifyclean successful"/> <echo message="verifyclean successful"/>

View File

@ -17,8 +17,8 @@ public class AtUnitComposition {
return testObject.methodTwo() == 2; return testObject.methodTwo() == 2;
} }
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
OSExecute.command( OSExecute.command("java -cp .. " +
"java -cp .. onjava.atunit.AtUnit AtUnitComposition.class"); "onjava.atunit.AtUnit AtUnitComposition.class");
} }
} }
/* Output: /* Output:

View File

@ -23,8 +23,8 @@ public class AtUnitExample1 {
@Test boolean failureTest() { return false; } @Test boolean failureTest() { return false; }
@Test boolean anotherDisappointment() { return false; } @Test boolean anotherDisappointment() { return false; }
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
OSExecute.command( OSExecute.command("java -cp .. " +
"java -cp .. onjava.atunit.AtUnit AtUnitExample1.class"); "onjava.atunit.AtUnit AtUnitExample1.class");
} }
} }
/* Output: /* Output:

View File

@ -31,8 +31,8 @@ public class AtUnitExample2 {
return methodOne().equals("This is methodOne"); return methodOne().equals("This is methodOne");
} }
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
OSExecute.command( OSExecute.command("java -cp .. " +
"java -cp .. onjava.atunit.AtUnit AtUnitExample2.class"); "onjava.atunit.AtUnit AtUnitExample2.class");
} }
} }
/* Output: /* Output:

View File

@ -26,8 +26,8 @@ public class AtUnitExample3 {
} }
@Test boolean m2() { return methodTwo() == 2; } @Test boolean m2() { return methodTwo() == 2; }
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
OSExecute.command( OSExecute.command("java -cp .. " +
"java -cp .. onjava.atunit.AtUnit AtUnitExample3.class"); "onjava.atunit.AtUnit AtUnitExample3.class");
} }
} }
/* Output: /* Output:

View File

@ -57,8 +57,8 @@ public class AtUnitExample4 {
} }
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
System.out.println("starting"); System.out.println("starting");
OSExecute.command( OSExecute.command("java -cp .. " +
"java -cp .. onjava.atunit.AtUnit AtUnitExample4.class"); "onjava.atunit.AtUnit AtUnitExample4.class");
} }
} }
/* Output: /* Output:

View File

@ -41,8 +41,8 @@ public class AtUnitExample5 {
return true; return true;
} }
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
OSExecute.command( OSExecute.command("java -cp .. " +
"java -cp .. onjava.atunit.AtUnit AtUnitExample5.class"); "onjava.atunit.AtUnit AtUnitExample5.class");
} }
} }
/* Output: /* Output:

View File

@ -13,8 +13,8 @@ public class AtUnitExternalTest extends AtUnitExample1 {
} }
@Test boolean _methodTwo() { return methodTwo() == 2; } @Test boolean _methodTwo() { return methodTwo() == 2; }
public static void main(String[] args) throws Exception{ public static void main(String[] args) throws Exception{
OSExecute.command( OSExecute.command("java -cp .. " +
"java -cp .. onjava.atunit.AtUnit AtUnitExternalTest.class"); "onjava.atunit.AtUnit AtUnitExternalTest.class");
} }
} }
/* Output: /* Output:

View File

@ -22,8 +22,8 @@ public class HashSetTest {
assert testObject.isEmpty(); assert testObject.isEmpty();
} }
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
OSExecute.command( OSExecute.command("java -cp .. " +
"java -cp .. onjava.atunit.AtUnit HashSetTest.class"); "onjava.atunit.AtUnit HashSetTest.class");
} }
} }
/* Output: /* Output:

View File

@ -27,8 +27,8 @@ public class StackLStringTest extends StackL<String> {
assert top().equals("B"); assert top().equals("B");
} }
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
OSExecute.command( OSExecute.command("java -cp .. " +
"java -cp .. onjava.atunit.AtUnit StackLStringTest.class"); "onjava.atunit.AtUnit StackLStringTest.class");
} }
} }
/* Output: /* Output:

View File

@ -111,7 +111,7 @@
<antcall target="finish"/> <antcall target="finish"/>
</target> </target>
<target name="testable" description="Compiles and runs all examples"> <target name="testable" description="Compiles and runs testable examples">
<delete file="errors.txt"/> <delete file="errors.txt"/>
<subant> <subant>
<filelist refid="testablefiles"/> <filelist refid="testablefiles"/>
@ -140,7 +140,9 @@
<fileset dir="${basedir}" casesensitive="yes"> <fileset dir="${basedir}" casesensitive="yes">
<include name="update_output.bat" /> <include name="update_output.bat" />
<include name="validate_failures.txt" /> <include name="validate_failures.txt" />
<include name="validate_successes.txt" />
<include name="strategies.txt" /> <include name="strategies.txt" />
<include name="edit_errors.bat" />
</fileset> </fileset>
</delete> </delete>
<echo message="verifyclean successful"/> <echo message="verifyclean successful"/>

View File

@ -32,7 +32,7 @@ public class ApplesAndOrangesWithoutGenerics {
___[ Error Output ]___ ___[ Error Output ]___
Exception in thread "main" java.lang.ClassCastException: Exception in thread "main" java.lang.ClassCastException:
Orange cannot be cast to Apple Orange cannot be cast to Apple
at ApplesAndOrangesWithoutGenerics.main(ApplesAndOr at ApplesAndOrangesWithoutGenerics.main(Unknown
angesWithoutGenerics.java:23) Source)
___[ Exception is Expected ]___ ___[ Exception is Expected ]___
*/ */

View File

@ -52,6 +52,32 @@ public class ExplicitCriticalSection {
} }
} }
/* Output: /* Output:
pm1: Pair: x: 10, y: 10 checkCounter = 2115789 pm1: Pair: x: 10, y: 10 checkCounter = 2193118
pm2: Pair: x: 10, y: 10 checkCounter = 2124465 pm2: Pair: x: 10, y: 10 checkCounter = 2184256
___[ Error Output ]___
Exception in thread "pool-1-thread-4" Exception in thread
"pool-1-thread-3"
concurrency.Pair$PairValuesNotEqualException: Pair values
not equal: x: 2, y: 1
at
concurrency.Pair.checkState(CriticalSection.java:36)
at
concurrency.PairChecker.run(CriticalSection.java:110)
at java.util.concurrent.ThreadPoolExecutor.runWorke
r(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.r
un(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
concurrency.Pair$PairValuesNotEqualException: Pair values
not equal: x: 2, y: 1
at
concurrency.Pair.checkState(CriticalSection.java:36)
at
concurrency.PairChecker.run(CriticalSection.java:110)
at java.util.concurrent.ThreadPoolExecutor.runWorke
r(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.r
un(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
___[ Exception is Expected ]___
*/ */

View File

@ -26,7 +26,7 @@
<jrun cls="DaemonsDoRunFinally" /> <jrun cls="DaemonsDoRunFinally" />
<jrun cls="DeadlockingDiningPhilosophers" arguments="0 5 timeout" /> <jrun cls="DeadlockingDiningPhilosophers" arguments="0 5 timeout" />
<jrun cls="DelayQueueDemo" /> <jrun cls="DelayQueueDemo" />
<jrun cls="EvenSupplier" /> <jrun cls="EvenSupplier" failOnError='false' timeOut='4000' msg='* Timeout for Testing *' />
<jrun cls="ExchangerDemo" /> <jrun cls="ExchangerDemo" />
<jrun cls="concurrency.ExplicitCriticalSection" dirpath="../concurrency" failOnError='false' msg='* Exception was Expected *' /> <jrun cls="concurrency.ExplicitCriticalSection" dirpath="../concurrency" failOnError='false' msg='* Exception was Expected *' />
<jrun cls="FastSimulation" /> <jrun cls="FastSimulation" />

View File

@ -3,6 +3,7 @@
// We make no guarantees that this code is fit for any purpose. // We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information. // Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// An exception that reports through a Logger. // An exception that reports through a Logger.
// {ErrorOutputExpected}
import java.util.logging.*; import java.util.logging.*;
import java.io.*; import java.io.*;
@ -32,14 +33,17 @@ public class LoggingExceptions {
} }
/* Output: /* Output:
___[ Error Output ]___ ___[ Error Output ]___
Jun 15, 2015 3:47:40 PM LoggingException <init> Dec 15, 2015 10:34:24 PM LoggingException <init>
SEVERE: LoggingException SEVERE: LoggingException
at at
LoggingExceptions.main(LoggingExceptions.java:19) LoggingExceptions.main(LoggingExceptions.java:20)
Caught LoggingException Caught LoggingException
Jun 15, 2015 3:47:40 PM LoggingException <init> Dec 15, 2015 10:34:24 PM LoggingException <init>
SEVERE: LoggingException SEVERE: LoggingException
at at
LoggingExceptions.main(LoggingExceptions.java:24) LoggingExceptions.main(LoggingExceptions.java:25)
Caught LoggingException Caught LoggingException
___[ Error Output is Expected ]___
*/ */

View File

@ -3,6 +3,7 @@
// We make no guarantees that this code is fit for any purpose. // We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information. // Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Logging caught exceptions. // Logging caught exceptions.
// {ErrorOutputExpected}
import java.util.logging.*; import java.util.logging.*;
import java.io.*; import java.io.*;
@ -24,8 +25,9 @@ public class LoggingExceptions2 {
} }
/* Output: /* Output:
___[ Error Output ]___ ___[ Error Output ]___
Jun 15, 2015 3:47:40 PM LoggingExceptions2 logException Dec 15, 2015 10:34:25 PM LoggingExceptions2 logException
SEVERE: java.lang.NullPointerException SEVERE: java.lang.NullPointerException
at at
LoggingExceptions2.main(LoggingExceptions2.java:16) LoggingExceptions2.main(LoggingExceptions2.java:17)
___[ Error Output is Expected ]___
*/ */

View File

@ -3,6 +3,7 @@
// We make no guarantees that this code is fit for any purpose. // We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information. // Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// {JVMArgs: -Djava.util.logging.config.file=log.prop} // {JVMArgs: -Djava.util.logging.config.file=log.prop}
// {ErrorOutputExpected}
import java.util.logging.*; import java.util.logging.*;
public class ConfigureLogging { public class ConfigureLogging {
@ -43,46 +44,41 @@ public class ConfigureLogging {
} }
} }
/* Output: /* Output:
Logger Name : net Level: SEVERE Logger Name : com Level: null
Logger Name : com.mindviewinc Level: FINEST Logger Name : com.mindviewinc Level: null
Logger Name : onjava Level: INFO Logger Name : onjava Level: null
Logger Name : com.mindviewinc.test Level: FINER Logger Name : com.mindviewinc.test Level: null
Logger Name : random Level: SEVERE Logger Name : random Level: null
___[ Error Output ]___ ___[ Error Output ]___
Jun 15, 2015 3:47:52 PM ConfigureLogging sendLogMessages Dec 15, 2015 9:58:42 PM ConfigureLogging sendLogMessages
SEVERE: Severe
Jun 15, 2015 3:47:52 PM ConfigureLogging sendLogMessages
FINEST: Finest
Jun 15, 2015 3:47:52 PM ConfigureLogging sendLogMessages
FINER: Finer
Jun 15, 2015 3:47:52 PM ConfigureLogging sendLogMessages
FINE: Fine
Jun 15, 2015 3:47:52 PM ConfigureLogging sendLogMessages
CONFIG: Config
Jun 15, 2015 3:47:52 PM ConfigureLogging sendLogMessages
INFO: Info INFO: Info
Jun 15, 2015 3:47:52 PM ConfigureLogging sendLogMessages Dec 15, 2015 9:58:42 PM ConfigureLogging sendLogMessages
WARNING: Warning WARNING: Warning
Jun 15, 2015 3:47:52 PM ConfigureLogging sendLogMessages Dec 15, 2015 9:58:42 PM ConfigureLogging sendLogMessages
SEVERE: Severe SEVERE: Severe
Jun 15, 2015 3:47:52 PM ConfigureLogging sendLogMessages Dec 15, 2015 9:58:42 PM ConfigureLogging sendLogMessages
INFO: Info INFO: Info
Jun 15, 2015 3:47:52 PM ConfigureLogging sendLogMessages Dec 15, 2015 9:58:42 PM ConfigureLogging sendLogMessages
WARNING: Warning WARNING: Warning
Jun 15, 2015 3:47:52 PM ConfigureLogging sendLogMessages Dec 15, 2015 9:58:42 PM ConfigureLogging sendLogMessages
SEVERE: Severe SEVERE: Severe
Jun 15, 2015 3:47:52 PM ConfigureLogging sendLogMessages Dec 15, 2015 9:58:42 PM ConfigureLogging sendLogMessages
FINER: Finer
Jun 15, 2015 3:47:52 PM ConfigureLogging sendLogMessages
FINE: Fine
Jun 15, 2015 3:47:52 PM ConfigureLogging sendLogMessages
CONFIG: Config
Jun 15, 2015 3:47:52 PM ConfigureLogging sendLogMessages
INFO: Info INFO: Info
Jun 15, 2015 3:47:52 PM ConfigureLogging sendLogMessages Dec 15, 2015 9:58:42 PM ConfigureLogging sendLogMessages
WARNING: Warning WARNING: Warning
Jun 15, 2015 3:47:52 PM ConfigureLogging sendLogMessages Dec 15, 2015 9:58:42 PM ConfigureLogging sendLogMessages
SEVERE: Severe SEVERE: Severe
Jun 15, 2015 3:47:52 PM ConfigureLogging sendLogMessages Dec 15, 2015 9:58:42 PM ConfigureLogging sendLogMessages
INFO: Info
Dec 15, 2015 9:58:42 PM ConfigureLogging sendLogMessages
WARNING: Warning
Dec 15, 2015 9:58:42 PM ConfigureLogging sendLogMessages
SEVERE: Severe SEVERE: Severe
Dec 15, 2015 9:58:42 PM ConfigureLogging sendLogMessages
INFO: Info
Dec 15, 2015 9:58:42 PM ConfigureLogging sendLogMessages
WARNING: Warning
Dec 15, 2015 9:58:42 PM ConfigureLogging sendLogMessages
SEVERE: Severe
___[ Error Output is Expected ]___
*/ */

View File

@ -3,6 +3,7 @@
// We make no guarantees that this code is fit for any purpose. // We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information. // Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// How to write custom handler // How to write custom handler
// {ErrorOutputExpected}
import java.util.logging.*; import java.util.logging.*;
import java.util.*; import java.util.*;
@ -39,8 +40,9 @@ public class CustomHandler {
, INFO:, CustomHandler:, main:, <Logging Info>, , INFO:, CustomHandler:, main:, <Logging Info>,
] ]
___[ Error Output ]___ ___[ Error Output ]___
Jun 15, 2015 3:47:52 PM CustomHandler main Dec 15, 2015 9:58:42 PM CustomHandler main
WARNING: Logging Warning WARNING: Logging Warning
Jun 15, 2015 3:47:52 PM CustomHandler main Dec 15, 2015 9:58:42 PM CustomHandler main
INFO: Logging Info INFO: Logging Info
___[ Error Output is Expected ]___
*/ */

View File

@ -2,6 +2,7 @@
// (c)2016 MindView LLC: see Copyright.txt // (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose. // We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information. // Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// {ErrorOutputExpected}
import java.util.logging.*; import java.util.logging.*;
public class InfoLogging { public class InfoLogging {
@ -13,6 +14,7 @@ public class InfoLogging {
} }
/* Output: /* Output:
___[ Error Output ]___ ___[ Error Output ]___
Jun 15, 2015 3:47:52 PM InfoLogging main Dec 15, 2015 9:58:43 PM InfoLogging main
INFO: Logging: INFO-level message INFO: Logging: INFO-level message
___[ Error Output is Expected ]___
*/ */

View File

@ -3,6 +3,7 @@
// We make no guarantees that this code is fit for any purpose. // We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information. // Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// Guaranteeing proper class and method names // Guaranteeing proper class and method names
// {ErrorOutputExpected}
import java.util.logging.*; import java.util.logging.*;
public class InfoLogging2 { public class InfoLogging2 {
@ -15,6 +16,7 @@ public class InfoLogging2 {
} }
/* Output: /* Output:
___[ Error Output ]___ ___[ Error Output ]___
Jun 15, 2015 3:47:52 PM InfoLogging2 main Dec 15, 2015 9:58:43 PM InfoLogging2 main
INFO: Logging an INFO-level message INFO: Logging an INFO-level message
___[ Error Output is Expected ]___
*/ */

View File

@ -2,6 +2,7 @@
// (c)2016 MindView LLC: see Copyright.txt // (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose. // We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information. // Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// {ErrorOutputExpected}
import java.util.logging.*; import java.util.logging.*;
public class LogToFile { public class LogToFile {
@ -16,6 +17,7 @@ public class LogToFile {
} }
/* Output: /* Output:
___[ Error Output ]___ ___[ Error Output ]___
Jun 15, 2015 3:47:52 PM LogToFile main Dec 15, 2015 9:58:43 PM LogToFile main
INFO: A message logged to the file INFO: A message logged to the file
___[ Error Output is Expected ]___
*/ */

View File

@ -2,6 +2,7 @@
// (c)2016 MindView LLC: see Copyright.txt // (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose. // We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information. // Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// {ErrorOutputExpected}
import java.util.logging.*; import java.util.logging.*;
public class LogToFile2 { public class LogToFile2 {
@ -18,6 +19,7 @@ public class LogToFile2 {
} }
/* Output: /* Output:
___[ Error Output ]___ ___[ Error Output ]___
Jun 15, 2015 3:47:52 PM LogToFile2 main Dec 15, 2015 9:58:43 PM LogToFile2 main
INFO: A message logged to the file INFO: A message logged to the file
___[ Error Output is Expected ]___
*/ */

View File

@ -2,6 +2,7 @@
// (c)2016 MindView LLC: see Copyright.txt // (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose. // We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information. // Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// {ErrorOutputExpected}
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -61,143 +62,124 @@ public class LoggingLevelManipulation {
} }
} }
/* Output: /* Output:
-- printing levels -- net : null com.mindviewinc : null -- printing levels -- com : null com.mindviewinc : null
onjava : null com.mindviewinc.test : null onjava : null com.mindviewinc.test : null random : null
random : null -- printing levels -- com : SEVERE com.mindviewinc : null
-- printing levels -- net : SEVERE com.mindviewinc : null onjava : null com.mindviewinc.test : null random : null
onjava : null com.mindviewinc.test : null
random : null
net level: SEVERE net level: SEVERE
-- printing levels -- net : SEVERE com.mindviewinc : null -- printing levels -- com : SEVERE com.mindviewinc : null
onjava : FINEST com.mindviewinc.test : FINEST onjava : FINEST com.mindviewinc.test : FINEST random :
random : FINEST FINEST
individual loggers set to FINEST individual loggers set to FINEST
-- printing levels -- net : FINEST com.mindviewinc : null -- printing levels -- com : FINEST com.mindviewinc : null
onjava : FINEST com.mindviewinc.test : FINEST onjava : FINEST com.mindviewinc.test : FINEST random :
random : FINEST FINEST
net level: FINEST net level: FINEST
___[ Error Output ]___ ___[ Error Output ]___
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation Dec 15, 2015 9:58:43 PM LoggingLevelManipulation
printLogMessages printLogMessages
SEVERE: net Severe SEVERE: com Severe
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation Dec 15, 2015 9:58:43 PM LoggingLevelManipulation
printLogMessages
INFO: com.mindviewinc Info
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation
printLogMessages
WARNING: com.mindviewinc Warning
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation
printLogMessages printLogMessages
SEVERE: com.mindviewinc Severe SEVERE: com.mindviewinc Severe
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation Dec 15, 2015 9:58:43 PM LoggingLevelManipulation
printLogMessages printLogMessages
INFO: onjava Info INFO: onjava Info
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation Dec 15, 2015 9:58:43 PM LoggingLevelManipulation
printLogMessages printLogMessages
WARNING: onjava Warning WARNING: onjava Warning
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation Dec 15, 2015 9:58:43 PM LoggingLevelManipulation
printLogMessages printLogMessages
SEVERE: onjava Severe SEVERE: onjava Severe
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation Dec 15, 2015 9:58:43 PM LoggingLevelManipulation
printLogMessages
INFO: com.mindviewinc.test Info
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation
printLogMessages
WARNING: com.mindviewinc.test Warning
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation
printLogMessages printLogMessages
SEVERE: com.mindviewinc.test Severe SEVERE: com.mindviewinc.test Severe
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation Dec 15, 2015 9:58:43 PM LoggingLevelManipulation
printLogMessages printLogMessages
INFO: random Info INFO: random Info
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation Dec 15, 2015 9:58:43 PM LoggingLevelManipulation
printLogMessages printLogMessages
WARNING: random Warning WARNING: random Warning
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation Dec 15, 2015 9:58:43 PM LoggingLevelManipulation
printLogMessages printLogMessages
SEVERE: random Severe SEVERE: random Severe
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation Dec 15, 2015 9:58:43 PM LoggingLevelManipulation
printLogMessages printLogMessages
SEVERE: net Severe SEVERE: com Severe
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation Dec 15, 2015 9:58:43 PM LoggingLevelManipulation
printLogMessages
INFO: com.mindviewinc Info
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation
printLogMessages
WARNING: com.mindviewinc Warning
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation
printLogMessages printLogMessages
SEVERE: com.mindviewinc Severe SEVERE: com.mindviewinc Severe
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation Dec 15, 2015 9:58:43 PM LoggingLevelManipulation
printLogMessages printLogMessages
INFO: onjava Info INFO: onjava Info
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation Dec 15, 2015 9:58:43 PM LoggingLevelManipulation
printLogMessages printLogMessages
WARNING: onjava Warning WARNING: onjava Warning
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation Dec 15, 2015 9:58:43 PM LoggingLevelManipulation
printLogMessages printLogMessages
SEVERE: onjava Severe SEVERE: onjava Severe
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation Dec 15, 2015 9:58:43 PM LoggingLevelManipulation
printLogMessages printLogMessages
INFO: com.mindviewinc.test Info INFO: com.mindviewinc.test Info
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation Dec 15, 2015 9:58:43 PM LoggingLevelManipulation
printLogMessages printLogMessages
WARNING: com.mindviewinc.test Warning WARNING: com.mindviewinc.test Warning
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation Dec 15, 2015 9:58:43 PM LoggingLevelManipulation
printLogMessages printLogMessages
SEVERE: com.mindviewinc.test Severe SEVERE: com.mindviewinc.test Severe
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation Dec 15, 2015 9:58:43 PM LoggingLevelManipulation
printLogMessages printLogMessages
INFO: random Info INFO: random Info
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation Dec 15, 2015 9:58:43 PM LoggingLevelManipulation
printLogMessages printLogMessages
WARNING: random Warning WARNING: random Warning
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation Dec 15, 2015 9:58:43 PM LoggingLevelManipulation
printLogMessages printLogMessages
SEVERE: random Severe SEVERE: random Severe
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation Dec 15, 2015 9:58:43 PM LoggingLevelManipulation
printLogMessages printLogMessages
INFO: net Info INFO: com Info
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation Dec 15, 2015 9:58:43 PM LoggingLevelManipulation
printLogMessages printLogMessages
WARNING: net Warning WARNING: com Warning
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation Dec 15, 2015 9:58:43 PM LoggingLevelManipulation
printLogMessages printLogMessages
SEVERE: net Severe SEVERE: com Severe
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation Dec 15, 2015 9:58:43 PM LoggingLevelManipulation
printLogMessages printLogMessages
INFO: com.mindviewinc Info INFO: com.mindviewinc Info
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation Dec 15, 2015 9:58:43 PM LoggingLevelManipulation
printLogMessages printLogMessages
WARNING: com.mindviewinc Warning WARNING: com.mindviewinc Warning
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation Dec 15, 2015 9:58:43 PM LoggingLevelManipulation
printLogMessages printLogMessages
SEVERE: com.mindviewinc Severe SEVERE: com.mindviewinc Severe
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation Dec 15, 2015 9:58:43 PM LoggingLevelManipulation
printLogMessages printLogMessages
INFO: onjava Info INFO: onjava Info
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation Dec 15, 2015 9:58:43 PM LoggingLevelManipulation
printLogMessages printLogMessages
WARNING: onjava Warning WARNING: onjava Warning
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation Dec 15, 2015 9:58:43 PM LoggingLevelManipulation
printLogMessages printLogMessages
SEVERE: onjava Severe SEVERE: onjava Severe
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation Dec 15, 2015 9:58:43 PM LoggingLevelManipulation
printLogMessages printLogMessages
INFO: com.mindviewinc.test Info INFO: com.mindviewinc.test Info
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation Dec 15, 2015 9:58:43 PM LoggingLevelManipulation
printLogMessages printLogMessages
WARNING: com.mindviewinc.test Warning WARNING: com.mindviewinc.test Warning
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation Dec 15, 2015 9:58:43 PM LoggingLevelManipulation
printLogMessages printLogMessages
SEVERE: com.mindviewinc.test Severe SEVERE: com.mindviewinc.test Severe
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation Dec 15, 2015 9:58:43 PM LoggingLevelManipulation
printLogMessages printLogMessages
INFO: random Info INFO: random Info
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation Dec 15, 2015 9:58:43 PM LoggingLevelManipulation
printLogMessages printLogMessages
WARNING: random Warning WARNING: random Warning
Jun 15, 2015 3:47:52 PM LoggingLevelManipulation Dec 15, 2015 9:58:43 PM LoggingLevelManipulation
printLogMessages printLogMessages
SEVERE: random Severe SEVERE: random Severe
___[ Error Output is Expected ]___
*/ */

View File

@ -2,6 +2,7 @@
// (c)2016 MindView LLC: see Copyright.txt // (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose. // We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information. // Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// {ErrorOutputExpected}
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -39,20 +40,23 @@ com level: SEVERE
individual loggers set to FINEST individual loggers set to FINEST
com level: SEVERE com level: SEVERE
___[ Error Output ]___ ___[ Error Output ]___
Jun 15, 2015 3:47:52 PM LoggingLevels logMessages Dec 15, 2015 9:58:43 PM LoggingLevels logMessages
SEVERE: test : severe
Jun 15, 2015 3:47:52 PM LoggingLevels logMessages
INFO: random : info
Jun 15, 2015 3:47:52 PM LoggingLevels logMessages
INFO: util : info INFO: util : info
Jun 15, 2015 3:47:52 PM LoggingLevels logMessages Dec 15, 2015 9:58:43 PM LoggingLevels logMessages
SEVERE: test : severe SEVERE: test : severe
Jun 15, 2015 3:47:52 PM LoggingLevels logMessages Dec 15, 2015 9:58:43 PM LoggingLevels logMessages
INFO: random : info INFO: random : info
Jun 15, 2015 3:47:52 PM LoggingLevels logMessages Dec 15, 2015 9:58:43 PM LoggingLevels logMessages
INFO: util : info INFO: util : info
Jun 15, 2015 3:47:52 PM LoggingLevels logMessages Dec 15, 2015 9:58:43 PM LoggingLevels logMessages
SEVERE: test : severe SEVERE: test : severe
Jun 15, 2015 3:47:52 PM LoggingLevels logMessages Dec 15, 2015 9:58:43 PM LoggingLevels logMessages
INFO: random : info INFO: random : info
Dec 15, 2015 9:58:43 PM LoggingLevels logMessages
INFO: util : info
Dec 15, 2015 9:58:43 PM LoggingLevels logMessages
SEVERE: test : severe
Dec 15, 2015 9:58:43 PM LoggingLevels logMessages
INFO: random : info
___[ Error Output is Expected ]___
*/ */

View File

@ -2,6 +2,7 @@
// (c)2016 MindView LLC: see Copyright.txt // (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose. // We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information. // Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// {ErrorOutputExpected}
import java.util.logging.*; import java.util.logging.*;
public class MultipleHandlers { public class MultipleHandlers {
@ -19,8 +20,9 @@ public class MultipleHandlers {
} }
/* Output: /* Output:
___[ Error Output ]___ ___[ Error Output ]___
Jun 15, 2015 3:47:52 PM MultipleHandlers main Dec 15, 2015 9:58:43 PM MultipleHandlers main
WARNING: Output to multiple handlers WARNING: Output to multiple handlers
Jun 15, 2015 3:47:52 PM MultipleHandlers main Dec 15, 2015 9:58:43 PM MultipleHandlers main
WARNING: Output to multiple handlers WARNING: Output to multiple handlers
___[ Error Output is Expected ]___
*/ */

View File

@ -2,6 +2,7 @@
// (c)2016 MindView LLC: see Copyright.txt // (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose. // We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information. // Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// {ErrorOutputExpected}
import java.util.logging.*; import java.util.logging.*;
public class MultipleHandlers2 { public class MultipleHandlers2 {
@ -20,6 +21,7 @@ public class MultipleHandlers2 {
} }
/* Output: /* Output:
___[ Error Output ]___ ___[ Error Output ]___
Jun 15, 2015 3:47:52 PM MultipleHandlers2 main Dec 15, 2015 9:58:43 PM MultipleHandlers2 main
WARNING: Output to multiple handlers WARNING: Output to multiple handlers
___[ Error Output is Expected ]___
*/ */

View File

@ -2,6 +2,7 @@
// (c)2016 MindView LLC: see Copyright.txt // (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose. // We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information. // Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// {ErrorOutputExpected}
import java.util.logging.*; import java.util.logging.*;
public class SimpleFilter { public class SimpleFilter {
@ -33,12 +34,13 @@ public class SimpleFilter {
} }
/* Output: /* Output:
___[ Error Output ]___ ___[ Error Output ]___
Jun 15, 2015 3:47:52 PM SimpleFilter sendLogMessages Dec 15, 2015 9:58:44 PM SimpleFilter sendLogMessages
WARNING: A duck in the house! WARNING: A duck in the house!
Jun 15, 2015 3:47:52 PM SimpleFilter sendLogMessages Dec 15, 2015 9:58:44 PM SimpleFilter sendLogMessages
WARNING: A Wombat at large! WARNING: A Wombat at large!
Jun 15, 2015 3:47:52 PM SimpleFilter main Dec 15, 2015 9:58:44 PM SimpleFilter main
INFO: After setting filter.. INFO: After setting filter..
Jun 15, 2015 3:47:52 PM SimpleFilter sendLogMessages Dec 15, 2015 9:58:44 PM SimpleFilter sendLogMessages
WARNING: A duck in the house! WARNING: A duck in the house!
___[ Error Output is Expected ]___
*/ */

View File

@ -2,6 +2,7 @@
// (c)2016 MindView LLC: see Copyright.txt // (c)2016 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose. // We make no guarantees that this code is fit for any purpose.
// Visit http://mindviewinc.com/Books/OnJava/ for more book information. // Visit http://mindviewinc.com/Books/OnJava/ for more book information.
// {ErrorOutputExpected}
import java.util.logging.*; import java.util.logging.*;
public class SimpleFormatterExample { public class SimpleFormatterExample {
@ -34,4 +35,5 @@ INFO : SimpleFormatterExample -:- logMessages -:- Line
One One
INFO : SimpleFormatterExample -:- logMessages -:- Line INFO : SimpleFormatterExample -:- logMessages -:- Line
Two Two
___[ Error Output is Expected ]___
*/ */

View File

@ -183,35 +183,61 @@ class Duet:
""" """
def __init__(self, out_filename): def __init__(self, out_filename):
if not out_filename.suffix == ".out" or out_filename.suffix == ".err":
print("Error: argument to Duet() must end with '.out' or '.err'") if not (out_filename.suffix == ".out" or
out_filename.suffix == ".err" or
out_filename.suffix == ".new"):
print("Error: argument to Duet() must end with '.out' or '.err' or '.new'")
print("Argument was {}".format(out_filename)) print("Argument was {}".format(out_filename))
sys.exit() sys.exit()
self.java_file = None # Full contents of Java code file self.java_file = None # Full contents of Java code file
self.java_slugline = None # First (marker) line of Java code file self.java_slugline = None # First (marker) line of Java code file
self.out_path = out_filename.with_suffix(".out") self.out_path = out_filename.with_suffix(".out")
self.out = None self.out = None
self.generated = ""
if self.out_path.exists(): if self.out_path.exists():
self.out = self.out_path.read_text() self.out = self.out_path.read_text().strip()
trace("{} file exists".format(self.out_path)) trace("{} file exists".format(self.out_path))
self.generated = self.fill_to_width(self.out)
self.error = False
self.err_path = out_filename.with_suffix(".err") self.err_path = out_filename.with_suffix(".err")
self.errors = None
if self.err_path.exists(): if self.err_path.exists():
self.errors = self.err_path.read_text() self.error = True
print("{} file exists".format(self.err_path)) self.generated += "\n___[ Error Output ]___\n"
self.generated += self.fill_to_width(self.err_path.read_text())
trace("{} file exists".format(self.err_path))
self.new = None
self.new_path = out_filename.with_suffix(".new")
if self.new_path.exists():
self.new = self.new_path.read_text().strip()
print("{} file exists".format(self.new_path))
self.java_path = self.calculate_java_path() self.java_path = self.calculate_java_path()
# This also fills self.java_file and self.java_slugline:
self.embedded = self.embedded_output() self.embedded = self.embedded_output()
self.ignore = False self.ignore = False
if "{IgnoreOutput}" in self.java_file: if "{IgnoreOutput}" in self.java_file:
self.ignore = True self.ignore = True
trace("Ignoring .out for {}".format(self.java_path)) trace("Ignoring .out for {}".format(self.java_path))
return return
self.generated = self.out_path.read_text().strip()
self.generated = self.fill_to_width(self.generated) if "{ThrowsException}" in self.java_file:
self.generated = self.generated.strip() + "\n___[ Exception is Expected ]___"
trace("Exception expected for {}".format(self.java_path))
if "{ErrorOutputExpected}" in self.java_file:
self.generated = self.generated.strip() + "\n___[ Error Output is Expected ]___"
trace("OK: 'Error Output' expected for {}".format(self.java_path))
self.embedded_adjusted = self.adjust(self.embedded) self.embedded_adjusted = self.adjust(self.embedded)
self.generated_un_adjusted = self.generated
self.generated_adjusted = None
if self.generated:
self.generated_adjusted = self.adjust(self.generated) self.generated_adjusted = self.adjust(self.generated)
def calculate_java_path(self): def calculate_java_path(self):

View File

@ -11,11 +11,25 @@ from output_duet import Duet, Valid
import os import os
import collections import collections
import pprint import pprint
import itertools
def trace(*str): pass def trace(*str): pass
# trace = print # trace = print
def clean():
for p in (Path(f) for f in [
"update_output.bat",
"edit_errors.bat",
"strategies.txt",
"validate_successes.txt",
"validate_failures.txt",
]):
if p.exists():
p.unlink()
if __name__ == '__main__': if __name__ == '__main__':
clean()
jfiles = sorted([java.name for java in Path(".").glob("**/*.java")]) jfiles = sorted([java.name for java in Path(".").glob("**/*.java")])
duplicates = sorted([x for x, y in collections.Counter(jfiles).items() if y > 1]) duplicates = sorted([x for x, y in collections.Counter(jfiles).items() if y > 1])
if duplicates: if duplicates:
@ -23,8 +37,10 @@ if __name__ == '__main__':
pprint.pprint(duplicates) pprint.pprint(duplicates)
count = 0 count = 0
for output in Path(".").glob("**/*.out"): for output in itertools.chain(Path(".").glob("**/*.out"), Path(".").glob("**/*.err")):
duet = Duet(output) duet = Duet(output)
# if duet.error:
# os.system("subl {}".format(duet.java_path))
trace("duet.ignore:", duet.ignore, duet.java_path ) trace("duet.ignore:", duet.ignore, duet.java_path )
if duet.ignore: if duet.ignore:
continue continue
@ -35,10 +51,24 @@ if __name__ == '__main__':
with Path("strategies.txt").open('a') as st: with Path("strategies.txt").open('a') as st:
print(' "' + duet.java_path.name + '" : IgnoreSortedLines(),', file = st) print(' "' + duet.java_path.name + '" : IgnoreSortedLines(),', file = st)
with Path("update_output.bat").open('a') as uo: with Path("update_output.bat").open('a') as uo:
print('call u ' + str(duet.out_path), file = uo) print('call no ' + str(duet.out_path.with_suffix(".new")), file = uo)
with Path("edit_errors.bat").open('a') as eo:
print('subl ' + str(duet.java_path), file = eo)
if duet.error:
duet.out_path.with_suffix(".new").write_text(duet.generated_un_adjusted)
os.system('subl ' + str(duet.out_path.with_suffix(".new")))
else:
with Path("validate_successes.txt").open('a') as vs:
print("{:<20}".format(v) + "{}".format(duet.java_path), file = vs)
count += 1 count += 1
print("\n" + " Verified files = {} ".format(count).center(60, "*")) print("\n" + " Verified files = {} ".format(count).center(60, "*"))
if Path("validate_failures.txt").exists(): if Path("validate_failures.txt").exists():
os.system("subl update_output.bat strategies.txt validate_failures.txt") os.system("subl "
"update_output.bat "
"edit_errors.bat "
"strategies.txt "
"validate_successes.txt "
"validate_failures.txt")
else: else:
print("\n" + " No Output Errors ".center(60, "=")) print("\n" + " No Output Errors ".center(60, "="))