JDO
  1. JDO
  2. JDO-558

Create tests for the serialization of PersistenceManagerFactory/PersistenceManager

    Details

    • Type: Task Task
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: JDO 2 maintenance release 1 (2.1)
    • Fix Version/s: None
    • Component/s: tck, tck2-legacy
    • Labels:
      None

      Description

      Serialization of PMFs/PMs needs to be tested as part of the TCK. Forthcoming spec updates on PM serialization will need assertions.

      1. jdo-558.patch
        5 kB
        Craig L Russell

        Activity

        Matthew T. Adams created issue -
        Craig L Russell made changes -
        Field Original Value New Value
        Assignee Craig Russell [ clr ]
        Fix Version/s JDO 2 maintenance release 2 [ 12313070 ]
        Hide
        Craig L Russell added a comment -

        Tests will serialize a PMF and then materialize it in the same VM (easy with the current JUnit setup), and make sure it's equivalent by getting a PM and trying to retrieve an instance by its id.

        A different test will serialize a PM and materialize it in the same VM. It should also be possible to retrieve an instance that was stored using the previous PMF.

        Another set of tests will create a new VM and try to materialize PMF and PM. This is more tricky with the current maven/JUnit setup since another VM needs to be created and communications established between the VMs.

        Show
        Craig L Russell added a comment - Tests will serialize a PMF and then materialize it in the same VM (easy with the current JUnit setup), and make sure it's equivalent by getting a PM and trying to retrieve an instance by its id. A different test will serialize a PM and materialize it in the same VM. It should also be possible to retrieve an instance that was stored using the previous PMF. Another set of tests will create a new VM and try to materialize PMF and PM. This is more tricky with the current maven/JUnit setup since another VM needs to be created and communications established between the VMs.
        Hide
        Craig L Russell added a comment -

        For reference, I've updated the assertions in the specification:
        Serialization
        Serialization of a persistence manager factory allows an application to preserve a reference to the factory via calling writeObject on it and having its state preserved by writing it to a stream in an external form. Later, the state can be read from a stream and a functionally equivalent instance of the factory can be restored.
        When serializing the state of a persistence manager factory, the properties used to create the factory must be serialized. Some of the properties might depend on the context of the Java VM, and so are not able to be serialized. These properties may include the registered life cycle listener instances, class loaders, and any other values that are not serializable.
        A11.10-1 [If the persistence manager factory was created via the getPersistenceManagerFactory(Map props) method, then the serializable properties in props must be written to the stream and upon restoration, used to construct or locate the persistence manager factory in the new context. ]
        A11.10-2 [If the persistence manager factory was created via the javax.persistence.Persistence.createEntityManagerFactory (Map overrides, String name) method, then the persistence manager factory must write the overrides and the name to the stream and use these parameters in the new context to read the persistence.xml in the new context, use the overrides, and reconstruct the persistence manager factory. ]
        A11.10-3 [If the persistence manager factory was created via the JDOHelper.getPersistenceManagerFactory (Map overrides, String name) method, then the persistence manager factory must write the overrides and the name to the stream and use these parameters in the new context to read the jdoconfig.xml in the new context, use the overrides, and reconstruct the persistence manager factory. ]
        If the persistence manager factory was created via the getPersistenceManagerFactory(Map overrides, Map props) method, then the serializable properties in the overrides must be written to the stream and upon restoration, used to establish overrides for the persistence manager factory in the new context. The treatment of the props parameter depends on the existence of certain entries:
        A11.10-4 [If the property javax.jdo.spi.PropertiesFileName is a key in the props, then the value of this key and the overrides must be written to the stream and used in the new context to recreate the persistence manager factory from the file name. ]
        A11.10-5 [If the property javax.jdo.Name is a key in the props, then the value of this key and the overrides must be written to the stream and used in the new context to recreate the persistence manager factory from jdoconfig.xml. ]

        I'm going to focus on assertion A11.10-1 for this round of the TCK.

        Show
        Craig L Russell added a comment - For reference, I've updated the assertions in the specification: Serialization Serialization of a persistence manager factory allows an application to preserve a reference to the factory via calling writeObject on it and having its state preserved by writing it to a stream in an external form. Later, the state can be read from a stream and a functionally equivalent instance of the factory can be restored. When serializing the state of a persistence manager factory, the properties used to create the factory must be serialized. Some of the properties might depend on the context of the Java VM, and so are not able to be serialized. These properties may include the registered life cycle listener instances, class loaders, and any other values that are not serializable. A11.10-1 [If the persistence manager factory was created via the getPersistenceManagerFactory(Map props) method, then the serializable properties in props must be written to the stream and upon restoration, used to construct or locate the persistence manager factory in the new context. ] A11.10-2 [If the persistence manager factory was created via the javax.persistence.Persistence.createEntityManagerFactory (Map overrides, String name) method, then the persistence manager factory must write the overrides and the name to the stream and use these parameters in the new context to read the persistence.xml in the new context, use the overrides, and reconstruct the persistence manager factory. ] A11.10-3 [If the persistence manager factory was created via the JDOHelper.getPersistenceManagerFactory (Map overrides, String name) method, then the persistence manager factory must write the overrides and the name to the stream and use these parameters in the new context to read the jdoconfig.xml in the new context, use the overrides, and reconstruct the persistence manager factory. ] If the persistence manager factory was created via the getPersistenceManagerFactory(Map overrides, Map props) method, then the serializable properties in the overrides must be written to the stream and upon restoration, used to establish overrides for the persistence manager factory in the new context. The treatment of the props parameter depends on the existence of certain entries: A11.10-4 [If the property javax.jdo.spi.PropertiesFileName is a key in the props, then the value of this key and the overrides must be written to the stream and used in the new context to recreate the persistence manager factory from the file name. ] A11.10-5 [If the property javax.jdo.Name is a key in the props, then the value of this key and the overrides must be written to the stream and used in the new context to recreate the persistence manager factory from jdoconfig.xml. ] I'm going to focus on assertion A11.10-1 for this round of the TCK.
        Hide
        Craig L Russell added a comment -

        This test serializes and materializes a PMF and makes sure the restored PMF is usable.

        With the current DataNucleus svn the test fails.

        Show
        Craig L Russell added a comment - This test serializes and materializes a PMF and makes sure the restored PMF is usable. With the current DataNucleus svn the test fails.
        Craig L Russell made changes -
        Attachment jdo-558.patch [ 12388868 ]
        Michael Bouschen made changes -
        Fix Version/s JDO 2 maintenance release 2 [ 12313070 ]
        Fix Version/s JDO 2 maintenance release 3 [ 12313404 ]
        Hide
        Craig L Russell added a comment -

        Defer until next maintenance release.

        Show
        Craig L Russell added a comment - Defer until next maintenance release.
        Craig L Russell made changes -
        Fix Version/s JDO 2 maintenance release 3 [ 12313404 ]

          People

          • Assignee:
            Craig L Russell
            Reporter:
            Matthew T. Adams
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:

              Development