Source Code Cross Referenced for CommandLineOptionsTest.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.assertSame;
026:        import static org.junit.Assert.assertTrue;
027:        import net.sourceforge.pmd.CommandLineOptions;
028:        import net.sourceforge.pmd.renderers.CSVRenderer;
029:        import net.sourceforge.pmd.renderers.EmacsRenderer;
030:        import net.sourceforge.pmd.renderers.HTMLRenderer;
031:        import net.sourceforge.pmd.renderers.IDEAJRenderer;
032:        import net.sourceforge.pmd.renderers.TextRenderer;
033:        import net.sourceforge.pmd.renderers.VBHTMLRenderer;
034:        import net.sourceforge.pmd.renderers.XMLRenderer;
035:
036:        import org.junit.Test;
037:
038:        import java.io.InputStreamReader;
039:
040:        import junit.framework.JUnit4TestAdapter;
041:
042:        public class CommandLineOptionsTest {
043:
044:            @Test
045:            public void testTargetJDKVersion() {
046:                CommandLineOptions opt = new CommandLineOptions(new String[] {
047:                        "file", "format", "basic" });
048:                assertEquals("1.5", opt.getTargetJDK());
049:                opt = new CommandLineOptions(new String[] { "file", "format",
050:                        "ruleset", "-targetjdk", "1.3" });
051:                assertEquals("1.3", opt.getTargetJDK());
052:                opt = new CommandLineOptions(new String[] { "file", "format",
053:                        "ruleset", "-targetjdk", "1.5" });
054:                assertEquals("1.5", opt.getTargetJDK());
055:                opt = new CommandLineOptions(new String[] { "file", "format",
056:                        "ruleset", "-targetjdk", "1.6" });
057:                assertEquals("1.6", opt.getTargetJDK());
058:                opt = new CommandLineOptions(new String[] { "-targetjdk",
059:                        "1.6", "file", "format", "ruleset" });
060:                assertEquals("1.6", opt.getTargetJDK());
061:            }
062:
063:            @Test
064:            public void testDebug() {
065:                CommandLineOptions opt = new CommandLineOptions(new String[] {
066:                        "file", "format", "basic", "-debug" });
067:                assertTrue(opt.debugEnabled());
068:                opt = new CommandLineOptions(new String[] { "-debug", "file",
069:                        "format", "basic" });
070:                assertTrue(opt.debugEnabled());
071:            }
072:
073:            @Test
074:            public void testExcludeMarker() {
075:                CommandLineOptions opt = new CommandLineOptions(new String[] {
076:                        "file", "format", "basic", "-excludemarker", "FOOBAR" });
077:                assertEquals("FOOBAR", opt.getExcludeMarker());
078:                opt = new CommandLineOptions(new String[] { "-excludemarker",
079:                        "FOOBAR", "file", "format", "basic" });
080:                assertEquals("FOOBAR", opt.getExcludeMarker());
081:            }
082:
083:            @Test
084:            public void testShortNames() {
085:                CommandLineOptions opt = new CommandLineOptions(new String[] {
086:                        "file", "format", "basic", "-shortnames" });
087:                assertTrue(opt.shortNamesEnabled());
088:                opt = new CommandLineOptions(new String[] { "-shortnames",
089:                        "file", "format", "basic" });
090:                assertTrue(opt.shortNamesEnabled());
091:            }
092:
093:            @Test
094:            public void testEncoding() {
095:                CommandLineOptions opt = new CommandLineOptions(new String[] {
096:                        "file", "format", "basic" });
097:                assertTrue(opt.getEncoding().equals(
098:                        (new InputStreamReader(System.in)).getEncoding()));
099:                opt = new CommandLineOptions(new String[] { "file", "format",
100:                        "ruleset", "-encoding", "UTF-8" });
101:                assertTrue(opt.getEncoding().equals("UTF-8"));
102:                opt = new CommandLineOptions(new String[] { "-encoding",
103:                        "UTF-8", "file", "format", "ruleset" });
104:                assertTrue(opt.getEncoding().equals("UTF-8"));
105:            }
106:
107:            @Test
108:            public void testInputFileName() {
109:                CommandLineOptions opt = new CommandLineOptions(new String[] {
110:                        "file", "format", "basic" });
111:                assertEquals("file", opt.getInputPath());
112:            }
113:
114:            @Test
115:            public void testReportFormat() {
116:                CommandLineOptions opt = new CommandLineOptions(new String[] {
117:                        "file", "format", "basic" });
118:                assertEquals("format", opt.getReportFormat());
119:            }
120:
121:            @Test
122:            public void testRulesets() {
123:                CommandLineOptions opt = new CommandLineOptions(new String[] {
124:                        "file", "format", "basic" });
125:                assertEquals("rulesets/basic.xml", opt.getRulesets());
126:            }
127:
128:            @Test
129:            public void testCommaSeparatedFiles() {
130:                CommandLineOptions opt = new CommandLineOptions(new String[] {
131:                        "file1,file2,file3", "format", "basic" });
132:                assertTrue(opt.containsCommaSeparatedFileList());
133:            }
134:
135:            @Test(expected=RuntimeException.class)
136:            public void testNotEnoughArgs() {
137:                new CommandLineOptions(new String[] { "file1", "format" });
138:            }
139:
140:            @Test(expected=RuntimeException.class)
141:            public void testNullArgs() {
142:                new CommandLineOptions(null);
143:            }
144:
145:            @Test
146:            public void testReportFile() {
147:
148:                CommandLineOptions opt = new CommandLineOptions(new String[] {
149:                        "file", "format", "basic", "-reportfile", "foo.txt" });
150:                assertSame("foo.txt", opt.getReportFile());
151:                opt = new CommandLineOptions(new String[] { "-reportfile",
152:                        "foo.txt", "file", "format", "basic" });
153:                assertSame("foo.txt", opt.getReportFile());
154:            }
155:
156:            @Test
157:            public void testCpus() {
158:
159:                CommandLineOptions opt = new CommandLineOptions(new String[] {
160:                        "file", "format", "basic", "-cpus", "2" });
161:                assertEquals(2, opt.getCpus());
162:                opt = new CommandLineOptions(new String[] { "-cpus", "2",
163:                        "file", "format", "basic" });
164:                assertEquals(2, opt.getCpus());
165:            }
166:
167:            @Test
168:            public void testRenderer() {
169:                CommandLineOptions opt = new CommandLineOptions(new String[] {
170:                        "file", "xml", "basic" });
171:                assertTrue(opt.createRenderer() instanceof  XMLRenderer);
172:                opt = new CommandLineOptions(new String[] { "file", "html",
173:                        "basic" });
174:                assertTrue(opt.createRenderer() instanceof  HTMLRenderer);
175:                opt = new CommandLineOptions(new String[] { "file", "text",
176:                        "basic" });
177:                assertTrue(opt.createRenderer() instanceof  TextRenderer);
178:                opt = new CommandLineOptions(new String[] { "file", "emacs",
179:                        "basic" });
180:                assertTrue(opt.createRenderer() instanceof  EmacsRenderer);
181:                opt = new CommandLineOptions(new String[] { "file", "csv",
182:                        "basic" });
183:                assertTrue(opt.createRenderer() instanceof  CSVRenderer);
184:                opt = new CommandLineOptions(new String[] { "file", "vbhtml",
185:                        "basic" });
186:                assertTrue(opt.createRenderer() instanceof  VBHTMLRenderer);
187:                opt = new CommandLineOptions(new String[] { "file", "ideaj",
188:                        "basic" });
189:                assertTrue(opt.createRenderer() instanceof  IDEAJRenderer);
190:            }
191:
192:            @Test(expected=IllegalArgumentException.class)
193:            public void illegalArgument1() {
194:                CommandLineOptions opt = new CommandLineOptions(new String[] {
195:                        "file", "", "basic" });
196:                opt.createRenderer();
197:            }
198:
199:            @Test(expected=IllegalArgumentException.class)
200:            public void illegalArgument2() {
201:                CommandLineOptions opt = new CommandLineOptions(new String[] {
202:                        "file", "fiddlefaddle", "basic" });
203:                opt.createRenderer();
204:            }
205:
206:            @Test
207:            public void testOptionsFirst() {
208:                CommandLineOptions opt = new CommandLineOptions(new String[] {
209:                        "-cpus", "2", "-debug", "file", "format", "basic" });
210:                assertEquals(2, opt.getCpus());
211:                assertEquals("file", opt.getInputPath());
212:                assertEquals("format", opt.getReportFormat());
213:                assertEquals("rulesets/basic.xml", opt.getRulesets());
214:                assertTrue(opt.debugEnabled());
215:            }
216:
217:            public static junit.framework.Test suite() {
218:                return new JUnit4TestAdapter(CommandLineOptionsTest.class);
219:            }
220:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.