Package software.xdev.tci.network
Class LazyNetwork
java.lang.Object
software.xdev.tci.network.LazyNetwork
- All Implemented Interfaces:
AutoCloseable,org.junit.rules.TestRule,org.testcontainers.containers.Network
A better implementation of
Network in relation to Network.NetworkImpl.
Improvements:
- Allows creation of the network in the background
- Doesn't create the network inside
Network.NetworkImpl.getId() - Doesn't check for duplicate network names when using a random
UUIDas name (see below) - Tries to delete the network when it's closed
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.testcontainers.containers.Network
org.testcontainers.containers.Network.NetworkImpl -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected BooleanBehavior ifnull:falsewhen no name is specified (random UUID), otherwisetruebecause When using a random UUIDv4 as name the chances of collision are extremely small (1 : 2.17 x 10^18)
Wikipedia According to the Docker docs this is "best effort" and not guaranteed to catch all name collisions.protected booleanprotected intprotected Stringprotected Booleanprotected Stringprotected StringBehavior ifnull: random UUID will be chosenprotected CompletableFuture<Void>Fields inherited from interface org.testcontainers.containers.Network
SHARED -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.junit.runners.model.Statementapply(org.junit.runners.model.Statement base, org.junit.runner.Description description) Deprecated, for removal: This API element is subject to removal in a future version.JUNit4 is effectively deadvoidclose()protected voidvoidcreate()voidcreate(Function<Runnable, CompletableFuture<Void>> executor) protected com.github.dockerjava.api.DockerClientintgetId()getName()booleanprotected voidvoidwaitForCreation(Duration timeout) withCheckDuplicate(Boolean checkDuplicate) withCreateNetworkCmdModifier(Consumer<com.github.dockerjava.api.command.CreateNetworkCmd> createNetworkCmdModifier) withDeleteNetworkOnClose(boolean deleteNetworkOnClose) withDeleteNetworkOnCloseTries(int deleteNetworkOnCloseTries) withDriver(String driver) withEnableIpv6(Boolean enableIpv6)
-
Field Details
-
name
Behavior ifnull: random UUID will be chosen -
enableIpv6
-
driver
-
createNetworkCmdModifiers
-
checkDuplicate
Behavior ifnull:falsewhen no name is specified (random UUID), otherwisetruebecause- When using a random UUIDv4 as name the chances of collision are extremely small (1 : 2.17 x 10^18)
Wikipedia - According to the Docker docs this is "best effort" and not guaranteed to catch all name collisions.
- When using a random UUIDv4 as name the chances of collision are extremely small (1 : 2.17 x 10^18)
-
deleteNetworkOnClose
protected boolean deleteNetworkOnClose -
deleteNetworkOnCloseTries
protected int deleteNetworkOnCloseTries -
startCF
-
id
-
-
Constructor Details
-
LazyNetwork
public LazyNetwork()
-
-
Method Details
-
create
public void create() -
create
-
startInternal
protected void startInternal() -
waitForCreation
-
getIdWithoutCheck
-
getId
- Specified by:
getIdin interfaceorg.testcontainers.containers.Network
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceorg.testcontainers.containers.Network
-
closeInternal
protected void closeInternal() -
getClient
protected com.github.dockerjava.api.DockerClient getClient() -
withName
-
withEnableIpv6
-
withDriver
-
withCreateNetworkCmdModifier
public LazyNetwork withCreateNetworkCmdModifier(Consumer<com.github.dockerjava.api.command.CreateNetworkCmd> createNetworkCmdModifier) -
withCheckDuplicate
-
withDeleteNetworkOnClose
-
withDeleteNetworkOnCloseTries
-
getName
-
getEnableIpv6
-
getDriver
-
getCreateNetworkCmdModifiers
-
getCheckDuplicate
-
isDeleteNetworkOnClose
public boolean isDeleteNetworkOnClose() -
getDeleteNetworkOnCloseTries
public int getDeleteNetworkOnCloseTries() -
apply
@Deprecated(forRemoval=true) public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description) Deprecated, for removal: This API element is subject to removal in a future version.JUNit4 is effectively dead- Specified by:
applyin interfaceorg.junit.rules.TestRule
-