Examples of DbSchemaUtil


Examples of ch.inftec.ju.testing.db.DbSchemaUtil

    this.jtaTestBean = this.ctx.getBean(JtaTestBean.class);
   
    // Run liquibase update and create default data
    // Note that we need an unmanaged DataSource to do so
    DataSource ds1 = ctx.getBean("jpaDb1DataSource", DataSource.class);
    new DbSchemaUtil(JuConnUtils.createByDataSource(ds1)).prepareDefaultSchemaAndTestData();
   
    DataSource ds2 = ctx.getBean("jpaDb2DataSource", DataSource.class);
    new DbSchemaUtil(JuConnUtils.createByDataSource(ds2)).prepareDefaultSchemaAndTestData();
  }
View Full Code Here

Examples of ch.inftec.ju.testing.db.DbSchemaUtil

  /**
   * Make sure we can set Liquibaes changeLog parameters.
   */
  @Test
  public void canSet_changeLogParameters() {
    DbSchemaUtil su = new DbSchemaUtil(this.em);

    su.clearSchema();
    su.liquibaseChangeLog()
        .changeLogResource("ch/inftec/ju/dbutil/test/DbSchemaUtilTest_liquibase_canUseChangeLogParameters.xml")
        .parameter("myTableName", "TestingEntity_LB")
        .parameter("myName", "FooBar")
        .run();

View Full Code Here

Examples of ch.inftec.ju.testing.db.DbSchemaUtil

public class AbstractDbTestTransactionTest extends AbstractDbTest {
  @Override
  protected void runDbInitializationScripts(JuEmfUtil emfUtil) {
    try (EmfWork ew = emfUtil.startWork()) {
      new DbSchemaUtil(ew.getEm()).prepareDefaultSchemaAndTestData();;
    }
  }
View Full Code Here

Examples of ch.inftec.ju.testing.db.DbSchemaUtil

 
  @Test
  public void canListSequences() {
    JuAssumeUtils.dbIsNot(this.emUtil, DbType.MYSQL); // Sequences are not supported by MqSQL
   
    new DbSchemaUtil(this.emUtil).runLiquibaseChangeLog("ch/inftec/ju/dbutil/test/JuEmUtilTest_canListSequences.xml");
   
    List<String> sequenceNames = this.emUtil.getSequenceNames();
    Assert.assertTrue(sequenceNames.contains("TESTSEQUENCE"));
  }
View Full Code Here

Examples of ch.inftec.ju.testing.db.DbSchemaUtil

    Assert.assertTrue(sequenceNames.contains("TESTSEQUENCE"));
  }
 
  @Test
  public void canResetIdentityGeneration_forPrimeryKeys() {
    new DbSchemaUtil(this.emUtil).prepareDefaultSchemaAndTestData();
   
    // Try to set identity generation to 10
    this.emUtil.resetIdentityGenerationOrSequences(10);
    TestingEntity te1 = new TestingEntity();
    this.em.persist(te1);
View Full Code Here

Examples of ch.inftec.ju.testing.db.DbSchemaUtil

 
  @Test
  public void canResetIdentityGeneration_forSequences() {
    JuAssumeUtils.dbIsNot(this.emUtil, DbType.MYSQL);
   
    DbSchemaUtil su = new DbSchemaUtil(this.emUtil);
    su.prepareDefaultSchemaAndTestData();
    su.runLiquibaseChangeLog("ch/inftec/ju/dbutil/test/JuEmUtilTest_canListSequences.xml");
    this.emUtil.resetIdentityGenerationOrSequences(1); // Is done by prepareDefaultSchemaAndTestData, but the testSequence might just have been created
   
    //CREATE SEQUENCE PUBLIC.testSequence
    Assert.assertEquals(new Long(1L), this.emUtil.getNextValueFromSequence("testSequence"));
   
View Full Code Here

Examples of ch.inftec.ju.testing.db.DbSchemaUtil

    Assert.assertEquals(new Long(10L), this.emUtil.getNextValueFromSequence("testSequence"));
  }
 
  @Test
  public void canEvaluate_primaryKeyColumnName_withSingleColumn() {
    new DbSchemaUtil(this.emUtil).prepareDefaultSchemaAndTestData();
   
    List<String> primaryKeyColumns = this.emUtil.getPrimaryKeyColumns("TestingEntity");
    Assert.assertEquals(1, primaryKeyColumns.size());
    Assert.assertEquals("id", primaryKeyColumns.get(0).toLowerCase());
  }
View Full Code Here

Examples of ch.inftec.ju.testing.db.DbSchemaUtil

    Assert.assertEquals("id", primaryKeyColumns.get(0).toLowerCase());
  }
 
  @Test
  public void canEvaluate_primaryKeyColumnName_withMultipleColumns() {
    new DbSchemaUtil(this.emUtil).prepareDefaultSchemaAndTestData();
   
    List<String> primaryKeyColumns = this.emUtil.getPrimaryKeyColumns("Team_Player");
    Assert.assertEquals(2, primaryKeyColumns.size());
    Assert.assertEquals("players_id", primaryKeyColumns.get(0).toLowerCase());
    Assert.assertEquals("teams_id", primaryKeyColumns.get(1).toLowerCase());
View Full Code Here

Examples of ch.inftec.ju.testing.db.DbSchemaUtil

import ch.inftec.ju.testing.db.DbSchemaUtil;

public class DbHandlerTest extends AbstractDbTest {
  @Test
  public void canResetIdentityGeneration_forPrimeryKeys() {
    new DbSchemaUtil(this.emUtil).prepareDefaultSchemaAndTestData();
   
    String lowerStmt = this.connUtil.getDbHandler().wrapInLowerString("te.name");
   
    Query q = this.em.createNativeQuery(String.format(
        "select %s as lowName, te.name from TestingEntity te where %s = 'test1'" // Also test if the statement works in comparisons
View Full Code Here

Examples of ch.inftec.ju.testing.db.DbSchemaUtil

import ch.inftec.ju.util.JuCollectionUtils;

public class DbSchemaUtilTest extends AbstractDbTest {
  @Test
  public void tablesAreCreated_usingLiquibaseExplicitly() {
    DbSchemaUtil su = new DbSchemaUtil(this.em);
   
    su.clearSchema();
    Assert.assertFalse(JuCollectionUtils.collectionContainsIgnoreCase(this.emUtil.getTableNames(), "TestingEntity_LB"));
   
    su.runLiquibaseChangeLog("ch/inftec/ju/dbutil/test/LiquibaseTestDataTest_testingEntity.xml");
   
    Assert.assertTrue(JuCollectionUtils.collectionContainsIgnoreCase(this.emUtil.getTableNames(), "TestingEntity_LB"));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.