BatchUtil { public static void commitTransactions(Map<?, ?> tranMap, Map<String, TransactionStatus> statMap) { commitTransactions(tranMap, statMap, null); } protected  BatchUtil(); static String cat(Object... args); static String getInfoLogStartMsg(String jobCd); static String getInfoLogEndMsg(String jobCd); static TransactionDefinition getTransactionDefinition(); static TransactionDefinition getTransactionDefinition(
            int propagationBehavior, int isolationLevel, int timeout,
            boolean readOnly); static TransactionStatus startTransaction(
            PlatformTransactionManager tran); static TransactionStatus startTransaction(
            PlatformTransactionManager tran, Log log); static TransactionStatus startTransaction(
            PlatformTransactionManager tran, int propagationBehavior,
            int isolationLevel, int timeout, boolean readOnly); static TransactionStatus startTransaction(
            PlatformTransactionManager tran, int propagationBehavior,
            int isolationLevel, int timeout, boolean readOnly, Log log); static TransactionStatus startTransaction(
            PlatformTransactionManager tran, TransactionDefinition def); static TransactionStatus startTransaction(
            PlatformTransactionManager tran, TransactionDefinition def, Log log); static Map<String, TransactionStatus> startTransactions(
            TransactionDefinition tranDef, Map<?, ?> tranMap); static Map<String, TransactionStatus> startTransactions(
            TransactionDefinition tranDef, Map<?, ?> tranMap, Log log); static void commitTransaction(PlatformTransactionManager tran,
            TransactionStatus stat); static void commitTransaction(PlatformTransactionManager tran,
            TransactionStatus stat, Log log); static void commitTransactions(Map<?, ?> tranMap,
            Map<String, TransactionStatus> statMap); static void commitTransactions(Map<?, ?> tranMap,
            Map<String, TransactionStatus> statMap, Log log); static void endTransaction(PlatformTransactionManager tran,
            TransactionStatus stat); static void endTransaction(PlatformTransactionManager tran,
            TransactionStatus stat, Log log); static boolean endTransactions(Map<?, ?> tranMap,
            Map<String, TransactionStatus> statMap); static boolean endTransactions(Map<?, ?> tranMap,
            Map<String, TransactionStatus> statMap, Log log); static Object setSavepoint(TransactionStatus stat); static Object setSavepoint(TransactionStatus stat, Log log); static void releaseSavepoint(TransactionStatus stat, Object savepoint); static void releaseSavepoint(TransactionStatus stat,
            Object savepoint, Log log); static void rollbackSavepoint(TransactionStatus stat,
            Object savepoint); static void rollbackSavepoint(TransactionStatus stat,
            Object savepoint, Log log); static void rollbackTransaction(PlatformTransactionManager tran,
            TransactionStatus stat); static void rollbackTransaction(PlatformTransactionManager tran,
            TransactionStatus stat, Log log); static TransactionStatus commitRestartTransaction(
            PlatformTransactionManager tran, TransactionStatus stat); static TransactionStatus commitRestartTransaction(
            PlatformTransactionManager tran, TransactionStatus stat, Log log); static TransactionStatus commitRestartTransaction(
            PlatformTransactionManager tran, TransactionStatus stat,
            TransactionDefinition def); static TransactionStatus commitRestartTransaction(
            PlatformTransactionManager tran, TransactionStatus stat,
            TransactionDefinition def, Log log); static TransactionStatus rollbackRestartTransaction(
            PlatformTransactionManager tran, TransactionStatus stat); static TransactionStatus rollbackRestartTransaction(
            PlatformTransactionManager tran, TransactionStatus stat, Log log); static TransactionStatus rollbackRestartTransaction(
            PlatformTransactionManager tran, TransactionStatus stat,
            TransactionDefinition def); static TransactionStatus rollbackRestartTransaction(
            PlatformTransactionManager tran, TransactionStatus stat,
            TransactionDefinition def, Log log); @SuppressWarnings({"rawtypes", "unchecked"}) static E[] changeListToArray(List<E> list, Class clazz); static List<String> getProperties(String propertyName, String grpKey); static String getMemoryInfo();  }
@Test public void testCommitTransactions01() throws Exception { Map<String, PlatformTransactionManager> tranMap = new HashMap<String, PlatformTransactionManager>(); PlatformTransactionManager tran = new PlatformTransactionManagerStub(); tranMap.put("tran", tran); Map<String, TransactionStatus> statMap = new HashMap<String, TransactionStatus>(); try { BatchUtil.commitTransactions(tranMap, statMap); } catch (Exception e) { e.printStackTrace(); fail(); return; } }
@Test public void testCommitTransactions02() throws Exception { Map<String, PlatformTransactionManager> tranMap = new HashMap<String, PlatformTransactionManager>(); PlatformTransactionManager tran = new PlatformTransactionManagerStub(); tranMap.put("tran", tran); Map<String, TransactionStatus> statMap = new HashMap<String, TransactionStatus>(); statMap.put("tran", new TransactionStatusStub()); try { BatchUtil.commitTransactions(tranMap, statMap, log); } catch (Exception e) { e.printStackTrace(); fail(); return; } }
@Test public void testCommitTransaction03() throws Exception { Map<String, PlatformTransactionManager> tranMap = new HashMap<String, PlatformTransactionManager>(); PlatformTransactionManagerStub4 tran = new PlatformTransactionManagerStub4(); tranMap.put("tran1", tran); tranMap.put("tran2", tran); tranMap.put("tran3", tran); tranMap.put("tran4", tran); Map<String, TransactionStatus> statMap = new LinkedHashMap<String, TransactionStatus>(); TransactionStatusStub status1 = new TransactionStatusStub(); status1.setName("stat1"); TransactionStatusStub status2 = new TransactionStatusStub(); status2.setName("stat2"); TransactionStatusStub status3 = new TransactionStatusStub(); status3.setName("stat3"); TransactionStatusStub status4 = new TransactionStatusStub(); status4.setName("stat4"); statMap.put("tran1", status1); statMap.put("tran2", status2); statMap.put("tran3", status3); statMap.put("tran4", status4); BatchUtil.commitTransactions(tranMap, statMap, log); List<TransactionStatus> statusList = tran.getStatusList(); assertEquals("stat4", ((TransactionStatusStub) statusList.get(0)) .getName()); assertEquals("stat3", ((TransactionStatusStub) statusList.get(1)) .getName()); assertEquals("stat2", ((TransactionStatusStub) statusList.get(2)) .getName()); assertEquals("stat1", ((TransactionStatusStub) statusList.get(3)) .getName()); }