-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…implemented interfaces
- Loading branch information
Showing
8 changed files
with
132 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...ovy/ru/vyarus/dropwizard/guice/cases/ifaceresource/InterfaceResourceDefinitionTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package ru.vyarus.dropwizard.guice.cases.ifaceresource | ||
|
||
import ru.vyarus.dropwizard.guice.cases.ifaceresource.support.InterfaceResourceApp | ||
import ru.vyarus.dropwizard.guice.cases.ifaceresource.support.ResourceImpl | ||
import ru.vyarus.dropwizard.guice.module.installer.feature.jersey.ResourceInstaller | ||
import ru.vyarus.dropwizard.guice.module.installer.internal.FeaturesHolder | ||
import ru.vyarus.dropwizard.guice.test.spock.UseDropwizardApp | ||
import spock.lang.Specification | ||
|
||
import javax.inject.Inject | ||
|
||
|
||
/** | ||
* @author Vyacheslav Rusakov | ||
* @since 18.06.2016 | ||
*/ | ||
@UseDropwizardApp(InterfaceResourceApp) | ||
class InterfaceResourceDefinitionTest extends Specification { | ||
|
||
@Inject | ||
FeaturesHolder holder | ||
|
||
def "Check resources recognition"() { | ||
|
||
expect: "only one resource recognized" | ||
holder.getFeatures(ResourceInstaller) == [ResourceImpl] | ||
} | ||
|
||
def "Check resource registered"() { | ||
|
||
expect: 'resource called' | ||
new URL("http://localhost:8080/res").getText() == 'called!' | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...groovy/ru/vyarus/dropwizard/guice/cases/ifaceresource/support/InterfaceResourceApp.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package ru.vyarus.dropwizard.guice.cases.ifaceresource.support | ||
|
||
import io.dropwizard.Application | ||
import io.dropwizard.setup.Bootstrap | ||
import io.dropwizard.setup.Environment | ||
import ru.vyarus.dropwizard.guice.GuiceBundle | ||
import ru.vyarus.dropwizard.guice.support.TestConfiguration | ||
|
||
/** | ||
* @author Vyacheslav Rusakov | ||
* @since 18.06.2016 | ||
*/ | ||
class InterfaceResourceApp extends Application<TestConfiguration> { | ||
|
||
@Override | ||
void initialize(Bootstrap<TestConfiguration> bootstrap) { | ||
bootstrap.addBundle(GuiceBundle.<TestConfiguration> builder() | ||
.enableAutoConfig(this.class.package.name) | ||
.build() | ||
); | ||
} | ||
|
||
@Override | ||
void run(TestConfiguration configuration, Environment environment) throws Exception { | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...roovy/ru/vyarus/dropwizard/guice/cases/ifaceresource/support/InvisibleResourceImpl.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package ru.vyarus.dropwizard.guice.cases.ifaceresource.support | ||
|
||
/** | ||
* This resource could not be recognized because @Path annotation is not on 1st level interface. | ||
* | ||
* @author Vyacheslav Rusakov | ||
* @since 18.06.2016 | ||
*/ | ||
class InvisibleResourceImpl implements SecondLevelResource { | ||
|
||
@Override | ||
String latest() { | ||
return null | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...est/groovy/ru/vyarus/dropwizard/guice/cases/ifaceresource/support/ResourceContract.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package ru.vyarus.dropwizard.guice.cases.ifaceresource.support | ||
|
||
import javax.ws.rs.GET | ||
import javax.ws.rs.Path | ||
import javax.ws.rs.Produces | ||
import javax.ws.rs.core.Response | ||
|
||
/** | ||
* @author Vyacheslav Rusakov | ||
* @since 18.06.2016 | ||
*/ | ||
@Path("/res") | ||
@Produces('application/json') | ||
interface ResourceContract { | ||
|
||
@GET | ||
@Path("/") | ||
String latest(); | ||
} |
12 changes: 12 additions & 0 deletions
12
src/test/groovy/ru/vyarus/dropwizard/guice/cases/ifaceresource/support/ResourceImpl.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package ru.vyarus.dropwizard.guice.cases.ifaceresource.support | ||
/** | ||
* @author Vyacheslav Rusakov | ||
* @since 18.06.2016 | ||
*/ | ||
class ResourceImpl implements ResourceContract { | ||
|
||
@Override | ||
String latest() { | ||
return "called!" | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
.../groovy/ru/vyarus/dropwizard/guice/cases/ifaceresource/support/SecondLevelResource.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package ru.vyarus.dropwizard.guice.cases.ifaceresource.support | ||
|
||
/** | ||
* @author Vyacheslav Rusakov | ||
* @since 18.06.2016 | ||
*/ | ||
interface SecondLevelResource extends ResourceContract { | ||
|
||
} |