Skip to content

Commit 9d4f07f

Browse files
authored
Provide metadata for MariaDB Java Client 3.5.2 (#612)
Due to the changes in [1], mariadb-java-client now requires reflective access to all of the methods on Configuration$Builder in addition to its fields. [1] mariadb-corporation/mariadb-connector-j@ca5057c
1 parent be77f06 commit 9d4f07f

File tree

12 files changed

+269
-0
lines changed

12 files changed

+269
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[
2+
"reflect-config.json",
3+
"resource-config.json"
4+
]
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[
2+
{
3+
"condition": {
4+
"typeReachable": "org.mariadb.jdbc.Configuration"
5+
},
6+
"name": "org.mariadb.jdbc.Configuration",
7+
"allDeclaredFields": true
8+
},
9+
{
10+
"condition": {
11+
"typeReachable": "org.mariadb.jdbc.Configuration"
12+
},
13+
"name": "org.mariadb.jdbc.Configuration$Builder",
14+
"allDeclaredFields": true,
15+
"allPublicMethods": true
16+
},
17+
{
18+
"condition": {
19+
"typeReachable": "org.mariadb.jdbc.plugin.authentication.standard.NativePasswordPlugin"
20+
},
21+
"name": "sun.security.provider.SHA",
22+
"methods": [
23+
{
24+
"name": "<init>",
25+
"parameterTypes": []
26+
}
27+
]
28+
}
29+
]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"bundles": [],
3+
"resources": {
4+
"includes": [
5+
{
6+
"condition": {
7+
"typeReachable": "org.mariadb.jdbc.util.VersionFactory"
8+
},
9+
"pattern": "\\Qmariadb.properties\\E"
10+
}
11+
]
12+
}
13+
}

metadata/org.mariadb.jdbc/mariadb-java-client/index.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@
2525
"3.5.0",
2626
"3.5.1"
2727
],
28+
"module" : "org.mariadb.jdbc:mariadb-java-client"
29+
},
30+
{
31+
"metadata-version" : "3.5.2",
32+
"tested-versions" : [
33+
"3.5.2"
34+
],
2835
"latest" : true,
2936
"module" : "org.mariadb.jdbc:mariadb-java-client"
3037
}

