Source Code Cross Referenced for CookieSelectorTestCase.java in  » Content-Management-System » apache-lenya-2.0 » org » apache » cocoon » selection » 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 » Content Management System » apache lenya 2.0 » org.apache.cocoon.selection 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package org.apache.cocoon.selection;
018:
019:        import java.util.Map;
020:        import junit.framework.Test;
021:        import junit.framework.TestSuite;
022:        import junit.textui.TestRunner;
023:        import org.apache.avalon.framework.parameters.Parameters;
024:        import org.apache.cocoon.SitemapComponentTestCase;
025:        import org.apache.cocoon.environment.mock.MockCookie;
026:
027:        public class CookieSelectorTestCase extends SitemapComponentTestCase {
028:
029:            private static final String COOKIE_SELECTOR = "cookie";
030:
031:            /**
032:             * Run this test suite from commandline
033:             *
034:             * @param args commandline arguments (ignored)
035:             */
036:            public static void main(String[] args) {
037:                TestRunner.run(suite());
038:            }
039:
040:            /** Create a test suite.
041:             * This test suite contains all test cases of this class.
042:             * @return the Test object containing all test cases.
043:             */
044:            public static Test suite() {
045:                TestSuite suite = new TestSuite(CookieSelectorTestCase.class);
046:                return suite;
047:            }
048:
049:            /**
050:             * A simple cookie select test
051:             */
052:            public void testCookieSelect() throws Exception {
053:                final String cookieName = "cookieSelectorTestCase";
054:                final String cookieValue = "cookieValue";
055:                // create a cookie
056:                // setting name := cookieName, value := cookieValue
057:                Map cookies = getRequest().getCookieMap();
058:                MockCookie mockCookie = new MockCookie();
059:                mockCookie.setName(cookieName);
060:                mockCookie.setValue(cookieValue);
061:                cookies.put(cookieName, mockCookie);
062:
063:                Parameters parameters = new Parameters();
064:                boolean result;
065:
066:                // test selection success
067:                result = this .select(COOKIE_SELECTOR, cookieValue, parameters);
068:                System.out.println(result);
069:                assertTrue("Test if a cookie is selected", result);
070:
071:                // test selection failure
072:                result = this .select(COOKIE_SELECTOR, "unknownCookieValue",
073:                        parameters);
074:                System.out.println(result);
075:                assertTrue("Test if a cookie is not selected", !result);
076:            }
077:
078:            /**
079:             * A simple cookie select test
080:             */
081:            public void testCookieSelectUsingParameters() throws Exception {
082:                final String cookieName = "cookieSelectorTestCase1";
083:                final String cookieValue = "cookieValue";
084:
085:                // create a cookie
086:                // setting name := cookieName, value := cookieValue
087:                Map cookies = getRequest().getCookieMap();
088:                MockCookie mockCookie = new MockCookie();
089:                // this cookie shall get selected
090:                mockCookie.setName(cookieName);
091:                mockCookie.setValue(cookieValue);
092:                cookies.put(cookieName, mockCookie);
093:
094:                // this cookie shall be ignored, as its name differs
095:                // from the parameterized cookie name
096:                mockCookie = new MockCookie();
097:                mockCookie.setName("cookieSelectorTestCase");
098:                mockCookie.setValue("unknownCookieValue");
099:                cookies.put("cookieSelectorTestCase", mockCookie);
100:
101:                // check the cookie as defined by this parameter, not as
102:                // defined in the component configuration
103:                Parameters parameters = new Parameters();
104:                parameters.setParameter("cookie-name", cookieName);
105:
106:                boolean result;
107:
108:                // test selection success
109:                result = this .select(COOKIE_SELECTOR, cookieValue, parameters);
110:                System.out.println(result);
111:                assertTrue("Test if a cookie is selected", result);
112:
113:                // test selection failure
114:                result = this .select(COOKIE_SELECTOR, "unknownCookieValue",
115:                        parameters);
116:                System.out.println(result);
117:                assertTrue("Test if a cookie is not selected", !result);
118:            }
119:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.