Source Code Cross Referenced for CmIntegrationTest.java in  » ERP-CRM-Financial » sakai » org » sakaiproject » coursemanagement » 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 » ERP CRM Financial » sakai » org.sakaiproject.coursemanagement.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**********************************************************************************
002:         * $URL: https://source.sakaiproject.org/svn/course-management/tags/sakai_2-4-1/cm-impl/integration-test/src/test/org/sakaiproject/coursemanagement/impl/CmIntegrationTest.java $
003:         * $Id: CmIntegrationTest.java 20528 2007-01-22 18:22:33Z jholtzman@berkeley.edu $
004:         ***********************************************************************************
005:         *
006:         * Copyright (c) 2006 The Sakai Foundation.
007:         * 
008:         * Licensed under the Educational Community License, Version 1.0 (the "License"); 
009:         * you may not use this file except in compliance with the License. 
010:         * You may obtain a copy of the License at
011:         * 
012:         *      http://www.opensource.org/licenses/ecl1.php
013:         * 
014:         * Unless required by applicable law or agreed to in writing, software 
015:         * distributed under the License is distributed on an "AS IS" BASIS, 
016:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
017:         * See the License for the specific language governing permissions and 
018:         * limitations under the License.
019:         *
020:         **********************************************************************************/package org.sakaiproject.coursemanagement.impl;
021:
022:        import java.util.HashSet;
023:        import java.util.Set;
024:
025:        import junit.extensions.TestSetup;
026:        import junit.framework.Assert;
027:        import junit.framework.Test;
028:        import junit.framework.TestSuite;
029:
030:        import org.apache.commons.logging.Log;
031:        import org.apache.commons.logging.LogFactory;
032:        import org.sakaiproject.authz.api.AuthzGroup;
033:        import org.sakaiproject.authz.api.AuthzGroupService;
034:        import org.sakaiproject.authz.api.Member;
035:        import org.sakaiproject.coursemanagement.api.CourseManagementAdministration;
036:        import org.sakaiproject.site.api.Site;
037:        import org.sakaiproject.site.api.SiteService;
038:        import org.sakaiproject.test.SakaiTestBase;
039:        import org.sakaiproject.tool.api.Session;
040:        import org.sakaiproject.tool.api.SessionManager;
041:        import org.sakaiproject.user.api.UserDirectoryService;
042:
043:        /**
044:         * Integration tests for the CM services.  The CmGroupProvider must be registered
045:         * with the component manager for these tests to pass.
046:         * 
047:         * @author <a href="mailto:jholtzman@berkeley.edu">Josh Holtzman</a>
048:         *
049:         */
050:        public class CmIntegrationTest extends SakaiTestBase {
051:            private static final Log log = LogFactory
052:                    .getLog(CmIntegrationTest.class);
053:
054:            private AuthzGroupService authzGroupService;
055:            private SiteService siteService;
056:            private CourseManagementAdministration cmAdmin;
057:            private UserDirectoryService uds;
058:
059:            private Site site;
060:
061:            public static Test suite() {
062:                TestSetup setup = new TestSetup(new TestSuite(
063:                        CmIntegrationTest.class)) {
064:                    protected void setUp() throws Exception {
065:                        log.debug("starting setup");
066:                        oneTimeSetup();
067:                        log.debug("finished setup");
068:                    }
069:
070:                    protected void tearDown() throws Exception {
071:                        oneTimeTearDown();
072:                    }
073:                };
074:                return setup;
075:            }
076:
077:            public void setUp() throws Exception {
078:                log.debug("Setting up a CmIntegrationTest test");
079:
080:                // Connect to the required services
081:                authzGroupService = (AuthzGroupService) getService(AuthzGroupService.class
082:                        .getName());
083:                siteService = (SiteService) getService(SiteService.class
084:                        .getName());
085:                cmAdmin = (CourseManagementAdministration) getService(CourseManagementAdministration.class
086:                        .getName());
087:                uds = (UserDirectoryService) getService(UserDirectoryService.class
088:                        .getName());
089:
090:                // Log in
091:                SessionManager sessionManager = (SessionManager) getService(SessionManager.class
092:                        .getName());
093:                Session session = sessionManager.getCurrentSession();
094:                session.setUserId("admin");
095:
096:                // Create some Sakai users (who will be added to the site by the CMGroupProvider)
097:                uds.addUser("cm-student1", "cm-student1", "cm-student",
098:                        "CM-one", "cm-student1@foo.bar", "cm-student1", null,
099:                        null);
100:                uds.addUser("cm-student2", "cm-student2", "cm-student",
101:                        "CM-two", "cm-student2@foo.bar", "cm-student2", null,
102:                        null);
103:                uds.addUser("cm-instructor1", "cm-instructor1",
104:                        "cm-instructor", "CM-one", "cm-instructor1@foo.bar",
105:                        "cm-instructor1", null, null);
106:                uds.addUser("cm-instructor2", "cm-instructor2",
107:                        "cm-instructor", "CM-two", "cm-instructor2@foo.bar",
108:                        "cm-instructor2", null, null);
109:
110:                // Create CM objects
111:                cmAdmin.createAcademicSession("CM-AS1", "CM-AS1", "CM-AS1",
112:                        null, null);
113:                cmAdmin.createCanonicalCourse("CM-CC1", "CM-CC1", "CM-CC1");
114:                cmAdmin.createCourseOffering("CM-CO1", "CM-CO1", "CM-CO1",
115:                        "open", "CM-AS1", "CM-CC1", null, null);
116:                Set instructors = new HashSet();
117:                instructors.add("cm-instructor1");
118:                cmAdmin.createEnrollmentSet("CM-ES1", "CM-ES1", "CM-ES1",
119:                        "lecture", "3", "CM-CO1", instructors);
120:                cmAdmin.createSection("CM-SEC1", "CM-SEC1", "CM-SEC1",
121:                        "lecture", null, "CM-CO1", "CM-ES1");
122:
123:                // Create some CM memberships, etc
124:                cmAdmin.addOrUpdateCourseOfferingMembership("cm-instructor2",
125:                        "Just helping out with guest lectures", "CM-CO1",
126:                        "active");
127:                cmAdmin.addOrUpdateEnrollment("cm-student1", "CM-ES1",
128:                        "waitlisted", "4", "letter grade");
129:
130:                // Create a site
131:                site = siteService.addSite("CM1", "course");
132:                site.setTitle("CM Integration Test Site");
133:                site.setProviderGroupId("CM-SEC1");
134:                siteService.save(site);
135:
136:                // This (or something similar) is needed to trigger the authz provider update, I think
137:                String siteRef = site.getReference();
138:                AuthzGroup azg = authzGroupService.getAuthzGroup(siteRef);
139:                // Ensure that the azg has the correct provider id
140:                Assert.assertEquals("CM-SEC1", azg.getProviderGroupId());
141:                azg.addMember("cm-student2", "Student", true, false);
142:                authzGroupService.save(azg);
143:
144:                // Now we have all of our users as members of the site: student1 is enrolled,
145:                // student2 was manually added, instructor1 is an official instructor, and
146:                // instructor2 has a membership in the course offering.
147:            }
148:
149:            public void tearDown() throws Exception {
150:                log.debug("Tearing down an AuthzIntegrationTest test");
151:
152:                // Remove the objects created for testing
153:                uds.removeUser(uds.editUser("cm-student1"));
154:                uds.removeUser(uds.editUser("cm-student2"));
155:                uds.removeUser(uds.editUser("cm-instructor1"));
156:                uds.removeUser(uds.editUser("cm-instructor2"));
157:
158:                cmAdmin.removeSection("CM-SEC1");
159:                cmAdmin.removeEnrollmentSet("CM-ES1");
160:                cmAdmin.removeCourseOffering("CM-CO1");
161:                cmAdmin.removeCanonicalCourse("CM-CC1");
162:                cmAdmin.removeAcademicSession("CM-AS1");
163:
164:                siteService.removeSite(site);
165:            }
166:
167:            public void testCmGroupProvider() throws Exception {
168:                // Our official instructors, enrollments and CM memberships should be expressed as sakai members
169:                Site site = siteService.getSite("CM1");
170:
171:                // Of course, our manually added member should be here
172:                Member manualMember = site.getMember("cm-student2");
173:                Assert.assertNotNull(manualMember);
174:                Assert.assertEquals("Student", manualMember.getRole().getId());
175:
176:                // Our CM-defined student should be here, too
177:                Member student = site.getMember("cm-student1");
178:                Assert.assertNotNull(student);
179:                Assert.assertEquals("Student", student.getRole().getId());
180:
181:            }
182:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.