Using Wiremock 2.x from Scala
See original GitHub issueI am trying to use Wiremock 2.1.6 from Scala. However, something has changed in the types of the mapping builders, so that scalac cannot typecheck it anymore.
The first stubbing example in the documentation:
stubFor(get(urlEqualTo("/some/thing"))
.willReturn(aResponse()
.withHeader("Content-Type", "text/plain")
.withBody("Hello world!")));
results in this error when compiling:
type mismatch;
found : ?0(in value <local TestSpec>) where type ?0(in value <local TestSpec>) <: AnyRef
required: com.github.tomakehurst.wiremock.client.RemoteMappingBuilder[_ <: AnyRef, _ <: com.github.tomakehurst.wiremock.client.ScenarioMappingBuilder]
get(urlEqualTo("some/thing")).willReturn(
The method willReturn
is defined in the RemoteMappingBuilder
interface
public interface RemoteMappingBuilder<M extends RemoteMappingBuilder, S extends ScenarioMappingBuilder> {
...
M willReturn(ResponseDefinitionBuilder responseDefBuilder);
}
It seems to me that Scala is not happy about the generic interface RemoteMappingBuilder
being used without type parameters in M extends RemoteMappingBuilder
.
Any suggestions on how to work around this?
(I also posted this on SO: http://stackoverflow.com/questions/38301631/wiremock-2-x-in-scala)
Issue Analytics
- State:
- Created 7 years ago
- Comments:5
Top Results From Across the Web
Wiremock 2.x in Scala - Stack Overflow
I am trying to use Wiremock 2.1.6 from Scala. However, something has changed in the types of the mapping builders, so that scalac...
Read more >Using Wiremock 2.x from Scala · Issue #457 - GitHub
I am trying to use Wiremock 2.1.6 from Scala. However, something has changed in the types of the mapping builders, so that scalac...
Read more >[Solved]-Wiremock 2.x in Scala-scala - appsloveworld
Coding example for the question Wiremock 2.x in Scala-scala.
Read more >Getting Started - WireMock
WireMock is distributed via Maven Central and can be included in your project using common build tools' dependency management. Get started with WireMock....
Read more >How to Download and Install WireMock
WireMock is distributed in two flavours - a standard JAR containing just WireMock, and a standalone fat JAR containing WireMock plus all its...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
We’re working on a fix but it’s taking a while. Maintaining some semblance of backwards compatibility is going to be hard.
Breaking Scala certainly wasn’t intentional. I’m not a Scala expert and hadn’t appreciated that its generics system will reject code that javac had no problem with.
Cool, thanks. That’s also the first time I come across something like this 😕