/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package datahelper;

import java.sql.DriverManager;
import org.junit.Assert;
import org.junit.Test;

/**
 *
 * @author Lisewski
 */
public class DataHelperTest1 {

    public DataHelperTest1() {
    }
    /**
     * Test of CopyData method, of class DataHelper.
     */

    
    @Test
    public void testH2ToSQLIte() throws Exception {
        System.out.println("CopyData from H2 to SQLite");
        
        Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
        Class.forName("org.sqlite.JDBC");
        Class.forName("org.h2.Driver");
        
//        var sourceConnection = DriverManager.getConnection("jdbc:sqlserver://aws.database;databaseName=AlexisPTSTest;user=gpspl;password=yW2S6KXdY8");
        var sourceConnection = DriverManager.getConnection("jdbc:sqlite:c:/java/db/test.db");
        var targetConnection = DriverManager.getConnection("jdbc:h2:c:/GPS/h2.db;AUTO_SERVER=TRUE;user=sa");

        var sourceSQL = "SELECT * FROM Authorisation";
        var targetTable = "Authorisation";
        var iRows = DataHelper.CopyData(sourceConnection, targetConnection, sourceSQL, targetTable, true);
//        var iRows = DataHelper.CopyData(targetConnection, sourceConnection, sourceSQL, targetTable, true);

        System.out.println(iRows);
        Assert.assertTrue(iRows > 0);
    }

}
