Bug 294089 - test implementation for QA JPA2.0 PessimisticLocking Test Plan project
Summary: test implementation for QA JPA2.0 PessimisticLocking Test Plan project
Status: RESOLVED 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: test
Depends on:
Blocks:
 
Reported: 2009-11-03 11:57 EST by Yiping Zhao CLA
Modified: 2022-06-09 10:09 EDT (History)
0 users

See Also:


Attachments
patch for adding new tests to test JPA2.0 PessimisticLocking feature (19.00 KB, patch)
2009-11-03 14:30 EST, Yiping Zhao CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yiping Zhao CLA 2009-11-03 11:57:58 EST
According to PessimisticLocking Test Plan http://aseng-wiki.us.oracle.com/asengwiki/display/ASQA/Pessimistic+Locking+Test+Plan, we need to add a list of new tests, these new tests and all existing tests together will have better coverage of scenarios exposed in JPA2.0 PessmisticLocking Functional Spec. 

The changes are:

1. add following two tests in EntityManagerJUnitTestSuite.java in advanced model

testPESSIMISTIC_FORCE_INCREMENTLockOnNonVersionedEntity() testLockWithJoinedInheritanceStrategy()

2. add following four tests in AdvancedQueryTestSuite.java in jpql model

testLockWithSecondaryTable
testVersionChangeWithReadLock
testVersionChangeWithWriteLock
testNamedQueryAnnotationOverwritePersistenceXML

3. add a new namedquery in Employee.java in advanced model
@NamedQuery(
	name="findAllEmployeesByIdAndFirstName",
	query="Select employee from Employee employee where employee.id = :id and employee.firstName = :firstName",
    hints={
                @QueryHint(name=QueryHints.PESSIMISTIC_LOCK_TIMEOUT, value="15")
    }
)

4. add <property name="javax.persistence.lock.timeout" value="5"/> to persistence.xml under trunk\jpa\eclipselink.jpa.test\resource\eclipselink-annotation-model

5. add verification part in testQueryPESSIMISTIC_FORCE_INCREMENTLock in AdvancedQueryTestSuite.java in jpql model to implement the features as designed in testForceIncrementAsWriteLock, which is PESSIMISTIC_FORCE_INCREMENT lock can be used as PESSIMISTIC_WRITE lock

//Verify if the entity has been updated correctly by using PESSIMISTIC_FORCE_INCREMENT as PESSIMISTIC_WRITE
            try {
                beginTransaction(em);
                Query query = em.createQuery("Select employee from Employee employee where employee.id = :id and employee.firstName = :firstName").setLockMode(LockModeType.PESSIMISTIC_FORCE_INCREMENT);
                query.setParameter("id", employee.getId());
                query.setParameter("firstName", employee.getFirstName());
                Employee queryResult = (Employee) query.getSingleResult();
                rollbackTransaction(em);
                
                assertTrue("The last name is not updated by using PESSIMISTIC_FORCE_INCREMENT.", queryResult.getLastName().equals("Auger"));
            } catch (RuntimeException ex) {
                if (isTransactionActive(em)) {
                    rollbackTransaction(em);
                }
                
                throw ex;
            } finally {
                closeEntityManager(em);
            }
Comment 1 Yiping Zhao CLA 2009-11-03 13:46:18 EST
6. change condition for running testPESSIMISTIC_FORCE_INCREMENTLock in EntityManagerJUnitTestSuite from "if (! isOnServer() && isSelectForUpateSupported())" to be "if (! isJPA10() && isSelectForUpateSupported())"

7. change condition for running test testQueryPESSIMISTIC_FORCE_INCREMENTLock in AdvancedQueryTestSuite.java from "if (! isOnServer() && isSelectForUpateSupported())" to be "if (! isJPA10() && isSelectForUpateSupported())"
Comment 2 Yiping Zhao CLA 2009-11-03 14:30:17 EST
Created attachment 151234 [details]
patch for adding new tests to test JPA2.0 PessimisticLocking feature
Comment 3 Yiping Zhao CLA 2009-11-04 14:03:08 EST
checked in the patch in Main branch as revision 5731.
Comment 4 Eclipse Webmaster CLA 2022-06-09 10:09:54 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink