Skip to content

Commit b16ccf4

Browse files
Add tests for offline example (#2465)
1 parent 77a2026 commit b16ccf4

2 files changed

Lines changed: 67 additions & 1 deletion

File tree

distribution/examples/offline/apis.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ api:
2222
---
2323
# Deploy an API from OpenAPI
2424
# API docs: http://localhost:2000/api-docs
25-
# Try: curl http://localhost:2000/shop
25+
# Try: curl http://localhost:2000/shop/v2/
2626
api:
2727
port: 2000
2828
specs:
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package com.predic8.membrane.examples.withoutinternet;
2+
3+
import com.predic8.membrane.examples.util.AbstractSampleMembraneStartStopTestcase;
4+
import org.junit.jupiter.api.Test;
5+
6+
import static io.restassured.RestAssured.when;
7+
import static org.hamcrest.Matchers.*;
8+
9+
public class OfflineExampleTest extends AbstractSampleMembraneStartStopTestcase {
10+
11+
@Override
12+
protected String getExampleDirName() {
13+
return "/offline";
14+
}
15+
16+
@Test
17+
public void toBackend() {
18+
// @formatter:off
19+
when()
20+
.get("http://localhost:2000/foo")
21+
.then()
22+
.statusCode(200)
23+
.body("success", equalTo(true));
24+
// @formatter:on
25+
}
26+
27+
@Test
28+
public void apiDocs() {
29+
// @formatter:off
30+
when()
31+
.get("http://localhost:2000/api-docs")
32+
.then()
33+
.statusCode(200)
34+
.body("fruit-shop-api-v2-2-0.size()", equalTo(5))
35+
.body("fruit-shop-api-v2-2-0.openapi", equalTo("3.0.3"))
36+
.body("fruit-shop-api-v2-2-0.title", equalTo("Fruit Shop API"))
37+
.body("fruit-shop-api-v2-2-0.version", equalTo("2.2.0"))
38+
.body("fruit-shop-api-v2-2-0.openapi_link", equalTo("/api-docs/fruit-shop-api-v2-2-0"))
39+
.body("fruit-shop-api-v2-2-0.ui_link", equalTo("/api-docs/ui/fruit-shop-api-v2-2-0"));
40+
// @formatter:on
41+
}
42+
43+
@Test
44+
public void shopV2_fruits() {
45+
// @formatter:off
46+
when()
47+
.get("http://localhost:2000/shop/v2")
48+
.then()
49+
.statusCode(200)
50+
.body("fruits", contains("apple", "cherry", "pear"))
51+
.body("fruits.size()", equalTo(3));
52+
// @formatter:on
53+
}
54+
55+
@Test
56+
public void admin() {
57+
// @formatter:off
58+
when()
59+
.get("http://localhost:9000")
60+
.then()
61+
.statusCode(200)
62+
.body(containsString("/admin"));
63+
// @formatter:on
64+
}
65+
66+
}

0 commit comments

Comments
 (0)