tests/src/index.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,12 @@
604604
"name" : "org.mariadb.jdbc:mariadb-java-client",
605605
"versions" : [ "3.0.6" ]
606606
} ]
607+
}, {
608+
"test-project-path" : "org.mariadb.jdbc/mariadb-java-client/3.5.2",
609+
"libraries" : [ {
610+
"name" : "org.mariadb.jdbc:mariadb-java-client",
611+
"versions" : [ "3.5.2" ]
612+
} ]
607613
}, {
608614
"test-project-path" : "org.mariadb/r2dbc-mariadb/1.1.3",
609615
"libraries" : [ {
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
mariadb-stderr.txt
2+
mariadb-stdout.txt
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright and related rights waived via CC0
3+
*
4+
* You should have received a copy of the CC0 legalcode along with this
5+
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
6+
*/
7+
plugins {
8+
id "org.graalvm.internal.tck"
9+
}
10+
11+
String libraryVersion = tck.testedLibraryVersion.get()
12+
13+
dependencies {
14+
implementation "org.mariadb.jdbc:mariadb-java-client:$libraryVersion"
15+
testImplementation 'org.assertj:assertj-core:3.22.0'
16+
testImplementation 'org.awaitility:awaitility:4.2.0'
17+
}
18+
19+
graalvmNative {
20+
agent {
21+
defaultMode = "conditional"
22+
modes {
23+
conditional {
24+
userCodeFilterPath = "user-code-filter.json"
25+
}
26+
}
27+
metadataCopy {
28+
mergeWithExisting = true
29+
inputTaskNames.add("test")
30+
outputDirectories.add("src/test/resources/META-INF/native-image/org.mariadb.jdbc/mariadb-java-client")
31+
}
32+
}
33+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
library.version=3.5.2
2+
metadata.dir=org.mariadb.jdbc/mariadb-java-client/3.5.2
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
mariadb:10.8
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright and related rights waived via CC0
3+
*
4+
* You should have received a copy of the CC0 legalcode along with this
5+
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
6+
*/
7+
8+
pluginManagement {
9+
def tckPath = Objects.requireNonNullElse(
10+
System.getenv("GVM_TCK_TCKDIR"),
11+
"../../../../tck-build-logic"
12+
)
13+
includeBuild(tckPath)
14+
}
15+
16+
plugins {
17+
id "org.graalvm.internal.tck-settings" version "1.0.0-SNAPSHOT"
18+
}
19+
20+
rootProject.name = 'mariadb-java-client-tests'
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
/*
2+
* Copyright and related rights waived via CC0
3+
*
4+
* You should have received a copy of the CC0 legalcode along with this
5+
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
6+
*/
7+
package mariadb;
8+
9+
import org.awaitility.Awaitility;
10+
import org.junit.jupiter.api.AfterAll;
11+
import org.junit.jupiter.api.BeforeAll;
12+
import org.junit.jupiter.api.Test;
13+
14+
import java.io.File;
15+
import java.io.IOException;
16+
import java.sql.Connection;
17+
import java.sql.DriverManager;
18+
import java.sql.PreparedStatement;
19+
import java.sql.ResultSet;
20+
import java.sql.SQLException;
21+
import java.sql.SQLNonTransientConnectionException;
22+
import java.time.Duration;
23+
import java.util.Properties;
24+
25+
import static org.assertj.core.api.Assertions.assertThat;
26+
27+
/**
28+
* This test uses docker to start a MariaDB database to test against.
29+
*/
30+
public class MariaDbTests {
31+
32+
private static final String USERNAME = "fred";
33+
34+
private static final String PASSWORD = "secret";
35+
36+
private static final String DATABASE = "test";
37+
38+
private static final String JDBC_URL = "jdbc:mariadb://localhost:3306/" + DATABASE;
39+
40+
private static Process process;
41+
42+
private static Connection openConnection() throws SQLException {
43+
Properties props = new Properties();
44+
props.setProperty("user", USERNAME);
45+
props.setProperty("password", PASSWORD);
46+
return DriverManager.getConnection(JDBC_URL, props);
47+
}
48+
49+
@BeforeAll
50+
static void beforeAll() throws IOException {
51+
System.out.println("Starting MariaDB ...");
52+
process = new ProcessBuilder(
53+
"docker", "run", "--rm", "-p", "3306:3306", "-e", "MARIADB_DATABASE=" + DATABASE, "-e", "MARIADB_USER=" + USERNAME,
54+
"-e", "MARIADB_PASSWORD=" + PASSWORD, "-e", "MARIADB_ALLOW_EMPTY_ROOT_PASSWORD=true", "mariadb:10.8").redirectOutput(new File("mariadb-stdout.txt"))
55+
.redirectError(new File("mariadb-stderr.txt")).start();
56+
57+
// Wait until connection can be established
58+
Awaitility.await().atMost(Duration.ofMinutes(1)).ignoreExceptionsMatching(e ->
59+
e instanceof SQLNonTransientConnectionException
60+
).until(() -> {
61+
openConnection().close();
62+
return true;
63+
});
64+
System.out.println("MariaDB started");
65+
}
66+
67+
@AfterAll
68+
static void tearDown() {
69+
if (process != null && process.isAlive()) {
70+
System.out.println("Shutting down MariaDB");
71+
process.destroy();
72+
}
73+
}
74+
75+
@Test
76+
void commitAndRollback() throws Exception {
77+
try (Connection conn = openConnection()) {
78+
conn.setAutoCommit(false);
79+
conn.prepareStatement("CREATE TABLE foo (id INT AUTO_INCREMENT, name VARCHAR(255), PRIMARY KEY (id))").execute();
80+
conn.commit();
81+
}
82+
83+
try (Connection conn = openConnection()) {
84+
conn.setAutoCommit(false);
85+
PreparedStatement statement = conn.prepareStatement("INSERT INTO foo (name) VALUES (?)");
86+
statement.setString(1, "Adam");
87+
statement.execute();
88+
statement.setString(1, "Eve");
89+
statement.execute();
90+
conn.commit();
91+
}
92+
93+
try (Connection conn = openConnection()) {
94+
// Test rollbacks
95+
conn.setAutoCommit(false);
96+
conn.prepareStatement("DELETE FROM foo").execute();
97+
conn.rollback();
98+
}
99+
100+
try (Connection conn = openConnection()) {
101+
conn.setAutoCommit(false);
102+
try (ResultSet resultSet = conn.prepareStatement("SELECT * FROM foo").executeQuery()) {
103+
assertThat(resultSet.next()).isTrue();
104+
assertThat(resultSet.getInt(1)).isEqualTo(1);
105+
assertThat(resultSet.getString(2)).isEqualTo("Adam");
106+
assertThat(resultSet.next()).isTrue();
107+
assertThat(resultSet.getInt(1)).isEqualTo(2);
108+
assertThat(resultSet.getString(2)).isEqualTo("Eve");
109+
assertThat(resultSet.next()).isFalse();
110+
}
111+
}
112+
}
113+
114+
@Test
115+
void simpleDatatypes() throws Exception {
116+
try (Connection connection = openConnection()) {
117+
connection.setAutoCommit(false);
118+
connection.prepareStatement("CREATE TABLE simple_datatypes " +
119+
"(b1 BIT, t1 TINYINT, b2 BOOLEAN, s1 SMALLINT, m1 MEDIUMINT, c2 INT, d1 BIGINT, d2 DECIMAL, " +
120+
"i1 FLOAT, j1 DOUBLE)").execute();
121+
PreparedStatement statement = connection.prepareStatement("INSERT INTO simple_datatypes VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
122+
statement.setInt(1, 1); // BIT
123+
statement.setByte(2, (byte) 127); // TINYINT
124+
statement.setBoolean(3, true); // BOOLEAN
125+
statement.setShort(4, (short) 2); // SMALLINT
126+
statement.setInt(5, 3); // MEDIUMINT
127+
statement.setInt(6, 4); // INT
128+
statement.setLong(7, Long.MAX_VALUE); // BIGINT
129+
statement.setDouble(8, Math.PI); // DECIMAL
130+
statement.setFloat(9, 42.2f); // FLOAT
131+
statement.setDouble(10, Math.PI); // DOUBLE
132+
statement.execute();
133+
134+
try (ResultSet resultSet = connection.prepareStatement("SELECT * FROM simple_datatypes").executeQuery()) {
135+
assertThat(resultSet.next()).isTrue();
136+
for (int i = 1; i <= 10; i++) {
137+
System.out.printf("column %d: %s%n", i, resultSet.getObject(i));
138+
}
139+
}
140+
}
141+
}
142+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"rules": [
3+
{
4+
"excludeClasses": "**"
5+
},
6+
{
7+
"includeClasses": "org.mariadb.jdbc.**"
8+
}
9+
]
10+
}

0 commit comments

Comments
 (0)