-
Notifications
You must be signed in to change notification settings - Fork 206
Expand file tree
/
Copy pathOracleArrayTest.java
More file actions
45 lines (38 loc) · 1.35 KB
/
OracleArrayTest.java
File metadata and controls
45 lines (38 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package tests.oracleclient;
import io.vertx.ext.unit.TestContext;
import io.vertx.ext.unit.junit.VertxUnitRunner;
import io.vertx.oracleclient.OracleBuilder;
import io.vertx.oracleclient.OracleConnection;
import io.vertx.sqlclient.Pool;
import io.vertx.sqlclient.Tuple;
import org.junit.After;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.runner.RunWith;
import tests.oracleclient.junit.OracleRule;
@RunWith(VertxUnitRunner.class)
public class OracleArrayTest extends OracleTestBase {
@ClassRule
public static OracleRule oracle = OracleRule.SHARED_INSTANCE;
Pool pool;
@Before
public void setUp() throws Exception {
pool = OracleBuilder.pool(builder -> builder
.connectingTo(oracle.options())
.using(vertx));
}
@Test
public void testStringArray(TestContext ctx) {
String[] elements = {"str1", "str2", "str3"};
pool.withConnection(conn -> {
Object stringsArray = ((OracleConnection) conn).createArray("STRING_ARRAY", elements);
String insertSql = "INSERT INTO test_collections( id, string_array_element) VALUES (?, ?)";
return conn.preparedQuery(insertSql).execute(Tuple.of(1, stringsArray));
}).onComplete(ctx.asyncAssertSuccess());
}
@After
public void tearDown(TestContext ctx) throws Exception {
pool.close().onComplete(ctx.asyncAssertSuccess());
}
}