Skip to content

Latest commit

 

History

History
46 lines (35 loc) · 1.64 KB

README.md

File metadata and controls

46 lines (35 loc) · 1.64 KB

Build Status Maven Central

Synapse Junit Extension

JUnit extension allowing to run tests against a real Synapse instance.

Usage

@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

<dependency>
  <groupId>com.cosium.synapse_junit_extension</groupId>
  <artifactId>synapse-junit-extension</artifactId>
  <version>${synapse-junit-extension.version}</version>
  <scope>test</scope>
</dependency>

Requirements

  • JDK 11+
  • Docker