| 1 4 package net.sf.mybatchfwk.test; 5 6 import junit.framework.TestCase; 7 import net.sf.mybatchfwk.BatchConfiguration; 8 import net.sf.mybatchfwk.BatchService; 9 10 public class TestBatch extends TestCase { 11 12 public void testOneShotBatch() { 13 14 Exception error = null; 15 16 BatchConfiguration config = new BatchConfiguration(); 17 config.setThreadPoolMinSize(1); 18 config.setThreadPoolMaxSize(2); 19 20 BatchService service = new BatchService(); 21 service.setBatch(new SimpleBatch()); 22 try { 23 service.init(config); 24 service.launch(); 25 } catch (Exception e) { 26 service.manageFatalError(e); 27 error = e; 28 } 29 30 assertNull(error); 31 assertEquals(service.getState(), BatchService.STATE.SHUTDOWN); 32 assertEquals(service.getExecutionReport().getNumberOfCompletedTasks(), 5); 33 } 34 35 public void testQueueCapacity() { 36 37 Exception error = null; 38 39 BatchConfiguration config = new BatchConfiguration(); 40 config.setThreadPoolMinSize(1); 41 config.setThreadPoolMaxSize(2); 42 config.setBlockingQueueCapacity(2); 43 44 BatchService service = new BatchService(); 45 service.setBatch(new SimpleBatch()); 46 try { 47 service.init(config); 48 service.launch(); 49 } catch (Exception e) { 50 service.manageFatalError(e); 51 error = e; 52 } 53 54 assertNull(error); 55 assertEquals(service.getState(), BatchService.STATE.SHUTDOWN); 56 assertEquals(service.getExecutionReport().getNumberOfCompletedTasks(), 5); 57 } 58 } 59 | Popular Tags |