View Javadoc

1   package liquibase.dbtest.mssql;
2   
3   import java.util.Date;
4   import liquibase.Liquibase;
5   import liquibase.dbtest.AbstractIntegrationTest;
6   import liquibase.exception.MigrationFailedException;
7   import liquibase.exception.ValidationFailedException;
8   import org.junit.Test;
9   
10  /**
11   *
12   * @author lujop
13   */
14  public abstract class AbstractMssqlIntegrationTest extends AbstractIntegrationTest{
15  
16      public AbstractMssqlIntegrationTest(String changelogDir, String url) throws Exception {
17          super(changelogDir, url);
18      }
19  
20      @Override
21      protected boolean shouldRollBack() {
22          return false;
23      }
24  
25      @Test
26      public void smartDataLoad() throws Exception {
27          if (this.getDatabase() == null) {
28              return;
29          }
30          Liquibase liquibase = createLiquibase("changelogs/common/smartDataLoad.changelog.xml");
31          clearDatabase(liquibase);
32          try {
33              liquibase.update(this.contexts);
34          } catch (ValidationFailedException e) {
35              e.printDescriptiveError(System.out);
36              throw e;
37          }
38          try {
39              liquibase.rollback(new Date(0), this.contexts);
40          } catch (ValidationFailedException e) {
41              e.printDescriptiveError(System.out);
42              throw e;
43          }
44      }
45  
46      @Override
47      //Mssql has problems with insert data in autoincrement tables. Because diff detects the id of that inserts and when it is ran the diff
48      //it tries to insert values in identity columns that isn't allowed in mssql
49      @Test(expected = MigrationFailedException.class)
50      public void testRerunDiffChangeLog() throws Exception {
51          if (getDatabase() == null) {
52              throw new MigrationFailedException();
53          }
54          super.testRerunDiffChangeLog();
55      }
56  
57  }