Reputation: 8311
I'm running Junit5 test with Testcontainers, in the test I'm starting an image with Maven to execute some commands.
For example, I created a test just to print mvn
version to stdout:
this.net = Network.newNetwork();
this.clientContainer = new GenericContainer<>("maven:3.6.3-jdk-11")
.withWorkingDirectory("/w")
.withClasspathResourceMapping("maven-settings.xml", "/w/settings.xml", BindMode.READ_ONLY)
.withStartupTimeout(Duration.ofSeconds(1))
.withNetwork(net)
.withCommand("tail", "-f", "/dev/null");
this.clientContainer.start();
ExecResult res =this.clientContainer.execInContainer(
StandardCharsets.UTF_8,
"mvn", "-B", "-version"
);
System.out.println("stdout: " + res.getStdout());
But the output looks strange, since it has too many newline characters in stdout:
stdout: Apache
M
a
v
en
3.6.
3
(cec
e
d
d
3
4
3
0
0
2
6
9
6
d
0
a
b
b
5
0
b
3
2
b
5
4
1
b
8
a
6
b
a
2
8
8
3
f
)
M
a
v
e
n
h
o
m
e
:
/
u
s
r
/
s
h
a
r
e
/
m
a
v
e
n
J
a
v
a
v
e
r
s
i
o
n
:
1
1
.
0
.
1
0
,
v
e
n
d
o
r
:
O
r
a
c
l
e
C
o
r
p
o
r
a
t
i
o
n
,
r
u
n
t
i
m
e
:
/
u
s
r
/
l
o
c
a
l
/
o
p
e
n
j
d
k
-
1
1
D
e
f
a
u
l
t
l
o
c
a
l
e
:
e
n
,
p
l
a
t
f
o
r
m
e
n
c
o
d
i
n
g
:
U
T
F
-
8
O
S
n
a
m
e
:
"
l
i
n
u
x
"
,
v
e
r
s
i
o
n
:
"
5
.
1
0
.
8
_
1
"
,
a
r
c
h
:
"
a
m
d
6
4
"
,
f
a
m
i
l
y
:
"
u
n
i
x
"
What could be the problem here? I tried to run with and without -B
option, tried other Maven commands, and tested with specifying charset encoding.
Upvotes: 0
Views: 111
Reputation: 1480
It's a bug of the Tescontainers library itself. However, it was fixed in the latest version 1.15.2
(fix PR), so try to upgrade the Testcontainers.
I was able to reproduce your issue with 1.15.1
version, but not with 1.15.2
anymore.
Upvotes: 3