Skip to content

Commit 7c13ba9

Browse files
committed
issue #289
1 parent 3a3c77a commit 7c13ba9

File tree

30 files changed

+1337
-19169
lines changed

30 files changed

+1337
-19169
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package eu.clarin.cmdi.curation.api;
2+
3+
import org.junit.jupiter.api.BeforeAll;
4+
import org.junit.jupiter.api.BeforeEach;
5+
import org.mockserver.client.MockServerClient;
6+
import org.mockserver.logging.MockServerLogger;
7+
import org.mockserver.socket.tls.KeyStoreFactory;
8+
import org.mockserver.springtest.MockServerTest;
9+
10+
import javax.net.ssl.HttpsURLConnection;
11+
import java.io.IOException;
12+
import java.net.URISyntaxException;
13+
import java.nio.file.Files;
14+
import java.nio.file.Paths;
15+
16+
import static org.mockserver.model.HttpRequest.request;
17+
import static org.mockserver.model.HttpResponse.response;
18+
19+
@MockServerTest
20+
public class BaseTest {
21+
22+
private MockServerClient mockServerClient;
23+
24+
@BeforeAll
25+
public static void init() throws IOException {
26+
// ensure all connection using HTTPS will use the SSL context defined by
27+
// MockServer to allow dynamically generated certificates to be accepted
28+
HttpsURLConnection.setDefaultSSLSocketFactory(new KeyStoreFactory(new MockServerLogger()).sslContext().getSocketFactory());
29+
}
30+
@BeforeEach
31+
public void createExpectations() throws URISyntaxException, IOException {
32+
this.mockServerClient
33+
.when(
34+
request()
35+
.withPath("/ds/ComponentRegistry/rest/registry/1.x/profiles")
36+
)
37+
.respond(
38+
response()
39+
.withBody("""
40+
<profileDescriptions>
41+
<profileDescription>
42+
<id>clarin.eu:cr1:p_1380106710826</id>
43+
<name>teiHeader</name>
44+
<description>
45+
TEI header. Supplies the descriptive and declarative information making up an electronic title page prefixed to every TEI-conformant text. Version 2.5.0. Last updated on 26th July 2013 http://www.tei-c.org/release/doc/tei-p5-doc/en/html/ref-teiHeader.html
46+
</description>
47+
<status>PRODUCTION</status>
48+
</profileDescription>
49+
</profileDescriptions>
50+
""")
51+
);
52+
this.mockServerClient
53+
.when(
54+
request()
55+
.withPath("/ds/ComponentRegistry/rest/registry/1.x/profiles/clarin.eu:cr1:p_1380106710826/xsd")
56+
)
57+
.respond(
58+
response()
59+
.withBody(Files.readString(Paths.get(getClass().getResource("/profile/teiHeader.xsd").toURI())))
60+
);
61+
this.mockServerClient
62+
.when(
63+
request()
64+
)
65+
.respond(
66+
response()
67+
.withStatusCode(200)
68+
);
69+
}
70+
}

0 commit comments

Comments
 (0)