43 questions
3
votes
1
answer
122
views
Testcontainer in a Spring Boot test starts automatically without explicit code or annotation to start
I am playing with Testcontainers and all the different approaches to use within a Spring Boot application. I am facing some strange issue. My tests should not be passing but it does and I don't ...
3
votes
1
answer
49
views
@DynamicPropertySource annotated method inside @TestConfiguration annotated class does not work
I am trying to understand Testcontainers and all the different approaches to use within a Spring Boot application. I landed on a strange issue and could not figure out what is missing.
I have the ...
0
votes
1
answer
247
views
Spring boot - @ServiceConnection doesn't work with KafkaTestContainer
I'm using Spring boot 3.5.6 and below is my container configuration
package com.transmonix.utils;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org....
1
vote
1
answer
274
views
DBRider(DBUnit) won't insert data into test container in spring boot
Can anyone using DBRider / Test Container in spring boot give advice ?
I've been using DBRider/Testcontainer without any issue, but at some point , it doesn't work out.
It seesm ...
0
votes
1
answer
197
views
Why can't I push an image to a local Docker registry started with Testcontainers?
I'm trying to create a local Docker registry using Testcontainers and push an image programatically to it. However, I'm getting a connection refused error when attempting to push the image. The first ...
0
votes
1
answer
261
views
Issue with Manually Setting ID in Spring Boot Integration Test with WebTestClient
Issue with Manually Setting ID in Spring Boot Integration Test with WebTestClient
I am writing an integration test for my Spring Boot controller using WebTestClient. However, when I manually set the ...
3
votes
1
answer
432
views
How to enable SQL logs in PostgreSQLContainer during tests
I have a Java Spring application that uses a PostgreSQL docker container for the tests. I would like to be able to see the SQL logs in that PostgreSQL container, but they do not show up. Can you ...
1
vote
0
answers
622
views
How do I replace DynamicPropertyRegistry as a bean method parameter?
I've got a spring-boot v3.2.5 app that runs successfully using testcontainers. I'm upgrading it to spring-boot v3.4.1.
I create the postgres testcontainer like this. It also sets the property spring....
1
vote
1
answer
249
views
SpringBootTest fails to start SQS container on CI server but not locally
I have the following ControllerIntegration test base class
@TestInstance(Lifecycle.PER_CLASS)
@AutoConfigureMockMvc
@EnableConfigurationProperties
@DirtiesContext(classMode = DirtiesContext.ClassMode....
0
votes
0
answers
715
views
Java TestContainers run with rootless Podman inside a non privileged Container
I want to run a a java TestContainer inside a non privileged container with a rootless podman. My docker commande to start it is like :
$: docker run --security-opt seccomp=unconfined --security-opt ...
0
votes
1
answer
662
views
TestContainers: Can not connect to Ryuk at localhost:50517 after upgrade to macos to Sequoia 15
As a demo project, I use the following:
https://github.com/testcontainers/testcontainers-java-spring-boot-quickstart,
Information about Java and Docker versions is below:
java -version
openjdk version ...
0
votes
0
answers
190
views
Postgress Test Container Fails to Start
Git Repo: https://github.com/SMHosseinM/demo
I'm using Postgress testContainer to spin up a postgress container for my integration test. However, when running the test, the application context fails ...
1
vote
0
answers
150
views
Unable to Instantiate Docker Client for Testcontainers in Gradle Build
I'm working on a Kotlin project that uses Spring Boot, JOOQ for database code generation, and Testcontainers for integration testing with PostgreSQL. My build is managed with Gradle, and I am ...
1
vote
0
answers
129
views
A way to bootstrap Docker environment when running Testcontainers tests?
I wonder if there is a way to bootstrap a Docker environment when running tests with @Testcontainers.
Right now when I run a test:
@Testcontainers
@SpringBootTest
internal class MyTest() {
@...
0
votes
1
answer
436
views
@KafkaListener with containerFactory is not triggered in @SpringBootTest
I am trying to write an integration test for my Kafka consumer using @SpringBootTest and Testcontainers for the underlying infrastructure. My setup looks like this one:
@Component
@...
1
vote
1
answer
2k
views
Issue with Testcontainers @ServiceConnection in AbstractIntegrationTest When Running Multiple Test Classes
I'm experiencing an issue with my integration tests using Testcontainers and the new @ServiceConnection annotation. I have an abstract class AbstractIntegrationTest which is extended by multiple test ...
2
votes
1
answer
142
views
Can we use mocking frameworks for load testing or should we create interfaces to inject dummy data into a class?
I have a service 'S' which has the logic to generate a report and download it. It is written in spring-boot and java. This is consumed by another system 'B' that has the data in its database 'C' that ...
0
votes
0
answers
31
views
spring specify location of propepties file
I have the following class that im using to start my application up locally with some containers (ommitted). For some reason i cant get it to pick up the local props file, it keeps picking up the ...
1
vote
1
answer
457
views
@Transactional in Spring Data MongoDB (+testcontainers)
I am failing to get the transactions to work in my basic spring data mongodb app. I've read articles and similar questions here and nothing seems to help. The test is being run with Testcontainers, ...
0
votes
2
answers
2k
views
When i try to test with Testcontainers more than one TestClass, others always failed
The problem is:
When i try to use singleton-testcontainer, all my testclasses after first failed by assertions.
It means, that even if i see in log that my scenarios was comlete success, Assertions ...
0
votes
1
answer
1k
views
Spring Testcontainers with kafka producer
I'm trying to integrate Testcontainers in my spring boot app.
I'm using Kafka Container to allow sending Kafka messages.
The main issue is that when I send message to kafka correctly, I would like to ...
1
vote
0
answers
2k
views
cannot access org.junit.rules.TestRule withUser("testcontainers") (an integration test for ActiveMQ Artemis)
I have an old project that needed to be connected to ActiveMQ Artemis. Then I decided to write an integration test. However, I get an error at startup.
I use Spring 2.5.14 and build.gradle.
apply ...
0
votes
1
answer
1k
views
Testcontainers access denied
I try to create JpaTest, for this I need a container with mariaDb. So I try create it:
private static final String CONTAINER_IMAGE_NAME = TestcontainersConfiguration.getInstance()
....
1
vote
1
answer
467
views
Creating a table in integration test before post construct of main component
I have a component where I have this code
@PostConstruct
public void initWeekMonthData() {
testData = repository.findAllActiveRecords();
}
Now I'm trying to write integration test ...
0
votes
1
answer
227
views
GitHub Actions: Permission denied when running GreenMailExtension for SMTP in test workflow
I have a testing workflow named "Test Project" set up in GitHub Actions, which includes a Maven test phase invoking a test class called RegistrationTest. This test class uses the ...
9
votes
1
answer
978
views
SpringBoot Data Mongodb with Testcontainers lead to "Prematurely reached end of stream"
It started after I upgraded my SB application to 3.2.0. I initially thought there was something wrong with my spring context. So after a couple of days banging my head against the wall, I finally ...
0
votes
0
answers
160
views
SpringBootTest: How to avoid the need of starting a container
I have SpringBootTests that use org.testcontainer:postgres for integration tests.
While thats very useful for tests that involve the database, it's quite useless when the database isn't needed. Let's ...
2
votes
1
answer
672
views
Start-up hook in testcontainers and Spring Boot 3.1
We would like to utilize the enhanced Testcontainers support in Spring Boot 3.1 As a consequence, the Spring itself is now responsible for starting the containers, whereas previously we had full ...
1
vote
2
answers
3k
views
Testcontainers start first test so long
I'm following this document to build a spring-boot application with org.springframework.boot:spring-boot-testcontainers dependency. I'm running the test in IntelliJ IDEA 2022.1
java version 17
org....
1
vote
1
answer
1k
views
How to enable multiple databases of ServiceConnection type using testcontainer in a spring boot application
I am using multipleDatasources in my spring boot application where we connect to postgres and mysql. it is working as expected but when I want to integrate it with TestContainers in dev mode . I have ...
3
votes
4
answers
3k
views
Spring boot multiple tests with testcontainers
I am trying to use Spring Boot Tests with test containers. I wrote an abstract integration tests that all integration tests are using.
@Testcontainers
@Transactional
@ActiveProfiles("test")
@...
0
votes
2
answers
917
views
@DynamicPropertySource does not override KafkaProperties
I am using Kafka from TestContainer, and @DynamicPropertySource does not override the KafkaProperties that I am using in the application code (src/main).
KafkaProperties are load in the context even ...
1
vote
2
answers
3k
views
Mapped port can only be obtained after the container is started - Testcontainers with @ServiceConnection and Spring 3.1.4
I'm trying to update my tests to use the latest support for Spring 3.1.4 for testcontainers, which replaces the @DynamicSource annotation with @ServiceConnection as per here .
However, I'm getting ...
1
vote
1
answer
939
views
Test Kafka listener with custom container factory in spring boot
I'm having big troubles trying to test a kafka listener.
The class is the following:
@Component
class KafkaListener(
private val useCase: UseCase
) {
@KafkaListener(
topics = [&...
0
votes
1
answer
904
views
How do you configure the logging driver for container using testcontainers?
When I write a docker-compose file I can insert a logging section like so:
logging:
options:
max-size: 10m
max-file: "3"
How can I congfigure my GenericContainer to have a logging ...
1
vote
0
answers
274
views
Using 2 buckets inside test container for couchbase in spring boot application
We are trying to write integration tests for our usecase where we have 2 buckets in couchbase database and I am trying to create test container with those 2 buckets. I have something like
new ...
0
votes
1
answer
1k
views
TestContainers with Spring Boot 3.0 and Keycloak: Should I use Keycloak Container for Unit or Integration Tests?
I'm in the process of exploring TestContainers with Spring Boot 3.0 for my Hello World application which has security-enabled endpoints. In the past, I relied on mocked tokens for unit testing ...
1
vote
0
answers
4k
views
How to run docker-compose file using testContainers in spring boot tests?
I have following docker-compose file for local development:
version: '3.4'
services:
samba:
image: instantlinux/samba-dc:latest
hostname: my.org
environment:
DOMAIN_ACTION: ...
2
votes
2
answers
6k
views
How to use @ServiceConnection with GenericContainer and custom ConnectionDetails
I am using new @ServiceConnection annotation to manage KafkaContainer in my tests and it works as expected - KafkaContainerConnectionDetails is used during auto configuration to override bootstrap ...
0
votes
1
answer
2k
views
Testcontainers start before Spring app and shut down after Spring App
I have this integration test:
@RunWith(SpringRunner.class)
@SpringBootTest(classes = MySpringApplication.class, webEnvironment = DEFINED_PORT)
public class UspControllerIT {
@Test
public void ...
1
vote
0
answers
90
views
Spring boot testcontainers configured via properties to use r2dbc throws java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
This is my application-it.yml file:
spring:
r2dbc:
url: r2dbc:tc:mysql:///warehouse-db?TC_IMAGE_TAG=latest
Here are my dependencies from pom.xml:
<dependencies>
<dependency>
...
0
votes
1
answer
201
views
Running Spring Boot Application in Dev Mode causes beans to be duplicated
I want to run my Spring Boot application in the dev mode:
My main (prod app):
fun main(args: Array<String>) {
runApplication<MyApp>(args = args, init = {
addInitializers(...
0
votes
2
answers
472
views
Spring Boot TestContainers Create application from an existing main method in Kotlin
I have a Spring Boot application:
@SpringBootApplication
class MyApp
fun main(args: Array<String>) {
val initConfig: SpringApplication.() -> Unit = {
addInitializers(...