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


001:        /**********************************************************************************
002:         *
003:         * $Id: TestServiceAgainstLoadedData.java 20345 2007-01-16 20:25:32Z ray@media.berkeley.edu $
004:         *
005:         ***********************************************************************************
006:         *
007:         * Copyright (c) 2006 The Regents of the University of California
008:         *
009:         * Licensed under the Educational Community License, Version 1.0 (the "License");
010:         * you may not use this file except in compliance with the License.
011:         * You may obtain a copy of the License at
012:         *
013:         *      http://www.opensource.org/licenses/ecl1.php
014:         *
015:         * Unless required by applicable law or agreed to in writing, software
016:         * distributed under the License is distributed on an "AS IS" BASIS,
017:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018:         * See the License for the specific language governing permissions and
019:         * limitations under the License.
020:         *
021:         **********************************************************************************/package org.sakaiproject.tool.gradebook.test;
022:
023:        import java.util.*;
024:
025:        import org.apache.commons.logging.Log;
026:        import org.apache.commons.logging.LogFactory;
027:
028:        import org.sakaiproject.section.api.coursemanagement.EnrollmentRecord;
029:        import org.sakaiproject.section.api.facade.Role;
030:        import org.sakaiproject.tool.gradebook.Assignment;
031:        import org.sakaiproject.tool.gradebook.Gradebook;
032:
033:        /**
034:         * This odd-looking JUnit class provides a very primitive test for data
035:         * contention when using the external service API. You'll see what look like
036:         * the same "tests" several times in a row. The idea is to run the test from
037:         * multiple windows simultaneously and try for locking exceptions.
038:         *
039:         * Pretty cheap stuff, but it took less time to get going than trying to
040:         * coordinate one of the JUnit multi-threading add-on projects with
041:         * Spring and Hivernate....
042:         *
043:         * Sample usage:
044:         *
045:         *   # Build standalone and load up the test database.
046:         *   cd ../sections/
047:         *   maven -Dmode=standalone -Dhibernate.properties.dir=C:/java/sakaisettings/mysql-standalone cln bld
048:         *   cd ../gradebook
049:         *   maven -Dhibernate.properties.dir=C:/java/sakaisettings/mysql-standalone cln bld
050:         *   maven -Dhibernate.properties.dir=C:/java/sakaisettings/mysql-standalone load-full-standalone
051:         *
052:         *   # Then do this from as many windows as you feel up to.
053:         *   cd app/standalone-app/
054:         *   maven -Dhibernate.properties.dir=C:/java/sakaisettings/mysql-standalone test-against-loaded-data
055:         */
056:        public class TestServiceAgainstLoadedData extends GradebookLoaderBase {
057:            private static final Log log = LogFactory
058:                    .getLog(TestServiceAgainstLoadedData.class);
059:
060:            public TestServiceAgainstLoadedData() {
061:                // Don't roll these tests back, since they are intended to act like real-world users.
062:                setDefaultRollback(false);
063:            }
064:
065:            private Assignment getAssignment(Gradebook gradebook,
066:                    String assignmentName) {
067:                List assignments = gradebookManager.getAssignments(gradebook
068:                        .getId());
069:                for (Iterator iter = assignments.iterator(); iter.hasNext();) {
070:                    Assignment asn = (Assignment) iter.next();
071:                    if (asn.getName().equals(assignmentName)) {
072:                        return asn;
073:                    }
074:                }
075:                return null;
076:            }
077:
078:            public void testUpdateExternalScores() throws Exception {
079:                Gradebook gradebook = gradebookManager
080:                        .getGradebook(TestGradebookLoader.GRADEBOOK_WITH_GRADES);
081:                List enrollments = sectionAwareness.getSiteMembersInRole(
082:                        gradebook.getUid(), Role.STUDENT);
083:
084:                Assignment asn = getAssignment(gradebook,
085:                        TestGradebookLoader.EXTERNAL_ASN_NAME1);
086:
087:                Map studentUidsToScores = new HashMap();
088:                int scoreGoRound = -1;
089:                for (Iterator iter = enrollments.iterator(); iter.hasNext();) {
090:                    EnrollmentRecord enr = (EnrollmentRecord) iter.next();
091:                    Double score = (scoreGoRound == -1) ? null : new Double(
092:                            scoreGoRound);
093:                    scoreGoRound = (scoreGoRound < 11) ? (scoreGoRound + 1)
094:                            : -1;
095:                    studentUidsToScores.put(enr.getUser().getUserUid(), score);
096:                }
097:                log.warn("about to updateExternalAssessmentScores with "
098:                        + enrollments.size() + " scores for "
099:                        + asn.getExternalId());
100:                gradebookExternalAssessmentService
101:                        .updateExternalAssessmentScores(gradebook.getUid(), asn
102:                                .getExternalId(), studentUidsToScores);
103:            }
104:
105:            public void testUpdateExternalScore() throws Exception {
106:                Gradebook gradebook = gradebookManager
107:                        .getGradebook(TestGradebookLoader.GRADEBOOK_WITH_GRADES);
108:                List enrollments = sectionAwareness.getSiteMembersInRole(
109:                        gradebook.getUid(), Role.STUDENT);
110:
111:                Assignment asn = getAssignment(gradebook,
112:                        TestGradebookLoader.EXTERNAL_ASN_NAME2);
113:
114:                int scoreGoRound = 2;
115:                for (Iterator iter = enrollments.iterator(); iter.hasNext();) {
116:                    EnrollmentRecord enr = (EnrollmentRecord) iter.next();
117:                    Double score = (scoreGoRound == -1) ? null : new Double(
118:                            scoreGoRound);
119:                    scoreGoRound = (scoreGoRound < 11) ? (scoreGoRound + 1)
120:                            : -1;
121:                    gradebookExternalAssessmentService
122:                            .updateExternalAssessmentScore(gradebook.getUid(),
123:                                    asn.getExternalId(), enr.getUser()
124:                                            .getUserUid(), score);
125:                }
126:            }
127:
128:            public void testUpdateExternalScores2() throws Exception {
129:                Gradebook gradebook = gradebookManager
130:                        .getGradebook(TestGradebookLoader.GRADEBOOK_WITH_GRADES);
131:                List enrollments = sectionAwareness.getSiteMembersInRole(
132:                        gradebook.getUid(), Role.STUDENT);
133:
134:                Assignment asn = getAssignment(gradebook,
135:                        TestGradebookLoader.EXTERNAL_ASN_NAME2);
136:
137:                Map studentUidsToScores = new HashMap();
138:                int scoreGoRound = -1;
139:                for (Iterator iter = enrollments.iterator(); iter.hasNext();) {
140:                    EnrollmentRecord enr = (EnrollmentRecord) iter.next();
141:                    Double score = (scoreGoRound == -1) ? null : new Double(
142:                            scoreGoRound);
143:                    scoreGoRound = (scoreGoRound < 11) ? (scoreGoRound + 1)
144:                            : -1;
145:                    studentUidsToScores.put(enr.getUser().getUserUid(), score);
146:                }
147:                log.warn("about to updateExternalAssessmentScores with "
148:                        + enrollments.size() + " scores for "
149:                        + asn.getExternalId());
150:                gradebookExternalAssessmentService
151:                        .updateExternalAssessmentScores(gradebook.getUid(), asn
152:                                .getExternalId(), studentUidsToScores);
153:            }
154:
155:            public void testUpdateExternalScore2() throws Exception {
156:                Gradebook gradebook = gradebookManager
157:                        .getGradebook(TestGradebookLoader.GRADEBOOK_WITH_GRADES);
158:                List enrollments = sectionAwareness.getSiteMembersInRole(
159:                        gradebook.getUid(), Role.STUDENT);
160:
161:                Assignment asn = getAssignment(gradebook,
162:                        TestGradebookLoader.EXTERNAL_ASN_NAME1);
163:
164:                int scoreGoRound = 2;
165:                for (Iterator iter = enrollments.iterator(); iter.hasNext();) {
166:                    EnrollmentRecord enr = (EnrollmentRecord) iter.next();
167:                    Double score = (scoreGoRound == -1) ? null : new Double(
168:                            scoreGoRound);
169:                    scoreGoRound = (scoreGoRound < 11) ? (scoreGoRound + 1)
170:                            : -1;
171:                    gradebookExternalAssessmentService
172:                            .updateExternalAssessmentScore(gradebook.getUid(),
173:                                    asn.getExternalId(), enr.getUser()
174:                                            .getUserUid(), score);
175:                }
176:            }
177:
178:            public void testUpdateExternalScores2Same() throws Exception {
179:                Gradebook gradebook = gradebookManager
180:                        .getGradebook(TestGradebookLoader.GRADEBOOK_WITH_GRADES);
181:                List enrollments = sectionAwareness.getSiteMembersInRole(
182:                        gradebook.getUid(), Role.STUDENT);
183:
184:                Assignment asn = getAssignment(gradebook,
185:                        TestGradebookLoader.EXTERNAL_ASN_NAME2);
186:
187:                Map studentUidsToScores = new HashMap();
188:                int scoreGoRound = -1;
189:                for (Iterator iter = enrollments.iterator(); iter.hasNext();) {
190:                    EnrollmentRecord enr = (EnrollmentRecord) iter.next();
191:                    Double score = (scoreGoRound == -1) ? null : new Double(
192:                            scoreGoRound);
193:                    scoreGoRound = (scoreGoRound < 11) ? (scoreGoRound + 1)
194:                            : -1;
195:                    studentUidsToScores.put(enr.getUser().getUserUid(), score);
196:                }
197:                log.warn("about to updateExternalAssessmentScores with "
198:                        + enrollments.size() + " scores for "
199:                        + asn.getExternalId());
200:                gradebookExternalAssessmentService
201:                        .updateExternalAssessmentScores(gradebook.getUid(), asn
202:                                .getExternalId(), studentUidsToScores);
203:            }
204:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.