Re: Testing applications

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Wed Nov 24 2004 - 09:48:46 EST

  • Next message: Twan Kogels: "Re: selectRelationshipObjects and addPrefetch results in classcastexception"

    Yeah, currently DataContext makes an assumption that parent QueryEngine is
    a DataDomain. This is a kludge that needs to go away in the future
    releases.

    So for now you may either override "getParentDataDomain()" to return null
    (and then mock up all methods in the DataContext that rely on it), or
    implement your QueryEngine mockup class as a subclass of DataDomain, thus
    going down the stack one more level. I think I've done it before for
    Cayenne's own unit tests. Can't say for sure as I don't have CVS check out
    on the current workstaton.

    Andrus

    > Now that I'm mocking the QueryEngine and ObjectStore I get a class cast
    > exception. Any ideas?
    >
    > testGetUserExceptions(au.com.relevance.corporatedb.UsersTest)java.lang.ClassCastException
    > at
    > org.objectstyle.cayenne.access.DataContext.getParentDataDomain(DataContext.java:380)
    > at
    > org.objectstyle.cayenne.access.DataContext.<init>(DataContext.java:339)
    > at
    > au.com.relevance.corporatedb.UsersTest.testGetUserExceptions(UsersTest.java:128)
    > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    > at
    > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    > at
    > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    > at org.jmock.core.VerifyingTestCase.runBare(Unknown Source)
    > at au.com.relevance.corporatedb.UsersTest.main(UsersTest.java:29)
    >
    > On 24/11/2004 3:56 PM, Andrus Adamchik wrote:
    >> Hi Justin,
    >>
    >> DataContext has another constructor that takes an instance of a parent
    >> QueryEngine interface... Just like with all mock objects, you have to
    >> mock the whole tree...
    >>
    >> Andrus
    >>
    >>
    >> On Nov 23, 2004, at 7:05 PM, Justin Deutsch wrote:
    >>
    >>
    > <snip>
    >
    > --
    > Justin Deutsch
    >
    > Relevance... because results count
    >
    > Relevance Phone: +61 (0)2 6241 6400
    > A.B.N. 86 063 403 690 Fax: +61 (0)2 6241 6422
    > Unit 11, Mobile: +61 (0)40 246 55 88
    > Cnr Brookes & Heffernan Sts, E-mail: Justin.Deutsc..elevance.com.au
    > Mitchell ACT 2911 Web: http://www.relevance.com.au



    This archive was generated by hypermail 2.0.0 : Wed Nov 24 2004 - 09:48:47 EST