Announcement Announcement Module
Collapse
No announcement yet.
Where is SchemaExport? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Where is SchemaExport?

    Woops! I wish I could change the title: It should read "How to use DBUnit with Hibernate Session?".

    I just inherited a junit test that runs and passes. Since I want to modify it to use DBUnit and I'm encountering obstacles.

    Here is some new code I inherited:
    Code:
    @RunWith(SpringJUnit4ClassRunner.class) 
    @ContextConfiguration(locations={"file:spring-configuration/unit-testing-config.xml"}) 
    public abstract class AbstractTestCase { 
    ... 
    // common ancestor sets up log4j 
    }
    The descendants of this unit test are correctly extracting the username, password, driver name, database URL from the spring configuration files for hibernate and creating a hibernate session using the "@autowired" feature. This is very clever and I've spent all evening figuring out how this works.

    Now DBUnit needs this information (username, password, driver name, URL) too. How do I get it?
    (1) Can I extract it from the hibernate session object? I tried and I could not find it in the Session object using the eclipse debugger.
    (2) Where is the application context? I cannot find that either. Maybe I could read it in again and extract the username, password, URL etc... from the spring configuration file redundantly a second time? I've tried this too and I cannot make it work. I get another instance of the hibernate session object from which I cannot extact the username, password, URL and driver name.

    (3) Maybe I could make DBUnit work with a hibernate session object instead? I'm looking in the dbunit docs and cannot find any accommodation of such.

    (4) Is there a counterpart to SpringJUnit4ClassRunner.class that works with main programs?


    Thanks,
    Siegfried
    Last edited by siegfried; Sep 13th, 2009, 12:17 PM. Reason: clarify
Working...
X