-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate all JPA tests to RestEasy Reactive
Because: 1. We recommend that people use RestEasy Reactive, so we might as well take our own advice. 2. I've had enough with copy/pasted, manual exception handling ("reportException(...)"), especially since it's buggy (it doesn't take into account the fact that exceptions may have a null message, e.g. NPEs); 3. I don't want to deal with servlets on a daily basis, thank you very much.
- Loading branch information
Showing
42 changed files
with
345 additions
and
766 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 11 additions & 27 deletions
38
integration-tests/jpa-h2-embedded/src/main/java/io/quarkus/it/jpa/h2/DialectEndpoint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,28 @@ | ||
package io.quarkus.it.jpa.h2; | ||
|
||
import java.io.IOException; | ||
import java.io.PrintWriter; | ||
|
||
import jakarta.inject.Inject; | ||
import jakarta.servlet.annotation.WebServlet; | ||
import jakarta.servlet.http.HttpServlet; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.Produces; | ||
import jakarta.ws.rs.core.MediaType; | ||
|
||
import org.hibernate.SessionFactory; | ||
import org.hibernate.engine.spi.SessionFactoryImplementor; | ||
|
||
import io.quarkus.hibernate.orm.runtime.config.DialectVersions; | ||
|
||
@WebServlet(name = "DialectEndpoint", urlPatterns = "/dialect/version") | ||
public class DialectEndpoint extends HttpServlet { | ||
@Path("/dialect/version") | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public class DialectEndpoint { | ||
@Inject | ||
SessionFactory sessionFactory; | ||
|
||
@Override | ||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { | ||
try { | ||
var version = sessionFactory.unwrap(SessionFactoryImplementor.class).getJdbcServices().getDialect().getVersion(); | ||
resp.getWriter().write(DialectVersions.toString(version)); | ||
} catch (Exception e) { | ||
reportException("Failed to retrieve dialect version", e, resp); | ||
} | ||
} | ||
|
||
private void reportException(String errorMessage, final Exception e, final HttpServletResponse resp) throws IOException { | ||
final PrintWriter writer = resp.getWriter(); | ||
if (errorMessage != null) { | ||
writer.write(errorMessage); | ||
writer.write(" "); | ||
} | ||
writer.write(e.toString()); | ||
writer.append("\n\t"); | ||
e.printStackTrace(writer); | ||
writer.append("\n\t"); | ||
@GET | ||
public String test() throws IOException { | ||
var version = sessionFactory.unwrap(SessionFactoryImplementor.class).getJdbcServices().getDialect().getVersion(); | ||
return DialectVersions.toString(version); | ||
} | ||
|
||
} |
Oops, something went wrong.