Got the unit tests to pass again. They highlighted a bug in the recent

changes, and once again prove they are worth the effort. ;-)
This commit is contained in:
Oliver Burn 2002-09-19 09:07:57 +00:00
parent 1b7d45aed3
commit 03f8352479
4 changed files with 47 additions and 9 deletions

View File

@ -224,21 +224,25 @@ public class Checker
}
catch (FileNotFoundException fnfe) {
errors = new LocalizedMessage[] {
new LocalizedMessage(0, "general.fileNotFound", null, null)};
new LocalizedMessage(0, Defn.CHECKSTYLE_BUNDLE,
"general.fileNotFound", null)};
}
catch (IOException ioe) {
errors = new LocalizedMessage[] {
new LocalizedMessage(0, "general.exception", null,
new LocalizedMessage(0, Defn.CHECKSTYLE_BUNDLE,
"general.exception",
new String[] {ioe.getMessage()})};
}
catch (RecognitionException re) {
errors = new LocalizedMessage[] {
new LocalizedMessage(0, "general.exception", null,
new LocalizedMessage(0, Defn.CHECKSTYLE_BUNDLE,
"general.exception",
new String[] {re.getMessage()})};
}
catch (TokenStreamException te) {
errors = new LocalizedMessage[] {
new LocalizedMessage(0, "general.exception", null,
new LocalizedMessage(0, Defn.CHECKSTYLE_BUNDLE,
"general.exception",
new String[] {te.getMessage()})};
}
@ -276,7 +280,8 @@ public class Checker
fireFileStarted(docFile);
if (!packageDoc.exists()) {
final LocalizedMessage error =
new LocalizedMessage(0, "javadoc.packageHtml", null, null);
new LocalizedMessage(0, Defn.CHECKSTYLE_BUNDLE,
"javadoc.packageHtml", null);
fireErrors(docFile, new LocalizedMessage[]{error});
packageHtmlErrors++;
}

View File

@ -25,6 +25,10 @@ package com.puppycrawl.tools.checkstyle;
**/
public interface Defn
{
// TODO: Change to a class - follow the advice of Bloch.
/** name of resource bundle for Checkstyle */
String CHECKSTYLE_BUNDLE = "com.puppycrawl.tools.checkstyle.messages";
/** property name for the to-do pattern **/
String TODO_PATTERN_PROP = "checkstyle.pattern.todo";
/** property name for the parameter pattern **/

View File

@ -9,7 +9,6 @@ import com.puppycrawl.tools.checkstyle.api.LocalizedMessage;
public class LocalizedMessageTest
extends TestCase
{
private final String BUNDLE = "com.puppycrawl.tools.checkstyle.messages";
public LocalizedMessageTest(String name)
{
super(name);
@ -23,15 +22,18 @@ public class LocalizedMessageTest
public void testMisc()
{
LocalizedMessage lm =
new LocalizedMessage(0, BUNDLE, "DefaultLogger.auditFinished", null);
new LocalizedMessage(0, Defn.CHECKSTYLE_BUNDLE,
"DefaultLogger.auditFinished", null);
assertNotNull(lm);
assertEquals("Audit done.", lm.getMessage());
lm = new LocalizedMessage(0, BUNDLE, "DefaultLogger.addException",
lm = new LocalizedMessage(0, Defn.CHECKSTYLE_BUNDLE,
"DefaultLogger.addException",
new String[]{"Claira"});
assertNotNull(lm);
assertEquals("Error auditing Claira", lm.getMessage());
lm = new LocalizedMessage(0, BUNDLE, "ws.notFollowed", new String[] {"{"});
lm = new LocalizedMessage(0, Defn.CHECKSTYLE_BUNDLE,
"ws.notFollowed", new String[] {"{"});
assertNotNull(lm);
assertEquals("'{' is not followed by whitespace.", lm.getMessage());
}

View File

@ -0,0 +1,27 @@
/*
* Created by IntelliJ IDEA.
* User: oliver.burn
* Date: 19/09/2002
* Time: 18:35:19
* To change template for new class use
* Code Style | Class Templates options (Tools | IDE Options).
*/
package com.puppycrawl.tools.checkstyle;
import junit.framework.TestCase;
import com.puppycrawl.tools.checkstyle.api.LocalizedMessages;
public class TreeWalkerTest
extends TestCase
{
public TreeWalkerTest(String s)
{
super(s);
}
public void testCreate()
{
new TreeWalker(new LocalizedMessages(8));
assertTrue(true);
}
}