public void testPublish() throws IOException, SQLException { publisher.publish(workUnitStates); InOrder inOrder = inOrder(conn, commands, workUnitState); inOrder.verify(conn, times(1)).setAutoCommit(false); inOrder.verify(commands, times(1)).copyTable(database, stagingTable, destinationTable); inOrder.verify(workUnitState, times(1)).setWorkingState(WorkUnitState.WorkingState.COMMITTED); inOrder.verify(conn, times(1)).commit(); inOrder.verify(conn, times(1)).close(); verify(commands, never()).deleteAll(database, destinationTable); }
public void testPublishReplaceOutput() throws IOException, SQLException { state.setProp(JdbcPublisher.JDBC_PUBLISHER_REPLACE_FINAL_TABLE, Boolean.toString(true)); publisher.publish(workUnitStates); InOrder inOrder = inOrder(conn, commands, workUnitState); inOrder.verify(conn, times(1)).setAutoCommit(false); inOrder.verify(commands, times(1)).deleteAll(database, destinationTable); inOrder.verify(commands, times(1)).copyTable(database, stagingTable, destinationTable); inOrder.verify(workUnitState, times(1)).setWorkingState(WorkUnitState.WorkingState.COMMITTED); inOrder.verify(conn, times(1)).commit(); inOrder.verify(conn, times(1)).close(); }
public void testPublishFailure() throws SQLException, IOException { doThrow(RuntimeException.class).when(commands).copyTable(database, stagingTable, destinationTable); try { publisher.publish(workUnitStates); Assert.fail("Test case didn't throw Exception."); } catch (RuntimeException e) { Assert.assertTrue(e instanceof RuntimeException); } InOrder inOrder = inOrder(conn, commands, workUnitState); inOrder.verify(conn, times(1)).setAutoCommit(false); inOrder.verify(commands, times(1)).copyTable(database, stagingTable, destinationTable); inOrder.verify(conn, times(1)).rollback(); inOrder.verify(conn, times(1)).close(); verify(conn, never()).commit(); verify(commands, never()).deleteAll(database, destinationTable); verify(workUnitState, never()).setWorkingState(any(WorkUnitState.WorkingState.class)); } }
String stagingTable = entry.getKey(); LOG.info("Copying data from staging table " + stagingTable + " into destination table " + destinationTable); commands.copyTable(databaseName, stagingTable, destinationTable); for (WorkUnitState workUnitState : entry.getValue()) { workUnitState.setWorkingState(WorkUnitState.WorkingState.COMMITTED);
String stagingTable = entry.getKey(); LOG.info("Copying data from staging table " + stagingTable + " into destination table " + destinationTable); commands.copyTable(databaseName, stagingTable, destinationTable); for (WorkUnitState workUnitState : entry.getValue()) { workUnitState.setWorkingState(WorkUnitState.WorkingState.COMMITTED);