Search in sources :

Example 1 with ClassRelativeResourceLoader

use of cn.taketoday.core.io.ClassRelativeResourceLoader in project today-framework by TAKETODAY.

the class EmbeddedDatabaseBuilderTests method createSameSchemaTwiceWithGeneratedUniqueDbNames.

@Test
public void createSameSchemaTwiceWithGeneratedUniqueDbNames() throws Exception {
    EmbeddedDatabase db1 = // 
    new EmbeddedDatabaseBuilder(new ClassRelativeResourceLoader(getClass())).addScripts("db-schema-without-dropping.sql", // 
    "db-test-data.sql").generateUniqueName(// 
    true).build();
    JdbcTemplate template1 = new JdbcTemplate(db1);
    assertNumRowsInTestTable(template1, 1);
    template1.update("insert into T_TEST (NAME) values ('Sam')");
    assertNumRowsInTestTable(template1, 2);
    EmbeddedDatabase db2 = // 
    new EmbeddedDatabaseBuilder(new ClassRelativeResourceLoader(getClass())).addScripts("db-schema-without-dropping.sql", // 
    "db-test-data.sql").generateUniqueName(// 
    true).build();
    assertDatabaseCreated(db2);
    db1.shutdown();
    db2.shutdown();
}
Also used : ClassRelativeResourceLoader(cn.taketoday.core.io.ClassRelativeResourceLoader) JdbcTemplate(cn.taketoday.jdbc.core.JdbcTemplate) Test(org.junit.jupiter.api.Test)

Example 2 with ClassRelativeResourceLoader

use of cn.taketoday.core.io.ClassRelativeResourceLoader in project today-infrastructure by TAKETODAY.

the class EmbeddedDatabaseBuilderTests method createSameSchemaTwiceWithGeneratedUniqueDbNames.

@Test
public void createSameSchemaTwiceWithGeneratedUniqueDbNames() throws Exception {
    EmbeddedDatabase db1 = // 
    new EmbeddedDatabaseBuilder(new ClassRelativeResourceLoader(getClass())).addScripts("db-schema-without-dropping.sql", // 
    "db-test-data.sql").generateUniqueName(// 
    true).build();
    JdbcTemplate template1 = new JdbcTemplate(db1);
    assertNumRowsInTestTable(template1, 1);
    template1.update("insert into T_TEST (NAME) values ('Sam')");
    assertNumRowsInTestTable(template1, 2);
    EmbeddedDatabase db2 = // 
    new EmbeddedDatabaseBuilder(new ClassRelativeResourceLoader(getClass())).addScripts("db-schema-without-dropping.sql", // 
    "db-test-data.sql").generateUniqueName(// 
    true).build();
    assertDatabaseCreated(db2);
    db1.shutdown();
    db2.shutdown();
}
Also used : ClassRelativeResourceLoader(cn.taketoday.core.io.ClassRelativeResourceLoader) JdbcTemplate(cn.taketoday.jdbc.core.JdbcTemplate) Test(org.junit.jupiter.api.Test)

Aggregations

ClassRelativeResourceLoader (cn.taketoday.core.io.ClassRelativeResourceLoader)2 JdbcTemplate (cn.taketoday.jdbc.core.JdbcTemplate)2 Test (org.junit.jupiter.api.Test)2