Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static synchronized ImagePullPolicy defaultPolicy() {
.currentThread()
.getContextClassLoader()
.loadClass(imagePullPolicyClassName)
.getConstructor()
.getDeclaredConstructor()
.newInstance();
} catch (Exception e) {
throw new IllegalArgumentException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,20 @@ public void simpleConfigurationTest() {
container.stop();
}
}

@Test
public void alwaysPullConfigurationTest() {
Mockito
.doReturn(AlwaysPullPolicy.class.getCanonicalName())
.when(TestcontainersConfiguration.getInstance())
.getImagePullPolicy();

try (DockerRegistryContainer registry = new DockerRegistryContainer()) {
registry.start();
GenericContainer<?> container = new GenericContainer<>(registry.createImage()).withExposedPorts(8080);
container.start();
assertThat(container.getImage().imagePullPolicy).isInstanceOf(AlwaysPullPolicy.class);
container.stop();
}
}
}
8 changes: 8 additions & 0 deletions docs/features/advanced_options.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ You can also configure Testcontainers to use your custom implementation by using
pull.policy=com.mycompany.testcontainers.ExampleImagePullPolicy
```

You can also use the provided implementation to always pull images

=== "`src/test/resources/testcontainers.properties`"
```text
pull.policy=org.testcontainers.images.AlwaysPullPolicy
```


Please see [the documentation on configuration mechanisms](./configuration.md) for more information.

## Customizing the container
Expand Down
Loading