FAQ
Hi all.

Just out of curiosity; how are you guys populating your test DBs before running tests? Has anyone written something brilliant to do it with e.g. .yml-files (via Cayenne)? Are you doing it via SQL-scripts? In code perhaps?

I’m currently creating my test DBs in code (using Cayenne) and it becomes cumbersome when they reach a certain size :).

Cheers,
- hugi

Search Discussions

  • Aristedes Maniatis at Mar 16, 2016 at 12:59 pm

    On 16/03/2016 9:31pm, Hugi Thordarson wrote:
    Hi all.

    Just out of curiosity; how are you guys populating your test DBs before running tests? Has anyone written something brilliant to do it with e.g. .yml-files (via Cayenne)? Are you doing it via SQL-scripts? In code perhaps?

    I’m currently creating my test DBs in code (using Cayenne) and it becomes cumbersome when they reach a certain size :).
    http://dbunit.sourceforge.net/ will do the trick for you. That combined with Derby's in-memory mode.

    Ari




    --
    -------------------------->
    Aristedes Maniatis
    GPG fingerprint CBFB 84B4 738D 4E87 5E5C 5EFA EF6A 7D2E 3E49 102A
  • Michael Gentry at Mar 16, 2016 at 10:22 pm
    For H2, I've used:

    http://www.h2database.com/javadoc/org/h2/tools/RunScript.html

    Then create some SQL scripts with bulk inserts of test data.

    mrg

    On Wed, Mar 16, 2016 at 6:31 AM, Hugi Thordarson wrote:

    Hi all.

    Just out of curiosity; how are you guys populating your test DBs before
    running tests? Has anyone written something brilliant to do it with e.g.
    .yml-files (via Cayenne)? Are you doing it via SQL-scripts? In code perhaps?

    I’m currently creating my test DBs in code (using Cayenne) and it becomes
    cumbersome when they reach a certain size :).

    Cheers,
    - hugi
  • Hugi Thordarson at Mar 17, 2016 at 1:33 pm
    Thanks, Michael and Ari! I’m going to look at both this and DBUnit (I’m currently using H2 so RunScript looks like it might fit the bill).

    Cheers,
    - hugi



    On 16. mar. 2016, at 22:22, Michael Gentry wrote:

    For H2, I've used:

    http://www.h2database.com/javadoc/org/h2/tools/RunScript.html

    Then create some SQL scripts with bulk inserts of test data.

    mrg

    On Wed, Mar 16, 2016 at 6:31 AM, Hugi Thordarson wrote:

    Hi all.

    Just out of curiosity; how are you guys populating your test DBs before
    running tests? Has anyone written something brilliant to do it with e.g.
    .yml-files (via Cayenne)? Are you doing it via SQL-scripts? In code perhaps?

    I’m currently creating my test DBs in code (using Cayenne) and it becomes
    cumbersome when they reach a certain size :).

    Cheers,
    - hugi
  • Michael Gentry at Mar 17, 2016 at 1:46 pm
    If it helps, here is one of my test classes that used RunScript to load
    data:

    public abstract class TestDatabaseBase extends TestBase
    {
         private static final Log log =
    LogFactory.getLog(TestDatabaseBase.class);

         @BeforeClass
         public static void loadSQL() throws SQLException
         {
             log.info("Loading Organizations.");

    RunScript.execute(CayenneUtils.getDataNodeConnection(CayenneUtils.createDataContext()),
                               new
    InputStreamReader(ClassLoader.getSystemResourceAsStream("sql/organizations.sql")));

             log.info("Loading Organizational Units.");

    RunScript.execute(CayenneUtils.getDataNodeConnection(CayenneUtils.createDataContext()),
                               new
    InputStreamReader(ClassLoader.getSystemResourceAsStream("sql/organizational_units.sql")));
         }
    }

    (Let me know if you need CayenneUtils.getDataNodeConnection() ...)

    Part of my organizations.sql file:

    insert into s_organizations
    (pk, code, name, smca)
    values
    (100, 'ARMY', 'Army', 1),
    (101, 'NAVY', 'Navy', 1),
    (102, 'AF', 'Air Force', 1),
    ...........
    (???, '???', '???', 0); -- close it off

    UPDATE AUTO_PK_SUPPORT SET NEXT_ID = 160 WHERE TABLE_NAME =
    'l_organizations';



    mrg

    On Thu, Mar 17, 2016 at 9:33 AM, Hugi Thordarson wrote:

    Thanks, Michael and Ari! I’m going to look at both this and DBUnit (I’m
    currently using H2 so RunScript looks like it might fit the bill).
    Cheers,
    - hugi



    On 16. mar. 2016, at 22:22, Michael Gentry wrote:

    For H2, I've used:

    http://www.h2database.com/javadoc/org/h2/tools/RunScript.html

    Then create some SQL scripts with bulk inserts of test data.

    mrg

    On Wed, Mar 16, 2016 at 6:31 AM, Hugi Thordarson wrote:

    Hi all.

    Just out of curiosity; how are you guys populating your test DBs before
    running tests? Has anyone written something brilliant to do it with
    e.g.
    .yml-files (via Cayenne)? Are you doing it via SQL-scripts? In code
    perhaps?
    I’m currently creating my test DBs in code (using Cayenne) and it
    becomes
    cumbersome when they reach a certain size :).

    Cheers,
    - hugi

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupuser @
categoriescayenne
postedMar 16, '16 at 10:32a
activeMar 17, '16 at 1:46p
posts5
users4
websitecayenne.apache.org

People

Translate

site design / logo © 2021 Grokbase