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

Using newArrayList for withExposedPorts method in order to allow addExposedPort later #453

Merged
merged 1 commit into from
Sep 16, 2017
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 @@ -42,7 +42,7 @@
import java.util.function.Consumer;
import java.util.stream.Collectors;

import static java.util.Arrays.asList;
import static com.google.common.collect.Lists.newArrayList;
import static org.testcontainers.containers.output.OutputFrame.OutputType.STDERR;
import static org.testcontainers.containers.output.OutputFrame.OutputType.STDOUT;
import static org.testcontainers.utility.CommandLine.runShellCommand;
Expand Down Expand Up @@ -554,7 +554,7 @@ protected void finished(Description description) {
*/
@Override
public SELF withExposedPorts(Integer... ports) {
this.setExposedPorts(asList(ports));
this.setExposedPorts(newArrayList(ports));
return self();

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.rnorth.visibleassertions.VisibleAssertions.*;
import static org.testcontainers.containers.BindMode.READ_ONLY;
import static org.testcontainers.containers.BindMode.READ_WRITE;
Expand Down Expand Up @@ -338,4 +339,12 @@ private BufferedReader getReaderForContainerPort80(GenericContainer container) {
return new BufferedReader(new InputStreamReader(socket.getInputStream()));
});
}

@Test
public void addExposedPortAfterWithExposedPortsTest() {
redis.addExposedPort(8987);
assertThat("Both ports should be exposed", redis.getExposedPorts().size(), equalTo(2));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would love to use containsInAnyOrder instead of this series of assertions, but it is not available in dependencies and I don't feel like I can add it just for this case.

assertTrue("withExposedPort should be exposed", redis.getExposedPorts().contains(REDIS_PORT));
assertTrue("addExposedPort should be exposed", redis.getExposedPorts().contains(8987));
}
}