Class CentralDogmaRule
java.lang.Object
org.junit.rules.ExternalResource
org.junit.rules.TemporaryFolder
com.linecorp.centraldogma.testing.junit4.CentralDogmaRule
- All Implemented Interfaces:
TestRule
A JUnit
Rule
that starts an embedded Central Dogma server.
> public class MyTest {
> @ClassRule
> public static final CentralDogmaRule rule = new CentralDogmaRule();
>
> @Test
> public void test() throws Exception {
> CentralDogma dogma = rule.client();
> dogma.push(...).join();
> ...
> }
> }
-
Nested Class Summary
Nested classes/interfaces inherited from class org.junit.rules.TemporaryFolder
TemporaryFolder.Builder
-
Constructor Summary
ConstructorDescriptionCreates a new instance with TLS disabled.CentralDogmaRule
(boolean useTls) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
after()
Stops the server and deletes the temporary files created by the server.protected void
before()
Starts an embedded server and callsscaffold(CentralDogma)
.final CentralDogma
client()
Returns the HTTP-basedCentralDogma
client.protected void
configure
(CentralDogmaBuilder builder) Override this method to configure the server.protected void
Override this method to configure the HTTP-basedCentralDogma
client builder.protected void
configureClient
(LegacyCentralDogmaBuilder builder) Override this method to configure the Thrift-basedCentralDogma
client builder.protected void
configureHttpClient
(WebClientBuilder builder) Override this method to configure theWebClient
builder.final CentralDogma
dogma()
Returns the server.final WebClient
Returns the HTTP client.final CentralDogma
Returns the Thrift-basedCentralDogma
client.final MirroringService
Returns theMirroringService
of the server.Returns theProjectManager
of the server.protected void
scaffold
(CentralDogma client) Override this method to perform the initial updates on the server, such as creating a repository and populating sample data.final InetSocketAddress
Returns the server address.final void
start()
Creates a new server, configures it withconfigure(CentralDogmaBuilder)
and starts the server.final CompletableFuture
<Void> Creates a new server, configures it withconfigure(CentralDogmaBuilder)
, and starts the server asynchronously.final void
stop()
Stops the server and deletes the temporary files created by the server.final CompletableFuture
<Void> Stops the server and deletes the temporary files created by the server.boolean
useTls()
Returns whether the server is running over TLS or not.Methods inherited from class org.junit.rules.TemporaryFolder
builder, create, delete, getRoot, newFile, newFile, newFolder, newFolder, newFolder
Methods inherited from class org.junit.rules.ExternalResource
apply
-
Constructor Details
-
CentralDogmaRule
public CentralDogmaRule()Creates a new instance with TLS disabled. -
CentralDogmaRule
public CentralDogmaRule(boolean useTls) Creates a new instance.
-
-
Method Details
-
before
Starts an embedded server and callsscaffold(CentralDogma)
.- Overrides:
before
in classTemporaryFolder
- Throws:
Throwable
-
after
protected void after()Stops the server and deletes the temporary files created by the server.- Overrides:
after
in classTemporaryFolder
-
start
public final void start()Creates a new server, configures it withconfigure(CentralDogmaBuilder)
and starts the server. Note that you don't need to call this method if you did not stop the server withstop()
, because the server is automatically started up by JUnit. -
startAsync
Creates a new server, configures it withconfigure(CentralDogmaBuilder)
, and starts the server asynchronously. -
stop
public final void stop()Stops the server and deletes the temporary files created by the server. Note that you don't usually need to call this method manually because the server is automatically stopped at the end by JUnit. -
stopAsync
Stops the server and deletes the temporary files created by the server. Note that you don't usually need to call this method manually because the server is automatically stopped at the end by JUnit. -
useTls
public boolean useTls()Returns whether the server is running over TLS or not. -
dogma
Returns the server.- Throws:
IllegalStateException
- if Central Dogma did not start yet
-
projectManager
Returns theProjectManager
of the server.- Throws:
IllegalStateException
- if Central Dogma did not start yet
-
mirroringService
Returns theMirroringService
of the server.- Throws:
IllegalStateException
- if Central Dogma did not start yet
-
client
Returns the HTTP-basedCentralDogma
client.- Throws:
IllegalStateException
- if Central Dogma did not start yet
-
legacyClient
Returns the Thrift-basedCentralDogma
client.- Throws:
IllegalStateException
- if Central Dogma did not start yet
-
httpClient
Returns the HTTP client.- Throws:
IllegalStateException
- if Central Dogma did not start yet
-
serverAddress
Returns the server address.- Throws:
IllegalStateException
- if Central Dogma did not start yet
-
configure
Override this method to configure the server. -
configureClient
Override this method to configure the HTTP-basedCentralDogma
client builder. -
configureClient
Override this method to configure the Thrift-basedCentralDogma
client builder. -
configureHttpClient
Override this method to configure theWebClient
builder. -
scaffold
Override this method to perform the initial updates on the server, such as creating a repository and populating sample data.
-