arquillian / arquillian-extension-transaction

9 stars 10 forks source link

Fix for hidden exception during test setup. #12

Closed vilmosnagy closed 8 years ago

vilmosnagy commented 8 years ago

Hello,

I think this bugfix is very similar to #9 .

If some exception occurs during the test-setup (for example, my datasets contain invalid data), the original exception is still hidden by an NPE. The NPE occurs during the rollback of the transaction. (I'm not totally sure, that there is any transaction.)

See one example here: https://github.com/vilmosnagy/arquillian-transaction-bug

There are 3 test-cases:

Here is the NPE's stack trace (the last lines only):

Caused by: java.lang.NullPointerException
    at org.jboss.arquillian.transaction.jta.provider.JtaTransactionProvider.rollbackTransaction(JtaTransactionProvider.java:103)
    ... 117 more

And here's the original exception, thrown by H2:

Caused by: org.dbunit.dataset.NoSuchColumnException: TEST_ENTITY.NOT_EXISTING_COLUMN -  (Non-uppercase input column: not_existing_column) in ColumnNameToIndexes cache map. Note that the map's column names are NOT case sensitive.
    at org.dbunit.dataset.AbstractTableMetaData.getColumnIndex(AbstractTableMetaData.java:117)
    at org.dbunit.operation.AbstractOperation.getOperationMetaData(AbstractOperation.java:89)
    at org.dbunit.operation.AbstractBatchOperation.execute(AbstractBatchOperation.java:143)
    at org.jboss.arquillian.persistence.dbunit.DBUnitDataHandler.seedDatabase(DBUnitDataHandler.java:167)
    at org.jboss.arquillian.persistence.dbunit.DBUnitDataHandler.prepare(DBUnitDataHandler.java:87)
    ... 191 more

I'd be happy to see the second exception, if something fails during the initialization of a test-case.

bartoszmajsak commented 8 years ago

Thank you very much for this contribution and example proving the issue. I will make sure it will land on the develop as soon as possible. I will try to incorporate your example as part of the test suite either here or in APE.

I'm not totally sure, that there is any transaction.

In fact when you use @UsingDataSet from "Arquillian Persistence Extension" it is by convention wrapping your test in the transaction.

bartoszmajsak commented 8 years ago

Pushed upstream. Thank you for your contribution!

vilmosnagy commented 8 years ago

Thanks! Do you know, when you'll release it?

bartoszmajsak commented 8 years ago

It's on @aslakknutsen desk now, as I don't have sufficient rights to pull the trigger :) I think it's safe to assume it will happen tomorrow.

aslakknutsen commented 8 years ago

pushed live, 1.0.3.Final

vilmosnagy commented 8 years ago

Thanks a lot!