-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored callable statement tests to avoid running a test twice
- Loading branch information
1 parent
4a97907
commit 73ce0fd
Showing
3 changed files
with
61 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/test/java/net/snowflake/client/jdbc/CallableStatementITBase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package net.snowflake.client.jdbc; | ||
|
||
import java.sql.Connection; | ||
import java.sql.SQLException; | ||
import java.sql.Statement; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
|
||
public class CallableStatementITBase extends BaseJDBCTest { | ||
public static Connection getConnection() throws SQLException { | ||
return BaseJDBCTest.getConnection(); | ||
} | ||
|
||
public static Connection getConnection(String queryResultFormat) throws SQLException { | ||
Connection conn = BaseJDBCTest.getConnection(); | ||
try (Statement stmt = conn.createStatement()) { | ||
stmt.execute("alter session set jdbc_query_result_format = '" + queryResultFormat + "'"); | ||
} | ||
return conn; | ||
} | ||
|
||
private final String createStoredProcedure = | ||
"create or replace procedure square_it(num FLOAT) returns float not " | ||
+ "null language javascript as $$ return NUM * NUM; $$"; | ||
private final String createSecondStoredProcedure = | ||
"create or replace procedure add_nums(x DOUBLE, y DOUBLE) " | ||
+ "returns double not null language javascript as $$ return X + Y; $$"; | ||
private final String deleteStoredProcedure = "drop procedure if exists square_it(FLOAT)"; | ||
private final String deleteSecondStoredProcedure = "drop procedure if exists add_nums(INT, INT)"; | ||
|
||
@BeforeEach | ||
public void setUp() throws SQLException { | ||
try (Connection con = getConnection(); | ||
Statement statement = con.createStatement()) { | ||
statement.execute(createStoredProcedure); | ||
statement.execute(createSecondStoredProcedure); | ||
} | ||
} | ||
|
||
@AfterEach | ||
public void tearDown() throws SQLException { | ||
try (Connection con = getConnection(); | ||
Statement statement = con.createStatement()) { | ||
statement.execute(deleteStoredProcedure); | ||
statement.execute(deleteSecondStoredProcedure); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters