Changes between Version 1 and Version 2 of ebXMLPersistenceLayerTestSuite


Ignore:
Timestamp:
Aug 9, 2008, 7:32:33 AM (16 years ago)
Author:
heikki
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ebXMLPersistenceLayerTestSuite

    v1 v2  
    1111
    1212The tests use the well-known unit testing framework [http://junit.org Junit]. Although developed against a local [http://www.mysql.com MySQL] database, the tests are currently being remodeled such that they use an embedded [http://www.mckoi.com McKoi] database server; this removes the dependency of the test suite on a pre-installed external database server. Some peculiarities of !McKoi are being accommodated, for instance it chokes if you try to create a table called "user".
     13
     14=== Example ===
     15
     16An example of a test case verifying that a !RegistryObject is stored, both by querying on !RegistryObject and polymorphically on its base class Identifiable, is this:
     17
     18 {{{
     19
     20        public void testPersistingRegistryObject(){
     21               
     22                // create transient object
     23                RegistryObject transientRegistryObject = RegistryObjectFactory.createRegistryObject();
     24                URN businessKey = transientRegistryObject.getId();
     25
     26                // make transient object persistent
     27                Transaction tx = hibernateSession.beginTransaction();
     28                hibernateSession.saveOrUpdate(transientRegistryObject);
     29                tx.commit();                     
     30               
     31                // verify database state
     32                Query registryObjectQuery = hibernateSession.createQuery("from RegistryObject o where o.id = '" + businessKey + "'");                     
     33                List<RegistryObject> registryObjectResult = registryObjectQuery.list();
     34                RegistryObject persistentRegistryObject = registryObjectResult.get(0);
     35                assertEquals(transientRegistryObject, persistentRegistryObject);
     36
     37                // verify database state using a polymorphic query
     38                Query identifiableQuery = hibernateSession.createQuery("from Identifiable o where o.id = '" + businessKey + "'");                         
     39                List<Identifiable> identifiableResult = identifiableQuery.list();
     40                Identifiable identifiable = identifiableResult.get(0);
     41                assertEquals(transientRegistryObject, identifiable);
     42        }
     43
     44 }}}