| 101 | * Test {@link SequenceCommand#executeCommand()} rollback if case of subcommand failure. |
| 102 | */ |
| 103 | @Test |
| 104 | public void testExecuteRollback() { |
| 105 | TestCommand command1 = new TestCommand(null); |
| 106 | FailingCommand command2 = new FailingCommand(); |
| 107 | TestCommand command3 = new TestCommand(null); |
| 108 | SequenceCommand command = new SequenceCommand("seq", Arrays.<Command>asList(command1, command2, command3)); |
| 109 | assertFalse(command.executeCommand()); |
| 110 | assertFalse(command1.executed); |
| 111 | // Don't check command2 executed state as it's possible but not necessary to undo failed commands |
| 112 | assertFalse(command3.executed); |
| 113 | command.undoCommand(); |
| 114 | } |
| 115 | |
| 116 | /** |
| 117 | * Test {@link SequenceCommand#executeCommand()} with continueOnError = true |
| 118 | */ |
| 119 | @Test |
| 120 | public void testContinueOnErrors() { |
| 121 | TestCommand command1 = new TestCommand(null); |
| 122 | FailingCommand command2 = new FailingCommand(); |
| 123 | TestCommand command3 = new TestCommand(null); |
| 124 | SequenceCommand command = new SequenceCommand("seq", Arrays.<Command>asList(command1, command2, command3)); |
| 125 | command.continueOnError = true; |
| 126 | assertTrue(command.executeCommand()); |
| 127 | assertTrue(command1.executed); |
| 128 | assertTrue(command3.executed); |
| 129 | command.undoCommand(); |
| 130 | assertFalse(command1.executed); |
| 131 | // Don't check command2 executed state as it's possible but not necessary to undo failed commands |
| 132 | assertFalse(command3.executed); |
| 133 | } |
| 134 | |
| 135 | /** |