Skip to content

Commit 5c6fbab

Browse files
authored
Merge pull request #60 from Marcono1234/junit5
Convert tests to JUnit 5 & refactor tests
2 parents b7a9e7d + a7532a0 commit 5c6fbab

14 files changed

+289
-274
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
*.iml
2+
/.idea
23
*.ipr
34
*.iws
45
*.log

VERSION.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
1.2.0 (not yet released)
22

3+
#60: Convert tests to JUnit 5 & refactor tests
4+
(contributed by @Marcono1234)
35
#61: Prevent user code from subclassing `UnsafeChunkEncoder`
46
(contributed by @Marcono1234)
57
- Updated `oss-parent` dep to latest (v72)

pom.xml

Lines changed: 91 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<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">
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
34
<modelVersion>4.0.0</modelVersion>
45
<!-- 13-Mar-2017, tatu: use FasterXML oss-parent over sonatype's, more
56
likely to get settings that work for releases
67
-->
78
<parent>
8-
<groupId>com.fasterxml</groupId>
9-
<artifactId>oss-parent</artifactId>
10-
<version>72</version>
9+
<groupId>com.fasterxml</groupId>
10+
<artifactId>oss-parent</artifactId>
11+
<version>72</version>
1112
</parent>
1213
<groupId>com.ning</groupId>
1314
<artifactId>compress-lzf</artifactId>
1415
<name>Compress-LZF</name>
1516
<version>1.2.0-SNAPSHOT</version>
1617
<packaging>bundle</packaging>
17-
<description>
18-
Compression codec for LZF encoding for particularly encoding/decoding, with reasonable compression.
19-
Compressor is basic Lempel-Ziv codec, without Huffman (deflate/gzip) or statistical post-encoding.
20-
See "http://oldhome.schmorp.de/marc/liblzf.html" for more on original LZF package.
18+
<description>
19+
Compression codec for LZF encoding for particularly encoding/decoding, with reasonable compression.
20+
Compressor is basic Lempel-Ziv codec, without Huffman (deflate/gzip) or statistical post-encoding.
21+
See "http://oldhome.schmorp.de/marc/liblzf.html" for more on original LZF package.
2122
</description>
2223
<url>https://github.com/ning/compress</url>
2324
<scm>
2425
<connection>scm:git:[email protected]:ning/compress.git</connection>
2526
<developerConnection>scm:git:[email protected]:ning/compress.git</developerConnection>
2627
<url>https://github.com/ning/compress</url>
27-
<tag>compress-lzf-1.1</tag>
28+
<tag>HEAD</tag>
2829
</scm>
2930
<issueManagement>
3031
<url>https://github.com/ning/compress/issues</url>
@@ -41,14 +42,14 @@ See "http://oldhome.schmorp.de/marc/liblzf.html" for more on original LZF packag
4142
</developer>
4243
</developers>
4344
<contributors>
44-
<contributor>
45-
<name>Jon Hartlaub</name>
46-
<email>[email protected]</email>
47-
</contributor>
48-
<contributor>
49-
<name>Cédrik Lime</name>
50-
<email>[email protected]</email>
51-
</contributor>
45+
<contributor>
46+
<name>Jon Hartlaub</name>
47+
<email>[email protected]</email>
48+
</contributor>
49+
<contributor>
50+
<name>Cédrik Lime</name>
51+
<email>[email protected]</email>
52+
</contributor>
5253
</contributors>
5354
<licenses>
5455
<license>
@@ -57,23 +58,34 @@ See "http://oldhome.schmorp.de/marc/liblzf.html" for more on original LZF packag
5758
<distribution>repo</distribution>
5859
</license>
5960
</licenses>
61+
62+
<dependencyManagement>
63+
<dependencies>
64+
<dependency>
65+
<groupId>org.junit</groupId>
66+
<artifactId>junit-bom</artifactId>
67+
<version>${version.junit5}</version>
68+
<type>pom</type>
69+
<scope>import</scope>
70+
</dependency>
71+
</dependencies>
72+
</dependencyManagement>
6073
<dependencies>
6174
<dependency>
62-
<groupId>org.testng</groupId>
63-
<artifactId>testng</artifactId>
64-
<version>7.5.1</version>
65-
<type>jar</type>
75+
<groupId>org.junit.jupiter</groupId>
76+
<artifactId>junit-jupiter</artifactId>
6677
<scope>test</scope>
6778
</dependency>
6879
</dependencies>
80+
6981
<build>
7082
<defaultGoal>install</defaultGoal>
7183
<plugins>
72-
<plugin>
73-
<groupId>org.sonatype.central</groupId>
74-
<artifactId>central-publishing-maven-plugin</artifactId>
75-
</plugin>
76-
<plugin>
84+
<plugin>
85+
<groupId>org.sonatype.central</groupId>
86+
<artifactId>central-publishing-maven-plugin</artifactId>
87+
</plugin>
88+
<plugin>
7789
<groupId>org.apache.maven.plugins</groupId>
7890
<artifactId>maven-compiler-plugin</artifactId>
7991
<!-- 1.6 since 0.9.7 -->
@@ -89,7 +101,6 @@ See "http://oldhome.schmorp.de/marc/liblzf.html" for more on original LZF packag
89101
<artifactId>maven-javadoc-plugin</artifactId>
90102
<configuration>
91103
<source>1.8</source>
92-
<target>1.8</target>
93104
<encoding>UTF-8</encoding>
94105
<links>
95106
<link>https://docs.oracle.com/javase/8/docs/api/</link>
@@ -109,62 +120,62 @@ See "http://oldhome.schmorp.de/marc/liblzf.html" for more on original LZF packag
109120
<groupId>org.apache.maven.plugins</groupId>
110121
<artifactId>maven-release-plugin</artifactId>
111122
<configuration>
112-
<mavenExecutorId>forked-path</mavenExecutorId>
123+
<mavenExecutorId>forked-path</mavenExecutorId>
113124
</configuration>
114125
</plugin>
115126
<!-- Plus, let's make jars OSGi bundles as well -->
116127
<plugin>
117-
<groupId>org.apache.felix</groupId>
118-
<artifactId>maven-bundle-plugin</artifactId>
119-
<extensions>true</extensions>
120-
<configuration>
121-
<instructions><!-- note: artifact id, name, version and description use defaults (which are fine) -->
122-
<Bundle-Vendor>http://ning.com</Bundle-Vendor>
123-
<!-- if using high-perf decoder: -->
124-
<Import-Package>
125-
sun.misc;resolution:=optional, *
126-
</Import-Package>
127-
<Private-Package>
128-
com.ning.compress.lzf.impl
129-
</Private-Package>
130-
<!-- Export-Package default: set of packages in local Java sources, excluding the default package '.' and any packages containing 'impl' or 'internal' -->
131-
<!-- 06-Jan-2021, tatu: Commented out, I think, since bundle plugin can figure it out? -->
132-
<!--Export-Package>
133-
com.ning.compress,
134-
com.ning.compress.gzip,
135-
com.ning.compress.lzf,
136-
com.ning.compress.lzf.parallel,
137-
com.ning.compress.lzf.util
138-
</Export-Package-->
139-
<Main-Class>com.ning.compress.lzf.LZF</Main-Class>
140-
</instructions>
141-
</configuration>
142-
</plugin>
128+
<groupId>org.apache.felix</groupId>
129+
<artifactId>maven-bundle-plugin</artifactId>
130+
<extensions>true</extensions>
131+
<configuration>
132+
<instructions><!-- note: artifact id, name, version and description use defaults (which are fine) -->
133+
<Bundle-Vendor>http://ning.com</Bundle-Vendor>
134+
<!-- if using high-perf decoder: -->
135+
<Import-Package>
136+
sun.misc;resolution:=optional, *
137+
</Import-Package>
138+
<Private-Package>
139+
com.ning.compress.lzf.impl
140+
</Private-Package>
141+
<!-- Export-Package default: set of packages in local Java sources, excluding the default package '.' and any packages containing 'impl' or 'internal' -->
142+
<!-- 06-Jan-2021, tatu: Commented out, I think, since bundle plugin can figure it out? -->
143+
<!--Export-Package>
144+
com.ning.compress,
145+
com.ning.compress.gzip,
146+
com.ning.compress.lzf,
147+
com.ning.compress.lzf.parallel,
148+
com.ning.compress.lzf.util
149+
</Export-Package-->
150+
<Main-Class>com.ning.compress.lzf.LZF</Main-Class>
151+
</instructions>
152+
</configuration>
153+
</plugin>
143154

