1 /***
2 * <copyright>
3 * Copyright 1997-2002 InfoEther, LLC
4 * under sponsorship of the Defense Advanced Research Projects Agency
5 (DARPA).
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the Cougaar Open Source License as published
9 by
10 * DARPA on the Cougaar Open Source Website (www.cougaar.org).
11 *
12 * THE COUGAAR SOFTWARE AND ANY DERIVATIVE SUPPLIED BY LICENSOR IS
13 * PROVIDED 'AS IS' WITHOUT WARRANTIES OF ANY KIND, WHETHER EXPRESS OR
14 * IMPLIED, INCLUDING (BUT NOT LIMITED TO) ALL IMPLIED WARRANTIES OF
15 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, AND WITHOUT
16 * ANY WARRANTIES AS TO NON-INFRINGEMENT. IN NO EVENT SHALL COPYRIGHT
17 * HOLDER BE LIABLE FOR ANY DIRECT, SPECIAL, INDIRECT OR CONSEQUENTIAL
18 * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE OF DATA OR PROFITS,
19 * TORTIOUS CONDUCT, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20 * PERFORMANCE OF THE COUGAAR SOFTWARE.
21 * </copyright>
22 */
23 package test.net.sourceforge.pmd;
24
25 import junit.framework.TestCase;
26 import net.sourceforge.pmd.AbstractRule;
27 import net.sourceforge.pmd.RuleContext;
28 import net.sourceforge.pmd.RuleViolation;
29
30 public class AbstractRuleTest extends TestCase {
31
32 private static class MyRule extends AbstractRule {
33 public String getMessage() {
34 return "myrule";
35 }
36 }
37
38 public AbstractRuleTest(String name) {
39 super(name);
40 }
41
42 public void testCreateRV() {
43 MyRule r = new MyRule();
44 RuleContext ctx = new RuleContext();
45 ctx.setSourceCodeFilename("filename");
46 RuleViolation rv = r.createRuleViolation(ctx, 5);
47 assertEquals("Line number mismatch!", 5, rv.getLine());
48 assertEquals("Filename mismatch!", "filename", rv.getFilename());
49 assertEquals("Rule object mismatch!", r, rv.getRule());
50 assertEquals("Rule description mismatch!", "myrule", rv.getDescription());
51 }
52
53 public void testCreateRV2() {
54 MyRule r = new MyRule();
55 RuleContext ctx = new RuleContext();
56 ctx.setSourceCodeFilename("filename");
57 RuleViolation rv = r.createRuleViolation(ctx, 5, "specificdescription");
58 assertEquals("Line number mismatch!", 5, rv.getLine());
59 assertEquals("Filename mismatch!", "filename", rv.getFilename());
60 assertEquals("Rule object mismatch!", r, rv.getRule());
61 assertEquals("Rule description mismatch!", "specificdescription", rv.getDescription());
62 }
63
64 }
This page was automatically generated by Maven