Source Code Cross Referenced for SuppressWarningsTest.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:        package test.net.sourceforge.pmd;
002:
003:        import static org.junit.Assert.assertEquals;
004:        import net.sourceforge.pmd.AbstractRule;
005:        import net.sourceforge.pmd.PMD;
006:        import net.sourceforge.pmd.Report;
007:        import net.sourceforge.pmd.SourceType;
008:        import net.sourceforge.pmd.ast.ASTClassOrInterfaceDeclaration;
009:        import net.sourceforge.pmd.ast.ASTVariableDeclaratorId;
010:
011:        import org.junit.Test;
012:
013:        import test.net.sourceforge.pmd.testframework.RuleTst;
014:        import junit.framework.JUnit4TestAdapter;
015:
016:        public class SuppressWarningsTest extends RuleTst {
017:
018:            private static class FooRule extends AbstractRule {
019:                public Object visit(ASTClassOrInterfaceDeclaration c, Object ctx) {
020:                    if (c.getImage().equalsIgnoreCase("Foo"))
021:                        addViolation(ctx, c);
022:                    return super .visit(c, ctx);
023:                }
024:
025:                public Object visit(ASTVariableDeclaratorId c, Object ctx) {
026:                    if (c.getImage().equalsIgnoreCase("Foo"))
027:                        addViolation(ctx, c);
028:                    return super .visit(c, ctx);
029:                }
030:
031:                public String getName() {
032:                    return "NoFoo";
033:                }
034:            }
035:
036:            @Test
037:            public void testClassLevelSuppression() throws Throwable {
038:                Report rpt = new Report();
039:                runTestFromString(TEST1, new FooRule(), rpt, SourceType.JAVA_15);
040:                assertEquals(0, rpt.size());
041:                runTestFromString(TEST2, new FooRule(), rpt, SourceType.JAVA_15);
042:                assertEquals(0, rpt.size());
043:            }
044:
045:            @Test
046:            public void testInheritedSuppression() throws Throwable {
047:                Report rpt = new Report();
048:                runTestFromString(TEST3, new FooRule(), rpt, SourceType.JAVA_15);
049:                assertEquals(0, rpt.size());
050:            }
051:
052:            @Test
053:            public void testMethodLevelSuppression() throws Throwable {
054:                Report rpt = new Report();
055:                runTestFromString(TEST4, new FooRule(), rpt, SourceType.JAVA_15);
056:                assertEquals(1, rpt.size());
057:            }
058:
059:            @Test
060:            public void testConstructorLevelSuppression() throws Throwable {
061:                Report rpt = new Report();
062:                runTestFromString(TEST5, new FooRule(), rpt, SourceType.JAVA_15);
063:                assertEquals(0, rpt.size());
064:            }
065:
066:            @Test
067:            public void testFieldLevelSuppression() throws Throwable {
068:                Report rpt = new Report();
069:                runTestFromString(TEST6, new FooRule(), rpt, SourceType.JAVA_15);
070:                assertEquals(1, rpt.size());
071:            }
072:
073:            @Test
074:            public void testParameterLevelSuppression() throws Throwable {
075:                Report rpt = new Report();
076:                runTestFromString(TEST7, new FooRule(), rpt, SourceType.JAVA_15);
077:                assertEquals(1, rpt.size());
078:            }
079:
080:            @Test
081:            public void testLocalVariableLevelSuppression() throws Throwable {
082:                Report rpt = new Report();
083:                runTestFromString(TEST8, new FooRule(), rpt, SourceType.JAVA_15);
084:                assertEquals(1, rpt.size());
085:            }
086:
087:            @Test
088:            public void testSpecificSuppression() throws Throwable {
089:                Report rpt = new Report();
090:                runTestFromString(TEST9, new FooRule(), rpt, SourceType.JAVA_15);
091:                assertEquals(1, rpt.size());
092:            }
093:
094:            @Test
095:            public void testNoSuppressionBlank() throws Throwable {
096:                Report rpt = new Report();
097:                runTestFromString(TEST10, new FooRule(), rpt,
098:                        SourceType.JAVA_15);
099:                assertEquals(2, rpt.size());
100:            }
101:
102:            @Test
103:            public void testNoSuppressionSomethingElseS() throws Throwable {
104:                Report rpt = new Report();
105:                runTestFromString(TEST11, new FooRule(), rpt,
106:                        SourceType.JAVA_15);
107:                assertEquals(2, rpt.size());
108:            }
109:
110:            private static final String TEST1 = "@SuppressWarnings(\"PMD\")"
111:                    + PMD.EOL + "public class Foo {}";
112:
113:            private static final String TEST2 = "@SuppressWarnings(\"PMD\")"
114:                    + PMD.EOL + "public class Foo {" + PMD.EOL
115:                    + " void bar() {" + PMD.EOL + "  int foo;" + PMD.EOL + " }"
116:                    + PMD.EOL + "}";
117:
118:            private static final String TEST3 = "public class Baz {" + PMD.EOL
119:                    + " @SuppressWarnings(\"PMD\")" + PMD.EOL
120:                    + " public class Bar {" + PMD.EOL + "  void bar() {"
121:                    + PMD.EOL + "   int foo;" + PMD.EOL + "  }" + PMD.EOL
122:                    + " }" + PMD.EOL + "}";
123:
124:            private static final String TEST4 = "public class Foo {" + PMD.EOL
125:                    + " @SuppressWarnings(\"PMD\")" + PMD.EOL + " void bar() {"
126:                    + PMD.EOL + "  int foo;" + PMD.EOL + " }" + PMD.EOL + "}";
127:
128:            private static final String TEST5 = "public class Bar {" + PMD.EOL
129:                    + " @SuppressWarnings(\"PMD\")" + PMD.EOL
130:                    + " public Bar() {" + PMD.EOL + "  int foo;" + PMD.EOL
131:                    + " }" + PMD.EOL + "}";
132:
133:            private static final String TEST6 = "public class Bar {" + PMD.EOL
134:                    + " @SuppressWarnings(\"PMD\")" + PMD.EOL + " int foo;"
135:                    + PMD.EOL + " void bar() {" + PMD.EOL + "  int foo;"
136:                    + PMD.EOL + " }" + PMD.EOL + "}";
137:
138:            private static final String TEST7 = "public class Bar {" + PMD.EOL
139:                    + " int foo;" + PMD.EOL
140:                    + " void bar(@SuppressWarnings(\"PMD\") int foo) {}"
141:                    + PMD.EOL + "}";
142:
143:            private static final String TEST8 = "public class Bar {" + PMD.EOL
144:                    + " int foo;" + PMD.EOL + " void bar() {" + PMD.EOL
145:                    + "  @SuppressWarnings(\"PMD\") int foo;" + PMD.EOL + " }"
146:                    + PMD.EOL + "}";
147:
148:            private static final String TEST9 = "public class Bar {" + PMD.EOL
149:                    + " int foo;" + PMD.EOL + " void bar() {" + PMD.EOL
150:                    + "  @SuppressWarnings(\"PMD.NoFoo\") int foo;" + PMD.EOL
151:                    + " }" + PMD.EOL + "}";
152:
153:            private static final String TEST10 = "public class Bar {" + PMD.EOL
154:                    + " int foo;" + PMD.EOL + " void bar() {" + PMD.EOL
155:                    + "  @SuppressWarnings(\"\") int foo;" + PMD.EOL + " }"
156:                    + PMD.EOL + "}";
157:
158:            private static final String TEST11 = "public class Bar {" + PMD.EOL
159:                    + " int foo;" + PMD.EOL + " void bar() {" + PMD.EOL
160:                    + "  @SuppressWarnings(\"SomethingElse\") int foo;"
161:                    + PMD.EOL + " }" + PMD.EOL + "}";
162:
163:            public static junit.framework.Test suite() {
164:                return new JUnit4TestAdapter(SuppressWarningsTest.class);
165:            }
166:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.