Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed HostPortWaitStrategy throws NumberFormatException when port is exposed but not mapped #640

Merged
merged 2 commits into from
Apr 11, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file.
## UNRELEASED

### Fixed
- Fixed `HostPortWaitStrategy` throws `NumberFormatException` when port is exposed but not mapped [\#640](https://github.com/testcontainers/testcontainers-java/issues/640))

### Changed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;

public interface ContainerState {
Expand Down Expand Up @@ -127,6 +128,7 @@ default List<Integer> getBoundPortNumbers() {
.map(PortBinding::parse)
.map(PortBinding::getBinding)
.map(Ports.Binding::getHostPortSpec)
.filter(Objects::nonNull)
.map(Integer::valueOf)
.collect(Collectors.toList());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package org.testcontainers.junit;

import org.junit.Rule;
import org.junit.Test;
import org.testcontainers.containers.DockerComposeContainer;

import java.io.File;

import static org.rnorth.visibleassertions.VisibleAssertions.pass;

public class DockerComposeExposedPortTest {

@Rule
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please convert it to try-with-resources-style and maybe just add to some other Docker Compose test

public DockerComposeContainer environment = new DockerComposeContainer(new File("src/test/resources/compose-exposedport-test.yml"))
.withExposedService("redis_1", 6379);