Skip to content
Permalink
Browse files
paho: Add test coverage for file persistence #3680
  • Loading branch information
aldettinger committed Mar 29, 2022
1 parent e08002a commit 80642ad479b06f028d1c74e67ee84eb81f6254f9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
@@ -16,6 +16,8 @@
*/
package org.apache.camel.quarkus.component.paho.deployment;

import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;
import java.util.ResourceBundle;

import io.quarkus.deployment.annotations.BuildProducer;
@@ -41,6 +43,9 @@ void registerReflectiveClasses(BuildProducer<ReflectiveClassBuildItem> p) {
p.produce(new ReflectiveClassBuildItem(false, false, JSR47Logger.class));
p.produce(new ReflectiveClassBuildItem(false, false, ResourceBundleCatalog.class));
p.produce(new ReflectiveClassBuildItem(false, false, ResourceBundle.class));
p.produce(new ReflectiveClassBuildItem(false, false, FileLock.class));
p.produce(new ReflectiveClassBuildItem(true, false, FileChannel.class));
p.produce(new ReflectiveClassBuildItem(true, false, "sun.nio.ch.FileLockImpl"));
}

@BuildStep
@@ -26,6 +26,7 @@
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

@@ -87,4 +88,11 @@ public String mqttExceptionDuringReconnectShouldSucceed() {
return mqex.getMessage();
}

@Path("/readThenWriteWithFilePersistenceShouldSucceed")
@GET
@Produces(MediaType.TEXT_PLAIN)
public String readThenWriteWithFilePersistenceShouldSucceed(@QueryParam("message") String message) throws Exception {
producerTemplate.requestBody("paho:withFilePersistence?retained=true&cleanSession=false&persistence=FILE", message);
return consumerTemplate.receiveBody("paho:withFilePersistence?cleanSession=false&persistence=FILE", 5000, String.class);
}
}
@@ -63,4 +63,15 @@ public void mqttExceptionDuringReconnectShouldSucceed() {
.statusCode(200)
.body(matchesRegex(".+"));
}

@Test
public void readThenWriteWithFilePersistenceShouldSucceed() {
String message = "readThenWriteWithFilePersistenceShouldSucceed message content: 762e6af1-3ec7-40e0-9271-0c98a1001728";
RestAssured.given()
.queryParam("message", message)
.get("/paho/readThenWriteWithFilePersistenceShouldSucceed")
.then()
.statusCode(200)
.body(is(message));
}
}

0 comments on commit 80642ad

Please sign in to comment.