1
PACT JVMテストケースを実行すると、次のエラーが発生します。実際にこのエラーが発生する前に、scala依存関係を1つ追加した後にもう1つのscalaエラーが発生しました。Pact JVMには、スカラー関連の依存関係もインストールする必要がありますか?
java.lang.NoClassDefFoundError: scala/Product$class
at au.com.dius.pact.model.RequestMatching.<init>(RequestMatching.scala:7)
at au.com.dius.pact.model.RequestMatching$.apply(RequestMatching.scala:7)
at au.com.dius.pact.model.RequestMatching.apply(RequestMatching.scala)
at au.com.dius.pact.consumer.BaseMockServer.<init>(MockHttpServer.kt:61)
at au.com.dius.pact.consumer.MockHttpServer.<init>(MockHttpServer.kt:202)
at au.com.dius.pact.consumer.MockHttpServerKt.mockServer(MockHttpServer.kt:34)
at au.com.dius.pact.consumer.ConsumerPactRunnerKt.runConsumerTest(ConsumerPactRunner.kt:12)
at au.com.dius.pact.consumer.ConsumerPactTestMk2.testPact(ConsumerPactTestMk2.java:26)
これは私のコードです: `パブリッククラスContractTestは、それは、バージョン3.5.5 are a little brokenの依存関係のように見えますConsumerPactTestMk2 {
@Rule
public PactProviderRuleMk2 mockProvider = new PactProviderRuleMk2("test_provider", "localhost", 5055, this);
@Override
@Pact(provider="test_provider", consumer="test_consumer")
protected RequestResponsePact createPact(PactDslWithProvider builder) {
Map<String, String> headers = new HashMap<String, String>();
headers.put("testreqheader", "testreqheadervalue");
JSONObject updateJsonObj = new JSONObject();
JSONObject updateVersion = new JSONObject();
updateVersion.put("version", "1.4");
updateJsonObj.put("update", updateVersion);
return builder.given("test state 1") // NOTE: Using provider states are optional, you can leave it out
.uponReceiving("ExampleJavaConsumerPactTest test interaction")
.path("/hostService/hosts/1")
.method("PUT")
.body(updateJsonObj)
.willRespondWith()
.status(200)
.body(updateJsonObj)
.given("test state 2") // NOTE: Using provider states are optional, you can leave it out
.uponReceiving("ExampleJavaConsumerPactTest second test interaction")
.method("GET")
.path("/hostService/hosts/1")
.body("")
.willRespondWith()
.status(200)
.body("")
.toPact();
}
@Override
protected String providerName() {
return "test_provider";
}
@Override
protected String consumerName() {
return "test_consumer";
}
@Override
protected void runTest(MockServer mockServer) throws IOException {
HttpClient httpClient = HttpClients.createDefault();
HttpPut putReq = new HttpPut(mockServer.getUrl());
HttpGet getReq = new HttpGet(mockServer.getUrl());
HttpResponse response = httpClient.execute(getReq);
Assert.assertEquals(response.getStatusLine().getStatusCode(), 200);
response = httpClient.execute(putReq);
Assert.assertEquals(getVersion(response.getEntity().toString()), "1.3");
}
`
verisonあなたは依存関係を使用していますか? –
私のバージョンは3.5.5です –
私は同じ問題がありました。私はあなたに答えを加えました。 –