Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 326097 - JPA: LifecycleJUnitTest assertion failures (1 of 5) on UOW.lifecycle tests are ignored by AssertionFailedError catch blocks
Summary: JPA: LifecycleJUnitTest assertion failures (1 of 5) on UOW.lifecycle tests ar...
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P2 major (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL: http://wiki.eclipse.org/EclipseLink/B...
Whiteboard:
Keywords:
Depends on: 259993
Blocks:
  Show dependency tree
 
Reported: 2010-09-23 16:08 EDT by Michael OBrien CLA
Modified: 2022-06-09 10:27 EDT (History)
5 users (show)

See Also:


Attachments
Lifecycle tests for pendingMerge 4 state should use clear() now not backdoor clearForClose() anymore so that we do not clear in state 4 (6.09 KB, patch)
2010-09-23 16:43 EDT, Michael OBrien CLA
no flags Details | Diff
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 (10.27 KB, patch)
2010-09-24 09:40 EDT, Michael OBrien CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael OBrien CLA 2010-09-23 16:08:07 EDT
>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
Comment 1 Michael OBrien CLA 2010-09-23 16:37:19 EDT
>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
Comment 2 Michael OBrien CLA 2010-09-23 16:43:41 EDT
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
Comment 3 Michael OBrien CLA 2010-09-24 09:40:07 EDT
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
Comment 4 Michael OBrien CLA 2010-09-24 11:13:38 EDT
>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" />
Comment 5 Michael OBrien CLA 2010-10-06 20:56:37 EDT
>fix is in SVN Rev # 8241 and 8242 (2.1.2)
https://fisheye2.atlassian.com/changelog/eclipselink/?cs=8241
Comment 6 Eclipse Webmaster CLA 2022-06-09 10:27:13 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink