Hello! I'm trying to set up Pact testing, but I am...
# general
e
Hello! I'm trying to set up Pact testing, but I am hung up on the provider side test. I am trying to use the Leiningen plugin . What I really need is an example of this plugin in use, but I couldn't find one. I'll add more details in this chain. ⬇️ Appreciate any help or ideas!
To set up the leiningen plugin, I added a
:pact
profile as described in the readme, and I added this to my project.clj :
Copy code
:pact
{:service-providers {:payment-service {:protocol "http"
                                       :host "localhost"
                                       :port 8010
                                       :path "/payment-batches/latest"
                                       :has-pact-with
                                           {:admin-api
                                               {:pact-file "admin-api-payment-service.json"}}}}}
But when I run
lein with-profile pact pact-verify
, I am getting an error message like
Copy code
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/io/input/UnsynchronizedByteArrayInputStream
	at org.apache.tika.io.TikaInputStream.get(TikaInputStream.java:323)
	at org.apache.tika.io.TikaInputStream.get(TikaInputStream.java:306)
	at au.com.dius.pact.core.model.OptionalBody.detectContentType(OptionalBody.kt:131)
	at au.com.dius.pact.core.model.OptionalBody.<init>(OptionalBody.kt:37)
	at au.com.dius.pact.core.model.OptionalBody$Companion.body(OptionalBody.kt:243)
	at au.com.dius.pact.core.model.OptionalBody$Companion.body(OptionalBody.kt:227)
	at au.com.dius.pact.core.model.HttpPart$Companion.decodeBody(HttpPart.kt:111)
	at au.com.dius.pact.core.model.HttpPart$Companion.extractBody(HttpPart.kt:98)
	at au.com.dius.pact.core.model.HttpPart$Companion.extractBody$default(HttpPart.kt:91)
	at au.com.dius.pact.core.model.Response$Companion.fromJson(Response.kt:120)
	at au.com.dius.pact.core.model.DefaultPactReader.extractResponse(PactReader.kt:323)
	at au.com.dius.pact.core.model.DefaultPactReader$loadV3Pact$interactions$1.invoke(PactReader.kt:265)
	at au.com.dius.pact.core.model.DefaultPactReader$loadV3Pact$interactions$1.invoke(PactReader.kt:263)
	at au.com.dius.pact.core.support.json.JsonValueKt.map(JsonValue.kt:338)
	at au.com.dius.pact.core.model.DefaultPactReader.loadV3Pact(PactReader.kt:263)
	at au.com.dius.pact.core.model.DefaultPactReader.pactFromJson(PactReader.kt:224)
	at au.com.dius.pact.core.model.DefaultPactReader.loadPact(PactReader.kt:217)
	at au.com.dius.pact.core.model.DefaultPactReader.loadPact(PactReader.kt:213)
	at au.com.dius.pact.provider.ProviderVerifier.loadPactFileForConsumer(ProviderVerifier.kt:1357)
	at au.com.dius.pact.provider.ProviderVerifier.runVerificationForConsumer(ProviderVerifier.kt:1195)
	at au.com.dius.pact.provider.ProviderVerifier.runVerificationForConsumer$default(ProviderVerifier.kt:1189)
	at au.com.dius.pact.provider.ProviderVerifier.verifyProvider(ProviderVerifier.kt:1173)
...
So I think something is wrong with the way I gave the value for
:pact-file
, or the way that file is formatted. Ideally, I'd like to be pointing this at the url for my PactFlow account, but as a start I just copied the file
admin-api-payment-service.json
into the provider repo. It seems to be finding the file -- I get a different error if I give it a bogus file name -- but can't seem to parse it. Any ideas for me?
y
hey, have you tried an absolute file path rather than just the file name? the docs suggest /path/to/filename your question may also be better served in pact-jvm. personally i’ve seen the docs but never used leiningen, so might not work :)
e
Yes, thanks for the suggestion. I've tried that and every other variation I could think of. 😆 I'll re-post to the other channel.