Source Code Cross Referenced for RuleViolationTest.java in  » Code-Analyzer » pmd-4.2rc1 » test » net » sourceforge » pmd » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Code Analyzer » pmd 4.2rc1 » test.net.sourceforge.pmd 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * <copyright>
003:         *  Copyright 1997-2002 InfoEther, LLC
004:         *  under sponsorship of the Defense Advanced Research Projects Agency
005:         (DARPA).
006:         *
007:         *  This program is free software; you can redistribute it and/or modify
008:         *  it under the terms of the Cougaar Open Source License as published
009:         by
010:         *  DARPA on the Cougaar Open Source Website (www.cougaar.org).
011:         *
012:         *  THE COUGAAR SOFTWARE AND ANY DERIVATIVE SUPPLIED BY LICENSOR IS
013:         *  PROVIDED 'AS IS' WITHOUT WARRANTIES OF ANY KIND, WHETHER EXPRESS OR
014:         *  IMPLIED, INCLUDING (BUT NOT LIMITED TO) ALL IMPLIED WARRANTIES OF
015:         *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, AND WITHOUT
016:         *  ANY WARRANTIES AS TO NON-INFRINGEMENT.  IN NO EVENT SHALL COPYRIGHT
017:         *  HOLDER BE LIABLE FOR ANY DIRECT, SPECIAL, INDIRECT OR CONSEQUENTIAL
018:         *  DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE OF DATA OR PROFITS,
019:         *  TORTIOUS CONDUCT, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
020:         *  PERFORMANCE OF THE COUGAAR SOFTWARE.
021:         * </copyright>
022:         */package test.net.sourceforge.pmd;
023:
024:        import static org.junit.Assert.assertEquals;
025:        import static org.junit.Assert.assertTrue;
026:        import junit.framework.JUnit4TestAdapter;
027:        import net.sourceforge.pmd.MockRule;
028:        import net.sourceforge.pmd.Rule;
029:        import net.sourceforge.pmd.RuleContext;
030:        import net.sourceforge.pmd.RuleViolation;
031:        import net.sourceforge.pmd.ast.SimpleJavaNode;
032:        import net.sourceforge.pmd.ast.SimpleNode;
033:
034:        import org.junit.Ignore;
035:        import org.junit.Test;
036:
037:        public class RuleViolationTest {
038:
039:            @Ignore
040:            @Test
041:            public void testConstructor1() {
042:                Rule rule = new MockRule("name", "desc", "msg", "rulesetname");
043:                RuleContext ctx = new RuleContext();
044:                ctx.setSourceCodeFilename("filename");
045:                SimpleNode s = new SimpleJavaNode(1);
046:                s.testingOnly__setBeginLine(2);
047:                RuleViolation r = new RuleViolation(rule, ctx, s);
048:                assertEquals("object mismatch", rule, r.getRule());
049:                assertEquals("line number is wrong", 2, r.getBeginLine());
050:                assertEquals("filename is wrong", "filename", r.getFilename());
051:            }
052:
053:            @Ignore
054:            @Test
055:            public void testConstructor2() {
056:                Rule rule = new MockRule("name", "desc", "msg", "rulesetname");
057:                RuleContext ctx = new RuleContext();
058:                ctx.setSourceCodeFilename("filename");
059:                SimpleNode s = new SimpleJavaNode(1);
060:                s.testingOnly__setBeginLine(2);
061:                RuleViolation r = new RuleViolation(rule, ctx, s, "description");
062:                assertEquals("object mismatch", rule, r.getRule());
063:                assertEquals("line number is wrong", 2, r.getBeginLine());
064:                assertEquals("filename is wrong", "filename", r.getFilename());
065:                assertEquals("description is wrong", "description", r
066:                        .getDescription());
067:            }
068:
069:            @Ignore
070:            @Test
071:            public void testComparatorWithDifferentFilenames() {
072:                Rule rule = new MockRule("name", "desc", "msg", "rulesetname");
073:                RuleViolation.RuleViolationComparator comp = new RuleViolation.RuleViolationComparator();
074:                RuleContext ctx = new RuleContext();
075:                ctx.setSourceCodeFilename("filename1");
076:                SimpleNode s = new SimpleJavaNode(1);
077:                s.testingOnly__setBeginLine(10);
078:                RuleViolation r1 = new RuleViolation(rule, ctx, s,
079:                        "description");
080:                ctx.setSourceCodeFilename("filename2");
081:                SimpleNode s1 = new SimpleJavaNode(1);
082:                s1.testingOnly__setBeginLine(10);
083:                RuleViolation r2 = new RuleViolation(rule, ctx, s1,
084:                        "description");
085:                assertEquals(-1, comp.compare(r1, r2));
086:                assertEquals(1, comp.compare(r2, r1));
087:            }
088:
089:            @Ignore
090:            @Test
091:            public void testComparatorWithSameFileDifferentLines() {
092:                Rule rule = new MockRule("name", "desc", "msg", "rulesetname");
093:                RuleViolation.RuleViolationComparator comp = new RuleViolation.RuleViolationComparator();
094:                RuleContext ctx = new RuleContext();
095:                ctx.setSourceCodeFilename("filename");
096:                SimpleNode s = new SimpleJavaNode(1);
097:                s.testingOnly__setBeginLine(10);
098:                SimpleNode s1 = new SimpleJavaNode(1);
099:                s1.testingOnly__setBeginLine(20);
100:                RuleViolation r1 = new RuleViolation(rule, ctx, s,
101:                        "description");
102:                RuleViolation r2 = new RuleViolation(rule, ctx, s1,
103:                        "description");
104:                assertTrue(comp.compare(r1, r2) < 0);
105:                assertTrue(comp.compare(r2, r1) > 0);
106:            }
107:
108:            @Ignore
109:            @Test
110:            public void testComparatorWithSameFileSameLines() {
111:                Rule rule = new MockRule("name", "desc", "msg", "rulesetname");
112:                RuleViolation.RuleViolationComparator comp = new RuleViolation.RuleViolationComparator();
113:                RuleContext ctx = new RuleContext();
114:                ctx.setSourceCodeFilename("filename");
115:                SimpleNode s = new SimpleJavaNode(1);
116:                s.testingOnly__setBeginLine(10);
117:                SimpleNode s1 = new SimpleJavaNode(1);
118:                s1.testingOnly__setBeginLine(10);
119:                RuleViolation r1 = new RuleViolation(rule, ctx, s,
120:                        "description");
121:                RuleViolation r2 = new RuleViolation(rule, ctx, s1,
122:                        "description");
123:                assertEquals(1, comp.compare(r1, r2));
124:                assertEquals(1, comp.compare(r2, r1));
125:            }
126:
127:            public static junit.framework.Test suite() {
128:                return new JUnit4TestAdapter(RuleViolationTest.class);
129:            }
130:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.