An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

        

[![Build Status](https://github.com/Cosium/synapse-junit-extension/actions/workflows/ci.yml/badge.svg)](https://github.com/Cosium/synapse-junit-extension/actions/workflows/ci.yml)
[![Maven Central](https://img.shields.io/maven-central/v/com.cosium.synapse_junit_extension/synapse-junit-extension.svg)](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