Skip to content

Commit a63efd0

Browse files
committed
Add tests for MySQL BIT and PostgreSQL BYTEA columns
Signed-off-by: Joern Bernhardt <[email protected]>
1 parent f8e04ae commit a63efd0

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

src/test/java/io/vertx/ext/asyncsql/MySQLClientTest.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,16 @@
2020
import io.vertx.core.Handler;
2121
import io.vertx.core.json.JsonArray;
2222
import io.vertx.core.json.JsonObject;
23+
import io.vertx.ext.sql.ResultSet;
2324
import io.vertx.ext.sql.SQLConnection;
2425
import io.vertx.ext.sql.UpdateResult;
2526
import io.vertx.ext.unit.Async;
2627
import io.vertx.ext.unit.TestContext;
2728
import org.junit.Before;
2829
import org.junit.Test;
2930

31+
import java.util.Arrays;
32+
3033
public class MySQLClientTest extends SQLTestBase {
3134

3235

@@ -93,6 +96,22 @@ public void testInsertedIds(TestContext context) {
9396
});
9497
}
9598

99+
protected String createByteArray1TableColumn() {
100+
return "BIT(1)";
101+
}
102+
103+
protected String createByteArray2TableColumn() {
104+
return "BIT(2)";
105+
}
106+
107+
protected String[] insertByteArray1Values() {
108+
return new String[]{"B'1'", "B'0'", "B'1'"};
109+
}
110+
111+
protected String[] insertByteArray2Values() {
112+
return new String[]{"B'10'", "B'01'", "B'11'"};
113+
}
114+
96115
private void setupAutoIncrementTable(SQLConnection conn, Handler<AsyncResult<Void>> handler) {
97116
conn.execute("BEGIN",
98117
ar -> conn.execute("DROP TABLE IF EXISTS test_table",

src/test/java/io/vertx/ext/asyncsql/PostgreSQLClientTest.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.junit.Before;
2828
import org.junit.Test;
2929

30+
import java.util.Arrays;
3031
import java.util.UUID;
3132

3233
public class PostgreSQLClientTest extends SQLTestBase {
@@ -111,6 +112,22 @@ public void testUsingUUIDsInTables(TestContext context) {
111112
});
112113
}
113114

115+
protected String createByteArray1TableColumn() {
116+
return "BYTEA";
117+
}
118+
119+
protected String createByteArray2TableColumn() {
120+
return "BYTEA";
121+
}
122+
123+
protected String[] insertByteArray1Values() {
124+
return new String[]{"E'\\001'", "E'\\\\000'", "E'\\\\001'"};
125+
}
126+
127+
protected String[] insertByteArray2Values() {
128+
return new String[]{"E'\\x2'", "E'\\x1'", "E'\\x3'"};
129+
}
130+
114131
private void setupAutoIncrementTable(SQLConnection conn, Handler<AsyncResult<Void>> handler) {
115132
conn.execute("BEGIN",
116133
ar -> conn.execute("DROP TABLE IF EXISTS test_table",

src/test/java/io/vertx/ext/asyncsql/SQLTestBase.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import io.vertx.ext.unit.TestContext;
2929
import org.junit.Test;
3030

31+
import java.util.Arrays;
3132
import java.util.List;
3233

3334
public abstract class SQLTestBase extends AbstractTestBase {

0 commit comments

Comments
 (0)