Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable check style for streampipes-integration-tests #814

Merged
merged 1 commit into from
Nov 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 25 additions & 24 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1563,7 +1563,30 @@ IoT data streams.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${maven-checkstyle-plugin.version}</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>9.2.1</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>validate</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration>
<suppressionsLocation>tools/maven/suppressions.xml</suppressionsLocation>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
<configLocation>tools/maven/checkstyle.xml</configLocation>
<encoding>UTF-8</encoding>
<logViolationsToConsole>false</logViolationsToConsole>
<failOnViolation>false</failOnViolation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -1783,29 +1806,7 @@ IoT data streams.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>9.2.1</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>validate</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration>
<suppressionsLocation>/tools/maven/suppressions.xml</suppressionsLocation>
<includeTestSourceDirectory>false</includeTestSourceDirectory>
<configLocation>/tools/maven/checkstyle.xml</configLocation>
<logViolationsToConsole>false</logViolationsToConsole>
<failOnViolation>false</failOnViolation>
</configuration>
<version>${maven-checkstyle-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
123 changes: 73 additions & 50 deletions streampipes-integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,59 +22,82 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>streampipes-parent</artifactId>
<groupId>org.apache.streampipes</groupId>
<version>0.71.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>streampipes-parent</artifactId>
<groupId>org.apache.streampipes</groupId>
<version>0.71.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>integration</artifactId>
<name>StreamPipes Integration Tests</name>
<artifactId>integration</artifactId>
<name>StreamPipes Integration Tests</name>

<properties>
<owasp.check.skip>true</owasp.check.skip>
<maven.deploy.skip>false</maven.deploy.skip>
<properties>
<owasp.check.skip>true</owasp.check.skip>
<maven.deploy.skip>false</maven.deploy.skip>

<pulsar.version>2.10.1</pulsar.version>
</properties>
<pulsar.version>2.10.1</pulsar.version>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.streampipes</groupId>
<artifactId>streampipes-connect</artifactId>
<version>0.71.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.streampipes</groupId>
<artifactId>streampipes-container</artifactId>
<version>0.71.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.pulsar</groupId>
<artifactId>pulsar-client</artifactId>
<version>${pulsar.version}</version>
</dependency>
<dependency>
<groupId>org.apache.streampipes</groupId>
<artifactId>streampipes-connect-adapters-iiot</artifactId>
<version>0.71.0-SNAPSHOT</version>
<classifier>embed</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>1.17.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<executions>
<execution>
<id>validate</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration>
<logViolationsToConsole>true</logViolationsToConsole>
<failOnViolation>true</failOnViolation>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>org.apache.streampipes</groupId>
<artifactId>streampipes-connect</artifactId>
<version>0.71.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.streampipes</groupId>
<artifactId>streampipes-container</artifactId>
<version>0.71.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.pulsar</groupId>
<artifactId>pulsar-client</artifactId>
<version>${pulsar.version}</version>
</dependency>
<dependency>
<groupId>org.apache.streampipes</groupId>
<artifactId>streampipes-connect-adapters-iiot</artifactId>
<version>0.71.0-SNAPSHOT</version>
<classifier>embed</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>1.17.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
*/
package org.apache.streampipes.integration.adapters;

import java.util.List;
import java.util.Map;
import org.apache.streampipes.connect.adapter.Adapter;
import org.apache.streampipes.connect.adapter.preprocessing.elements.DebugAdapterSink;
import org.apache.streampipes.connect.api.exception.AdapterException;
Expand All @@ -27,33 +25,36 @@
import org.apache.streampipes.container.init.DeclarersSingleton;
import org.apache.streampipes.model.connect.adapter.AdapterDescription;

import java.util.List;
import java.util.Map;

public abstract class AdapterTesterBase implements AutoCloseable {
Adapter adapter;

public Adapter startAdapter(AdapterDescription adapterDescription) throws AdapterException {
DeclarersSingleton.getInstance().add(new PulsarProtocol());
Adapter adapter = (Adapter) AdapterUtils.setAdapter(adapterDescription);
adapter.startAdapter();
this.adapter = adapter;
return adapter;
}
Adapter adapter;

public abstract void startAdapterService() throws Exception;
public Adapter startAdapter(AdapterDescription adapterDescription) throws AdapterException {
DeclarersSingleton.getInstance().add(new PulsarProtocol());
Adapter adapter = (Adapter) AdapterUtils.setAdapter(adapterDescription);
adapter.startAdapter();
this.adapter = adapter;
return adapter;
}

public abstract AdapterDescription prepareAdapter() throws Exception;
public abstract void startAdapterService() throws Exception;

public abstract List<Map<String, Object>> generateData() throws Exception;
public abstract AdapterDescription prepareAdapter() throws Exception;

public abstract void validateData(List<Map<String, Object>> data) throws Exception;
public abstract List<Map<String, Object>> generateData() throws Exception;

public Map<String, Object> takeEvent() throws InterruptedException {
return ((DebugAdapterSink) adapter.getAdapterPipeline().getPipelineSink()).takeEvent();
}
public abstract void validateData(List<Map<String, Object>> data) throws Exception;

public Map<String, Object> takeEvent() throws InterruptedException {
return ((DebugAdapterSink) adapter.getAdapterPipeline().getPipelineSink()).takeEvent();
}

public void stopAdapter() throws AdapterException {
if (adapter != null) {
adapter.stopAdapter();
}
public void stopAdapter() throws AdapterException {
if (adapter != null) {
adapter.stopAdapter();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,26 @@
*/
package org.apache.streampipes.integration.adapters;

import java.util.List;
import java.util.Map;
import org.apache.streampipes.model.connect.adapter.AdapterDescription;

import org.junit.Test;

import java.util.List;
import java.util.Map;

public class AdaptersTest {
public void testAdapter(AdapterTesterBase adapterTester) throws Exception {
adapterTester.startAdapterService();
AdapterDescription adapterDescription = adapterTester.prepareAdapter();
adapterTester.startAdapter(adapterDescription);
List<Map<String, Object>> data = adapterTester.generateData();
adapterTester.validateData(data);
}
public void testAdapter(AdapterTesterBase adapterTester) throws Exception {
adapterTester.startAdapterService();
AdapterDescription adapterDescription = adapterTester.prepareAdapter();
adapterTester.startAdapter(adapterDescription);
List<Map<String, Object>> data = adapterTester.generateData();
adapterTester.validateData(data);
}

@Test
public void testPulsarAdapter() throws Exception {
try (PulsarAdapterTester pulsarAdapterTester = new PulsarAdapterTester()) {
testAdapter(pulsarAdapterTester);
}
@Test
public void testPulsarAdapter() throws Exception {
try (PulsarAdapterTester pulsarAdapterTester = new PulsarAdapterTester()) {
testAdapter(pulsarAdapterTester);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
*/
package org.apache.streampipes.integration.adapters;

import com.google.common.collect.Maps;
import org.apache.pulsar.client.api.Producer;
import org.apache.pulsar.client.api.PulsarClient;
import org.apache.streampipes.connect.adapter.format.json.object.JsonObjectFormat;
import org.apache.streampipes.connect.api.exception.AdapterException;
import org.apache.streampipes.connect.iiot.protocol.stream.pulsar.PulsarProtocol;
Expand All @@ -30,6 +27,10 @@
import org.apache.streampipes.sdk.builder.adapter.GenericDataStreamAdapterBuilder;
import org.apache.streampipes.sdk.builder.adapter.ProtocolDescriptionBuilder;
import org.apache.streampipes.sdk.helpers.Labels;

import com.google.common.collect.Maps;
import org.apache.pulsar.client.api.Producer;
import org.apache.pulsar.client.api.PulsarClient;
import org.junit.Assert;
import org.testcontainers.shaded.com.fasterxml.jackson.databind.ObjectMapper;

Expand All @@ -41,7 +42,7 @@

public class PulsarAdapterTester extends AdapterTesterBase {
PulsarContainer pulsarContainer;
private final static String TOPIC = "test-topic";
private static final String TOPIC = "test-topic";

@Override
public void startAdapterService() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
*/
package org.apache.streampipes.integration.containers;

import static java.time.temporal.ChronoUnit.SECONDS;
import java.time.Duration;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.wait.strategy.HttpWaitStrategy;

import java.time.Duration;

import static java.time.temporal.ChronoUnit.SECONDS;

public class PulsarContainer extends GenericContainer<PulsarContainer> {
private static final int BROKER_HTTP_PORT = 8080;
private static final int BROKER_SERVICE_PORT = 6650;
Expand All @@ -32,10 +34,10 @@ public PulsarContainer() {

public void start() {
this.waitStrategy = new HttpWaitStrategy()
.forPort(BROKER_HTTP_PORT)
.forStatusCode(200)
.forPath("/admin/v2/namespaces/public/default")
.withStartupTimeout(Duration.of(300, SECONDS));
.forPort(BROKER_HTTP_PORT)
.forStatusCode(200)
.forPath("/admin/v2/namespaces/public/default")
.withStartupTimeout(Duration.of(300, SECONDS));
this.withExposedPorts(BROKER_SERVICE_PORT, BROKER_HTTP_PORT);
this.withCreateContainerCmdModifier(createContainerCmd -> {
createContainerCmd.withEntrypoint("bin/pulsar");
Expand Down
5 changes: 3 additions & 2 deletions tools/maven/checkstyle-header.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
*
*/
9 changes: 8 additions & 1 deletion tools/maven/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,13 @@ page at http://checkstyle.sourceforge.net/config.html -->
<property name="severity" value="error"/>
</module>


<module name="Indentation">
<property name="basicOffset" value="2"/>
<property name="braceAdjustment" value="2"/>
<property name="caseIndent" value="2"/>
<property name="throwsIndent" value="4"/>
<property name="lineWrappingIndentation" value="4"/>
<property name="arrayInitIndent" value="2"/>
</module>
</module>
</module>