Skip to content

Commit

Permalink
Fix package relocation for standalone jar (#37)
Browse files Browse the repository at this point in the history
- handlebars relocation matches wiremock standalone
- added IntelliJ run configuration for docker
- added markdown helper for docker test
- added http file for docker test


## References

#36 

## Submitter checklist

- [ ] Recommended: Join [WireMock Slack](https://slack.wiremock.org/) to
get any help in `#help-contributing` or a project-specific channel like
`#wiremock-java`
- [ ] The PR request is well described and justified, including the body
and the references
- [ ] The PR title represents the desired changelog entry
- [ ] The repository's code style is followed (see the contributing
guide)
- [ ] Test coverage that demonstrates that the change works as expected
- [ ] For new features, there's necessary documentation in this pull
request or in a subsequent PR to
[wiremock.org](https://github.com/wiremock/wiremock.org)

<!--
Put an `x` into the [ ] to show you have filled the information.
The template comes from
https://github.com/wiremock/.github/blob/main/.github/pull_request_template.md
You can override it by creating .github/pull_request_template.md in your
own repository
-->
  • Loading branch information
dirkbolte authored Aug 24, 2023
1 parent 04d1f10 commit 77d0a92
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 3 deletions.
33 changes: 33 additions & 0 deletions .run/WireMock Docker Test.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="WireMock Docker Test" type="docker-deploy" factoryName="docker-image" server-name="Docker">
<deployment type="docker-image">
<settings>
<option name="imageTag" value="wiremock/wiremock:3x" />
<option name="command" value="--global-response-templating --verbose" />
<option name="containerName" value="wiremock-extension-state-test" />
<option name="portBindings">
<list>
<DockerPortBindingImpl>
<option name="containerPort" value="8080" />
<option name="hostPort" value="8080" />
</DockerPortBindingImpl>
</list>
</option>
<option name="volumeBindings">
<list>
<DockerVolumeBindingImpl>
<option name="containerPath" value="/var/wiremock/extensions" />
<option name="hostPath" value="$PROJECT_DIR$/build/libs" />
<option name="readOnly" value="true" />
</DockerVolumeBindingImpl>
<DockerVolumeBindingImpl>
<option name="containerPath" value="/home/wiremock" />
<option name="hostPath" value="$PROJECT_DIR$/src/test/resources/remoteloader/" />
</DockerVolumeBindingImpl>
</list>
</option>
</settings>
</deployment>
<method v="2" />
</configuration>
</component>
17 changes: 17 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Testing docker

Build and start the container:

```bash
./gradlew clean build -x test
```

```bash
docker run -it --rm \
-p 8080:8080 \
--name wiremock \
-v $PWD/build/libs:/var/wiremock/extensions \
-v $PWD/src/test/resources/remoteloader:/home/wiremock \
wiremock/wiremock:3x \
--global-response-templating
```
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,8 @@ docker run -it --rm \
-p 8080:8080 \
--name wiremock \
-v $PWD/extensions:/var/wiremock/extensions \
wiremock/wiremock:3x
wiremock/wiremock:3x \
-- --global-response-templating
```

## Record a state
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ shadowJar {
from("shadowjar/resources") {}
}

relocate "com.github.ben-manes.caffeine", 'wiremock.org.extensions.state.caffeine'
relocate "com.github.jknack", 'wiremock.org.extensions.state.jknack'
relocate "com.github.ben-manes.caffeine", 'wiremock.com.github.ben-manes.caffeine'
relocate "com.github.jknack", 'wiremock.com.github.jknack'


dependencies {
Expand Down
47 changes: 47 additions & 0 deletions docker_container_test.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
### empty get

GET http://localhost:8080/queue/myqueue

> {%
client.test("Request executed successfully", function () {
const status = response.status;
client.assert(status === 200, "expected response status 200 but received '" + status + "'");
});
client.test("Response content-type is json", function() {
const type = response.contentType.mimeType;
client.assert(type === "application/json", "Expected 'application/json' but received '" + type + "'");
});
client.test("empty list is returned", function () {
const item = response.body.item;
client.assert(item === "no data", "response is not an empty list: '" + item + "'");
});
%}

### POST entry

POST http://localhost:8080/queue/myqueue/abdcef

> {%
client.test("Request executed successfully", function () {
client.assert(response.status === 200, "response status is not 200");
});
%}

### filled get

GET http://localhost:8080/queue/myqueue

> {%
client.test("Request executed successfully", function () {
const status = response.status;
client.assert(status === 200, "expected response status 200 but received '" + status + "'");
});
client.test("Response content-type is json", function() {
const type = response.contentType.mimeType;
client.assert(type === "application/json", "Expected 'application/json' but received '" + type + "'");
});
client.test("list with correct is returned", function () {
const item = response.body.item;
client.assert(item === 'abdcef', "response does not contain queue item but is: '" + item + "'");
});
%}

0 comments on commit 77d0a92

Please sign in to comment.