Source Code Cross Referenced for SchedulerServiceImplTest.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » core » service » 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 » Kuali Financial System » org.kuali.core.service.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2007 The Kuali Foundation.
003:         * 
004:         * Licensed under the Educational Community License, Version 1.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         * 
008:         * http://www.opensource.org/licenses/ecl1.php
009:         * 
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:        package org.kuali.core.service.impl;
017:
018:        import java.util.List;
019:
020:        import org.kuali.kfs.batch.BatchJobStatus;
021:        import org.kuali.kfs.context.KualiTestBase;
022:        import org.kuali.kfs.context.SpringContext;
023:        import org.kuali.kfs.service.SchedulerService;
024:        import org.kuali.test.ConfigureContext;
025:        import org.kuali.test.fixtures.UserNameFixture;
026:
027:        @ConfigureContext(session=UserNameFixture.KULUSER,initializeBatchSchedule=true)
028:        public class SchedulerServiceImplTest extends KualiTestBase {
029:
030:            // tests added to make sure that the scheduler was available during the tests
031:            public void testGetJobs_unscheduled() {
032:                SchedulerService s = SpringContext
033:                        .getBean(SchedulerService.class);
034:                List<BatchJobStatus> jobs = s.getJobs("unscheduled");
035:                for (BatchJobStatus job : jobs) {
036:                    System.out.println(job);
037:                }
038:            }
039:
040:            public void testGetJobs_scheduled() {
041:                SchedulerService s = SpringContext
042:                        .getBean(SchedulerService.class);
043:                List<BatchJobStatus> jobs = s.getJobs("scheduled");
044:                for (BatchJobStatus job : jobs) {
045:                    System.out.println(job);
046:                }
047:            }
048:
049:            /*
050:             * // this job seems to be missing from the system during the test runs public void testScheduledJobTrigger() throws Exception {
051:             * SchedulerService s = SpringContext.getBean(SchedulerService.class); BatchJobStatus job = s.getJob( "scheduled", "scheduleJob" );
052:             * assertNotNull( "job must not be null", job ); System.out.println( "scheduleJob Next Run Time: " + job.getNextRunDate() );
053:             * Calendar cal = Calendar.getInstance(); cal.setTime( job.getNextRunDate() ); assertEquals( "year must be 2099", 2099, cal.get(
054:             * Calendar.YEAR ) ); }
055:             */
056:
057:            /**
058:             * Test the running of a job. There is not much to test on the results, except that this does not cause an error.
059:             */
060:
061:            public void testRunJob() throws Exception {
062:                SchedulerService s = SpringContext
063:                        .getBean(SchedulerService.class);
064:                BatchJobStatus job = s.getJob(
065:                        SchedulerService.UNSCHEDULED_GROUP, "scrubberJob");
066:                assertNotNull("job must not be null", job);
067:                System.out.println(job);
068:                job.runJob(null);
069:                System.out.println(s.getRunningJobs());
070:                System.out.println(s.getJob(SchedulerService.UNSCHEDULED_GROUP,
071:                        "scrubberJob"));
072:                Thread.sleep(1000);
073:                System.out.println(s.getRunningJobs());
074:                System.out.println(s.getJob(SchedulerService.UNSCHEDULED_GROUP,
075:                        "scrubberJob"));
076:                Thread.sleep(1000);
077:                System.out.println(s.getRunningJobs());
078:                System.out.println(s.getJob(SchedulerService.UNSCHEDULED_GROUP,
079:                        "scrubberJob"));
080:                Thread.sleep(1000);
081:                System.out.println(s.getRunningJobs());
082:                System.out.println(s.getJob(SchedulerService.UNSCHEDULED_GROUP,
083:                        "scrubberJob"));
084:                Thread.sleep(1000);
085:                System.out.println(s.getRunningJobs());
086:                System.out.println(s.getJob(SchedulerService.UNSCHEDULED_GROUP,
087:                        "scrubberJob"));
088:                Thread.sleep(1000);
089:                System.out.println(s.getRunningJobs());
090:                System.out.println(s.getJob(SchedulerService.UNSCHEDULED_GROUP,
091:                        "scrubberJob"));
092:            }
093:
094:            /**
095:             * Test that the unschedule job function works and removes the job from the standard scheduled group. Assumes: scrubberJob
096:             * exists as a job in the scheduled group.
097:             */
098:
099:            public void testUnscheduleJob() throws Exception {
100:                SchedulerService s = SpringContext
101:                        .getBean(SchedulerService.class);
102:                BatchJobStatus job = s.getJob(SchedulerService.SCHEDULED_GROUP,
103:                        "scrubberJob");
104:                assertNotNull("job must not be null", job);
105:
106:                assertTrue("must return isScheduled == true", job.isScheduled());
107:
108:                s.removeScheduled(job.getName());
109:                job = s.getJob(SchedulerService.SCHEDULED_GROUP, "scrubberJob");
110:                assertNull("new attempt to retrieve job must be null", job);
111:
112:                job = s.getJob(SchedulerService.UNSCHEDULED_GROUP,
113:                        "scrubberJob");
114:                assertNotNull("job must not be null", job);
115:                assertFalse("must return isScheduled == false", job
116:                        .isScheduled());
117:            }
118:
119:            /**
120:             * Test that the schedule job function works and puts the job into the standard scheduled group. Also tests to make sure that
121:             * BatchJobStatus detects the scheduled status even if it is in the unscheduled group. Assumes: clearOldOriginEntriesJob exists
122:             * as a job in the unscheduled group.
123:             */
124:
125:            public void testScheduleJob() throws Exception {
126:                SchedulerService s = SpringContext
127:                        .getBean(SchedulerService.class);
128:                BatchJobStatus job = s.getJob(
129:                        SchedulerService.UNSCHEDULED_GROUP,
130:                        "clearOldOriginEntriesJob");
131:                assertNotNull("job must not be null", job);
132:
133:                assertFalse("must return isScheduled == false", job
134:                        .isScheduled());
135:
136:                job.schedule();
137:
138:                job = s.getJob(SchedulerService.UNSCHEDULED_GROUP,
139:                        "clearOldOriginEntriesJob");
140:                assertNotNull("job (in unsched group) must not be null", job);
141:                assertTrue("must return isScheduled == true", job.isScheduled());
142:
143:                job = s.getJob(SchedulerService.SCHEDULED_GROUP,
144:                        "clearOldOriginEntriesJob");
145:                assertNotNull("job (in sched group) must not be null", job);
146:                assertTrue("must return isScheduled == true", job.isScheduled());
147:
148:            }
149:
150:            /*
151:             * This test has problems with timing. It needs a job that it can rely on running for a specified period of time before being
152:             * included in the automated tests.
153:             */
154:            /*
155:             * public void testJobInterrupt() throws Exception{ SchedulerService s = SpringContext.getBean(SchedulerService.class);
156:             * BatchJobStatus job = s.getJob(SchedulerService.UNSCHEDULED_GROUP, "scrubberJob" ); job.runJob( null ); // wait for job to
157:             * enter running status int waitCount = 0; // provide an "out" in case things fail badly while ( !job.isRunning() && waitCount <
158:             * 500 ) { Thread.sleep( 50 ); waitCount++; } // stop the job job.interrupt(); waitCount = 0; while ( job.isRunning() &&
159:             * waitCount < 500 ) { Thread.sleep( 50 ); waitCount++; } Thread.sleep( 2000 ); job =
160:             * s.getJob(SchedulerService.UNSCHEDULED_GROUP, "scrubberJob" ); List<BatchJobStatus> jobs = s.getJobs(); for ( BatchJobStatus
161:             * b : jobs ) { System.out.println( b ); } assertEquals( "job status not correct", SchedulerService.CANCELLED_JOB_STATUS_CODE,
162:             * job.getStatus() ); }
163:             */
164:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.