Issue Details (XML | Word | Printable)

Key: JDO-273
Type: Test Test
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Martin Zaun
Reporter: Matthew T. Adams
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
JDO

Create tests for sections 5.5.8 & 5.5.9, detachment lifecycle

Created: 07/Jan/06 02:24 AM   Updated: 30/Mar/06 06:42 AM
Return to search
Component/s: tck2
Affects Version/s: JDO 2 beta
Fix Version/s: JDO 2 final

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works JDO-273.patch 2006-01-24 04:06 AM Michael Watzek 70 kB

Resolution Date: 30/Mar/06 06:42 AM


 Description  « Hide
Write tests for assertions in sections "5.5.8 Detached-clean", "5.5.9 Detached-dirty".

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Michael Watzek added a comment - 24/Jan/06 04:06 AM
The attached patch implements the lifecycle transition tests for JDO-258 and JDO-273.

The patch extends the existing test class org.apache.jdo.tck.lifecycle.StateTransitions and adds a new test class org.apache.jdo.tck.lifecycle.CheckStatesOfReturnedObjects.

The lifecycle matrix in class StateTransitions has been extended by three states (persistent-nontransactional-dirty, detached-clean, and detached-dirty) and by five operations (detach-all-on-commit, detachCopy-outside-tx, detachCopy-inside-tx, serialize-outside-tx, and serialize-inside-tx). Note, that this class checks lifecycle transitions on the parameter instance of the operations above.

Class CheckStatesOfReturnedObjects almost implements the same algorithm and lifecycle matrix as class StateTransitions. There are mainly two differences:

1) The maxtrix only considers operations makePersistent plus the five new operations above.
2) The expected state is checked against the returned instance of an operation.

Currently, both classes still contain some comments in the matrix. These comments are not meant to be checked in, but they have to be removed before check in. All places where these comments occur, JPOX currently returns an unexpected state. Due to the fact that the test fails for the first unexpected state, I decided to put the expected state in comments. The comments follow the pattern /*Bug: EXPECTED_STATE*/UNEXPECTED_STATE. In particular, I found the following bugs:

Class StateTransitions:
-- makeTransactional(detached-clean) -> transient-clean (must be
JDOUserException)
-- makeTransactional(detached-dirty) -> transient-clean (must be
JDOUserException)
-- makeTransient(persistent-nontransactional-dirty) -> transient (must be JDOUserException)
-- makeTransient(detached-clean) -> detached-clean (must be
JDOUserException)
-- makeTransient(detached-dirty) -> detached-dirty (must be
JDOUserException)
-- commit, detachAllOnCommit==true (hollow) -> hollow (must be
detached-clean)
-- commit, detachAllOnCommit==true (persistent-new-deleted) ->
JDOObjectNotFoundException (must be transient)
-- commit, detachAllOnCommit==true (persistent-deleted) ->
JDOObjectNotFoundException (must be transient)
-- commit, detachAllOnCommit==true (persistent-nontransational) ->
hollow (must be detached-clean)
-- detachCopy with active tx (transient) -> transient (must be persistent-new)
-- detachCopy with active tx (transient-clean) -> transient-clean (must be persistent-new)
-- detachCopy with active tx (transient-dirty) -> transient-dirty (must be persistent-new)

Class CheckStatesOfReturnedObjects :
-- makePersistent(detached-clean) -> persistent-dirty (must be persistent-clean)
-- detachCopy with active tx (transient) -> transient (must be detached-clean)
-- detachCopy with active tx (transient-clean) -> transient (must be detached-clean)
-- detachCopy with active tx (transient-dirty) -> transient (must be detached-dirty)
-- serialize with active tx (persistent-new) -> transient (must be detached-clean)

Martin Zaun added a comment - 23/Mar/06 04:09 PM
Combined patch for JDO-273 and JDO-258 committed with revision 388087.

The patch is based on Michael Watzek's patch for JDO-273 with a couple of modifications:
- merged with latest JDO_Test.java, resolved conflicting changes
- renamed class CheckStatesOfReturnedObjects to StateTransitionsReturnedObjects
- changed classes StateTransitions and StateTransitionsReturnedObjects not to fail on
  the first error but to collect all error messages and test for failure at the end of test()
- re-enacted the correct but commented state transitions currently failed by jpox
  (see Michael's comments above)
- reviewed and fixed a number of failing state transitions with Craig
- added a few cleanups

There are a few action items left:

- Review and clarify the state transition for argument instances of states 'hollow' and
  'persistent-nontransactional' for serialize with active tx. Currently, the test expects for
  both, datastore and optimistic, tx a transition to 'persistent-clean'. Some discussion,
  however, has suggested that UNCHANGED should be the transition for optimistic tx.

- File a jpox issue on the failing state transitions for argument instances (29 errors)
  and returned instances (19 errors).

- There's a large amount of code duplication between classes StateTransitions and
  StateTransitionsReturnedObjects. File an issue for later cleanup and refactorization.


Martin Zaun added a comment - 23/Mar/06 04:30 PM

> - File a jpox issue on the failing state transitions for argument instances (29 errors)
> and returned instances (19 errors).

Filed as issue JDO-347.

> - There's a large amount of code duplication between classes StateTransitions and
> StateTransitionsReturnedObjects. File an issue for later cleanup and refactorization.

Filed as issue JDO-346.

Martin Zaun added a comment - 24/Mar/06 01:03 AM
Sorry for the missing class src/java/org/apache/jdo/tck/lifecycle/StateTransitionsReturnedObjects.java.
Checked in with revision 388211.

Michelle Caisse added a comment - 26/Mar/06 01:03 PM
I have added the new assertions in sections 5.5.8 and 5.5.9 to the assertions spreadsheet. The test classes need to have their Assertion ID comment fields and ASSERTION_FAILED Strings updated with the list of new assertions tested, including the assertions listed in JDO-258.

Martin Zaun added a comment - 28/Mar/06 05:10 AM
> - Review and clarify the state transition for argument instances of states 'hollow' and
> 'persistent-nontransactional' for serialize with active tx. Currently, the test expects for
> both, datastore and optimistic, tx a transition to 'persistent-clean'. Some discussion,
> however, has suggested that UNCHANGED should be the transition for optimistic tx.

Confirmed by Craig: UNCHANGED should be the state transition for serialize with optimistic tx.
Committed fix with revision 389247.

Martin Zaun added a comment - 28/Mar/06 07:38 AM
Requested by Craig: As the spec leaves open some behaviour with 'detachCopy outside tx',
the StateTransitionsReturnedObjects test should skip this scenario for now.

To re-enable, just uncomment this scenario in the array:
    private static final boolean[][] applies_to_scenario = {
        ...
        //{ false, false, true }, // detachCopy outside tx

Committed in revision 389315.