JUnit extension allowing to run tests against a real Synapse instance.
@EnableSynapse
class SynapseTest {
@Test
void test(Synapse synapse) throws IOException, InterruptedException {
URI synapseUri = URI.create(synapse.url() + "/_matrix/static/");
HttpResponse<String> response = HttpClient
.newHttpClient()
.send(
HttpRequest.newBuilder(synapseUri).GET().build(),
HttpResponse.BodyHandlers.ofString());
assertThat(response.body()).contains("Synapse is running");
assertThat(response.statusCode()).isEqualTo(200);
}
}
For performance reasons, a single Synapse instance is shared with any test belonging to any class annotated
with @EnableSynapse
. Therefore, you can run a test suite containing as many test classes as you want, Synapse will be started only once. It will shutdown at the end of the JUnit runtime.
<dependency>
<groupId>com.cosium.synapse_junit_extension</groupId>
<artifactId>synapse-junit-extension</artifactId>
<version>${synapse-junit-extension.version}</version>
<scope>test</scope>
</dependency>
- JDK 11+
- Docker