Source Code Cross Referenced for JspPageStyleTest.java in  » Code-Analyzer » pmd-4.2rc1 » test » net » sourceforge » pmd » jsp » ast » 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.jsp.ast 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package test.net.sourceforge.pmd.jsp.ast;
002:
003:        import static org.junit.Assert.assertEquals;
004:        import net.sourceforge.pmd.jsp.ast.ASTElExpression;
005:        import net.sourceforge.pmd.jsp.ast.ASTJspComment;
006:        import net.sourceforge.pmd.jsp.ast.ASTJspDeclaration;
007:        import net.sourceforge.pmd.jsp.ast.ASTJspDirective;
008:        import net.sourceforge.pmd.jsp.ast.ASTJspDirectiveAttribute;
009:        import net.sourceforge.pmd.jsp.ast.ASTJspExpression;
010:        import net.sourceforge.pmd.jsp.ast.ASTJspExpressionInAttribute;
011:        import net.sourceforge.pmd.jsp.ast.ASTJspScriptlet;
012:        import net.sourceforge.pmd.jsp.ast.ASTValueBinding;
013:
014:        import org.junit.Test;
015:
016:        import java.util.ArrayList;
017:        import java.util.Collections;
018:        import java.util.Comparator;
019:        import java.util.List;
020:        import java.util.Set;
021:
022:        public class JspPageStyleTest extends AbstractJspNodesTst {
023:
024:            /**
025:             * Test parsing of a JSP comment.
026:             */
027:            @Test
028:            public void testComment() {
029:                Set comments = getNodes(ASTJspComment.class, JSP_COMMENT);
030:                assertEquals("One comment expected!", 1, comments.size());
031:                ASTJspComment comment = (ASTJspComment) comments.iterator()
032:                        .next();
033:                assertEquals("Correct comment content expected!",
034:                        "some comment", comment.getImage());
035:            }
036:
037:            /**
038:             * Test parsing a JSP directive.
039:             */
040:            @Test
041:            public void testDirective() {
042:                Set nodes = getNodes(null, JSP_DIRECTIVE);
043:
044:                Set<ASTJspDirective> directives = getNodesOfType(
045:                        ASTJspDirective.class, nodes);
046:                assertEquals("One directive expected!", 1, directives.size());
047:                ASTJspDirective directive = directives.iterator().next();
048:                assertEquals("Correct directive name expected!", "page",
049:                        directive.getName());
050:
051:                Set<ASTJspDirectiveAttribute> directiveAttrs = getNodesOfType(
052:                        ASTJspDirectiveAttribute.class, nodes);
053:                assertEquals("Two directive attributes expected!", 2,
054:                        directiveAttrs.size());
055:
056:                List<ASTJspDirectiveAttribute> attrsList = new ArrayList<ASTJspDirectiveAttribute>(
057:                        directiveAttrs);
058:                Collections.sort(attrsList,
059:                        new Comparator<ASTJspDirectiveAttribute>() {
060:                            public int compare(ASTJspDirectiveAttribute arg0,
061:                                    ASTJspDirectiveAttribute arg1) {
062:                                return arg0.getName().compareTo(arg1.getName());
063:                            }
064:                        });
065:
066:                ASTJspDirectiveAttribute attr = attrsList.get(0);
067:                assertEquals("Correct directive attribute name expected!",
068:                        "language", attr.getName());
069:                assertEquals("Correct directive attribute value expected!",
070:                        "java", attr.getValue());
071:
072:                attr = attrsList.get(1);
073:                assertEquals("Correct directive attribute name expected!",
074:                        "session", attr.getName());
075:                assertEquals("Correct directive attribute value expected!",
076:                        "true", attr.getValue());
077:
078:            }
079:
080:            /**
081:             * Test parsing of a JSP declaration.
082:             */
083:            @Test
084:            public void testDeclaration() {
085:                Set declarations = getNodes(ASTJspDeclaration.class,
086:                        JSP_DECLARATION);
087:                assertEquals("One declaration expected!", 1, declarations
088:                        .size());
089:                ASTJspDeclaration declaration = (ASTJspDeclaration) declarations
090:                        .iterator().next();
091:                assertEquals("Correct declaration content expected!",
092:                        "String someString = \"s\";", declaration.getImage());
093:            }
094:
095:            /**
096:             * Test parsing of a JSP scriptlet.
097:             */
098:            @Test
099:            public void testScriptlet() {
100:                Set scriptlets = getNodes(ASTJspScriptlet.class, JSP_SCRIPTLET);
101:                assertEquals("One scriptlet expected!", 1, scriptlets.size());
102:                ASTJspScriptlet scriptlet = (ASTJspScriptlet) scriptlets
103:                        .iterator().next();
104:                assertEquals("Correct scriptlet content expected!",
105:                        "someString = someString + \"suffix\";", scriptlet
106:                                .getImage());
107:            }
108:
109:            /**
110:             * Test parsing of a JSP expression.
111:             */
112:            @Test
113:            public void testExpression() {
114:                Set expressions = getNodes(ASTJspExpression.class,
115:                        JSP_EXPRESSION);
116:                assertEquals("One expression expected!", 1, expressions.size());
117:                ASTJspExpression expression = (ASTJspExpression) expressions
118:                        .iterator().next();
119:                assertEquals("Correct expression content expected!",
120:                        "someString", expression.getImage());
121:            }
122:
123:            /**
124:             * Test parsing of a JSP expression in an attribute.
125:             */
126:            @Test
127:            public void testExpressionInAttribute() {
128:                Set expressions = getNodes(ASTJspExpressionInAttribute.class,
129:                        JSP_EXPRESSION_IN_ATTRIBUTE);
130:                assertEquals("One expression expected!", 1, expressions.size());
131:                ASTJspExpressionInAttribute expression = (ASTJspExpressionInAttribute) expressions
132:                        .iterator().next();
133:                assertEquals("Correct expression content expected!",
134:                        "style.getClass()", expression.getImage());
135:            }
136:
137:            /**
138:             * Test parsing of a EL expression.
139:             */
140:            @Test
141:            public void testElExpression() {
142:                Set expressions = getNodes(ASTElExpression.class,
143:                        JSP_EL_EXPRESSION);
144:                assertEquals("One expression expected!", 1, expressions.size());
145:                ASTElExpression expression = (ASTElExpression) expressions
146:                        .iterator().next();
147:                assertEquals("Correct expression content expected!",
148:                        "myBean.get(\"${ World }\")", expression.getImage());
149:            }
150:
151:            /**
152:             * Test parsing of a EL expression in an attribute.
153:             */
154:            @Test
155:            public void testElExpressionInAttribute() {
156:                Set expressions = getNodes(ASTElExpression.class,
157:                        JSP_EL_EXPRESSION_IN_ATTRIBUTE);
158:                assertEquals("One expression expected!", 1, expressions.size());
159:                ASTElExpression expression = (ASTElExpression) expressions
160:                        .iterator().next();
161:                assertEquals("Correct expression content expected!",
162:                        "myValidator.find(\"'jsp'\")", expression.getImage());
163:            }
164:
165:            /**
166:             * Test parsing of a EL expression in an attribute.
167:             */
168:            @Test
169:            public void testJsfValueBinding() {
170:                Set valueBindings = getNodes(ASTValueBinding.class,
171:                        JSF_VALUE_BINDING);
172:                assertEquals("One value binding expected!", 1, valueBindings
173:                        .size());
174:                ASTValueBinding valueBinding = (ASTValueBinding) valueBindings
175:                        .iterator().next();
176:                assertEquals("Correct expression content expected!",
177:                        "myValidator.find(\"'jsf'\")", valueBinding.getImage());
178:            }
179:
180:            private static final String JSP_COMMENT = "<html> <%-- some comment --%> </html>";
181:
182:            private static final String JSP_DIRECTIVE = "<html> <%@ page language=\"java\" session='true'%> </html>";
183:
184:            private static final String JSP_DECLARATION = "<html><%! String someString = \"s\"; %></html>";
185:
186:            private static final String JSP_SCRIPTLET = "<html> <% someString = someString + \"suffix\"; %> </html>";
187:
188:            private static final String JSP_EXPRESSION = "<html><head><title> <%= someString %> </title></head></html>";
189:
190:            private static final String JSP_EXPRESSION_IN_ATTRIBUTE = "<html> <body> <p class='<%= style.getClass() %>'> Hello </p> </body> </html>";
191:
192:            private static final String JSP_EL_EXPRESSION = "<html><title>Hello ${myBean.get(\"${ World }\") } .jsp</title></html>";
193:
194:            private static final String JSP_EL_EXPRESSION_IN_ATTRIBUTE = "<html> <f:validator type=\"get('type').${myValidator.find(\"'jsp'\")}\" /> </html>";
195:
196:            private static final String JSF_VALUE_BINDING = "<html> <body> <p class='#{myValidator.find(\"'jsf'\")}'> Hello </p> </body> </html>";
197:
198:            public static junit.framework.Test suite() {
199:                return new junit.framework.JUnit4TestAdapter(
200:                        JspPageStyleTest.class);
201:            }
202:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.