Source Code Cross Referenced for GenericIllegalRegexpCheckTest.java in  » Code-Analyzer » checkstyle » com » puppycrawl » tools » checkstyle » checks » 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 » checkstyle » com.puppycrawl.tools.checkstyle.checks 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.puppycrawl.tools.checkstyle.checks;
002:
003:        import com.puppycrawl.tools.checkstyle.BaseCheckTestCase;
004:        import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
005:
006:        public class GenericIllegalRegexpCheckTest extends BaseCheckTestCase {
007:            private DefaultConfiguration mCheckConfig;
008:
009:            public void setUp() {
010:                mCheckConfig = createCheckConfig(GenericIllegalRegexpCheck.class);
011:            }
012:
013:            public void testIt() throws Exception {
014:                final String illegal = "System\\.(out)|(err)\\.print(ln)?\\(";
015:                mCheckConfig.addAttribute("format", illegal);
016:                final String[] expected = { "69: Line matches the illegal pattern '"
017:                        + illegal + "'." };
018:                verify(mCheckConfig, getPath("InputSemantic.java"), expected);
019:            }
020:
021:            public void testMessageProperty() throws Exception {
022:                final String illegal = "System\\.(out)|(err)\\.print(ln)?\\(";
023:                final String message = "Bad line :(";
024:                mCheckConfig.addAttribute("format", illegal);
025:                mCheckConfig.addAttribute("message", message);
026:                final String[] expected = { "69: " + message, };
027:                verify(mCheckConfig, getPath("InputSemantic.java"), expected);
028:            }
029:
030:            public void testIgnoreCaseTrue() throws Exception {
031:                final String illegal = "SYSTEM\\.(OUT)|(ERR)\\.PRINT(LN)?\\(";
032:                mCheckConfig.addAttribute("format", illegal);
033:                mCheckConfig.addAttribute("ignoreCase", "true");
034:                final String[] expected = { "69: Line matches the illegal pattern '"
035:                        + illegal + "'." };
036:                verify(mCheckConfig, getPath("InputSemantic.java"), expected);
037:            }
038:
039:            public void testIgnoreCaseFalse() throws Exception {
040:                final String illegal = "SYSTEM\\.(OUT)|(ERR)\\.PRINT(LN)?\\(";
041:                mCheckConfig.addAttribute("format", illegal);
042:                mCheckConfig.addAttribute("ignoreCase", "false");
043:                final String[] expected = {};
044:                verify(mCheckConfig, getPath("InputSemantic.java"), expected);
045:            }
046:
047:            public void testIgnoreCommentsCppStyle() throws Exception {
048:                // See if the comment is removed properly
049:                final String illegal = "don't use trailing comments";
050:                mCheckConfig.addAttribute("format", illegal);
051:                mCheckConfig.addAttribute("ignoreComments", "true");
052:                final String[] expected = {};
053:                verify(mCheckConfig, getPath("InputTrailingComment.java"),
054:                        expected);
055:            }
056:
057:            public void testIgnoreCommentsFalseCppStyle() throws Exception {
058:                // See if the comment is removed properly
059:                final String illegal = "don't use trailing comments";
060:                mCheckConfig.addAttribute("format", illegal);
061:                mCheckConfig.addAttribute("ignoreComments", "false");
062:                final String[] expected = { "2: Line matches the illegal pattern '"
063:                        + illegal + "'." };
064:                verify(mCheckConfig, getPath("InputTrailingComment.java"),
065:                        expected);
066:            }
067:
068:            public void testIgnoreCommentsCStyle() throws Exception {
069:                // See if the comment is removed properly
070:                final String illegal = "c-style 1";
071:                mCheckConfig.addAttribute("format", illegal);
072:                mCheckConfig.addAttribute("ignoreComments", "true");
073:                final String[] expected = {};
074:                verify(mCheckConfig, getPath("InputTrailingComment.java"),
075:                        expected);
076:            }
077:
078:            public void testIgnoreCommentsFalseCStyle() throws Exception {
079:                final String illegal = "c-style 1";
080:                mCheckConfig.addAttribute("format", illegal);
081:                mCheckConfig.addAttribute("ignoreComments", "false");
082:                final String[] expected = { "17: Line matches the illegal pattern '"
083:                        + illegal + "'." };
084:                verify(mCheckConfig, getPath("InputTrailingComment.java"),
085:                        expected);
086:            }
087:
088:            public void testIgnoreCommentsMultipleCStyle() throws Exception {
089:                // See if a second comment on the same line is removed properly
090:                final String illegal = "c-style 2";
091:                mCheckConfig.addAttribute("format", illegal);
092:                mCheckConfig.addAttribute("ignoreComments", "true");
093:                final String[] expected = {};
094:                verify(mCheckConfig, getPath("InputTrailingComment.java"),
095:                        expected);
096:            }
097:
098:            public void testIgnoreCommentsMultiLine() throws Exception {
099:                final String illegal = "Let's check multi-line comments";
100:                mCheckConfig.addAttribute("format", illegal);
101:                mCheckConfig.addAttribute("ignoreComments", "true");
102:                final String[] expected = {};
103:                verify(mCheckConfig, getPath("InputTrailingComment.java"),
104:                        expected);
105:            }
106:
107:            public void testIgnoreCommentsInlineStart() throws Exception {
108:                final String illegal = "long ms /";
109:                mCheckConfig.addAttribute("format", illegal);
110:                mCheckConfig.addAttribute("ignoreComments", "true");
111:                final String[] expected = {};
112:                verify(mCheckConfig, getPath("InputTrailingComment.java"),
113:                        expected);
114:            }
115:
116:            public void testIgnoreCommentsInlineEnd() throws Exception {
117:                final String illegal = "int z";
118:                mCheckConfig.addAttribute("format", illegal);
119:                mCheckConfig.addAttribute("ignoreComments", "true");
120:                final String[] expected = { "20: Line matches the illegal pattern '"
121:                        + illegal + "'." };
122:                verify(mCheckConfig, getPath("InputTrailingComment.java"),
123:                        expected);
124:            }
125:
126:            public void testIgnoreCommentsInlineMiddle() throws Exception {
127:                final String illegal = "int y";
128:                mCheckConfig.addAttribute("format", illegal);
129:                mCheckConfig.addAttribute("ignoreComments", "true");
130:                final String[] expected = { "21: Line matches the illegal pattern '"
131:                        + illegal + "'." };
132:                verify(mCheckConfig, getPath("InputTrailingComment.java"),
133:                        expected);
134:            }
135:
136:            public void testIgnoreCommentsNoSpaces() throws Exception {
137:                // make sure the comment is not turned into spaces
138:                final String illegal = "long ms  ";
139:                mCheckConfig.addAttribute("format", illegal);
140:                mCheckConfig.addAttribute("ignoreComments", "true");
141:                final String[] expected = {};
142:                verify(mCheckConfig, getPath("InputTrailingComment.java"),
143:                        expected);
144:            }
145:
146:            public void test1371588() throws Exception {
147:                // StackOverflowError with trailing space and ignoreComments
148:                final String illegal = "\\s+$";
149:                mCheckConfig.addAttribute("format", illegal);
150:                mCheckConfig.addAttribute("ignoreComments", "true");
151:                final String[] expected = {};
152:                verify(mCheckConfig, getPath("InputTrailingComment.java"),
153:                        expected);
154:            }
155:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.