Comments (7)
I like the idea of giving users more low-level validation access to their HTTP endpoints. Currently users can do this if the REST client returns a javax.ws.rs.core.Response
object, but in many cases REST clients do not because it's more convenient to simply return a POJO from the JAX-RS method.
One popular REST testing library I know if is REST-assured. Here is a good article about it: https://www.baeldung.com/rest-assured-tutorial
If you look at section (7) it talks about configuring the library, perhaps we could automatically detect the presence of the RestAssured class and if it's present then microshed would automatically bootstrap it (e.g. set baseURI, base path, port, etc). This would allow us to have a test case that looks like this:
@MicroShedTest
public class MyTest {
@Container
public static ApplicationContainer app = // usual config
@Test
public void testCreatePerson() {
// validate that POST request to
// http://<container-ip>:<container-port>/myservice/?name=Hank?age=52
// returns HTTP 200 with content type JSON
given()
.contentType(JSON)
.queryParam("name", "Hank")
.queryParam("age", 52)
.when()
.post("/")
.then()
.statusCode(200)
.contentType(JSON);
}
}
from microshed-testing.
This looks quite good 👍
from microshed-testing.
created a draft PR for the integration here: #134
It can't be merged until the corresponding PR I made on REST-assured gets merged though
from microshed-testing.
wow, that was fast 👍 I'll try it over the weekend while building REST-Assured with your PR locally
from microshed-testing.
works great and I really like the given/when/then
structure of Rest Assured.
Just out of curiosity, if now a user wants to plug a custom MessageBodyReader
or MessageBodyWriter
e.g JAXB
or for whatever reason, he/she uses binary formats like Kryo, this would always result in effort and adjustment within RestAssured, or? I assume 80% of the use cases are fine with JSON
but the rest might need something different
from microshed-testing.
RestAssured has builtin converters for JSON and XML formats, but if a user wants to implement a converter to handle a custom data format.
For JSON-B integration with RestAssured I could have just written the converter in MicroShed code, but then we'd need to have a dependency on RestAssured which I wanted to avoid (i.e. not even an optional dependency)
from microshed-testing.
PR #134 adds the integration with REST Assured and is now merged, it will be available in the next release (probably 0.6.3)
from microshed-testing.
Related Issues (20)
- Would like the ability to calculate a base path from a JAX-RS Application type in a specific package, unrelated to @RESTClient type HOT 4
- Upgrade to Test Containers 1.15 HOT 4
- Microshed with quarkus 1.12.2-Final cant initialize PostgreSQLContainer HOT 1
- Sample application for Payara Microshed JWT (microshed-testing-jaxrs-mpjwt) is not working
- Tests all fail with mvn verify when there is an application tag in server.xml HOT 6
- [Quarkus] yaml configuration not supported
- Support Podman for container runtime HOT 1
- Building rest client fails with "java.lang.IllegalArgumentException: <FQCN> is not an interface." HOT 1
- Bump liberty adapter base image to support Java 11 or 17 HOT 4
- Support Jakarta namespace HOT 6
- Testing JWT endpoint with RESTassured HOT 1
- Is this resitory still active? HOT 2
- Release 0.9.2 [Proposal] HOT 11
- Update dependabot to non-preview version
- WithExposedPorts fails integrationtests HOT 1
- Create seperate Dockerfile for sample applications
- Get test space upload working for pushes to main branch only
- Update gradle wrapper to support future Java 17
- DCO step in CI removal HOT 2
- Local build on ARM fails HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from microshed-testing.