Попытка построить тест-драйв Hello World. https://jersey.java.net/documentation/2.5.1/test-framework.html заставляет его выглядеть так просто, но при переопределении метода configure, как документировано, не работает.Документация по дизайну трикотажных изделий не работает
Из документации
package api;
import static org.junit.Assert.assertEquals;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.core.Application;
import org.junit.Test;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.core.ResourceConfig;
import com.sun.jersey.test.framework.JerseyTest;
import com.sun.jersey.test.framework.WebAppDescriptor;
public class JerseyTester extends JerseyTest {
@Path("hello")
public static class HelloResource {
@GET
public String getHello() {
return "Hello World!";
}
}
@Override
protected Application configure() {
return new ResourceConfig(HelloResource.class);
}
@Test
public void testHelloWorld() {
WebResource webResource = resource();
String responseMsg = webResource.path("helloworld").get(String.class);
assertEquals("Hello World", responseMsg);
}
}
Вопрос является метод настройки переопределения не работает - я получаю ошибку: «Тип возврата несовместим с JerseyTest.configure()». Я также получаю сообщение об ошибке: «Невозможно создать экземпляр типа ResourceConfig» - как это может быть, когда документация явно указывает на его создание ?!
Это так я не знаю, почему это не сработает. Я просто пытаюсь получить тестируемую конечную точку простого Джейн.
Вот моя зависимость:
dependencies {
compile 'javax.ws.rs:jsr311-api:1.1.1'
compile 'com.sun.jersey:jersey-server:1.19'
compile 'com.sun.jersey:jersey-core:1.19'
compile 'com.sun.jersey:jersey-client:1.19'
compile 'com.sun.jersey:jersey-servlet:1.19'
compile 'com.sun.jersey:jersey-json:1.19'
compile 'com.yammer.metrics:metrics-core:2.2.0'
compile 'com.yammer.metrics:metrics-servlet:2.2.0'
compile 'com.yammer.metrics:metrics-jersey:2.2.0'
compile 'com.yammer.metrics:metrics-graphite:2.2.0'
compile 'log4j:log4j:1.2.16'
testCompile 'junit:junit-dep:4.10'
testCompile 'com.sun.jersey.jersey-test-framework:jersey-test-framework-grizzly2:1.19'
testCompile 'org.slf4j:slf4j-simple:1.6.1'
}
Добавление информации к сообщению – Patrick