File tree 1 file changed +27
-0
lines changed
libraries-data-db/src/test/java/com/baeldung/libraries/h2
1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com .baeldung .libraries .h2 ;
2
+
3
+ import org .junit .jupiter .api .Assertions ;
4
+ import org .junit .jupiter .api .Test ;
5
+ import java .sql .*;
6
+
7
+ public class H2JUnitTest {
8
+
9
+ @ Test
10
+ public static void whenConnectingToSpecificSchema_ShouldReturnTheSpecificSchema () throws Exception {
11
+ Connection conn = DriverManager .getConnection (
12
+ "jdbc:h2:~/TEST_DB;INIT=CREATE SCHEMA IF NOT EXISTS TEST_SCHEMA\\ ;SET SCHEMA TEST_SCHEMA" ,
13
+ "sa" ,
14
+ "" );
15
+
16
+ Statement stmt =conn .createStatement ();
17
+
18
+ ResultSet rs =stmt .executeQuery ("SELECT CURRENT_SCHEMA" );
19
+ rs .first ();
20
+
21
+ String actualSchema = rs .getString (1 );
22
+ String expectedSchema = new String ("TEST_SCHEMA" );
23
+
24
+ Assertions .assertTrue (actualSchema .equals (expectedSchema ));
25
+ }
26
+
27
+ }
You can’t perform that action at this time.
0 commit comments