I am setting up a back-end test using Java. When running my test I am presented with the following error:
java.lang.NoSuchMethodError: io.netty.util.internal.PlatformDependent.allocateUninitializedArray(I)[B
My pom file contains the following dependencies in regard to Netty:
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport</artifactId>
<version>4.1.36.Final</version>
</dependency>
My code itself looks as follows:
import cucumber.api.java.en.And;
import org.mockserver.client.MockServerClient;
import org.mockserver.matchers.Times;
import org.mockserver.model.HttpRequest;
import org.mockserver.model.HttpResponse;
import org.springframework.beans.factory.annotation.Autowired;
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
public class PdfGenerateStep {
@Autowired
private MockServerClient mockServerClient;
@And("Pdf {string} is generated")
public void generatePDF(String pdfFile) {
HttpRequest httpRequest = new HttpRequest();
httpRequest.withPath("/pdf-service/doc/request")
.withHeader("template", "TEST")
.withHeader("docFormat", "pdf")
.withHeader("fromParty", "PDFGEN")
.withHeader("APPLICATION", "App")
.withMethod("POST");
HttpResponse httpResponse = new HttpResponse();
httpResponse.withStatusCode(200);
httpResponse.withBody(readPdfFile(pdfFile));
mockServerClient.when(httpRequest, Times.once()).respond(httpResponse);
}
private byte[] readPdfFile(String file) {
try {
Path path = Paths.get(getClass().getClassLoader().getResource(file).toURI());
return Files.readAllBytes(path);
} catch (URISyntaxException | IOException e) {
e.printStackTrace();
}
return null;
}
}