Announcement Announcement Module
Collapse
No announcement yet.
Setting up a test database Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Setting up a test database

    Hi all
    I'm looking for a way to test my Spring JDBCTemplate DAOs. To be brief I'm thinking of using an in-memory Hsqldb database, and populating it using DBunit.

    The trouble is creating the tables. I can't find a simple way of doing it.
    Dbunit complains if I try to insert data from a flat dataset when the table does not exist.

    I wrote a simple script executer which implements the InitializingBean interface and runs my CREATE scripts once it's datasource property is set.
    I also found an example using a FactoryBean to return a datasource with the inserted tables.
    But it sounds like reinventing the wheel. I'm sure this has been done and there is a 'proper' way of doing it.

    Could anybody point me the way.

    thanks
    w.

    PS In other words, I'm looking for a way to emulate the autocreate property of hibernate.

  • #2
    Dude, you may try this one for some little references for Setting up a test database... this may help you a little dude...http://www.ogsadai.org.uk/documentat...dbs/index.html





    _________________
    Indianapolis Web Design

    Comment


    • #3
      bengomez:
      You seam to have misunderstood my problem. It is not "how do I create a test database?", it's more to do with "how do I run my SQL CREATE TABLE scripts when running a unit test on a in-memory Hsqldb database"

      Comment


      • #4
        Setting up a test database

        I want the answer to this, too. I want to enter commands like this and it's not working:

        protected void onSetUpInTransaction()
        {
        String[] dataSql = getDataSql();
        for (String sql : dataSql)
        {
        jdbcTemplate.execute(sql);
        }
        }
        private String[] getDataSql()
        {
        "Delete from TABLE",
        "Insert into TABLE (ID,NAME) values (1,'name1')"
        }

        Comment

        Working...
        X