I'm having trouble with an integration test (I hate calling them "unit tests" 
if they really aren't) of my CXF app.  My problem is probably only with Spring, 
but perhaps people here have run into this.

I define some JNDI references in my Spring context to datasources.  This will 
work fine when I deploy the WAR to my appserver, where I'll define the 
datasources, but in my integration test I have to manually create those 
datasources.

The code in my test class looks something like this:

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({"/applicationContext.xml"})
public class MyIntTest {
    @BeforeClass
    public static void init() {
        SimpleNamingContextBuilder builder = new SimpleNamingContextBuilder();
        DataSource  someds  =
                new DriverManagerDataSource(System.getProperty("test.some.url"),
                                            
System.getProperty("test.some.userName"),
                                            
System.getProperty("test.some.password"));
        builder.bind("jdbc/someds", someds);
    }

The reference in the context looks like this:

    <jee:jndi-lookup jndi-name="jdbc/someds" id="someDataSource"/>

The problem (or at least one of the problems) is that this "init()" method will 
not get executed until after the context is finished initializing.  At a 
minimum, I need to be able to execute this method before the appcontext is 
initialized.

It's starting to look like I can't use the Spring runner, and will have to 
initialize Spring manually after I bind the datasource.

Reply via email to