From c3337823269e4be4f3e4dbc9eb6bb4dc880b98f9 Mon Sep 17 00:00:00 2001 From: Nick Miyake Date: Fri, 3 Jun 2016 20:49:16 -0700 Subject: [PATCH] Use consistent naming scheme for test classes and methods --- ...Test.java => DockerComposeRuleShould.java} | 29 ++++++++------- ...AdditionalEnvironmentValidatorShould.java} | 6 ++-- ... => DaemonEnvironmentValidatorShould.java} | 6 ++-- ...t.java => DaemonHostIpResolverShould.java} | 8 ++--- ...est.java => DockerComposeFilesShould.java} | 14 ++++---- ...ctNameTest.java => ProjectNameShould.java} | 16 ++++----- ... => RemoteEnvironmentValidatorShould.java} | 10 +++--- ...t.java => RemoteHostIpResolverShould.java} | 6 ++-- ...cheTest.java => ContainerCacheShould.java} | 6 ++-- ...mesTest.java => ContainerNamesShould.java} | 14 ++++---- ...ontainerTest.java => ContainerShould.java} | 14 ++++---- ...ilderTest.java => LocalBuilderShould.java} | 30 ++++++++-------- .../{PortsTest.java => PortsShould.java} | 19 +++++----- ...lderTest.java => RemoteBuilderShould.java} | 10 +++--- ...poseTest.java => DockerComposeShould.java} | 36 +++++++++++-------- ...t.java => DockerComposeVersionShould.java} | 2 +- ...rTest.java => FileLogCollectorShould.java} | 25 +++++++------ ...t.java => AvailablePortMatcherShould.java} | 6 ++-- 18 files changed, 139 insertions(+), 118 deletions(-) rename src/test/java/com/palantir/docker/compose/{DockerComposeRuleTest.java => DockerComposeRuleShould.java} (85%) rename src/test/java/com/palantir/docker/compose/configuration/{AdditionalEnvironmentValidatorTest.java => AdditionalEnvironmentValidatorShould.java} (88%) rename src/test/java/com/palantir/docker/compose/configuration/{DaemonEnvironmentValidatorTest.java => DaemonEnvironmentValidatorShould.java} (89%) rename src/test/java/com/palantir/docker/compose/configuration/{DaemonHostIpResolverTest.java => DaemonHostIpResolverShould.java} (81%) rename src/test/java/com/palantir/docker/compose/configuration/{DockerComposeFilesTest.java => DockerComposeFilesShould.java} (83%) rename src/test/java/com/palantir/docker/compose/configuration/{ProjectNameTest.java => ProjectNameShould.java} (84%) rename src/test/java/com/palantir/docker/compose/configuration/{RemoteEnvironmentValidatorTest.java => RemoteEnvironmentValidatorShould.java} (88%) rename src/test/java/com/palantir/docker/compose/configuration/{RemoteHostIpResolverTest.java => RemoteHostIpResolverShould.java} (89%) rename src/test/java/com/palantir/docker/compose/connection/{ContainerCacheTest.java => ContainerCacheShould.java} (89%) rename src/test/java/com/palantir/docker/compose/connection/{ContainerNamesTest.java => ContainerNamesShould.java} (81%) rename src/test/java/com/palantir/docker/compose/connection/{ContainerTest.java => ContainerShould.java} (89%) rename src/test/java/com/palantir/docker/compose/connection/{LocalBuilderTest.java => LocalBuilderShould.java} (88%) rename src/test/java/com/palantir/docker/compose/connection/{PortsTest.java => PortsShould.java} (80%) rename src/test/java/com/palantir/docker/compose/connection/{RemoteBuilderTest.java => RemoteBuilderShould.java} (89%) rename src/test/java/com/palantir/docker/compose/execution/{DockerComposeTest.java => DockerComposeShould.java} (80%) rename src/test/java/com/palantir/docker/compose/execution/{DockerComposeVersionTest.java => DockerComposeVersionShould.java} (97%) rename src/test/java/com/palantir/docker/compose/logging/{FileLogCollectorTest.java => FileLogCollectorShould.java} (87%) rename src/test/java/com/palantir/docker/compose/matchers/{AvailablePortMatcherTest.java => AvailablePortMatcherShould.java} (90%) diff --git a/src/test/java/com/palantir/docker/compose/DockerComposeRuleTest.java b/src/test/java/com/palantir/docker/compose/DockerComposeRuleShould.java similarity index 85% rename from src/test/java/com/palantir/docker/compose/DockerComposeRuleTest.java rename to src/test/java/com/palantir/docker/compose/DockerComposeRuleShould.java index 5a7e1d428..de0d1bb3a 100644 --- a/src/test/java/com/palantir/docker/compose/DockerComposeRuleTest.java +++ b/src/test/java/com/palantir/docker/compose/DockerComposeRuleShould.java @@ -59,7 +59,7 @@ import org.mockito.runners.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) -public class DockerComposeRuleTest { +public class DockerComposeRuleShould { private static final String IP = "127.0.0.1"; @@ -85,21 +85,21 @@ public class DockerComposeRuleTest { } @Test - public void docker_compose_build_and_up_is_called_before_tests_are_run() throws IOException, InterruptedException { + public void call_build_and_up_before_tests_are_run() throws IOException, InterruptedException { rule.before(); verify(dockerCompose).build(); verify(dockerCompose).up(); } @Test - public void docker_compose_kill_and_rm_are_called_after_tests_are_run() throws IOException, InterruptedException { + public void call_kill_and_rm_after_tests_are_run() throws IOException, InterruptedException { rule.after(); verify(dockerCompose).kill(); verify(dockerCompose).rm(); } @Test - public void docker_compose_wait_for_service_passes_when_check_is_true() throws IOException, InterruptedException { + public void pass_wait_for_service_when_check_is_true() throws IOException, InterruptedException { AtomicInteger timesCheckCalled = new AtomicInteger(0); withComposeExecutableReturningContainerFor("db"); HealthCheck checkCalledOnce = (container) -> SuccessOrFailure.fromBoolean(timesCheckCalled.incrementAndGet() == 1, "not called once yet"); @@ -108,7 +108,7 @@ public void docker_compose_wait_for_service_passes_when_check_is_true() throws I } @Test - public void docker_compose_wait_for_service_waits_multiple_services() throws IOException, InterruptedException { + public void wait_for_multiple_services_on_wait() throws IOException, InterruptedException { Container db1 = withComposeExecutableReturningContainerFor("db1"); Container db2 = withComposeExecutableReturningContainerFor("db2"); List containers = ImmutableList.of(db1, db2); @@ -122,7 +122,7 @@ public void docker_compose_wait_for_service_waits_multiple_services() throws IOE } @Test - public void docker_compose_wait_for_service_passes_when_check_is_true_after_being_false() throws IOException, InterruptedException { + public void pass_wait_for_service_when_check_is_true_after_being_false() throws IOException, InterruptedException { AtomicInteger timesCheckCalled = new AtomicInteger(0); withComposeExecutableReturningContainerFor("db"); HealthCheck checkCalledTwice = (container) -> SuccessOrFailure.fromBoolean(timesCheckCalled.incrementAndGet() == 2, "not called twice yet"); @@ -131,7 +131,8 @@ public void docker_compose_wait_for_service_passes_when_check_is_true_after_bein } @Test - public void throws_if_a_wait_for_service_check_remains_false_till_the_timeout() throws IOException, InterruptedException { + public void throw_exception_if_a_wait_for_service_check_remains_false_until_the_timeout() + throws IOException, InterruptedException { withComposeExecutableReturningContainerFor("db"); exception.expect(IllegalStateException.class); @@ -142,7 +143,7 @@ public void throws_if_a_wait_for_service_check_remains_false_till_the_timeout() } @Test - public void port_for_container_can_be_retrieved_by_external_mapping() throws IOException, InterruptedException { + public void retrieve_port_for_container_by_external_mapping() throws IOException, InterruptedException { DockerPort expectedPort = env.port("db", IP, 5433, 5432); withComposeExecutableReturningContainerFor("db"); @@ -152,7 +153,7 @@ public void port_for_container_can_be_retrieved_by_external_mapping() throws IOE } @Test - public void port_for_container_can_be_retrieved_by_internal_mapping() throws IOException, InterruptedException { + public void retrieve_port_for_container_by_internal_mapping() throws IOException, InterruptedException { DockerPort expectedPort = env.port("db", IP, 5433, 5432); withComposeExecutableReturningContainerFor("db"); @@ -162,7 +163,7 @@ public void port_for_container_can_be_retrieved_by_internal_mapping() throws IOE } @Test - public void when_two_external_ports_on_a_container_are_requested_docker_compose_ps_is_only_executed_once() throws Exception { + public void execute_ps_once_when_two_external_ports_on_a_container_are_requested() throws Exception { env.ports("db", IP, 5432, 8080); withComposeExecutableReturningContainerFor("db"); @@ -173,7 +174,8 @@ public void when_two_external_ports_on_a_container_are_requested_docker_compose_ } @Test - public void waiting_for_service_that_does_not_exist_results_in_an_illegal_state_exception() throws IOException, InterruptedException { + public void throw_illegal_state_exception_when_waiting_for_service_that_does_not_exist() + throws IOException, InterruptedException { String nonExistentContainer = "nonExistent"; when(dockerCompose.ports(nonExistentContainer)) .thenThrow(new IllegalStateException("No container with name 'nonExistent' found")); @@ -187,7 +189,8 @@ public void waiting_for_service_that_does_not_exist_results_in_an_illegal_state_ @SuppressWarnings("unchecked") @Test - public void logs_can_be_saved_to_a_directory_while_containers_are_running() throws IOException, InterruptedException { + public void be_able_to_save_logs_to_a_directory_while_containers_are_running() + throws IOException, InterruptedException { File logLocation = logFolder.newFolder(); DockerComposeRule loggingComposition = DockerComposeRule.builder().from(rule).saveLogsTo(logLocation.getAbsolutePath()).build(); when(dockerCompose.ps()).thenReturn(new ContainerNames("db")); @@ -206,7 +209,7 @@ public void logs_can_be_saved_to_a_directory_while_containers_are_running() thro } @Test - public void when_skipShutdown_is_true_shutdown_does_not_happen() throws InterruptedException { + public void not_shut_down_when_skipShutdown_is_true() throws InterruptedException { defaultBuilder().skipShutdown(true) .build() .after(); diff --git a/src/test/java/com/palantir/docker/compose/configuration/AdditionalEnvironmentValidatorTest.java b/src/test/java/com/palantir/docker/compose/configuration/AdditionalEnvironmentValidatorShould.java similarity index 88% rename from src/test/java/com/palantir/docker/compose/configuration/AdditionalEnvironmentValidatorTest.java rename to src/test/java/com/palantir/docker/compose/configuration/AdditionalEnvironmentValidatorShould.java index 0a04a48a2..7f8d85509 100644 --- a/src/test/java/com/palantir/docker/compose/configuration/AdditionalEnvironmentValidatorTest.java +++ b/src/test/java/com/palantir/docker/compose/configuration/AdditionalEnvironmentValidatorShould.java @@ -24,13 +24,13 @@ import org.junit.Test; import org.junit.rules.ExpectedException; -public class AdditionalEnvironmentValidatorTest { +public class AdditionalEnvironmentValidatorShould { @Rule public ExpectedException exception = ExpectedException.none(); @Test - public void additional_environment_variables_with_docker_variables() throws Exception { + public void throw_exception_when_additional_environment_variables_contain_docker_variables() throws Exception { Map variables = ImmutableMap.builder().put("DOCKER_HOST", "tcp://some-host:2376") .put("SOME_VARIABLE", "Some Value") .build(); @@ -42,7 +42,7 @@ public void additional_environment_variables_with_docker_variables() throws Exce } @Test - public void valid_arbitrary_environment_variables() throws Exception { + public void validate_arbitrary_environment_variables() throws Exception { Map variables = ImmutableMap.builder().put("SOME_VARIABLE", "Some Value") .build(); diff --git a/src/test/java/com/palantir/docker/compose/configuration/DaemonEnvironmentValidatorTest.java b/src/test/java/com/palantir/docker/compose/configuration/DaemonEnvironmentValidatorShould.java similarity index 89% rename from src/test/java/com/palantir/docker/compose/configuration/DaemonEnvironmentValidatorTest.java rename to src/test/java/com/palantir/docker/compose/configuration/DaemonEnvironmentValidatorShould.java index 04b545ee7..cc3dfc42a 100644 --- a/src/test/java/com/palantir/docker/compose/configuration/DaemonEnvironmentValidatorTest.java +++ b/src/test/java/com/palantir/docker/compose/configuration/DaemonEnvironmentValidatorShould.java @@ -27,13 +27,13 @@ import org.junit.Test; import org.junit.rules.ExpectedException; -public class DaemonEnvironmentValidatorTest { +public class DaemonEnvironmentValidatorShould { @Rule public ExpectedException exception = ExpectedException.none(); @Test - public void docker_environment_does_not_contain_docker_variables() throws Exception { + public void validate_successfully_when_docker_environment_does_not_contain_docker_variables() throws Exception { Map variables = ImmutableMap.builder() .put("SOME_VARIABLE", "SOME_VALUE") .put("ANOTHER_VARIABLE", "ANOTHER_VALUE") @@ -43,7 +43,7 @@ public void docker_environment_does_not_contain_docker_variables() throws Except } @Test - public void docker_environment_contains_illegal_docker_variables() throws Exception { + public void throw_exception_when_docker_environment_contains_illegal_docker_variables() throws Exception { Map variables = ImmutableMap.builder() .put(DOCKER_HOST, "tcp://192.168.99.100:2376") .put(DOCKER_TLS_VERIFY, "1") diff --git a/src/test/java/com/palantir/docker/compose/configuration/DaemonHostIpResolverTest.java b/src/test/java/com/palantir/docker/compose/configuration/DaemonHostIpResolverShould.java similarity index 81% rename from src/test/java/com/palantir/docker/compose/configuration/DaemonHostIpResolverTest.java rename to src/test/java/com/palantir/docker/compose/configuration/DaemonHostIpResolverShould.java index 6197ea859..0c38536be 100644 --- a/src/test/java/com/palantir/docker/compose/configuration/DaemonHostIpResolverTest.java +++ b/src/test/java/com/palantir/docker/compose/configuration/DaemonHostIpResolverShould.java @@ -21,20 +21,20 @@ import org.junit.Test; -public class DaemonHostIpResolverTest { +public class DaemonHostIpResolverShould { @Test - public void daemon_returns_local_host_with_null() throws Exception { + public void return_local_host_with_null() throws Exception { assertThat(new DaemonHostIpResolver().resolveIp(null), is(LOCALHOST)); } @Test - public void daemon_returns_local_host_with_blank() throws Exception { + public void return_local_host_with_blank() throws Exception { assertThat(new DaemonHostIpResolver().resolveIp(""), is(LOCALHOST)); } @Test - public void daemon_returns_local_host_with_arbitrary() throws Exception { + public void return_local_host_with_arbitrary() throws Exception { assertThat(new DaemonHostIpResolver().resolveIp("arbitrary"), is(LOCALHOST)); } diff --git a/src/test/java/com/palantir/docker/compose/configuration/DockerComposeFilesTest.java b/src/test/java/com/palantir/docker/compose/configuration/DockerComposeFilesShould.java similarity index 83% rename from src/test/java/com/palantir/docker/compose/configuration/DockerComposeFilesTest.java rename to src/test/java/com/palantir/docker/compose/configuration/DockerComposeFilesShould.java index fc835a63a..f88043199 100644 --- a/src/test/java/com/palantir/docker/compose/configuration/DockerComposeFilesTest.java +++ b/src/test/java/com/palantir/docker/compose/configuration/DockerComposeFilesShould.java @@ -26,7 +26,7 @@ import org.junit.rules.ExpectedException; import org.junit.rules.TemporaryFolder; -public class DockerComposeFilesTest { +public class DockerComposeFilesShould { @Rule public final TemporaryFolder tempFolder = new TemporaryFolder(); @@ -35,14 +35,14 @@ public class DockerComposeFilesTest { public final ExpectedException exception = ExpectedException.none(); @Test - public void notSpecifyingAComposeFileResultsInError() throws Exception { + public void throw_exception_when_compose_file_is_not_specified() throws Exception { exception.expect(IllegalArgumentException.class); exception.expectMessage("A docker compose file must be specified."); DockerComposeFiles.from(); } @Test - public void missingDockerComposeFileThrowsAnException() throws Exception { + public void throw_exception_when_compose_file_does_not_exist() throws Exception { exception.expect(IllegalStateException.class); exception.expectMessage("The following docker-compose files:"); exception.expectMessage("does-not-exist.yaml"); @@ -51,7 +51,9 @@ public void missingDockerComposeFileThrowsAnException() throws Exception { } @Test - public void aSingleMissingComposeFileWithAnExistingComposeFileThrowsCorrectException() throws Exception { + public void + throw_correct_exception_when_there_is_a_single_missing_compose_file_with_an_existing_compose_file() + throws Exception { exception.expect(IllegalStateException.class); exception.expectMessage("The following docker-compose files:"); exception.expectMessage("does-not-exist.yaml"); @@ -63,14 +65,14 @@ public void aSingleMissingComposeFileWithAnExistingComposeFileThrowsCorrectExcep } @Test - public void dockerComposeFileCommandGetsGeneratedCorrectly_singleComposeFile() throws Exception { + public void generate_docker_compose_file_command_correctly_for_single_compose_file() throws Exception { File composeFile = tempFolder.newFile("docker-compose.yaml"); DockerComposeFiles dockerComposeFiles = DockerComposeFiles.from(composeFile.getAbsolutePath()); assertThat(dockerComposeFiles.constructComposeFileCommand(), contains("--file", composeFile.getAbsolutePath())); } @Test - public void dockerComposeFileCommandGetsGeneratedCorrectly_multipleComposeFile() throws Exception { + public void generate_docker_compose_file_command_correctly_for_multiple_compose_files() throws Exception { File composeFile1 = tempFolder.newFile("docker-compose1.yaml"); File composeFile2 = tempFolder.newFile("docker-compose2.yaml"); DockerComposeFiles dockerComposeFiles = DockerComposeFiles.from(composeFile1.getAbsolutePath(), composeFile2.getAbsolutePath()); diff --git a/src/test/java/com/palantir/docker/compose/configuration/ProjectNameTest.java b/src/test/java/com/palantir/docker/compose/configuration/ProjectNameShould.java similarity index 84% rename from src/test/java/com/palantir/docker/compose/configuration/ProjectNameTest.java rename to src/test/java/com/palantir/docker/compose/configuration/ProjectNameShould.java index 440628a3c..851b4f31e 100644 --- a/src/test/java/com/palantir/docker/compose/configuration/ProjectNameTest.java +++ b/src/test/java/com/palantir/docker/compose/configuration/ProjectNameShould.java @@ -27,13 +27,13 @@ import org.junit.Test; import org.junit.rules.ExpectedException; -public class ProjectNameTest { +public class ProjectNameShould { @Rule public final ExpectedException exception = ExpectedException.none(); @Test - public void construct_compose_command_should_use_project_name_prefix() { + public void use_project_name_prefix_in_construct_compose_command() { List command = ProjectName.random().constructComposeFileCommand(); assertThat(command, hasSize(2)); @@ -41,7 +41,7 @@ public void construct_compose_command_should_use_project_name_prefix() { } @Test - public void successive_calls_to_random_should_produce_different_names() { + public void produce_different_names_on_successive_calls_to_random() { List firstCommand = ProjectName.random().constructComposeFileCommand(); List secondCommand = ProjectName.random().constructComposeFileCommand(); @@ -49,32 +49,32 @@ public void successive_calls_to_random_should_produce_different_names() { } @Test - public void random_should_be_eight_characters_long() { + public void have_eight_characters_long_random() { String randomName = ProjectName.random().constructComposeFileCommand().get(1); assertThat(randomName.length(), is(8)); } @Test - public void from_string_factory_should_pass_name_to_command() { + public void should_pass_name_to_command_in_from_string_factory() { List command = ProjectName.fromString("projectname").constructComposeFileCommand(); assertThat(command, contains("--project-name", "projectname")); } @Test - public void from_string_factory_should_disallow_names() { + public void should_disallow_names_in_from_string_factory() { List command = ProjectName.fromString("projectname").constructComposeFileCommand(); assertThat(command, contains("--project-name", "projectname")); } @Test - public void from_string_should_reject_blanks() { + public void reject_blanks_in_from_string() { exception.expect(IllegalStateException.class); exception.expectMessage("ProjectName must not be blank."); ProjectName.fromString(" "); } @Test - public void validation_should_match_docker_compose_cli() { + public void match_validation_behavior_of_docker_compose_cli() { exception.expect(IllegalStateException.class); exception.expectMessage("ProjectName 'Crazy#Proj ect!Name' not allowed, please use lowercase letters and numbers only."); ProjectName.fromString("Crazy#Proj ect!Name"); diff --git a/src/test/java/com/palantir/docker/compose/configuration/RemoteEnvironmentValidatorTest.java b/src/test/java/com/palantir/docker/compose/configuration/RemoteEnvironmentValidatorShould.java similarity index 88% rename from src/test/java/com/palantir/docker/compose/configuration/RemoteEnvironmentValidatorTest.java rename to src/test/java/com/palantir/docker/compose/configuration/RemoteEnvironmentValidatorShould.java index b2f81b1fa..4ff69502b 100644 --- a/src/test/java/com/palantir/docker/compose/configuration/RemoteEnvironmentValidatorTest.java +++ b/src/test/java/com/palantir/docker/compose/configuration/RemoteEnvironmentValidatorShould.java @@ -27,13 +27,13 @@ import org.junit.Test; import org.junit.rules.ExpectedException; -public class RemoteEnvironmentValidatorTest { +public class RemoteEnvironmentValidatorShould { @Rule public ExpectedException exception = ExpectedException.none(); @Test - public void docker_host_is_required_to_be_set() throws Exception { + public void throw_exception_if_docker_host_is_not_set() throws Exception { Map variables = ImmutableMap.builder() .put("SOME_VARIABLE", "SOME_VALUE") .build(); @@ -45,7 +45,7 @@ public void docker_host_is_required_to_be_set() throws Exception { } @Test - public void docker_cert_path_is_required_if_tls_is_on() throws Exception { + public void throw_exception_if_docker_cert_path_is_missing_and_tls_is_on() throws Exception { Map variables = ImmutableMap.builder() .put(DOCKER_HOST, "tcp://192.168.99.100:2376") .put(DOCKER_TLS_VERIFY, "1") @@ -59,7 +59,7 @@ public void docker_cert_path_is_required_if_tls_is_on() throws Exception { } @Test - public void environment_with_all_valid_variables_set_without_t_l_s() throws Exception { + public void validate_environment_with_all_valid_variables_set_without_tls() throws Exception { Map variables = ImmutableMap.builder() .put(DOCKER_HOST, "tcp://192.168.99.100:2376") .put("SOME_VARIABLE", "SOME_VALUE") @@ -69,7 +69,7 @@ public void environment_with_all_valid_variables_set_without_t_l_s() throws Exce } @Test - public void environment_with_all_valid_variables_set_with_t_l_s() throws Exception { + public void validate_environment_with_all_valid_variables_set_with_tls() throws Exception { Map variables = ImmutableMap.builder() .put(DOCKER_HOST, "tcp://192.168.99.100:2376") .put(DOCKER_TLS_VERIFY, "1") diff --git a/src/test/java/com/palantir/docker/compose/configuration/RemoteHostIpResolverTest.java b/src/test/java/com/palantir/docker/compose/configuration/RemoteHostIpResolverShould.java similarity index 89% rename from src/test/java/com/palantir/docker/compose/configuration/RemoteHostIpResolverTest.java rename to src/test/java/com/palantir/docker/compose/configuration/RemoteHostIpResolverShould.java index bf6ae631c..b7b97afcc 100644 --- a/src/test/java/com/palantir/docker/compose/configuration/RemoteHostIpResolverTest.java +++ b/src/test/java/com/palantir/docker/compose/configuration/RemoteHostIpResolverShould.java @@ -23,7 +23,7 @@ import org.junit.Test; import org.junit.rules.ExpectedException; -public class RemoteHostIpResolverTest { +public class RemoteHostIpResolverShould { private static final String IP = "192.168.99.100"; private static final int PORT = 2376; @@ -32,14 +32,14 @@ public class RemoteHostIpResolverTest { public ExpectedException exception = ExpectedException.none(); @Test - public void resolving_invalid_docker_host_results_in_error_blank() throws Exception { + public void result_in_error_blank_when_resolving_invalid_docker_host() throws Exception { exception.expect(IllegalArgumentException.class); exception.expectMessage("DOCKER_HOST cannot be blank/null"); new RemoteHostIpResolver().resolveIp(""); } @Test - public void resolving_invalid_docker_host_results_in_error_null() throws Exception { + public void result_in_error_null_when_resolving_invalid_docker_host() throws Exception { exception.expect(IllegalArgumentException.class); exception.expectMessage("DOCKER_HOST cannot be blank/null"); new RemoteHostIpResolver().resolveIp(null); diff --git a/src/test/java/com/palantir/docker/compose/connection/ContainerCacheTest.java b/src/test/java/com/palantir/docker/compose/connection/ContainerCacheShould.java similarity index 89% rename from src/test/java/com/palantir/docker/compose/connection/ContainerCacheTest.java rename to src/test/java/com/palantir/docker/compose/connection/ContainerCacheShould.java index 9e6b7a374..2bbb87bd9 100644 --- a/src/test/java/com/palantir/docker/compose/connection/ContainerCacheTest.java +++ b/src/test/java/com/palantir/docker/compose/connection/ContainerCacheShould.java @@ -25,7 +25,7 @@ import org.junit.Before; import org.junit.Test; -public class ContainerCacheTest { +public class ContainerCacheShould { private static final String CONTAINER_NAME = "container"; @@ -38,13 +38,13 @@ public void setup() { } @Test - public void getting_a_new_container_returns_a_container_with_the_specified_name() { + public void return_a_container_with_the_specified_name_when_getting_a_new_container() { Container container = containers.container(CONTAINER_NAME); assertThat(container, is(new Container(CONTAINER_NAME, dockerCompose))); } @Test - public void getting_a_container_twice_returns_the_same_object() { + public void return_the_same_object_when_getting_a_container_twice() { Container container = containers.container(CONTAINER_NAME); Container sameContainer = containers.container(CONTAINER_NAME); assertThat(container, is(sameInstance(sameContainer))); diff --git a/src/test/java/com/palantir/docker/compose/connection/ContainerNamesTest.java b/src/test/java/com/palantir/docker/compose/connection/ContainerNamesShould.java similarity index 81% rename from src/test/java/com/palantir/docker/compose/connection/ContainerNamesTest.java rename to src/test/java/com/palantir/docker/compose/connection/ContainerNamesShould.java index 8e1873054..3595f92e3 100644 --- a/src/test/java/com/palantir/docker/compose/connection/ContainerNamesTest.java +++ b/src/test/java/com/palantir/docker/compose/connection/ContainerNamesShould.java @@ -22,40 +22,40 @@ import org.junit.Test; -public class ContainerNamesTest { +public class ContainerNamesShould { @Test - public void empty_ps_output_results_in_no_container_names() { + public void result_in_no_container_names_when_ps_output_is_empty() { ContainerNames names = ContainerNames.parseFromDockerComposePs("\n----\n"); assertThat(names, is(new ContainerNames(emptyList()))); } @Test - public void ps_output_with_a_single_container_results_in_a_single_container_name() { + public void result_in_a_single_container_name_when_ps_output_has_a_single_container() { ContainerNames names = ContainerNames.parseFromDockerComposePs("\n----\ndir_db_1 other line contents"); assertThat(names, is(new ContainerNames("db"))); } @Test - public void containers_with_underscores_in_their_name_are_allowed() { + public void allow_containers_with_underscores_in_their_name() { ContainerNames names = ContainerNames.parseFromDockerComposePs("\n----\ndir_left_right_1 other line contents"); assertThat(names, is(new ContainerNames("left_right"))); } @Test - public void ps_output_with_two_containers_results_in_a_two_container_name() { + public void result_in_two_container_names_when_ps_output_has_two_containers() { ContainerNames names = ContainerNames.parseFromDockerComposePs("\n----\ndir_db_1 other line contents\ndir_db2_1 other stuff"); assertThat(names, is(new ContainerNames(asList("db", "db2")))); } @Test - public void an_empty_line_in_ps_output_is_ignored() { + public void ignore_an_empty_line_in_ps_output() { ContainerNames names = ContainerNames.parseFromDockerComposePs("\n----\ndir_db_1 other line contents\n\n"); assertThat(names, is(new ContainerNames("db"))); } @Test - public void a_line_with_ony_spaces_in_ps_output_is_ignored() { + public void ignore_a_line_with_ony_spaces_in_ps_output() { ContainerNames names = ContainerNames.parseFromDockerComposePs("\n----\ndir_db_1 other line contents\n \n"); assertThat(names, is(new ContainerNames("db"))); } diff --git a/src/test/java/com/palantir/docker/compose/connection/ContainerTest.java b/src/test/java/com/palantir/docker/compose/connection/ContainerShould.java similarity index 89% rename from src/test/java/com/palantir/docker/compose/connection/ContainerTest.java rename to src/test/java/com/palantir/docker/compose/connection/ContainerShould.java index 95ede8c25..7b50f94b5 100644 --- a/src/test/java/com/palantir/docker/compose/connection/ContainerTest.java +++ b/src/test/java/com/palantir/docker/compose/connection/ContainerShould.java @@ -31,7 +31,7 @@ import org.junit.Test; import org.junit.rules.ExpectedException; -public class ContainerTest { +public class ContainerShould { private static final String IP = "127.0.0.1"; @@ -43,21 +43,21 @@ public class ContainerTest { private final Container container = new Container("service", dockerComposeProcess); @Test - public void port_is_returned_for_container_when_external_port_number_given() throws Exception { + public void return_port_for_container_when_external_port_number_given() throws Exception { DockerPort expected = env.availableService("service", IP, 5433, 5432); DockerPort port = container.portMappedExternallyTo(5433); assertThat(port, is(expected)); } @Test - public void port_is_returned_for_container_when_internal_port_number_given() throws Exception { + public void return_port_for_container_when_internal_port_number_given() throws Exception { DockerPort expected = env.availableService("service", IP, 5433, 5432); DockerPort port = container.portMappedInternallyTo(5432); assertThat(port, is(expected)); } @Test - public void when_two_ports_are_requested_docker_ports_is_only_called_once() throws Exception { + public void call_docker_ports_once_when_two_ports_are_requested() throws Exception { env.ports("service", IP, 8080, 8081); container.portMappedInternallyTo(8080); container.portMappedInternallyTo(8081); @@ -65,7 +65,8 @@ public void when_two_ports_are_requested_docker_ports_is_only_called_once() thro } @Test - public void requested_a_port_for_an_unknown_external_port_results_in_an_illegal_argument_exception() throws Exception { + public void throw_illegal_argument_exception_when_a_port_for_an_unknown_external_port_is_requested() + throws Exception { // Service must have ports otherwise we end up with an exception telling you the service is listening at all env.availableService("service", IP, 5400, 5400); exception.expect(IllegalArgumentException.class); @@ -74,7 +75,8 @@ public void requested_a_port_for_an_unknown_external_port_results_in_an_illegal_ } @Test - public void requested_a_port_for_an_unknown_internal_port_results_in_an_illegal_argument_exception() throws Exception { + public void throw_illegal_argument_exception_when_a_port_for_an_unknown_internal_port_is_requested() + throws Exception { env.availableService("service", IP, 5400, 5400); exception.expect(IllegalArgumentException.class); exception.expectMessage("No internal port '5432' for container 'service'"); diff --git a/src/test/java/com/palantir/docker/compose/connection/LocalBuilderTest.java b/src/test/java/com/palantir/docker/compose/connection/LocalBuilderShould.java similarity index 88% rename from src/test/java/com/palantir/docker/compose/connection/LocalBuilderTest.java rename to src/test/java/com/palantir/docker/compose/connection/LocalBuilderShould.java index 45d7d15d7..50b2c0824 100644 --- a/src/test/java/com/palantir/docker/compose/connection/LocalBuilderTest.java +++ b/src/test/java/com/palantir/docker/compose/connection/LocalBuilderShould.java @@ -34,13 +34,13 @@ import org.junit.Test; import org.junit.rules.ExpectedException; -public class LocalBuilderTest { +public class LocalBuilderShould { @Rule public ExpectedException exception = ExpectedException.none(); @Test - public void localBuilderWithAdditionalEnvironmentSetTwiceOverridesPreviousEnvironment_daemon() throws Exception { + public void override_previous_environment_when_additional_environment_set_twice_daemon() throws Exception { Map environment1 = ImmutableMap.of("ENV_1", "VAL_1"); Map environment2 = ImmutableMap.of("ENV_2", "VAL_2"); DockerMachine localMachine = new LocalBuilder(DAEMON, newHashMap()).withEnvironment(environment1) @@ -51,7 +51,7 @@ public void localBuilderWithAdditionalEnvironmentSetTwiceOverridesPreviousEnviro } @Test - public void localBuilderWithAdditionalEnvironmentSetAndIndividualEnvironmentIsUnionOfTheTwo_daemon() throws Exception { + public void be_union_of_additional_environment_and_individual_environment_when_both_set_daemon() throws Exception { Map environment = ImmutableMap.builder() .put("ENV_1", "VAL_1") .put("ENV_2", "VAL_2") @@ -64,7 +64,7 @@ public void localBuilderWithAdditionalEnvironmentSetAndIndividualEnvironmentIsUn } @Test - public void localBuilderWithAdditionalEnvironmentSetTwiceOverridesPreviousEnvironment_remote() throws Exception { + public void override_previous_environment_with_additional_environment_set_twice_remote() throws Exception { Map dockerVariables = ImmutableMap.builder() .put(DOCKER_HOST, "tcp://192.168.99.100:2376") .build(); @@ -78,7 +78,7 @@ public void localBuilderWithAdditionalEnvironmentSetTwiceOverridesPreviousEnviro } @Test - public void localBuilderWithAdditionalEnvironmentSetAndIndividualEnvironmentIsUnionOfTheTwo_remote() throws Exception { + public void be_union_of_additional_environment_and_individual_environment_when_both_set_remote() throws Exception { Map dockerVariables = ImmutableMap.builder() .put(DOCKER_HOST, "tcp://192.168.99.100:2376") .build(); @@ -94,7 +94,7 @@ public void localBuilderWithAdditionalEnvironmentSetAndIndividualEnvironmentIsUn } @Test - public void localBuilderWithAdditionalEnvironmentGetsVariableOverriden() throws Exception { + public void get_variable_overriden_with_additional_environment() throws Exception { Map environment = ImmutableMap.builder() .put("ENV_1", "VAL_1") .put("ENV_2", "VAL_2") @@ -112,7 +112,7 @@ public void localBuilderWithAdditionalEnvironmentGetsVariableOverriden() throws } @Test - public void localBuilderHasInvalidVariables_daemon() throws Exception { + public void have_invalid_variables_daemon() throws Exception { Map invalidDockerVariables = ImmutableMap.builder() .put(DOCKER_HOST, "tcp://192.168.99.100:2376") .put(DOCKER_TLS_VERIFY, "1") @@ -130,7 +130,7 @@ public void localBuilderHasInvalidVariables_daemon() throws Exception { } @Test - public void localBuilderHasInvalidAdditionalVariables_daemon() throws Exception { + public void have_invalid_additional_variables_daemon() throws Exception { exception.expect(IllegalStateException.class); exception.expectMessage("The following variables"); exception.expectMessage(DOCKER_HOST); @@ -141,7 +141,7 @@ public void localBuilderHasInvalidAdditionalVariables_daemon() throws Exception } @Test - public void localBuilderHasInvalidAdditionalVariables_remote() throws Exception { + public void have_invalid_additional_variables_remote() throws Exception { Map dockerVariables = ImmutableMap.builder() .put(DOCKER_HOST, "tcp://192.168.99.100:2376") .put(DOCKER_TLS_VERIFY, "1") @@ -158,13 +158,13 @@ public void localBuilderHasInvalidAdditionalVariables_remote() throws Exception } @Test - public void localBuilderReturnsLocalhostAsIp_daemon() throws Exception { + public void return_localhost_as_ip_daemon() throws Exception { DockerMachine localMachine = new LocalBuilder(DAEMON, newHashMap()).build(); assertThat(localMachine.getIp(), is(LOCALHOST)); } @Test - public void localBuilderReturnsDockerHostAsIp_remote() throws Exception { + public void return_docker_host_as_ip_remote() throws Exception { Map dockerVariables = ImmutableMap.builder() .put(DOCKER_HOST, "tcp://192.168.99.100:2376") .put(DOCKER_TLS_VERIFY, "1") @@ -176,7 +176,7 @@ public void localBuilderReturnsDockerHostAsIp_remote() throws Exception { } @Test - public void local_builder_has_missing_docker_host_remote() throws Exception { + public void have_missing_docker_host_remote() throws Exception { exception.expect(IllegalStateException.class); exception.expectMessage("Missing required environment variables: "); exception.expectMessage(DOCKER_HOST); @@ -184,7 +184,7 @@ public void local_builder_has_missing_docker_host_remote() throws Exception { } @Test - public void local_builder_builds_without_tls_remote() throws Exception { + public void build_without_tls_remote() throws Exception { Map dockerVariables = ImmutableMap.builder() .put(DOCKER_HOST, "tcp://192.168.99.100:2376") .build(); @@ -194,7 +194,7 @@ public void local_builder_builds_without_tls_remote() throws Exception { } @Test - public void local_builder_has_missing_cert_path_remote() throws Exception { + public void have_missing_cert_path_remote() throws Exception { Map dockerVariables = ImmutableMap.builder() .put(DOCKER_HOST, "tcp://192.168.99.100:2376") .put(DOCKER_TLS_VERIFY, "1") @@ -207,7 +207,7 @@ public void local_builder_has_missing_cert_path_remote() throws Exception { } @Test - public void local_builder_builds_with_tls_remote() throws Exception { + public void build_with_tls_remote() throws Exception { Map dockerVariables = ImmutableMap.builder() .put(DOCKER_HOST, "tcp://192.168.99.100:2376") .put(DOCKER_TLS_VERIFY, "1") diff --git a/src/test/java/com/palantir/docker/compose/connection/PortsTest.java b/src/test/java/com/palantir/docker/compose/connection/PortsShould.java similarity index 80% rename from src/test/java/com/palantir/docker/compose/connection/PortsTest.java rename to src/test/java/com/palantir/docker/compose/connection/PortsShould.java index 9f5f276b5..8bc9ac37b 100644 --- a/src/test/java/com/palantir/docker/compose/connection/PortsTest.java +++ b/src/test/java/com/palantir/docker/compose/connection/PortsShould.java @@ -28,7 +28,7 @@ import org.junit.Test; import org.junit.rules.ExpectedException; -public class PortsTest { +public class PortsShould { public static final String LOCALHOST_IP = "127.0.0.1"; @Rule @@ -43,7 +43,7 @@ public void setup() { } @Test - public void no_ports_in_ps_output_results_in_no_ports() throws IOException, InterruptedException { + public void result_in_no_ports_when_there_are_no_ports_in_ps_output() throws IOException, InterruptedException { String psOutput = "------"; Ports ports = Ports.parseFromDockerComposePs(psOutput, null); Ports expected = new Ports(emptyList()); @@ -51,7 +51,7 @@ public void no_ports_in_ps_output_results_in_no_ports() throws IOException, Inte } @Test - public void single_tcp_port_mapping_results_in_single_port() throws IOException, InterruptedException { + public void result_in_single_port_when_there_is_single_tcp_port_mapping() throws IOException, InterruptedException { String psOutput = "0.0.0.0:5432->5432/tcp"; Ports ports = Ports.parseFromDockerComposePs(psOutput, LOCALHOST_IP); Ports expected = new Ports(newArrayList(new DockerPort(LOCALHOST_IP, 5432, 5432))); @@ -59,7 +59,9 @@ public void single_tcp_port_mapping_results_in_single_port() throws IOException, } @Test - public void single_tcp_port_mapping_results_in_single_port_with_ip_other_than_localhost() throws IOException, InterruptedException { + public void + result_in_single_port_with_ip_other_than_localhost_when_there_is_single_tcp_port_mapping() + throws IOException, InterruptedException { String psOutput = "10.0.1.2:1234->2345/tcp"; Ports ports = Ports.parseFromDockerComposePs(psOutput, LOCALHOST_IP); Ports expected = new Ports(newArrayList(new DockerPort("10.0.1.2", 1234, 2345))); @@ -67,7 +69,7 @@ public void single_tcp_port_mapping_results_in_single_port_with_ip_other_than_lo } @Test - public void two_tcp_port_mappings_results_in_two_ports() throws IOException, InterruptedException { + public void result_in_two_ports_when_there_are_two_tcp_port_mappings() throws IOException, InterruptedException { String psOutput = "0.0.0.0:5432->5432/tcp, 0.0.0.0:5433->5432/tcp"; Ports ports = Ports.parseFromDockerComposePs(psOutput, LOCALHOST_IP); Ports expected = new Ports(newArrayList(new DockerPort(LOCALHOST_IP, 5432, 5432), @@ -76,7 +78,7 @@ public void two_tcp_port_mappings_results_in_two_ports() throws IOException, Int } @Test - public void non_mapped_exposed_port_results_in_no_ports() throws IOException, InterruptedException { + public void result_in_no_ports_when_there_is_a_non_mapped_exposed_port() throws IOException, InterruptedException { String psOutput = "5432/tcp"; Ports ports = Ports.parseFromDockerComposePs(psOutput, LOCALHOST_IP); Ports expected = new Ports(emptyList()); @@ -84,7 +86,7 @@ public void non_mapped_exposed_port_results_in_no_ports() throws IOException, In } @Test - public void actual_docker_compose_output_can_be_parsed() throws IOException, InterruptedException { + public void parse_actual_docker_compose_output() throws IOException, InterruptedException { String psOutput = " Name Command State Ports \n" + "-------------------------------------------------------------------------------------------------------------------------------------------------\n" @@ -96,7 +98,8 @@ public void actual_docker_compose_output_can_be_parsed() throws IOException, Int } @Test - public void no_running_container_found_for_service_results_in_an_illegal_state_exception() throws IOException, InterruptedException { + public void throw_illegal_state_exception_when_no_running_container_found_for_service() + throws IOException, InterruptedException { exception.expect(IllegalArgumentException.class); exception.expectMessage("No container found"); Ports.parseFromDockerComposePs("", ""); diff --git a/src/test/java/com/palantir/docker/compose/connection/RemoteBuilderTest.java b/src/test/java/com/palantir/docker/compose/connection/RemoteBuilderShould.java similarity index 89% rename from src/test/java/com/palantir/docker/compose/connection/RemoteBuilderTest.java rename to src/test/java/com/palantir/docker/compose/connection/RemoteBuilderShould.java index 4c73e7439..6d1ddaeb5 100644 --- a/src/test/java/com/palantir/docker/compose/connection/RemoteBuilderTest.java +++ b/src/test/java/com/palantir/docker/compose/connection/RemoteBuilderShould.java @@ -26,13 +26,13 @@ import org.junit.Test; import org.junit.rules.ExpectedException; -public class RemoteBuilderTest { +public class RemoteBuilderShould { @Rule public ExpectedException exception = ExpectedException.none(); @Test - public void a_docker_machine_built_without_a_host_results_in_an_error() throws Exception { + public void throw_exception_when_building_a_docker_machine_without_a_host() throws Exception { exception.expect(IllegalStateException.class); exception.expectMessage("Missing required environment variables"); exception.expectMessage("DOCKER_HOST"); @@ -42,7 +42,7 @@ public void a_docker_machine_built_without_a_host_results_in_an_error() throws E } @Test - public void a_docker_machine_built_without_t_l_s_has_no_t_l_s_environment_variables() throws Exception { + public void have_no_tls_environment_variables_when_a_docker_machine_is_built_without_tls() throws Exception { DockerMachine dockerMachine = DockerMachine.remoteMachine() .host("tcp://192.168.99.100") .withoutTLS() @@ -56,7 +56,7 @@ public void a_docker_machine_built_without_t_l_s_has_no_t_l_s_environment_variab } @Test - public void a_docker_machine_built_with_t_l_s_has_t_l_s_environment_variables_set() throws Exception { + public void have_tls_environment_variables_set_when_a_docker_machine_is_built_with_tls() throws Exception { DockerMachine dockerMachine = DockerMachine.remoteMachine() .host("tcp://192.168.99.100") .withTLS("/path/to/certs") @@ -70,7 +70,7 @@ public void a_docker_machine_built_with_t_l_s_has_t_l_s_environment_variables_se } @Test - public void a_docker_machine_built_with_additional_environment_variables() throws Exception { + public void build_a_docker_machine_with_additional_environment_variables() throws Exception { DockerMachine dockerMachine = DockerMachine.remoteMachine() .host("tcp://192.168.99.100") .withoutTLS() diff --git a/src/test/java/com/palantir/docker/compose/execution/DockerComposeTest.java b/src/test/java/com/palantir/docker/compose/execution/DockerComposeShould.java similarity index 80% rename from src/test/java/com/palantir/docker/compose/execution/DockerComposeTest.java rename to src/test/java/com/palantir/docker/compose/execution/DockerComposeShould.java index 1ae40496d..fa6420dc4 100644 --- a/src/test/java/com/palantir/docker/compose/execution/DockerComposeTest.java +++ b/src/test/java/com/palantir/docker/compose/execution/DockerComposeShould.java @@ -38,7 +38,7 @@ import org.junit.Test; import org.junit.rules.ExpectedException; -public class DockerComposeTest { +public class DockerComposeShould { @Rule public ExpectedException exception = ExpectedException.none(); @@ -58,19 +58,19 @@ public void setup() throws IOException, InterruptedException { } @Test - public void up_calls_docker_compose_up_with_daemon_flag() throws IOException, InterruptedException { + public void call_docker_compose_up_with_daemon_flag_on_up() throws IOException, InterruptedException { compose.up(); verify(executor).execute("up", "-d"); } @Test - public void rm_calls_docker_compose_rm_with_force_and_volume_flags() throws IOException, InterruptedException { + public void call_docker_compose_rm_with_force_and_volume_flags_on_rm() throws IOException, InterruptedException { compose.rm(); verify(executor).execute("rm", "--force", "-v"); } @Test - public void ps_parses_and_returns_container_names() throws IOException, InterruptedException { + public void parse_and_returns_container_names_on_ps() throws IOException, InterruptedException { when(executedProcess.getInputStream()).thenReturn(toInputStream("ps\n----\ndir_db_1")); ContainerNames containerNames = compose.ps(); verify(executor).execute("ps"); @@ -78,7 +78,7 @@ public void ps_parses_and_returns_container_names() throws IOException, Interrup } @Test - public void logs_calls_docker_compose_with_no_colour_flag() throws IOException, InterruptedException { + public void call_docker_compose_with_no_colour_flag_on_logs() throws IOException, InterruptedException { when(executedProcess.getInputStream()).thenReturn( toInputStream("docker-compose version 1.5.6, build 1ad8866"), toInputStream("logs")); @@ -89,7 +89,8 @@ public void logs_calls_docker_compose_with_no_colour_flag() throws IOException, } @Test - public void logs_calls_docker_compose_with_the_follow_flag_when_the_version_is_at_least_1_7_0() throws IOException, InterruptedException { + public void call_docker_compose_with_the_follow_flag_when_the_version_is_at_least_1_7_0_on_logs() + throws IOException, InterruptedException { when(executedProcess.getInputStream()).thenReturn( toInputStream("docker-compose version 1.7.0, build 1ad8866"), toInputStream("logs")); @@ -100,7 +101,7 @@ public void logs_calls_docker_compose_with_the_follow_flag_when_the_version_is_a } @Test - public void when_kill_exits_with_a_non_zero_exit_code_an_exception_is_thrown() throws IOException, InterruptedException { + public void throw_exception_when_kill_exits_with_a_non_zero_exit_code() throws IOException, InterruptedException { when(executedProcess.exitValue()).thenReturn(1); exception.expect(DockerComposeExecutionException.class); exception.expectMessage("'docker-compose kill' returned exit code 1"); @@ -108,14 +109,16 @@ public void when_kill_exits_with_a_non_zero_exit_code_an_exception_is_thrown() t } @Test - public void when_down_fails_because_the_command_does_not_exist_then_an_exception_is_not_thrown() throws IOException, InterruptedException { + public void not_throw_exception_when_down_fails_because_the_command_does_not_exist() + throws IOException, InterruptedException { when(executedProcess.exitValue()).thenReturn(1); when(executedProcess.getInputStream()).thenReturn(toInputStream("No such command: down")); compose.down(); } @Test - public void when_down_fails_for_a_reason_other_than_the_command_not_being_present_then_an_exception_is_thrown() throws IOException, InterruptedException { + public void throw_exception_when_down_fails_for_a_reason_other_than_the_command_not_being_present() + throws IOException, InterruptedException { when(executedProcess.exitValue()).thenReturn(1); when(executedProcess.getInputStream()).thenReturn(toInputStream("")); @@ -125,20 +128,21 @@ public void when_down_fails_for_a_reason_other_than_the_command_not_being_presen } @Test - public void when_down_exists_if_uses_the_remove_volumes_flag() throws IOException, InterruptedException { + public void use_the_remove_volumes_flag_when_down_exists() throws IOException, InterruptedException { compose.down(); verify(executor).execute("down", "--volumes"); } @Test - public void calling_ports_parses_the_ps_output() throws IOException, InterruptedException { + public void parse_the_ps_output_on_ports() throws IOException, InterruptedException { Ports ports = compose.ports("db"); verify(executor).execute("ps", "db"); assertThat(ports, is(new Ports(new DockerPort("0.0.0.0", 7000, 7000)))); } @Test - public void when_there_is_no_container_found_for_ports_an_i_s_e_is_thrown() throws IOException, InterruptedException { + public void throw_illegal_state_exception_when_there_is_no_container_found_for_ports() + throws IOException, InterruptedException { when(executedProcess.getInputStream()).thenReturn(toInputStream("")); exception.expect(IllegalStateException.class); exception.expectMessage("No container with name 'db' found"); @@ -146,14 +150,16 @@ public void when_there_is_no_container_found_for_ports_an_i_s_e_is_thrown() thro } @Test - public void docker_compose_exec_passes_concatenated_arguments_to_executor() throws IOException, InterruptedException { + public void pass_concatenated_arguments_to_executor_on_docker_compose_exec() + throws IOException, InterruptedException { when(executedProcess.getInputStream()).thenReturn(toInputStream("docker-compose version 1.7.0rc1, build 1ad8866")); compose.exec(options("-d"), "container_1", arguments("ls")); verify(executor, times(1)).execute("exec", "-d", "container_1", "ls"); } @Test - public void docker_compose_exec_fails_if_docker_compose_version_is_prior_1_7() throws IOException, InterruptedException { + public void fail_if_docker_compose_version_is_prior_1_7_on_docker_compose_exec() + throws IOException, InterruptedException { when(executedProcess.getInputStream()).thenReturn(toInputStream("docker-compose version 1.5.6, build 1ad8866")); exception.expect(IllegalStateException.class); exception.expectMessage("You need at least docker-compose 1.7 to run docker-compose exec"); @@ -161,7 +167,7 @@ public void docker_compose_exec_fails_if_docker_compose_version_is_prior_1_7() t } @Test - public void docker_compose_exec_returns_the_output_from_the_executed_process() throws Exception { + public void return_the_output_from_the_executed_process_on_docker_compose_exec() throws Exception { String lsString = "-rw-r--r-- 1 user 1318458867 11326 Mar 9 17:47 LICENSE\n" + "-rw-r--r-- 1 user 1318458867 12570 May 12 14:51 README.md"; diff --git a/src/test/java/com/palantir/docker/compose/execution/DockerComposeVersionTest.java b/src/test/java/com/palantir/docker/compose/execution/DockerComposeVersionShould.java similarity index 97% rename from src/test/java/com/palantir/docker/compose/execution/DockerComposeVersionTest.java rename to src/test/java/com/palantir/docker/compose/execution/DockerComposeVersionShould.java index f05e1bf9b..a6a572dbd 100644 --- a/src/test/java/com/palantir/docker/compose/execution/DockerComposeVersionTest.java +++ b/src/test/java/com/palantir/docker/compose/execution/DockerComposeVersionShould.java @@ -24,7 +24,7 @@ import org.junit.Test; -public class DockerComposeVersionTest { +public class DockerComposeVersionShould { @Test public void compare_major_versions_first() throws Exception { diff --git a/src/test/java/com/palantir/docker/compose/logging/FileLogCollectorTest.java b/src/test/java/com/palantir/docker/compose/logging/FileLogCollectorShould.java similarity index 87% rename from src/test/java/com/palantir/docker/compose/logging/FileLogCollectorTest.java rename to src/test/java/com/palantir/docker/compose/logging/FileLogCollectorShould.java index 405decffb..32ab12d3a 100644 --- a/src/test/java/com/palantir/docker/compose/logging/FileLogCollectorTest.java +++ b/src/test/java/com/palantir/docker/compose/logging/FileLogCollectorShould.java @@ -45,7 +45,7 @@ import org.junit.rules.TemporaryFolder; @SuppressWarnings("unchecked") -public class FileLogCollectorTest { +public class FileLogCollectorShould { @Rule public TemporaryFolder logDirectoryParent = new TemporaryFolder(); @@ -63,7 +63,7 @@ public void setup() throws IOException { } @Test - public void cannot_be_created_when_trying_to_use_a_file_as_the_log_directory() throws IOException { + public void throw_exception_when_created_with_file_as_the_log_directory() throws IOException { File file = logDirectoryParent.newFile("cannot-use"); exception.expect(IllegalArgumentException.class); @@ -73,7 +73,7 @@ public void cannot_be_created_when_trying_to_use_a_file_as_the_log_directory() t } @Test - public void creates_the_log_directory_if_it_does_not_already_exist() throws IOException { + public void create_the_log_directory_if_it_does_not_already_exist() throws IOException { File doesNotExistYetDirectory = logDirectoryParent.getRoot() .toPath() .resolve("doesNotExist") @@ -83,7 +83,8 @@ public void creates_the_log_directory_if_it_does_not_already_exist() throws IOEx } @Test - public void cannot_be_created_if_the_log_directory_does_not_exist_and_cannot_be_created() throws IOException { + public void throw_exception_when_created_if_the_log_directory_does_not_exist_and_cannot_be_created() + throws IOException { File cannotBeCreatedDirectory = cannotBeCreatedDirectory(); exception.expect(IllegalArgumentException.class); @@ -94,7 +95,7 @@ public void cannot_be_created_if_the_log_directory_does_not_exist_and_cannot_be_ } @Test - public void when_no_containers_are_running_no_logs_are_collected() throws IOException, InterruptedException { + public void not_collect_any_logs_when_no_containers_are_running() throws IOException, InterruptedException { when(compose.ps()).thenReturn(new ContainerNames(emptyList())); logCollector.startCollecting(compose); logCollector.stopCollecting(); @@ -102,7 +103,8 @@ public void when_no_containers_are_running_no_logs_are_collected() throws IOExce } @Test - public void when_one_container_is_running_and_terminates_before_start_collecting_is_run_logs_are_collected() throws Exception { + public void collect_logs_when_one_container_is_running_and_terminates_before_start_collecting_is_run() + throws Exception { when(compose.ps()).thenReturn(new ContainerNames("db")); when(compose.writeLogs(eq("db"), any(OutputStream.class))).thenAnswer((args) -> { OutputStream outputStream = (OutputStream) args.getArguments()[1]; @@ -116,7 +118,8 @@ public void when_one_container_is_running_and_terminates_before_start_collecting } @Test - public void when_one_container_is_running_and_does_not_terminate_until_after_start_collecting_is_run_logs_are_collected() throws Exception { + public void collect_logs_when_one_container_is_running_and_does_not_terminate_until_after_start_collecting_is_run() + throws Exception { when(compose.ps()).thenReturn(new ContainerNames("db")); CountDownLatch latch = new CountDownLatch(1); when(compose.writeLogs(eq("db"), any(OutputStream.class))).thenAnswer((args) -> { @@ -135,7 +138,8 @@ public void when_one_container_is_running_and_does_not_terminate_until_after_sta } @Test - public void when_one_container_is_running_and_does_not_terminate_the_logs_are_still_collected() throws IOException, InterruptedException { + public void collect_logs_when_one_container_is_running_and_does_not_terminate() + throws IOException, InterruptedException { when(compose.ps()).thenReturn(new ContainerNames("db")); CountDownLatch latch = new CountDownLatch(1); when(compose.writeLogs(eq("db"), any(OutputStream.class))).thenAnswer((args) -> { @@ -159,7 +163,7 @@ public void when_one_container_is_running_and_does_not_terminate_the_logs_are_st } @Test - public void two_containers_have_logs_collected_in_parallel() throws IOException, InterruptedException { + public void collect_logs_in_parallel_for_two_containers() throws IOException, InterruptedException { when(compose.ps()).thenReturn(new ContainerNames(asList("db", "db2"))); CountDownLatch dbLatch = new CountDownLatch(1); when(compose.writeLogs(eq("db"), any(OutputStream.class))).thenAnswer((args) -> { @@ -188,7 +192,8 @@ public void two_containers_have_logs_collected_in_parallel() throws IOException, } @Test - public void a_started_collector_cannot_be_starteda_second_time() throws IOException, InterruptedException { + public void throw_exception_when_trying_to_start_a_started_collector_a_second_time() + throws IOException, InterruptedException { when(compose.ps()).thenReturn(new ContainerNames("db")); logCollector.startCollecting(compose); exception.expect(RuntimeException.class); diff --git a/src/test/java/com/palantir/docker/compose/matchers/AvailablePortMatcherTest.java b/src/test/java/com/palantir/docker/compose/matchers/AvailablePortMatcherShould.java similarity index 90% rename from src/test/java/com/palantir/docker/compose/matchers/AvailablePortMatcherTest.java rename to src/test/java/com/palantir/docker/compose/matchers/AvailablePortMatcherShould.java index 21a3fe981..8fd73846c 100644 --- a/src/test/java/com/palantir/docker/compose/matchers/AvailablePortMatcherTest.java +++ b/src/test/java/com/palantir/docker/compose/matchers/AvailablePortMatcherShould.java @@ -26,19 +26,19 @@ import org.junit.Test; import org.junit.rules.ExpectedException; -public class AvailablePortMatcherTest { +public class AvailablePortMatcherShould { @Rule public ExpectedException exception = ExpectedException.none(); @Test - public void no_unavailable_ports_is_good() throws Exception { + public void succeed_when_there_are_no_unavailable_ports() throws Exception { List unavailablePorts = emptyList(); assertThat(unavailablePorts, areAvailable()); } @Test - public void some_unavailable_ports_results_in_useful_error_messages() throws Exception { + public void throw_exception_when_there_are_some_unavailable_ports() throws Exception { List unavailablePorts = newArrayList(new DockerPort("0.0.0.0", 1234, 1234), new DockerPort("1.2.3.4", 2345, 3456)); exception.expect(AssertionError.class);