Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

paho: add test case for RFC3986 style urls #3758 #3759

Merged
merged 1 commit into from
May 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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");
zhfeng marked this conversation as resolved.
Show resolved Hide resolved

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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}