Skip to content

Commit

Permalink
Make jUnit 4 test methods public (#3727)
Browse files Browse the repository at this point in the history
This is a regression from f17aea0 - not all
tests are jUnit 5. jUnit 4 test methods should be made public.
  • Loading branch information
rhowe authored and joschi committed Mar 4, 2021
1 parent 7848488 commit 5ecc581
Show file tree
Hide file tree
Showing 15 changed files with 41 additions and 41 deletions.
Expand Up @@ -22,7 +22,7 @@ public class GzipDefaultVaryBehaviourTest {
new DropwizardAppRule<>(TestApplication.class, resourceFilePath("gzip-vary-test-config.yaml"));

@Test
void testDefaultVaryHeader() {
public void testDefaultVaryHeader() {
final Response clientResponse = RULE.client().target(
"http://localhost:" + RULE.getLocalPort() + "/test").request().header(ACCEPT_ENCODING, "gzip").get();

Expand Down
Expand Up @@ -35,15 +35,15 @@ public class PersonResourceExceptionMapperTest {
.build();

@Test
void testDefaultConstraintViolation() {
public void testDefaultConstraintViolation() {
assertThat(RESOURCES.target("/person/blah/index")
.queryParam("ind", -1).request()
.get().readEntity(String.class))
.isEqualTo("Invalid data");
}

@Test
void testDefaultJsonProcessingMapper() {
public void testDefaultJsonProcessingMapper() {
assertThat(RESOURCES.target("/person/blah/runtime-exception")
.request()
.post(Entity.json("{ \"he: \"ho\"}"))
Expand All @@ -52,7 +52,7 @@ void testDefaultJsonProcessingMapper() {
}

@Test
void testDefaultExceptionMapper() {
public void testDefaultExceptionMapper() {
assertThat(RESOURCES.target("/person/blah/runtime-exception")
.request()
.post(Entity.json("{}"))
Expand All @@ -61,7 +61,7 @@ void testDefaultExceptionMapper() {
}

@Test
void testDefaultEofExceptionMapper() {
public void testDefaultEofExceptionMapper() {
assertThat(RESOURCES.target("/person/blah/eof-exception")
.request()
.get().readEntity(String.class))
Expand Down
Expand Up @@ -54,22 +54,22 @@ public void setup() {
}

@Test
void testGetPerson() {
public void testGetPerson() {
assertThat(resourceTestRule.target("/person/blah").request()
.get(Person.class))
.isEqualTo(person);
verify(peopleStore).fetchPerson("blah");
}

@Test
void testGetImmutableListOfPersons() {
public void testGetImmutableListOfPersons() {
assertThat(resourceTestRule.target("/person/blah/list").request()
.get(new GenericType<List<Person>>() {
})).isEqualTo(Collections.singletonList(person));
}

@Test
void testGetPersonWithQueryParam() {
public void testGetPersonWithQueryParam() {
// Test to ensure that the dropwizard validator is registered so that
// it can validate the "ind" IntParam.
assertThat(resourceTestRule.target("/person/blah/index")
Expand All @@ -80,15 +80,15 @@ void testGetPersonWithQueryParam() {
}

@Test
void testDefaultConstraintViolation() {
public void testDefaultConstraintViolation() {
assertThat(resourceTestRule.target("/person/blah/index")
.queryParam("ind", -1).request()
.get().readEntity(String.class))
.isEqualTo("{\"errors\":[\"query param ind must be greater than or equal to 0\"]}");
}

@Test
void testDefaultJsonProcessingMapper() {
public void testDefaultJsonProcessingMapper() {
assertThat(resourceTestRule.target("/person/blah/runtime-exception")
.request()
.post(Entity.json("{ \"he: \"ho\"}"))
Expand All @@ -97,7 +97,7 @@ void testDefaultJsonProcessingMapper() {
}

@Test
void testDefaultExceptionMapper() {
public void testDefaultExceptionMapper() {
assertThat(resourceTestRule.target("/person/blah/runtime-exception")
.request()
.post(Entity.json("{}"))
Expand All @@ -106,15 +106,15 @@ void testDefaultExceptionMapper() {
}

@Test
void testDefaultEofExceptionMapper() {
public void testDefaultEofExceptionMapper() {
assertThat(resourceTestRule.target("/person/blah/eof-exception")
.request()
.get().getStatus())
.isEqualTo(Response.Status.BAD_REQUEST.getStatusCode());
}

@Test
void testValidationGroupsException() {
public void testValidationGroupsException() {
final Response resp = resourceTestRule.target("/person/blah/validation-groups-exception")
.request()
.post(Entity.json("{}"));
Expand All @@ -125,7 +125,7 @@ void testValidationGroupsException() {
}

@Test
void testCustomClientConfiguration() {
public void testCustomClientConfiguration() {
assertThat(resourceTestRule.client().getConfiguration().isRegistered(DummyExceptionMapper.class)).isTrue();
}
}
Expand Up @@ -26,22 +26,22 @@ public class ResourceTestRuleWithGrizzlyTest {
.build();

@Test
void testResource() {
public void testResource() {
assertThat(resourceTestRule.target("test").request()
.get(String.class))
.isEqualTo("test");
}

@Test
void testExceptionMapper() {
public void testExceptionMapper() {
final Response resp = resourceTestRule.target("test").request()
.post(Entity.json(""));
assertThat(resp.getStatus()).isEqualTo(500);
assertThat(resp.readEntity(String.class)).isEqualTo("Can't touch this");
}

@Test
void testClientSupportsPatchMethod() {
public void testClientSupportsPatchMethod() {
final String resp = resourceTestRule.target("test")
.request()
.method("PATCH", Entity.text("Patch is working"), String.class);
Expand Down
Expand Up @@ -15,7 +15,7 @@ public class ResourceTestRuleWithoutLoggingBootstrapTest {
.build();

@Test
void testResource() {
public void testResource() {
assertThat(resourceTestRule.target("test").request()
.get(String.class))
.isEqualTo("Default message");
Expand Down
Expand Up @@ -25,7 +25,7 @@ public class DAOTestRuleConfigTest {
.build();

@Test
void explicitConfigCreatesSessionFactory() {
public void explicitConfigCreatesSessionFactory() {
// it yields a valid SessionFactory instance
final SessionFactory sessionFactory = database.getSessionFactory();
assertThat(sessionFactory).isNotNull();
Expand Down
Expand Up @@ -18,21 +18,21 @@ public class DAOTestRuleTest {
public final DAOTestRule daoTestRule = DAOTestRule.newBuilder().addEntityClass(TestEntity.class).build();

@Test
void ruleCreatedSessionFactory() {
public void ruleCreatedSessionFactory() {
final SessionFactory sessionFactory = daoTestRule.getSessionFactory();

assertThat(sessionFactory).isNotNull();
}

@Test
void ruleCanOpenTransaction() {
public void ruleCanOpenTransaction() {
final Long id = daoTestRule.inTransaction(() -> persist(new TestEntity("description")).getId());

assertThat(id).isNotNull();
}

@Test
void ruleCanRoundtrip() {
public void ruleCanRoundtrip() {
final Long id = daoTestRule.inTransaction(() -> persist(new TestEntity("description")).getId());

final TestEntity testEntity = get(id);
Expand All @@ -42,13 +42,13 @@ void ruleCanRoundtrip() {
}

@Test
void transactionThrowsExceptionAsExpected() {
public void transactionThrowsExceptionAsExpected() {
assertThatExceptionOfType(ConstraintViolationException.class).isThrownBy(()->
daoTestRule.inTransaction(() -> persist(new TestEntity(null))));
}

@Test
void rollsBackTransaction() {
public void rollsBackTransaction() {
// given a successfully persisted entity
final TestEntity testEntity = new TestEntity("description");
daoTestRule.inTransaction(() -> persist(testEntity));
Expand Down
Expand Up @@ -16,7 +16,7 @@ public class DAOTestRuleWithoutLoggingBootstrapTest {
.build();

@Test
void ruleCreatedSessionFactory() {
public void ruleCreatedSessionFactory() {
final SessionFactory sessionFactory = daoTestRule.getSessionFactory();

assertThat(sessionFactory).isNotNull();
Expand Down
Expand Up @@ -20,15 +20,15 @@ public class DropwizardAppRuleConfigOverrideTest {
config("extra", () -> "supplied again"));

@Test
void supportsConfigAttributeOverrides() {
public void supportsConfigAttributeOverrides() {
final String content = RULE.client().target("http://localhost:" + RULE.getLocalPort() + "/test")
.request().get(String.class);

assertThat(content).isEqualTo("A new way to say Hooray!");
}

@Test
void supportsSuppliedConfigAttributeOverrides() throws Exception {
public void supportsSuppliedConfigAttributeOverrides() throws Exception {
assertThat(System.getProperty("app-rule.extra")).isEqualTo("supplied");
assertThat(System.getProperty("dw.extra")).isEqualTo("supplied again");
}
Expand Down
Expand Up @@ -26,7 +26,7 @@ public class DropwizardAppRuleReentrantTest {
private Description description = mock(Description.class);

@Test
void testReentrantRuleStartsApplicationOnlyOnce() throws Throwable {
public void testReentrantRuleStartsApplicationOnlyOnce() throws Throwable {
@SuppressWarnings("deprecation")
DropwizardAppRule<TestConfiguration> dropwizardAppRule = new DropwizardAppRule<>(testSupport);

Expand Down
Expand Up @@ -17,7 +17,7 @@ public class DropwizardAppRuleResetConfigOverrideTest {
config("app-rule-reset", "message", "A new way to say Hooray!"));

@Test
void test2() throws Exception {
public void test2() throws Exception {
dropwizardAppRule.before();
assertThat(System.getProperty("app-rule-reset.message")).isEqualTo("A new way to say Hooray!");
assertThat(System.getProperty("app-rule-reset.extra")).isNull();
Expand Down
Expand Up @@ -20,33 +20,33 @@ public class DropwizardAppRuleTest {
new DropwizardAppRule<>(DropwizardTestApplication.class, resourceFilePath("test-config.yaml"));

@Test
void canGetExpectedResourceOverHttp() {
public void canGetExpectedResourceOverHttp() {
final String content = ClientBuilder.newClient().target(
"http://localhost:" + RULE.getLocalPort() + "/test").request().get(String.class);

assertThat(content).isEqualTo("Yes, it's here");
}

@Test
void returnsConfiguration() {
public void returnsConfiguration() {
final TestConfiguration config = RULE.getConfiguration();
assertThat(config.getMessage()).isEqualTo("Yes, it's here");
}

@Test
void returnsApplication() {
public void returnsApplication() {
final DropwizardTestApplication application = RULE.getApplication();
assertThat(application).isNotNull();
}

@Test
void returnsEnvironment() {
public void returnsEnvironment() {
final Environment environment = RULE.getEnvironment();
assertThat(environment.getName()).isEqualTo("DropwizardTestApplication");
}

@Test
void canPerformAdminTask() {
public void canPerformAdminTask() {
final String response
= RULE.client().target("http://localhost:"
+ RULE.getAdminPort() + "/tasks/hello?name=test_user")
Expand All @@ -57,7 +57,7 @@ void canPerformAdminTask() {
}

@Test
void canPerformAdminTaskWithPostBody() {
public void canPerformAdminTaskWithPostBody() {
final String response
= RULE.client().target("http://localhost:"
+ RULE.getAdminPort() + "/tasks/echo")
Expand All @@ -68,15 +68,15 @@ void canPerformAdminTaskWithPostBody() {
}

@Test
void clientUsesJacksonMapperFromEnvironment() {
public void clientUsesJacksonMapperFromEnvironment() {
assertThat(RULE.client().target("http://localhost:" + RULE.getLocalPort() + "/message")
.request()
.get(DropwizardTestApplication.MessageView.class).getMessage())
.contains("Yes, it's here");
}

@Test
void clientSupportsPatchMethod() {
public void clientSupportsPatchMethod() {
assertThat(RULE.client().target("http://localhost:" + RULE.getLocalPort() + "/echoPatch")
.request()
.method("PATCH", Entity.text("Patch is working"), String.class))
Expand Down
Expand Up @@ -39,7 +39,7 @@ public class DropwizardAppRuleWithExplicitTest {


@Test
void runWithExplicitConfig() {
public void runWithExplicitConfig() {
Map<String, String> response = RULE.client().target("http://localhost:" + RULE.getLocalPort() + "/test")
.request()
.get(new GenericType<Map<String, String>>() {
Expand Down
Expand Up @@ -27,7 +27,7 @@ public class DropwizardAppRuleWithoutConfigTest {
ConfigOverride.config("server.adminConnectors[0].port", "0"));

@Test
void runWithoutConfigFile() {
public void runWithoutConfigFile() {
Map<String, String> response = RULE.client().target("http://localhost:" + RULE.getLocalPort() + "/test")
.request()
.get(new GenericType<Map<String, String>>() {
Expand Down
Expand Up @@ -21,13 +21,13 @@ public class DropwizardClientRuleTest {
public static final DropwizardClientRule RULE_WITH_CLASS = new DropwizardClientRule(TestResource.class);

@Test
void shouldGetStringBodyFromDropWizard() throws IOException {
public void shouldGetStringBodyFromDropWizard() throws IOException {
final URL url = new URL(RULE_WITH_INSTANCE.baseUri() + "/test");
assertThat("foo").isEqualTo(Resources.toString(url, StandardCharsets.UTF_8));
}

@Test
void shouldGetDefaultStringBodyFromDropWizard() throws IOException {
public void shouldGetDefaultStringBodyFromDropWizard() throws IOException {
final URL url = new URL(RULE_WITH_CLASS.baseUri() + "/test");
assertThat(Resources.toString(url, StandardCharsets.UTF_8)).isEqualTo(TestResource.DEFAULT_MESSAGE);
}
Expand Down

0 comments on commit 5ecc581

Please sign in to comment.