01: /**
02: * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, version 2.1, dated February 1999.
03: *
04: * This program is free software; you can redistribute it and/or modify
05: * it under the terms of the latest version of the GNU Lesser General
06: * Public License as published by the Free Software Foundation;
07: *
08: * This program is distributed in the hope that it will be useful,
09: * but WITHOUT ANY WARRANTY; without even the implied warranty of
10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11: * GNU Lesser General Public License for more details.
12: *
13: * You should have received a copy of the GNU Lesser General Public License
14: * along with this program (LICENSE.txt); if not, write to the Free Software
15: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16: *
17: * Based on code generated by Agitar build: Agitator Version 1.0.2.000071 (Build date: Jan 12, 2007) [1.0.2.000071]
18: */package org.jamwiki.utils;
19:
20: import java.util.logging.LogRecord;
21: import java.util.logging.Level;
22: import java.util.PropertyResourceBundle;
23: import java.io.ByteArrayInputStream;
24: import junit.framework.TestCase;
25:
26: /**
27: *
28: */
29: public class WikiLogFormatterTest extends TestCase {
30:
31: /**
32: *
33: */
34: public void testConstructor() throws Throwable {
35: // FIXME - implement this
36: }
37:
38: /**
39: *
40: */
41: public void testFormat() throws Throwable {
42: String result = new WikiLogFormatter("").format(new LogRecord(
43: Level.ALL, "testWikiLogFormatterParam2"));
44: // FIXME
45: // assertEquals("result", " ALL: null - testWikiLogFormatterParam2\n", result);
46: }
47:
48: /**
49: *
50: */
51: public void testFormatThrowsIllegalArgumentException()
52: throws Throwable {
53: try {
54: new WikiLogFormatter("testWikiLogFormatterDatePattern")
55: .format(new LogRecord(Level.FINE,
56: "testWikiLogFormatterParam2"));
57: fail("Expected IllegalArgumentException to be thrown");
58: } catch (IllegalArgumentException ex) {
59: assertEquals("ex.getMessage()",
60: "Illegal pattern character 't'", ex.getMessage());
61: }
62: }
63:
64: /**
65: *
66: */
67: public void testFormatThrowsNullPointerException() throws Throwable {
68: try {
69: new WikiLogFormatter("").format(null);
70: fail("Expected NullPointerException to be thrown");
71: } catch (NullPointerException ex) {
72: assertNull("ex.getMessage()", ex.getMessage());
73: }
74: }
75:
76: /**
77: *
78: */
79: public void testFormatThrowsNullPointerException1()
80: throws Throwable {
81: byte[] bytes = new byte[2];
82: LogRecord record = new LogRecord(Level.OFF, null);
83: record.setResourceBundle(new PropertyResourceBundle(
84: new ByteArrayInputStream(bytes)));
85: try {
86: new WikiLogFormatter("").format(record);
87: fail("Expected NullPointerException to be thrown");
88: } catch (NullPointerException ex) {
89: assertNull("ex.getMessage()", ex.getMessage());
90: }
91: }
92: }
|