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


001:        /**********************************************************************************
002:         * $URL: https://source.sakaiproject.org/svn/sections/tags/sakai_2-4-1/sections-impl/integration-test/src/java/org/sakaiproject/test/section/CourseManagementIntegrationTest.java $
003:         * $Id: CourseManagementIntegrationTest.java 20230 2007-01-10 01:13:02Z jholtzman@berkeley.edu $
004:         ***********************************************************************************
005:         *
006:         * Copyright (c) 2005, 2006 The Regents of the University of California and The Regents of the University of Michigan
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.test.section;
021:
022:        import junit.framework.Assert;
023:
024:        import org.sakaiproject.component.section.sakai.SectionManagerImpl;
025:        import org.sakaiproject.section.api.SectionManager;
026:        import org.sakaiproject.section.api.SectionManager.ExternalIntegrationConfig;
027:        import org.sakaiproject.section.api.coursemanagement.CourseSection;
028:        import org.sakaiproject.section.api.facade.Role;
029:        import org.sakaiproject.site.api.Site;
030:        import org.sakaiproject.site.api.SiteService;
031:        import org.sakaiproject.test.SakaiTestBase;
032:        import org.sakaiproject.tool.api.Session;
033:        import org.sakaiproject.tool.api.SessionManager;
034:
035:        public class CourseManagementIntegrationTest extends SakaiTestBase {
036:            // Services
037:            private SiteService siteService;
038:            private SessionManager sessionManager;
039:            private SectionManager sectionManager;
040:
041:            // Objects we'll need to clean up on tearDown
042:            private String siteId;
043:
044:            /**
045:             * Setup test fixture (runs once for each test method called)
046:             */
047:            public void setUp() throws Exception {
048:                // Fetch the services we need to run the tests
049:                siteService = (SiteService) getService(SiteService.class
050:                        .getName());
051:                sessionManager = (SessionManager) getService(SessionManager.class
052:                        .getName());
053:                sectionManager = (SectionManager) getService(SectionManager.class
054:                        .getName());
055:
056:                Session session = sessionManager.getCurrentSession();
057:                session.setUserId("admin");
058:                session.setUserEid("admin");
059:            }
060:
061:            /**
062:             * Remove the newly created objects, so we can run more tests with a clean slate.
063:             */
064:            public void tearDown() throws Exception {
065:                if (siteId != null) {
066:                    Site site = siteService.getSite(siteId);
067:                    siteService.removeSite(site);
068:                }
069:            }
070:
071:            //// Manual Mandatory ////
072:
073:            public void testManualMandatoryConfig() throws Exception {
074:                // Set the sectionManager to be manual mandatory
075:                ((SectionManagerImpl) sectionManager)
076:                        .setConfig(ExternalIntegrationConfig.MANUAL_MANDATORY
077:                                .toString());
078:
079:                // Create a site
080:                siteId = generateSiteId();
081:                Site site = siteService.addSite(siteId, "course");
082:                String siteReference = site.getReference();
083:
084:                // Ensure that the site is not externally managed by default
085:                Assert.assertFalse(sectionManager
086:                        .isExternallyManaged(siteReference));
087:
088:                // Ensure that the section manager won't allow the site to be set to "automatic" sections
089:                try {
090:                    sectionManager.setExternallyManaged(siteReference, true);
091:                    fail();
092:                } catch (Exception e) {
093:                }
094:            }
095:
096:            public void testManualMandatorySections() throws Exception {
097:                // Set the sectionManager to be manual mandatory
098:                ((SectionManagerImpl) sectionManager)
099:                        .setConfig(ExternalIntegrationConfig.MANUAL_MANDATORY
100:                                .toString());
101:
102:                // Create a site
103:                siteId = generateSiteId();
104:                Site site = siteService.addSite(siteId, "course");
105:
106:                // Set the provider ID to an external section EID, and save the site
107:                site.setProviderGroupId("bio101_f2006_lab1");
108:                siteService.save(site);
109:
110:                // Ensure that no internal sections were created from the single attached "roster" (aka provider ID)
111:                Assert.assertEquals(0, sectionManager.getSections(siteId)
112:                        .size());
113:
114:                // Now create a complex provider ID (multiple rosters)
115:                site.setProviderGroupId("bio101_f2006_lab1+bio101_f2006_lab2");
116:                siteService.save(site);
117:
118:                // Ensure that no internal sections were created for multiple rosters
119:                Assert.assertEquals(0, sectionManager.getSections(siteId)
120:                        .size());
121:            }
122:
123:            //// Manual Default ////
124:
125:            public void testManualDefaultConfig() throws Exception {
126:                // Set the sectionManager to be manual default
127:                ((SectionManagerImpl) sectionManager)
128:                        .setConfig(ExternalIntegrationConfig.MANUAL_DEFAULT
129:                                .toString());
130:
131:                // Create a site
132:                siteId = generateSiteId();
133:                Site site = siteService.addSite(siteId, "course");
134:                String siteReference = site.getReference();
135:
136:                // Ensure that the site is not externally managed by default
137:                Assert.assertFalse(sectionManager
138:                        .isExternallyManaged(siteReference));
139:
140:                // Ensure that the section manager will allow the site to be set to "automatic" sections
141:                try {
142:                    sectionManager.setExternallyManaged(siteReference, true);
143:                } catch (Exception e) {
144:                    fail("Unable to change a manual site to automatic, even though we should be able to do so: "
145:                            + e.getMessage());
146:                }
147:            }
148:
149:            public void testManualDefaultSections() throws Exception {
150:                // Set the sectionManager to be manual default
151:                ((SectionManagerImpl) sectionManager)
152:                        .setConfig(ExternalIntegrationConfig.MANUAL_DEFAULT
153:                                .toString());
154:
155:                // Create a site
156:                siteId = generateSiteId();
157:                Site site = siteService.addSite(siteId, "course");
158:
159:                // Set the provider ID to an external section EID, and save the site
160:                site.setProviderGroupId("bio101_f2006_lab1");
161:                siteService.save(site);
162:
163:                // Ensure that no internal sections were created from the single attached "roster" (aka provider ID)
164:                Assert.assertEquals(0, sectionManager.getSections(siteId)
165:                        .size());
166:
167:                // Now create a complex provider ID (multiple rosters)
168:                site.setProviderGroupId("bio101_f2006_lab1+bio101_f2006_lab2");
169:                siteService.save(site);
170:
171:                // Ensure that no internal sections were created for multiple rosters
172:                Assert.assertEquals(0, sectionManager.getSections(siteId)
173:                        .size());
174:
175:                // Add a section "manually"
176:                CourseSection section = sectionManager.addSection(site
177:                        .getReference(), "a manual section", "lec",
178:                        new Integer(10), null, null, null, false, false, false,
179:                        false, false, false, false);
180:
181:                // Now change this "manual by default" site to be externally controlled (automatic)
182:                sectionManager.setExternallyManaged(site.getReference(), true);
183:
184:                // Ensure that the manually created section was removed
185:                Assert.assertFalse(sectionManager.getSections(siteId).contains(
186:                        section));
187:
188:                // Get a new site object from the service, since the one we have is now out-of-date
189:                site = siteService.getSite(siteId);
190:
191:                // Ensure that the provided rosters are reflected as sections
192:                Assert.assertEquals(2, sectionManager.getSections(siteId)
193:                        .size());
194:
195:                // Change the provider IDs again.
196:                site
197:                        .setProviderGroupId("bio101_f2006_lec1+bio101_f2006_lab1+bio101_f2006_lab2");
198:                siteService.save(site);
199:
200:                // The automatic sections should have been added to the site
201:                Assert.assertEquals(3, sectionManager.getSections(siteId)
202:                        .size());
203:            }
204:
205:            //// Automatic Default ////
206:
207:            public void testAutomaticDefaultConfig() throws Exception {
208:                // Set the sectionManager to be auto default
209:                ((SectionManagerImpl) sectionManager)
210:                        .setConfig(ExternalIntegrationConfig.AUTOMATIC_DEFAULT
211:                                .toString());
212:
213:                // Create a site
214:                siteId = generateSiteId();
215:                Site site = siteService.addSite(siteId, "course");
216:                String siteReference = site.getReference();
217:
218:                // Ensure that the site is externally managed by default
219:                Assert.assertTrue(sectionManager
220:                        .isExternallyManaged(siteReference));
221:
222:                // Ensure that the section manager will allow the site to be set to "manual" sections
223:                try {
224:                    sectionManager.setExternallyManaged(siteReference, false);
225:                } catch (Exception e) {
226:                    fail("We should be able to switch to internal section management, but couldn't: "
227:                            + e.getMessage());
228:                }
229:            }
230:
231:            public void testAutomaticDefaultSections() throws Exception {
232:                // Set the sectionManager to be auto default
233:                ((SectionManagerImpl) sectionManager)
234:                        .setConfig(ExternalIntegrationConfig.AUTOMATIC_DEFAULT
235:                                .toString());
236:
237:                // Create a site
238:                siteId = generateSiteId();
239:                Site site = siteService.addSite(siteId, "course");
240:
241:                // Set the provider ID to an external section EID, and save the site
242:                site.setProviderGroupId("bio101_f2006_lab1");
243:                siteService.save(site);
244:
245:                // Ensure that a single internal section was created from the attached "roster" (aka provider ID)
246:                Assert.assertEquals(1, sectionManager.getSections(siteId)
247:                        .size());
248:
249:                // Now create a complex provider ID (multiple rosters)
250:                site.setProviderGroupId("bio101_f2006_lab1+bio101_f2006_lab2");
251:                siteService.save(site);
252:
253:                // Ensure that both internal sections were created for the rosters
254:                Assert.assertEquals(2, sectionManager.getSections(siteId)
255:                        .size());
256:
257:                // Ensure that we can not edit the sections
258:                CourseSection section = (CourseSection) sectionManager
259:                        .getSections(siteId).get(0);
260:                try {
261:                    sectionManager.updateSection(section.getUuid(),
262:                            "a new title", null, null);
263:                    fail("We should not be able to edit sections in an externally controlled site.");
264:                } catch (Exception e) {
265:                }
266:
267:                // Ensure that we can not delete the sections
268:                try {
269:                    sectionManager.disbandSection(section.getUuid());
270:                    fail("We should not be able to delete sections in an externally controlled site.");
271:                } catch (Exception e) {
272:                }
273:
274:                // Now change this "automatic by default" site to be manually controlled
275:                sectionManager.setExternallyManaged(site.getReference(), false);
276:
277:                // Get a new site object from the service, since the one we have is now out-of-date
278:                site = siteService.getSite(siteId);
279:
280:                // Ensure that the provided rosters are still reflected as sections
281:                Assert.assertEquals(2, sectionManager.getSections(siteId)
282:                        .size());
283:
284:                // Change the provider IDs again.
285:                site
286:                        .setProviderGroupId("bio101_f2006_lec1+bio101_f2006_lab1+bio101_f2006_lab2");
287:                siteService.save(site);
288:
289:                // The sections should not have changed, since we're a manual site
290:                Assert.assertEquals(2, sectionManager.getSections(siteId)
291:                        .size());
292:
293:                // Ensure that we can edit a section
294:                try {
295:                    sectionManager.updateSection(section.getUuid(),
296:                            "a new title", null, null);
297:                } catch (Exception e) {
298:                    fail("We should be able to edit sections, but couldn't: "
299:                            + e);
300:                    e.printStackTrace();
301:                }
302:
303:                // Ensure that we can delete sections
304:                try {
305:                    sectionManager.disbandSection(section.getUuid());
306:                } catch (Exception e) {
307:                    fail("We should be able to delete sections in a manually controlled site: "
308:                            + e.getMessage());
309:                }
310:            }
311:
312:            //// Automatic Mandatory ////
313:
314:            public void testAutomaticMandatoryConfig() throws Exception {
315:                // Set the sectionManager to be automatic mandatory
316:                ((SectionManagerImpl) sectionManager)
317:                        .setConfig(ExternalIntegrationConfig.AUTOMATIC_MANDATORY
318:                                .toString());
319:
320:                // Create a site
321:                siteId = generateSiteId();
322:                Site site = siteService.addSite(siteId, "course");
323:                String siteReference = site.getReference();
324:
325:                // Ensure that the site is externally managed by default
326:                Assert.assertTrue(sectionManager
327:                        .isExternallyManaged(siteReference));
328:
329:                // Ensure that the section manager won't allow the site to be set to "manual" sections
330:                try {
331:                    sectionManager.setExternallyManaged(siteReference, false);
332:                    fail();
333:                } catch (Exception e) {
334:                }
335:            }
336:
337:            public void testAutomaticMandatorySections() throws Exception {
338:                // Set the sectionManager to be automatic mandatory
339:                ((SectionManagerImpl) sectionManager)
340:                        .setConfig(ExternalIntegrationConfig.AUTOMATIC_MANDATORY
341:                                .toString());
342:
343:                // Create a site
344:                siteId = generateSiteId();
345:                Site site = siteService.addSite(siteId, "course");
346:
347:                // Set the provider ID to an external section EID, and save the site
348:                site.setProviderGroupId("bio101_f2006_lab1");
349:                siteService.save(site);
350:
351:                // Ensure that a single internal section was created from the attached "roster" (aka provider ID)
352:                Assert.assertEquals(1, sectionManager.getSections(siteId)
353:                        .size());
354:
355:                // Now create a complex provider ID (multiple rosters)
356:                site.setProviderGroupId("bio101_f2006_lab1+bio101_f2006_lab2");
357:                siteService.save(site);
358:
359:                // Ensure that both internal sections were created
360:                Assert.assertEquals(2, sectionManager.getSections(siteId)
361:                        .size());
362:
363:                // Ensure that sections in this site can not be edited
364:                CourseSection section = (CourseSection) sectionManager
365:                        .getSections(siteId).get(0);
366:                try {
367:                    sectionManager.updateSection(section.getUuid(),
368:                            "a new title", null, null);
369:                    fail();
370:                } catch (Exception e) {
371:                }
372:
373:                // Ensure that students can not be added
374:                try {
375:                    sectionManager.addSectionMembership("admin", Role.STUDENT,
376:                            section.getUuid());
377:                    fail("We should not be allowed to add students to an externally managed section");
378:                } catch (Exception e) {
379:                }
380:
381:                // Ensure that TAs can be added
382:                try {
383:                    sectionManager.addSectionMembership("admin", Role.TA,
384:                            section.getUuid());
385:                } catch (Exception e) {
386:                    fail("Exception adding a TA to an externally managed section: "
387:                            + e.getMessage());
388:                }
389:
390:                // Remove the provider ID (roster) from the site.
391:                site.setProviderGroupId(null);
392:                siteService.save(site);
393:
394:                // Ensure that the sections were removed
395:                Assert.assertEquals(0, sectionManager.getSections(siteId)
396:                        .size());
397:            }
398:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.