1 4 package net.sf.mybatchfwk.test; 5 6 import net.sf.mybatchfwk.BatchConfiguration; 7 import net.sf.mybatchfwk.BatchService; 8 import junit.framework.TestCase; 9 10 public class TestManagedBatch extends TestCase { 11 12 public void testManagedBatch() { 13 14 Exception error = null; 15 16 BatchConfiguration config = new BatchConfiguration(); 17 config.setThreadPoolMinSize(1); 18 config.setThreadPoolMaxSize(2); 19 config.setBlockingQueueCapacity(2); 20 config.setJmxEnable(true); 21 config.setJmxEnableNotifications(true); 22 23 BatchService service = new BatchService(); 24 service.setBatch(new SimpleBatch()); 25 try { 26 service.init(config); 27 service.launch(); 28 } catch (Exception e) { 29 service.manageFatalError(e); 30 error = e; 31 } 32 33 assertNull(error); 34 assertEquals(service.getState(), BatchService.STATE.SHUTDOWN); 35 assertEquals(service.getExecutionReport().getNumberOfCompletedTasks(), 5); 36 } 37 } 38 | Popular Tags |