Re: out-of-container JNDI

From: Paul Furbacher (pfurbache..ac.com)
Date: Mon Jul 07 2008 - 23:38:28 EDT

  • Next message: Andrus Adamchik: "Re: 'not an instance of declaring class' on Weblogic-Oracle"

    Have you looked at Spring mocks?

    http://static.springframework.org/spring/docs/1.2.x/api/org/springframework/mock/jndi/package-summary.html

    http://forum.springframework.org/showthread.php?t=16670

    http://www.ericholsinger.com/programming/java/junit-testing-jndi-datasources-thinking-outside-of-the-container/

    I used it quite successfully some time ago when I was doing this kind
    of work, along with

            org.springframework.test.AbstractTransactionalSpringContextTests

    or its subclass

             
    org
    .springframework.test.AbstractTransactionalDataSourceSpringContextTests

    Good stuff.

    Paul Furbacher

    On Jul 4, 2008, at 10:32 AM, Jon Sharp wrote:

    > Hey guys,
    >
    > I'm using Cayenne 3.0M3, and have been using JNDI to get my
    > datasource. This works just fine when deploying our app to our
    > Glassfish container, as we have our JNDI resource defined there.
    > However, we are now attempting to do some JUnit testing of our data
    > access layer and therefore need to provide a JNDI reference out-of-
    > container. I've found this helpful blog entry by Randy Carver:
    >
    > http://blogs.sun.com/randystuph/entry/injecting_jndi_datasources_for_junit
    >
    > and it really seemed to address our issue. It seems to get us
    > close, but Cayenne doesn't seem to pick up on our "jdbc/sunrise"
    > reference. (this matches the reference in our Cayenne data map.)
    > It attempts to find a resource by using the modeler user
    > preferences, instead. The JNDI docs I found relating to Cayenne
    > seemed to be for 1.2, so I don't know how relevant they still are.
    > They seem to indicate that Cayenne will look for the "default"
    > provider first, then the user prefs. My question is, do we need to
    > do anything else in our JUnit setup method to make our "jdbc/
    > sunrise" reference the "default"?
    >
    > Does anyone do out-of-container JUnit testing with Cayenne and JNDI?
    >
    > Thanks,
    > Jon
    >
    > --
    > Jon Sharp
    > CTO & Senior Engineer
    > Campground Automation Systems, Inc.
    > jo..ampgroundautomation.com
    > (615) 579-5868
    > www.campgroundautomation.com



    This archive was generated by hypermail 2.0.0 : Mon Jul 07 2008 - 23:39:14 EDT