ppalaga commented on code in PR #3721:
URL: https://github.com/apache/camel-quarkus/pull/3721#discussion_r848634127
##########
integration-tests/paho/src/main/java/org/apache/camel/quarkus/component/paho/PahoResource.java:
##########
@@ -92,7 +116,41 @@ public String mqttExceptionDuringReconnectShouldSucceed() {
@GET
@Produces(MediaType.TEXT_PLAIN)
public String
readThenWriteWithFilePersistenceShouldSucceed(@QueryParam("message") String
message) throws Exception {
-
producerTemplate.requestBody("paho:withFilePersistence?retained=true&persistence=FILE",
message);
- return
consumerTemplate.receiveBody("paho:withFilePersistence?persistence=FILE", 5000,
String.class);
+
producerTemplate.requestBody("paho:withFilePersistence?retained=true&persistence=FILE&brokerUrl="
+ brokerUrl("tcp"),
+ message);
+ return
consumerTemplate.receiveBody("paho:withFilePersistence?persistence=FILE&brokerUrl="
+ brokerUrl("tcp"), 5000,
+ String.class);
+ }
+
+ private String brokerUrl(String protocol) {
+ return ConfigProvider.getConfig().getValue("paho.broker." + protocol +
".url", String.class);
+ }
+
+ private void setKeyStore(String keystore, String password) {
+ InputStream in =
Thread.currentThread().getContextClassLoader().getResourceAsStream(keystore);
+
+ try {
+ Files.copy(in, Paths.get(keystore),
StandardCopyOption.REPLACE_EXISTING);
+ System.setProperty("javax.net.ssl.keyStore", keystore);
+ System.setProperty("javax.net.ssl.keyStorePassword", password);
+ System.setProperty("javax.net.ssl.trustStore", keystore);
+ System.setProperty("javax.net.ssl.trustStorePassword", password);
Review Comment:
Does this setting and unsetting `javax.net.ssl.*` really work? Is paho
creating its own SSLContext dynamically? IIRC the JVM's global context is
initializable only once (and thus, if paho is using it, the unsetting has no
effect). I wonder whether the unsetting is important for some specific reason?
##########
integration-tests/paho/src/main/java/org/apache/camel/quarkus/component/paho/PahoResource.java:
##########
@@ -92,7 +116,41 @@ public String mqttExceptionDuringReconnectShouldSucceed() {
@GET
@Produces(MediaType.TEXT_PLAIN)
public String
readThenWriteWithFilePersistenceShouldSucceed(@QueryParam("message") String
message) throws Exception {
-
producerTemplate.requestBody("paho:withFilePersistence?retained=true&persistence=FILE",
message);
- return
consumerTemplate.receiveBody("paho:withFilePersistence?persistence=FILE", 5000,
String.class);
+
producerTemplate.requestBody("paho:withFilePersistence?retained=true&persistence=FILE&brokerUrl="
+ brokerUrl("tcp"),
+ message);
+ return
consumerTemplate.receiveBody("paho:withFilePersistence?persistence=FILE&brokerUrl="
+ brokerUrl("tcp"), 5000,
+ String.class);
+ }
+
+ private String brokerUrl(String protocol) {
+ return ConfigProvider.getConfig().getValue("paho.broker." + protocol +
".url", String.class);
+ }
+
+ private void setKeyStore(String keystore, String password) {
+ InputStream in =
Thread.currentThread().getContextClassLoader().getResourceAsStream(keystore);
+
+ try {
Review Comment:
```suggestion
try (InputStream in =
Thread.currentThread().getContextClassLoader().getResourceAsStream(keystore)) {
```
It would be nice if we could close the InputStream
##########
integration-tests/paho/src/main/java/org/apache/camel/quarkus/component/paho/PahoResource.java:
##########
@@ -92,7 +116,41 @@ public String mqttExceptionDuringReconnectShouldSucceed() {
@GET
@Produces(MediaType.TEXT_PLAIN)
public String
readThenWriteWithFilePersistenceShouldSucceed(@QueryParam("message") String
message) throws Exception {
-
producerTemplate.requestBody("paho:withFilePersistence?retained=true&persistence=FILE",
message);
- return
consumerTemplate.receiveBody("paho:withFilePersistence?persistence=FILE", 5000,
String.class);
+
producerTemplate.requestBody("paho:withFilePersistence?retained=true&persistence=FILE&brokerUrl="
+ brokerUrl("tcp"),
+ message);
+ return
consumerTemplate.receiveBody("paho:withFilePersistence?persistence=FILE&brokerUrl="
+ brokerUrl("tcp"), 5000,
+ String.class);
+ }
+
+ private String brokerUrl(String protocol) {
+ return ConfigProvider.getConfig().getValue("paho.broker." + protocol +
".url", String.class);
+ }
+
+ private void setKeyStore(String keystore, String password) {
+ InputStream in =
Thread.currentThread().getContextClassLoader().getResourceAsStream(keystore);
+
+ try {
+ Files.copy(in, Paths.get(keystore),
StandardCopyOption.REPLACE_EXISTING);
Review Comment:
Woudn't this copy the file to the given module's root directory, where
somebody could inadvertently add it to git? Maybe under tmp or target could be
better?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]