Once I implemented BatchQueryBuilderFactory and used an ugly hack needed to move it from DataDomain down to Cayenne internals. I think I could make that code cleaner using injection..
2010/5/27 Andrus Adamchik <[email protected]> > I think at some point we will reorg the unit tests to be based on a DI > stack. Need to think about a good design for this... > > In the meantime, can you be more specific - which class will have that > injectable var? Maybe it can be initialized without injection? > > And on a general note, in Cayenne not all stack objects are created via > injection. Either by design (there has to be some level of granularity at > which DI stops and where an object can decide on its own on how to > initialize its composite state) or because we haven't switched them yet. DI > enabled are the high-level stack objects (DataDomain), and common user > extension points, such as DbAdapter or DataSourcFactory. > > Andrus > > > > On May 27, 2010, at 10:42 AM, Andrey Razumovsky wrote: > > No. in main Cayenne code, I want to add injectable var and put code that >> injects default implementation in CayenneServerModule. But that wouldn't >> work at least for unit tests, since injection does not get invoked there. >> What's the best way to fix the situation? >> >> 2010/5/27 Andrus Adamchik <[email protected]> >> >> Are we still talking about unit tests? Can you give an example of what >>> you >>> are trying to accomplish? >>> >>> Andrus >>> >>> >>> On May 27, 2010, at 10:33 AM, Andrey Razumovsky wrote: >>> >>> So does that mean I never can rely on injecting, and must always have a >>> >>>> insurance of default injectable interface implementation in my code? >>>> >>>> 2010/5/27 Andrus Adamchik <[email protected]> >>>> >>>> Not to the unit tests inheriting from CayenneCase and friends. Unit >>>> tests >>>> >>>>> were always bootstrapped in their own way, even in the past (mostly for >>>>> performance reasons). However if you need to define mock services, etc. >>>>> via >>>>> IoC this can be done with a great deal of flexibility. E.g. see >>>>> DataDomainProviderTest.java, DefaultDataSourceFactoryLoaderTest.java >>>>> and >>>>> other tests in the same package. >>>>> >>>>> Andrus >>>>> >>>>> >>>>> >>>>> >>>>> On May 27, 2010, at 9:21 AM, Andrey Razumovsky wrote: >>>>> >>>>> Hi Andrus, >>>>> >>>>> >>>>>> Are new 3.1 DI "modules" (CayenneServerModule) bound to Cayenne >>>>>> bootstrap >>>>>> process? At least, I don't think they are when we're running JUnit >>>>>> tests. >>>>>> Or >>>>>> otherwise, how to "turn on" injecting? >>>>>> >>>>>> -- >>>>>> Andrey >>>>>> >>>>>> >>>>>> >>>>> >>>>> >>>> -- >>>> Andrey >>>> >>>> >>> >>> >> >> -- >> Andrey >> > > -- Andrey
