ReceiveAsciiAction extends AsciiAction { @Override public void execute(State state) throws WorkflowExecutionException { TlsContext tlsContext = state.getTlsContext(); if (isExecuted()) { throw new WorkflowExecutionException("Action already executed!"); } try { LOGGER.debug("Receiving ASCII message..."); byte[] fetchData = tlsContext.getTransportHandler().fetchData(); receivedAsciiString = new String(fetchData, getEncoding()); LOGGER.info("Received: " + receivedAsciiString); setExecuted(true); } catch (IOException E) { LOGGER.debug(E); setExecuted(false); } } ReceiveAsciiAction();  ReceiveAsciiAction(String asciiText, String encoding); @Override void execute(State state); String getReceivedAsciiString(); @Override void reset(); @Override boolean executedAsPlanned();  }
@Test public void testExecute() throws Exception { ((FakeTransportHandler) tlsContext.getTransportHandler()) .setFetchableByte(new byte[] { 0x15, 0x03, 0x02, 0x01 }); action.execute(state); assertTrue(action.isExecuted()); }
@Test(expected = WorkflowExecutionException.class) public void testExecuteWorkflowExecutionException() { action.execute(state); action.execute(state); }