https://github.com/cosium/synapse-junit-extension
JUnit extension allowing to run tests against a real Synapse instance
https://github.com/cosium/synapse-junit-extension
junit junit-extension matrix-org synapse testcontainers
Last synced: about 2 months ago
JSON representation
JUnit extension allowing to run tests against a real Synapse instance
- Host: GitHub
- URL: https://github.com/cosium/synapse-junit-extension
- Owner: Cosium
- License: mit
- Created: 2023-07-01T09:42:42.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2025-02-24T23:23:08.000Z (about 2 months ago)
- Last Synced: 2025-02-25T20:41:21.032Z (about 2 months ago)
- Topics: junit, junit-extension, matrix-org, synapse, testcontainers
- Language: Java
- Homepage:
- Size: 93.8 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/Cosium/synapse-junit-extension/actions/workflows/ci.yml)
[](https://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.cosium.synapse_junit_extension%22%20AND%20a%3A%22synapse-junit-extension%22)# Synapse Junit Extension
[JUnit](https://junit.org) extension allowing to run tests against a real [Synapse](https://github.com/matrix-org/synapse) instance.
# Usage
```java
@EnableSynapse
class SynapseTest {
@Test
void test(Synapse synapse) throws IOException, InterruptedException {
URI synapseUri = URI.create(synapse.url() + "/_matrix/static/");
HttpResponse 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
```xml
com.cosium.synapse_junit_extension
synapse-junit-extension
${synapse-junit-extension.version}
test```
# Requirements
* JDK 11+
* Docker