|
17 | 17 | package com.google.cloud.spanner.jdbc; |
18 | 18 |
|
19 | 19 | import static com.google.common.truth.Truth.assertThat; |
| 20 | +import static org.junit.Assert.assertEquals; |
20 | 21 | import static org.junit.Assert.assertFalse; |
21 | 22 | import static org.junit.Assert.assertNotNull; |
22 | 23 | import static org.junit.Assert.assertTrue; |
|
25 | 26 | import com.google.cloud.spanner.Mutation; |
26 | 27 | import com.google.cloud.spanner.connection.AbstractMockServerTest; |
27 | 28 | import com.google.cloud.spanner.connection.SpannerPool; |
| 29 | +import com.google.spanner.v1.CommitRequest; |
28 | 30 | import java.sql.DriverManager; |
29 | 31 | import java.sql.ResultSet; |
30 | 32 | import java.sql.SQLException; |
| 33 | +import java.time.Duration; |
31 | 34 | import org.junit.After; |
32 | 35 | import org.junit.Test; |
33 | 36 | import org.junit.runner.RunWith; |
34 | 37 | import org.junit.runners.JUnit4; |
35 | 38 |
|
36 | 39 | @RunWith(JUnit4.class) |
37 | | -public class JdbcCommitStatsTest extends AbstractMockServerTest { |
| 40 | +public class JdbcTransactionOptionsTest extends AbstractMockServerTest { |
38 | 41 |
|
39 | 42 | @After |
40 | 43 | public void closeSpannerPool() { |
@@ -120,4 +123,19 @@ public void testSetAndUseReturnCommitStatsUsingSql() throws SQLException { |
120 | 123 | } |
121 | 124 | } |
122 | 125 | } |
| 126 | + |
| 127 | + @Test |
| 128 | + public void testMaxCommitDelay() throws SQLException { |
| 129 | + try (java.sql.Connection connection = createJdbcConnection()) { |
| 130 | + connection.createStatement().execute("SET max_commit_delay='50ms'"); |
| 131 | + connection |
| 132 | + .unwrap(CloudSpannerJdbcConnection.class) |
| 133 | + .bufferedWrite(Mutation.newInsertBuilder("FOO").set("ID").to(1L).build()); |
| 134 | + connection.commit(); |
| 135 | + |
| 136 | + assertEquals(1, mockSpanner.countRequestsOfType(CommitRequest.class)); |
| 137 | + CommitRequest request = mockSpanner.getRequestsOfType(CommitRequest.class).get(0); |
| 138 | + assertEquals(Duration.ofMillis(50).toNanos(), request.getMaxCommitDelay().getNanos()); |
| 139 | + } |
| 140 | + } |
123 | 141 | } |
0 commit comments