Community
Participate
Working Groups
>Problem: advanced.LifecycleJUnitTest assertion failures on UOW.lifecycle tests are swallowed by AssertionFailedError catch blocks 1 of 2 tests that need to be refactor is failing (test may be written wrong) Andrei and James came across the stacktrace printouts. I need to determine if the assertion failures that are being ignored are valid or not. >One test testClearWhileEntityManagerInFakeMergePendingState4 is invalid and ignores assertion failures - needs to be fixed >another test testClearWhileEntityManagerInFakeBirthState0 is ok but ignores assertion failures - needs to be fixed >In 2 of the tests I am also not closing the transaction (if open) in the finally clause >1 junit.framework.AssertionFailedError: Unchanged MergePending state 4 is not set expected:<4> but was:<0> Thread [Thread-6] (Suspended) LifecycleJUnitTest.testClearWhileEntityManagerInFakeMergePendingState4() line: 128 NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method] NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39 DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25 Method.invoke(Object, Object...) line: 597 LifecycleJUnitTest(TestCase).runTest() line: 168 LifecycleJUnitTest(TestCase).runBare() line: 134 LifecycleJUnitTest(JUnitTestCase).runBare() line: 466 TestResult$1.protect() line: 110 TestResult.runProtected(Test, Protectable) line: 128 TestResult.run(TestCase) line: 113 LifecycleJUnitTest(TestCase).run(TestResult) line: 124 TestExecutor.execute(Test) line: 248 TestExecutor.runTest(Test) line: 671 SynchronizedTestExecutor.run() line: 61
>The failing test looks to be correct >If I understand it correctly - I was trying to test that a clearForClose() did not clear when in UOW state 4 >It is now clearing but (not failing properly) public void clearForClose(boolean shouldClearCache) { clear(shouldClearCache); if (isActive()) { //Reset lifecycle > this.lifecycle = Birth; >the lifecycle is reset to 0 from 4 because the isActive() check is true for all non state 5 Thread [Thread-6] (Suspended) UnitOfWorkImpl.clearForClose(boolean) line: 5751 LifecycleJUnitTest.testClearWhileEntityManagerInFakeMergePendingState4() line: 120 public boolean isActive() { > return this.lifecycle != Death; } >I discussed this with Andrei and the code was moved to clear() I should be calling the API function and not the backdoor now. >The change in the patch works now - and the test is once again usefull in reporting failures TEST MODEL NAME: (JUnit test): LifecycleJUnitTestSuite Errors: (failures): 0 Fatal Errors: (errors): 0 Passed: 6 Total Tests: 6
Created attachment 179490 [details] Lifecycle tests for pendingMerge 4 state should use clear() now not backdoor clearForClose() anymore so that we do not clear in state 4
Created attachment 179521 [details] Lifecycle tests for pendingMerge 4 state should use em.clear() now not backdoor uow.clearForClose() anymore so that we do not clear in state 4
>2.1.2 test results OK <testcase classname="org.eclipse.persistence.testing.tests.jpa.advanced.concurrency.LifecycleJUnitTest" name="testClearWhileEntityManagerInFakeMergePendingState4" time="0.0" /> <testcase classname="org.eclipse.persistence.testing.tests.jpa.advanced.concurrency.LifecycleJUnitTest" name="testClearWhileEntityManagerInFakeBirthState0" time="0.0" /> <testcase classname="org.eclipse.persistence.testing.tests.jpa.advanced.concurrency.LifecycleJUnitTest" name="testClearWhileEntityManagerInCommitPendingStateWithClearAfterCommit" time="0.062" /> <testcase classname="org.eclipse.persistence.testing.tests.jpa.advanced.concurrency.LifecycleJUnitTest" name="testClearWhileEntityManagerInCommitPendingStateWithNoClearAfterCommit" time="0.0" /> <testcase classname="org.eclipse.persistence.testing.tests.jpa.advanced.concurrency.LifecycleJUnitTest" name="testClearAfterEntityManagerCommitFinished" time="0.0" />
>fix is in SVN Rev # 8241 and 8242 (2.1.2) https://fisheye2.atlassian.com/changelog/eclipselink/?cs=8241
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink