Skip to content

Commit a5e01d5

Browse files
committed
Fix hibernate-reactive-mssql tests
In particular: * Remove undertow, whose dependency was not correctly set, and which shouldn't be used regardless (see 18d1034) * Fix SQL syntax to use SQL-Server specific parameter placeholders; see https://quarkus.io/guides/reactive-sql-clients#reactive-sql-clients-details * Fix configuration/setup to mention mssql instead of mysql... Hibernate Reactive MS
1 parent 69c66a9 commit a5e01d5

File tree

6 files changed

+25
-40
lines changed

6 files changed

+25
-40
lines changed

integration-tests/hibernate-reactive-mssql/pom.xml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<description>Hibernate Reactive related tests running with the MS SQL Server database</description>
1515

1616
<properties>
17-
<reactive-mssql.url>vertx-reactive:mssql://localhost:3306/hibernate_orm_test</reactive-mssql.url>
17+
<reactive-mssql.url>vertx-reactive:sqlserver://localhost:1435</reactive-mssql.url>
1818
</properties>
1919

2020
<dependencies>
@@ -30,17 +30,18 @@
3030
<groupId>io.quarkus</groupId>
3131
<artifactId>quarkus-rest-jsonb</artifactId>
3232
</dependency>
33-
<dependency>
34-
<groupId>io.quarkus</groupId>
35-
<artifactId>quarkus-undertow</artifactId>
36-
</dependency>
3733

3834
<!-- test dependencies -->
3935
<dependency>
4036
<groupId>io.quarkus</groupId>
4137
<artifactId>quarkus-junit5</artifactId>
4238
<scope>test</scope>
4339
</dependency>
40+
<dependency>
41+
<groupId>io.quarkus</groupId>
42+
<artifactId>quarkus-junit5-internal</artifactId>
43+
<scope>test</scope>
44+
</dependency>
4445
<dependency>
4546
<groupId>io.rest-assured</groupId>
4647
<artifactId>rest-assured</artifactId>
@@ -201,7 +202,7 @@
201202
<alias>quarkus-test-mssqldb</alias>
202203
<run>
203204
<ports>
204-
<port>1433:1433</port>
205+
<port>1435:1433</port>
205206
</ports>
206207
<env>
207208
<ACCEPT_EULA>Y</ACCEPT_EULA>
Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,28 @@
11
package io.quarkus.it.hibernate.reactive.mssql;
22

33
import java.io.IOException;
4-
import java.io.PrintWriter;
54

65
import jakarta.inject.Inject;
7-
import jakarta.servlet.annotation.WebServlet;
8-
import jakarta.servlet.http.HttpServlet;
9-
import jakarta.servlet.http.HttpServletRequest;
10-
import jakarta.servlet.http.HttpServletResponse;
6+
import jakarta.ws.rs.GET;
7+
import jakarta.ws.rs.Path;
8+
import jakarta.ws.rs.Produces;
9+
import jakarta.ws.rs.core.MediaType;
1110

1211
import org.hibernate.SessionFactory;
1312
import org.hibernate.engine.spi.SessionFactoryImplementor;
1413

1514
import io.quarkus.hibernate.orm.runtime.config.DialectVersions;
1615

17-
@WebServlet(name = "DialectEndpoint", urlPatterns = "/dialect/version")
18-
public class DialectEndpoint extends HttpServlet {
16+
@Path("/dialect/version")
17+
@Produces(MediaType.TEXT_PLAIN)
18+
public class DialectEndpoint {
1919
@Inject
2020
SessionFactory sessionFactory;
2121

22-
@Override
23-
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
24-
try {
25-
var version = sessionFactory.unwrap(SessionFactoryImplementor.class).getJdbcServices().getDialect().getVersion();
26-
resp.getWriter().write(DialectVersions.toString(version));
27-
} catch (Exception e) {
28-
reportException("Failed to retrieve dialect version", e, resp);
29-
}
30-
}
31-
32-
private void reportException(String errorMessage, final Exception e, final HttpServletResponse resp) throws IOException {
33-
final PrintWriter writer = resp.getWriter();
34-
if (errorMessage != null) {
35-
writer.write(errorMessage);
36-
writer.write(" ");
37-
}
38-
writer.write(e.toString());
39-
writer.append("\n\t");
40-
e.printStackTrace(writer);
41-
writer.append("\n\t");
22+
@GET
23+
public String test() throws IOException {
24+
var version = sessionFactory.unwrap(SessionFactoryImplementor.class).getJdbcServices().getDialect().getVersion();
25+
return DialectVersions.toString(version);
4226
}
4327

4428
}

integration-tests/hibernate-reactive-mssql/src/main/java/io/quarkus/it/hibernate/reactive/mssql/HibernateReactiveMSSQLTestEndpoint.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ private Uni<RowSet<Row>> populateDB() {
8787
}
8888

8989
private Uni<String> selectNameFromId(Integer id) {
90-
return mssqlPool.preparedQuery("SELECT name FROM Pig WHERE id = ?").execute(Tuple.of(id)).map(rowSet -> {
90+
return mssqlPool.preparedQuery("SELECT name FROM Pig WHERE id = @p1").execute(Tuple.of(id)).map(rowSet -> {
9191
if (rowSet.size() == 1) {
9292
return rowSet.iterator().next().getString(0);
9393
} else if (rowSet.size() > 1) {
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
quarkus.datasource.db-kind=mysql
2-
quarkus.datasource.username=hibernate_orm_test
3-
quarkus.datasource.password=hibernate_orm_test
1+
quarkus.datasource.db-kind=mssql
2+
quarkus.datasource.username=sa
3+
quarkus.datasource.password=yourStrong(!)Password
44

55
# Hibernate config
66
#quarkus.hibernate-orm.log.sql=true
77
quarkus.hibernate-orm.database.generation=drop-and-create
88

99
# Reactive config
1010
quarkus.datasource.reactive=true
11-
quarkus.datasource.reactive.url=${reactive-mysql.url}
11+
quarkus.datasource.reactive.url=${reactive-mssql.url}

integration-tests/hibernate-reactive-mssql/src/test/java/io/quarkus/it/hibernate/reactive/mssql/DialectInGraalITCase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
* DialectTest, but in native mode.
77
*/
88
@QuarkusIntegrationTest
9-
public class DialectInGraalITCase extends DefaultDialectVersionTest {
9+
public class DialectInGraalITCase extends DialectTest {
1010

1111
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Test the dialect used by default in Quarkus.
1313
*/
1414
@QuarkusTest
15-
public class DefaultDialectVersionTest {
15+
public class DialectTest {
1616

1717
/**
1818
* This is important for backwards compatibility reasons:

0 commit comments

Comments
 (0)