Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 333706 - TEST: fieldaccess tests should never use "default" pu
Summary: TEST: fieldaccess tests should never use "default" pu
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-06 16:58 EST by Andrei Ilitchev CLA
Modified: 2022-06-09 10:10 EDT (History)
1 user (show)

See Also:


Attachments
Suggested patch. (53.68 KB, patch)
2011-01-06 17:14 EST, Andrei Ilitchev CLA
no flags Details | Diff
Suggested patch - reposted. (54.78 KB, patch)
2011-01-07 10:38 EST, Andrei Ilitchev CLA
no flags Details | Diff
updated patch (69.76 KB, patch)
2011-01-07 11:41 EST, Andrei Ilitchev CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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