Source Code Cross Referenced for UserInfoAttributesServicesImplTest.java in  » Portal » Pluto » org » apache » pluto » driver » services » impl » 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 » Portal » Pluto » org.apache.pluto.driver.services.impl 
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.pluto.driver.services.impl;
018:
019:        import java.io.IOException;
020:        import java.security.Principal;
021:        import java.util.Enumeration;
022:        import java.util.Locale;
023:        import java.util.Map;
024:        import java.util.Properties;
025:
026:        import javax.portlet.PortalContext;
027:        import javax.portlet.PortletMode;
028:        import javax.portlet.PortletPreferences;
029:        import javax.portlet.PortletRequest;
030:        import javax.portlet.PortletSession;
031:        import javax.portlet.WindowState;
032:
033:        import org.apache.pluto.PortletContainerException;
034:        import org.apache.pluto.spi.optional.P3PAttributes;
035:
036:        import junit.framework.TestCase;
037:
038:        /**
039:         * JUnit test class for UserInfoAttributesServicesImpl.
040:         *
041:         */
042:        public class UserInfoAttributesServicesImplTest extends TestCase {
043:            /* Represents properties in user-info-attributes.properties */
044:            private Properties props = new Properties();
045:            //Test data
046:            /* Test user - used in MockPortletRequest */
047:            private static final String TEST_REMOTE_USER = "tomcat";
048:            private static final String TEST_USER_GENDER = "male";
049:            private static final String TEST_USER_NAME_GIVEN = "Catalina";
050:            private static final String TEST_USER_NAME_FAMILY = "Tomcat";
051:
052:            protected void setUp() throws Exception {
053:                super .setUp();
054:                props.setProperty(TEST_REMOTE_USER + "."
055:                        + P3PAttributes.USER_GENDER, TEST_USER_GENDER);
056:                props.setProperty(TEST_REMOTE_USER + "."
057:                        + P3PAttributes.USER_NAME_GIVEN, TEST_USER_NAME_GIVEN);
058:                props
059:                        .setProperty(TEST_REMOTE_USER + "."
060:                                + P3PAttributes.USER_NAME_FAMILY,
061:                                TEST_USER_NAME_FAMILY);
062:            }
063:
064:            /*
065:             * Test method for 'org.apache.pluto.services.optional.UserInfoAttributesServiceImpl.getUserInfo(PortletRequest)'
066:             */
067:            public void testGetAttributes() {
068:                try {
069:                    Map map = null;
070:                    UserInfoAttributesServiceImpl uias = UserInfoAttributesServiceImpl
071:                            .getInstance(props);
072:                    PortletRequest pr = new MockPortletRequest();
073:                    map = uias.getUserInfo(pr);
074:                    String sex = (String) map.get(P3PAttributes.USER_GENDER);
075:                    assertTrue(sex.equals(TEST_USER_GENDER));
076:                    System.out.println("Sex: " + sex);
077:                    String fname = (String) map
078:                            .get(P3PAttributes.USER_NAME_GIVEN);
079:                    assertTrue(fname.equals(TEST_USER_NAME_GIVEN));
080:                    System.out.println("first name: " + fname);
081:                    String lname = (String) map
082:                            .get(P3PAttributes.USER_NAME_FAMILY);
083:                    assertTrue(lname.equals(TEST_USER_NAME_FAMILY));
084:                    System.out.println("last name: " + lname);
085:                } catch (IOException e) {
086:                    e.printStackTrace();
087:                    fail(e.toString());
088:                } catch (PortletContainerException e) {
089:                    e.printStackTrace();
090:                    fail(e.toString());
091:                }
092:            }
093:
094:            /**
095:             * Stubbed implementation used only by this class where only
096:             * getRemoteUser() has been implemented to return a constant.
097:             *
098:             */
099:            public class MockPortletRequest implements  PortletRequest {
100:
101:                public boolean isWindowStateAllowed(WindowState arg0) {
102:                    // TODO Auto-generated method stub
103:                    return false;
104:                }
105:
106:                public boolean isPortletModeAllowed(PortletMode arg0) {
107:                    // TODO Auto-generated method stub
108:                    return false;
109:                }
110:
111:                public PortletMode getPortletMode() {
112:                    // TODO Auto-generated method stub
113:                    return null;
114:                }
115:
116:                public WindowState getWindowState() {
117:                    // TODO Auto-generated method stub
118:                    return null;
119:                }
120:
121:                public PortletPreferences getPreferences() {
122:                    // TODO Auto-generated method stub
123:                    return null;
124:                }
125:
126:                public PortletSession getPortletSession() {
127:                    // TODO Auto-generated method stub
128:                    return null;
129:                }
130:
131:                public PortletSession getPortletSession(boolean arg0) {
132:                    // TODO Auto-generated method stub
133:                    return null;
134:                }
135:
136:                public String getProperty(String arg0) {
137:                    // TODO Auto-generated method stub
138:                    return null;
139:                }
140:
141:                public Enumeration getProperties(String arg0) {
142:                    // TODO Auto-generated method stub
143:                    return null;
144:                }
145:
146:                public Enumeration getPropertyNames() {
147:                    // TODO Auto-generated method stub
148:                    return null;
149:                }
150:
151:                public PortalContext getPortalContext() {
152:                    // TODO Auto-generated method stub
153:                    return null;
154:                }
155:
156:                public String getAuthType() {
157:                    // TODO Auto-generated method stub
158:                    return null;
159:                }
160:
161:                public String getContextPath() {
162:                    // TODO Auto-generated method stub
163:                    return null;
164:                }
165:
166:                public String getRemoteUser() {
167:                    return TEST_REMOTE_USER;
168:                }
169:
170:                public Principal getUserPrincipal() {
171:                    // TODO Auto-generated method stub
172:                    return null;
173:                }
174:
175:                public boolean isUserInRole(String arg0) {
176:                    // TODO Auto-generated method stub
177:                    return false;
178:                }
179:
180:                public Object getAttribute(String arg0) {
181:                    // TODO Auto-generated method stub
182:                    return null;
183:                }
184:
185:                public Enumeration getAttributeNames() {
186:                    // TODO Auto-generated method stub
187:                    return null;
188:                }
189:
190:                public String getParameter(String arg0) {
191:                    // TODO Auto-generated method stub
192:                    return null;
193:                }
194:
195:                public Enumeration getParameterNames() {
196:                    // TODO Auto-generated method stub
197:                    return null;
198:                }
199:
200:                public String[] getParameterValues(String arg0) {
201:                    // TODO Auto-generated method stub
202:                    return null;
203:                }
204:
205:                public Map getParameterMap() {
206:                    // TODO Auto-generated method stub
207:                    return null;
208:                }
209:
210:                public boolean isSecure() {
211:                    // TODO Auto-generated method stub
212:                    return false;
213:                }
214:
215:                public void setAttribute(String arg0, Object arg1) {
216:                    // TODO Auto-generated method stub
217:
218:                }
219:
220:                public void removeAttribute(String arg0) {
221:                    // TODO Auto-generated method stub
222:
223:                }
224:
225:                public String getRequestedSessionId() {
226:                    // TODO Auto-generated method stub
227:                    return null;
228:                }
229:
230:                public boolean isRequestedSessionIdValid() {
231:                    // TODO Auto-generated method stub
232:                    return false;
233:                }
234:
235:                public String getResponseContentType() {
236:                    // TODO Auto-generated method stub
237:                    return null;
238:                }
239:
240:                public Enumeration getResponseContentTypes() {
241:                    // TODO Auto-generated method stub
242:                    return null;
243:                }
244:
245:                public Locale getLocale() {
246:                    // TODO Auto-generated method stub
247:                    return null;
248:                }
249:
250:                public Enumeration getLocales() {
251:                    // TODO Auto-generated method stub
252:                    return null;
253:                }
254:
255:                public String getScheme() {
256:                    // TODO Auto-generated method stub
257:                    return null;
258:                }
259:
260:                public String getServerName() {
261:                    // TODO Auto-generated method stub
262:                    return null;
263:                }
264:
265:                public int getServerPort() {
266:                    // TODO Auto-generated method stub
267:                    return 0;
268:                }
269:
270:            }
271:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.