Source Code Cross Referenced for TestCreateUserHomePagesFromRoles.java in  » Portal » jetspeed-2.1.3 » org » apache » jetspeed » page » 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 » jetspeed 2.1.3 » org.apache.jetspeed.page 
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.jetspeed.page;
018:
019:        import java.security.Principal;
020:        import java.util.HashSet;
021:        import java.util.Set;
022:
023:        import javax.security.auth.Subject;
024:
025:        import junit.framework.Test;
026:        import junit.framework.TestCase;
027:        import junit.framework.TestSuite;
028:
029:        import org.apache.jetspeed.om.folder.Folder;
030:        import org.apache.jetspeed.page.psml.CastorXmlPageManager;
031:        import org.apache.jetspeed.security.impl.RolePrincipalImpl;
032:        import org.apache.jetspeed.security.impl.UserPrincipalImpl;
033:
034:        /**
035:         * TestSecureCastorXmlPageManager
036:         * 
037:         * @author <a href="rwatler@apache.org">Randy Watler</a>
038:         * @version $Id$
039:         */
040:        public class TestCreateUserHomePagesFromRoles extends TestCase
041:                implements  PageManagerTestShared {
042:            protected CastorXmlPageManager pageManager;
043:
044:            /*
045:             * (non-Javadoc)
046:             * 
047:             * @see junit.framework.TestCase#setUp()
048:             */
049:            protected void setUp() throws Exception {
050:                super .setUp();
051:                pageManager = Shared.makeCastorXMLPageManager("secure-pages",
052:                        false, true);
053:            }
054:
055:            /**
056:             * <p>
057:             * tearDown
058:             * </p>
059:             * 
060:             * @see junit.framework.TestCase#tearDown()
061:             * @throws java.lang.Exception
062:             */
063:            protected void tearDown() throws Exception {
064:                super .tearDown();
065:            }
066:
067:            /**
068:             * Defines the testcase name for JUnit.
069:             * 
070:             * @param name
071:             *            the testcase's name.
072:             */
073:            public TestCreateUserHomePagesFromRoles(String name) {
074:                super (name);
075:            }
076:
077:            /**
078:             * Start the tests.
079:             * 
080:             * @param args
081:             *            the arguments. Not used
082:             */
083:            public static void main(String args[]) {
084:                junit.awtui.TestRunner
085:                        .main(new String[] { TestCreateUserHomePagesFromRoles.class
086:                                .getName() });
087:            }
088:
089:            /**
090:             * Creates the test suite.
091:             * 
092:             * @return a test suite (<code>TestSuite</code>) that includes all
093:             *         methods starting with "test"
094:             */
095:            public static Test suite() {
096:                // All methods starting with "test" will be executed in the test suite.
097:                return new TestSuite(TestCreateUserHomePagesFromRoles.class);
098:            }
099:
100:            static final String FOLDER1 = Folder.ROLE_FOLDER + "role1";
101:            static final String FOLDER2 = Folder.ROLE_FOLDER + "role2";
102:            static final String FOLDER3 = Folder.ROLE_FOLDER + "role3";
103:
104:            static final String DEFAULT_PAGE = Folder.USER_FOLDER + "david"
105:                    + Folder.PATH_SEPARATOR + "default-page.psml";
106:            static final String ROLE_PAGE_1 = Folder.USER_FOLDER + "david"
107:                    + Folder.PATH_SEPARATOR + "role1-default-page.psml";
108:            static final String ROLE_PAGE_2 = Folder.USER_FOLDER + "david"
109:                    + Folder.PATH_SEPARATOR + "role2-default-page.psml";
110:            static final String ROLE_PAGE_3 = Folder.USER_FOLDER + "david"
111:                    + Folder.PATH_SEPARATOR + "role3-default-page.psml";
112:            static final String SUB_PAGE = Folder.USER_FOLDER + "david"
113:                    + Folder.PATH_SEPARATOR + "sub1" + Folder.PATH_SEPARATOR
114:                    + "default-page.psml";
115:            static final String SUB_LINK = Folder.USER_FOLDER + "david"
116:                    + Folder.PATH_SEPARATOR + "sub1" + Folder.PATH_SEPARATOR
117:                    + "apache_portals.link";
118:
119:            public void testCreateUserHomePagesFromRoles() throws Exception {
120:                PageManager pageManager = Shared.makeCastorXMLPageManager(
121:                        "pages", false, false);
122:
123:                assertTrue("folder1 failed to create", pageManager
124:                        .folderExists(FOLDER1));
125:                assertTrue("folder2 failed to create", pageManager
126:                        .folderExists(FOLDER2));
127:                assertTrue("folder3 failed to create", pageManager
128:                        .folderExists(FOLDER3));
129:
130:                Set principals = new HashSet();
131:
132:                // create the role principals
133:                Principal rolePrincipal1 = new RolePrincipalImpl("role1");
134:                Principal rolePrincipal2 = new RolePrincipalImpl("role2");
135:                Principal rolePrincipal3 = new RolePrincipalImpl("role3");
136:                principals.add(rolePrincipal1);
137:                principals.add(rolePrincipal2);
138:                principals.add(rolePrincipal3);
139:
140:                // create the user principal
141:                Principal userPrincipal = new UserPrincipalImpl("david");
142:                principals.add(userPrincipal);
143:
144:                // create the subject
145:                Subject subject = new Subject(true, principals, new HashSet(),
146:                        new HashSet());
147:
148:                pageManager.createUserHomePagesFromRoles(subject);
149:
150:                assertTrue("failed to create default page", pageManager
151:                        .pageExists(DEFAULT_PAGE));
152:                assertTrue("failed to create sub page", pageManager
153:                        .pageExists(SUB_PAGE));
154:                assertTrue("failed to create sub link", pageManager
155:                        .linkExists(SUB_LINK));
156:            }
157:
158:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.