Skip to content

Commit

Permalink
URI set to localhost:0 when a random port is used (#9)
Browse files Browse the repository at this point in the history
* Remove junit and jersey test as dependecy, this will allow the user to cherry pick their version (expect when breaking change are involved)

* Register the URI after launching the jersey server
  • Loading branch information
grunenwflorian authored and hanleyt committed Apr 29, 2019
1 parent 0d53b35 commit 55b68e7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
# Jersey-JUnit
A [JUnit 5 extension](https://junit.org/junit5/docs/current/user-guide/#extensions) for testing JAX-RS and Jersey-based applications using the Jersey test framework.
A zero dependency [JUnit 5 extension](https://junit.org/junit5/docs/current/user-guide/#extensions) library for testing JAX-RS and Jersey-based applications using the Jersey test framework.

[![Build Status](https://travis-ci.org/hanleyt/jersey-junit.svg?branch=master)](https://travis-ci.org/hanleyt/jersey-junit)
[![codecov](https://codecov.io/gh/hanleyt/jersey-junit/branch/master/graph/badge.svg)](https://codecov.io/gh/hanleyt/jersey-junit)
[![jitpack](https://jitpack.io/v/hanleyt/jersey-junit.svg)](https://jitpack.io/#hanleyt/jersey-junit)


Set Up
-----
Add the following dependency to your gradle build file:

```testCompile group: 'com.github.hanleyt', name: 'jersey-junit', version: '1.3.0'```
```
testCompile group: 'com.github.hanleyt', name: 'jersey-junit', version: '1.4.0'
// Add a test container factory, for example grizzly :
testCompile group: 'org.glassfish.jersey.test-framework.providers', name: 'jersey-test-framework-provider-grizzly2', version: '2.28'
```

Ensuring you have the jitpack repo in your list of repos:

Expand Down
9 changes: 4 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,11 @@ tasks {
}

dependencies {
compile("org.glassfish.jersey.test-framework.providers:jersey-test-framework-provider-grizzly2:$jerseyVersion")
compileOnly("org.junit.jupiter:junit-jupiter-api:$junitJupiterVersion")
compileOnly("org.glassfish.jersey.test-framework:jersey-test-framework-core:$jerseyVersion")

compile("org.junit.jupiter:junit-jupiter-api:$junitJupiterVersion")
runtimeOnly("org.junit.jupiter:junit-jupiter-engine:$junitJupiterVersion")
testCompile("org.junit.jupiter:junit-jupiter-engine:$junitJupiterVersion")

testCompile("org.glassfish.jersey.test-framework.providers:jersey-test-framework-provider-grizzly2:$jerseyVersion")
testCompile("org.glassfish.jersey.inject:jersey-hk2:$jerseyVersion")

testCompile("org.junit.jupiter:junit-jupiter-engine:$junitJupiterVersion")
}
2 changes: 1 addition & 1 deletion src/main/java/com/github/hanleyt/JerseyExtension.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ public void beforeEach(ExtensionContext context) throws Exception {
JerseyTest jerseyTest = initJerseyTest(context);
getStore(context).put(Client.class, jerseyTest.client());
getStore(context).put(WebTarget.class, jerseyTest.target());
getStore(context).put(URI.class, jerseyTest.target().getUri());
}

private JerseyTest initJerseyTest(ExtensionContext context) throws Exception {
JerseyTest jerseyTest = new JerseyTest() {
@Override
protected Application configure() {
getStore(context).put(URI.class, getBaseUri());
return applicationProvider.apply(context);
}

Expand Down

0 comments on commit 55b68e7

Please sign in to comment.