diff --git a/.gitignore b/.gitignore index 10f76c3..99fb77a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.iml *.ipr *.iws -target/ \ No newline at end of file +target/ +.idea/ diff --git a/pom.xml b/pom.xml index 18e82ee..ade9331 100644 --- a/pom.xml +++ b/pom.xml @@ -4,13 +4,21 @@ <groupId>com.federecio</groupId> <artifactId>dropwizard-junit</artifactId> - <version>0.1-SNAPSHOT</version> + <version>0.2-SNAPSHOT</version> + + <properties> + <dropwizard.version>0.7.0-SNAPSHOT</dropwizard.version> + </properties> <developers> <developer> <name>Federico Recio</name> <url>http://about.me/federecio</url> </developer> + <developer> + <name>Jochen Szostek</name> + <url>http://prefabsoft.com</url> + </developer> </developers> <scm> @@ -20,11 +28,11 @@ </scm> <dependencies> + <!-- DropWizard --> <dependency> - <groupId>com.yammer.dropwizard</groupId> + <groupId>com.codahale.dropwizard</groupId> <artifactId>dropwizard-core</artifactId> - <version>0.6.2</version> - <scope>provided</scope> + <version>${dropwizard.version}</version> </dependency> <dependency> <groupId>junit</groupId> diff --git a/src/main/java/com/federecio/dropwizard/junitrunner/DropwizardJunitRunner.java b/src/main/java/com/federecio/dropwizard/junitrunner/DropwizardJunitRunner.java index a906c94..47b62e0 100644 --- a/src/main/java/com/federecio/dropwizard/junitrunner/DropwizardJunitRunner.java +++ b/src/main/java/com/federecio/dropwizard/junitrunner/DropwizardJunitRunner.java @@ -1,21 +1,20 @@ package com.federecio.dropwizard.junitrunner; -import java.lang.annotation.Annotation; -import java.net.URL; - +import com.codahale.dropwizard.Application; import org.junit.runner.notification.RunNotifier; import org.junit.runners.BlockJUnit4ClassRunner; import org.junit.runners.model.InitializationError; import org.junit.runners.model.Statement; -import com.yammer.dropwizard.Service; +import java.lang.annotation.Annotation; +import java.net.URL; /** * @author Federico Recio */ public class DropwizardJunitRunner extends BlockJUnit4ClassRunner { - private Service<?> service; + private Application<?> application; public DropwizardJunitRunner(Class<?> testClass) throws InitializationError { super(testClass); @@ -26,20 +25,20 @@ protected Statement classBlock(final RunNotifier notifier) { DropwizardTestConfig dropwizardTestConfig = getTestConfigOrFail(); URL resource = getYamlConfigFileOrFail(dropwizardTestConfig); try { - service = dropwizardTestConfig.serviceClass().newInstance(); - service.run(new String[]{"server", resource.getFile()}); + application = dropwizardTestConfig.applicationClass().newInstance(); + application.run(new String[]{"server", resource.getFile()}); } catch (IllegalAccessException e) { - throw new DropwizardJunitRunnerException("Could not access class or class' constructor on " + dropwizardTestConfig.serviceClass(), e); + throw new DropwizardJunitRunnerException("Could not access class or class' constructor on " + dropwizardTestConfig.applicationClass(), e); } catch (InstantiationException e) { - throw new DropwizardJunitRunnerException("Could not instantiate class " + dropwizardTestConfig.serviceClass(), e); + throw new DropwizardJunitRunnerException("Could not instantiate class " + dropwizardTestConfig.applicationClass(), e); } catch (Exception e) { throw new DropwizardJunitRunnerException(e); } return super.classBlock(notifier); } - protected Service<?> getService() { - return service; + protected Application<?> getApplication() { + return application; } private DropwizardTestConfig getTestConfigOrFail() { diff --git a/src/main/java/com/federecio/dropwizard/junitrunner/DropwizardTestConfig.java b/src/main/java/com/federecio/dropwizard/junitrunner/DropwizardTestConfig.java index 82a2e0d..2a32b86 100644 --- a/src/main/java/com/federecio/dropwizard/junitrunner/DropwizardTestConfig.java +++ b/src/main/java/com/federecio/dropwizard/junitrunner/DropwizardTestConfig.java @@ -1,12 +1,12 @@ package com.federecio.dropwizard.junitrunner; +import com.codahale.dropwizard.Application; + import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import com.yammer.dropwizard.Service; - /** * @author Federico Recio */ @@ -14,7 +14,7 @@ @Target(ElementType.TYPE) public @interface DropwizardTestConfig { - Class<? extends Service<?>> serviceClass(); + Class<? extends Application<?>> applicationClass(); String yamlFile(); } \ No newline at end of file diff --git a/src/test/java/com/federecio/dropwizard/junitrunner/DropwizardJunitRunnerTest.java b/src/test/java/com/federecio/dropwizard/junitrunner/DropwizardJunitRunnerTest.java index 4a6cb29..67d501f 100644 --- a/src/test/java/com/federecio/dropwizard/junitrunner/DropwizardJunitRunnerTest.java +++ b/src/test/java/com/federecio/dropwizard/junitrunner/DropwizardJunitRunnerTest.java @@ -1,16 +1,15 @@ package com.federecio.dropwizard.junitrunner; +import com.jayway.restassured.RestAssured; import org.eclipse.jetty.http.HttpStatus; import org.junit.Test; import org.junit.runner.RunWith; -import com.jayway.restassured.RestAssured; - /** * @author Federico Recio */ @RunWith(DropwizardJunitRunner.class) -@DropwizardTestConfig(serviceClass = TestService.class, yamlFile = "/test.yaml") +@DropwizardTestConfig(applicationClass = TestApplication.class, yamlFile = "/test.yaml") public class DropwizardJunitRunnerTest { @Test diff --git a/src/test/java/com/federecio/dropwizard/junitrunner/TestService.java b/src/test/java/com/federecio/dropwizard/junitrunner/TestApplication.java similarity index 52% rename from src/test/java/com/federecio/dropwizard/junitrunner/TestService.java rename to src/test/java/com/federecio/dropwizard/junitrunner/TestApplication.java index e88657f..829b2e5 100644 --- a/src/test/java/com/federecio/dropwizard/junitrunner/TestService.java +++ b/src/test/java/com/federecio/dropwizard/junitrunner/TestApplication.java @@ -1,13 +1,13 @@ package com.federecio.dropwizard.junitrunner; -import com.yammer.dropwizard.Service; -import com.yammer.dropwizard.config.Bootstrap; -import com.yammer.dropwizard.config.Environment; +import com.codahale.dropwizard.Application; +import com.codahale.dropwizard.setup.Bootstrap; +import com.codahale.dropwizard.setup.Environment; /** * @author Federico Recio */ -public class TestService extends Service<TestConfig> { +public class TestApplication extends Application<TestConfig> { @Override public void initialize(Bootstrap<TestConfig> bootstrap) { @@ -16,6 +16,6 @@ public void initialize(Bootstrap<TestConfig> bootstrap) { @Override public void run(TestConfig configuration, Environment environment) throws Exception { - environment.addResource(new TestResource()); + environment.jersey().register(new TestResource()); } } \ No newline at end of file diff --git a/src/test/java/com/federecio/dropwizard/junitrunner/TestConfig.java b/src/test/java/com/federecio/dropwizard/junitrunner/TestConfig.java index e5530fb..58cff61 100644 --- a/src/test/java/com/federecio/dropwizard/junitrunner/TestConfig.java +++ b/src/test/java/com/federecio/dropwizard/junitrunner/TestConfig.java @@ -1,6 +1,6 @@ package com.federecio.dropwizard.junitrunner; -import com.yammer.dropwizard.config.Configuration; +import com.codahale.dropwizard.Configuration; /** * @author Federico Recio