You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ja...@apache.org on 2022/01/04 17:54:07 UTC

[camel-quarkus] branch main updated: Fix timestamp validation in syslog integration tests

This is an automated email from the ASF dual-hosted git repository.

jamesnetherton pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git


The following commit(s) were added to refs/heads/main by this push:
     new b660cc6  Fix timestamp validation in syslog integration tests
b660cc6 is described below

commit b660cc65fa331d3afa990d737a9e63e6cfdbd16c
Author: James Netherton <ja...@gmail.com>
AuthorDate: Tue Jan 4 14:46:59 2022 +0000

    Fix timestamp validation in syslog integration tests
---
 .../quarkus/component/syslog/it/SyslogTest.java     | 21 ++++++++++++---------
 .../syslog/src/test/resources/rfc3164.txt           |  1 -
 .../syslog/src/test/resources/rfc5425.txt           |  1 -
 3 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/integration-tests/syslog/src/test/java/org/apache/camel/quarkus/component/syslog/it/SyslogTest.java b/integration-tests/syslog/src/test/java/org/apache/camel/quarkus/component/syslog/it/SyslogTest.java
index 858a899..ec1c0ac 100644
--- a/integration-tests/syslog/src/test/java/org/apache/camel/quarkus/component/syslog/it/SyslogTest.java
+++ b/integration-tests/syslog/src/test/java/org/apache/camel/quarkus/component/syslog/it/SyslogTest.java
@@ -16,14 +16,14 @@
  */
 package org.apache.camel.quarkus.component.syslog.it;
 
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
+import java.time.Year;
+import java.util.HashMap;
 import java.util.Locale;
+import java.util.Map;
 
 import io.quarkus.test.common.QuarkusTestResource;
 import io.quarkus.test.junit.QuarkusTest;
 import io.restassured.RestAssured;
-import org.apache.commons.io.IOUtils;
 import org.junit.jupiter.params.ParameterizedTest;
 import org.junit.jupiter.params.provider.ValueSource;
 
@@ -35,10 +35,17 @@ import static org.hamcrest.Matchers.startsWith;
 @QuarkusTestResource(SyslogTestResource.class)
 class SyslogTest {
 
+    private static final Map<String, String> SYSLOG_MESSAGES = new HashMap<>() {
+        {
+            put("rfc3164", "<1>Feb  2 10:11:12 localhost Test SysLog RFC3164 Message");
+            put("rfc5425", "<1>1 " + Year.now() + "-02-02T10:11:12Z localhost test - ID01 - Test SysLog RFC5425 Message");
+        }
+    };
+
     @ParameterizedTest
     @ValueSource(strings = { "rfc3164", "rfc5425" })
     public void syslogDataFormat(String rfcVersion) throws Exception {
-        final String message = readSyslogMessage(rfcVersion);
+        final String message = SYSLOG_MESSAGES.get(rfcVersion);
 
         // Send message
         RestAssured.given()
@@ -55,7 +62,7 @@ class SyslogTest {
                 .body(
                         "hostname", equalTo("localhost"),
                         "logMessage", equalTo("Test SysLog " + rfcVersion.toUpperCase(Locale.US) + " Message"),
-                        "timestamp", startsWith("2021-02-02T10:11:12"));
+                        "timestamp", startsWith(Year.now() + "-02-02T10:11:12"));
 
         // Get the raw SyslogMessage marshalled message
         RestAssured.get("/syslog/messages/raw")
@@ -63,8 +70,4 @@ class SyslogTest {
                 .statusCode(200)
                 .body(is(message));
     }
-
-    private String readSyslogMessage(String rfcVersion) throws IOException {
-        return IOUtils.toString(SyslogTest.class.getResourceAsStream("/" + rfcVersion + ".txt"), StandardCharsets.UTF_8);
-    }
 }
diff --git a/integration-tests/syslog/src/test/resources/rfc3164.txt b/integration-tests/syslog/src/test/resources/rfc3164.txt
deleted file mode 100644
index b4875ae..0000000
--- a/integration-tests/syslog/src/test/resources/rfc3164.txt
+++ /dev/null
@@ -1 +0,0 @@
-<1>Feb  2 10:11:12 localhost Test SysLog RFC3164 Message
\ No newline at end of file
diff --git a/integration-tests/syslog/src/test/resources/rfc5425.txt b/integration-tests/syslog/src/test/resources/rfc5425.txt
deleted file mode 100644
index c3d1863..0000000
--- a/integration-tests/syslog/src/test/resources/rfc5425.txt
+++ /dev/null
@@ -1 +0,0 @@
-<1>1 2021-02-02T10:11:12Z localhost test - ID01 - Test SysLog RFC5425 Message
\ No newline at end of file