@Test(expected = ExecutionException.class) public void testExecuteWithAsyncActionExecutionFailure() throws Throwable { Serializable params = null; final AsyncActionContext asyncActionContext = new AsyncActionContext(params); transDef.setReadOnly(true); context.checking(new Expectations() { { oneOf(asyncActionMock).isReadOnly(); will(returnValue(true)); oneOf(transMgrMock).getTransaction(transDef); will(returnValue(transStatus)); oneOf(asyncActionMock).getValidationStrategy(); will(returnValue(validationStrategy)); oneOf(validationStrategy).validate(asyncActionContext); oneOf(asyncActionMock).getExecutionStrategy(); will(returnValue(executionStrategy)); oneOf(executionStrategy).execute(asyncActionContext); will(throwException(new ExecutionException())); oneOf(transStatus).isCompleted(); will(returnValue(false)); oneOf(transMgrMock).rollback(transStatus); } }); sut.execute(asyncActionContext, asyncActionMock); context.assertIsSatisfied(); }
public Serializable execute(final AsyncActionContext inAsyncActionContext, final AsyncAction inAsyncAction) { Serializable results = null; DefaultTransactionDefinition transDef = new DefaultTransactionDefinition(); transDef.setName(inAsyncAction.toString()); transDef.setReadOnly(inAsyncAction.isReadOnly()); TransactionStatus transStatus = transMgr.getTransaction(transDef); try { inAsyncAction.getValidationStrategy().validate(inAsyncActionContext); results = inAsyncAction.getExecutionStrategy().execute(inAsyncActionContext); transMgr.commit(transStatus); } catch (ValidationException vex) { onException(transStatus); logger.warn("Validation failed for the current action.", vex); for (Entry<String, String> currentError : vex.getErrors().entrySet()) { logger.warn("Validation key: " + currentError.getKey() + ", value: " + currentError.getValue()); } throw vex; } catch (ExecutionException eex) { onException(transStatus); logger.error("Error occurred during execution.", eex); throw eex; } catch (Exception ex) { onException(transStatus); logger.error("Error occurred performing transaction.", ex); throw new GeneralException(ex); } return results; }
AsyncActionController implements AsynchronousActionController { public Serializable execute(final AsyncActionContext inAsyncActionContext, final AsyncAction inAsyncAction) { Serializable results = null; DefaultTransactionDefinition transDef = new DefaultTransactionDefinition(); transDef.setName(inAsyncAction.toString()); transDef.setReadOnly(inAsyncAction.isReadOnly()); TransactionStatus transStatus = transMgr.getTransaction(transDef); try { inAsyncAction.getValidationStrategy().validate(inAsyncActionContext); results = inAsyncAction.getExecutionStrategy().execute(inAsyncActionContext); transMgr.commit(transStatus); } catch (ValidationException vex) { onException(transStatus); logger.warn("Validation failed for the current action.", vex); for (Entry<String, String> currentError : vex.getErrors().entrySet()) { logger.warn("Validation key: " + currentError.getKey() + ", value: " + currentError.getValue()); } throw vex; } catch (ExecutionException eex) { onException(transStatus); logger.error("Error occurred during execution.", eex); throw eex; } catch (Exception ex) { onException(transStatus); logger.error("Error occurred performing transaction.", ex); throw new GeneralException(ex); } return results; } }
AsyncActionController implements AsynchronousActionController { public Serializable execute(final AsyncActionContext inAsyncActionContext, final AsyncAction inAsyncAction) { Serializable results = null; DefaultTransactionDefinition transDef = new DefaultTransactionDefinition(); transDef.setName(inAsyncAction.toString()); transDef.setReadOnly(inAsyncAction.isReadOnly()); TransactionStatus transStatus = transMgr.getTransaction(transDef); try { inAsyncAction.getValidationStrategy().validate(inAsyncActionContext); results = inAsyncAction.getExecutionStrategy().execute(inAsyncActionContext); transMgr.commit(transStatus); } catch (ValidationException vex) { onException(transStatus); logger.warn("Validation failed for the current action.", vex); for (Entry<String, String> currentError : vex.getErrors().entrySet()) { logger.warn("Validation key: " + currentError.getKey() + ", value: " + currentError.getValue()); } throw vex; } catch (ExecutionException eex) { onException(transStatus); logger.error("Error occurred during execution.", eex); throw eex; } catch (Exception ex) { onException(transStatus); logger.error("Error occurred performing transaction.", ex); throw new GeneralException(ex); } return results; } AsyncActionController(final PlatformTransactionManager inTransMgr); }
AsyncActionController implements AsynchronousActionController { public Serializable execute(final AsyncActionContext inAsyncActionContext, final AsyncAction inAsyncAction) { Serializable results = null; DefaultTransactionDefinition transDef = new DefaultTransactionDefinition(); transDef.setName(inAsyncAction.toString()); transDef.setReadOnly(inAsyncAction.isReadOnly()); TransactionStatus transStatus = transMgr.getTransaction(transDef); try { inAsyncAction.getValidationStrategy().validate(inAsyncActionContext); results = inAsyncAction.getExecutionStrategy().execute(inAsyncActionContext); transMgr.commit(transStatus); } catch (ValidationException vex) { onException(transStatus); logger.warn("Validation failed for the current action.", vex); for (Entry<String, String> currentError : vex.getErrors().entrySet()) { logger.warn("Validation key: " + currentError.getKey() + ", value: " + currentError.getValue()); } throw vex; } catch (ExecutionException eex) { onException(transStatus); logger.error("Error occurred during execution.", eex); throw eex; } catch (Exception ex) { onException(transStatus); logger.error("Error occurred performing transaction.", ex); throw new GeneralException(ex); } return results; } AsyncActionController(final PlatformTransactionManager inTransMgr); Serializable execute(final AsyncActionContext inAsyncActionContext, final AsyncAction inAsyncAction); @SuppressWarnings("unchecked") Serializable execute(final AsyncActionContext inAsyncActionContext,
            final TaskHandlerAction inTaskHandlerAction); }
AsyncActionController implements AsynchronousActionController { public Serializable execute(final AsyncActionContext inAsyncActionContext, final AsyncAction inAsyncAction) { Serializable results = null; DefaultTransactionDefinition transDef = new DefaultTransactionDefinition(); transDef.setName(inAsyncAction.toString()); transDef.setReadOnly(inAsyncAction.isReadOnly()); TransactionStatus transStatus = transMgr.getTransaction(transDef); try { inAsyncAction.getValidationStrategy().validate(inAsyncActionContext); results = inAsyncAction.getExecutionStrategy().execute(inAsyncActionContext); transMgr.commit(transStatus); } catch (ValidationException vex) { onException(transStatus); logger.warn("Validation failed for the current action.", vex); for (Entry<String, String> currentError : vex.getErrors().entrySet()) { logger.warn("Validation key: " + currentError.getKey() + ", value: " + currentError.getValue()); } throw vex; } catch (ExecutionException eex) { onException(transStatus); logger.error("Error occurred during execution.", eex); throw eex; } catch (Exception ex) { onException(transStatus); logger.error("Error occurred performing transaction.", ex); throw new GeneralException(ex); } return results; } AsyncActionController(final PlatformTransactionManager inTransMgr); Serializable execute(final AsyncActionContext inAsyncActionContext, final AsyncAction inAsyncAction); @SuppressWarnings("unchecked") Serializable execute(final AsyncActionContext inAsyncActionContext,
            final TaskHandlerAction inTaskHandlerAction);  }