-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathSiriusExtension.java
More file actions
38 lines (32 loc) · 1.35 KB
/
SiriusExtension.java
File metadata and controls
38 lines (32 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
* Made with all the love in the world
* by scireum in Remshalden, Germany
*
* Copyright by scireum GmbH
* http://www.scireum.de - info@scireum.de
*/
package sirius.kernel;
import org.junit.jupiter.api.extension.BeforeAllCallback;
import org.junit.jupiter.api.extension.BeforeEachCallback;
import org.junit.jupiter.api.extension.ExtensionContext;
import sirius.kernel.async.CallContext;
/**
* JUnit 5 extension to support the Sirius framework lifecycle. Annotated test classes will be provisioned with
* a running framework and a cleared {@link CallContext} before each test.
*/
public class SiriusExtension implements BeforeAllCallback, BeforeEachCallback {
@Override
public void beforeAll(ExtensionContext context) {
// Allow setting restricted HTTP headers, like `Origin:` … Only very few tests actually need this, but it is
// required to set the property before any HttpURLConnection is created, so we do it here globally unless
// the JVM was already configured explicitly.
if (System.getProperty("sun.net.http.allowRestrictedHeaders") == null) {
System.setProperty("sun.net.http.allowRestrictedHeaders", "true");
}
TestHelper.setUp(SiriusExtension.class);
}
@Override
public void beforeEach(ExtensionContext context) throws Exception {
CallContext.initialize();
}
}