144-
<!-- 06-Jan-2021, tatu: Add rudimentary JDK9+ module info. To build with JDK 8
145-
will have to use `moduleInfoFile` which isn't great but will have to do
146-
-->
147-
<plugin>
148-
<groupId>org.moditect</groupId>
149-
<artifactId>moditect-maven-plugin</artifactId>
150-
<executions>
151-
<execution>
152-
<id>add-module-infos</id>
153-
<phase>package</phase>
154-
<goals>
155-
<goal>add-module-info</goal>
156-
</goals>
157-
<configuration>
158-
<overwriteExistingFiles>true</overwriteExistingFiles>
159-
<module>
160-
<moduleInfoFile>src/moditect/module-info.java</moduleInfoFile>
161-
</module>
162-
</configuration>
163-
</execution>
164-
</executions>
165-
</plugin>
155+
<!-- 06-Jan-2021, tatu: Add rudimentary JDK9+ module info. To build with JDK 8
156+
will have to use `moduleInfoFile` which isn't great but will have to do
157+
-->
158+
<plugin>
159+
<groupId>org.moditect</groupId>
160+
<artifactId>moditect-maven-plugin</artifactId>
161+
<executions>
162+
<execution>
163+
<id>add-module-infos</id>
164+
<phase>package</phase>
165+
<goals>
166+
<goal>add-module-info</goal>
167+
</goals>
168+
<configuration>
169+
<overwriteExistingFiles>true</overwriteExistingFiles>
170+
<module>
171+
<moduleInfoFile>src/moditect/module-info.java</moduleInfoFile>
172+
</module>
173+
</configuration>
174+
</execution>
175+
</executions>
176+
</plugin>
166177

