You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ol...@apache.org on 2022/09/08 05:55:26 UTC
[sling-org-apache-sling-commons-clam] branch master updated: SLING-11477 Update Testing PaxExam to 4.0.0
This is an automated email from the ASF dual-hosted git repository.
olli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-clam.git
The following commit(s) were added to refs/heads/master by this push:
new 78f2828 SLING-11477 Update Testing PaxExam to 4.0.0
78f2828 is described below
commit 78f2828f0220d502aea603507249ebcaa7e21d37
Author: Oliver Lietz <ol...@apache.org>
AuthorDate: Thu Sep 8 07:54:55 2022 +0200
SLING-11477 Update Testing PaxExam to 4.0.0
* use Testing PaxExam 4.0.0-SNAPSHOT
* update test dependencies
* use Hamcrest's assertThat
---
pom.xml | 8 ++++----
.../commons/clam/it/tests/ClamTestSupport.java | 17 +---------------
.../commons/clam/it/tests/ClamdServiceIT.java | 23 +++++++++++-----------
3 files changed, 17 insertions(+), 31 deletions(-)
diff --git a/pom.xml b/pom.xml
index b8e5b85..5b6b7c7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -199,7 +199,7 @@
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.framework</artifactId>
- <version>7.0.1</version>
+ <version>7.0.5</version>
<scope>test</scope>
</dependency>
<!-- Apache Sling -->
@@ -212,7 +212,7 @@
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.testing.paxexam</artifactId>
- <version>3.1.0</version>
+ <version>4.0.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<!-- nullability -->
@@ -277,13 +277,13 @@
<dependency>
<groupId>org.ops4j.pax.url</groupId>
<artifactId>pax-url-wrap</artifactId>
- <version>2.6.7</version>
+ <version>2.6.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
- <version>1.16.1</version>
+ <version>1.17.3</version>
<scope>test</scope>
</dependency>
</dependencies>
diff --git a/src/test/java/org/apache/sling/commons/clam/it/tests/ClamTestSupport.java b/src/test/java/org/apache/sling/commons/clam/it/tests/ClamTestSupport.java
index 8a6cff0..b112ea1 100644
--- a/src/test/java/org/apache/sling/commons/clam/it/tests/ClamTestSupport.java
+++ b/src/test/java/org/apache/sling/commons/clam/it/tests/ClamTestSupport.java
@@ -22,23 +22,17 @@ import java.io.IOException;
import java.io.InputStream;
import java.time.Duration;
import java.util.Arrays;
-import java.util.Objects;
import org.apache.sling.testing.paxexam.TestSupport;
import org.jetbrains.annotations.NotNull;
import org.ops4j.pax.exam.Configuration;
import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.options.OptionalCompositeOption;
-import org.ops4j.pax.exam.options.extra.VMOption;
import org.testcontainers.containers.GenericContainer;
import static org.apache.sling.testing.paxexam.SlingOptions.scr;
import static org.apache.sling.testing.paxexam.SlingOptions.testcontainers;
-import static org.ops4j.pax.exam.CoreOptions.junitBundles;
import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
import static org.ops4j.pax.exam.CoreOptions.options;
-import static org.ops4j.pax.exam.CoreOptions.vmOption;
-import static org.ops4j.pax.exam.CoreOptions.when;
import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.newConfiguration;
public abstract class ClamTestSupport extends TestSupport {
@@ -75,19 +69,10 @@ public abstract class ClamTestSupport extends TestSupport {
mavenBundle().groupId("org.apache.sling").artifactId("org.apache.sling.commons.content.analyzing").versionAsInProject(),
scr(),
// testing
- testcontainers(),
- junitBundles(),
- jacoco() // remove with Testing PaxExam 4.0
+ testcontainers()
);
}
- // remove with Testing PaxExam 4.0
- protected OptionalCompositeOption jacoco() {
- final String jacocoCommand = System.getProperty("jacoco.command");
- final VMOption option = Objects.nonNull(jacocoCommand) && !jacocoCommand.trim().isEmpty() ? vmOption(jacocoCommand) : null;
- return when(Objects.nonNull(option)).useOptions(option);
- }
-
protected static class InfiniteInputStream extends InputStream {
@Override
diff --git a/src/test/java/org/apache/sling/commons/clam/it/tests/ClamdServiceIT.java b/src/test/java/org/apache/sling/commons/clam/it/tests/ClamdServiceIT.java
index d3204ed..d564553 100644
--- a/src/test/java/org/apache/sling/commons/clam/it/tests/ClamdServiceIT.java
+++ b/src/test/java/org/apache/sling/commons/clam/it/tests/ClamdServiceIT.java
@@ -42,8 +42,9 @@ import org.ops4j.pax.exam.spi.reactors.PerClass;
import org.ops4j.pax.exam.util.Filter;
import org.ops4j.pax.exam.util.PathUtils;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
@RunWith(PaxExam.class)
@ExamReactorStrategy(PerClass.class)
@@ -68,7 +69,7 @@ public class ClamdServiceIT extends ClamTestSupport {
@Test
public void testClamService() {
- assertNotNull(clamService);
+ assertThat(clamService, notNullValue());
}
@Test
@@ -76,7 +77,7 @@ public class ClamdServiceIT extends ClamTestSupport {
final String data = "ok – no malware here";
try (final InputStream inputStream = IOUtils.toInputStream(data, StandardCharsets.UTF_8)) {
final ScanResult result = clamService.scan(inputStream);
- assertEquals(ScanResult.Status.OK, result.getStatus());
+ assertThat(result.getStatus(), is(ScanResult.Status.OK));
}
}
@@ -85,7 +86,7 @@ public class ClamdServiceIT extends ClamTestSupport {
final byte[] eicarcom2_zip = readEicarFile();
try (final InputStream fileInputStream = new ByteArrayInputStream(eicarcom2_zip)) {
final ScanResult result = clamService.scan(fileInputStream);
- assertEquals(ScanResult.Status.FOUND, result.getStatus());
+ assertThat(result.getStatus(), is(ScanResult.Status.FOUND));
}
}
@@ -93,8 +94,8 @@ public class ClamdServiceIT extends ClamTestSupport {
public void testScan_infiniteStream() throws Exception {
try (final InputStream inputStream = new InfiniteInputStream()) {
final ScanResult result = clamService.scan(inputStream);
- assertEquals(ScanResult.Status.ERROR, result.getStatus());
- assertEquals(INSTREAM_SIZE_LIMIT_EXCEEDED_ERROR_MESSAGE, result.getMessage());
+ assertThat(result.getStatus(), is(ScanResult.Status.ERROR));
+ assertThat(result.getMessage(), is(INSTREAM_SIZE_LIMIT_EXCEEDED_ERROR_MESSAGE));
}
}
@@ -102,7 +103,7 @@ public class ClamdServiceIT extends ClamTestSupport {
@Test
public void testContentAnalyzer() {
- assertNotNull(contentAnalyzer);
+ assertThat(contentAnalyzer, notNullValue());
}
@Test
@@ -111,7 +112,7 @@ public class ClamdServiceIT extends ClamTestSupport {
final Map<String, Object> report = new HashMap<>();
try (final InputStream inputStream = IOUtils.toInputStream(data, StandardCharsets.UTF_8)) {
contentAnalyzer.analyze(inputStream, null, report).get();
- assertEquals(ScanResult.Status.OK, report.get("sling.commons.clam.scanresult.status"));
+ assertThat(report.get("sling.commons.clam.scanresult.status"), is(ScanResult.Status.OK));
}
}
@@ -121,7 +122,7 @@ public class ClamdServiceIT extends ClamTestSupport {
final Map<String, Object> report = new HashMap<>();
try (final InputStream inputStream = new ByteArrayInputStream(eicarcom2_zip)) {
contentAnalyzer.analyze(inputStream, null, report).get();
- assertEquals(ScanResult.Status.FOUND, report.get("sling.commons.clam.scanresult.status"));
+ assertThat(report.get("sling.commons.clam.scanresult.status"), is(ScanResult.Status.FOUND));
}
}
@@ -130,7 +131,7 @@ public class ClamdServiceIT extends ClamTestSupport {
final Map<String, Object> report = new HashMap<>();
try (final InputStream inputStream = new InfiniteInputStream()) {
contentAnalyzer.analyze(inputStream, null, report).get();
- assertEquals(INSTREAM_SIZE_LIMIT_EXCEEDED_ERROR_MESSAGE, report.get("sling.commons.clam.scanresult.message"));
+ assertThat(report.get("sling.commons.clam.scanresult.message"), is(INSTREAM_SIZE_LIMIT_EXCEEDED_ERROR_MESSAGE));
}
}