Created
October 6, 2012 23:32
-
-
Save PiotrNowicki/3846509 to your computer and use it in GitHub Desktop.
Arquillian persistence problem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void dataIsPopulated() { | |
// given populated cache | |
// when | |
List<Question> questions = cut.getQuestions(); | |
// then | |
assertThat(questions.size()).isEqualTo(3); | |
} | |
@Test | |
//@Transactional(TransactionMode.ROLLBACK) | |
public void updateGeneratesEvent() throws NotSupportedException, SystemException { | |
utx.begin(); | |
// given | |
Question question = cut.getQuestions().get(0); | |
// when | |
question.setSummary("My test summary"); | |
cut.updateQuestion(question); | |
// then | |
Question actual = cut.getQuestionById(question.getId()); | |
assertThat(actual.getSummary()).isEqualTo("My test summary"); | |
utx.rollback(); | |
} |
Works like a charm mate! I put @Cleanup(phase = TestExecutionPhase.NONE)
at the class level and @Transactional(TransactionMode.ROLLBACK)
for each transactional method that should be rolled-back.
Thanks once again - I'll look forward to watching JTA module arriving :-)
BTW: great job with this APE :-)
JTA module is already there, just hidden in APE internals hehe. Having kinda headache with it currently :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The trick is that APE cleans your db for each and every tests, to have it somehow "isolated". I know it's not really what you would expect from plain @transactional (a bit too much convention here ;)), that's why I'm working on moving JTA transaction to its own module (for next version - Alpha6). If you want to turn off clean-up use @cleanup(NONE) on class level.