|
| 1 | +package tests.oracleclient; |
| 2 | + |
| 3 | +import io.vertx.ext.unit.TestContext; |
| 4 | +import io.vertx.ext.unit.junit.VertxUnitRunner; |
| 5 | +import io.vertx.oracleclient.OracleBuilder; |
| 6 | +import io.vertx.oracleclient.OracleConnection; |
| 7 | +import io.vertx.sqlclient.Pool; |
| 8 | +import io.vertx.sqlclient.Tuple; |
| 9 | +import org.junit.After; |
| 10 | +import org.junit.Before; |
| 11 | +import org.junit.ClassRule; |
| 12 | +import org.junit.Test; |
| 13 | +import org.junit.runner.RunWith; |
| 14 | +import tests.oracleclient.junit.OracleRule; |
| 15 | + |
| 16 | +@RunWith(VertxUnitRunner.class) |
| 17 | +public class OracleArrayTest extends OracleTestBase { |
| 18 | + |
| 19 | + @ClassRule |
| 20 | + public static OracleRule oracle = OracleRule.SHARED_INSTANCE; |
| 21 | + |
| 22 | + Pool pool; |
| 23 | + |
| 24 | + @Before |
| 25 | + public void setUp() throws Exception { |
| 26 | + pool = OracleBuilder.pool(builder -> builder |
| 27 | + .connectingTo(oracle.options()) |
| 28 | + .using(vertx)); |
| 29 | + } |
| 30 | + |
| 31 | + @Test |
| 32 | + public void testStringArray(TestContext ctx) { |
| 33 | + String[] elements = {"str1", "str2", "str3"}; |
| 34 | + pool.withConnection(conn -> { |
| 35 | + Object stringsArray = ((OracleConnection) conn).createArray("STRING_ARRAY", elements); |
| 36 | + String insertSql = "INSERT INTO test_collections( id, string_array_element) VALUES (?, ?)"; |
| 37 | + return conn.preparedQuery(insertSql).execute(Tuple.of(1, stringsArray)); |
| 38 | + }).onComplete(ctx.asyncAssertSuccess()); |
| 39 | + } |
| 40 | + |
| 41 | + @After |
| 42 | + public void tearDown(TestContext ctx) throws Exception { |
| 43 | + pool.close().onComplete(ctx.asyncAssertSuccess()); |
| 44 | + } |
| 45 | +} |
0 commit comments