### Question:
TransactionalMessagePublisher implements MessagePublisher<TypedMessage>, TransactionalResource { @Override public void publish(final TypedMessage typedMessage) throws MessagePublishException { final MessagingTransaction transaction = getCurrentTransaction(); transaction.addMessage(typedMessage); } TransactionalMessagePublisher(final MessagePublisher<TypedMessage> messagePublisher); @Override void begin(); @Override void commit(); @Override void publish(final TypedMessage typedMessage); @Override void abort();  }### Answer:
@Test public void shouldNotPublishMessage_withNonExistingTransaction() throws Exception { final TransactionalMessagePublisher transactionalMessagePublisher = new TransactionalMessagePublisher( mockMessagePublisher); final TypedMessage typedMessage = mock(TypedMessage.class); NonExistentTransactionException actualException = null; try { transactionalMessagePublisher.publish(typedMessage); } catch (final NonExistentTransactionException e) { actualException = e; } assertNotNull(actualException); }