Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 333706

Summary: TEST: fieldaccess tests should never use "default" pu
Product: z_Archived Reporter: Andrei Ilitchev <andrei.ilitchev>
Component: EclipselinkAssignee: Project Inbox <eclipselink.orm-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: michael.f.obrien
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Suggested patch.
none
Suggested patch - reposted.
none
updated patch none

Description Andrei Ilitchev CLA 2011-01-06 16:58:15 EST
It's a purely testing bug: lots of jpa.fieldaccess tests use "default" pu instaed of "fieldaccess".

It primarily happens because there are lots of test methods that - unless given puName - use "default" pu.

More commonly used methods are:
createEntityManager,
getServerSession,
clearCache.

but there is a bunch of other methods, too:
doesEntityManagerFactoryExist,
getDbPlatform,
getEntityManagerFactory,
isWeavingEnabled,
isPessimisticWriteLockSupported,
isSelectForUpateNoWaitSupported,
supportsStoredProcedures,
verifyDelete,
verifyObjectInCacheAndDatabase,
verifyObjectInEntityManager,
...?

To resolve the problem once and for all, all the methods should call getPersistenceUnitName method instaed of using "default" (some already do) - that would allow a TestSuite to specify its persistence unit - and then always call "defaulting" versions of the methods above.

I.e., define
String getPersistenceUnit() {
  return "fieldaccess";
}
and boldly use 
createEntityManager() or getServerSession()
instead of:
createEntityManager("fieldaccess") or getServerSession("fieldaccess")
Comment 1 Andrei Ilitchev CLA 2011-01-06 17:14:18 EST
Created attachment 186231 [details]
Suggested patch.

The patch enforces fieldaccess tests never using "default" pu - always using "fieldaccess" instead (easily verifyable by creating a conditional break point in createEMF method).

1. For now just made sure that "fieldaccess" argument is always passed when it should (didn't attempt refactoring all the methods to use getPersistenceUnitName() instead of "default").

2. Moved feildaccess.relationships/** from eclipselink-annotation-model.jar to eclipselink-advanced-field-access-model.jar;

3. fieldaccess.relationships.VirtualAttributeTestSuite is no longer used - currently it's an exact copy of relationships.VirtualAttributeTestSuite. To use this test suite smbd has to define fieldaccess entities for it.
Comment 2 Andrei Ilitchev CLA 2011-01-07 10:38:38 EST
Created attachment 186282 [details]
Suggested patch - reposted.
Comment 3 Andrei Ilitchev CLA 2011-01-07 11:41:24 EST
Created attachment 186288 [details]
updated patch

The patch updated according to feedback received from Tom, Edwin and Yiping:
1. CompositeEnumerationTest removed from the patch;
2. fieldaccess.relationships.VirtualAttributeTestSuite deleted - only makes sense for method access;
3. In build.xml "server-test-fieldaccess-relationships" should now use "fieldaccess" pu (was "default");
4. Move from all persistence.xml (that includes osgi, spring...) the property
            <property name="eclipselink.cache.shared.org.eclipse.persistence.testing.models.jpa.fieldaccess.relationships.IsolatedItem" value="false"/>
into the corresponding persistence.xml for "fielsaccess".
Comment 4 Andrei Ilitchev CLA 2011-01-07 17:24:35 EST
Checked into trunk.
Reviewed by Tom, Edwin and Yiping.
Comment 5 Eclipse Webmaster CLA 2022-06-09 10:10:14 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink