|
 |
|
| |
Exercises
- Create a class containing a static clause that throws an exception
if assertions are not enabled. Demonstrate that this test works correctly.
- Modify the preceding exercise to use the approach in
LoaderAssertions.java to turn on assertions instead of throwing an
exception. Demonstrate that this works correctly.
- In LoggingLevels.java, comment out the code that sets the severity
level of the root logger handlers and verify that messages of level
CONFIG and below are not reported.
- Inherit from java.util.Logging.Level and define your own level with
a value less than FINEST. Modify LoggingLevels.java to use your new level
and show that messages at your level will not appear when the logging level is
FINEST.
- Associate a FileHandler with the root logger.
- Modify the FileHandler so that it formats output to a simple text
file.
- Modify MultipleHandlers.java so that it generates output in plain
text format instead of XML.
- Modify LoggingLevels.java to set different logging levels for the
handlers associated with the root logger.
- Write a simple program that sets the root logger logging level based on a
command-line argument.
- Write an example using Formatters and Handlers to output a log file as
HTML.
- Write an example using Handlers and Filters to log messages with any
severity level over INFO in one file and any severity level including and below
INFO in other file. The files should be written in simple text.
Modify log.prop to add an additional initialization class that
initializes a custom Formatter for the logger com.
Run JDB on SimpleDebugging.java, but do not give the command
catch Exception. Show that it still catches the exception.
- Add an uninitialized reference to SimpleDebugging.java (youll
have to do it in a way that the compiler doesnt catch the error!) and use
JDB to track down the problem.
- Perform the experiment described in the Coverage Testing
section.
- Create a doclet that displays identifiers that might not follow the Java
naming convention by checking how capital letters are used for those
identifiers.
|
|
|