167-
<!-- EVEN BETTER; make executable! -->
178+
<!-- EVEN BETTER; make executable! -->
168179

169180
<!-- 08-Sep-2014, tatu: except, doesn't quite work yet. Sigh.
170181
<plugin>
@@ -208,7 +219,7 @@ com.ning.compress.lzf.util
208219
<programFile>lzf</programFile>
209220
<flags>-Xmx200m</flags>
210221
</configuration>
211-
222+
212223
<executions>
213224
<execution>
214225
<phase>package</phase>
@@ -220,8 +231,10 @@ com.ning.compress.lzf.util
220231
</plugin>
221232
-->
222233

234+
223235
</plugins>
224236
</build>
237+
225238
<profiles>
226239
<profile>
227240
<id>release-sign-artifacts</id>

src/test/java/com/ning/compress/gzip/TestGzipStreams.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
package com.ning.compress.gzip;
22

33
import java.io.*;
4+
import java.nio.charset.StandardCharsets;
45
import java.util.zip.*;
56

6-
import org.testng.Assert;
7-
import org.testng.annotations.Test;
8-
97
import com.ning.compress.BaseForTests;
8+
import org.junit.jupiter.api.Test;
9+
10+
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
1011

1112
public class TestGzipStreams extends BaseForTests
1213
{
1314
private final static String INPUT_STR = "Some somewhat short text string -- but enough repetition to overcome shortness of input";
1415
private final static byte[] INPUT_BYTES;
1516
static {
1617
try {
17-
INPUT_BYTES = INPUT_STR.getBytes("UTF-8");
18+
INPUT_BYTES = INPUT_STR.getBytes(StandardCharsets.UTF_8);
1819
} catch (Exception e) {
1920
throw new RuntimeException(e);
2021
}
@@ -33,7 +34,7 @@ public void testReusableInputStreams() throws IOException
3334
byte[] raw = bytes.toByteArray();
3435
OptimizedGZIPInputStream re = new OptimizedGZIPInputStream(new ByteArrayInputStream(raw));
3536
byte[] b = _readAll(re);
36-
Assert.assertEquals(INPUT_BYTES, b);
37+
assertArrayEquals(INPUT_BYTES, b);
3738
re.close();
3839
}
3940

@@ -48,7 +49,7 @@ public void testReusableOutputStreams() throws IOException
4849

4950
byte[] raw = bytes.toByteArray();
5051
byte[] b = _readAll(new GZIPInputStream(new ByteArrayInputStream(raw)));
51-
Assert.assertEquals(INPUT_BYTES, b);
52+
assertArrayEquals(INPUT_BYTES, b);
5253
}
5354

