mirror of
https://github.com/rasilon/ujetl.git
synced 2026-04-11 18:39:30 +00:00
Add pre and post SQL
This commit is contained in:
parent
ddc67f3a41
commit
8fdbc6a78e
4 changed files with 95 additions and 3 deletions
|
|
@ -45,6 +45,8 @@ public class TestJob {
|
|||
"SELECT -1 AS key",
|
||||
"SELECT id,dat FROM src WHERE id > ?",
|
||||
"INSERT INTO dest VALUES(?,?)",
|
||||
null,
|
||||
null,
|
||||
100,
|
||||
100,
|
||||
100
|
||||
|
|
|
|||
62
src/test/java/com/rasilon/ujetl/TestPrePost.java
Normal file
62
src/test/java/com/rasilon/ujetl/TestPrePost.java
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
package com.rasilon.ujetl;
|
||||
|
||||
import java.sql.*;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.MethodOrderer.Alphanumeric;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
|
||||
public class TestPrePost {
|
||||
|
||||
private static String jdbcURL = "jdbc:h2:mem:dbtest";
|
||||
@Test
|
||||
public void test002verifyH2Works() {
|
||||
try {
|
||||
Connection conn = DriverManager.getConnection(jdbcURL, "sa", "");
|
||||
conn.close();
|
||||
} catch(Exception e) {
|
||||
fail(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPrePost() {
|
||||
try (
|
||||
Connection src = DriverManager.getConnection(jdbcURL, "sa", "");
|
||||
Connection dest = DriverManager.getConnection(jdbcURL, "sa", "");
|
||||
|
||||
) {
|
||||
src.createStatement().executeUpdate("CREATE TABLE src(id bigint not null primary key, dat varchar);");
|
||||
dest.createStatement().executeUpdate("CREATE TABLE dest(id bigint not null primary key, dat varchar);");
|
||||
PreparedStatement inserter = src.prepareStatement("INSERT INTO src(id,dat) VALUES(?,'banana')");
|
||||
for(int i=0; i<10000; i++) {
|
||||
inserter.setInt(1,i);
|
||||
inserter.executeUpdate();
|
||||
}
|
||||
|
||||
Job j = new Job(
|
||||
src,
|
||||
dest,
|
||||
"jUnit Test Config",
|
||||
"jUnit Test Job",
|
||||
"SELECT -1 AS key",
|
||||
"SELECT id,dat FROM src WHERE id > ?",
|
||||
"INSERT INTO tmp_dest VALUES(?,?)",
|
||||
"CREATE TEMP TABLE tmp_dest(id bigint not null primary key, dat varchar);",
|
||||
"INSERT INTO dest SELECT * from tmp_dest;",
|
||||
100,
|
||||
100,
|
||||
100
|
||||
);
|
||||
j.start();
|
||||
j.join();
|
||||
// do stuff
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
fail(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue