1

I don't know why is transaction is not completed.

Example)


    public void transactionMethod() {
        DefaultTransactionDefinition txDefinition = new DefaultTransactionDefinition();
        txDefinition.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
        TransactionStatus testTx = txManager.getTransaction(txDefinition);

        try {
            txManager.commit(testTx);
        } catch (Exception ex) {

            log.error("Catch!!!!!!!!!!!");
        }
        if (Objects.nonNull(testTx) && !testTx.isCompleted()) {

            txManager.rollback(testTx);
        }

    }

    @Test
    public void test() {
        SimpleTransactionStatus testTx = new SimpleTransactionStatus();
        when(txManager.getTransaction(any())).thenReturn(testTx);

        target.transactionMethod();
    }

I think rollback is not implemented because commit ended in try{}. However, testTx.isCompleted()is false..... Could you tell me why testTx.isCompleted() is false?

SD.LEE
  • 31
  • 4

0 Answers0