Optimistic Locking, Unit Tests, etc.

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Sat Apr 10 2004 - 20:37:56 EDT

  • Next message: jir..bjectstyle.org: "[OS-JIRA] Created: (CAY-116) Sybase Schema Generation: no way to drop constraints"

    Looks like it is time for 1.1 M5. Here the latest update on the coding
    progress.

    Optimistic Locking:

    Just checked in the optimistic locking code. It is based on Mike's
    patch, however instead of changing the DataNode flow for batch
    execution, I redefined how UpdateBatchQueries are partitioned.
    Basically for now I am taking NULLS in the WHERE clause into account
    and create separate batch for each combination of null positions. E.g.
    there will be two independent batches created for these two queries:

    UPDATE SIMPLE_LOCKING_TEST SET DESCRIPTION = ? WHERE LOCKING_TEST_ID =
    ? AND NAME = ?
    and
    UPDATE SIMPLE_LOCKING_TEST SET DESCRIPTION = ? WHERE LOCKING_TEST_ID =
    ? AND NAME IS NULL

    Not sure what else is missing... I haven't tested locking on date and
    timestamp columns yet, however I have test entities setup as a separate
    DataMap called "locking". Mike, are there any other issues that I might
    have overlooked?

    Unit Tests Refactoring:

    With all the hype surrounding so-called IoC containers lately, I
    started using one of those, Spring framework
    (http://www.springframework.org/), for our unit tests. This allowed me
    to make the whole setup much more flexible and easy to configure.

    Now we can keep any number of small test DataMaps in one test mapping
    project, and use Spring to configure AccessStacks (AccessStack is a
    DataDomain wrapper used in testing only) out of this mapping
    information, bypassing Cayenne configuration. For instance now we can
    inherit test case classes from CayenneTestCase, PeopleTestCase, or
    LockingTestCase, and get access to a small subset of entities to test
    only specific area of Cayenne, instead of using Artist entity for
    everything. See
    "src/tests/resources/test-resources/spring-test-resources.xml".

    Another cool thing - we can now configure test data sets in XML, and
    load and execute them using Cayenne and Spring. No DBUnit or anything
    like that is required. I am gradually switching the test cases to this
    approach. Very cool and easy to use. See files under
    "src/tests/resources/test-resources/dml".

    Andrus



    This archive was generated by hypermail 2.0.0 : Sat Apr 10 2004 - 20:38:01 EDT