测试过去一直持续到上周,现在开始失败了。错误显示如下。
其余-放心= 2.9.0 HttpClient的-4.5.1.jar 的HttpCore-4.4.3.jar
我从常春藤中排除了其他httpclient和核心罐这两个以上版本来自放心。我真的需要帮助。
import static com.jayway.restassured.RestAssured.given
@Test
public void getSummary(){
given().
contentType("application/json").
when().
get("http://example.org/ab/resources/client/case/123455").
then().
statusCode(200).
extract().path("id");
;
//statusCode(200);
}
java.lang.NoSuchFieldError: DEF_CONTENT_CHARSET
at com.jayway.restassured.config.EncoderConfig.(EncoderConfig.java:61)
at com.jayway.restassured.config.RestAssuredConfig.(RestAssuredConfig.java:41)
at com.jayway.restassured.RestAssured.(RestAssured.java:423)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:278)
at org.codehaus.groovy.runtime.callsite.CallSiteArray$1.run(CallSiteArray.java:68)
at org.codehaus.groovy.runtime.callsite.CallSiteArray$1.run(CallSiteArray.java:65)
at java.security.AccessController.doPrivileged(Native Method)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallStaticSite(CallSiteArray.java:65)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:56)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:194)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:198)
at com.thomson.tssq.jwb.restapitests.RestAPITest.getSummary(RestAPITest.groovy:16)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:78)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:212)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
答案 0 :(得分:0)
查看在classpath或maven pom.xml中是否有以下列出的jar
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ rest-assured ---
[INFO] io.rest-assured:rest-assured:jar:3.0.2-SNAPSHOT
[INFO] +- org.codehaus.groovy:groovy:jar:2.4.6:compile
[INFO] +- org.codehaus.groovy:groovy-xml:jar:2.4.6:compile
[INFO] +- org.apache.httpcomponents:httpclient:jar:4.5.2:compile
[INFO] | +- org.apache.httpcomponents:httpcore:jar:4.4.4:compile
[INFO] | +- commons-logging:commons-logging:jar:1.2:compile
[INFO] | \- commons-codec:commons-codec:jar:1.9:compile
[INFO] +- org.apache.httpcomponents:httpmime:jar:4.5.1:compile
[INFO] +- com.github.scribejava:scribejava-apis:jar:2.5.3:compile
[INFO] | \- com.github.scribejava:scribejava-core:jar:2.5.3:compile
[INFO] +- org.hamcrest:hamcrest-core:jar:1.3:compile
[INFO] +- org.hamcrest:hamcrest-library:jar:1.3:compile
[INFO] +- org.ccil.cowan.tagsoup:tagsoup:jar:1.2.1:compile
[INFO] +- io.rest-assured:json-path:jar:3.0.2-SNAPSHOT:compile
[INFO] | +- org.codehaus.groovy:groovy-json:jar:2.4.6:compile
[INFO] | \- io.rest-assured:rest-assured-common:jar:3.0.2-SNAPSHOT:compile
[INFO] +- io.rest-assured:xml-path:jar:3.0.2-SNAPSHOT:compile
[INFO] | \- org.apache.commons:commons-lang3:jar:3.4:compile
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.7.3:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.7.0:compile
[INFO] | \- com.fasterxml.jackson.core:jackson-core:jar:2.7.3:compile
[INFO] +- org.codehaus.jackson:jackson-core-asl:jar:1.9.11:compile
[INFO] +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.11:compile
[INFO] +- com.google.code.gson:gson:jar:2.6.2:compile
[INFO] +- com.googlecode.json-simple:json-simple:jar:1.1.1:compile
[INFO] +- junit:junit:jar:4.12:test
[INFO] \- org.assertj:assertj-core:jar:1.7.0:test