1 4 package net.sf.mybatchfwk.test; 5 6 import junit.framework.TestCase; 7 import net.sf.mybatchfwk.BatchConfiguration; 8 import net.sf.mybatchfwk.BatchException; 9 import net.sf.mybatchfwk.BatchService; 10 import net.sf.mybatchfwk.history.MemoryExecutionHistory; 11 12 public class TestHistoryStorage extends TestCase { 13 14 public void testMemoryStorage() { 15 16 Exception error = null; 17 18 BatchConfiguration config = new BatchConfiguration(); 19 config.setThreadPoolMinSize(1); 20 config.setThreadPoolMaxSize(2); 21 config.setBlockingQueueCapacity(2); 22 config.setExecutionHistoryClass(MemoryExecutionHistory.class); 23 24 BatchService service = new BatchService(); 25 service.setBatch(new SimpleBatch()); 26 try { 27 service.init(config); 28 service.launch(); 29 } catch (Exception e) { 30 service.manageFatalError(e); 31 error = e; 32 } 33 34 assertNull(error); 35 assertEquals(service.getState(), BatchService.STATE.SHUTDOWN); 36 assertEquals(service.getExecutionReport().getNumberOfCompletedTasks(), 5); 37 try { 38 assertNotNull(service.getExecutionReport().completedTasksIdIterator()); 39 assertNotNull(service.getExecutionReport().failedTasksIdIterator()); 40 } catch (BatchException e) { 41 fail(); 42 } 43 } 44 } 45 | Popular Tags |