Skip to content

Commit

Permalink
Upgrade deps; Gradle 8.5; Java 17; and readme cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dgroomes committed Dec 16, 2023
1 parent bfaf316 commit 799083b
Show file tree
Hide file tree
Showing 6 changed files with 241 additions and 143 deletions.
75 changes: 52 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,84 @@

📚 Learning and exploring WireMock.

> Mock your APIs for fast, robust and comprehensive testing
> Mock the APIs You Depend On
>
> -- <cite>http://wiremock.org</cite>
This is a collection of Gradle sub-projects that showcase the excellent HTTP mock server _WireMock_

## Overview

This is a collection of Gradle subprojects that showcase the excellent HTTP mock server _WireMock_
<http://wiremock.org/docs/>.

There are two sub-projects:
There are two subprojects:

* [`programmatic/`](#programmatic)
* [`standalone/`](#standalone)


## `programmatic/`

The `programmatic/` sub-project showcases how to run the WireMock server programmatically via Java code and with
The `programmatic/` subproject showcases how to run the WireMock server programmatically via Java code and with
various configurations. Use it like a recipe book for when you write your own WireMock code!

Instructions:

* Use Java 11
* Run:
* `./gradlew programmatic:run`
* Make requests to the stubbed endpoints:
* `curl --request GET --url http://localhost:8070/message`
* `curl --request GET --url http://localhost:8070/random-integer`
* Observe the Jetty server statistics by going to <http://localhost:8070/stats/> in your browser
* Statistics include things like the number of responses with 200/300/400/500 status codes, the number of connections,
and the amount of memory used by the underlying Jetty server.
### Instructions

Follow these instructions to run the example program.

1. Use Java 17
2. Build and run the program:
* ```shell
./gradlew programmatic:run
```
3. Make requests to the stubbed endpoints:
* ```shell
curl --request GET --url http://localhost:8070/message
```
* ```shell
curl --request GET --url http://localhost:8070/random-integer
```
4. Observe the Jetty server statistics by going to <http://localhost:8070/stats/> in your browser
* Statistics include things like the number of responses with 200/300/400/500 status codes, the number of connections,
and the amount of memory used by the underlying Jetty server.


## `standalone/`

The `standalone/` sub-project showcases how to run WireMock as a standalone process by downloading the
The `standalone/` subproject showcases how to run WireMock as a standalone process by downloading the
executable jar and running it. See the official docs at <http://wiremock.org/docs/running-standalone/>.

Instructions:
### Instructions

Follow these instructions to run the standalone WireMock server.

1. Use Java 17
2. Run the standalone server
* ```shell
./gradlew standalone:run
```
3. When you're done, stop the program with `Ctrl + C`
* Use Java 11
* Run with `./gradlew standalone:run`
* Exit with `Ctrl + C`
## Wish List
General clean-ups, changes and things I wish to implement for this project:
* Make the sub-projects completely standalone and adhere to the convention I have in my other playground repos.
* DONE Add a stub with a custom handler that uses custom Java code to respond to the request.
* Create a WireMock-in-Docker example
* DONE create a sub-project that declares dependency constraint versions and which will be used as a `platform(...)`
* [ ] Make the subprojects completely standalone and adhere to the convention I have in my other playground repos.
* [x] DONE Add a stub with a custom handler that uses custom Java code to respond to the request.
* [ ] SKIP (WireMock has its own Docker image now; great!) Create a WireMock-in-Docker example
* [x] DONE create a subproject that declares dependency constraint versions and which will be used as a `platform(...)`
from the other projects. For details of this feature, see the [Gradle docs about "platform"](https://docs.gradle.org/current/userguide/platforms.html)
* [x] DONE Upgrade to Gradle 8.5
* [x] DONE Upgrade dependencies
* [x] DONE Upgrade to Java 17
* [ ] Upgrade to WireMock 3.0
* [ ] Upgrade to Java 21?
* [ ] Do something with proxying. Anything I care to have a reference for? Any nice new proxy features in WireMock 3.0?
* [ ] Add some stubs to the standalone project
* [ ] Remove the JFR stuff (although interesting; that kind of stuff belongs in other playground repos)
## Notes
Expand Down
8 changes: 4 additions & 4 deletions dependency-constraints/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
plugins {
/*
* Using the Gradle "platform" feature to declare dependency version constraints that will be used by the other sub-projects
* so that we only ever have to declare version information in one place instead of across all sub-projects. See the
* Using the Gradle "platform" feature to declare dependency version constraints that will be used by the other subprojects
* so that we only ever have to declare version information in one place instead of across all subprojects. See the
* Gradle docs about "platform": https://docs.gradle.org/current/userguide/platforms.html
*/
`java-platform`
}

val slf4jVersion = "1.7.30" // releases: http://www.slf4j.org/news.html
val wireMockVersion = "2.29.1" // releases: https://github.com/tomakehurst/wiremock/tags
val slf4jVersion = "1.7.36" // releases: http://www.slf4j.org/news.html
val wireMockVersion = "2.35.1" // releases: https://github.com/tomakehurst/wiremock/tags

dependencies {
constraints {
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 3 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 799083b

Please sign in to comment.