Skip to content

JUnit extension allowing to run tests against a real Synapse instance

License

Notifications You must be signed in to change notification settings

Cosium/synapse-junit-extension

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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