|
| 1 | +/* |
| 2 | + * Copyright (c) 2011-2021 Contributors to the Eclipse Foundation |
| 3 | + * |
| 4 | + * This program and the accompanying materials are made available under the |
| 5 | + * terms of the Eclipse Public License 2.0 which is available at |
| 6 | + * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 |
| 7 | + * which is available at https://www.apache.org/licenses/LICENSE-2.0. |
| 8 | + * |
| 9 | + * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 |
| 10 | + */ |
| 11 | + |
| 12 | +package io.vertx.oracleclient.test; |
| 13 | + |
| 14 | +import io.vertx.ext.unit.TestContext; |
| 15 | +import io.vertx.ext.unit.junit.VertxUnitRunner; |
| 16 | +import io.vertx.oracleclient.OraclePool; |
| 17 | +import io.vertx.oracleclient.test.junit.OracleRule; |
| 18 | +import io.vertx.sqlclient.PoolOptions; |
| 19 | +import org.junit.After; |
| 20 | +import org.junit.Before; |
| 21 | +import org.junit.ClassRule; |
| 22 | +import org.junit.Test; |
| 23 | +import org.junit.runner.RunWith; |
| 24 | + |
| 25 | +import java.time.OffsetDateTime; |
| 26 | + |
| 27 | +import static java.time.temporal.ChronoUnit.MINUTES; |
| 28 | +import static org.hamcrest.CoreMatchers.instanceOf; |
| 29 | +import static org.hamcrest.CoreMatchers.is; |
| 30 | +import static org.hamcrest.MatcherAssert.assertThat; |
| 31 | +import static org.junit.Assert.assertEquals; |
| 32 | + |
| 33 | +@RunWith(VertxUnitRunner.class) |
| 34 | +public class OracleQueriesTest extends OracleTestBase { |
| 35 | + |
| 36 | + @ClassRule |
| 37 | + public static OracleRule oracle = OracleRule.SHARED_INSTANCE; |
| 38 | + |
| 39 | + OraclePool pool; |
| 40 | + |
| 41 | + @Before |
| 42 | + public void setUp() throws Exception { |
| 43 | + pool = OraclePool.pool(vertx, oracle.options(), new PoolOptions()); |
| 44 | + } |
| 45 | + |
| 46 | + @Test |
| 47 | + public void testCurrentTimestampType(TestContext ctx) { |
| 48 | + pool.query("SELECT CURRENT_TIMESTAMP FROM dual").execute(ctx.asyncAssertSuccess(rows -> { |
| 49 | + ctx.verify(v -> { |
| 50 | + assertEquals(1, rows.size()); |
| 51 | + Object value = rows.iterator().next().getValue(0); |
| 52 | + assertThat(value, is(instanceOf(OffsetDateTime.class))); |
| 53 | + assertEquals(0, MINUTES.between((OffsetDateTime) value, OffsetDateTime.now())); |
| 54 | + }); |
| 55 | + })); |
| 56 | + } |
| 57 | + |
| 58 | + @After |
| 59 | + public void tearDown(TestContext ctx) throws Exception { |
| 60 | + pool.close(ctx.asyncAssertSuccess()); |
| 61 | + } |
| 62 | +} |
0 commit comments