Class CentralDogmaExtension
java.lang.Object
com.linecorp.centraldogma.testing.junit.AbstractAllOrEachExtension
com.linecorp.centraldogma.testing.junit.CentralDogmaExtension
- All Implemented Interfaces:
AfterAllCallback
,AfterEachCallback
,BeforeAllCallback
,BeforeEachCallback
,Extension
A JUnit
Extension
that starts an embedded Central Dogma server.
> class MyTest {
> @RegisterExtension
> static final CentralDogmaExtension extension = new CentralDogmaExtension();
>
> @Test
> void test() throws Exception {
> CentralDogma dogma = extension.client();
> dogma.push(...).join();
> ...
> }
> }
-
Constructor Summary
ConstructorDescriptionCreates a new instance with TLS disabled.CentralDogmaExtension
(boolean useTls) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
after
(ExtensionContext context) A method that should be run at the end of a test lifecycle.void
before
(ExtensionContext context) A method that should be run at the beginning of a test lifecycle.final BlockingWebClient
Returns the blocking HTTP client.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 Path
dataDir()
Returns thePath
to the server's data directory.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 com.linecorp.centraldogma.testing.junit.AbstractAllOrEachExtension
afterAll, afterEach, beforeAll, beforeEach, runForEachTest
-
Constructor Details
-
CentralDogmaExtension
public CentralDogmaExtension()Creates a new instance with TLS disabled. -
CentralDogmaExtension
public CentralDogmaExtension(boolean useTls) Creates a new instance.
-
-
Method Details
-
before
Description copied from class:AbstractAllOrEachExtension
A method that should be run at the beginning of a test lifecycle. IfAbstractAllOrEachExtension.runForEachTest()
returnsfalse
, this is run once before all tests, otherwise it is run before each test method.- Specified by:
before
in classAbstractAllOrEachExtension
- Throws:
Exception
-
after
Description copied from class:AbstractAllOrEachExtension
A method that should be run at the end of a test lifecycle. IfAbstractAllOrEachExtension.runForEachTest()
returnsfalse
, this is run once after all tests, otherwise it is run after each test method.- Specified by:
after
in classAbstractAllOrEachExtension
- Throws:
Exception
-
dataDir
Returns thePath
to the server's data directory.- Throws:
IllegalStateException
- if the data directory is not created yet
-
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
-
blockingHttpClient
Returns the blocking 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.
-