5455
private byte[] _readAll(InputStream in) throws IOException

src/test/java/com/ning/compress/gzip/TestGzipUncompressor.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
import java.io.*;
44
import java.util.Random;
55

6-
import org.testng.Assert;
7-
import org.testng.annotations.Test;
8-
96
import com.ning.compress.BaseForTests;
107
import com.ning.compress.DataHandler;
118
import com.ning.compress.UncompressorOutputStream;
9+
import org.junit.jupiter.api.Test;
10+
11+
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
1212

1313
public class TestGzipUncompressor extends BaseForTests
1414
{
15-
@Test
15+
@Test
1616
public void testSimpleSmall1by1() throws IOException
1717
{
1818
byte[] fluff = constructFluff(4000);
@@ -25,8 +25,8 @@ public void testSimpleSmall1by1() throws IOException
2525
}
2626
uncomp.complete();
2727
byte[] result = co.getBytes();
28-
29-
Assert.assertEquals(fluff, result);
28+
29+
assertArrayEquals(fluff, result);
3030
}
3131

3232
@Test
@@ -41,7 +41,7 @@ public void testSimpleSmallAsChunk() throws IOException
4141
uncomp.feedCompressedData(comp, 0, comp.length);
4242
uncomp.complete();
4343
byte[] result = co.getBytes();
44-
Assert.assertEquals(fluff, result);
44+
assertArrayEquals(fluff, result);
4545
}
4646

4747
@Test
@@ -61,8 +61,8 @@ public void testSimpleBiggerVarLength() throws IOException
6161
}
6262
uncomp.complete();
6363
byte[] result = co.getBytes();
64-
65-
Assert.assertEquals(fluff, result);
64+
65+
assertArrayEquals(fluff, result);
6666
}
6767

6868
@Test
@@ -77,8 +77,8 @@ public void testSimpleBiggerOneChunk() throws IOException
7777
uncomp.feedCompressedData(comp, 0, comp.length);
7878
uncomp.complete();
7979
byte[] result = co.getBytes();
80-
81-
Assert.assertEquals(fluff, result);
80+
81+
assertArrayEquals(fluff, result);
8282
}
8383

8484
@Test
@@ -91,8 +91,8 @@ public void testSimpleBiggerAsStream() throws IOException
9191
out.write(comp, 0, comp.length);
9292
out.close();
9393
byte[] result = co.getBytes();
94-
95-
Assert.assertEquals(fluff, result);
94+
95+
assertArrayEquals(fluff, result);
9696
}
9797

9898
/*

0 commit comments

Comments
 (0)