You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by va...@apache.org on 2021/01/15 09:45:08 UTC
[camel-kafka-connector] branch master updated: Updates SSH tests to
Camel's 3.7 test infra interfaces
This is an automated email from the ASF dual-hosted git repository.
valdar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-kafka-connector.git
The following commit(s) were added to refs/heads/master by this push:
new 524fc20 Updates SSH tests to Camel's 3.7 test infra interfaces
524fc20 is described below
commit 524fc20b021a0e683a1e32b7a5f66203bb4b0484
Author: Otavio Rodolfo Piske <op...@redhat.com>
AuthorDate: Fri Jan 15 08:33:55 2021 +0100
Updates SSH tests to Camel's 3.7 test infra interfaces
---
.../SshProperties.java} | 32 ++++------------------
.../ssh/services/SshLocalContainerService.java | 15 +++++++++-
.../ssh/services/SshRemoteService.java | 13 +++++++--
.../kafkaconnector/ssh/services/SshService.java | 13 ++-------
4 files changed, 31 insertions(+), 42 deletions(-)
diff --git a/tests/itests-ssh/src/test/java/org/apache/camel/kafkaconnector/ssh/services/SshRemoteService.java b/tests/itests-ssh/src/test/java/org/apache/camel/kafkaconnector/ssh/common/SshProperties.java
similarity index 58%
copy from tests/itests-ssh/src/test/java/org/apache/camel/kafkaconnector/ssh/services/SshRemoteService.java
copy to tests/itests-ssh/src/test/java/org/apache/camel/kafkaconnector/ssh/common/SshProperties.java
index cb5de9c..920e5fa 100644
--- a/tests/itests-ssh/src/test/java/org/apache/camel/kafkaconnector/ssh/services/SshRemoteService.java
+++ b/tests/itests-ssh/src/test/java/org/apache/camel/kafkaconnector/ssh/common/SshProperties.java
@@ -15,35 +15,13 @@
* limitations under the License.
*/
-package org.apache.camel.kafkaconnector.ssh.services;
+package org.apache.camel.kafkaconnector.ssh.common;
-public class SshRemoteService implements SshService {
+public final class SshProperties {
+ public static final String SSH_HOST = "ssh.host";
+ public static final String SSH_PORT = "ssh.port";
- private static final int DEFAULT_SSH_PORT = 22;
+ private SshProperties() {
- @Override
- public void initialize() {
-
- }
-
- @Override
- public void shutdown() {
-
- }
-
- @Override
- public int getSshPort() {
- String strPort = System.getProperty("ssh.port");
-
- if (strPort != null) {
- return Integer.parseInt(strPort);
- }
-
- return DEFAULT_SSH_PORT;
- }
-
- @Override
- public String getSshHost() {
- return System.getProperty("ssh.host");
}
}
diff --git a/tests/itests-ssh/src/test/java/org/apache/camel/kafkaconnector/ssh/services/SshLocalContainerService.java b/tests/itests-ssh/src/test/java/org/apache/camel/kafkaconnector/ssh/services/SshLocalContainerService.java
index 3ecc73c..aca073c 100644
--- a/tests/itests-ssh/src/test/java/org/apache/camel/kafkaconnector/ssh/services/SshLocalContainerService.java
+++ b/tests/itests-ssh/src/test/java/org/apache/camel/kafkaconnector/ssh/services/SshLocalContainerService.java
@@ -17,10 +17,12 @@
package org.apache.camel.kafkaconnector.ssh.services;
+import org.apache.camel.kafkaconnector.ssh.common.SshProperties;
+import org.apache.camel.test.infra.common.services.ContainerService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class SshLocalContainerService implements SshService {
+public class SshLocalContainerService implements SshService, ContainerService<SshContainer> {
private static final Logger LOG = LoggerFactory.getLogger(SshLocalContainerService.class);
private SshContainer container;
@@ -40,6 +42,12 @@ public class SshLocalContainerService implements SshService {
}
@Override
+ public void registerProperties() {
+ System.setProperty(SshProperties.SSH_PORT, String.valueOf(getSshPort()));
+ System.setProperty(SshProperties.SSH_HOST, getSshHost());
+ }
+
+ @Override
public void initialize() {
container.start();
LOG.info("SSH server running at address {}", getSshEndpoint());
@@ -50,4 +58,9 @@ public class SshLocalContainerService implements SshService {
LOG.info("Stopping the Ssh container");
container.stop();
}
+
+ @Override
+ public SshContainer getContainer() {
+ return container;
+ }
}
diff --git a/tests/itests-ssh/src/test/java/org/apache/camel/kafkaconnector/ssh/services/SshRemoteService.java b/tests/itests-ssh/src/test/java/org/apache/camel/kafkaconnector/ssh/services/SshRemoteService.java
index cb5de9c..4bac3d8 100644
--- a/tests/itests-ssh/src/test/java/org/apache/camel/kafkaconnector/ssh/services/SshRemoteService.java
+++ b/tests/itests-ssh/src/test/java/org/apache/camel/kafkaconnector/ssh/services/SshRemoteService.java
@@ -17,13 +17,20 @@
package org.apache.camel.kafkaconnector.ssh.services;
+import org.apache.camel.kafkaconnector.ssh.common.SshProperties;
+
public class SshRemoteService implements SshService {
private static final int DEFAULT_SSH_PORT = 22;
@Override
- public void initialize() {
+ public void registerProperties() {
+ // NO-OP
+ }
+ @Override
+ public void initialize() {
+ registerProperties();
}
@Override
@@ -33,7 +40,7 @@ public class SshRemoteService implements SshService {
@Override
public int getSshPort() {
- String strPort = System.getProperty("ssh.port");
+ String strPort = System.getProperty(SshProperties.SSH_PORT);
if (strPort != null) {
return Integer.parseInt(strPort);
@@ -44,6 +51,6 @@ public class SshRemoteService implements SshService {
@Override
public String getSshHost() {
- return System.getProperty("ssh.host");
+ return System.getProperty(SshProperties.SSH_HOST);
}
}
diff --git a/tests/itests-ssh/src/test/java/org/apache/camel/kafkaconnector/ssh/services/SshService.java b/tests/itests-ssh/src/test/java/org/apache/camel/kafkaconnector/ssh/services/SshService.java
index c2dcef7..c764e99 100644
--- a/tests/itests-ssh/src/test/java/org/apache/camel/kafkaconnector/ssh/services/SshService.java
+++ b/tests/itests-ssh/src/test/java/org/apache/camel/kafkaconnector/ssh/services/SshService.java
@@ -17,11 +17,12 @@
package org.apache.camel.kafkaconnector.ssh.services;
+import org.apache.camel.test.infra.common.services.TestService;
import org.junit.jupiter.api.extension.AfterAllCallback;
import org.junit.jupiter.api.extension.BeforeAllCallback;
import org.junit.jupiter.api.extension.ExtensionContext;
-public interface SshService extends BeforeAllCallback, AfterAllCallback {
+public interface SshService extends TestService, BeforeAllCallback, AfterAllCallback {
int getSshPort();
@@ -31,16 +32,6 @@ public interface SshService extends BeforeAllCallback, AfterAllCallback {
String getSshHost();
- /**
- * Perform any initialization necessary
- */
- void initialize();
-
- /**
- * Shuts down the service after the test has completed
- */
- void shutdown();
-
@Override
default void beforeAll(ExtensionContext extensionContext) {
initialize();