hi Everyone would appreciate your help, upgrade my...
# wiremock-java
s
hi Everyone would appreciate your help, upgrade my env from junit 4 to junit 5, spring boot 2.7 to spring 3.3.4 but not able to stub (running cucumber test) getting the follow error:
Copy code
java.lang.NullPointerException: Cannot invoke "com.github.tomakehurst.wiremock.junit.Stubbing.stubFor(com.github.tomakehurst.wiremock.client.MappingBuilder)" because "this.stubbing" is null
	at com.github.tomakehurst.wiremock.junit.DslWrapper.stubFor(DslWrapper.java:261)
	at ct.com.zebra.secondary.series.templates.TemplatesStepdefs.configureWireMockStub(TemplatesStepdefs.java:172)
	at ✽.I configure wire mock to retrieve image input/zebra.png for studyId:cbbbc88f-c897-4ac9-b4ee-33e6bde32480 seriesId:214.2639356445.26983.21153.46400.80153539354141 dicomId:214.405089174.64947.23898.43714.188026663186433 fileType:JPG
this is how i create the wiremock:
Copy code
@RegisterExtension
static WireMockExtension wireMockServer = WireMockExtension.newInstance()
        .options(wireMockConfig()
                .needClientAuth(false)
                .httpsPort(8081)
                .port(8082))
        .build();
this is where i am trying to create the stub, and what casue the exception:
Copy code
@And("I configure wire mock to retrieve image {} for studyId:{} seriesId:{} dicomId:{} fileType:{}")
public void configureWireMockStub(String imagePath, String studyId, String seriesId, String dicomId, String fileType) throws IOException {
    byte[] fileContent = IOUtils.toByteArray(this.getClass().getClassLoader().getResourceAsStream(imagePath));


    wireMockServer.stubFor(get(urlEqualTo("/study/%s/series/%s/dcm/%s?fileType=%s"
            .formatted(studyId, seriesId, dicomId, fileType)))
            .willReturn(aResponse()
                    .withBody(fileContent)));
this is the gradle config:
Copy code
// Wiremock
    testImplementation 'org.wiremock:wiremock-standalone:3.9.1'
t
That suggests that the WireMock server didn’t start up. Did you see any other exceptions thrown in the log?
s
No just this one….
t
You could try setting a breakpoint at
WireMockExtension:#216
and see if it manages to run the
start()
call without throwing.
133 Views