1 package liquibase.maven;
2
3 import java.io.IOException;
4 import java.io.File;
5 import org.apache.maven.it.VerificationException;
6
7 import org.apache.maven.it.Verifier;
8 import org.apache.maven.it.util.ResourceExtractor;
9 import org.junit.Test;
10 import liquibase.database.Database;
11 import liquibase.database.DatabaseConnection;
12 import liquibase.database.DatabaseFactory;
13 import liquibase.test.DatabaseTestContext;
14 import org.junit.Before;
15 import static org.junit.Assert.*;
16
17
18
19
20
21 public class MavenIntegrationTest {
22 private static final String URL="jdbc:hsqldb:file:target/test-classes/maven/liquibase;shutdown=true";
23
24 @Before
25 public void cleanDatabase() throws Exception {
26 DatabaseConnection connection = DatabaseTestContext.getInstance().getConnection(URL);
27 assertNotNull(connection);
28 Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(connection);
29 database.dropDatabaseObjects(null);
30 database.close();
31 DatabaseFactory.reset();
32 }
33
34 @Test
35 public void testUpdate() throws Exception{
36 Verifier verifier=createVerifier();
37
38 verifier.executeGoal( "clean" );
39 verifier.executeGoal( "install" );
40
41
42 verifier.verifyErrorFreeLog();
43
44
45 verifier.resetStreams();
46 }
47
48 @Test
49 public void testRollbackTag() throws Exception {
50 Verifier verifier= createVerifier();
51
52
53 verifier.executeGoal("clean");
54 verifier.executeGoal("liquibase:tag");
55 verifier.executeGoal("package");
56 verifier.executeGoal("liquibase:rollback");
57
58 verifier.executeGoal("liquibase:update");
59
60
61 verifier.verifyErrorFreeLog();
62
63
64 verifier.resetStreams();
65 }
66
67 private Verifier createVerifier() throws IOException, VerificationException {
68 File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/maven" );
69
70
71 Verifier verifier = new Verifier(testDir.getAbsolutePath());
72 verifier.setAutoclean(false);
73 verifier.deleteArtifact("org.liquibase", "liquibase-maven-integration-tests", "1.0-SNAPSHOT", "jar");
74 return verifier;
75 }
76
77 }