Changeset 24 for trunk


Ignore:
Timestamp:
Sep 22, 2010, 10:01:20 PM (14 years ago)
Author:
fmguler
Message:

Refs #3 - Added liquibase library for test database operations, which means we can update and rollback a test database in the test scenarios. Now we should add test scenarios to be tested on this database.

Location:
trunk/fmgVen
Files:
3 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/fmgVen/lib/nblibraries.properties

    r23 r24  
    66    ${base}/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar 
    77libs.Test.classpath=\ 
    8     ${base}/test/postgresql-8.4-701.jdbc3.jar 
     8    ${base}/test/postgresql-8.4-701.jdbc3.jar;\ 
     9    ${base}/test/liquibase-1.9.5.jar 
    910libs.Ven.classpath=\ 
    1011    ${base}/ven/spring-beans.jar;\ 
  • trunk/fmgVen/nbproject/project.properties

    r23 r24  
    3939    ${javac.classpath}:\ 
    4040    ${build.classes.dir}:\ 
    41     ${libs.junit.classpath} 
     41    ${libs.junit.classpath}:\ 
     42    ${libs.Test.classpath} 
    4243javadoc.additionalparam= 
    4344javadoc.author=false 
  • trunk/fmgVen/test/com/fmguler/ven/sample/Sample.java

    r23 r24  
    2020import com.fmguler.ven.Ven; 
    2121import com.fmguler.ven.sample.domain.SomeDomainObject; 
     22import java.sql.SQLException; 
     23import java.util.Locale; 
    2224import javax.sql.DataSource; 
     25import liquibase.FileSystemFileOpener; 
     26import liquibase.exception.JDBCException; 
     27import liquibase.exception.LiquibaseException; 
    2328import org.springframework.jdbc.datasource.DriverManagerDataSource; 
     29import liquibase.Liquibase; 
     30import liquibase.database.Database; 
     31import liquibase.database.DatabaseFactory; 
    2432 
    2533/** 
     
    2937public class Sample { 
    3038    public static void main(String[] args) { 
     39        buildDatabase(); 
    3140        test1(); 
     41        //rollbackDatabase(); 
    3242    } 
    3343 
     
    5161        ds.setUsername("postgres"); 
    5262        ds.setPassword("qwerty"); 
    53         ds.setUrl("jdbc:postgresql://127.0.0.1:5432/vendb"); 
     63        ds.setUrl("jdbc:postgresql://127.0.0.1:5432/ven-test"); 
    5464        return ds; 
    5565    } 
     66 
     67    private static void buildDatabase() { 
     68        try { 
     69            Locale currLocale = Locale.getDefault(); 
     70            Locale.setDefault(Locale.ENGLISH); 
     71            Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(getDataSource().getConnection()); 
     72            Liquibase liquibase = new Liquibase("etc/test-db/test-db-changelog.xml", new FileSystemFileOpener(), database); 
     73            liquibase.update(""); 
     74            Locale.setDefault(currLocale); 
     75        } catch (SQLException ex) { 
     76            ex.printStackTrace(); 
     77        } catch (JDBCException ex) { 
     78            ex.printStackTrace(); 
     79        } catch (LiquibaseException ex) { 
     80            ex.printStackTrace(); 
     81        } 
     82    } 
     83 
     84    private static void rollbackDatabase() { 
     85        try { 
     86            Locale currLocale = Locale.getDefault(); 
     87            Locale.setDefault(Locale.ENGLISH); 
     88            Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(getDataSource().getConnection()); 
     89            Liquibase liquibase = new Liquibase("etc/test-db/test-db-changelog.xml", new FileSystemFileOpener(), database); 
     90            //liquibase.rollback(51, ""); 
     91            liquibase.rollback("0", ""); 
     92            Locale.setDefault(currLocale); 
     93        } catch (SQLException ex) { 
     94            ex.printStackTrace(); 
     95        } catch (JDBCException ex) { 
     96            ex.printStackTrace(); 
     97        } catch (LiquibaseException ex) { 
     98            ex.printStackTrace(); 
     99        } 
     100    } 
    56101} 
Note: See TracChangeset for help on using the changeset viewer.