Various improvements for MQTT modules code style
This commit is contained in:
@@ -32,6 +32,9 @@ import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
@Testcontainers(disabledWithoutDocker = true)
|
||||
public interface MosquittoContainerTest {
|
||||
|
||||
/**
|
||||
* The Mosquitto Testcontainers instance.
|
||||
*/
|
||||
GenericContainer<?> MOSQUITTO_CONTAINER = new GenericContainer<>("eclipse-mosquitto:2.0.13")
|
||||
.withCommand("mosquitto -c /mosquitto-no-auth.conf")
|
||||
.withExposedPorts(1883);
|
||||
|
||||
@@ -59,12 +59,8 @@ public class SftpTestSupport extends RemoteFileTestSupport {
|
||||
public static void createServer() throws Exception {
|
||||
server = SshServer.setUpDefaultServer();
|
||||
server.setPasswordAuthenticator(
|
||||
(username, password, session) -> StringUtils.hasText(password) && !"badPassword".equals(password)); // fail
|
||||
// if
|
||||
// pub
|
||||
// key
|
||||
// validation
|
||||
// failed
|
||||
// fail if pub key validation failed
|
||||
(username, password, session) -> StringUtils.hasText(password) && !"badPassword".equals(password));
|
||||
server.setPublickeyAuthenticator((username, key, session) -> key.equals(decodePublicKey("id_rsa_pp.pub")));
|
||||
server.setPort(0);
|
||||
server.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(new File("hostkey.ser").toPath()));
|
||||
|
||||
@@ -59,7 +59,7 @@ public class MqttConsumerTests implements MosquittoContainerTest {
|
||||
|
||||
@DynamicPropertySource
|
||||
static void mongoDbProperties(DynamicPropertyRegistry registry) {
|
||||
registry.add("mqtt.url", () -> "tcp://localhost:" + MOSQUITTO_CONTAINER.getMappedPort(1883));
|
||||
registry.add("mqtt.url", MosquittoContainerTest::mqttUrl);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -58,7 +58,7 @@ public class MqttSupplierTests implements MosquittoContainerTest {
|
||||
|
||||
@DynamicPropertySource
|
||||
static void mongoDbProperties(DynamicPropertyRegistry registry) {
|
||||
registry.add("mqtt.url", () -> "tcp://localhost:" + MOSQUITTO_CONTAINER.getMappedPort(1883));
|
||||
registry.add("mqtt.url", MosquittoContainerTest::mqttUrl);
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
||||
Reference in New Issue
Block a user