This is an automated email from the ASF dual-hosted git repository. orpiske 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 5d06dab Fixed checkstyle issues with the CXF integration tests 5d06dab is described below commit 5d06dab4749c0175173bd57db8d101a946047c63 Author: Otavio Rodolfo Piske <opi...@redhat.com> AuthorDate: Wed Feb 17 12:01:34 2021 +0100 Fixed checkstyle issues with the CXF integration tests --- .../cxf/sink/CamelSinkCXFITCase.java | 65 +++++++++------------ .../cxf/sink/CamelSinkCXFPropertyFactory.java | 14 ++--- .../camel/kafkaconnector/cxf/sink/GreeterImpl.java | 4 +- .../kafkaconnector/cxf/sink/HelloServiceImpl.java | 4 +- .../cxf/source/CamelSourceCXFITCase.java | 67 ++++++++-------------- .../cxf/source/CamelSourceCXFPropertyFactory.java | 15 ++--- 6 files changed, 62 insertions(+), 107 deletions(-) diff --git a/tests/itests-cxf/src/test/java/org/apache/camel/kafkaconnector/cxf/sink/CamelSinkCXFITCase.java b/tests/itests-cxf/src/test/java/org/apache/camel/kafkaconnector/cxf/sink/CamelSinkCXFITCase.java index 61c01c1..6220924 100644 --- a/tests/itests-cxf/src/test/java/org/apache/camel/kafkaconnector/cxf/sink/CamelSinkCXFITCase.java +++ b/tests/itests-cxf/src/test/java/org/apache/camel/kafkaconnector/cxf/sink/CamelSinkCXFITCase.java @@ -37,42 +37,37 @@ import org.apache.cxf.ext.logging.LoggingInInterceptor; import org.apache.cxf.ext.logging.LoggingOutInterceptor; import org.apache.cxf.frontend.ServerFactoryBean; import org.apache.cxf.jaxws.EndpointImpl; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Timeout; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import static org.junit.jupiter.api.Assertions.fail; public class CamelSinkCXFITCase extends AbstractKafkaTest { - private static final Logger LOG = LoggerFactory.getLogger(CamelSinkCXFITCase.class); - - - private final int expect = 10; - - private final int simplePort = NetworkUtils.getFreePort("localhost"); - private final int jaxwsPort = NetworkUtils.getFreePort("localhost"); - protected static final String ECHO_OPERATION = "echo"; protected static final String GREET_ME_OPERATION = "greetMe"; protected static final String TEST_MESSAGE = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" - + "<soap:Body><ns1:echo xmlns:ns1=\"http://source.cxf.kafkaconnector.camel.apache.org/\">" - + "<arg0 xmlns=\"http://source.cxf.kafkaconnector.camel.apache.org/\">hello world</arg0>" - + "</ns1:echo></soap:Body></soap:Envelope>"; - protected static final String JAXWS_TEST_MESSAGE = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\"\n" + - " + \"<soap:Body><ns1:greetMe xmlns:ns1=\"http://apache.org/hello_world_soap_http/types\">\"\n" + - " + \"<requestType xmlns=\"http://apache.org/hello_world_soap_http/types\">hello world!</requestType>\"\n" + - " + \"</ns1:greetMe></soap:Body></soap:Envelope>"; + + "<soap:Body><ns1:echo xmlns:ns1=\"http://source.cxf.kafkaconnector.camel.apache.org/\">" + + "<arg0 xmlns=\"http://source.cxf.kafkaconnector.camel.apache.org/\">hello world</arg0>" + + "</ns1:echo></soap:Body></soap:Envelope>"; + protected static final String JAXWS_TEST_MESSAGE = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\"\n" + + " + \"<soap:Body><ns1:greetMe xmlns:ns1=\"http://apache.org/hello_world_soap_http/types\">\"\n" + + " + \"<requestType xmlns=\"http://apache.org/hello_world_soap_http/types\">hello world!</requestType>\"\n" + + " + \"</ns1:greetMe></soap:Body></soap:Envelope>"; + + private static final Logger LOG = LoggerFactory.getLogger(CamelSinkCXFITCase.class); protected Server server; protected EndpointImpl endpoint; - - - + private final int simplePort = NetworkUtils.getFreePort("localhost"); + private final int jaxwsPort = NetworkUtils.getFreePort("localhost"); + + private final int expect = 10; + @Override protected String[] getConnectorsInTest() { return new String[] {"camel-cxf-kafka-connector"}; @@ -86,7 +81,6 @@ public class CamelSinkCXFITCase extends AbstractKafkaTest { return "http://localhost:" + jaxwsPort + "/" + getClass().getSimpleName() + "/jaxwstest"; } - @BeforeEach public void setUp() throws IOException { // start a simple front service @@ -100,7 +94,7 @@ public class CamelSinkCXFITCase extends AbstractKafkaTest { server.getEndpoint().getOutInterceptors().add(new LoggingOutInterceptor()); // start a jaxws front service GreeterImpl greeterImpl = new GreeterImpl(); - endpoint = (EndpointImpl)Endpoint.publish(getJaxWsServerAddress(), greeterImpl); + endpoint = (EndpointImpl) Endpoint.publish(getJaxWsServerAddress(), greeterImpl); endpoint.getInInterceptors().add(new LoggingInInterceptor()); endpoint.getOutInterceptors().add(new LoggingOutInterceptor()); } @@ -112,7 +106,6 @@ public class CamelSinkCXFITCase extends AbstractKafkaTest { server.destroy(); } - private void putRecords(String message) { KafkaClient<String, String> kafkaClient = new KafkaClient<>(getKafkaService().getBootstrapServers()); @@ -123,11 +116,12 @@ public class CamelSinkCXFITCase extends AbstractKafkaTest { LOG.error("Unable to produce messages: {}", e.getMessage(), e); } catch (InterruptedException e) { break; - } + } } } - public void runTest(ConnectorPropertyFactory connectorPropertyFactory, String message) throws ExecutionException, InterruptedException, TimeoutException { + public void runTest(ConnectorPropertyFactory connectorPropertyFactory, String message) + throws ExecutionException, InterruptedException, TimeoutException { connectorPropertyFactory.log(); getKafkaConnectService().initializeConnector(connectorPropertyFactory); getKafkaConnectService().initializeConnectorBlocking(connectorPropertyFactory, 1); @@ -136,20 +130,17 @@ public class CamelSinkCXFITCase extends AbstractKafkaTest { service.submit(r); Thread.sleep(5000); LOG.debug("Created the consumer ... About to receive messages"); - + } @Test @Timeout(90) public void testBasicSendReceiveUsingUrl() { try { - ConnectorPropertyFactory connectorPropertyFactory = CamelSinkCXFPropertyFactory.basic() - .withTopics(TestUtils.getDefaultTestTopic(this.getClass())) - .withAddress(getSimpleServerAddress()) - .withServiceClass("org.apache.camel.kafkaconnector.cxf.source.HelloService") - .withDataFormat("RAW"); + .withTopics(TestUtils.getDefaultTestTopic(this.getClass())).withAddress(getSimpleServerAddress()) + .withServiceClass("org.apache.camel.kafkaconnector.cxf.source.HelloService").withDataFormat("RAW"); runTest(connectorPropertyFactory, TEST_MESSAGE); } catch (Exception e) { @@ -162,11 +153,9 @@ public class CamelSinkCXFITCase extends AbstractKafkaTest { @Timeout(90) public void testJaxWsBasicSendReceiveUsingUrl() { try { - ConnectorPropertyFactory connectorPropertyFactory = CamelSinkCXFPropertyFactory.basic() - .withTopics(TestUtils.getDefaultTestTopic(this.getClass())) - .withAddress(this.getJaxwsEndpointUri()) + .withTopics(TestUtils.getDefaultTestTopic(this.getClass())).withAddress(this.getJaxwsEndpointUri()) .withDataFormat("RAW"); runTest(connectorPropertyFactory, JAXWS_TEST_MESSAGE); @@ -175,15 +164,13 @@ public class CamelSinkCXFITCase extends AbstractKafkaTest { fail(e.getMessage(), e); } } - + protected String getSimpleEndpointUri() { - return getSimpleServerAddress() - + "?serviceClass=org.apache.camel.kafkaconnector.cxf.source.HelloService"; + return getSimpleServerAddress() + "?serviceClass=org.apache.camel.kafkaconnector.cxf.source.HelloService"; } protected String getJaxwsEndpointUri() { return getJaxWsServerAddress() + "?serviceClass=org.apache.hello_world_soap_http.Greeter"; } - } \ No newline at end of file diff --git a/tests/itests-cxf/src/test/java/org/apache/camel/kafkaconnector/cxf/sink/CamelSinkCXFPropertyFactory.java b/tests/itests-cxf/src/test/java/org/apache/camel/kafkaconnector/cxf/sink/CamelSinkCXFPropertyFactory.java index e7ed6a7..3e814df 100644 --- a/tests/itests-cxf/src/test/java/org/apache/camel/kafkaconnector/cxf/sink/CamelSinkCXFPropertyFactory.java +++ b/tests/itests-cxf/src/test/java/org/apache/camel/kafkaconnector/cxf/sink/CamelSinkCXFPropertyFactory.java @@ -20,39 +20,33 @@ package org.apache.camel.kafkaconnector.cxf.sink; import org.apache.camel.kafkaconnector.common.EndpointUrlBuilder; import org.apache.camel.kafkaconnector.common.SinkConnectorPropertyFactory; - final class CamelSinkCXFPropertyFactory extends SinkConnectorPropertyFactory<CamelSinkCXFPropertyFactory> { private CamelSinkCXFPropertyFactory() { } - - public EndpointUrlBuilder<CamelSinkCXFPropertyFactory> withUrl(String serviceUrl) { String url = String.format("cxf://%s", serviceUrl); return new EndpointUrlBuilder<>(this::withSinkUrl, url); } - + public CamelSinkCXFPropertyFactory withDataFormat(String dataFormat) { return setProperty("camel.sink.endpoint.dataFormat", dataFormat); } - + public CamelSinkCXFPropertyFactory withAddress(String address) { return setProperty("camel.sink.path.address", address); } - + public CamelSinkCXFPropertyFactory withServiceClass(String serviceClass) { return setProperty("camel.sink.endpoint.serviceClass", serviceClass); } public static CamelSinkCXFPropertyFactory basic() { - return new CamelSinkCXFPropertyFactory() - .withTasksMax(1) - .withName("CamelCXFSinkConnector") + return new CamelSinkCXFPropertyFactory().withTasksMax(1).withName("CamelCXFSinkConnector") .withConnectorClass("org.apache.camel.kafkaconnector.cxf.CamelCxfSinkConnector") .withKeyConverterClass("org.apache.kafka.connect.storage.StringConverter") .withValueConverterClass("org.apache.kafka.connect.storage.StringConverter"); } } - diff --git a/tests/itests-cxf/src/test/java/org/apache/camel/kafkaconnector/cxf/sink/GreeterImpl.java b/tests/itests-cxf/src/test/java/org/apache/camel/kafkaconnector/cxf/sink/GreeterImpl.java index a5b909d..9981604 100644 --- a/tests/itests-cxf/src/test/java/org/apache/camel/kafkaconnector/cxf/sink/GreeterImpl.java +++ b/tests/itests-cxf/src/test/java/org/apache/camel/kafkaconnector/cxf/sink/GreeterImpl.java @@ -19,10 +19,10 @@ package org.apache.camel.kafkaconnector.cxf.sink; import java.util.logging.Logger; - public class GreeterImpl extends org.apache.hello_world_soap_http.GreeterImpl { - + private static final Logger LOG = Logger.getLogger(GreeterImpl.class.getName()); + public String greetMe(String hi) { LOG.info("jaxws greetMe " + hi); return "Greet " + hi; diff --git a/tests/itests-cxf/src/test/java/org/apache/camel/kafkaconnector/cxf/sink/HelloServiceImpl.java b/tests/itests-cxf/src/test/java/org/apache/camel/kafkaconnector/cxf/sink/HelloServiceImpl.java index 42f12f5..88f1f12 100644 --- a/tests/itests-cxf/src/test/java/org/apache/camel/kafkaconnector/cxf/sink/HelloServiceImpl.java +++ b/tests/itests-cxf/src/test/java/org/apache/camel/kafkaconnector/cxf/sink/HelloServiceImpl.java @@ -23,8 +23,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class HelloServiceImpl implements HelloService { + public static int invocationCount; private static final Logger LOG = LoggerFactory.getLogger(HelloServiceImpl.class); - public static int invocationCount = 0; private String name; @@ -57,7 +57,7 @@ public class HelloServiceImpl implements HelloService { @Override public String sayHello() { - + return "hello" + name; } diff --git a/tests/itests-cxf/src/test/java/org/apache/camel/kafkaconnector/cxf/source/CamelSourceCXFITCase.java b/tests/itests-cxf/src/test/java/org/apache/camel/kafkaconnector/cxf/source/CamelSourceCXFITCase.java index 4ddf9e8..719501c 100644 --- a/tests/itests-cxf/src/test/java/org/apache/camel/kafkaconnector/cxf/source/CamelSourceCXFITCase.java +++ b/tests/itests-cxf/src/test/java/org/apache/camel/kafkaconnector/cxf/source/CamelSourceCXFITCase.java @@ -40,32 +40,24 @@ import org.slf4j.LoggerFactory; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.fail; - /** - * A simple test case that checks whether the CXF Consumer Endpoint produces the expected number of - * messages + * A simple test case that checks whether the CXF Consumer Endpoint produces the expected number of messages */ public class CamelSourceCXFITCase extends AbstractKafkaTest { - + protected static final int PORT = NetworkUtils.getFreePort("localhost"); - protected static final String SIMPLE_ENDPOINT_ADDRESS = "http://localhost:" + PORT - + "/CxfConsumerTest/test"; - protected static final String SIMPLE_ENDPOINT_URI = SIMPLE_ENDPOINT_ADDRESS - + "?serviceClass=org.apache.camel.kafkaconnector.cxf.source.HelloService" - + "&publishedEndpointUrl=http://www.simple.com/services/test"; + protected static final String SIMPLE_ENDPOINT_ADDRESS = "http://localhost:" + PORT + "/CxfConsumerTest/test"; + protected static final String SIMPLE_ENDPOINT_URI = SIMPLE_ENDPOINT_ADDRESS + + "?serviceClass=org.apache.camel.kafkaconnector.cxf.source.HelloService" + + "&publishedEndpointUrl=http://www.simple.com/services/test"; - private static final String TEST_MESSAGE = "Hello World!"; - - private static final Logger LOG = LoggerFactory.getLogger(CamelSourceCXFITCase.class); private int received; private final int expect = 1; - - @Override protected String[] getConnectorsInTest() { return new String[] {"camel-cxf-kafka-connector"}; @@ -74,12 +66,12 @@ public class CamelSourceCXFITCase extends AbstractKafkaTest { @BeforeEach public void setUp() { received = 0; - + } private <T> boolean checkRecord(ConsumerRecord<String, T> record) { LOG.debug("Received: {}", record.value()); - + received++; if (received == expect) { @@ -89,12 +81,13 @@ public class CamelSourceCXFITCase extends AbstractKafkaTest { return true; } - - - public void runBasicStringTest(ConnectorPropertyFactory connectorPropertyFactory) throws ExecutionException, InterruptedException { + public void runBasicStringTest(ConnectorPropertyFactory connectorPropertyFactory) + throws ExecutionException, InterruptedException { connectorPropertyFactory.log(); getKafkaConnectService().initializeConnector(connectorPropertyFactory); - Thread.sleep(5000);//ensure cxf source connector is up + + // ensure cxf source connector is up + Thread.sleep(5000); ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean(); ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean(); clientBean.setAddress(SIMPLE_ENDPOINT_ADDRESS); @@ -110,8 +103,7 @@ public class CamelSourceCXFITCase extends AbstractKafkaTest { } catch (Exception e) { LOG.info("Test Invocation Failure", e); } - - + LOG.debug("Creating the consumer ..."); KafkaClient<String, String> kafkaClient = new KafkaClient<>(getKafkaService().getBootstrapServers()); kafkaClient.consume(TestUtils.getDefaultTestTopic(this.getClass()), this::checkRecord); @@ -120,18 +112,13 @@ public class CamelSourceCXFITCase extends AbstractKafkaTest { assertEquals(received, expect, "Didn't process the expected amount of messages"); } - - @Test @Timeout(20) public void testBasicSendReceive() { try { - ConnectorPropertyFactory connectorPropertyFactory = CamelSourceCXFPropertyFactory - .basic() - .withKafkaTopic(TestUtils.getDefaultTestTopic(this.getClass())) - .withAddress(SIMPLE_ENDPOINT_ADDRESS) + ConnectorPropertyFactory connectorPropertyFactory = CamelSourceCXFPropertyFactory.basic() + .withKafkaTopic(TestUtils.getDefaultTestTopic(this.getClass())).withAddress(SIMPLE_ENDPOINT_ADDRESS) .withServiceClass("org.apache.camel.kafkaconnector.cxf.source.HelloService"); - runBasicStringTest(connectorPropertyFactory); } catch (Exception e) { @@ -139,16 +126,14 @@ public class CamelSourceCXFITCase extends AbstractKafkaTest { fail(e.getMessage()); } } - + @Test @Timeout(20) public void testBasicSendReceiveUsingUrl() { try { - ConnectorPropertyFactory connectorPropertyFactory = CamelSourceCXFPropertyFactory - .basic() - .withKafkaTopic(TestUtils.getDefaultTestTopic(this.getClass())) - .withUrl(SIMPLE_ENDPOINT_URI).buildUrl(); - + ConnectorPropertyFactory connectorPropertyFactory = CamelSourceCXFPropertyFactory.basic() + .withKafkaTopic(TestUtils.getDefaultTestTopic(this.getClass())).withUrl(SIMPLE_ENDPOINT_URI) + .buildUrl(); runBasicStringTest(connectorPropertyFactory); } catch (Exception e) { @@ -157,18 +142,13 @@ public class CamelSourceCXFITCase extends AbstractKafkaTest { } } - @Test @Timeout(20) public void testBasicSendReceiveUsingDataFormat() { try { - ConnectorPropertyFactory connectorPropertyFactory = CamelSourceCXFPropertyFactory - .basic() - .withKafkaTopic(TestUtils.getDefaultTestTopic(this.getClass())) - .withAddress(SIMPLE_ENDPOINT_ADDRESS) - .withServiceClass("org.apache.camel.kafkaconnector.cxf.source.HelloService") - .withDataFormat("POJO"); - + ConnectorPropertyFactory connectorPropertyFactory = CamelSourceCXFPropertyFactory.basic() + .withKafkaTopic(TestUtils.getDefaultTestTopic(this.getClass())).withAddress(SIMPLE_ENDPOINT_ADDRESS) + .withServiceClass("org.apache.camel.kafkaconnector.cxf.source.HelloService").withDataFormat("POJO"); runBasicStringTest(connectorPropertyFactory); } catch (Exception e) { @@ -177,5 +157,4 @@ public class CamelSourceCXFITCase extends AbstractKafkaTest { } } - } diff --git a/tests/itests-cxf/src/test/java/org/apache/camel/kafkaconnector/cxf/source/CamelSourceCXFPropertyFactory.java b/tests/itests-cxf/src/test/java/org/apache/camel/kafkaconnector/cxf/source/CamelSourceCXFPropertyFactory.java index 7d054e5..e385b73 100644 --- a/tests/itests-cxf/src/test/java/org/apache/camel/kafkaconnector/cxf/source/CamelSourceCXFPropertyFactory.java +++ b/tests/itests-cxf/src/test/java/org/apache/camel/kafkaconnector/cxf/source/CamelSourceCXFPropertyFactory.java @@ -17,11 +17,9 @@ package org.apache.camel.kafkaconnector.cxf.source; - import org.apache.camel.kafkaconnector.common.EndpointUrlBuilder; import org.apache.camel.kafkaconnector.common.SourceConnectorPropertyFactory; - /** * Creates the set of properties used by a Camel CXF Source Connector */ @@ -33,23 +31,21 @@ final class CamelSourceCXFPropertyFactory extends SourceConnectorPropertyFactory public CamelSourceCXFPropertyFactory withAddress(String address) { return setProperty("camel.source.path.address", address); } - + public CamelSourceCXFPropertyFactory withServiceClass(String serviceClass) { return setProperty("camel.source.endpoint.serviceClass", serviceClass); } - + public CamelSourceCXFPropertyFactory withPublishedEndpointUrl(String publishedEndpointUrl) { return setProperty("camel.source.endpoint.publishedEndpointUrl", publishedEndpointUrl); } - + public CamelSourceCXFPropertyFactory withDataFormat(String dataFormat) { return setProperty("camel.source.endpoint.dataFormat", dataFormat); } - + public static CamelSourceCXFPropertyFactory basic() { - return new CamelSourceCXFPropertyFactory() - .withName("CamelCXFSourceConnector") - .withTasksMax(1) + return new CamelSourceCXFPropertyFactory().withName("CamelCXFSourceConnector").withTasksMax(1) .withConnectorClass("org.apache.camel.kafkaconnector.cxf.CamelCxfSourceConnector") .withKeyConverterClass("org.apache.kafka.connect.storage.StringConverter") .withValueConverterClass("org.apache.kafka.connect.storage.StringConverter"); @@ -60,5 +56,4 @@ final class CamelSourceCXFPropertyFactory extends SourceConnectorPropertyFactory return new EndpointUrlBuilder<>(this::withSourceUrl, url); } - }