01: /*
02: * Copyright 2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.kuali.module.labor.util;
17:
18: import org.kuali.kfs.batch.BatchSpringContext;
19: import org.kuali.kfs.batch.JobDescriptor;
20: import org.kuali.kfs.batch.Step;
21: import org.kuali.kfs.context.KualiTestBase;
22: import org.kuali.test.ConfigureContext;
23: import org.kuali.test.fixtures.UserNameFixture;
24:
25: @ConfigureContext(session=UserNameFixture.KULUSER)
26: public class LaborBatchRunner extends KualiTestBase {
27: private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger
28: .getLogger(LaborBatchRunner.class);
29:
30: public void testRunBatch() {
31: JobDescriptor laborBatchJob = BatchSpringContext
32: .getJobDescriptor("laborBatchJob");
33: for (Step step : laborBatchJob.getSteps()) {
34: runStep(step);
35: }
36: }
37:
38: private void runStep(Step step) {
39: try {
40: String stepName = step.getName();
41:
42: long start = System.currentTimeMillis();
43: System.out.println(stepName + " started at " + start);
44:
45: boolean isSuccess = step.execute(getClass().getName());
46:
47: long elapsedTime = System.currentTimeMillis() - start;
48: System.out.println("Execution Time = " + elapsedTime + "("
49: + isSuccess + ")");
50: } catch (Exception e) {
51: System.out.println(e);
52: }
53: }
54: }
|