-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow RestAssured to test external servers (#1009)
Close: #1006
- Loading branch information
Showing
3 changed files
with
61 additions
and
4 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
30 changes: 30 additions & 0 deletions
30
...t-assured/src/test/java/io/micronaut/test/rest/assured/RestAssuredExternalServerTest.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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package io.micronaut.test.rest.assured; | ||
|
||
import io.micronaut.context.annotation.Property; | ||
import io.micronaut.test.extensions.junit5.annotation.MicronautTest; | ||
import io.restassured.specification.RequestSpecification; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.hamcrest.Matchers.hasSize; | ||
|
||
@MicronautTest | ||
@Property(name = "micronaut.test.server.url", value = "https://jsonplaceholder.typicode.com") | ||
class RestAssuredExternalServerTest { | ||
|
||
@Test | ||
void testSinglePost(RequestSpecification spec) { | ||
spec | ||
.when().get("/posts/1") | ||
.then().statusCode(200) | ||
.body("title", is("sunt aut facere repellat provident occaecati excepturi optio reprehenderit")); | ||
} | ||
|
||
@Test | ||
void testUsers(RequestSpecification spec) { | ||
spec | ||
.when().get("/users") | ||
.then().statusCode(200) | ||
.body("id", hasSize(10)); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<configuration> | ||
|
||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||
<!-- encoders are assigned the type | ||
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default --> | ||
<encoder> | ||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern> | ||
</encoder> | ||
</appender> | ||
|
||
<root level="info"> | ||
<appender-ref ref="STDOUT" /> | ||
</root> | ||
</configuration> |