@Test public void testStartupCommandOverrideApplied() { assertTrue(redisWithCustomPort.isRunning()); // good enough to check that the container started listening } }
@BeforeAll static void doSomethingWithAContainer() { assertTrue(GENERIC_CONTAINER.isRunning()); }
@Test void top_level_containers_should_be_running() { assertTrue(TOP_LEVEL_CONTAINER.isRunning()); }
@Test void top_level_container_should_be_running() { assertTrue(topLevelContainer.isRunning()); topLevelContainerId = topLevelContainer.getContainerId(); }
@Test void both_containers_should_be_running() { assertTrue(topLevelContainer.isRunning()); assertTrue(nestedContainer.isRunning()); if (nestedContainerId == null) { nestedContainerId = nestedContainer.getContainerId(); } else { assertNotEquals(nestedContainerId, nestedContainer.getContainerId()); } }
@Test void top_level_container_should_be_running() { assertTrue(TOP_LEVEL_CONTAINER.isRunning()); topLevelContainerId = TOP_LEVEL_CONTAINER.getContainerId(); }
@Test public void testThatAuthLocatorIsUsed() throws Exception { final DockerImageName expectedName = new DockerImageName(testImageNameWithTag); final AuthConfig authConfig = new AuthConfig() .withUsername("testuser") .withPassword("notasecret") .withRegistryAddress("http://" + testRegistryAddress); // Replace the RegistryAuthLocator singleton with our mock, for the duration of this test final RegistryAuthLocator mockAuthLocator = Mockito.mock(RegistryAuthLocator.class); RegistryAuthLocator.setInstance(mockAuthLocator); when(mockAuthLocator.lookupAuthConfig(eq(expectedName), any())) .thenReturn(authConfig); // a push will use the auth locator for authentication, although that isn't the goal of this test putImageInRegistry(); // actually start a container, which will require an authenticated pull try (final GenericContainer container = new GenericContainer<>(testImageNameWithTag) .withCommand("/bin/sh", "-c", "sleep 10")) { container.start(); assertTrue("container started following an authenticated pull", container.isRunning()); } }
@BeforeClass public static void setUp() throws Exception { TestUtil.ignoreException(() -> { mongo = new GenericContainer("mongo:3") .withNetworkAliases("mongo-" + Base58.randomString(6)) .withExposedPorts(MONGO_DEFAULT_PORT) .waitingFor(new HttpWaitStrategy() .forPort(MONGO_DEFAULT_PORT) .forStatusCodeMatching(response -> response == HTTP_OK || response == HTTP_UNAUTHORIZED) .withStartupTimeout(Duration.ofMinutes(2))); mongo.start(); }, Exception.class); assumeNotNull(mongo); assumeTrue("Mongo DB must be running", mongo.isRunning()); MongoClient mongoClient = new MongoClient(mongo.getContainerIpAddress(), mongo.getMappedPort(MONGO_DEFAULT_PORT)); HOST = String.format("mongodb://%s:%s", mongo.getContainerIpAddress(), mongo.getMappedPort(MONGO_DEFAULT_PORT)); params = map("host", HOST, "db", "test", "collection", "test"); MongoDatabase database = mongoClient.getDatabase("test"); collection = database.getCollection("test"); collection.deleteMany(new Document()); collection.insertOne(new Document(map("name", "testDocument", "date", currentTime, "longValue", longValue))); db = new TestGraphDatabaseFactory() .newImpermanentDatabaseBuilder() .newGraphDatabase(); TestUtil.registerProcedure(db, MongoDB.class); mongoClient.close(); }
public void stop() { if (cassandraContainer.isRunning()) { cassandraContainer.stop(); } }
public void stop() { if (cassandraContainer.isRunning()) { cassandraContainer.stop(); } }
public void start() { if (!cassandraContainer.isRunning()) { cassandraContainer.start(); } }
public void start() { if (!cassandraContainer.isRunning()) { cassandraContainer.start(); } }
public void start() { if (!container.isRunning()) { container.start(); } }
public void performIfRunning(ThrowingConsumer<DockerRabbitMQ> actionPerform) { if (container.isRunning()) { actionPerform.accept(this); } } }