-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from StrongestNumber9/test_fixes
Test fixes
- Loading branch information
Showing
7 changed files
with
499 additions
and
286 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,116 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<packaging>jar</packaging> | ||
<modelVersion>4.0.0</modelVersion> | ||
<artifactId>rlp_01</artifactId> | ||
<name>rlp_01</name> | ||
<description>A minimal RELP implementation.</description> | ||
<url>https://teragrep.com</url> | ||
<groupId>com.teragrep</groupId> | ||
<version>${revision}${sha1}${changelist}</version> | ||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<revision>0.0.1</revision> | ||
<changelist>-SNAPSHOT</changelist> | ||
<sha1/> | ||
<java.version>1.8</java.version> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
<junit.version>5.9.3</junit.version> | ||
</properties> | ||
<licenses> | ||
<license> | ||
<name>Apache License v2.0</name> | ||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> | ||
</license> | ||
</licenses> | ||
<developers> | ||
<developer> | ||
<name>Mikko Kortelainen</name> | ||
<email>[email protected]</email> | ||
<organization>Teragrep</organization> | ||
<organizationUrl>https://teragrep.com</organizationUrl> | ||
</developer> | ||
</developers> | ||
<scm> | ||
<connection>scm:git:https://github.com/teragrep/rlp_01.git</connection> | ||
<developerConnection>scm:git:git@github.com:teragrep/rlp_01.git</developerConnection> | ||
<url>https://github.com/teragrep/rlp_01/tree/master</url> | ||
</scm> | ||
|
||
<dependencies> | ||
<!-- tls-channel, without slf4j --> | ||
<dependency> | ||
<groupId>com.teragrep</groupId> | ||
<artifactId>tls_01</artifactId> | ||
<version>0.7.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-api</artifactId> | ||
<scope>test</scope> | ||
<version>${junit.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.vintage</groupId> | ||
<artifactId>junit-vintage-engine</artifactId> | ||
<scope>test</scope> | ||
<version>${junit.version}</version> | ||
</dependency> | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<packaging>jar</packaging> | ||
<modelVersion>4.0.0</modelVersion> | ||
<artifactId>rlp_01</artifactId> | ||
<name>rlp_01</name> | ||
<description>A minimal RELP implementation.</description> | ||
<url>https://teragrep.com</url> | ||
<groupId>com.teragrep</groupId> | ||
<version>${revision}${sha1}${changelist}</version> | ||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<revision>0.0.1</revision> | ||
<changelist>-SNAPSHOT</changelist> | ||
<sha1/> | ||
<java.version>1.8</java.version> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
<junit.version>5.10.0</junit.version> | ||
<teragrep.tls_01.version>0.7.1</teragrep.tls_01.version> | ||
</properties> | ||
|
||
<licenses> | ||
<license> | ||
<name>Apache License v2.0</name> | ||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> | ||
</license> | ||
</licenses> | ||
|
||
<developers> | ||
<developer> | ||
<name>Mikko Kortelainen</name> | ||
<email>[email protected]</email> | ||
<organization>Teragrep</organization> | ||
<organizationUrl>https://teragrep.com</organizationUrl> | ||
</developer> | ||
</developers> | ||
|
||
<scm> | ||
<connection>scm:git:https://github.com/teragrep/rlp_01.git</connection> | ||
<developerConnection>scm:git:git@github.com:teragrep/rlp_01.git</developerConnection> | ||
<url>https://github.com/teragrep/rlp_01/tree/master</url> | ||
</scm> | ||
|
||
<dependencies> | ||
<!-- tls-channel, without slf4j --> | ||
<dependency> | ||
<groupId>com.teragrep</groupId> | ||
<artifactId>tls_01</artifactId> | ||
<version>${teragrep.tls_01.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-api</artifactId> | ||
<scope>test</scope> | ||
<version>${junit.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.vintage</groupId> | ||
<artifactId>junit-vintage-engine</artifactId> | ||
<scope>test</scope> | ||
<version>${junit.version}</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<directory>${project.basedir}/target</directory> | ||
<finalName>rlp_01</finalName> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.11.0</version> | ||
<configuration> | ||
<compilerArgument>-Xlint:all</compilerArgument> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-enforcer-plugin</artifactId> | ||
<version>3.3.0</version> | ||
<executions> | ||
<execution> | ||
<id>enforce</id> | ||
<phase>none</phase> | ||
</execution> | ||
<execution> | ||
<id>enforce-maven</id> | ||
<goals> | ||
<goal>enforce</goal> | ||
</goals> | ||
<configuration> | ||
<rules> | ||
<requireMavenVersion> | ||
<version>3.2.5</version> | ||
</requireMavenVersion> | ||
</rules> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<rules> | ||
<requireJavaVersion> | ||
<version>1.8</version> | ||
</requireJavaVersion> | ||
</rules> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-source-plugin</artifactId> | ||
<version>2.2.1</version> | ||
<version>3.2.1</version> | ||
<executions> | ||
<execution> | ||
<id>attach-sources</id> | ||
|
@@ -86,7 +123,7 @@ | |
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-javadoc-plugin</artifactId> | ||
<version>2.9.1</version> | ||
<version>3.4.1</version> | ||
<executions> | ||
<execution> | ||
<id>attach-javadocs</id> | ||
|
@@ -100,18 +137,18 @@ | |
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>2.22.2</version> | ||
<configuration> | ||
<parallel>all</parallel> | ||
<useUnlimitedThreads>true</useUnlimitedThreads> | ||
</configuration> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>3.0.0-M7</version> | ||
<configuration> | ||
<parallel>all</parallel> | ||
<useUnlimitedThreads>true</useUnlimitedThreads> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-failsafe-plugin</artifactId> | ||
<version>3.0.0-M5</version> | ||
<version>3.1.2</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
|
@@ -122,17 +159,17 @@ | |
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-deploy-plugin</artifactId> | ||
<version>2.8.2</version> | ||
<configuration> | ||
<skip>false</skip> | ||
</configuration> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-deploy-plugin</artifactId> | ||
<version>3.0.0</version> | ||
<configuration> | ||
<skip>false</skip> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>flatten-maven-plugin</artifactId> | ||
<version>1.1.0</version> | ||
<version>1.3.0</version> | ||
<configuration> | ||
<updatePomFile>true</updatePomFile> | ||
<flattenMode>resolveCiFriendliesOnly</flattenMode> | ||
|
@@ -158,13 +195,13 @@ | |
</build> | ||
<profiles> | ||
<profile> | ||
<id>publish-maven-central</id> | ||
<id>publish-maven-central</id> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-gpg-plugin</artifactId> | ||
<version>1.6</version> | ||
<version>3.0.1</version> | ||
<executions> | ||
<execution> | ||
<id>sign-artifacts</id> | ||
|
@@ -196,7 +233,7 @@ | |
</distributionManagement> | ||
</profile> | ||
<profile> | ||
<id>publish-github-packages</id> | ||
<id>publish-github-packages</id> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/* | ||
Java Reliable Event Logging Protocol Library RLP-01 | ||
Copyright (C) 2021, 2022 Suomen Kanuuna Oy | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package com.teragrep.rlp_01; | ||
|
||
import java.nio.ByteBuffer; | ||
import java.nio.charset.StandardCharsets; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class CodeTest { | ||
|
||
@Test | ||
public void testCode200() { | ||
String message = "200 OK"; | ||
int len = message.length(); | ||
ByteBuffer buffer = ByteBuffer.allocateDirect(len); | ||
buffer.put(message.getBytes(StandardCharsets.UTF_8)); | ||
buffer.flip(); | ||
RelpFrameRX frame = new RelpFrameRX(2, RelpCommand.SYSLOG, len, buffer); | ||
Assertions.assertEquals(200, frame.getResponseCode(), "Got wrong response code"); | ||
} | ||
|
||
@Test | ||
public void testCode500() { | ||
String message = "500 NOK"; | ||
int len = message.length(); | ||
ByteBuffer buffer = ByteBuffer.allocateDirect(len); | ||
buffer.put(message.getBytes(StandardCharsets.UTF_8)); | ||
buffer.flip(); | ||
RelpFrameRX frame = new RelpFrameRX(2, RelpCommand.SYSLOG, len, buffer); | ||
Assertions.assertEquals(500, frame.getResponseCode(), "Got wrong response code"); | ||
} | ||
|
||
@Test | ||
public void testCode123() { | ||
String message = "123 OK"; | ||
int len = message.length(); | ||
ByteBuffer buffer = ByteBuffer.allocateDirect(len); | ||
buffer.put(message.getBytes(StandardCharsets.UTF_8)); | ||
buffer.flip(); | ||
RelpFrameRX frame = new RelpFrameRX(2, RelpCommand.SYSLOG, len, buffer); | ||
Assertions.assertEquals(123, frame.getResponseCode(), "Got wrong response code"); | ||
} | ||
|
||
@Test | ||
public void testCodeEmpty() { | ||
String message = ""; | ||
int len = 0; | ||
ByteBuffer buffer = ByteBuffer.allocateDirect(len); | ||
buffer.put(message.getBytes(StandardCharsets.UTF_8)); | ||
buffer.flip(); | ||
Assertions.assertThrows(IllegalArgumentException.class, () -> { | ||
RelpFrameRX frame = new RelpFrameRX(2, RelpCommand.SYSLOG, len, buffer); | ||
frame.getResponseCode(); | ||
}); | ||
} | ||
|
||
@Test | ||
public void testCodeNoCode() { | ||
String message = " "; | ||
int len = message.length(); | ||
ByteBuffer buffer = ByteBuffer.allocateDirect(len); | ||
buffer.put(message.getBytes(StandardCharsets.UTF_8)); | ||
buffer.flip(); | ||
Assertions.assertThrows(IllegalArgumentException.class, () -> { | ||
RelpFrameRX frame = new RelpFrameRX(2, RelpCommand.SYSLOG, len, buffer); | ||
frame.getResponseCode(); | ||
}); | ||
} | ||
|
||
@Test | ||
public void testCode2000() { | ||
String message = "2000 OK"; | ||
int len = message.length(); | ||
ByteBuffer buffer = ByteBuffer.allocateDirect(len); | ||
buffer.put(message.getBytes(StandardCharsets.UTF_8)); | ||
buffer.flip(); | ||
Assertions.assertThrows(IllegalArgumentException.class, () -> { | ||
RelpFrameRX frame = new RelpFrameRX(2, RelpCommand.SYSLOG, len, buffer); | ||
frame.getResponseCode(); | ||
}); | ||
} | ||
} |
Oops, something went wrong.