forked from xvik/dropwizard-guicey
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInterfaceResourceDefinitionTest.groovy
48 lines (36 loc) · 1.57 KB
/
InterfaceResourceDefinitionTest.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package ru.vyarus.dropwizard.guice.cases.ifaceresource
import org.glassfish.jersey.client.proxy.WebResourceFactory
import ru.vyarus.dropwizard.guice.cases.ifaceresource.support.InterfaceResourceApp
import ru.vyarus.dropwizard.guice.cases.ifaceresource.support.ResourceContract
import ru.vyarus.dropwizard.guice.cases.ifaceresource.support.ResourceImpl
import ru.vyarus.dropwizard.guice.module.GuiceyConfigurationInfo
import ru.vyarus.dropwizard.guice.module.installer.feature.jersey.ResourceInstaller
import ru.vyarus.dropwizard.guice.test.spock.UseDropwizardApp
import spock.lang.Specification
import javax.inject.Inject
import javax.ws.rs.client.Client
import javax.ws.rs.client.ClientBuilder
/**
* @author Vyacheslav Rusakov
* @since 18.06.2016
*/
@UseDropwizardApp(InterfaceResourceApp)
class InterfaceResourceDefinitionTest extends Specification {
@Inject
GuiceyConfigurationInfo info
def "Check resources recognition"() {
expect: "only one resource recognized"
info.getExtensions(ResourceInstaller) == [ResourceImpl]
}
def "Check resource registered"() {
expect: 'resource called'
new URL("http://localhost:8080/res").getText() == 'called!'
}
def "Check resource proxy usage"() {
// https://jersey.java.net/apidocs/2.22.1/jersey/org/glassfish/jersey/client/proxy/package-summary.html
Client c = ClientBuilder.newClient();
ResourceContract resource = WebResourceFactory.newResource(ResourceContract.class, c.target("http://localhost:8080/"));
expect:
resource.latest() == 'called!'
}
}