Open
Description
Hi so I'm developing a plugin for JMeter that uses fluent-http as a web server to expose a REST API.
I'm currently unable to consume any URL, the server is started on the right port - I was able to check that out with a simple telnet. However, it never sends a response. I've been trying to figure out the problem by reading the documentation but no luck.
Here's my sample code:
public class App {
private WebServer instance;
private int port;
private JMeterContext jMeterContext;
public App(int p, JMeterContext jc) {
this.instance = new WebServer().configure(routes -> routes
.get("/test", new Payload("application/json","{\"hello\":\"world!\"}", 200))
);
this.port = p;
this.jMeterContext = jc;
}
/**
* Methods to start or stop the API
*/
public void start() {
this.instance.start(this.port);
}
public void stop() {
this.instance.stop();
}
}
Here's my unit test to check the connectivity:
public class TestAppServer {
private static int PORT = 8080;
private static String APP_ADDRESS = "http://localhost:" + PORT;
private App server;
@Before
public void startTest() throws Exception {
this.server = new App(PORT, null);
this.server.start();
}
@Test
public void testServerConnectivity() throws Exception {
HttpResponse<JsonNode> response = Unirest.get(APP_ADDRESS + "/test").asJson();
assertTrue(response.getBody().toString().contains("world"));
}
@After
public void stopTest() throws Exception {
this.server.stop();
}
}
Any chance anyone could help me pinpoint the issue here? It's for sure something stupid on my end!
Thanks,
Metadata
Metadata
Assignees
Labels
No labels