Package ch.inftec.ju.testing.db

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


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


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

    Assert.assertTrue(JuCollectionUtils.collectionContainsIgnoreCase(this.emUtil.getTableNames(), "TestingEntity_LB"));
  }
 
  @Test
  public void tablesAreCreated_usingFlywayExplicitly() {
    DbSchemaUtil su = new DbSchemaUtil(this.em);
   
    su.clearSchema();
    Assert.assertFalse(JuCollectionUtils.collectionContainsIgnoreCase(this.emUtil.getTableNames(), "TESTINGENTITY_FW"));
   
    su.runFlywayMigration("db/DbSchemaUtilTest-migration");
   
    Assert.assertTrue(JuCollectionUtils.collectionContainsIgnoreCase(this.emUtil.getTableNames(), "TESTINGENTITY_FW"));
  }
View Full Code Here

   * Check if we can use the replaceOrExists tag. Liquibase doesn't support it with Derby, throwing an Exception.
   * Therefore we filter the change logs before submitting them to Liquibase.
   */
  @Test
  public void liquibase_canUseReplaceOrExists() {
    DbSchemaUtil su = new DbSchemaUtil(this.em);
   
    su.clearSchema();
    su.runLiquibaseChangeLog("ch/inftec/ju/dbutil/test/DbSchemaUtilTest_liquibase_canUseReplaceOrExists.xml");
  }
View Full Code Here

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

 
  @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

    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

 
  @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

    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

    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

TOP

Related Classes of ch.inftec.ju.testing.db.DbSchemaUtil

Copyright © 2018 www.massapicom. 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.