Skip to content
Permalink
Browse files
paho: add test case for RFC3986 style urls #3758
  • Loading branch information
aldettinger committed May 5, 2022
1 parent 7f56d57 commit 4f3748f13231eeba519a331cf135fbd5bd3c0266
Showing 2 changed files with 26 additions and 0 deletions.
@@ -125,6 +125,21 @@ public String readThenWriteWithFilePersistenceShouldSucceed(@QueryParam("message
String.class);
}

@Path("/sendReceiveWithRfc3986AuthorityShouldSucceed")
@GET
@Produces(MediaType.TEXT_PLAIN)
public String sendReceiveWithRfc3986AuthorityShouldSucceed(@QueryParam("message") String message) {

// Change the brokerUrl to an RFC3986 form
String tcpUrl = ConfigProvider.getConfig().getValue("paho.broker.tcp.url", String.class);
tcpUrl = tcpUrl.replaceAll("tcp://([^:]*):(.*)", "tcp://user:password@$1:$2");

producerTemplate.requestBody("paho:rfc3986?retained=true&brokerUrl=" + tcpUrl,
message);
return consumerTemplate.receiveBody("paho:rfc3986?brokerUrl=" + tcpUrl, 5000,
String.class);
}

private String brokerUrl(String protocol) {
return ConfigProvider.getConfig().getValue("paho.broker." + protocol + ".url", String.class);
}
@@ -89,4 +89,15 @@ public void readThenWriteWithFilePersistenceShouldSucceed() {
.statusCode(200)
.body(is(message));
}

@Test
public void sendReceiveWithRfc3986AuthorityShouldSucceed() {
String message = "sendReceiveWithRfc3986AuthorityShouldSucceed message content: 3bfe3754-cea4-488c-9534-f70d2a1a7c23";
RestAssured.given()
.queryParam("message", message)
.get("/paho/sendReceiveWithRfc3986AuthorityShouldSucceed")
.then()
.statusCode(200)
.body(is(message));
}
}

0 comments on commit 4f3748f

Please sign in to comment.