Skip to content

Commit

Permalink
Fix NPE for GenericContainer::isRunning (#411) (#412)
Browse files Browse the repository at this point in the history
* Fix NPE for GenericContainer::isRunning (#411)

* Add test for GenericContainer::isRunning (#411)

* Fix not stopped container in test (#411)

* Added comment to CHANGELOG.md (#411)
  • Loading branch information
kprokopchik authored and bsideup committed Jul 25, 2017
1 parent 99b1084 commit 94d7641
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file.
### Fixed
- Worked around incompatibility between Netty's Unix socket support and OS X 10.11. Reinstated use of TCP-Unix Socket proxy when running on OS X prior to v10.12. (Fixes #402)
- Changed to use version 2.0 of the Visible Assertions library for startup pre-flight checks. This no longer has a dependency on Jansi, and is intended to resolve a JVM crash issue apparently caused by native lib version conflicts (#395). Please note that the newer ANSI code is less mature and thus has had less testing, particularly in interesting terminal environments such as Windows. If issues are encountered, coloured assertion output may be disabled by setting the system property `visibleassertions.ansi.enabled` to `true`.
- Fixed NullPointerException when calling GenericContainer#isRunning on not started container (#411)

### Changed
- Removed Guava usage from `jdbc` module (#401)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ public String getIpAddress() {
@Override
public Boolean isRunning() {
try {
return dockerClient.inspectContainerCmd(containerId).exec().getState().getRunning();
return containerId != null && dockerClient.inspectContainerCmd(containerId).exec().getState().getRunning();
} catch (DockerException e) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,15 @@ public static void setupContent() throws FileNotFoundException {
// assertTrue("The list contains an item that was put in (redis is working!)", testList2.contains("baz"));
// }

@Test
public void testIsRunning() {
try (GenericContainer container = new GenericContainer()) {
assertFalse("Container is not started and not running", container.isRunning());
container.start();
assertTrue("Container is started and running", container.isRunning());
}
}

@Test
public void simpleRabbitMqTest() throws IOException, TimeoutException {
ConnectionFactory factory = new ConnectionFactory();
Expand Down

0 comments on commit 94d7641

Please sign in to comment.