diff --git a/eclipse-java-formatter.xml b/eclipse-java-formatter.xml
new file mode 100644
index 0000000..53b9f2a
--- /dev/null
+++ b/eclipse-java-formatter.xml
@@ -0,0 +1,450 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/license-header b/license-header
new file mode 100644
index 0000000..c2a2989
--- /dev/null
+++ b/license-header
@@ -0,0 +1,45 @@
+/*
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ *
+ *
+ * Additional permission under GNU Affero General Public License version 3
+ * section 7
+ *
+ * If you modify this Program, or any covered work, by linking or combining it
+ * with other code, such other code is not for that reason alone subject to any
+ * of the requirements of the GNU Affero GPL version 3 as long as this Program
+ * is the same Program as licensed from Suomen Kanuuna Oy without any additional
+ * modifications.
+ *
+ * Supplemented terms under GNU Affero General Public License version 3
+ * section 7
+ *
+ * Origin of the software must be attributed to Suomen Kanuuna Oy. Any modified
+ * versions must be marked as "Modified version of" The Program.
+ *
+ * Names of the licensors and authors may not be used for publicity purposes.
+ *
+ * No rights are granted for use of trade names, trademarks, or service marks
+ * which are in The Program if any.
+ *
+ * Licensee must indemnify licensors and authors for any liability that these
+ * contractual assumptions impose on licensors and authors.
+ *
+ * To the extent this program is licensed as part of the Commercial versions of
+ * Teragrep, the applicable Commercial License may apply to this file if you as
+ * a licensee so wish it.
+ */
diff --git a/pom.xml b/pom.xml
index f271460..0d59675 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,30 +1,13 @@
-
- jar
+
4.0.0
+ com.teragrep
rlo_06
${revision}${sha1}${changelist}
+ jar
rlo_06
Syslog (RFC 5424) library for Java
- com.teragrep
https://teragrep.com
-
- UTF-8
- 1.8
- 1.8
- 1.8
- 0.0.1
- -SNAPSHOT
-
- 5.7.1
- localhost
- http://localhost
- releases
- releases
- http://localhost/repository/releases/
-
GNU Affero General Public License v3.0
@@ -44,6 +27,27 @@
scm:git:git@github.com:teragrep/rlo_06.git
https://github.com/teragrep/rlo_06/tree/master
+
+
+ ${repository.id}
+ ${repository.url}
+
+
+
+ -SNAPSHOT
+ 1.8
+ 5.7.1
+ 1.8
+ 1.8
+ UTF-8
+ http://localhost
+ localhost
+ releases
+ releases
+ http://localhost/repository/releases/
+ 0.0.1
+
+
@@ -87,18 +91,63 @@
rlo_06
- org.apache.rat
- apache-rat-plugin
- 0.15
- false
+ com.diffplug.spotless
+ spotless-maven-plugin
+ 2.30.0
+
+
+
+ ${project.basedir}/eclipse-java-formatter.xml
+ 4.10.0
+
+
+
+ ${project.basedir}/license-header
+
+
+
+
+
+ UTF-8
+ \n
+ true
+ false
+ 2
+ recommended_2008_06
+ true
+ true
+ true
+
+
+
+
+
+ .gitattributes
+ .gitignore
+
+
+
+
+ true
+ 4
+
+
+
+
- test
check
+ compile
+
+
+ org.apache.rat
+ apache-rat-plugin
+ 0.15
+ false
false
@@ -128,6 +177,14 @@
README.adoc
+
+
+
+ check
+
+ test
+
+
org.apache.maven.plugins
@@ -168,18 +225,18 @@
- flatten
- process-resources
+ flatten.clean
- flatten
+ clean
+ clean
- flatten.clean
- clean
+ flatten
- clean
+ flatten
+ process-resources
@@ -225,6 +282,17 @@
publish-maven-central
+
+
+ ossrh
+ Central Repository OSSRH
+ https://oss.sonatype.org/service/local/staging/deploy/maven2/
+
+
+ ossrh
+ https://oss.sonatype.org/content/repositories/snapshots
+
+
@@ -234,10 +302,10 @@
sign-artifacts
- verify
sign
+ verify
--pinentry-mode
@@ -249,20 +317,16 @@
+
+
+ publish-github-packages
-
- ossrh
- https://oss.sonatype.org/content/repositories/snapshots
-
- ossrh
- Central Repository OSSRH
- https://oss.sonatype.org/service/local/staging/deploy/maven2/
+ github
+ GitHub Packages
+ https://maven.pkg.github.com/teragrep/rlo_06
-
-
- publish-github-packages
@@ -272,10 +336,10 @@
sign-artifacts
- verify
sign
+ verify
--pinentry-mode
@@ -287,19 +351,6 @@
-
-
- github
- GitHub Packages
- https://maven.pkg.github.com/teragrep/rlo_06
-
-
-
-
- ${repository.id}
- ${repository.url}
-
-
diff --git a/src/main/java/com/teragrep/rlo_06/AppNameFunction.java b/src/main/java/com/teragrep/rlo_06/AppNameFunction.java
index cabbcda..ed39aff 100644
--- a/src/main/java/com/teragrep/rlo_06/AppNameFunction.java
+++ b/src/main/java/com/teragrep/rlo_06/AppNameFunction.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -53,13 +53,12 @@ public final class AppNameFunction implements BiFunction1 2014-06-20T09:14:07.12345+00:00 host01 systemd DEA MSG-01 [ID_A@1 u="3" e="t"][ID_B@2 n="9"] sigsegv\n
-
+
Actions: _______O
Payload:'systemd '
States : .......T
*/
-
@Override
public ByteBuffer apply(Stream stream, ByteBuffer buffer) {
diff --git a/src/main/java/com/teragrep/rlo_06/AppNameParseException.java b/src/main/java/com/teragrep/rlo_06/AppNameParseException.java
index 4bf3113..00084d3 100644
--- a/src/main/java/com/teragrep/rlo_06/AppNameParseException.java
+++ b/src/main/java/com/teragrep/rlo_06/AppNameParseException.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -46,6 +46,7 @@
package com.teragrep.rlo_06;
class AppNameParseException extends ParseException {
+
public AppNameParseException(String message, Throwable cause) {
super(message, cause);
}
@@ -58,4 +59,3 @@ public AppNameParseException(Throwable cause) {
super(cause);
}
}
-
diff --git a/src/main/java/com/teragrep/rlo_06/Byteable.java b/src/main/java/com/teragrep/rlo_06/Byteable.java
index a8207b6..e27616b 100644
--- a/src/main/java/com/teragrep/rlo_06/Byteable.java
+++ b/src/main/java/com/teragrep/rlo_06/Byteable.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
diff --git a/src/main/java/com/teragrep/rlo_06/Cache.java b/src/main/java/com/teragrep/rlo_06/Cache.java
index 24912ce..d65965d 100644
--- a/src/main/java/com/teragrep/rlo_06/Cache.java
+++ b/src/main/java/com/teragrep/rlo_06/Cache.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -46,6 +46,8 @@
package com.teragrep.rlo_06;
interface Cache {
+
T take();
+
void put(T t);
}
diff --git a/src/main/java/com/teragrep/rlo_06/Clearable.java b/src/main/java/com/teragrep/rlo_06/Clearable.java
index 7bfb0dc..0c1e559 100644
--- a/src/main/java/com/teragrep/rlo_06/Clearable.java
+++ b/src/main/java/com/teragrep/rlo_06/Clearable.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -46,5 +46,6 @@
package com.teragrep.rlo_06;
interface Clearable {
+
void clear();
}
diff --git a/src/main/java/com/teragrep/rlo_06/Fragment.java b/src/main/java/com/teragrep/rlo_06/Fragment.java
index 17c3cd6..641a489 100644
--- a/src/main/java/com/teragrep/rlo_06/Fragment.java
+++ b/src/main/java/com/teragrep/rlo_06/Fragment.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -47,7 +47,6 @@
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
-import java.time.ZonedDateTime;
import java.util.function.BiFunction;
import java.util.function.Consumer;
diff --git a/src/main/java/com/teragrep/rlo_06/FragmentState.java b/src/main/java/com/teragrep/rlo_06/FragmentState.java
index 88aed8f..4845a8a 100644
--- a/src/main/java/com/teragrep/rlo_06/FragmentState.java
+++ b/src/main/java/com/teragrep/rlo_06/FragmentState.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -46,6 +46,5 @@
package com.teragrep.rlo_06;
public enum FragmentState {
- WRITTEN,
- EMPTY
+ WRITTEN, EMPTY
}
diff --git a/src/main/java/com/teragrep/rlo_06/HostnameFunction.java b/src/main/java/com/teragrep/rlo_06/HostnameFunction.java
index 6da0766..c7f7b09 100644
--- a/src/main/java/com/teragrep/rlo_06/HostnameFunction.java
+++ b/src/main/java/com/teragrep/rlo_06/HostnameFunction.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -53,7 +53,7 @@ public final class HostnameFunction implements BiFunction1 2014-06-20T09:14:07.12345+00:00 host01 systemd DEA MSG-01 [ID_A@1 u="3" e="t"][ID_B@2 n="9"] sigsegv\n
-
+
Actions: ______O
Payload:'host01 '
States : ......T
diff --git a/src/main/java/com/teragrep/rlo_06/HostnameParseException.java b/src/main/java/com/teragrep/rlo_06/HostnameParseException.java
index 443207b..f7eeafe 100644
--- a/src/main/java/com/teragrep/rlo_06/HostnameParseException.java
+++ b/src/main/java/com/teragrep/rlo_06/HostnameParseException.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -46,6 +46,7 @@
package com.teragrep.rlo_06;
class HostnameParseException extends ParseException {
+
public HostnameParseException(String message, Throwable cause) {
super(message, cause);
}
@@ -58,4 +59,3 @@ public HostnameParseException(Throwable cause) {
super(cause);
}
}
-
diff --git a/src/main/java/com/teragrep/rlo_06/Matchable.java b/src/main/java/com/teragrep/rlo_06/Matchable.java
index caa51f1..410f9b8 100644
--- a/src/main/java/com/teragrep/rlo_06/Matchable.java
+++ b/src/main/java/com/teragrep/rlo_06/Matchable.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -48,5 +48,6 @@
import java.nio.ByteBuffer;
public interface Matchable {
+
boolean matches(ByteBuffer buffer);
}
diff --git a/src/main/java/com/teragrep/rlo_06/MsgFunction.java b/src/main/java/com/teragrep/rlo_06/MsgFunction.java
index dcd5aa2..2e98e0a 100644
--- a/src/main/java/com/teragrep/rlo_06/MsgFunction.java
+++ b/src/main/java/com/teragrep/rlo_06/MsgFunction.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -52,13 +52,13 @@ public final class MsgFunction implements BiFunction1 2014-06-20T09:14:07.12345+00:00 host01 systemd DEA MSG-01 [ID_A@1 u="3" e="t"][ID_B@2 n="9"] sigsegv\n
-
+
Actions: x_______OO
Actions: _ // if not space
Actions: O // if space
Payload:' sigsegv\n'
States : %.......TT
-
+
*/
private final boolean lineFeedTermination;
@@ -78,7 +78,6 @@ public ByteBuffer apply(Stream stream, ByteBuffer buffer) {
}
msg_current_left--;
-
// this little while here is the steamroller of this parser
if (this.lineFeedTermination) { // Line-feed termination active
while (stream.next()) {
@@ -95,10 +94,9 @@ else if (msg_current_left < 1) {
buffer.put(b);
msg_current_left--;
-
-
}
- } else { // Line-feed termination inactive, reading until EOF
+ }
+ else { // Line-feed termination inactive, reading until EOF
while (stream.next()) {
buffer.put(stream.get());
msg_current_left--;
diff --git a/src/main/java/com/teragrep/rlo_06/MsgIdFunction.java b/src/main/java/com/teragrep/rlo_06/MsgIdFunction.java
index 0338dd6..431ad92 100644
--- a/src/main/java/com/teragrep/rlo_06/MsgIdFunction.java
+++ b/src/main/java/com/teragrep/rlo_06/MsgIdFunction.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -53,7 +53,7 @@ public final class MsgIdFunction implements BiFunction1 2014-06-20T09:14:07.12345+00:00 host01 systemd DEA MSG-01 [ID_A@1 u="3" e="t"][ID_B@2 n="9"] sigsegv\n
-
+
Actions: ______O
Payload:'MSG-01 '
States : ......T
diff --git a/src/main/java/com/teragrep/rlo_06/MsgIdParseException.java b/src/main/java/com/teragrep/rlo_06/MsgIdParseException.java
index 1706de9..f8e7ae7 100644
--- a/src/main/java/com/teragrep/rlo_06/MsgIdParseException.java
+++ b/src/main/java/com/teragrep/rlo_06/MsgIdParseException.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -46,6 +46,7 @@
package com.teragrep.rlo_06;
class MsgIdParseException extends ParseException {
+
public MsgIdParseException(String message, Throwable cause) {
super(message, cause);
}
@@ -58,4 +59,3 @@ public MsgIdParseException(Throwable cause) {
super(cause);
}
}
-
diff --git a/src/main/java/com/teragrep/rlo_06/MsgParseException.java b/src/main/java/com/teragrep/rlo_06/MsgParseException.java
index 428a44d..9d98273 100644
--- a/src/main/java/com/teragrep/rlo_06/MsgParseException.java
+++ b/src/main/java/com/teragrep/rlo_06/MsgParseException.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -46,6 +46,7 @@
package com.teragrep.rlo_06;
class MsgParseException extends ParseException {
+
public MsgParseException(String message, Throwable cause) {
super(message, cause);
}
@@ -58,4 +59,3 @@ public MsgParseException(Throwable cause) {
super(cause);
}
}
-
diff --git a/src/main/java/com/teragrep/rlo_06/ParseException.java b/src/main/java/com/teragrep/rlo_06/ParseException.java
index 654f997..d22304a 100644
--- a/src/main/java/com/teragrep/rlo_06/ParseException.java
+++ b/src/main/java/com/teragrep/rlo_06/ParseException.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -46,6 +46,7 @@
package com.teragrep.rlo_06;
public class ParseException extends RuntimeException {
+
public ParseException(String message, Throwable cause) {
super(message, cause);
}
@@ -58,4 +59,3 @@ public ParseException(Throwable cause) {
super(cause);
}
}
-
diff --git a/src/main/java/com/teragrep/rlo_06/PriorityFunction.java b/src/main/java/com/teragrep/rlo_06/PriorityFunction.java
index fc6f5be..89c1fb9 100644
--- a/src/main/java/com/teragrep/rlo_06/PriorityFunction.java
+++ b/src/main/java/com/teragrep/rlo_06/PriorityFunction.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -53,7 +53,7 @@ public final class PriorityFunction implements BiFunction1 2014-06-20T09:14:07.12345+00:00 host01 systemd DEA MSG-01 [ID_A@1 u="3" e="t"][ID_B@2 n="9"] sigsegv\n
-
+
Actions: O__O
Payload:'<14>'
States : |..T
@@ -71,14 +71,15 @@ public ByteBuffer apply(Stream stream, ByteBuffer buffer) {
if (stream.get() >= 48 && stream.get() <= 57) { // first is always a number between 0..9
buffer.put(stream.get());
- } else {
+ }
+ else {
throw new PriorityParseException("PRIORITY number incorrect");
}
if (!stream.next()) {
throw new PriorityParseException("PRIORITY is too short, can't continue");
}
- if (stream.get() >= 48 &&stream.get() <= 57) { // second may be a number between 0..9
+ if (stream.get() >= 48 && stream.get() <= 57) { // second may be a number between 0..9
buffer.put(stream.get());
if (!stream.next()) {
@@ -95,14 +96,18 @@ public ByteBuffer apply(Stream stream, ByteBuffer buffer) {
if (stream.get() != 62) { // omit
throw new PriorityParseException("PRIORITY > missing");
}
- } else if (stream.get() == 62) { // third may be a '>'
-// omit '>'
- } else {
+ }
+ else if (stream.get() == 62) { // third may be a '>'
+ // omit '>'
+ }
+ else {
throw new PriorityParseException("PRIORITY number incorrect");
}
- } else if (stream.get() == 62) { // second may be a '>'
+ }
+ else if (stream.get() == 62) { // second may be a '>'
// omit '>'
- } else {
+ }
+ else {
throw new PriorityParseException("PRIORITY number incorrect");
}
buffer.flip();
diff --git a/src/main/java/com/teragrep/rlo_06/PriorityParseException.java b/src/main/java/com/teragrep/rlo_06/PriorityParseException.java
index fdd4c26..3f0535b 100644
--- a/src/main/java/com/teragrep/rlo_06/PriorityParseException.java
+++ b/src/main/java/com/teragrep/rlo_06/PriorityParseException.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -46,6 +46,7 @@
package com.teragrep.rlo_06;
class PriorityParseException extends ParseException {
+
public PriorityParseException(String message, Throwable cause) {
super(message, cause);
}
@@ -58,4 +59,3 @@ public PriorityParseException(Throwable cause) {
super(cause);
}
}
-
diff --git a/src/main/java/com/teragrep/rlo_06/ProcIdFunction.java b/src/main/java/com/teragrep/rlo_06/ProcIdFunction.java
index 40c6972..4a46348 100644
--- a/src/main/java/com/teragrep/rlo_06/ProcIdFunction.java
+++ b/src/main/java/com/teragrep/rlo_06/ProcIdFunction.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -53,7 +53,7 @@ public final class ProcIdFunction implements BiFunction1 2014-06-20T09:14:07.12345+00:00 host01 systemd DEA MSG-01 [ID_A@1 u="3" e="t"][ID_B@2 n="9"] sigsegv\n
-
+
Actions: ___O
Payload:'DEA '
States : ...T
diff --git a/src/main/java/com/teragrep/rlo_06/ProcIdParseException.java b/src/main/java/com/teragrep/rlo_06/ProcIdParseException.java
index a150383..ade4eaa 100644
--- a/src/main/java/com/teragrep/rlo_06/ProcIdParseException.java
+++ b/src/main/java/com/teragrep/rlo_06/ProcIdParseException.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -46,6 +46,7 @@
package com.teragrep.rlo_06;
class ProcIdParseException extends ParseException {
+
public ProcIdParseException(String message, Throwable cause) {
super(message, cause);
}
@@ -58,4 +59,3 @@ public ProcIdParseException(Throwable cause) {
super(cause);
}
}
-
diff --git a/src/main/java/com/teragrep/rlo_06/RFC5424Facility.java b/src/main/java/com/teragrep/rlo_06/RFC5424Facility.java
index a83bc7c..0bbbd36 100644
--- a/src/main/java/com/teragrep/rlo_06/RFC5424Facility.java
+++ b/src/main/java/com/teragrep/rlo_06/RFC5424Facility.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -46,10 +46,13 @@
package com.teragrep.rlo_06;
public class RFC5424Facility {
+
final Fragment fragment;
+
public RFC5424Facility(Fragment fragment) {
this.fragment = fragment;
}
+
public int asInt() {
return Integer.parseInt(fragment.toString()) >> 3;
}
diff --git a/src/main/java/com/teragrep/rlo_06/RFC5424Frame.java b/src/main/java/com/teragrep/rlo_06/RFC5424Frame.java
index f3b04cc..4ecb9e5 100644
--- a/src/main/java/com/teragrep/rlo_06/RFC5424Frame.java
+++ b/src/main/java/com/teragrep/rlo_06/RFC5424Frame.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -45,12 +45,12 @@
*/
package com.teragrep.rlo_06;
-import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.function.Consumer;
public final class RFC5424Frame {
+
private final Stream stream;
private final Consumer streamConsumer;
@@ -77,34 +77,42 @@ public RFC5424Frame(boolean lineFeedTermination) {
this.procId = new Fragment(128, new ProcIdFunction());
this.msgId = new Fragment(32, new MsgIdFunction());
this.structuredData = new StructuredData();
- this.msg = new Fragment(256*1024, new MsgFunction(lineFeedTermination));
+ this.msg = new Fragment(256 * 1024, new MsgFunction(lineFeedTermination));
this.stream = new Stream();
this.streamConsumer = priority
- .andThen(version
- .andThen(timestamp
- .andThen(hostname
- .andThen(appName
- .andThen(procId
- .andThen(msgId
- .andThen(structuredData
- .andThen(msg)
+ .andThen(
+ version
+ .andThen(
+ timestamp
+ .andThen(
+ hostname
+ .andThen(
+ appName
+ .andThen(
+ procId
+ .andThen(
+ msgId
+ .andThen(
+ structuredData
+ .andThen(
+ msg
+ )
+ )
+ )
+ )
)
- )
)
- )
)
- )
);
}
-
public boolean next() throws IOException {
/*
Following abbreviations are used to indicate parsing in the comments.
-
+
Actions done to characters: _=Store, ^=Parser variable, O=Omit
-
+
O__O_O_______________________________O______O_______O___O______OO^^^^^^O^OO_OO^OO_OOO^^^^^^O^OO_OO________OO
<14>1 2014-06-20T09:14:07.12345+00:00 host01 systemd DEA MSG-01 [ID_A@1 u="3" e="t"][ID_B@2 n="9"] sigsegv\n
|..T.T...............................T......T.......T...T......T|......%.%%.%%.%%.%%|......%.%%.%T
diff --git a/src/main/java/com/teragrep/rlo_06/RFC5424Severity.java b/src/main/java/com/teragrep/rlo_06/RFC5424Severity.java
index 3319b6f..ad5da8f 100644
--- a/src/main/java/com/teragrep/rlo_06/RFC5424Severity.java
+++ b/src/main/java/com/teragrep/rlo_06/RFC5424Severity.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -46,7 +46,9 @@
package com.teragrep.rlo_06;
public class RFC5424Severity {
+
final Fragment fragment;
+
public RFC5424Severity(Fragment fragment) {
this.fragment = fragment;
}
diff --git a/src/main/java/com/teragrep/rlo_06/RFC5424Timestamp.java b/src/main/java/com/teragrep/rlo_06/RFC5424Timestamp.java
index b1f0629..1a15c72 100644
--- a/src/main/java/com/teragrep/rlo_06/RFC5424Timestamp.java
+++ b/src/main/java/com/teragrep/rlo_06/RFC5424Timestamp.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -48,10 +48,13 @@
import java.time.ZonedDateTime;
public class RFC5424Timestamp {
+
final Fragment fragment;
+
public RFC5424Timestamp(Fragment fragment) {
this.fragment = fragment;
}
+
public ZonedDateTime toZonedDateTime() {
return ZonedDateTime.parse(fragment.toString());
}
diff --git a/src/main/java/com/teragrep/rlo_06/SDElement.java b/src/main/java/com/teragrep/rlo_06/SDElement.java
index a264a57..dc023a3 100644
--- a/src/main/java/com/teragrep/rlo_06/SDElement.java
+++ b/src/main/java/com/teragrep/rlo_06/SDElement.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -60,6 +60,7 @@ public final class SDElement implements Consumer, Clearable {
private FragmentState fragmentState;
private final Fragment stubFragment;
+
SDElement() {
int numElements = 16;
this.sdElementId = new Fragment(32, new SDElementIdFunction());
@@ -68,6 +69,7 @@ public final class SDElement implements Consumer, Clearable {
this.fragmentState = FragmentState.EMPTY;
this.stubFragment = new Fragment();
}
+
// structured data, oh wow the performance hit
@Override
public void accept(Stream stream) {
@@ -132,9 +134,6 @@ public String toString() {
if (fragmentState != FragmentState.WRITTEN) {
throw new IllegalStateException("fragmentState != FragmentState.WRITTEN");
}
- return "SDElement{" +
- "sdElementId=" + sdElementId +
- ", sdParams=" + sdParams +
- '}';
+ return "SDElement{" + "sdElementId=" + sdElementId + ", sdParams=" + sdParams + '}';
}
}
diff --git a/src/main/java/com/teragrep/rlo_06/SDElementCache.java b/src/main/java/com/teragrep/rlo_06/SDElementCache.java
index 781aa40..5928e50 100644
--- a/src/main/java/com/teragrep/rlo_06/SDElementCache.java
+++ b/src/main/java/com/teragrep/rlo_06/SDElementCache.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -61,7 +61,6 @@ final class SDElementCache implements Cache {
cachedSDElements = new Stack<>();
}
-
public SDElement take() {
SDElement sdElement;
diff --git a/src/main/java/com/teragrep/rlo_06/SDElementIdFunction.java b/src/main/java/com/teragrep/rlo_06/SDElementIdFunction.java
index a0338d6..9de44db 100644
--- a/src/main/java/com/teragrep/rlo_06/SDElementIdFunction.java
+++ b/src/main/java/com/teragrep/rlo_06/SDElementIdFunction.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -56,11 +56,11 @@ public ByteBuffer apply(Stream stream, ByteBuffer buffer) {
// parse the sdId
short sdId_max_left = 32;
- /*
- vvvvvv
- Payload:'[ID_A@1 u="3" e="t"][ID_B@2 n="9"] '
- Payload:'[ID_A@1]'
- */
+ /*
+ vvvvvv
+ Payload:'[ID_A@1 u="3" e="t"][ID_B@2 n="9"] '
+ Payload:'[ID_A@1]'
+ */
if (!stream.next()) {
throw new StructuredDataParseException("SD is too short, can't continue");
diff --git a/src/main/java/com/teragrep/rlo_06/SDParam.java b/src/main/java/com/teragrep/rlo_06/SDParam.java
index 70bba76..4510365 100644
--- a/src/main/java/com/teragrep/rlo_06/SDParam.java
+++ b/src/main/java/com/teragrep/rlo_06/SDParam.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -48,6 +48,7 @@
import java.util.function.Consumer;
public final class SDParam implements Consumer, Clearable {
+
public final Fragment sdParamKey;
public final Fragment sdParamValue;
@@ -56,7 +57,7 @@ public final class SDParam implements Consumer, Clearable {
SDParam() {
this.sdParamKey = new Fragment(32, new SDParamKeyFunction());
- this.sdParamValue = new Fragment(8*1024, new SDParamValueFunction());
+ this.sdParamValue = new Fragment(8 * 1024, new SDParamValueFunction());
this.fragmentState = FragmentState.EMPTY;
this.stubFragment = new Fragment();
}
@@ -106,9 +107,6 @@ public String toString() {
if (fragmentState != FragmentState.WRITTEN) {
throw new IllegalStateException("fragmentState != FragmentState.WRITTEN");
}
- return "SDParam{" +
- "sdParamKey=" + sdParamKey +
- ", sdParamValue=" + sdParamValue +
- '}';
+ return "SDParam{" + "sdParamKey=" + sdParamKey + ", sdParamValue=" + sdParamValue + '}';
}
}
diff --git a/src/main/java/com/teragrep/rlo_06/SDParamCache.java b/src/main/java/com/teragrep/rlo_06/SDParamCache.java
index e85c04b..1ffcdfb 100644
--- a/src/main/java/com/teragrep/rlo_06/SDParamCache.java
+++ b/src/main/java/com/teragrep/rlo_06/SDParamCache.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -49,10 +49,9 @@
public class SDParamCache implements Cache {
-
private final Stack cachedSDParams;
final int numElements;
-
+
SDParamCache(int numElements) {
this.numElements = numElements;
this.cachedSDParams = new Stack<>();
diff --git a/src/main/java/com/teragrep/rlo_06/SDParamKeyFunction.java b/src/main/java/com/teragrep/rlo_06/SDParamKeyFunction.java
index 50f1634..7cea33f 100644
--- a/src/main/java/com/teragrep/rlo_06/SDParamKeyFunction.java
+++ b/src/main/java/com/teragrep/rlo_06/SDParamKeyFunction.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
diff --git a/src/main/java/com/teragrep/rlo_06/SDParamValueFunction.java b/src/main/java/com/teragrep/rlo_06/SDParamValueFunction.java
index 829e8b2..9471ef7 100644
--- a/src/main/java/com/teragrep/rlo_06/SDParamValueFunction.java
+++ b/src/main/java/com/teragrep/rlo_06/SDParamValueFunction.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -94,7 +94,8 @@ public ByteBuffer apply(Stream stream, ByteBuffer buffer) {
b = stream.get();
}
}
- } else {
+ }
+ else {
buffer.put(b);
sdElemVal_max_left--;
diff --git a/src/main/java/com/teragrep/rlo_06/SDVector.java b/src/main/java/com/teragrep/rlo_06/SDVector.java
index 7471194..17cabee 100644
--- a/src/main/java/com/teragrep/rlo_06/SDVector.java
+++ b/src/main/java/com/teragrep/rlo_06/SDVector.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -73,9 +73,6 @@ public SDVector(String sdElementId, String sdParamKey) {
@Override
public String toString() {
- return "SDVector{" +
- "sdElementId='" + sdElementId + '\'' +
- ", sdParamKey='" + sdParamKey + '\'' +
- '}';
+ return "SDVector{" + "sdElementId='" + sdElementId + '\'' + ", sdParamKey='" + sdParamKey + '\'' + '}';
}
}
diff --git a/src/main/java/com/teragrep/rlo_06/Stream.java b/src/main/java/com/teragrep/rlo_06/Stream.java
index 64f4433..796ddc9 100644
--- a/src/main/java/com/teragrep/rlo_06/Stream.java
+++ b/src/main/java/com/teragrep/rlo_06/Stream.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -60,7 +60,6 @@ final class Stream implements Supplier {
private int bytesInBuffer = -1;
private byte b;
-
Stream() {
this.inputStream = new ByteArrayInputStream(new byte[0]);
}
@@ -80,7 +79,8 @@ boolean next() {
int read;
try {
read = inputStream.read(buffer, 0, buffer.length);
- } catch (IOException ioException) {
+ }
+ catch (IOException ioException) {
throw new UncheckedIOException(ioException);
}
if (read <= 0) { // EOF
diff --git a/src/main/java/com/teragrep/rlo_06/StructuredData.java b/src/main/java/com/teragrep/rlo_06/StructuredData.java
index 3ba3f35..4007dc1 100644
--- a/src/main/java/com/teragrep/rlo_06/StructuredData.java
+++ b/src/main/java/com/teragrep/rlo_06/StructuredData.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -45,7 +45,6 @@
*/
package com.teragrep.rlo_06;
-
import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;
@@ -56,11 +55,11 @@ public final class StructuredData implements Consumer, Clearable {
|||||||||||||||||||||||||||||||||||
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvR
<14>1 2014-06-20T09:14:07.12345+00:00 host01 systemd DEA MSG-01 [ID_A@1 u="3" e="t"][ID_B@2 n="9"] sigsegv\n
-
+
Actions: O^^^^^^O^OO_OO^OO_OOO^^^^^^O^OO_OO
Payload:'[ID_A@1 u="3" e="t"][ID_B@2 n="9"]'
States : |......%.%%.%%.%%.%%|......%.%%.%T
-
+
NOTE this does not provide any proof what so ever if certain sdId exist or not, we are only interested
in values if they exist.
*/
@@ -77,7 +76,6 @@ public final class StructuredData implements Consumer, Clearable {
private final Fragment stubFragment;
-
StructuredData() {
int numElements = 16;
this.sdElementCache = new SDElementCache(numElements);
@@ -94,7 +92,6 @@ public void accept(Stream stream) {
byte b;
-
if (!stream.next()) {
throw new StructuredDataParseException("Expected SD, received nothing");
}
@@ -117,11 +114,11 @@ else if (b == 91) {
SDElement sdElement = sdElementCache.take();
sdElement.accept(stream);
sdElements.add(sdElement);
- /*
+ /*
vv vv
- Payload:'[ID_A@1 u="3" e="t"][ID_B@2 n="9"] sigsegv\n'
- Payload: '[ID_A@1] sigsegv\n'
- */
+ Payload:'[ID_A@1 u="3" e="t"][ID_B@2 n="9"] sigsegv\n'
+ Payload: '[ID_A@1] sigsegv\n'
+ */
if (!stream.next()) {
throw new StructuredDataParseException("SD is too short, can't continue");
@@ -136,7 +133,6 @@ else if (b == 91) {
fragmentState = FragmentState.WRITTEN;
}
-
@Override
public void clear() {
for (SDElement sdElement : sdElements) {
@@ -155,7 +151,7 @@ public Fragment getValue(SDVector sdVector) {
// reverse search as last value is only that matters
ListIterator listIterator = sdElements.listIterator(sdElements.size());
Fragment rv = stubFragment;
- while(listIterator.hasPrevious()) {
+ while (listIterator.hasPrevious()) {
SDElement sdElement = listIterator.previous();
rv = sdElement.getSDParamValue(sdVector);
if (!rv.isStub) {
@@ -170,8 +166,6 @@ public String toString() {
if (fragmentState != FragmentState.WRITTEN) {
throw new IllegalStateException("fragmentState != FragmentState.WRITTEN");
}
- return "StructuredData{" +
- "sdElements=" + sdElements +
- '}';
+ return "StructuredData{" + "sdElements=" + sdElements + '}';
}
}
diff --git a/src/main/java/com/teragrep/rlo_06/StructuredDataParseException.java b/src/main/java/com/teragrep/rlo_06/StructuredDataParseException.java
index 987bd4c..962596d 100644
--- a/src/main/java/com/teragrep/rlo_06/StructuredDataParseException.java
+++ b/src/main/java/com/teragrep/rlo_06/StructuredDataParseException.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -46,6 +46,7 @@
package com.teragrep.rlo_06;
class StructuredDataParseException extends ParseException {
+
public StructuredDataParseException(String message, Throwable cause) {
super(message, cause);
}
@@ -58,4 +59,3 @@ public StructuredDataParseException(Throwable cause) {
super(cause);
}
}
-
diff --git a/src/main/java/com/teragrep/rlo_06/TimestampFunction.java b/src/main/java/com/teragrep/rlo_06/TimestampFunction.java
index a7f9b44..2a49964 100644
--- a/src/main/java/com/teragrep/rlo_06/TimestampFunction.java
+++ b/src/main/java/com/teragrep/rlo_06/TimestampFunction.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -53,7 +53,7 @@ public final class TimestampFunction implements BiFunction1 2014-06-20T09:14:07.12345+00:00 host01 systemd DEA MSG-01 [ID_A@1 u="3" e="t"][ID_B@2 n="9"] sigsegv\n
-
+
Actions: _______________________________O
Payload:'2014-06-20T09:14:07.12345+00:00 '
States : ...............................T
diff --git a/src/main/java/com/teragrep/rlo_06/TimestampParseException.java b/src/main/java/com/teragrep/rlo_06/TimestampParseException.java
index 9c2ecc2..271d35c 100644
--- a/src/main/java/com/teragrep/rlo_06/TimestampParseException.java
+++ b/src/main/java/com/teragrep/rlo_06/TimestampParseException.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -46,6 +46,7 @@
package com.teragrep.rlo_06;
class TimestampParseException extends ParseException {
+
public TimestampParseException(String message, Throwable cause) {
super(message, cause);
}
@@ -58,4 +59,3 @@ public TimestampParseException(Throwable cause) {
super(cause);
}
}
-
diff --git a/src/main/java/com/teragrep/rlo_06/VersionFunction.java b/src/main/java/com/teragrep/rlo_06/VersionFunction.java
index ab82511..38e626b 100644
--- a/src/main/java/com/teragrep/rlo_06/VersionFunction.java
+++ b/src/main/java/com/teragrep/rlo_06/VersionFunction.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -77,7 +77,8 @@ public ByteBuffer apply(Stream stream, ByteBuffer buffer) {
if (b != 32) { // omit ' '
throw new VersionParseException("SP missing after VERSION");
}
- } else {
+ }
+ else {
throw new VersionParseException("VERSION not 1");
}
buffer.flip();
diff --git a/src/main/java/com/teragrep/rlo_06/VersionParseException.java b/src/main/java/com/teragrep/rlo_06/VersionParseException.java
index bd61272..a5e1cb0 100644
--- a/src/main/java/com/teragrep/rlo_06/VersionParseException.java
+++ b/src/main/java/com/teragrep/rlo_06/VersionParseException.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -46,6 +46,7 @@
package com.teragrep.rlo_06;
class VersionParseException extends ParseException {
+
public VersionParseException(String message, Throwable cause) {
super(message, cause);
}
@@ -58,4 +59,3 @@ public VersionParseException(Throwable cause) {
super(cause);
}
}
-
diff --git a/src/test/java/com/teragrep/rlo_06/AllToBytesTest.java b/src/test/java/com/teragrep/rlo_06/AllToBytesTest.java
index ed529a0..28609bd 100644
--- a/src/test/java/com/teragrep/rlo_06/AllToBytesTest.java
+++ b/src/test/java/com/teragrep/rlo_06/AllToBytesTest.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -56,11 +56,12 @@
import static org.junit.jupiter.api.Assertions.assertTrue;
public class AllToBytesTest {
+
@Test
public void allBytesToStringEqualsTest() throws IOException {
String SYSLOG_MESSAGE = "<14>1 2014-06-20T09:14:07.12345+00:00 host01 systemd DEA MSG-01 [sd_one@48577 id_one=\"eno\" id_two=\"owt\"][sd_two@48577 id_three=\"eerht\" id_four=\"ruof\"] msg\n";
- InputStream inputStream = new ByteArrayInputStream( SYSLOG_MESSAGE.getBytes());
+ InputStream inputStream = new ByteArrayInputStream(SYSLOG_MESSAGE.getBytes());
RFC5424Frame rfc5424Frame = new RFC5424Frame(true);
rfc5424Frame.load(inputStream);
assertTrue(rfc5424Frame.next());
diff --git a/src/test/java/com/teragrep/rlo_06/AppNameTest.java b/src/test/java/com/teragrep/rlo_06/AppNameTest.java
index 51b24f2..9bed6a1 100644
--- a/src/test/java/com/teragrep/rlo_06/AppNameTest.java
+++ b/src/test/java/com/teragrep/rlo_06/AppNameTest.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -54,15 +54,14 @@
import static org.junit.jupiter.api.Assertions.assertThrows;
public class AppNameTest {
+
@Test
public void parseTest() {
Fragment appName = new Fragment(48, new AppNameFunction());
String input = "anAppNameTag ";
- ByteArrayInputStream bais = new ByteArrayInputStream(
- input.getBytes(StandardCharsets.US_ASCII)
- );
+ ByteArrayInputStream bais = new ByteArrayInputStream(input.getBytes(StandardCharsets.US_ASCII));
Stream stream = new Stream();
stream.setInputStream(bais);
@@ -77,9 +76,7 @@ public void dashAppnameTest() {
String input = "- ";
- ByteArrayInputStream bais = new ByteArrayInputStream(
- input.getBytes(StandardCharsets.US_ASCII)
- );
+ ByteArrayInputStream bais = new ByteArrayInputStream(input.getBytes(StandardCharsets.US_ASCII));
Stream stream = new Stream();
stream.setInputStream(bais);
@@ -95,9 +92,7 @@ public void tooLongAppNameTest() {
String input = "ThisIsVeryLongAppNameThatShouldNotExistAndWillBeOverThe48CharLimit ";
- ByteArrayInputStream bais = new ByteArrayInputStream(
- input.getBytes(StandardCharsets.US_ASCII)
- );
+ ByteArrayInputStream bais = new ByteArrayInputStream(input.getBytes(StandardCharsets.US_ASCII));
assertThrows(AppNameParseException.class, () -> {
Stream stream = new Stream();
diff --git a/src/test/java/com/teragrep/rlo_06/BrokenSyntaxTest.java b/src/test/java/com/teragrep/rlo_06/BrokenSyntaxTest.java
index 6d3c2b6..c44c831 100644
--- a/src/test/java/com/teragrep/rlo_06/BrokenSyntaxTest.java
+++ b/src/test/java/com/teragrep/rlo_06/BrokenSyntaxTest.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -50,6 +50,7 @@
import java.io.ByteArrayInputStream;
import java.io.InputStream;
+
public class BrokenSyntaxTest {
@Test
@@ -84,7 +85,6 @@ void testOpenSD() throws Exception {
Assertions.assertThrows(ParseException.class, rfc5424Frame::next);
}
-
@Test
void testAllNil() throws Exception {
String input = "<2>1 - - - - - ";
diff --git a/src/test/java/com/teragrep/rlo_06/ClearThrowsTest.java b/src/test/java/com/teragrep/rlo_06/ClearThrowsTest.java
index 39135d4..6e659c2 100644
--- a/src/test/java/com/teragrep/rlo_06/ClearThrowsTest.java
+++ b/src/test/java/com/teragrep/rlo_06/ClearThrowsTest.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -53,6 +53,7 @@
import java.io.InputStream;
public class ClearThrowsTest {
+
@Test
public void allBytesToStringEqualsTest() throws IOException {
String SYSLOG_MESSAGE = "<14>1 2014-06-20T09:14:07.12345+00:00 host01 systemd DEA MSG-01 [sd_one@48577 id_one=\"eno\" id_two=\"owt\"][sd_two@48577 id_three=\"eerht\" id_four=\"ruof\"] msg\n";
diff --git a/src/test/java/com/teragrep/rlo_06/HostnameTest.java b/src/test/java/com/teragrep/rlo_06/HostnameTest.java
index 0f7cef2..601cb75 100644
--- a/src/test/java/com/teragrep/rlo_06/HostnameTest.java
+++ b/src/test/java/com/teragrep/rlo_06/HostnameTest.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -54,15 +54,14 @@
import static org.junit.jupiter.api.Assertions.assertThrows;
public class HostnameTest {
+
@Test
public void parseTest() {
Fragment hostname = new Fragment(255, new HostnameFunction());
String input = "example.com ";
- ByteArrayInputStream bais = new ByteArrayInputStream(
- input.getBytes(StandardCharsets.US_ASCII)
- );
+ ByteArrayInputStream bais = new ByteArrayInputStream(input.getBytes(StandardCharsets.US_ASCII));
Stream stream = new Stream();
stream.setInputStream(bais);
@@ -78,9 +77,7 @@ public void dashHostnameTest() {
String input = "- ";
- ByteArrayInputStream bais = new ByteArrayInputStream(
- input.getBytes(StandardCharsets.US_ASCII)
- );
+ ByteArrayInputStream bais = new ByteArrayInputStream(input.getBytes(StandardCharsets.US_ASCII));
Stream stream = new Stream();
stream.setInputStream(bais);
@@ -96,9 +93,7 @@ public void tooLongHostnameTest() {
String input = new String(new char[256]).replace('\0', 'x');
- ByteArrayInputStream bais = new ByteArrayInputStream(
- input.getBytes(StandardCharsets.US_ASCII)
- );
+ ByteArrayInputStream bais = new ByteArrayInputStream(input.getBytes(StandardCharsets.US_ASCII));
assertThrows(HostnameParseException.class, () -> {
Stream stream = new Stream();
diff --git a/src/test/java/com/teragrep/rlo_06/MsgIdTest.java b/src/test/java/com/teragrep/rlo_06/MsgIdTest.java
index 82caf98..d75d56a 100644
--- a/src/test/java/com/teragrep/rlo_06/MsgIdTest.java
+++ b/src/test/java/com/teragrep/rlo_06/MsgIdTest.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -54,15 +54,14 @@
import static org.junit.jupiter.api.Assertions.assertThrows;
public class MsgIdTest {
+
@Test
public void parseTest() {
Fragment msgId = new Fragment(32, new MsgIdFunction());
String input = "987654 ";
- ByteArrayInputStream bais = new ByteArrayInputStream(
- input.getBytes(StandardCharsets.US_ASCII)
- );
+ ByteArrayInputStream bais = new ByteArrayInputStream(input.getBytes(StandardCharsets.US_ASCII));
Stream stream = new Stream();
stream.setInputStream(bais);
@@ -78,9 +77,7 @@ public void dashMsgIdTest() {
String input = "- ";
- ByteArrayInputStream bais = new ByteArrayInputStream(
- input.getBytes(StandardCharsets.US_ASCII)
- );
+ ByteArrayInputStream bais = new ByteArrayInputStream(input.getBytes(StandardCharsets.US_ASCII));
Stream stream = new Stream();
stream.setInputStream(bais);
@@ -96,9 +93,7 @@ public void tooLongMsgIdTest() {
String input = "9876543210987654321098765432109876543210 ";
- ByteArrayInputStream bais = new ByteArrayInputStream(
- input.getBytes(StandardCharsets.US_ASCII)
- );
+ ByteArrayInputStream bais = new ByteArrayInputStream(input.getBytes(StandardCharsets.US_ASCII));
assertThrows(MsgIdParseException.class, () -> {
Stream stream = new Stream();
stream.setInputStream(bais);
diff --git a/src/test/java/com/teragrep/rlo_06/MsgTest.java b/src/test/java/com/teragrep/rlo_06/MsgTest.java
index d284743..05f3b9c 100644
--- a/src/test/java/com/teragrep/rlo_06/MsgTest.java
+++ b/src/test/java/com/teragrep/rlo_06/MsgTest.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -52,16 +52,15 @@
import java.nio.charset.StandardCharsets;
public class MsgTest {
+
@Test
public void parseLeadingSpaceNoLFTest() {
// lf termination off
- Fragment msg = new Fragment(256*1024, new MsgFunction(false));
+ Fragment msg = new Fragment(256 * 1024, new MsgFunction(false));
String input = " msg with preceding space and no newline";
- ByteArrayInputStream bais = new ByteArrayInputStream(
- input.getBytes(StandardCharsets.US_ASCII)
- );
+ ByteArrayInputStream bais = new ByteArrayInputStream(input.getBytes(StandardCharsets.US_ASCII));
Stream stream = new Stream();
stream.setInputStream(bais);
@@ -75,13 +74,11 @@ public void parseLeadingSpaceNoLFTest() {
@Test
public void parseNoLeadingSpaceNoLFTest() {
// lf termination off
- Fragment msg = new Fragment(256*1024, new MsgFunction(false));
+ Fragment msg = new Fragment(256 * 1024, new MsgFunction(false));
String input = "msg without preceding space and no newline";
- ByteArrayInputStream bais = new ByteArrayInputStream(
- input.getBytes(StandardCharsets.US_ASCII)
- );
+ ByteArrayInputStream bais = new ByteArrayInputStream(input.getBytes(StandardCharsets.US_ASCII));
Stream stream = new Stream();
stream.setInputStream(bais);
@@ -95,13 +92,11 @@ public void parseNoLeadingSpaceNoLFTest() {
@Test
public void parseNewlineTest() {
// lf termination off
- Fragment msg = new Fragment(256*1024, new MsgFunction(false));
+ Fragment msg = new Fragment(256 * 1024, new MsgFunction(false));
String input = " yes\nnewline";
- ByteArrayInputStream bais = new ByteArrayInputStream(
- input.getBytes(StandardCharsets.US_ASCII)
- );
+ ByteArrayInputStream bais = new ByteArrayInputStream(input.getBytes(StandardCharsets.US_ASCII));
Stream stream = new Stream();
stream.setInputStream(bais);
@@ -111,16 +106,15 @@ public void parseNewlineTest() {
Assertions.assertEquals("yes\nnewline", msg.toString());
}
+
@Test
public void parseLFTerminationWithNextTest() {
// lf termination off
- Fragment msg = new Fragment(256*1024, new MsgFunction(true));
+ Fragment msg = new Fragment(256 * 1024, new MsgFunction(true));
String input = " there is something after newline\nanother";
- ByteArrayInputStream bais = new ByteArrayInputStream(
- input.getBytes(StandardCharsets.US_ASCII)
- );
+ ByteArrayInputStream bais = new ByteArrayInputStream(input.getBytes(StandardCharsets.US_ASCII));
Stream stream = new Stream();
stream.setInputStream(bais);
@@ -134,13 +128,11 @@ public void parseLFTerminationWithNextTest() {
@Test
public void parseLFTerminationWithoutNextTest() {
// lf termination off
- Fragment msg = new Fragment(256*1024, new MsgFunction(true));
+ Fragment msg = new Fragment(256 * 1024, new MsgFunction(true));
String input = " there is nothing after newline\n";
- ByteArrayInputStream bais = new ByteArrayInputStream(
- input.getBytes(StandardCharsets.US_ASCII)
- );
+ ByteArrayInputStream bais = new ByteArrayInputStream(input.getBytes(StandardCharsets.US_ASCII));
Stream stream = new Stream();
stream.setInputStream(bais);
@@ -154,13 +146,11 @@ public void parseLFTerminationWithoutNextTest() {
@Test
public void emptyMessageTest() {
// lf termination off
- Fragment msg = new Fragment(256*1024, new MsgFunction(true));
+ Fragment msg = new Fragment(256 * 1024, new MsgFunction(true));
String input = " ";
- ByteArrayInputStream bais = new ByteArrayInputStream(
- input.getBytes(StandardCharsets.US_ASCII)
- );
+ ByteArrayInputStream bais = new ByteArrayInputStream(input.getBytes(StandardCharsets.US_ASCII));
Stream stream = new Stream();
stream.setInputStream(bais);
diff --git a/src/test/java/com/teragrep/rlo_06/PriorityDecodeTest.java b/src/test/java/com/teragrep/rlo_06/PriorityDecodeTest.java
index 71c5a88..c0a52f6 100644
--- a/src/test/java/com/teragrep/rlo_06/PriorityDecodeTest.java
+++ b/src/test/java/com/teragrep/rlo_06/PriorityDecodeTest.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -55,6 +55,7 @@
import static org.junit.jupiter.api.Assertions.assertTrue;
public class PriorityDecodeTest {
+
@Test
public void testDecodePriority() throws IOException {
String SYSLOG_MESSAGE = "<134>1 2018-01-01T10:12:00+01:00 hostname appname - - - Message";
diff --git a/src/test/java/com/teragrep/rlo_06/PriorityTest.java b/src/test/java/com/teragrep/rlo_06/PriorityTest.java
index b46b862..38325f8 100644
--- a/src/test/java/com/teragrep/rlo_06/PriorityTest.java
+++ b/src/test/java/com/teragrep/rlo_06/PriorityTest.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -61,9 +61,7 @@ public void parseTest() {
String input = "<123>";
- ByteArrayInputStream bais = new ByteArrayInputStream(
- input.getBytes(StandardCharsets.US_ASCII)
- );
+ ByteArrayInputStream bais = new ByteArrayInputStream(input.getBytes(StandardCharsets.US_ASCII));
Stream stream = new Stream();
stream.setInputStream(bais);
@@ -81,9 +79,7 @@ public void emptyPriorityIdTest() {
String input = "<>";
- ByteArrayInputStream bais = new ByteArrayInputStream(
- input.getBytes(StandardCharsets.US_ASCII)
- );
+ ByteArrayInputStream bais = new ByteArrayInputStream(input.getBytes(StandardCharsets.US_ASCII));
assertThrows(PriorityParseException.class, () -> {
Stream stream = new Stream();
@@ -101,9 +97,7 @@ public void tooLongPriorityIdTest() {
String input = "<12345>";
- ByteArrayInputStream bais = new ByteArrayInputStream(
- input.getBytes(StandardCharsets.US_ASCII)
- );
+ ByteArrayInputStream bais = new ByteArrayInputStream(input.getBytes(StandardCharsets.US_ASCII));
assertThrows(PriorityParseException.class, () -> {
Stream stream = new Stream();
diff --git a/src/test/java/com/teragrep/rlo_06/ProcIdTest.java b/src/test/java/com/teragrep/rlo_06/ProcIdTest.java
index cf2f72f..041f2f8 100644
--- a/src/test/java/com/teragrep/rlo_06/ProcIdTest.java
+++ b/src/test/java/com/teragrep/rlo_06/ProcIdTest.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -54,15 +54,14 @@
import static org.junit.jupiter.api.Assertions.assertThrows;
public class ProcIdTest {
+
@Test
public void parseTest() {
Fragment procId = new Fragment(128, new ProcIdFunction());
String input = "cade00f0-3260-4b88-ab61-d644a75dfbbb ";
- ByteArrayInputStream bais = new ByteArrayInputStream(
- input.getBytes(StandardCharsets.US_ASCII)
- );
+ ByteArrayInputStream bais = new ByteArrayInputStream(input.getBytes(StandardCharsets.US_ASCII));
Stream stream = new Stream();
stream.setInputStream(bais);
@@ -78,9 +77,7 @@ public void emptyProcIdTest() {
String input = "";
- ByteArrayInputStream bais = new ByteArrayInputStream(
- input.getBytes(StandardCharsets.US_ASCII)
- );
+ ByteArrayInputStream bais = new ByteArrayInputStream(input.getBytes(StandardCharsets.US_ASCII));
assertThrows(ParseException.class, () -> {
Stream stream = new Stream();
@@ -96,9 +93,7 @@ public void tooLongProcIdTest() {
String input = new String(new char[256]).replace('\0', 'x');
- ByteArrayInputStream bais = new ByteArrayInputStream(
- input.getBytes(StandardCharsets.US_ASCII)
- );
+ ByteArrayInputStream bais = new ByteArrayInputStream(input.getBytes(StandardCharsets.US_ASCII));
assertThrows(ProcIdParseException.class, () -> {
Stream stream = new Stream();
diff --git a/src/test/java/com/teragrep/rlo_06/StructuredDataTest.java b/src/test/java/com/teragrep/rlo_06/StructuredDataTest.java
index 08c55ca..509e7f1 100644
--- a/src/test/java/com/teragrep/rlo_06/StructuredDataTest.java
+++ b/src/test/java/com/teragrep/rlo_06/StructuredDataTest.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -52,15 +52,14 @@
import java.nio.charset.StandardCharsets;
public class StructuredDataTest {
+
@Test
public void parseTest() {
StructuredData structuredData = new StructuredData();
String input = "[id@0 keyHere=\"valueThere\"] "; // structured data terminates only to non [ character
- ByteArrayInputStream bais = new ByteArrayInputStream(
- input.getBytes(StandardCharsets.US_ASCII)
- );
+ ByteArrayInputStream bais = new ByteArrayInputStream(input.getBytes(StandardCharsets.US_ASCII));
Stream stream = new Stream();
stream.setInputStream(bais);
@@ -85,9 +84,7 @@ public void clearSDElementTest() {
String input = "[id@0 keyHere=\"valueThere\"] "; // structured data terminates only to non [ character
- ByteArrayInputStream bais = new ByteArrayInputStream(
- input.getBytes(StandardCharsets.US_ASCII)
- );
+ ByteArrayInputStream bais = new ByteArrayInputStream(input.getBytes(StandardCharsets.US_ASCII));
Stream stream = new Stream();
stream.setInputStream(bais);
@@ -101,17 +98,14 @@ public void clearSDElementTest() {
// clear
structuredData.sdElements.get(0).sdElementId.clear();
Assertions.assertThrows(IllegalStateException.class, () -> {
- structuredData.sdElements.get(0).sdElementId.toString();
- },
- "direction != Direction.READ");
-
+ structuredData.sdElements.get(0).sdElementId.toString();
+ }, "direction != Direction.READ");
// double clear
structuredData.sdElements.get(0).sdElementId.clear();
Assertions.assertThrows(IllegalStateException.class, () -> {
- structuredData.sdElements.get(0).sdElementId.toString();
- },
- "direction != Direction.READ");
+ structuredData.sdElements.get(0).sdElementId.toString();
+ }, "direction != Direction.READ");
}
@Test
@@ -120,9 +114,7 @@ public void clearSDParamKeyTest() {
String input = "[id@0 keyHere=\"valueThere\"] "; // structured data terminates only to non [ character
- ByteArrayInputStream bais = new ByteArrayInputStream(
- input.getBytes(StandardCharsets.US_ASCII)
- );
+ ByteArrayInputStream bais = new ByteArrayInputStream(input.getBytes(StandardCharsets.US_ASCII));
Stream stream = new Stream();
stream.setInputStream(bais);
@@ -135,11 +127,13 @@ public void clearSDParamKeyTest() {
// clear
structuredData.sdElements.get(0).sdParams.get(0).sdParamKey.clear();
- Assertions.assertThrows(IllegalStateException.class, () -> structuredData.sdElements.get(0).sdParams.get(0).sdParamKey.toString());
+ Assertions
+ .assertThrows(IllegalStateException.class, () -> structuredData.sdElements.get(0).sdParams.get(0).sdParamKey.toString());
// double clear
structuredData.sdElements.get(0).sdParams.get(0).sdParamKey.clear();
- Assertions.assertThrows(IllegalStateException.class, () -> structuredData.sdElements.get(0).sdParams.get(0).sdParamKey.toString());
+ Assertions
+ .assertThrows(IllegalStateException.class, () -> structuredData.sdElements.get(0).sdParams.get(0).sdParamKey.toString());
}
@Test
@@ -148,9 +142,7 @@ public void parseDashTest() {
String input = "- "; // structured data terminates after the dash character
- ByteArrayInputStream bais = new ByteArrayInputStream(
- input.getBytes(StandardCharsets.US_ASCII)
- );
+ ByteArrayInputStream bais = new ByteArrayInputStream(input.getBytes(StandardCharsets.US_ASCII));
Stream stream = new Stream();
stream.setInputStream(bais);
diff --git a/src/test/java/com/teragrep/rlo_06/TimestampConversionTest.java b/src/test/java/com/teragrep/rlo_06/TimestampConversionTest.java
index 752bfb9..cd3fb65 100644
--- a/src/test/java/com/teragrep/rlo_06/TimestampConversionTest.java
+++ b/src/test/java/com/teragrep/rlo_06/TimestampConversionTest.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -55,6 +55,7 @@
import static org.junit.jupiter.api.Assertions.assertTrue;
public class TimestampConversionTest {
+
@Test
public void testTimestampConversion() throws IOException {
Assertions.assertEquals("2003-08-24T05:14:15.000003-07:00", getTimestamp("2003-08-24T05:14:15.000003-07:00"));
diff --git a/src/test/java/com/teragrep/rlo_06/TimestampTest.java b/src/test/java/com/teragrep/rlo_06/TimestampTest.java
index 4aa1475..da03458 100644
--- a/src/test/java/com/teragrep/rlo_06/TimestampTest.java
+++ b/src/test/java/com/teragrep/rlo_06/TimestampTest.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -52,15 +52,14 @@
import java.nio.charset.StandardCharsets;
public class TimestampTest {
+
@Test
public void parseTest() {
Fragment timestamp = new Fragment(32, new TimestampFunction());
String input = "2023-06-16T12:08:12.123456+03:00 ";
- ByteArrayInputStream bais = new ByteArrayInputStream(
- input.getBytes(StandardCharsets.US_ASCII)
- );
+ ByteArrayInputStream bais = new ByteArrayInputStream(input.getBytes(StandardCharsets.US_ASCII));
Stream stream = new Stream();
stream.setInputStream(bais);
diff --git a/src/test/java/com/teragrep/rlo_06/VersionTest.java b/src/test/java/com/teragrep/rlo_06/VersionTest.java
index d2f1486..263fb5a 100644
--- a/src/test/java/com/teragrep/rlo_06/VersionTest.java
+++ b/src/test/java/com/teragrep/rlo_06/VersionTest.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -54,15 +54,14 @@
import static org.junit.jupiter.api.Assertions.assertThrows;
public class VersionTest {
+
@Test
public void parseTest() {
Fragment version = new Fragment(1, new VersionFunction());
String input = "1 ";
- ByteArrayInputStream bais = new ByteArrayInputStream(
- input.getBytes(StandardCharsets.US_ASCII)
- );
+ ByteArrayInputStream bais = new ByteArrayInputStream(input.getBytes(StandardCharsets.US_ASCII));
Stream stream = new Stream();
stream.setInputStream(bais);
@@ -78,9 +77,7 @@ public void testEmptyVersion() {
String input = " ";
- ByteArrayInputStream bais = new ByteArrayInputStream(
- input.getBytes(StandardCharsets.US_ASCII)
- );
+ ByteArrayInputStream bais = new ByteArrayInputStream(input.getBytes(StandardCharsets.US_ASCII));
assertThrows(VersionParseException.class, () -> {
Stream stream = new Stream();
@@ -90,16 +87,13 @@ public void testEmptyVersion() {
});
}
-
@Test
public void testNonOneVersion() {
Fragment version = new Fragment(1, new VersionFunction());
String input = "2 ";
- ByteArrayInputStream bais = new ByteArrayInputStream(
- input.getBytes(StandardCharsets.US_ASCII)
- );
+ ByteArrayInputStream bais = new ByteArrayInputStream(input.getBytes(StandardCharsets.US_ASCII));
assertThrows(VersionParseException.class, () -> {
Stream stream = new Stream();
diff --git a/src/test/java/com/teragrep/rlo_06/tests/AllSubscriptionTest.java b/src/test/java/com/teragrep/rlo_06/tests/AllSubscriptionTest.java
index 6249231..775ae9e 100644
--- a/src/test/java/com/teragrep/rlo_06/tests/AllSubscriptionTest.java
+++ b/src/test/java/com/teragrep/rlo_06/tests/AllSubscriptionTest.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -52,7 +52,6 @@
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.util.HashMap;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -62,22 +61,21 @@ public class AllSubscriptionTest {
public void testAllSubscription() throws IOException {
String SYSLOG_MESSAGE = "<14>1 2014-06-20T09:14:07.12345+00:00 host01 systemd DEA MSG-01 [ID_A@1 u=\"\\\"3\" e=\"t\"][ID_B@2 n=\"9\"][event_id@48577 hostname=\"sc-99-99-14-247\" uuid=\"0FD92E51B37748EB90CD894CCEE63907\" unixtime=\"1612047600.0\" id_source=\"source\"][event_node_source@48577 hostname=\"sc-99-99-14-247\" source=\"f17_ssmis_20210131v7.nc\" source_module=\"imfile\"][event_node_relay@48577 hostname=\"localhost\" source=\"sc-99-99-14-247\" source_module=\"imrelp\"][event_version@48577 major=\"2\" minor=\"2\" hostname=\"localhost\" version_source=\"relay\"][event_node_router@48577 source=\"logrouter.example.com\" source_module=\"imrelp\" hostname=\"localhost\"][teragrep@48577 streamname=\"log:f17:0\" directory=\"com_teragrep_audit\" unixtime=\"1612047600.0\"] msg\n";
- InputStream inputStream = new ByteArrayInputStream( SYSLOG_MESSAGE.getBytes());
+ InputStream inputStream = new ByteArrayInputStream(SYSLOG_MESSAGE.getBytes());
RFC5424Frame rfc5424Frame = new RFC5424Frame(true);
rfc5424Frame.load(inputStream);
assertTrue(rfc5424Frame.next());
-
SDVector sdVector = new SDVector("event_id@48577", "uuid");
- Assertions.assertEquals("0FD92E51B37748EB90CD894CCEE63907", rfc5424Frame.structuredData.getValue(sdVector).toString());
+ Assertions
+ .assertEquals("0FD92E51B37748EB90CD894CCEE63907", rfc5424Frame.structuredData.getValue(sdVector).toString());
}
-
@Test
public void testAllGet() throws IOException {
String SYSLOG_MESSAGE = "<14>1 2014-06-20T09:14:07.12345+00:00 host01 systemd DEA MSG-01 [ID_A@1 u=\"\\\"3\" e=\"t\"][ID_B@2 n=\"9\"][event_id@48577 hostname=\"sc-99-99-14-247\" uuid=\"0FD92E51B37748EB90CD894CCEE63907\" unixtime=\"1612047600.0\" id_source=\"source\"][event_node_source@48577 hostname=\"sc-99-99-14-247\" source=\"f17_ssmis_20210131v7.nc\" source_module=\"imfile\"][event_node_relay@48577 hostname=\"localhost\" source=\"sc-99-99-14-247\" source_module=\"imrelp\"][event_version@48577 major=\"2\" minor=\"2\" hostname=\"localhost\" version_source=\"relay\"][event_node_router@48577 source=\"logrouter.example.com\" source_module=\"imrelp\" hostname=\"localhost\"][teragrep@48577 streamname=\"log:f17:0\" directory=\"com_teragrep_audit\" unixtime=\"1612047600.0\"] msg\n";
- InputStream inputStream = new ByteArrayInputStream( SYSLOG_MESSAGE.getBytes());
+ InputStream inputStream = new ByteArrayInputStream(SYSLOG_MESSAGE.getBytes());
RFC5424Frame rfc5424Frame = new RFC5424Frame(true);
rfc5424Frame.load(inputStream);
assertTrue(rfc5424Frame.next());
@@ -87,33 +85,113 @@ public void testAllGet() throws IOException {
Assertions.assertEquals("9", rfc5424Frame.structuredData.getValue(new SDVector("ID_B@2", "n")).toString());
- Assertions.assertEquals("sc-99-99-14-247", rfc5424Frame.structuredData.getValue(new SDVector("event_id@48577", "hostname")).toString());
- Assertions.assertEquals("0FD92E51B37748EB90CD894CCEE63907", rfc5424Frame.structuredData.getValue(new SDVector("event_id@48577", "uuid")).toString());
- Assertions.assertEquals("sc-99-99-14-247", rfc5424Frame.structuredData.getValue(new SDVector("event_id@48577", "hostname")).toString());
- Assertions.assertEquals("1612047600.0", rfc5424Frame.structuredData.getValue(new SDVector("event_id@48577", "unixtime")).toString());
- Assertions.assertEquals("source", rfc5424Frame.structuredData.getValue(new SDVector("event_id@48577", "id_source")).toString());
-
- Assertions.assertEquals("sc-99-99-14-247", rfc5424Frame.structuredData.getValue(new SDVector("event_node_source@48577", "hostname")).toString());
- Assertions.assertEquals("f17_ssmis_20210131v7.nc", rfc5424Frame.structuredData.getValue(new SDVector("event_node_source@48577", "source")).toString());
- Assertions.assertEquals("imfile", rfc5424Frame.structuredData.getValue(new SDVector("event_node_source@48577", "source_module")).toString());
-
- Assertions.assertEquals("localhost", rfc5424Frame.structuredData.getValue(new SDVector("event_node_relay@48577", "hostname")).toString());
- Assertions.assertEquals("sc-99-99-14-247", rfc5424Frame.structuredData.getValue(new SDVector("event_node_relay@48577", "source")).toString());
- Assertions.assertEquals("imrelp", rfc5424Frame.structuredData.getValue(new SDVector("event_node_relay@48577", "source_module")).toString());
-
- Assertions.assertEquals("2", rfc5424Frame.structuredData.getValue(new SDVector("event_version@48577", "major")).toString());
- Assertions.assertEquals("2", rfc5424Frame.structuredData.getValue(new SDVector("event_version@48577", "minor")).toString());
- Assertions.assertEquals("localhost", rfc5424Frame.structuredData.getValue(new SDVector("event_version@48577", "hostname")).toString());
- Assertions.assertEquals("relay", rfc5424Frame.structuredData.getValue(new SDVector("event_version@48577", "version_source")).toString());
-
- Assertions.assertEquals("logrouter.example.com", rfc5424Frame.structuredData.getValue(new SDVector("event_node_router@48577", "source")).toString());
- Assertions.assertEquals("imrelp", rfc5424Frame.structuredData.getValue(new SDVector("event_node_router@48577", "source_module")).toString());
- Assertions.assertEquals("localhost", rfc5424Frame.structuredData.getValue(new SDVector("event_node_router@48577", "hostname")).toString());
-
- Assertions.assertEquals("log:f17:0", rfc5424Frame.structuredData.getValue(new SDVector("teragrep@48577", "streamname")).toString());
- Assertions.assertEquals("com_teragrep_audit", rfc5424Frame.structuredData.getValue(new SDVector("teragrep@48577", "directory")).toString());
- Assertions.assertEquals("1612047600.0", rfc5424Frame.structuredData.getValue(new SDVector("teragrep@48577", "unixtime")).toString());
+ Assertions
+ .assertEquals(
+ "sc-99-99-14-247",
+ rfc5424Frame.structuredData.getValue(new SDVector("event_id@48577", "hostname")).toString()
+ );
+ Assertions
+ .assertEquals(
+ "0FD92E51B37748EB90CD894CCEE63907",
+ rfc5424Frame.structuredData.getValue(new SDVector("event_id@48577", "uuid")).toString()
+ );
+ Assertions
+ .assertEquals(
+ "sc-99-99-14-247",
+ rfc5424Frame.structuredData.getValue(new SDVector("event_id@48577", "hostname")).toString()
+ );
+ Assertions
+ .assertEquals(
+ "1612047600.0", rfc5424Frame.structuredData.getValue(new SDVector("event_id@48577", "unixtime")).toString()
+ );
+ Assertions
+ .assertEquals("source", rfc5424Frame.structuredData.getValue(new SDVector("event_id@48577", "id_source")).toString());
+
+ Assertions
+ .assertEquals(
+ "sc-99-99-14-247", rfc5424Frame.structuredData
+ .getValue(new SDVector("event_node_source@48577", "hostname"))
+ .toString()
+ );
+ Assertions
+ .assertEquals(
+ "f17_ssmis_20210131v7.nc", rfc5424Frame.structuredData
+ .getValue(new SDVector("event_node_source@48577", "source"))
+ .toString()
+ );
+ Assertions
+ .assertEquals(
+ "imfile", rfc5424Frame.structuredData
+ .getValue(new SDVector("event_node_source@48577", "source_module"))
+ .toString()
+ );
+
+ Assertions
+ .assertEquals(
+ "localhost", rfc5424Frame.structuredData
+ .getValue(new SDVector("event_node_relay@48577", "hostname"))
+ .toString()
+ );
+ Assertions
+ .assertEquals(
+ "sc-99-99-14-247", rfc5424Frame.structuredData
+ .getValue(new SDVector("event_node_relay@48577", "source"))
+ .toString()
+ );
+ Assertions
+ .assertEquals(
+ "imrelp", rfc5424Frame.structuredData
+ .getValue(new SDVector("event_node_relay@48577", "source_module"))
+ .toString()
+ );
+
+ Assertions
+ .assertEquals("2", rfc5424Frame.structuredData.getValue(new SDVector("event_version@48577", "major")).toString());
+ Assertions
+ .assertEquals("2", rfc5424Frame.structuredData.getValue(new SDVector("event_version@48577", "minor")).toString());
+ Assertions
+ .assertEquals(
+ "localhost", rfc5424Frame.structuredData.getValue(new SDVector("event_version@48577", "hostname")).toString()
+ );
+ Assertions
+ .assertEquals(
+ "relay", rfc5424Frame.structuredData
+ .getValue(new SDVector("event_version@48577", "version_source"))
+ .toString()
+ );
+
+ Assertions
+ .assertEquals(
+ "logrouter.example.com", rfc5424Frame.structuredData
+ .getValue(new SDVector("event_node_router@48577", "source"))
+ .toString()
+ );
+ Assertions
+ .assertEquals(
+ "imrelp", rfc5424Frame.structuredData
+ .getValue(new SDVector("event_node_router@48577", "source_module"))
+ .toString()
+ );
+ Assertions
+ .assertEquals(
+ "localhost", rfc5424Frame.structuredData
+ .getValue(new SDVector("event_node_router@48577", "hostname"))
+ .toString()
+ );
+
+ Assertions
+ .assertEquals(
+ "log:f17:0", rfc5424Frame.structuredData.getValue(new SDVector("teragrep@48577", "streamname")).toString()
+ );
+ Assertions
+ .assertEquals(
+ "com_teragrep_audit",
+ rfc5424Frame.structuredData.getValue(new SDVector("teragrep@48577", "directory")).toString()
+ );
+ Assertions
+ .assertEquals(
+ "1612047600.0", rfc5424Frame.structuredData.getValue(new SDVector("teragrep@48577", "unixtime")).toString()
+ );
}
-
}
diff --git a/src/test/java/com/teragrep/rlo_06/tests/NewParserTest.java b/src/test/java/com/teragrep/rlo_06/tests/NewParserTest.java
index a29285b..c14db5e 100644
--- a/src/test/java/com/teragrep/rlo_06/tests/NewParserTest.java
+++ b/src/test/java/com/teragrep/rlo_06/tests/NewParserTest.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -51,22 +51,20 @@
import java.io.*;
-
import static org.junit.jupiter.api.Assertions.*;
public class NewParserTest {
-
@Test
void testNewParser() throws Exception {
String SYSLOG_MESSAGE = "<14>1 2014-06-20T09:14:07.123456+00:00 host01 systemd DEA MSG-01 [ID_A@1 u=\"\\\"3\" e=\"t\"][ID_B@2 n=\"9\"] sigsegv\n";
-
+
InputStream inputStream = new ByteArrayInputStream((SYSLOG_MESSAGE).getBytes());
RFC5424Frame rfc5424Frame = new RFC5424Frame(true);
rfc5424Frame.load(inputStream);
-
+
assertTrue(rfc5424Frame.next());
-
+
Assertions.assertEquals("14", rfc5424Frame.priority.toString());
Assertions.assertEquals("1", rfc5424Frame.version.toString());
Assertions.assertEquals("2014-06-20T09:14:07.123456+00:00", rfc5424Frame.timestamp.toString());
@@ -102,19 +100,22 @@ void testNewParser() throws Exception {
public void testAllAsList() throws IOException {
String SYSLOG_MESSAGE = "<14>1 2014-06-20T09:14:07.12345+00:00 host01 systemd DEA MSG-01 [ID_A@1 u=\"\\\"3\" e=\"t\"][ID_B@2 n=\"9\"][event_id@48577 hostname=\"sc-99-99-14-247\" uuid=\"0FD92E51B37748EB90CD894CCEE63907\" unixtime=\"1612047600.0\" id_source=\"source\"][event_node_source@48577 hostname=\"sc-99-99-14-247\" source=\"f17_ssmis_20210131v7.nc\" source_module=\"imfile\"][event_node_relay@48577 hostname=\"localhost\" source=\"sc-99-99-14-247\" source_module=\"imrelp\"][event_version@48577 major=\"2\" minor=\"2\" hostname=\"localhost\" version_source=\"relay\"][event_node_router@48577 source=\"logrouter.example.com\" source_module=\"imrelp\" hostname=\"localhost\"][teragrep@48577 streamname=\"log:f17:0\" directory=\"com_teragrep_audit\" unixtime=\"1612047600.0\"] msg\n";
- InputStream inputStream = new ByteArrayInputStream( SYSLOG_MESSAGE.getBytes());
+ InputStream inputStream = new ByteArrayInputStream(SYSLOG_MESSAGE.getBytes());
RFC5424Frame rfc5424Frame = new RFC5424Frame(true);
rfc5424Frame.load(inputStream);
assertTrue(rfc5424Frame.next());
-
Assertions.assertEquals("ID_A@1", rfc5424Frame.structuredData.sdElements.get(0).sdElementId.toString());
Assertions.assertEquals("ID_B@2", rfc5424Frame.structuredData.sdElements.get(1).sdElementId.toString());
Assertions.assertEquals("event_id@48577", rfc5424Frame.structuredData.sdElements.get(2).sdElementId.toString());
- Assertions.assertEquals("event_node_source@48577", rfc5424Frame.structuredData.sdElements.get(3).sdElementId.toString());
- Assertions.assertEquals("event_node_relay@48577", rfc5424Frame.structuredData.sdElements.get(4).sdElementId.toString());
- Assertions.assertEquals("event_version@48577", rfc5424Frame.structuredData.sdElements.get(5).sdElementId.toString());
- Assertions.assertEquals("event_node_router@48577", rfc5424Frame.structuredData.sdElements.get(6).sdElementId.toString());
+ Assertions
+ .assertEquals("event_node_source@48577", rfc5424Frame.structuredData.sdElements.get(3).sdElementId.toString());
+ Assertions
+ .assertEquals("event_node_relay@48577", rfc5424Frame.structuredData.sdElements.get(4).sdElementId.toString());
+ Assertions
+ .assertEquals("event_version@48577", rfc5424Frame.structuredData.sdElements.get(5).sdElementId.toString());
+ Assertions
+ .assertEquals("event_node_router@48577", rfc5424Frame.structuredData.sdElements.get(6).sdElementId.toString());
Assertions.assertEquals("teragrep@48577", rfc5424Frame.structuredData.sdElements.get(7).sdElementId.toString());
Assertions.assertThrows(IndexOutOfBoundsException.class, () -> {
diff --git a/src/test/java/com/teragrep/rlo_06/tests/PerformanceTest.java b/src/test/java/com/teragrep/rlo_06/tests/PerformanceTest.java
index 33b9505..02bce1c 100644
--- a/src/test/java/com/teragrep/rlo_06/tests/PerformanceTest.java
+++ b/src/test/java/com/teragrep/rlo_06/tests/PerformanceTest.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -57,17 +57,19 @@
public class PerformanceTest {
@Test
- @DisabledIfSystemProperty(named = "noPerfTest", matches = "true")
+ @DisabledIfSystemProperty(
+ named = "noPerfTest",
+ matches = "true"
+ )
void testLongPayloadPerformance() throws Exception {
- String payload = new String(new char[128*1000]).replace("\0", "X");
- String SYSLOG_MESSAGE = "<14>1 2014-06-20T09:14:07.12345+00:00 host01 systemd DEA MSG-01 [ID_A@1 u=\"\\\"3\" e=\"t\"][ID_B@2 n=\"9\"][event_id@48577 hostname=\"sc-99-99-14-247\" uuid=\"0FD92E51B37748EB90CD894CCEE63907\" unixtime=\"1612047600.0\" id_source=\"source\"][event_node_source@48577 hostname=\"sc-99-99-14-247\" source=\"f17_ssmis_20210131v7.nc\" source_module=\"imfile\"][event_node_relay@48577 hostname=\"localhost\" source=\"sc-99-99-14-247\" source_module=\"imrelp\"][event_version@48577 major=\"2\" minor=\"2\" hostname=\"localhost\" version_source=\"relay\"][event_node_router@48577 source=\"logrouter.example.com\" source_module=\"imrelp\" hostname=\"localhost\"][teragrep@48577 streamname=\"log:f17:0\" directory=\"com_teragrep_audit\" unixtime=\"1612047600.0\"] " + payload + "\n";
+ String payload = new String(new char[128 * 1000]).replace("\0", "X");
+ String SYSLOG_MESSAGE = "<14>1 2014-06-20T09:14:07.12345+00:00 host01 systemd DEA MSG-01 [ID_A@1 u=\"\\\"3\" e=\"t\"][ID_B@2 n=\"9\"][event_id@48577 hostname=\"sc-99-99-14-247\" uuid=\"0FD92E51B37748EB90CD894CCEE63907\" unixtime=\"1612047600.0\" id_source=\"source\"][event_node_source@48577 hostname=\"sc-99-99-14-247\" source=\"f17_ssmis_20210131v7.nc\" source_module=\"imfile\"][event_node_relay@48577 hostname=\"localhost\" source=\"sc-99-99-14-247\" source_module=\"imrelp\"][event_version@48577 major=\"2\" minor=\"2\" hostname=\"localhost\" version_source=\"relay\"][event_node_router@48577 source=\"logrouter.example.com\" source_module=\"imrelp\" hostname=\"localhost\"][teragrep@48577 streamname=\"log:f17:0\" directory=\"com_teragrep_audit\" unixtime=\"1612047600.0\"] "
+ + payload + "\n";
- InputStream inputStream = new ByteArrayInputStream( SYSLOG_MESSAGE.getBytes());
+ InputStream inputStream = new ByteArrayInputStream(SYSLOG_MESSAGE.getBytes());
RFC5424Frame rfc5424Frame = new RFC5424Frame(true);
rfc5424Frame.load(inputStream);
-
-
Instant instant1 = Instant.now();
long count = 50000;
for (long i = 0; i < count; i++) {
@@ -75,23 +77,28 @@ void testLongPayloadPerformance() throws Exception {
inputStream.reset();
}
Instant instant2 = Instant.now();
- long msgsize = (count * SYSLOG_MESSAGE.length())/1024/1024;
- long spent = instant2.toEpochMilli()-instant1.toEpochMilli();
- System.out.println("testLongPayloadPerformance: time taken " + spent + " for " + count +
- ", total RPS: " + (float) count/ ((float) spent/1000) +
- ", " + (float) msgsize + " megabytes (" + (float) (msgsize/((float)spent/1000)) + " MB/s)");
+ long msgsize = (count * SYSLOG_MESSAGE.length()) / 1024 / 1024;
+ long spent = instant2.toEpochMilli() - instant1.toEpochMilli();
+ System.out
+ .println(
+ "testLongPayloadPerformance: time taken " + spent + " for " + count + ", total RPS: "
+ + (float) count / ((float) spent / 1000) + ", " + (float) msgsize + " megabytes ("
+ + (float) (msgsize / ((float) spent / 1000)) + " MB/s)"
+ );
}
@Test
- @DisabledIfSystemProperty(named = "noPerfTest", matches = "true")
+ @DisabledIfSystemProperty(
+ named = "noPerfTest",
+ matches = "true"
+ )
void testShortPayloadPerformance() throws Exception {
String SYSLOG_MESSAGE = "<14>1 2014-06-20T09:14:07.12345+00:00 host01 systemd DEA MSG-01 [ID_A@1 u=\"\\\"3\" e=\"t\"][ID_B@2 n=\"9\"][event_id@48577 hostname=\"sc-99-99-14-247\" uuid=\"0FD92E51B37748EB90CD894CCEE63907\" unixtime=\"1612047600.0\" id_source=\"source\"][event_node_source@48577 hostname=\"sc-99-99-14-247\" source=\"f17_ssmis_20210131v7.nc\" source_module=\"imfile\"][event_node_relay@48577 hostname=\"localhost\" source=\"sc-99-99-14-247\" source_module=\"imrelp\"][event_version@48577 major=\"2\" minor=\"2\" hostname=\"localhost\" version_source=\"relay\"][event_node_router@48577 source=\"logrouter.example.com\" source_module=\"imrelp\" hostname=\"localhost\"][teragrep@48577 streamname=\"log:f17:0\" directory=\"com_teragrep_audit\" unixtime=\"1612047600.0\"] sigsegv\n";
- InputStream inputStream = new ByteArrayInputStream( SYSLOG_MESSAGE.getBytes());
+ InputStream inputStream = new ByteArrayInputStream(SYSLOG_MESSAGE.getBytes());
RFC5424Frame rfc5424Frame = new RFC5424Frame(true);
rfc5424Frame.load(inputStream);
-
Instant instant1 = Instant.now();
long count = 10000000;
for (long i = 0; i < count; i++) {
@@ -100,30 +107,37 @@ void testShortPayloadPerformance() throws Exception {
}
Instant instant2 = Instant.now();
- long msgsize = (count * SYSLOG_MESSAGE.length())/1024/1024;
- long spent = instant2.toEpochMilli()-instant1.toEpochMilli();
- System.out.println("testShortPayloadPerformance: time taken " + spent + " for " + count +
- ", total RPS: " + (float) count/ ((float) spent/1000) +
- ", " + (float) msgsize + " megabytes (" + (float) (msgsize/((float)spent/1000)) + " MB/s)");
+ long msgsize = (count * SYSLOG_MESSAGE.length()) / 1024 / 1024;
+ long spent = instant2.toEpochMilli() - instant1.toEpochMilli();
+ System.out
+ .println(
+ "testShortPayloadPerformance: time taken " + spent + " for " + count + ", total RPS: "
+ + (float) count / ((float) spent / 1000) + ", " + (float) msgsize + " megabytes ("
+ + (float) (msgsize / ((float) spent / 1000)) + " MB/s)"
+ );
}
@Test
- @DisabledIfSystemProperty(named = "noPerfTest", matches = "true")
+ @DisabledIfSystemProperty(
+ named = "noPerfTest",
+ matches = "true"
+ )
void testMediumLongSDPerformance() throws Exception {
String payload = new String(new char[16]).replace("\0", "X");
StringBuilder builder = new StringBuilder();
- for(int i=0; i<10; i++) {
+ for (int i = 0; i < 10; i++) {
builder.append("[verylongsdidhere@");
builder.append(i);
- for(int y=0; y<10; y++) {
+ for (int y = 0; y < 10; y++) {
builder.append(" verylongelementnamehere=\"");
builder.append(payload);
builder.append("\"");
}
builder.append("]");
}
- String SYSLOG_MESSAGE = "<14>1 2014-06-20T09:14:07.12345+00:00 host01 systemd DEA MSG-01 " + builder + " sigsegv\n";
+ String SYSLOG_MESSAGE = "<14>1 2014-06-20T09:14:07.12345+00:00 host01 systemd DEA MSG-01 " + builder
+ + " sigsegv\n";
InputStream inputStream = new ByteArrayInputStream(SYSLOG_MESSAGE.getBytes());
RFC5424Frame rfc5424Frame = new RFC5424Frame(true);
rfc5424Frame.load(inputStream);
@@ -136,30 +150,37 @@ void testMediumLongSDPerformance() throws Exception {
}
Instant instant2 = Instant.now();
- long msgsize = (count * SYSLOG_MESSAGE.length())/1024/1024;
- long spent = instant2.toEpochMilli()-instant1.toEpochMilli();
- System.out.println("testMediumLongSDPerformance: time taken " + spent + " for " + count +
- ", total RPS: " + (float) count/ ((float) spent/1000) +
- ", " + (float) msgsize + " megabytes (" + (float) (msgsize/((float)spent/1000)) + " MB/s)");
+ long msgsize = (count * SYSLOG_MESSAGE.length()) / 1024 / 1024;
+ long spent = instant2.toEpochMilli() - instant1.toEpochMilli();
+ System.out
+ .println(
+ "testMediumLongSDPerformance: time taken " + spent + " for " + count + ", total RPS: "
+ + (float) count / ((float) spent / 1000) + ", " + (float) msgsize + " megabytes ("
+ + (float) (msgsize / ((float) spent / 1000)) + " MB/s)"
+ );
}
@Test
- @DisabledIfSystemProperty(named = "noPerfTest", matches = "true")
+ @DisabledIfSystemProperty(
+ named = "noPerfTest",
+ matches = "true"
+ )
void testVeryLongSDPerformance() throws Exception {
String payload = new String(new char[128]).replace("\0", "X");
StringBuilder builder = new StringBuilder();
- for(int i=0; i<100; i++) {
+ for (int i = 0; i < 100; i++) {
builder.append("[verylongsdidhere@");
builder.append(i);
- for(int y=0; y<100; y++) {
+ for (int y = 0; y < 100; y++) {
builder.append(" verylongelementnamehere=\"");
builder.append(payload);
builder.append("\"");
}
builder.append("]");
}
- String SYSLOG_MESSAGE = "<14>1 2014-06-20T09:14:07.12345+00:00 host01 systemd DEA MSG-01 " + builder + " sigsegv\n";
+ String SYSLOG_MESSAGE = "<14>1 2014-06-20T09:14:07.12345+00:00 host01 systemd DEA MSG-01 " + builder
+ + " sigsegv\n";
InputStream inputStream = new ByteArrayInputStream(SYSLOG_MESSAGE.getBytes());
RFC5424Frame rfc5424Frame = new RFC5424Frame(true);
rfc5424Frame.load(inputStream);
@@ -172,24 +193,29 @@ void testVeryLongSDPerformance() throws Exception {
}
Instant instant2 = Instant.now();
- long msgsize = (count * SYSLOG_MESSAGE.length())/1024/1024;
- long spent = instant2.toEpochMilli()-instant1.toEpochMilli();
- System.out.println("testVeryLongSDPerformance: time taken " + spent + " for " + count +
- ", total RPS: " + (float) count/ ((float) spent/1000) +
- ", " + (float) msgsize + " megabytes (" + (float) (msgsize/((float)spent/1000)) + " MB/s)");
+ long msgsize = (count * SYSLOG_MESSAGE.length()) / 1024 / 1024;
+ long spent = instant2.toEpochMilli() - instant1.toEpochMilli();
+ System.out
+ .println(
+ "testVeryLongSDPerformance: time taken " + spent + " for " + count + ", total RPS: "
+ + (float) count / ((float) spent / 1000) + ", " + (float) msgsize + " megabytes ("
+ + (float) (msgsize / ((float) spent / 1000)) + " MB/s)"
+ );
}
@Test
- @DisabledIfSystemProperty(named = "noPerfTest", matches = "true")
+ @DisabledIfSystemProperty(
+ named = "noPerfTest",
+ matches = "true"
+ )
void testDashes() throws Exception {
String SYSLOG_MESSAGE = "<2>1 - - - - - ";
- InputStream inputStream = new ByteArrayInputStream( SYSLOG_MESSAGE.getBytes());
+ InputStream inputStream = new ByteArrayInputStream(SYSLOG_MESSAGE.getBytes());
RFC5424Frame rfc5424Frame = new RFC5424Frame(true);
rfc5424Frame.load(inputStream);
-
Instant instant1 = Instant.now();
long count = 100000000;
for (long i = 0; i < count; i++) {
@@ -198,11 +224,14 @@ void testDashes() throws Exception {
}
Instant instant2 = Instant.now();
- long msgsize = (count * SYSLOG_MESSAGE.length())/1024/1024;
- long spent = instant2.toEpochMilli()-instant1.toEpochMilli();
- System.out.println("testDashes: time taken " + spent + " for " + count +
- ", total RPS: " + (float) count/ ((float) spent/1000) +
- ", " + (float) msgsize + " megabytes (" + (float) (msgsize/((float)spent/1000)) + " MB/s)");
+ long msgsize = (count * SYSLOG_MESSAGE.length()) / 1024 / 1024;
+ long spent = instant2.toEpochMilli() - instant1.toEpochMilli();
+ System.out
+ .println(
+ "testDashes: time taken " + spent + " for " + count + ", total RPS: "
+ + (float) count / ((float) spent / 1000) + ", " + (float) msgsize + " megabytes ("
+ + (float) (msgsize / ((float) spent / 1000)) + " MB/s)"
+ );
}
}
diff --git a/src/test/java/com/teragrep/rlo_06/tests/PlaygroundTest.java b/src/test/java/com/teragrep/rlo_06/tests/PlaygroundTest.java
index c1cd9d5..1e3a4f9 100644
--- a/src/test/java/com/teragrep/rlo_06/tests/PlaygroundTest.java
+++ b/src/test/java/com/teragrep/rlo_06/tests/PlaygroundTest.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -55,8 +55,9 @@ public class PlaygroundTest {
//@Test
void ReadableByteChannelPerformance() throws Exception {
- String payload = new String(new char[128*1000]).replace("\0", "X");
- String SYSLOG_MESSAGE = "<14>1 2014-06-20T09:14:07.12345+00:00 host01 systemd DEA MSG-01 [ID_A@1 u=\"\\\"3\" e=\"t\"][ID_B@2 n=\"9\"][event_id@48577 hostname=\"sc-99-99-14-247\" uuid=\"0FD92E51B37748EB90CD894CCEE63907\" unixtime=\"1612047600.0\" id_source=\"source\"][event_node_source@48577 hostname=\"sc-99-99-14-247\" source=\"f17_ssmis_20210131v7.nc\" source_module=\"imfile\"][event_node_relay@48577 hostname=\"localhost\" source=\"sc-99-99-14-247\" source_module=\"imrelp\"][event_version@48577 major=\"2\" minor=\"2\" hostname=\"localhost\" version_source=\"relay\"][event_node_router@48577 source=\"logrouter.example.com\" source_module=\"imrelp\" hostname=\"localhost\"][teragrep@48577 streamname=\"log:f17:0\" directory=\"com_teragrep_audit\" unixtime=\"1612047600.0\"] " + payload + "\n";
+ String payload = new String(new char[128 * 1000]).replace("\0", "X");
+ String SYSLOG_MESSAGE = "<14>1 2014-06-20T09:14:07.12345+00:00 host01 systemd DEA MSG-01 [ID_A@1 u=\"\\\"3\" e=\"t\"][ID_B@2 n=\"9\"][event_id@48577 hostname=\"sc-99-99-14-247\" uuid=\"0FD92E51B37748EB90CD894CCEE63907\" unixtime=\"1612047600.0\" id_source=\"source\"][event_node_source@48577 hostname=\"sc-99-99-14-247\" source=\"f17_ssmis_20210131v7.nc\" source_module=\"imfile\"][event_node_relay@48577 hostname=\"localhost\" source=\"sc-99-99-14-247\" source_module=\"imrelp\"][event_version@48577 major=\"2\" minor=\"2\" hostname=\"localhost\" version_source=\"relay\"][event_node_router@48577 source=\"logrouter.example.com\" source_module=\"imrelp\" hostname=\"localhost\"][teragrep@48577 streamname=\"log:f17:0\" directory=\"com_teragrep_audit\" unixtime=\"1612047600.0\"] "
+ + payload + "\n";
Instant instant1 = Instant.now();
int count = 128102000;
@@ -65,7 +66,7 @@ void ReadableByteChannelPerformance() throws Exception {
final File initialFile = new File("output.txt");
final InputStream inputStream = new FileInputStream(initialFile);
// final InputStream inputStream = new BufferedInputStream(new FileInputStream("output.txt"));
- ByteBuffer byteBuffer = ByteBuffer.allocateDirect(1024*128);
+ ByteBuffer byteBuffer = ByteBuffer.allocateDirect(1024 * 128);
ReadableByteChannel ioChan = Channels.newChannel(inputStream);
ioChan.read(byteBuffer);
@@ -91,20 +92,25 @@ void ReadableByteChannelPerformance() throws Exception {
}
Instant instant2 = Instant.now();
- System.out.println(new String(new byte[] {b}));
+ System.out.println(new String(new byte[] {
+ b
+ }));
System.out.println(pulls);
- int msgsize = count*SYSLOG_MESSAGE.length();
-
- long spent = instant2.toEpochMilli()-instant1.toEpochMilli();
- System.out.println("ReadableByteChannelPerformance: time taken " + spent + " for " + count +
- ", total chars per second: " + (float) count / ((float) spent/1000) +
- ", " + (float) msgsize/1024/1024 + " megabytes (" + (float) (msgsize/((float)spent/1000))/1024/1024 + " MB/s)");
+ int msgsize = count * SYSLOG_MESSAGE.length();
+
+ long spent = instant2.toEpochMilli() - instant1.toEpochMilli();
+ System.out
+ .println(
+ "ReadableByteChannelPerformance: time taken " + spent + " for " + count
+ + ", total chars per second: " + (float) count / ((float) spent / 1000) + ", "
+ + (float) msgsize / 1024 / 1024 + " megabytes ("
+ + (float) (msgsize / ((float) spent / 1000)) / 1024 / 1024 + " MB/s)"
+ );
}
//@Test
void bufferFast() throws IOException {
-
final File initialFile = new File("output.txt");
final InputStream inputStream = new FileInputStream(initialFile);
@@ -114,7 +120,7 @@ void bufferFast() throws IOException {
long count = 0;
int lines = 0;
- byte[] buffer = new byte[1024*128];
+ byte[] buffer = new byte[1024 * 128];
int pointer = 0;
int read = inputStream.read(buffer, 0, buffer.length);
@@ -133,14 +139,23 @@ void bufferFast() throws IOException {
}
Instant instant2 = Instant.now();
- System.out.println(new String(new byte[] {b}));
- long spent = instant2.toEpochMilli()-instant1.toEpochMilli();
- System.out.println("puhHuijaaTsuuh: time taken " + spent + " for " + count +
- ", total chars per second: " + (float) count / ((float) spent/1000) +
- ", " + (float) initialFile.length()/1024/1024 + " megabytes (" + (float) (initialFile.length()/((float)spent/1000))/1024/1024 + " MB/s)");
-
- System.out.println("puhHuijaaTsuuh: time taken " + spent + " for " + lines +
- ", total lines per second: " + (float) lines / ((float) spent/1000));
+ System.out.println(new String(new byte[] {
+ b
+ }));
+ long spent = instant2.toEpochMilli() - instant1.toEpochMilli();
+ System.out
+ .println(
+ "puhHuijaaTsuuh: time taken " + spent + " for " + count + ", total chars per second: "
+ + (float) count / ((float) spent / 1000) + ", "
+ + (float) initialFile.length() / 1024 / 1024 + " megabytes ("
+ + (float) (initialFile.length() / ((float) spent / 1000)) / 1024 / 1024 + " MB/s)"
+ );
+
+ System.out
+ .println(
+ "puhHuijaaTsuuh: time taken " + spent + " for " + lines + ", total lines per second: "
+ + (float) lines / ((float) spent / 1000)
+ );
}
}
diff --git a/src/test/java/com/teragrep/rlo_06/tests/ResultSetAsByteBufferTest.java b/src/test/java/com/teragrep/rlo_06/tests/ResultSetAsByteBufferTest.java
index ad23378..8c6c2b7 100644
--- a/src/test/java/com/teragrep/rlo_06/tests/ResultSetAsByteBufferTest.java
+++ b/src/test/java/com/teragrep/rlo_06/tests/ResultSetAsByteBufferTest.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -67,17 +67,18 @@ public void read() throws IOException {
Assertions.assertTrue(rfc5424Frame.next());
- String sourceModule = rfc5424Frame.structuredData.getValue(new SDVector("event_node_source@48577", "source_module")).toString();
- String hostname = rfc5424Frame.structuredData.getValue(new SDVector("event_node_relay@48577", "source")).toString();
- String sourceFile = rfc5424Frame.structuredData.getValue(new SDVector("event_node_source@48577", "source")).toString();
+ String sourceModule = rfc5424Frame.structuredData
+ .getValue(new SDVector("event_node_source@48577", "source_module"))
+ .toString();
+ String hostname = rfc5424Frame.structuredData
+ .getValue(new SDVector("event_node_relay@48577", "source"))
+ .toString();
+ String sourceFile = rfc5424Frame.structuredData
+ .getValue(new SDVector("event_node_source@48577", "source"))
+ .toString();
assertEquals(
"imfile:sc-99-99-14-247:f17_ssmis_20210131v7.nc",
- String.format(
- "%s:%s:%s",
- sourceModule,
- hostname,
- sourceFile
- )
+ String.format("%s:%s:%s", sourceModule, hostname, sourceFile)
);
}
}
diff --git a/src/test/java/com/teragrep/rlo_06/tests/SyntaxTest.java b/src/test/java/com/teragrep/rlo_06/tests/SyntaxTest.java
index 08692e8..234c19b 100644
--- a/src/test/java/com/teragrep/rlo_06/tests/SyntaxTest.java
+++ b/src/test/java/com/teragrep/rlo_06/tests/SyntaxTest.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -52,7 +52,6 @@
import java.io.*;
import java.nio.file.Files;
-
import static org.junit.jupiter.api.Assertions.*;
public class SyntaxTest {
@@ -79,7 +78,6 @@ void testMultipleSyntax() throws Exception {
Assertions.assertEquals("MSG-01", rfc5424Frame.msgId.toString());
Assertions.assertEquals("sigsegv", rfc5424Frame.msg.toString());
-
// Structured Data 1
SDVector sdVector = new SDVector("ID_A@1", "u");
Assertions.assertEquals("\\\"3", rfc5424Frame.structuredData.getValue(sdVector).toString());
@@ -99,9 +97,9 @@ void testMultipleSyntax() throws Exception {
Assertions.assertEquals("ASD-05", rfc5424Frame.msgId.toString());
Assertions.assertEquals("normal", rfc5424Frame.msg.toString());
-
// Structured Data 2
- Assertions.assertEquals("\\\"3", rfc5424Frame.structuredData.getValue(new SDVector("ID_A@1", "u")).toString());
+ Assertions
+ .assertEquals("\\\"3", rfc5424Frame.structuredData.getValue(new SDVector("ID_A@1", "u")).toString());
assertFalse(rfc5424Frame.next());
@@ -146,7 +144,8 @@ void testNoNewLineEOF() throws Exception {
Assertions.assertEquals("sigsegv", rfc5424Frame.msg.toString());
// Structured Data 1
- Assertions.assertEquals("\\\"3", rfc5424Frame.structuredData.getValue(new SDVector("ID_A@1", "u")).toString());
+ Assertions
+ .assertEquals("\\\"3", rfc5424Frame.structuredData.getValue(new SDVector("ID_A@1", "u")).toString());
assertFalse(rfc5424Frame.next());
@@ -171,7 +170,10 @@ void testNoNewLineEOF() throws Exception {
@Test
void testTeragrepStructuredElement() throws Exception {
final File logFile = new File("src/test/resources/event.log");
- final InputStream inputStream = new BufferedInputStream(Files.newInputStream(logFile.toPath()), 32 * 1024 * 1024);
+ final InputStream inputStream = new BufferedInputStream(
+ Files.newInputStream(logFile.toPath()),
+ 32 * 1024 * 1024
+ );
RFC5424Frame rfc5424Frame = new RFC5424Frame(true);
rfc5424Frame.load(inputStream);
@@ -182,21 +184,65 @@ void testTeragrepStructuredElement() throws Exception {
Assertions.assertEquals("sc-99-99-14-25", rfc5424Frame.hostname.toString());
Assertions.assertEquals("-", rfc5424Frame.procId.toString());
Assertions.assertEquals("-", rfc5424Frame.msgId.toString());
- Assertions.assertEquals("{\"rainfall_rate\": 0.0, \"wind_speed\": 8.0, \"atmosphere_water_vapor_content\": 4.800000190734863, \"atmosphere_cloud_liquid_water_content\": 0.029999997466802597, \"latitude\": -89.875, \"longitude\": 0.125}", rfc5424Frame.msg.toString());
+ Assertions
+ .assertEquals(
+ "{\"rainfall_rate\": 0.0, \"wind_speed\": 8.0, \"atmosphere_water_vapor_content\": 4.800000190734863, \"atmosphere_cloud_liquid_water_content\": 0.029999997466802597, \"latitude\": -89.875, \"longitude\": 0.125}",
+ rfc5424Frame.msg.toString()
+ );
// event_node_source@48577
- Assertions.assertEquals("f17_ssmis_20200319v7.nc", rfc5424Frame.structuredData.getValue(new SDVector("event_node_source@48577", "source")).toString());
- Assertions.assertEquals("imfile", rfc5424Frame.structuredData.getValue(new SDVector("event_node_source@48577", "source_module")).toString());
- Assertions.assertEquals("sc-99-99-14-25", rfc5424Frame.structuredData.getValue(new SDVector("event_node_source@48577", "hostname")).toString());
+ Assertions
+ .assertEquals(
+ "f17_ssmis_20200319v7.nc", rfc5424Frame.structuredData
+ .getValue(new SDVector("event_node_source@48577", "source"))
+ .toString()
+ );
+ Assertions
+ .assertEquals(
+ "imfile", rfc5424Frame.structuredData
+ .getValue(new SDVector("event_node_source@48577", "source_module"))
+ .toString()
+ );
+ Assertions
+ .assertEquals(
+ "sc-99-99-14-25", rfc5424Frame.structuredData
+ .getValue(new SDVector("event_node_source@48577", "hostname"))
+ .toString()
+ );
// event_node_relay@48577
- Assertions.assertEquals("sc-99-99-14-25", rfc5424Frame.structuredData.getValue(new SDVector("event_node_relay@48577", "source")).toString());
- Assertions.assertEquals("imrelp", rfc5424Frame.structuredData.getValue(new SDVector("event_node_relay@48577", "source_module")).toString());
- Assertions.assertEquals("localhost", rfc5424Frame.structuredData.getValue(new SDVector("event_node_relay@48577", "hostname")).toString());
+ Assertions
+ .assertEquals(
+ "sc-99-99-14-25", rfc5424Frame.structuredData
+ .getValue(new SDVector("event_node_relay@48577", "source"))
+ .toString()
+ );
+ Assertions
+ .assertEquals(
+ "imrelp", rfc5424Frame.structuredData
+ .getValue(new SDVector("event_node_relay@48577", "source_module"))
+ .toString()
+ );
+ Assertions
+ .assertEquals(
+ "localhost", rfc5424Frame.structuredData
+ .getValue(new SDVector("event_node_relay@48577", "hostname"))
+ .toString()
+ );
// teragrep@48577
- Assertions.assertEquals("log:f17:0", rfc5424Frame.structuredData.getValue(new SDVector("teragrep@48577", "streamname")).toString());
- Assertions.assertEquals("com_teragrep_audit", rfc5424Frame.structuredData.getValue(new SDVector("teragrep@48577", "directory")).toString());
- Assertions.assertEquals("1584572400.0", rfc5424Frame.structuredData.getValue(new SDVector("teragrep@48577", "unixtime")).toString());
+ Assertions
+ .assertEquals(
+ "log:f17:0", rfc5424Frame.structuredData.getValue(new SDVector("teragrep@48577", "streamname")).toString()
+ );
+ Assertions
+ .assertEquals(
+ "com_teragrep_audit",
+ rfc5424Frame.structuredData.getValue(new SDVector("teragrep@48577", "directory")).toString()
+ );
+ Assertions
+ .assertEquals(
+ "1584572400.0", rfc5424Frame.structuredData.getValue(new SDVector("teragrep@48577", "unixtime")).toString()
+ );
// Message Finished
}
@@ -219,10 +265,18 @@ void consecutiveNoNewLine() throws Exception {
Assertions.assertEquals("rsyslogd-pstats", rfc5424Frame.appName.toString());
Assertions.assertEquals("-", rfc5424Frame.procId.toString());
Assertions.assertEquals("-", rfc5424Frame.msgId.toString());
- Assertions.assertEquals("{\"@timestamp\":\"2021-03-18T12:29:36.842898+02:00\",\"host\":\"logsource.example.com\",\"source-module\":\"impstats\", \"name\": \"tags-out\", \"origin\": \"dynstats.bucket\", \"values\": { } }", rfc5424Frame.msg.toString());
+ Assertions
+ .assertEquals(
+ "{\"@timestamp\":\"2021-03-18T12:29:36.842898+02:00\",\"host\":\"logsource.example.com\",\"source-module\":\"impstats\", \"name\": \"tags-out\", \"origin\": \"dynstats.bucket\", \"values\": { } }",
+ rfc5424Frame.msg.toString()
+ );
// Structured Data 1
- Assertions.assertEquals("logsource.example.com", rfc5424Frame.structuredData.getValue(new SDVector("event_id@48577", "hostname")).toString());
+ Assertions
+ .assertEquals(
+ "logsource.example.com",
+ rfc5424Frame.structuredData.getValue(new SDVector("event_id@48577", "hostname")).toString()
+ );
}
// finally empty
@@ -263,10 +317,18 @@ void consecutiveWithNewLine() throws Exception {
Assertions.assertEquals("rsyslogd-pstats", rfc5424Frame.appName.toString());
Assertions.assertEquals("-", rfc5424Frame.procId.toString());
Assertions.assertEquals("-", rfc5424Frame.msgId.toString());
- Assertions.assertEquals("{\"@timestamp\":\"2021-03-25T15:14:09.449777+02:00\",\"host\":\"logsource.example.com\",\"source-module\":\"impstats\", \"name\": \"resource-usage\", \"origin\": \"impstats\", \"utime\": 693053726, \"stime\": 133593735, \"maxrss\": 4690828, \"minflt\": 46694808, \"majflt\": 0, \"inblock\": 122077416, \"oublock\": 123878288, \"nvcsw\": 7199, \"nivcsw\": 9287, \"openfiles\": 20 }", rfc5424Frame.msg.toString());
+ Assertions
+ .assertEquals(
+ "{\"@timestamp\":\"2021-03-25T15:14:09.449777+02:00\",\"host\":\"logsource.example.com\",\"source-module\":\"impstats\", \"name\": \"resource-usage\", \"origin\": \"impstats\", \"utime\": 693053726, \"stime\": 133593735, \"maxrss\": 4690828, \"minflt\": 46694808, \"majflt\": 0, \"inblock\": 122077416, \"oublock\": 123878288, \"nvcsw\": 7199, \"nivcsw\": 9287, \"openfiles\": 20 }",
+ rfc5424Frame.msg.toString()
+ );
// Structured Data 1
- Assertions.assertEquals("logsource.example.com", rfc5424Frame.structuredData.getValue(new SDVector("event_id@48577", "hostname")).toString());
+ Assertions
+ .assertEquals(
+ "logsource.example.com",
+ rfc5424Frame.structuredData.getValue(new SDVector("event_id@48577", "hostname")).toString()
+ );
}
// finally empty
@@ -282,7 +344,6 @@ void consecutiveWithNewLine() throws Exception {
assertThrows(IllegalStateException.class, rfc5424Frame.msgId::toString);
assertThrows(IllegalStateException.class, rfc5424Frame.msg::toString);
-
// Structured Data Finished
Assertions.assertThrows(IllegalStateException.class, () -> {
rfc5424Frame.structuredData.getValue(new SDVector("event_id@48577", "hostname")).toString();
@@ -308,7 +369,10 @@ public void testNoSd() throws IOException {
Assertions.assertEquals("app-tag", rfc5424Frame.appName.toString());
Assertions.assertEquals("-", rfc5424Frame.procId.toString());
Assertions.assertEquals("-", rfc5424Frame.msgId.toString());
- Assertions.assertEquals(" 1.2.3.4 - - [08/Mar/2019:14:00:00 +0200] \"POST /idt/device/", rfc5424Frame.msg.toString());
+ Assertions
+ .assertEquals(
+ " 1.2.3.4 - - [08/Mar/2019:14:00:00 +0200] \"POST /idt/device/", rfc5424Frame.msg.toString()
+ );
assertFalse(rfc5424Frame.next());
@@ -337,7 +401,6 @@ public void brokenSDElemWorkaroundTest() throws IOException {
Assertions.assertEquals(" source-http ", rfc5424Frame.msg.toString());
assertFalse(rfc5424Frame.next());
-
inputStream.reset();
}
diff --git a/src/test/java/com/teragrep/rlo_06/tests/TestFileTest.java b/src/test/java/com/teragrep/rlo_06/tests/TestFileTest.java
index e92bfcc..56a277b 100644
--- a/src/test/java/com/teragrep/rlo_06/tests/TestFileTest.java
+++ b/src/test/java/com/teragrep/rlo_06/tests/TestFileTest.java
@@ -1,6 +1,6 @@
/*
- * Java RFC524 parser library RLO-06
- * Copyright (C) 2022 Suomen Kanuuna Oy
+ * Teragrep RFC5424 frame library for Java (rlo_06)
+ * Copyright (C) 2022-2024 Suomen Kanuuna Oy
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -56,10 +56,12 @@
import java.time.Instant;
public class TestFileTest {
+
//@Test
void createTestFile() throws Exception {
- String payload = new String(new char[128*1000]).replace("\0", "X");
- String SYSLOG_MESSAGE = "<14>1 2014-06-20T09:14:07.12345+00:00 host01 systemd DEA MSG-01 [ID_A@1 u=\"\\\"3\" e=\"t\"][ID_B@2 n=\"9\"][event_id@48577 hostname=\"sc-99-99-14-247\" uuid=\"0FD92E51B37748EB90CD894CCEE63907\" unixtime=\"1612047600.0\" id_source=\"source\"][event_node_source@48577 hostname=\"sc-99-99-14-247\" source=\"f17_ssmis_20210131v7.nc\" source_module=\"imfile\"][event_node_relay@48577 hostname=\"localhost\" source=\"sc-99-99-14-247\" source_module=\"imrelp\"][event_version@48577 major=\"2\" minor=\"2\" hostname=\"localhost\" version_source=\"relay\"][event_node_router@48577 source=\"logrouter.example.com\" source_module=\"imrelp\" hostname=\"localhost\"][teragrep@48577 streamname=\"log:f17:0\" directory=\"com_teragrep_audit\" unixtime=\"1612047600.0\"] " + payload + "\n";
+ String payload = new String(new char[128 * 1000]).replace("\0", "X");
+ String SYSLOG_MESSAGE = "<14>1 2014-06-20T09:14:07.12345+00:00 host01 systemd DEA MSG-01 [ID_A@1 u=\"\\\"3\" e=\"t\"][ID_B@2 n=\"9\"][event_id@48577 hostname=\"sc-99-99-14-247\" uuid=\"0FD92E51B37748EB90CD894CCEE63907\" unixtime=\"1612047600.0\" id_source=\"source\"][event_node_source@48577 hostname=\"sc-99-99-14-247\" source=\"f17_ssmis_20210131v7.nc\" source_module=\"imfile\"][event_node_relay@48577 hostname=\"localhost\" source=\"sc-99-99-14-247\" source_module=\"imrelp\"][event_version@48577 major=\"2\" minor=\"2\" hostname=\"localhost\" version_source=\"relay\"][event_node_router@48577 source=\"logrouter.example.com\" source_module=\"imrelp\" hostname=\"localhost\"][teragrep@48577 streamname=\"log:f17:0\" directory=\"com_teragrep_audit\" unixtime=\"1612047600.0\"] "
+ + payload + "\n";
int count = 100000;
@@ -70,14 +72,16 @@ void createTestFile() throws Exception {
FileUtils.writeStringToFile(file, SYSLOG_MESSAGE, "UTF-8", true);
}
- System.out.println(new String(new byte[] {b}));
+ System.out.println(new String(new byte[] {
+ b
+ }));
}
//@Test
void readTestFile() throws Exception {
final File initialFile = new File("output.txt");
- final InputStream inputStream = new BufferedInputStream(new FileInputStream(initialFile),32*1024*1024);
+ final InputStream inputStream = new BufferedInputStream(new FileInputStream(initialFile), 32 * 1024 * 1024);
RFC5424Frame rfc5424Frame = new RFC5424Frame();
rfc5424Frame.load(inputStream);
@@ -88,8 +92,11 @@ void readTestFile() throws Exception {
}
Instant instant2 = Instant.now();
- long spent = instant2.toEpochMilli()-instant1.toEpochMilli();
- System.out.println("testLongPayloadPerformance: time taken " + spent + " for " + count +
- ", total EPS: " + (float) count / ((float) spent/1000));
+ long spent = instant2.toEpochMilli() - instant1.toEpochMilli();
+ System.out
+ .println(
+ "testLongPayloadPerformance: time taken " + spent + " for " + count + ", total EPS: "
+ + (float) count / ((float) spent / 1000)
+ );
}
}