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


001:        /**********************************************************************************
002:         * $URL: https://source.sakaiproject.org/svn/sections/tags/sakai_2-4-1/sections-app/src/test/org/sakaiproject/test/section/dataload/DataLoadTest.java $
003:         * $Id: DataLoadTest.java 18134 2006-11-14 18:59:25Z 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.dataload;
021:
022:        import java.sql.Time;
023:        import java.util.ArrayList;
024:        import java.util.Date;
025:        import java.util.Iterator;
026:        import java.util.List;
027:
028:        import org.apache.commons.logging.Log;
029:        import org.apache.commons.logging.LogFactory;
030:        import org.sakaiproject.section.api.CourseManager;
031:        import org.sakaiproject.section.api.SectionManager;
032:        import org.sakaiproject.section.api.coursemanagement.Course;
033:        import org.sakaiproject.section.api.coursemanagement.CourseSection;
034:        import org.sakaiproject.section.api.coursemanagement.User;
035:        import org.sakaiproject.section.api.exception.RoleConfigurationException;
036:        import org.sakaiproject.section.api.facade.Role;
037:        import org.sakaiproject.component.section.support.UserManager;
038:        import org.sakaiproject.test.section.SectionsTestBase;
039:
040:        public class DataLoadTest extends SectionsTestBase {
041:            private static Log log = LogFactory.getLog(DataLoadTest.class);
042:
043:            public DataLoadTest() {
044:                // Don't roll these tests back, since they are intended to load data
045:                setDefaultRollback(false);
046:            }
047:
048:            protected CourseManager courseManager;
049:            protected SectionManager sectionManager;
050:            protected UserManager userManager;
051:
052:            protected void onSetUpInTransaction() throws Exception {
053:                courseManager = (CourseManager) applicationContext
054:                        .getBean("org.sakaiproject.section.api.CourseManager");
055:                sectionManager = (SectionManager) applicationContext
056:                        .getBean("org.sakaiproject.section.api.SectionManager");
057:                userManager = (UserManager) applicationContext
058:                        .getBean("org.sakaiproject.component.section.support.UserManager");
059:            }
060:
061:            public void testLoadData() {
062:                // Load courses
063:                Course course1 = courseManager.createCourse("site1",
064:                        "A Course for Site #1", false, false, true);
065:                Course course2 = courseManager.createCourse("site2",
066:                        "A Course for Site #2", false, false, false);
067:                Course course3 = courseManager.createCourse("site3",
068:                        "A Course for Site #3", false, false, false);
069:
070:                // Load sections
071:                CourseSection lab1 = sectionManager.addSection(course1
072:                        .getUuid(), "Lab 1", "section.category.lab",
073:                        new Integer(20), "Dank basement lab", new Time(
074:                                new Date().getTime()), new Time(new Date()
075:                                .getTime()), true, false, true, false, false,
076:                        false, false);
077:                CourseSection lab2 = sectionManager.addSection(course1
078:                        .getUuid(), "Lab 2", "section.category.lab",
079:                        new Integer(20), "Dank basement lab", new Time(
080:                                new Date().getTime()), new Time(new Date()
081:                                .getTime()), false, true, false, true, false,
082:                        false, false);
083:                CourseSection disc1 = sectionManager.addSection(course1
084:                        .getUuid(), "Disc 1", "section.category.discussion",
085:                        new Integer(30), "Sunny classroom", new Time(new Date()
086:                                .getTime()), new Time(new Date().getTime()),
087:                        true, false, true, false, true, false, false);
088:
089:                // Load students
090:                User studenta = userManager.createUser("studenta",
091:                        "Joe Student", "Student, Joe", "jstudent");
092:                User studentb = userManager.createUser("studentb",
093:                        "Jane Undergrad", "Undergrad, Jane", "jundergrad");
094:                User studentc = userManager.createUser("studentc", "Max Guest",
095:                        "Guest, Max", "mguest");
096:
097:                List studentList = new ArrayList();
098:                for (int i = 0; i < 100; i++) {
099:                    studentList.add(userManager.createUser("student" + i,
100:                            "Test Student " + i, "Student, Test " + i,
101:                            "tstudent" + i));
102:                }
103:
104:                // Load TAs
105:                User ta1 = userManager.createUser("ta1", "Mike Grad",
106:                        "Grad, Mike", "mgrad");
107:                User ta2 = userManager.createUser("ta2",
108:                        "Sara Hyphenated-Elongated-Postdoc",
109:                        "Hyphenated-Elongated-Postdoc, Sara",
110:                        "shyphenatedelongatedpostdoc");
111:
112:                // Load instructors
113:                User instructor1 = userManager.createUser("instructor1",
114:                        "Bill Economist", "Economist, Bill", "beconomist");
115:                User instructor2 = userManager.createUser("instructor2",
116:                        "Amber Philosopher", "Philosopher, Amber",
117:                        "aphilosopher");
118:
119:                // Load other people
120:                userManager.createUser("other1", "Other Person",
121:                        "Person, Other", "operson");
122:
123:                // Load enrollments into the courses
124:                courseManager.addEnrollment(studenta, course1);
125:                courseManager.addEnrollment(studenta, course2);
126:                courseManager.addEnrollment(studenta, course3);
127:
128:                courseManager.addEnrollment(studentb, course1);
129:                courseManager.addEnrollment(studentb, course2);
130:                courseManager.addEnrollment(studentb, course3);
131:
132:                courseManager.addEnrollment(studentc, course1);
133:                courseManager.addEnrollment(studentc, course2);
134:                courseManager.addEnrollment(studentc, course3);
135:
136:                for (Iterator iter = studentList.iterator(); iter.hasNext();) {
137:                    User user = (User) iter.next();
138:                    courseManager.addEnrollment(user, course1);
139:                    courseManager.addEnrollment(user, course2);
140:                    courseManager.addEnrollment(user, course3);
141:                }
142:
143:                // Load enrollments into sections
144:                try {
145:                    sectionManager.addSectionMembership("studenta",
146:                            Role.STUDENT, lab1.getUuid());
147:                    sectionManager.addSectionMembership("studentb",
148:                            Role.STUDENT, lab2.getUuid());
149:                    sectionManager.addSectionMembership("studentc",
150:                            Role.STUDENT, disc1.getUuid());
151:                } catch (RoleConfigurationException rce) {
152:                    log.error(rce);
153:                    fail();
154:                }
155:
156:                // Load TAs into the course
157:                courseManager.addTA(ta1, course1);
158:                courseManager.addTA(ta1, course2);
159:                courseManager.addTA(ta1, course3);
160:
161:                courseManager.addTA(ta2, course1);
162:                courseManager.addTA(ta2, course2);
163:                courseManager.addTA(ta2, course3);
164:
165:                // Load TAs into the sections
166:                try {
167:                    sectionManager.addSectionMembership("ta1", Role.TA, lab1
168:                            .getUuid());
169:                    sectionManager.addSectionMembership("ta1", Role.TA, disc1
170:                            .getUuid());
171:                    sectionManager.addSectionMembership("ta2", Role.TA, lab2
172:                            .getUuid());
173:                    sectionManager.addSectionMembership("ta2", Role.TA, disc1
174:                            .getUuid());
175:                } catch (RoleConfigurationException rce) {
176:                    log.error(rce);
177:                    fail();
178:                }
179:
180:                // Load instructors into the courses
181:                courseManager.addInstructor(instructor1, course1);
182:                courseManager.addInstructor(instructor2, course2);
183:                courseManager.addInstructor(instructor2, course3);
184:            }
185:
186:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.