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

Allow passing explicit Configuration via `DropwizardTestSupport`, `DropwizardAppRule` (for #1130) #1131

Closed
wants to merge 2 commits into
base: master
from

Conversation

Projects
None yet
3 participants
@cowtowncoder
Contributor

cowtowncoder commented Jun 24, 2015

PR adds an alternate way to construct test scaffolding, by passing pre-constructed Configuration instead of relying on a YAML resource. This is useful for tests where configuration is programmatically set. Other minor access changes needed to support this functionality.

* @since 0.9
*
* @param applicationClass Type of Application to create
* @param config Pre-constructed configuration object caller provides; will not

This comment has been minimized.

@arteam

arteam Jun 26, 2015

Member

Nit: the parameter is called configuration, but in the Javadoc it's config.

}
this.applicationClass = applicationClass;
configPath = "";
configOverrides = Collections.emptySet();

This comment has been minimized.

@arteam

arteam Jun 26, 2015

Member

Maybe better to use ImmutableSet.of() in order to be consistent with other constructor?

@Override
public ConfigurationFactory<C> create(Class<C> klass, Validator validator,
ObjectMapper objectMapper, String propertyPrefix) {
return new POJOConfigurationFactory<C>(configuration);

This comment has been minimized.

@arteam

arteam Jun 26, 2015

Member

We compile against Java 7, so we could use just new POJOConfigurationFactory<>(configuration)

return new POJOConfigurationFactory<C>(configuration);
}
});
} else if (customPropertyPrefix.isPresent()) {

This comment has been minimized.

@arteam

arteam Jun 26, 2015

Member

Nit: extra whitespace between else and if.

@cowtowncoder

This comment has been minimized.

Contributor

cowtowncoder commented Jun 26, 2015

Thanks! Will fix the issues.


public class POJOConfigurationFactory<C extends Configuration>
extends ConfigurationFactory<C>
{

This comment has been minimized.

@arteam

arteam Jun 26, 2015

Member

Nit: It's more idiomatic to place an opening brace on the same line as the class declaration.

public class DropwizardAppRuleWithExplicitTest {

@Test
public void bogusTest() { }

This comment has been minimized.

@arteam

arteam Jun 26, 2015

Member

What is the point of this test? Sorry, but I don't follow.

This comment has been minimized.

@cowtowncoder

cowtowncoder Jun 26, 2015

Contributor

I'll have to go back to ensure, but the idea was to verify that given Configuration object indeed is passed as-is, instead of being loaded from the resource.

This comment has been minimized.

@cowtowncoder

cowtowncoder Jun 26, 2015

Contributor

Right. So, basically it exercises the new method, passing config, instead of a path to YAML resource from which Configuration would be read. Most of the stuff is fluff, scaffolding, the meat is just the construction of DropwizardAppRule and verifying client returns expected message.

@arteam

This comment has been minimized.

Member

arteam commented Jun 26, 2015

Thanks, Tatu. Apart from some nitpicks, the patch looks good to me.

@jplock jplock added this to the 0.9.0 milestone Jul 2, 2015

@arteam

This comment has been minimized.

Member

arteam commented Jul 2, 2015

The patch has already been applied to master in 15e561d.
For some reason the pull request remained opened. I close it manually.

Thanks again to @cowtowncoder for work on this.

@arteam arteam closed this Jul 2, 2015

@cowtowncoder

This comment has been minimized.

Contributor

cowtowncoder commented Jul 3, 2015

Excellent! Thank you for thorough review & merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment