You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2026/02/01 11:23:30 UTC
(maven-shared-utils) branch junit5x updated (cd4e05f -> 00335b4)
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a change to branch junit5x
in repository https://gitbox.apache.org/repos/asf/maven-shared-utils.git
discard cd4e05f Convert to JUnit 5
add 6babffb Bump org.apache.maven.shared:maven-shared-components from 45 to 46 (#357)
add 9a802f5 Bump org.apache.maven.shared:maven-shared-components from 46 to 47 (#358)
new 00335b4 Convert tests to JUnit 5
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (cd4e05f)
\
N -- N -- N refs/heads/junit5x (00335b4)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
pom.xml | 11 +---
.../maven/shared/utils/cli/CommandLineUtils.java | 6 +-
.../apache/maven/shared/utils/io/FileUtils.java | 1 -
.../maven/shared/utils/logging/MessageUtils.java | 13 ++--
.../maven/shared/utils/xml/Xpp3DomBuilder.java | 1 -
src/site/site.xml | 2 +-
.../apache/maven/shared/utils/StringUtilsTest.java | 7 ++-
.../maven/shared/utils/io/FileUtilsTest.java | 70 +++++++++++-----------
.../apache/maven/shared/utils/io/IOUtilTest.java | 7 ++-
9 files changed, 57 insertions(+), 61 deletions(-)
(maven-shared-utils) 01/01: Convert tests to JUnit 5
Posted by sl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch junit5x
in repository https://gitbox.apache.org/repos/asf/maven-shared-utils.git
commit 00335b4b0056375b42283f59c17cbdfa4286ec43
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Sat Dec 27 02:25:47 2025 +0100
Convert tests to JUnit 5
---
pom.xml | 16 -
.../maven/shared/utils/cli/CommandLineUtils.java | 6 +-
.../apache/maven/shared/utils/io/FileUtils.java | 1 -
.../maven/shared/utils/logging/MessageUtils.java | 13 +-
.../maven/shared/utils/xml/Xpp3DomBuilder.java | 1 -
src/site/site.xml | 2 +-
.../org/apache/maven/shared/utils/CaseTest.java | 8 +-
.../java/org/apache/maven/shared/utils/OsTest.java | 1 +
.../apache/maven/shared/utils/PathToolTest.java | 17 +-
.../maven/shared/utils/PropertyUtilsTest.java | 75 +-
.../apache/maven/shared/utils/StringUtilsTest.java | 889 ++++++++--------
.../maven/shared/utils/XmlStreamReaderTest.java | 47 +-
.../shared/utils/cli/CommandLineUtilsTest.java | 11 +-
.../shared/utils/cli/StreamPollFeederTest.java | 3 +-
.../shared/utils/cli/shell/BourneShellTest.java | 3 +-
.../ReflectionValueExtractorTest.java | 30 +-
.../shared/utils/io/DirectoryScannerTest.java | 13 +-
.../maven/shared/utils/io/FileUtilsTest.java | 291 +++---
.../apache/maven/shared/utils/io/IOUtilTest.java | 1105 ++++++++++----------
.../maven/shared/utils/io/SelectorUtilsTest.java | 2 +-
.../utils/logging/AnsiMessageBuilderTest.java | 21 +-
.../shared/utils/logging/MessageUtilsTest.java | 17 +-
.../shared/utils/xml/PrettyPrintXmlWriterTest.java | 59 +-
.../maven/shared/utils/xml/XmlWriterUtilTest.java | 23 +-
.../maven/shared/utils/xml/Xpp3DomBuilderTest.java | 72 +-
.../maven/shared/utils/xml/pull/Xpp3DomTest.java | 30 +-
26 files changed, 1303 insertions(+), 1453 deletions(-)
diff --git a/pom.xml b/pom.xml
index 8deec23..e09ce3d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -66,16 +66,6 @@
<mavenVersion>3.2.5</mavenVersion>
</properties>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>hamcrest-core</artifactId>
- <version>3.0</version>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
@@ -95,12 +85,6 @@
<artifactId>commons-io</artifactId>
<version>2.21.0</version>
</dependency>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>hamcrest</artifactId>
- <version>3.0</version>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
diff --git a/src/main/java/org/apache/maven/shared/utils/cli/CommandLineUtils.java b/src/main/java/org/apache/maven/shared/utils/cli/CommandLineUtils.java
index 96714b4..04f5cd6 100644
--- a/src/main/java/org/apache/maven/shared/utils/cli/CommandLineUtils.java
+++ b/src/main/java/org/apache/maven/shared/utils/cli/CommandLineUtils.java
@@ -386,7 +386,7 @@ public abstract class CommandLineUtils {
final int inDoubleQuote = 2;
boolean inEscape = false;
int state = normal;
- final StringTokenizer tok = new StringTokenizer(toProcess, "\"\' \\", true);
+ final StringTokenizer tok = new StringTokenizer(toProcess, "\"' \\", true);
List<String> tokens = new ArrayList<>();
StringBuilder current = new StringBuilder();
@@ -394,7 +394,7 @@ public abstract class CommandLineUtils {
String nextTok = tok.nextToken();
switch (state) {
case inQuote:
- if ("\'".equals(nextTok)) {
+ if ("'".equals(nextTok)) {
if (inEscape) {
current.append(nextTok);
inEscape = false;
@@ -420,7 +420,7 @@ public abstract class CommandLineUtils {
}
break;
default:
- if ("\'".equals(nextTok)) {
+ if ("'".equals(nextTok)) {
if (inEscape) {
inEscape = false;
current.append(nextTok);
diff --git a/src/main/java/org/apache/maven/shared/utils/io/FileUtils.java b/src/main/java/org/apache/maven/shared/utils/io/FileUtils.java
index 007b855..1996e0b 100644
--- a/src/main/java/org/apache/maven/shared/utils/io/FileUtils.java
+++ b/src/main/java/org/apache/maven/shared/utils/io/FileUtils.java
@@ -443,7 +443,6 @@ public class FileUtils {
@Deprecated
public static void fileDelete(@Nonnull String fileName) {
File file = new File(fileName);
- //noinspection ResultOfMethodCallIgnored
deleteLegacyStyle(file);
}
diff --git a/src/main/java/org/apache/maven/shared/utils/logging/MessageUtils.java b/src/main/java/org/apache/maven/shared/utils/logging/MessageUtils.java
index 7f2f4be..24b727b 100644
--- a/src/main/java/org/apache/maven/shared/utils/logging/MessageUtils.java
+++ b/src/main/java/org/apache/maven/shared/utils/logging/MessageUtils.java
@@ -171,16 +171,13 @@ public class MessageUtils {
public static void registerShutdownHook() {
if (JANSI && shutdownHook == null) {
// No shutdown hook registered yet.
- shutdownHook = new Thread() {
- @Override
- public void run() {
- synchronized (STARTUP_SHUTDOWN_MONITOR) {
- while (AnsiConsole.isInstalled()) {
- doSystemUninstall();
- }
+ shutdownHook = new Thread(() -> {
+ synchronized (STARTUP_SHUTDOWN_MONITOR) {
+ while (AnsiConsole.isInstalled()) {
+ doSystemUninstall();
}
}
- };
+ });
Runtime.getRuntime().addShutdownHook(shutdownHook);
}
}
diff --git a/src/main/java/org/apache/maven/shared/utils/xml/Xpp3DomBuilder.java b/src/main/java/org/apache/maven/shared/utils/xml/Xpp3DomBuilder.java
index 0936218..aeadbb2 100644
--- a/src/main/java/org/apache/maven/shared/utils/xml/Xpp3DomBuilder.java
+++ b/src/main/java/org/apache/maven/shared/utils/xml/Xpp3DomBuilder.java
@@ -219,7 +219,6 @@ public class Xpp3DomBuilder {
}
private void appendToTopValue(String toAppend) {
- // noinspection MismatchedQueryAndUpdateOfStringBuilder
StringBuilder stringBuilder = values.get(values.size() - 1);
stringBuilder.append(toAppend);
}
diff --git a/src/site/site.xml b/src/site/site.xml
index e607a00..f035df0 100644
--- a/src/site/site.xml
+++ b/src/site/site.xml
@@ -28,7 +28,7 @@ under the License.
<item name="Source Xref" href="xref/index.html"/>
<!--item name="FAQ" href="faq.html"/-->
<!-- According to https://issues.apache.org/jira/browse/MNGSITE-152 -->
- <item name="License" href="http://www.apache.org/licenses/"/>
+ <item name="License" href="https://www.apache.org/licenses/"/>
<item name="Download" href="download.html"/>
</menu>
diff --git a/src/test/java/org/apache/maven/shared/utils/CaseTest.java b/src/test/java/org/apache/maven/shared/utils/CaseTest.java
index 0e93ecd..c3c6ad9 100644
--- a/src/test/java/org/apache/maven/shared/utils/CaseTest.java
+++ b/src/test/java/org/apache/maven/shared/utils/CaseTest.java
@@ -40,18 +40,18 @@ public class CaseTest {
/** common ASCII 'i' */
@SuppressWarnings("ConstantName")
- private static final char DOTTED_i = '\u0069';
+ private static final char DOTTED_i = 'i';
/** common ASCII 'I' */
@SuppressWarnings("ConstantName")
- private static final char DOTLESS_I = '\u0049';
+ private static final char DOTLESS_I = 'I';
/** turkish dotless i = ı */
@SuppressWarnings("ConstantName")
- private static final char DOTLESS_i = '\u0131';
+ private static final char DOTLESS_i = 'ı';
/** turkish dotted I = İ */
- private static final char DOTTED_I = '\u0130';
+ private static final char DOTTED_I = 'İ';
/** http://en.wikipedia.org/wiki/Dot_(diacritic) */
private static final char COMBINING_DOT_ABOVE = '\u0307';
diff --git a/src/test/java/org/apache/maven/shared/utils/OsTest.java b/src/test/java/org/apache/maven/shared/utils/OsTest.java
index b73238d..e524191 100644
--- a/src/test/java/org/apache/maven/shared/utils/OsTest.java
+++ b/src/test/java/org/apache/maven/shared/utils/OsTest.java
@@ -33,6 +33,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
*
* @author <a href="mailto:struberg@yahoo.de">Mark Struberg</a>
*/
+@SuppressWarnings("deprecation")
public class OsTest {
private String origOsName;
private String origOsArch;
diff --git a/src/test/java/org/apache/maven/shared/utils/PathToolTest.java b/src/test/java/org/apache/maven/shared/utils/PathToolTest.java
index 4cba8c0..3153765 100644
--- a/src/test/java/org/apache/maven/shared/utils/PathToolTest.java
+++ b/src/test/java/org/apache/maven/shared/utils/PathToolTest.java
@@ -18,30 +18,26 @@
*/
package org.apache.maven.shared.utils;
-import java.io.File;
-
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.io.TempDir;
+import org.junit.jupiter.api.condition.DisabledOnOs;
+import org.junit.jupiter.api.condition.EnabledOnOs;
+import org.junit.jupiter.api.condition.OS;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assumptions.assumeTrue;
/**
* Test the {@link PathTool} class.
*
* @author <a href="mailto:struberg@yahoo.de">Mark Struberg</a>
*/
+@SuppressWarnings("deprecation")
public class PathToolTest {
- @TempDir
- private File tempFolder;
-
@Test
// Keep in sync with testGetRelativeFilePathWindows()
+ @DisabledOnOs(OS.WINDOWS)
public void testGetRelativeFilePathNonWindows() {
- assumeTrue(File.separatorChar == '/');
-
assertEquals("", PathTool.getRelativeFilePath(null, null));
assertEquals("", PathTool.getRelativeFilePath(null, "/usr/local/java/bin"));
@@ -65,9 +61,8 @@ public class PathToolTest {
@Test
// Keep in sync with testGetRelativeFilePathNonWindows()
+ @EnabledOnOs(OS.WINDOWS)
public void testGetRelativeFilePathWindows() {
- assumeTrue(File.separatorChar == '\\');
-
assertEquals("", PathTool.getRelativeFilePath(null, null));
assertEquals("", PathTool.getRelativeFilePath(null, "c:\\usr\\local\\java\\bin"));
diff --git a/src/test/java/org/apache/maven/shared/utils/PropertyUtilsTest.java b/src/test/java/org/apache/maven/shared/utils/PropertyUtilsTest.java
index 64dc97c..7f7e7f7 100644
--- a/src/test/java/org/apache/maven/shared/utils/PropertyUtilsTest.java
+++ b/src/test/java/org/apache/maven/shared/utils/PropertyUtilsTest.java
@@ -20,7 +20,6 @@ package org.apache.maven.shared.utils;
import java.io.ByteArrayInputStream;
import java.io.File;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -30,14 +29,14 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.net.URL;
+import java.nio.file.Files;
import java.util.Properties;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
public class PropertyUtilsTest {
@@ -51,72 +50,72 @@ public class PropertyUtilsTest {
@Test
@SuppressWarnings("deprecation")
// @ReproducesPlexusBug( "Should return null on error like url and file do" )
- public void loadNullInputStream() throws Exception {
- assertThat(PropertyUtils.loadProperties((InputStream) null), is(new Properties()));
+ public void loadNullInputStream() {
+ assertEquals(new Properties(), PropertyUtils.loadProperties((InputStream) null));
}
@Test
- public void loadOptionalNullInputStream() throws Exception {
- assertThat(PropertyUtils.loadOptionalProperties((InputStream) null), is(new Properties()));
+ public void loadOptionalNullInputStream() {
+ assertEquals(new Properties(), PropertyUtils.loadOptionalProperties((InputStream) null));
}
@Test
public void loadOptionalPropertiesIoException() throws Exception {
URL url = new URL("https://nonesuch12344.foo.bar.com");
- assertThat(PropertyUtils.loadOptionalProperties(url), is(new Properties()));
+ assertEquals(new Properties(), PropertyUtils.loadOptionalProperties(url));
}
@Test
@SuppressWarnings("deprecation")
- public void loadNullURL() throws Exception {
- assertThat(PropertyUtils.loadProperties((URL) null), nullValue(Properties.class));
+ public void loadNullURL() {
+ assertNull(PropertyUtils.loadProperties((URL) null));
}
@Test
- public void loadOptionalNullURL() throws Exception {
- assertThat(PropertyUtils.loadOptionalProperties((URL) null), is(new Properties()));
+ public void loadOptionalNullURL() {
+ assertEquals(new Properties(), PropertyUtils.loadOptionalProperties((URL) null));
}
@Test
@SuppressWarnings("deprecation")
- public void loadNullFile() throws Exception {
- assertThat(PropertyUtils.loadProperties((File) null), nullValue(Properties.class));
+ public void loadNullFile() {
+ assertNull(PropertyUtils.loadProperties((File) null));
}
@Test
- public void loadOptionalNullFile() throws Exception {
- assertThat(PropertyUtils.loadOptionalProperties((File) null), is(new Properties()));
+ public void loadOptionalNullFile() {
+ assertEquals(new Properties(), PropertyUtils.loadOptionalProperties((File) null));
}
@Test
@SuppressWarnings("deprecation")
- public void loadEmptyInputStream() throws Exception {
- assertThat(PropertyUtils.loadProperties(new ByteArrayInputStream(new byte[0])), is(new Properties()));
+ public void loadEmptyInputStream() {
+ assertEquals(new Properties(), PropertyUtils.loadProperties(new ByteArrayInputStream(new byte[0])));
- assertThat(PropertyUtils.loadOptionalProperties(new ByteArrayInputStream(new byte[0])), is(new Properties()));
+ assertEquals(new Properties(), PropertyUtils.loadOptionalProperties(new ByteArrayInputStream(new byte[0])));
}
@Test
@NeedsTemporaryFolder
@SuppressWarnings("deprecation")
public void loadEmptyFile() throws Exception {
- assertThat(PropertyUtils.loadProperties(newFile(tempFolder, "empty")), is(new Properties()));
- assertThat(PropertyUtils.loadOptionalProperties(newFile(tempFolder, "optional")), is(new Properties()));
+ assertEquals(new Properties(), PropertyUtils.loadProperties(newFile(tempFolder, "empty")));
+ assertEquals(new Properties(), PropertyUtils.loadOptionalProperties(newFile(tempFolder, "optional")));
}
@Test
@NeedsTemporaryFolder
@SuppressWarnings("deprecation")
public void loadEmptyURL() throws Exception {
- assertThat(
+ assertEquals(
+ new Properties(),
PropertyUtils.loadProperties(
- newFile(tempFolder, "empty").toURI().toURL()),
- is(new Properties()));
+ newFile(tempFolder, "empty").toURI().toURL()));
- assertThat(
+ assertEquals(
+ new Properties(),
PropertyUtils.loadOptionalProperties(
- newFile(tempFolder, "optional").toURI().toURL()),
- is(new Properties()));
+ newFile(tempFolder, "optional").toURI().toURL()));
}
@Test
@@ -125,11 +124,10 @@ public class PropertyUtilsTest {
Properties value = new Properties();
value.setProperty("a", "b");
- assertThat(PropertyUtils.loadProperties(new ByteArrayInputStream("a=b".getBytes("ISO-8859-1"))), is(value));
+ assertEquals(value, PropertyUtils.loadProperties(new ByteArrayInputStream("a=b".getBytes("ISO-8859-1"))));
- assertThat(
- PropertyUtils.loadOptionalProperties(new ByteArrayInputStream("a=b".getBytes("ISO-8859-1"))),
- is(value));
+ assertEquals(
+ value, PropertyUtils.loadOptionalProperties(new ByteArrayInputStream("a=b".getBytes("ISO-8859-1"))));
}
@Test
@@ -139,10 +137,10 @@ public class PropertyUtilsTest {
File valid = newFile(tempFolder, "valid");
Properties value = new Properties();
value.setProperty("a", "b");
- try (OutputStream out = new FileOutputStream(valid)) {
+ try (OutputStream out = Files.newOutputStream(valid.toPath())) {
value.store(out, "a test");
- assertThat(PropertyUtils.loadProperties(valid), is(value));
- assertThat(PropertyUtils.loadOptionalProperties(valid), is(value));
+ assertEquals(value, PropertyUtils.loadProperties(valid));
+ assertEquals(value, PropertyUtils.loadOptionalProperties(valid));
}
}
@@ -153,10 +151,11 @@ public class PropertyUtilsTest {
File valid = newFile(tempFolder, "valid");
Properties value = new Properties();
value.setProperty("a", "b");
- try (OutputStream out = new FileOutputStream(valid)) {
+ try (OutputStream out = Files.newOutputStream(valid.toPath())) {
value.store(out, "a test");
- assertThat(PropertyUtils.loadProperties(valid.toURI().toURL()), is(value));
- assertThat(PropertyUtils.loadOptionalProperties(valid.toURI().toURL()), is(value));
+ assertEquals(value, PropertyUtils.loadProperties(valid.toURI().toURL()));
+ assertEquals(
+ value, PropertyUtils.loadOptionalProperties(valid.toURI().toURL()));
}
}
diff --git a/src/test/java/org/apache/maven/shared/utils/StringUtilsTest.java b/src/test/java/org/apache/maven/shared/utils/StringUtilsTest.java
index e5c7124..7cfcf00 100644
--- a/src/test/java/org/apache/maven/shared/utils/StringUtilsTest.java
+++ b/src/test/java/org/apache/maven/shared/utils/StringUtilsTest.java
@@ -25,56 +25,55 @@ import java.util.Map;
import org.junit.jupiter.api.Test;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test the {@link StringUtils} class.
*
* @author <a href="mailto:struberg@yahoo.de">Mark Struberg</a>
*/
+@SuppressWarnings("deprecation")
public class StringUtilsTest {
@Test
public void testAbbreviateNPE() {
- assertThrows(NullPointerException.class, () -> assertThat(StringUtils.abbreviate(null, 10), nullValue()));
+ assertThrows(NullPointerException.class, () -> StringUtils.abbreviate(null, 10));
}
@Test
public void testAbbreviateMinLength() {
- assertThrows(
- IllegalArgumentException.class,
- () -> assertThat(StringUtils.abbreviate("This is a longtext", 3), is("T")));
+ assertThrows(IllegalArgumentException.class, () -> StringUtils.abbreviate("This is a longtext", 3));
}
@Test
public void testAbbreviate() {
- assertThat(StringUtils.abbreviate("This is a longtext", 10), is("This is..."));
+ assertEquals("This is...", StringUtils.abbreviate("This is a longtext", 10));
- assertThat(StringUtils.abbreviate("This is a longtext", 50), is("This is a longtext"));
+ assertEquals("This is a longtext", StringUtils.abbreviate("This is a longtext", 50));
}
@Test
public void testAbbreviateOffsetNPE() {
- assertThrows(NullPointerException.class, () -> assertThat(StringUtils.abbreviate(null, 10, 20), nullValue()));
+ assertThrows(NullPointerException.class, () -> StringUtils.abbreviate(null, 10, 20));
}
@Test
public void testAbbreviateOffsetMinLength() {
- assertThrows(
- IllegalArgumentException.class,
- () -> assertThat(StringUtils.abbreviate("This is a longtext", 10, 3), is("T")));
+ assertThrows(IllegalArgumentException.class, () -> StringUtils.abbreviate("This is a longtext", 10, 3));
}
@Test
public void testAbbreviateOffset() {
- assertThat(StringUtils.abbreviate("This is a longtext", 5, 10), is("...is a..."));
+ assertEquals("...is a...", StringUtils.abbreviate("This is a longtext", 5, 10));
- assertThat(StringUtils.abbreviate("This is a longtext", 10, 20), is("This is a longtext"));
+ assertEquals("This is a longtext", StringUtils.abbreviate("This is a longtext", 10, 20));
- assertThat(StringUtils.abbreviate("This is a longtext", 50, 20), is("This is a longtext"));
+ assertEquals("This is a longtext", StringUtils.abbreviate("This is a longtext", 50, 20));
}
@Test
@@ -84,40 +83,39 @@ public class StringUtilsTest {
@Test
public void testAddAndDeHump() {
- assertThat(StringUtils.addAndDeHump("lalala"), is("lalala"));
+ assertEquals("lalala", StringUtils.addAndDeHump("lalala"));
- assertThat(StringUtils.addAndDeHump("LaLaLa"), is("la-la-la"));
+ assertEquals("la-la-la", StringUtils.addAndDeHump("LaLaLa"));
- assertThat(StringUtils.addAndDeHump("ALLUPPER"), is("a-l-l-u-p-p-e-r"));
+ assertEquals("a-l-l-u-p-p-e-r", StringUtils.addAndDeHump("ALLUPPER"));
}
@Test
public void testCapitalise() {
- assertThat(StringUtils.capitalise(null), nullValue());
+ assertNull(StringUtils.capitalise(null));
- assertThat(StringUtils.capitalise("startBig"), is("StartBig"));
+ assertEquals("StartBig", StringUtils.capitalise("startBig"));
}
@Test
public void testCapitaliseAllWords() {
- assertThat(StringUtils.capitaliseAllWords(null), nullValue());
+ assertNull(StringUtils.capitaliseAllWords(null));
- assertThat(StringUtils.capitaliseAllWords("start all big"), is("Start All Big"));
+ assertEquals("Start All Big", StringUtils.capitaliseAllWords("start all big"));
}
@Test
public void testCapitalizeFirstLetterNPE() {
- assertThrows(
- NullPointerException.class, () -> assertThat(StringUtils.capitalizeFirstLetter(null), nullValue()));
+ assertThrows(NullPointerException.class, () -> assertNull(StringUtils.capitalizeFirstLetter(null)));
}
@Test
public void testCapitalizeFirstLetter() {
- assertThat(StringUtils.capitalizeFirstLetter("Dings"), is("Dings"));
+ assertEquals("Dings", StringUtils.capitalizeFirstLetter("Dings"));
- assertThat(StringUtils.capitalizeFirstLetter(" dings"), is(" dings"));
+ assertEquals(" dings", StringUtils.capitalizeFirstLetter(" dings"));
- assertThat(StringUtils.capitalizeFirstLetter("start all big"), is("Start all big"));
+ assertEquals("Start all big", StringUtils.capitalizeFirstLetter("start all big"));
}
@Test
@@ -127,11 +125,11 @@ public class StringUtilsTest {
@Test
public void testCenter() {
- assertThat(StringUtils.center("centerMe", 20), is(" centerMe "));
+ assertEquals(" centerMe ", StringUtils.center("centerMe", 20));
- assertThat(StringUtils.center("centerMe", 4), is("centerMe"));
+ assertEquals("centerMe", StringUtils.center("centerMe", 4));
- assertThat(StringUtils.center(" centerMe", 20), is(" centerMe "));
+ assertEquals(" centerMe ", StringUtils.center(" centerMe", 20));
}
@Test
@@ -141,11 +139,11 @@ public class StringUtilsTest {
@Test
public void testCenterDelim() {
- assertThat(StringUtils.center("centerMe", 20, "*"), is("******centerMe******"));
+ assertEquals("******centerMe******", StringUtils.center("centerMe", 20, "*"));
- assertThat(StringUtils.center("centerMe", 4, "*"), is("centerMe"));
+ assertEquals("centerMe", StringUtils.center("centerMe", 4, "*"));
- assertThat(StringUtils.center(" centerMe", 20, "*"), is("** centerMe**"));
+ assertEquals("** centerMe**", StringUtils.center(" centerMe", 20, "*"));
}
@Test
@@ -155,13 +153,13 @@ public class StringUtilsTest {
@Test
public void testChomp() {
- assertThat(StringUtils.chomp("dings"), is("dings"));
+ assertEquals("dings", StringUtils.chomp("dings"));
- assertThat(StringUtils.chomp("dings\n"), is("dings"));
+ assertEquals("dings", StringUtils.chomp("dings\n"));
- assertThat(StringUtils.chomp("dings\nbums"), is("dings"));
+ assertEquals("dings", StringUtils.chomp("dings\nbums"));
- assertThat(StringUtils.chomp("dings\nbums\ndongs"), is("dings\nbums"));
+ assertEquals("dings\nbums", StringUtils.chomp("dings\nbums\ndongs"));
}
@Test
@@ -171,13 +169,13 @@ public class StringUtilsTest {
@Test
public void testChompDelim() {
- assertThat(StringUtils.chomp("dings", "+"), is("dings"));
+ assertEquals("dings", StringUtils.chomp("dings", "+"));
- assertThat(StringUtils.chomp("dings+", "+"), is("dings"));
+ assertEquals("dings", StringUtils.chomp("dings+", "+"));
- assertThat(StringUtils.chomp("dings+bums", "+"), is("dings"));
+ assertEquals("dings", StringUtils.chomp("dings+bums", "+"));
- assertThat(StringUtils.chomp("dings+bums+dongs", "+"), is("dings+bums"));
+ assertEquals("dings+bums", StringUtils.chomp("dings+bums+dongs", "+"));
}
@Test
@@ -187,15 +185,15 @@ public class StringUtilsTest {
@Test
public void testChompLast() {
- assertThat(StringUtils.chompLast("dings"), is("dings"));
+ assertEquals("dings", StringUtils.chompLast("dings"));
- assertThat(StringUtils.chompLast("\n"), is(""));
+ assertEquals("", StringUtils.chompLast("\n"));
- assertThat(StringUtils.chompLast("dings\n"), is("dings"));
+ assertEquals("dings", StringUtils.chompLast("dings\n"));
- assertThat(StringUtils.chompLast("dings\nbums"), is("dings\nbums"));
+ assertEquals("dings\nbums", StringUtils.chompLast("dings\nbums"));
- assertThat(StringUtils.chompLast("dings\nbums\ndongs\n"), is("dings\nbums\ndongs"));
+ assertEquals("dings\nbums\ndongs", StringUtils.chompLast("dings\nbums\ndongs\n"));
}
@Test
@@ -205,15 +203,15 @@ public class StringUtilsTest {
@Test
public void testChompLastDelim() {
- assertThat(StringUtils.chompLast("dings", "+"), is("dings"));
+ assertEquals("dings", StringUtils.chompLast("dings", "+"));
- assertThat(StringUtils.chompLast("+", "+"), is(""));
+ assertEquals("", StringUtils.chompLast("+", "+"));
- assertThat(StringUtils.chompLast("dings+", "+"), is("dings"));
+ assertEquals("dings", StringUtils.chompLast("dings+", "+"));
- assertThat(StringUtils.chompLast("dings+bums", "+"), is("dings+bums"));
+ assertEquals("dings+bums", StringUtils.chompLast("dings+bums", "+"));
- assertThat(StringUtils.chompLast("dings+bums+dongs+", "+"), is("dings+bums+dongs"));
+ assertEquals("dings+bums+dongs", StringUtils.chompLast("dings+bums+dongs+", "+"));
}
@Test
@@ -223,15 +221,15 @@ public class StringUtilsTest {
@Test
public void testChop() {
- assertThat(StringUtils.chop("dings"), is("ding"));
+ assertEquals("ding", StringUtils.chop("dings"));
- assertThat(StringUtils.chop("x"), is(""));
+ assertEquals("", StringUtils.chop("x"));
- assertThat(StringUtils.chop("dings\n"), is("dings"));
+ assertEquals("dings", StringUtils.chop("dings\n"));
- assertThat(StringUtils.chop("dings\r\n"), is("dings"));
+ assertEquals("dings", StringUtils.chop("dings\r\n"));
- assertThat(StringUtils.chop("dings\n\r"), is("dings\n"));
+ assertEquals("dings\n", StringUtils.chop("dings\n\r"));
}
@Test
@@ -241,68 +239,69 @@ public class StringUtilsTest {
@Test
public void testChopNewline() {
- assertThat(StringUtils.chopNewline("dings"), is("dings"));
+ assertEquals("dings", StringUtils.chopNewline("dings"));
- assertThat(StringUtils.chopNewline("x"), is("x"));
+ assertEquals("x", StringUtils.chopNewline("x"));
- assertThat(StringUtils.chopNewline("dings\n"), is("dings"));
+ assertEquals("dings", StringUtils.chopNewline("dings\n"));
- assertThat(StringUtils.chopNewline("dings\r\n"), is("dings"));
+ assertEquals("dings", StringUtils.chopNewline("dings\r\n"));
- assertThat(StringUtils.chopNewline("dings\n\r"), is("dings\n\r"));
+ assertEquals("dings\n\r", StringUtils.chopNewline("dings\n\r"));
}
@Test
public void testClean() {
- assertThat(StringUtils.clean(null), is(""));
+ assertEquals("", StringUtils.clean(null));
- assertThat(StringUtils.clean(" "), is(""));
+ assertEquals("", StringUtils.clean(" "));
- assertThat(StringUtils.clean(" c "), is("c"));
+ assertEquals("c", StringUtils.clean(" c "));
- assertThat(StringUtils.clean(" dings \n "), is("dings"));
+ assertEquals("dings", StringUtils.clean(" dings \n "));
}
@Test
public void testConcatenateNPE() {
- assertThrows(NullPointerException.class, () -> StringUtils.concatenate(null));
+ assertThrows(NullPointerException.class, () -> StringUtils.concatenate((Object) null));
}
@Test
public void testConcatenate() {
- assertThat(StringUtils.concatenate(new String[0]), is(""));
+ assertEquals("", StringUtils.concatenate());
- assertThat(StringUtils.concatenate(new String[] {"x"}), is("x"));
+ assertEquals("x", StringUtils.concatenate("x"));
- assertThat(StringUtils.concatenate(new String[] {"x", "y", "z"}), is("xyz"));
+ assertEquals("xyz", StringUtils.concatenate("x", "y", "z"));
}
+ @SuppressWarnings("ConstantValue")
@Test
public void testContainsString() {
- assertThat(StringUtils.contains(null, null), is(false));
+ assertFalse(StringUtils.contains(null, null));
- assertThat(StringUtils.contains(null, "string"), is(false));
+ assertFalse(StringUtils.contains(null, "string"));
- assertThat(StringUtils.contains("string", null), is(false));
+ assertFalse(StringUtils.contains("string", null));
- assertThat(StringUtils.contains("string", ""), is(true));
+ assertTrue(StringUtils.contains("string", ""));
- assertThat(StringUtils.contains("string", "in"), is(true));
+ assertTrue(StringUtils.contains("string", "in"));
- assertThat(StringUtils.contains("string", "IN"), is(false));
+ assertFalse(StringUtils.contains("string", "IN"));
}
@Test
public void testContainsChar() {
- assertThat(StringUtils.contains(null, 'c'), is(false));
+ assertFalse(StringUtils.contains(null, 'c'));
- assertThat(StringUtils.contains("string", "c"), is(false));
+ assertFalse(StringUtils.contains("string", "c"));
- assertThat(StringUtils.contains("string", ""), is(true));
+ assertTrue(StringUtils.contains("string", ""));
- assertThat(StringUtils.contains("string", "r"), is(true));
+ assertTrue(StringUtils.contains("string", "r"));
- assertThat(StringUtils.contains("string", "R"), is(false));
+ assertFalse(StringUtils.contains("string", "R"));
}
@Test
@@ -317,25 +316,25 @@ public class StringUtilsTest {
@Test
public void testCountMatches() {
- assertThat(StringUtils.countMatches(null, "is"), is(0));
+ assertEquals(0, StringUtils.countMatches(null, "is"));
- assertThat(StringUtils.countMatches("this is it", "is"), is(2));
+ assertEquals(2, StringUtils.countMatches("this is it", "is"));
- assertThat(StringUtils.countMatches("this is it", "notincluded"), is(0));
+ assertEquals(0, StringUtils.countMatches("this is it", "notincluded"));
}
@Test
public void testDefaultString() {
- assertThat(StringUtils.defaultString(null), is(""));
+ assertEquals("", StringUtils.defaultString(null));
- assertThat(StringUtils.defaultString("dings"), is("dings"));
+ assertEquals("dings", StringUtils.defaultString("dings"));
}
@Test
public void testDefaultStringDefaultValue() {
- assertThat(StringUtils.defaultString(null, "defaultValue"), is("defaultValue"));
+ assertEquals("defaultValue", StringUtils.defaultString(null, "defaultValue"));
- assertThat(StringUtils.defaultString("dings", "defaultValue"), is("dings"));
+ assertEquals("dings", StringUtils.defaultString("dings", "defaultValue"));
}
@Test
@@ -345,13 +344,13 @@ public class StringUtilsTest {
@Test
public void testDeleteWhitespace() {
- assertThat(StringUtils.deleteWhitespace(" \t \n"), is(""));
+ assertEquals("", StringUtils.deleteWhitespace(" \t \n"));
- assertThat(StringUtils.deleteWhitespace(" \t \b \n"), is("\b"));
+ assertEquals("\b", StringUtils.deleteWhitespace(" \t \b \n"));
- assertThat(StringUtils.deleteWhitespace("dings"), is("dings"));
+ assertEquals("dings", StringUtils.deleteWhitespace("dings"));
- assertThat(StringUtils.deleteWhitespace("\n dings \t "), is("dings"));
+ assertEquals("dings", StringUtils.deleteWhitespace("\n dings \t "));
}
@Test
@@ -371,11 +370,11 @@ public class StringUtilsTest {
@Test
public void testDifference() {
- assertThat(StringUtils.difference("this", "another"), is("another"));
+ assertEquals("another", StringUtils.difference("this", "another"));
- assertThat(StringUtils.difference("I am human", "I am a robot"), is("a robot"));
+ assertEquals("a robot", StringUtils.difference("I am human", "I am a robot"));
- assertThat(StringUtils.difference("I am human", "I AM a robot"), is("AM a robot"));
+ assertEquals("AM a robot", StringUtils.difference("I am human", "I AM a robot"));
}
@Test
@@ -395,54 +394,54 @@ public class StringUtilsTest {
@Test
public void testDifferenceAt() {
- assertThat(StringUtils.differenceAt("this", "another"), is(0));
+ assertEquals(0, StringUtils.differenceAt("this", "another"));
- assertThat(StringUtils.differenceAt("I am human", "I am a robot"), is(5));
+ assertEquals(5, StringUtils.differenceAt("I am human", "I am a robot"));
- assertThat(StringUtils.differenceAt("I am human", "I AM a robot"), is(2));
+ assertEquals(2, StringUtils.differenceAt("I am human", "I AM a robot"));
}
@Test
public void testEndsWithIgnoreCase() {
- assertThat(StringUtils.endsWithIgnoreCase(null, null), is(false));
+ assertFalse(StringUtils.endsWithIgnoreCase(null, null));
- assertThat(StringUtils.endsWithIgnoreCase(null, "string"), is(false));
+ assertFalse(StringUtils.endsWithIgnoreCase(null, "string"));
- assertThat(StringUtils.endsWithIgnoreCase("string", null), is(false));
+ assertFalse(StringUtils.endsWithIgnoreCase("string", null));
- assertThat(StringUtils.endsWithIgnoreCase("string", "ing"), is(true));
+ assertTrue(StringUtils.endsWithIgnoreCase("string", "ing"));
- assertThat(StringUtils.endsWithIgnoreCase("string", "a string"), is(false));
+ assertFalse(StringUtils.endsWithIgnoreCase("string", "a string"));
- assertThat(StringUtils.endsWithIgnoreCase("string", "str"), is(false));
+ assertFalse(StringUtils.endsWithIgnoreCase("string", "str"));
}
@Test
public void testEquals() {
- assertThat(StringUtils.equals(null, null), is(true));
+ assertTrue(StringUtils.equals(null, null));
- assertThat(StringUtils.equals("x", null), is(false));
+ assertFalse(StringUtils.equals("x", null));
- assertThat(StringUtils.equals(null, "x"), is(false));
+ assertFalse(StringUtils.equals(null, "x"));
- assertThat(StringUtils.equals("X", "x"), is(false));
+ assertFalse(StringUtils.equals("X", "x"));
- assertThat(StringUtils.equals("dings", "dings"), is(true));
+ assertTrue(StringUtils.equals("dings", "dings"));
}
@Test
public void testEqualsIgnoreCase() {
- assertThat(StringUtils.equalsIgnoreCase(null, null), is(true));
+ assertTrue(StringUtils.equalsIgnoreCase(null, null));
- assertThat(StringUtils.equalsIgnoreCase("x", null), is(false));
+ assertFalse(StringUtils.equalsIgnoreCase("x", null));
- assertThat(StringUtils.equalsIgnoreCase(null, "x"), is(false));
+ assertFalse(StringUtils.equalsIgnoreCase(null, "x"));
- assertThat(StringUtils.equalsIgnoreCase("X", "x"), is(true));
+ assertTrue(StringUtils.equalsIgnoreCase("X", "x"));
- assertThat(StringUtils.equalsIgnoreCase("dings", "dings"), is(true));
+ assertTrue(StringUtils.equalsIgnoreCase("dings", "dings"));
- assertThat(StringUtils.equalsIgnoreCase("dings", "diNGs"), is(true));
+ assertTrue(StringUtils.equalsIgnoreCase("dings", "diNGs"));
}
@Test
@@ -452,23 +451,23 @@ public class StringUtilsTest {
@Test
public void testEscape() {
- assertThat(StringUtils.escape("dings"), is("dings"));
+ assertEquals("dings", StringUtils.escape("dings"));
- assertThat(StringUtils.escape("dings\tbums"), is("dings\\tbums"));
+ assertEquals("dings\\tbums", StringUtils.escape("dings\tbums"));
- assertThat(StringUtils.escape("dings\nbums"), is("dings\\nbums"));
+ assertEquals("dings\\nbums", StringUtils.escape("dings\nbums"));
}
@Test
public void testEscape2() {
- assertThat(StringUtils.escape(null, null, '#'), nullValue());
+ assertNull(StringUtils.escape(null, null, '#'));
- assertThat(StringUtils.escape("dings", new char[] {'\t', '\b'}, '+'), is("dings"));
+ assertEquals("dings", StringUtils.escape("dings", new char[] {'\t', '\b'}, '+'));
- assertThat(StringUtils.escape("dings\tbums", new char[] {'\t', '\b'}, '+'), is("dings+\tbums"));
+ assertEquals("dings+\tbums", StringUtils.escape("dings\tbums", new char[] {'\t', '\b'}, '+'));
- assertThat(StringUtils.escape("dings\nbums", new char[] {'\t', '\b'}, '+'), is("dings\nbums"));
- assertThat(StringUtils.escape("dings\bbums", new char[] {'\t', '\b'}, '+'), is("dings+\bbums"));
+ assertEquals("dings\nbums", StringUtils.escape("dings\nbums", new char[] {'\t', '\b'}, '+'));
+ assertEquals("dings+\bbums", StringUtils.escape("dings\bbums", new char[] {'\t', '\b'}, '+'));
}
@Test
@@ -488,52 +487,46 @@ public class StringUtilsTest {
@Test
public void testGetChomp() {
- assertThat(StringUtils.getChomp("dings-bums", "-"), is("-bums"));
+ assertEquals("-bums", StringUtils.getChomp("dings-bums", "-"));
- assertThat(StringUtils.getChomp("dings-", "-"), is("-"));
+ assertEquals("-", StringUtils.getChomp("dings-", "-"));
- assertThat(StringUtils.getChomp("dingsbums", "-"), is(""));
+ assertEquals("", StringUtils.getChomp("dingsbums", "-"));
}
@Test
public void testGetNestedStringNPE() {
- assertThrows(
- NullPointerException.class,
- () -> assertThat(StringUtils.getNestedString(" +dings+ ", null), nullValue()));
+ assertThrows(NullPointerException.class, () -> StringUtils.getNestedString(" +dings+ ", null));
}
@Test
public void testGetNestedString() {
- assertThat(StringUtils.getNestedString(null, null), nullValue());
+ assertNull(StringUtils.getNestedString(null, null));
- assertThat(StringUtils.getNestedString(" +dings+ ", "+"), is("dings"));
+ assertEquals("dings", StringUtils.getNestedString(" +dings+ ", "+"));
- assertThat(StringUtils.getNestedString(" +dings+ ", "not"), nullValue());
+ assertNull(StringUtils.getNestedString(" +dings+ ", "not"));
}
@Test
public void testGetNestedString2NPE1() {
- assertThrows(
- NullPointerException.class,
- () -> assertThat(StringUtils.getNestedString(" +dings+ ", null, null), nullValue()));
+ assertThrows(NullPointerException.class, () -> StringUtils.getNestedString(" +dings+ ", null, null));
}
@Test
public void testGetNestedString2NPE2() {
- assertThrows(
- NullPointerException.class,
- () -> assertThat(StringUtils.getNestedString(" +dings+ ", null, "neither"), nullValue()));
+ assertThrows(NullPointerException.class, () -> StringUtils.getNestedString(" +dings+ ", null, "neither"));
}
@Test
public void testGetNestedString2() {
- assertThat(StringUtils.getNestedString(null, null, null), nullValue());
+ assertNull(StringUtils.getNestedString(null, null, null));
- assertThat(StringUtils.getNestedString(" +dings+ ", "not", null), nullValue());
+ assertNull(StringUtils.getNestedString(" +dings+ ", "not", null));
- assertThat(StringUtils.getNestedString(" +dings- ", "+", "-"), is("dings"));
+ assertEquals("dings", StringUtils.getNestedString(" +dings- ", "+", "-"));
- assertThat(StringUtils.getNestedString(" +dings+ ", "not", "neither"), nullValue());
+ assertNull(StringUtils.getNestedString(" +dings+ ", "not", "neither"));
}
@Test
@@ -548,20 +541,20 @@ public class StringUtilsTest {
@Test
public void testGetPrechomp() {
- assertThat(StringUtils.getPrechomp("dings bums dongs", "bums"), is("dings bums"));
+ assertEquals("dings bums", StringUtils.getPrechomp("dings bums dongs", "bums"));
- assertThat(StringUtils.getPrechomp("dings bums dongs", "non"), is(""));
+ assertEquals("", StringUtils.getPrechomp("dings bums dongs", "non"));
}
@Test
public void testIndexOfAny() {
- assertThat(StringUtils.indexOfAny(null, null), is(-1));
+ assertEquals(-1, StringUtils.indexOfAny(null, null));
- assertThat(StringUtils.indexOfAny("dings", null), is(-1));
+ assertEquals(-1, StringUtils.indexOfAny("dings", null));
- assertThat(StringUtils.indexOfAny(null, new String[] {}), is(-1));
+ assertEquals(-1, StringUtils.indexOfAny(null, new String[] {}));
- assertThat(StringUtils.indexOfAny("dings bums dongs", new String[] {"knuff", "bums"}), is(6));
+ assertEquals(6, StringUtils.indexOfAny("dings bums dongs", new String[] {"knuff", "bums"}));
}
@Test
@@ -577,185 +570,184 @@ public class StringUtilsTest {
@Test
public void testInterpolate() {
Map<String, String> variables = new HashMap<>();
- assertThat(
- StringUtils.interpolate("This ${text} will get replaced", variables),
- is("This ${text} will get replaced"));
+ assertEquals(
+ "This ${text} will get replaced", StringUtils.interpolate("This ${text} will get replaced", variables));
variables.put("text", "with a special content");
- assertThat(
- StringUtils.interpolate("This ${text} will get replaced", variables),
- is("This with a special content will get replaced"));
+ assertEquals(
+ "This with a special content will get replaced",
+ StringUtils.interpolate("This ${text} will get replaced", variables));
}
@Test
public void testIsAlpha() {
- assertThat(StringUtils.isAlpha(null), is(false));
+ assertFalse(StringUtils.isAlpha(null));
- assertThat(StringUtils.isAlpha("2"), is(false));
+ assertFalse(StringUtils.isAlpha("2"));
- assertThat(StringUtils.isAlpha("asvsdfSDF"), is(true));
+ assertTrue(StringUtils.isAlpha("asvsdfSDF"));
- assertThat(StringUtils.isAlpha("asvsdfSDF \t "), is(false));
+ assertFalse(StringUtils.isAlpha("asvsdfSDF \t "));
- assertThat(StringUtils.isAlpha("435afsafd3!"), is(false));
+ assertFalse(StringUtils.isAlpha("435afsafd3!"));
}
@Test
public void testIsAlphaSpace() {
- assertThat(StringUtils.isAlphaSpace(null), is(false));
+ assertFalse(StringUtils.isAlphaSpace(null));
- assertThat(StringUtils.isAlphaSpace("2"), is(false));
+ assertFalse(StringUtils.isAlphaSpace("2"));
- assertThat(StringUtils.isAlphaSpace("asvsdfSDF"), is(true));
+ assertTrue(StringUtils.isAlphaSpace("asvsdfSDF"));
- assertThat(StringUtils.isAlphaSpace("asvsdfSDF "), is(true));
+ assertTrue(StringUtils.isAlphaSpace("asvsdfSDF "));
- assertThat(StringUtils.isAlphaSpace("asvsdfSDF \t "), is(false));
+ assertFalse(StringUtils.isAlphaSpace("asvsdfSDF \t "));
- assertThat(StringUtils.isAlphaSpace("435afsafd3!"), is(false));
+ assertFalse(StringUtils.isAlphaSpace("435afsafd3!"));
}
@Test
public void testIsAlphanumeric() {
- assertThat(StringUtils.isAlphanumeric(null), is(false));
+ assertFalse(StringUtils.isAlphanumeric(null));
- assertThat(StringUtils.isAlphanumeric("2"), is(true));
+ assertTrue(StringUtils.isAlphanumeric("2"));
- assertThat(StringUtils.isAlphanumeric("asvsdfSDF"), is(true));
+ assertTrue(StringUtils.isAlphanumeric("asvsdfSDF"));
- assertThat(StringUtils.isAlphanumeric("asvsdfSDF "), is(false));
+ assertFalse(StringUtils.isAlphanumeric("asvsdfSDF "));
- assertThat(StringUtils.isAlphanumeric("asvsdfSDF \t "), is(false));
+ assertFalse(StringUtils.isAlphanumeric("asvsdfSDF \t "));
- assertThat(StringUtils.isAlphanumeric("435afsafd3!"), is(false));
+ assertFalse(StringUtils.isAlphanumeric("435afsafd3!"));
- assertThat(StringUtils.isAlphanumeric("435afsafd3"), is(true));
+ assertTrue(StringUtils.isAlphanumeric("435afsafd3"));
- assertThat(StringUtils.isAlphanumeric("435 "), is(false));
+ assertFalse(StringUtils.isAlphanumeric("435 "));
- assertThat(StringUtils.isAlphanumeric("435"), is(true));
+ assertTrue(StringUtils.isAlphanumeric("435"));
}
@Test
public void testIsAlphanumericSpace() {
- assertThat(StringUtils.isAlphanumericSpace(null), is(false));
+ assertFalse(StringUtils.isAlphanumericSpace(null));
- assertThat(StringUtils.isAlphanumericSpace("2"), is(true));
+ assertTrue(StringUtils.isAlphanumericSpace("2"));
- assertThat(StringUtils.isAlphanumericSpace("asvsdfSDF"), is(true));
+ assertTrue(StringUtils.isAlphanumericSpace("asvsdfSDF"));
- assertThat(StringUtils.isAlphanumericSpace("asvsdfSDF "), is(true));
+ assertTrue(StringUtils.isAlphanumericSpace("asvsdfSDF "));
- assertThat(StringUtils.isAlphanumericSpace("asvsdfSDF \t "), is(false));
+ assertFalse(StringUtils.isAlphanumericSpace("asvsdfSDF \t "));
- assertThat(StringUtils.isAlphanumericSpace("435afsafd3!"), is(false));
+ assertFalse(StringUtils.isAlphanumericSpace("435afsafd3!"));
- assertThat(StringUtils.isAlphanumericSpace("435afsafd3"), is(true));
+ assertTrue(StringUtils.isAlphanumericSpace("435afsafd3"));
- assertThat(StringUtils.isAlphanumericSpace("435 "), is(true));
+ assertTrue(StringUtils.isAlphanumericSpace("435 "));
- assertThat(StringUtils.isAlphanumericSpace("435"), is(true));
+ assertTrue(StringUtils.isAlphanumericSpace("435"));
}
@Test
public void testIsBlank() {
- assertThat(StringUtils.isBlank(null), is(true));
+ assertTrue(StringUtils.isBlank(null));
- assertThat(StringUtils.isBlank("xx"), is(false));
+ assertFalse(StringUtils.isBlank("xx"));
- assertThat(StringUtils.isBlank("xx "), is(false));
+ assertFalse(StringUtils.isBlank("xx "));
- assertThat(StringUtils.isBlank(" "), is(true));
+ assertTrue(StringUtils.isBlank(" "));
- assertThat(StringUtils.isBlank(" \t "), is(true));
+ assertTrue(StringUtils.isBlank(" \t "));
- assertThat(StringUtils.isBlank(" \n "), is(true));
+ assertTrue(StringUtils.isBlank(" \n "));
}
@Test
public void testEmpty() {
- assertThat(StringUtils.isEmpty(null), is(true));
+ assertTrue(StringUtils.isEmpty(null));
- assertThat(StringUtils.isEmpty("xx"), is(false));
+ assertFalse(StringUtils.isEmpty("xx"));
- assertThat(StringUtils.isEmpty("xx "), is(false));
+ assertFalse(StringUtils.isEmpty("xx "));
- assertThat(StringUtils.isEmpty(" "), is(true));
+ assertTrue(StringUtils.isEmpty(" "));
- assertThat(StringUtils.isEmpty(" \t "), is(true));
+ assertTrue(StringUtils.isEmpty(" \t "));
- assertThat(StringUtils.isEmpty(" \n "), is(true));
+ assertTrue(StringUtils.isEmpty(" \n "));
}
@Test
public void testNotBlank() {
- assertThat(StringUtils.isNotBlank(null), is(false));
+ assertFalse(StringUtils.isNotBlank(null));
- assertThat(StringUtils.isNotBlank("xx"), is(true));
+ assertTrue(StringUtils.isNotBlank("xx"));
- assertThat(StringUtils.isNotBlank("xx "), is(true));
+ assertTrue(StringUtils.isNotBlank("xx "));
- assertThat(StringUtils.isNotBlank(" "), is(false));
+ assertFalse(StringUtils.isNotBlank(" "));
- assertThat(StringUtils.isNotBlank(" \t "), is(false));
+ assertFalse(StringUtils.isNotBlank(" \t "));
- assertThat(StringUtils.isNotBlank(" \n "), is(false));
+ assertFalse(StringUtils.isNotBlank(" \n "));
}
@Test
public void testNotEmpty() {
- assertThat(StringUtils.isNotEmpty(null), is(false));
+ assertFalse(StringUtils.isNotEmpty(null));
- assertThat(StringUtils.isNotEmpty("xx"), is(true));
+ assertTrue(StringUtils.isNotEmpty("xx"));
- assertThat(StringUtils.isNotEmpty("xx "), is(true));
+ assertTrue(StringUtils.isNotEmpty("xx "));
- assertThat(StringUtils.isNotEmpty(" "), is(true));
+ assertTrue(StringUtils.isNotEmpty(" "));
- assertThat(StringUtils.isNotEmpty(""), is(false));
+ assertFalse(StringUtils.isNotEmpty(""));
- assertThat(StringUtils.isNotEmpty(" \t "), is(true));
+ assertTrue(StringUtils.isNotEmpty(" \t "));
- assertThat(StringUtils.isNotEmpty(" \n "), is(true));
+ assertTrue(StringUtils.isNotEmpty(" \n "));
}
@Test
public void testIsNumeric() {
- assertThat(StringUtils.isNumeric(null), is(false));
+ assertFalse(StringUtils.isNumeric(null));
- assertThat(StringUtils.isNumeric("2"), is(true));
+ assertTrue(StringUtils.isNumeric("2"));
- assertThat(StringUtils.isNumeric("asvsdfSDF"), is(false));
+ assertFalse(StringUtils.isNumeric("asvsdfSDF"));
- assertThat(StringUtils.isNumeric("asvsdfSDF "), is(false));
+ assertFalse(StringUtils.isNumeric("asvsdfSDF "));
- assertThat(StringUtils.isNumeric("asvsdfSDF \t "), is(false));
+ assertFalse(StringUtils.isNumeric("asvsdfSDF \t "));
- assertThat(StringUtils.isNumeric("435afsafd3!"), is(false));
+ assertFalse(StringUtils.isNumeric("435afsafd3!"));
- assertThat(StringUtils.isNumeric("435afsafd3"), is(false));
+ assertFalse(StringUtils.isNumeric("435afsafd3"));
- assertThat(StringUtils.isNumeric("435 "), is(false));
+ assertFalse(StringUtils.isNumeric("435 "));
- assertThat(StringUtils.isNumeric("435"), is(true));
+ assertTrue(StringUtils.isNumeric("435"));
}
@Test
public void testIsWhitespace() {
- assertThat(StringUtils.isWhitespace(null), is(false));
+ assertFalse(StringUtils.isWhitespace(null));
- assertThat(StringUtils.isWhitespace("xx"), is(false));
+ assertFalse(StringUtils.isWhitespace("xx"));
- assertThat(StringUtils.isWhitespace("xx "), is(false));
+ assertFalse(StringUtils.isWhitespace("xx "));
- assertThat(StringUtils.isWhitespace(" "), is(true));
+ assertTrue(StringUtils.isWhitespace(" "));
- assertThat(StringUtils.isWhitespace(""), is(true));
+ assertTrue(StringUtils.isWhitespace(""));
- assertThat(StringUtils.isWhitespace(" \t "), is(true));
+ assertTrue(StringUtils.isWhitespace(" \t "));
- assertThat(StringUtils.isWhitespace(" \n "), is(true));
+ assertTrue(StringUtils.isWhitespace(" \n "));
}
@Test
@@ -765,11 +757,11 @@ public class StringUtilsTest {
@Test
public void testJoinArray() {
- assertThat(StringUtils.join(new Object[0], null), is(""));
+ assertEquals("", StringUtils.join(new Object[0], null));
- assertThat(StringUtils.join(new Object[] {"a", "b", "c"}, null), is("abc"));
+ assertEquals("abc", StringUtils.join(new Object[] {"a", "b", "c"}, null));
- assertThat(StringUtils.join(new Object[] {"a", "b", "c"}, "__"), is("a__b__c"));
+ assertEquals("a__b__c", StringUtils.join(new Object[] {"a", "b", "c"}, "__"));
}
@Test
@@ -781,26 +773,26 @@ public class StringUtilsTest {
public void testJoinIterator() {
ArrayList<String> list = new ArrayList<>();
- assertThat(StringUtils.join(list.iterator(), null), is(""));
+ assertEquals(StringUtils.join(list.iterator(), null), "");
list.add("a");
list.add("b");
list.add("c");
- assertThat(StringUtils.join(list.iterator(), null), is("abc"));
+ assertEquals("abc", StringUtils.join(list.iterator(), null));
- assertThat(StringUtils.join(list.iterator(), "__"), is("a__b__c"));
+ assertEquals(StringUtils.join(list.iterator(), "__"), "a__b__c");
}
@Test
public void testLastIndexOfAny() {
- assertThat(StringUtils.lastIndexOfAny(null, null), is(-1));
+ assertEquals(-1, StringUtils.lastIndexOfAny(null, null));
- assertThat(StringUtils.lastIndexOfAny("dings", null), is(-1));
+ assertEquals(-1, StringUtils.lastIndexOfAny("dings", null));
- assertThat(StringUtils.lastIndexOfAny("dings bums boms", new String[] {"ms", " b"}), is(13));
+ assertEquals(13, StringUtils.lastIndexOfAny("dings bums boms", "ms", " b"));
- assertThat(StringUtils.lastIndexOfAny("dings bums boms", new String[] {"nix", "da"}), is(-1));
+ assertEquals(-1, StringUtils.lastIndexOfAny("dings bums boms", "nix", "da"));
}
@Test
@@ -810,13 +802,13 @@ public class StringUtilsTest {
@Test
public void testLeft() {
- assertThat(StringUtils.left(null, 4), nullValue());
+ assertNull(StringUtils.left(null, 4));
- assertThat(StringUtils.left("dingsbums", 4), is("ding"));
+ assertEquals("ding", StringUtils.left("dingsbums", 4));
- assertThat(StringUtils.left("dingsbums", 40), is("dingsbums"));
+ assertEquals("dingsbums", StringUtils.left("dingsbums", 40));
- assertThat(StringUtils.left("dingsbums", 0), is(""));
+ assertEquals("", StringUtils.left("dingsbums", 0));
}
@Test
@@ -826,11 +818,11 @@ public class StringUtilsTest {
@Test
public void testLeftPad1() {
- assertThat(StringUtils.leftPad("dings", 0), is("dings"));
+ assertEquals("dings", StringUtils.leftPad("dings", 0));
- assertThat(StringUtils.leftPad("dings", 2), is("dings"));
+ assertEquals("dings", StringUtils.leftPad("dings", 2));
- assertThat(StringUtils.leftPad("dings", 10), is(" dings"));
+ assertEquals(" dings", StringUtils.leftPad("dings", 10));
}
@Test
@@ -850,20 +842,20 @@ public class StringUtilsTest {
@Test
public void testLeftPad2() {
- assertThat(StringUtils.leftPad("dings", 0, "*"), is("dings"));
+ assertEquals("dings", StringUtils.leftPad("dings", 0, "*"));
- assertThat(StringUtils.leftPad("dings", 2, "*"), is("dings"));
+ assertEquals("dings", StringUtils.leftPad("dings", 2, "*"));
- assertThat(StringUtils.leftPad("dings", 10, "*"), is("*****dings"));
+ assertEquals("*****dings", StringUtils.leftPad("dings", 10, "*"));
}
@Test
public void testLowerCase() {
- assertThat(StringUtils.lowerCase(null), nullValue());
+ assertNull(StringUtils.lowerCase(null));
- assertThat(StringUtils.lowerCase("dinGSbuMS"), is("dingsbums"));
+ assertEquals("dingsbums", StringUtils.lowerCase("dinGSbuMS"));
- assertThat(StringUtils.lowerCase(""), is(""));
+ assertEquals("", StringUtils.lowerCase(""));
}
@Test
@@ -873,7 +865,7 @@ public class StringUtilsTest {
@Test
public void testLowerCaseFirstLetter() {
- assertThat(StringUtils.lowercaseFirstLetter("Dings Bums"), is("dings Bums"));
+ assertEquals("dings Bums", StringUtils.lowercaseFirstLetter("Dings Bums"));
}
@Test
@@ -888,11 +880,11 @@ public class StringUtilsTest {
@Test
public void testMid() {
- assertThat(StringUtils.mid(null, 0, 0), nullValue());
+ assertNull(StringUtils.mid(null, 0, 0));
- assertThat(StringUtils.mid("dings bums", 0, 0), is(""));
+ assertEquals("", StringUtils.mid("dings bums", 0, 0));
- assertThat(StringUtils.mid("dings bums", 3, 4), is("gs b"));
+ assertEquals("gs b", StringUtils.mid("dings bums", 3, 4));
}
@Test
@@ -912,9 +904,9 @@ public class StringUtilsTest {
@Test
public void testOverlayString() {
- assertThat(StringUtils.overlayString("dings", "bums", 0, 0), is("bumsdings"));
+ assertEquals("bumsdings", StringUtils.overlayString("dings", "bums", 0, 0));
- assertThat(StringUtils.overlayString("dings", "bums", 2, 4), is("dibumss"));
+ assertEquals("dibumss", StringUtils.overlayString("dings", "bums", 2, 4));
}
@Test
@@ -934,122 +926,116 @@ public class StringUtilsTest {
@Test
public void testPrechomp() {
- assertThat(StringUtils.prechomp("dings bums", " "), is("bums"));
+ assertEquals("bums", StringUtils.prechomp("dings bums", " "));
- assertThat(StringUtils.prechomp("dings bums", "nix"), is("dings bums"));
+ assertEquals("dings bums", StringUtils.prechomp("dings bums", "nix"));
}
@Test
public void testQuoteAndEscape1() {
- assertThat(StringUtils.quoteAndEscape(null, '+'), nullValue());
+ assertNull(StringUtils.quoteAndEscape(null, '+'));
- assertThat(StringUtils.quoteAndEscape("", '+'), is(""));
+ assertEquals("", StringUtils.quoteAndEscape("", '+'));
- assertThat(StringUtils.quoteAndEscape("abc", '"'), is("abc"));
+ assertEquals("abc", StringUtils.quoteAndEscape("abc", '"'));
- assertThat(StringUtils.quoteAndEscape("a\"bc", '"'), is("\"a\\\"bc\""));
+ assertEquals("\"a\\\"bc\"", StringUtils.quoteAndEscape("a\"bc", '"'));
- assertThat(StringUtils.quoteAndEscape("a\'bc", '\''), is("\'a\\'bc\'"));
+ assertEquals("'a\\'bc'", StringUtils.quoteAndEscape("a'bc", '\''));
- assertThat(StringUtils.quoteAndEscape("a\"bc", '\''), is("a\"bc"));
+ assertEquals("a\"bc", StringUtils.quoteAndEscape("a\"bc", '\''));
}
@Test
public void testQuoteAndEscape2() {
- assertThat(StringUtils.quoteAndEscape(null, '+', new char[] {'"'}), nullValue());
+ assertNull(StringUtils.quoteAndEscape(null, '+', new char[] {'"'}));
- assertThat(StringUtils.quoteAndEscape("", '+', new char[] {'"'}), is(""));
+ assertEquals("", StringUtils.quoteAndEscape("", '+', new char[] {'"'}));
- assertThat(StringUtils.quoteAndEscape("abc", '"', new char[] {'"'}), is("abc"));
+ assertEquals("abc", StringUtils.quoteAndEscape("abc", '"', new char[] {'"'}));
- assertThat(StringUtils.quoteAndEscape("a\"bc", '"', new char[] {'"'}), is("\"a\\\"bc\""));
+ assertEquals("\"a\\\"bc\"", StringUtils.quoteAndEscape("a\"bc", '"', new char[] {'"'}));
- assertThat(StringUtils.quoteAndEscape("a\'bc", '\'', new char[] {'"'}), is("\'a\\'bc\'"));
+ assertEquals("'a\\'bc'", StringUtils.quoteAndEscape("a'bc", '\'', new char[] {'"'}));
- assertThat(StringUtils.quoteAndEscape("a\"bc", '\'', new char[] {'\''}), is("a\"bc"));
+ assertEquals("a\"bc", StringUtils.quoteAndEscape("a\"bc", '\'', new char[] {'\''}));
- assertThat(StringUtils.quoteAndEscape("a\"bc", '\'', new char[] {'\'', '"'}), is("\'a\"bc\'"));
+ assertEquals("'a\"bc'", StringUtils.quoteAndEscape("a\"bc", '\'', new char[] {'\'', '"'}));
}
@Test
public void testQuoteAndEscape3() {
- assertThat(StringUtils.quoteAndEscape(null, '+', new char[] {'"'}, '\\', false), nullValue());
+ assertNull(StringUtils.quoteAndEscape(null, '+', new char[] {'"'}, '\\', false));
- assertThat(StringUtils.quoteAndEscape("", '+', new char[] {'"'}, '\\', false), is(""));
+ assertEquals("", StringUtils.quoteAndEscape("", '+', new char[] {'"'}, '\\', false));
- assertThat(StringUtils.quoteAndEscape("abc", '"', new char[] {'"'}, '\\', false), is("abc"));
+ assertEquals("abc", StringUtils.quoteAndEscape("abc", '"', new char[] {'"'}, '\\', false));
- assertThat(StringUtils.quoteAndEscape("a\"bc", '"', new char[] {'"'}, '\\', false), is("\"a\\\"bc\""));
+ assertEquals("\"a\\\"bc\"", StringUtils.quoteAndEscape("a\"bc", '"', new char[] {'"'}, '\\', false));
- assertThat(StringUtils.quoteAndEscape("a\'bc", '\'', new char[] {'"'}, '\\', false), is("a\'bc"));
+ assertEquals("a'bc", StringUtils.quoteAndEscape("a'bc", '\'', new char[] {'"'}, '\\', false));
- assertThat(StringUtils.quoteAndEscape("a\"bc", '\'', new char[] {'\''}, '\\', false), is("a\"bc"));
+ assertEquals("a\"bc", StringUtils.quoteAndEscape("a\"bc", '\'', new char[] {'\''}, '\\', false));
- assertThat(StringUtils.quoteAndEscape("a\"bc", '\'', new char[] {'\'', '"'}, '\\', false), is("\'a\\\"bc\'"));
+ assertEquals("'a\\\"bc'", StringUtils.quoteAndEscape("a\"bc", '\'', new char[] {'\'', '"'}, '\\', false));
// with force flag
- assertThat(StringUtils.quoteAndEscape(null, '+', new char[] {'"'}, '\\', true), nullValue());
+ assertNull(StringUtils.quoteAndEscape(null, '+', new char[] {'"'}, '\\', true));
- assertThat(StringUtils.quoteAndEscape("", '+', new char[] {'"'}, '\\', true), is("++"));
+ assertEquals("++", StringUtils.quoteAndEscape("", '+', new char[] {'"'}, '\\', true));
- assertThat(StringUtils.quoteAndEscape("abc", '"', new char[] {'"'}, '\\', true), is("\"abc\""));
+ assertEquals("\"abc\"", StringUtils.quoteAndEscape("abc", '"', new char[] {'"'}, '\\', true));
- assertThat(StringUtils.quoteAndEscape("a\"bc", '"', new char[] {'"'}, '\\', true), is("\"a\\\"bc\""));
+ assertEquals("\"a\\\"bc\"", StringUtils.quoteAndEscape("a\"bc", '"', new char[] {'"'}, '\\', true));
- assertThat(StringUtils.quoteAndEscape("a\'bc", '\'', new char[] {'"'}, '\\', true), is("\'a\'bc\'"));
+ assertEquals("'a'bc'", StringUtils.quoteAndEscape("a'bc", '\'', new char[] {'"'}, '\\', true));
- assertThat(StringUtils.quoteAndEscape("a\"bc", '\'', new char[] {'\''}, '\\', true), is("\'a\"bc\'"));
+ assertEquals("'a\"bc'", StringUtils.quoteAndEscape("a\"bc", '\'', new char[] {'\''}, '\\', true));
- assertThat(StringUtils.quoteAndEscape("a\"bc", '\'', new char[] {'\'', '"'}, '\\', true), is("\'a\\\"bc\'"));
+ assertEquals("'a\\\"bc'", StringUtils.quoteAndEscape("a\"bc", '\'', new char[] {'\'', '"'}, '\\', true));
}
@Test
public void testQuoteAndEscape4() {
- assertThat(StringUtils.quoteAndEscape(null, '+', new char[] {'"'}, new char[] {'"'}, '\\', false), nullValue());
+ assertNull(StringUtils.quoteAndEscape(null, '+', new char[] {'"'}, new char[] {'"'}, '\\', false));
- assertThat(StringUtils.quoteAndEscape("", '+', new char[] {'"'}, new char[] {'"'}, '\\', false), is(""));
+ assertEquals("", StringUtils.quoteAndEscape("", '+', new char[] {'"'}, new char[] {'"'}, '\\', false));
- assertThat(StringUtils.quoteAndEscape("abc", '"', new char[] {'"'}, new char[] {'"'}, '\\', false), is("abc"));
+ assertEquals("abc", StringUtils.quoteAndEscape("abc", '"', new char[] {'"'}, new char[] {'"'}, '\\', false));
- assertThat(
- StringUtils.quoteAndEscape("a\"bc", '"', new char[] {'"'}, new char[] {'"'}, '\\', false),
- is("\"a\\\"bc\""));
+ assertEquals(
+ "\"a\\\"bc\"",
+ StringUtils.quoteAndEscape("a\"bc", '"', new char[] {'"'}, new char[] {'"'}, '\\', false));
- assertThat(
- StringUtils.quoteAndEscape("a\'bc", '\'', new char[] {'"'}, new char[] {'"'}, '\\', false),
- is("a\'bc"));
+ assertEquals("a'bc", StringUtils.quoteAndEscape("a'bc", '\'', new char[] {'"'}, new char[] {'"'}, '\\', false));
- assertThat(
- StringUtils.quoteAndEscape("a\"bc", '\'', new char[] {'\''}, new char[] {'"'}, '\\', false),
- is("\'a\"bc\'"));
+ assertEquals(
+ "'a\"bc'", StringUtils.quoteAndEscape("a\"bc", '\'', new char[] {'\''}, new char[] {'"'}, '\\', false));
- assertThat(
- StringUtils.quoteAndEscape("\'a\"bc\'", '\'', new char[] {'\'', '"'}, new char[] {'"'}, '\\', false),
- is("\'a\"bc\'"));
+ assertEquals(
+ "'a\"bc'",
+ StringUtils.quoteAndEscape("'a\"bc'", '\'', new char[] {'\'', '"'}, new char[] {'"'}, '\\', false));
// with force flag
- assertThat(StringUtils.quoteAndEscape(null, '+', new char[] {'"'}, new char[] {'"'}, '\\', true), nullValue());
+ assertNull(StringUtils.quoteAndEscape(null, '+', new char[] {'"'}, new char[] {'"'}, '\\', true));
- assertThat(StringUtils.quoteAndEscape("", '+', new char[] {'"'}, new char[] {'"'}, '\\', true), is("++"));
+ assertEquals("++", StringUtils.quoteAndEscape("", '+', new char[] {'"'}, new char[] {'"'}, '\\', true));
- assertThat(
- StringUtils.quoteAndEscape("abc", '"', new char[] {'"'}, new char[] {'"'}, '\\', true), is("\"abc\""));
+ assertEquals("\"abc\"", StringUtils.quoteAndEscape("abc", '"', new char[] {'"'}, new char[] {'"'}, '\\', true));
- assertThat(
- StringUtils.quoteAndEscape("a\"bc", '"', new char[] {'"'}, new char[] {'"'}, '\\', true),
- is("\"a\\\"bc\""));
+ assertEquals(
+ "\"a\\\"bc\"",
+ StringUtils.quoteAndEscape("a\"bc", '"', new char[] {'"'}, new char[] {'"'}, '\\', true));
- assertThat(
- StringUtils.quoteAndEscape("a\'bc", '\'', new char[] {'"'}, new char[] {'"'}, '\\', true),
- is("\'a\'bc\'"));
+ assertEquals(
+ "'a'bc'", StringUtils.quoteAndEscape("a'bc", '\'', new char[] {'"'}, new char[] {'"'}, '\\', true));
- assertThat(
- StringUtils.quoteAndEscape("a\"bc", '\'', new char[] {'\''}, new char[] {'"'}, '\\', true),
- is("\'a\"bc\'"));
+ assertEquals(
+ "'a\"bc'", StringUtils.quoteAndEscape("a\"bc", '\'', new char[] {'\''}, new char[] {'"'}, '\\', true));
- assertThat(
- StringUtils.quoteAndEscape("a\"bc", '\'', new char[] {'\'', '"'}, new char[] {'"'}, '\\', true),
- is("\'a\\\"bc\'"));
+ assertEquals(
+ "'a\\\"bc'",
+ StringUtils.quoteAndEscape("a\"bc", '\'', new char[] {'\'', '"'}, new char[] {'"'}, '\\', true));
}
@Test
@@ -1069,11 +1055,11 @@ public class StringUtilsTest {
@Test
public void testRemoveAndHump() {
- assertThat(StringUtils.removeAndHump("dings", "bums"), is("Ding"));
+ assertEquals("Ding", StringUtils.removeAndHump("dings", "bums"));
- assertThat(StringUtils.removeAndHump("this-is-it", "-"), is("ThisIsIt"));
+ assertEquals("ThisIsIt", StringUtils.removeAndHump("this-is-it", "-"));
- assertThat(StringUtils.removeAndHump("THIS-IS-IT", "-"), is("THISISIT"));
+ assertEquals("THISISIT", StringUtils.removeAndHump("THIS-IS-IT", "-"));
}
@Test
@@ -1083,13 +1069,13 @@ public class StringUtilsTest {
@Test
public void testRemoveDuplicateWhitespace() {
- assertThat(StringUtils.removeDuplicateWhitespace("dings"), is("dings"));
+ assertEquals("dings", StringUtils.removeDuplicateWhitespace("dings"));
- assertThat(StringUtils.removeDuplicateWhitespace("dings bums"), is("dings bums"));
+ assertEquals("dings bums", StringUtils.removeDuplicateWhitespace("dings bums"));
- assertThat(StringUtils.removeDuplicateWhitespace("dings bums"), is("dings bums"));
+ assertEquals("dings bums", StringUtils.removeDuplicateWhitespace("dings bums"));
- assertThat(StringUtils.removeDuplicateWhitespace("dings \t bums"), is("dings bums"));
+ assertEquals("dings bums", StringUtils.removeDuplicateWhitespace("dings \t bums"));
}
@Test
@@ -1104,94 +1090,94 @@ public class StringUtilsTest {
@Test
public void testRepeat() {
- assertThat(StringUtils.repeat("dings", 0), is(""));
+ assertEquals("", StringUtils.repeat("dings", 0));
- assertThat(StringUtils.repeat("dings", 1), is("dings"));
+ assertEquals("dings", StringUtils.repeat("dings", 1));
- assertThat(StringUtils.repeat("dings", 3), is("dingsdingsdings"));
+ assertEquals("dingsdingsdings", StringUtils.repeat("dings", 3));
}
@Test
public void testReplaceChar() {
- assertThat(StringUtils.replace(null, 'i', 'o'), nullValue());
+ assertNull(StringUtils.replace(null, 'i', 'o'));
- assertThat(StringUtils.replace("dings", 'i', 'o'), is("dongs"));
+ assertEquals("dongs", StringUtils.replace("dings", 'i', 'o'));
- assertThat(StringUtils.replace("dingsbims", 'i', 'o'), is("dongsboms"));
+ assertEquals("dongsboms", StringUtils.replace("dingsbims", 'i', 'o'));
- assertThat(StringUtils.replace("dings", 'x', 'o'), is("dings"));
+ assertEquals("dings", StringUtils.replace("dings", 'x', 'o'));
}
@Test
public void testReplace2CharMax() {
- assertThat(StringUtils.replace(null, 'i', 'o', 0), nullValue());
+ assertNull(StringUtils.replace(null, 'i', 'o', 0));
- assertThat(StringUtils.replace("dingsibumsi", 'i', 'o', 3), is("dongsobumso"));
+ assertEquals("dongsobumso", StringUtils.replace("dingsibumsi", 'i', 'o', 3));
- assertThat(StringUtils.replace("dingsibumsi", 'i', 'o', 2), is("dongsobumsi"));
+ assertEquals("dongsobumsi", StringUtils.replace("dingsibumsi", 'i', 'o', 2));
- assertThat(StringUtils.replace("dingsibumsi", 'i', 'o', 0), is("dongsobumso"));
+ assertEquals("dongsobumso", StringUtils.replace("dingsibumsi", 'i', 'o', 0));
- assertThat(StringUtils.replace("dingsibumsi", 'i', 'o', -2), is("dongsobumso"));
+ assertEquals("dongsobumso", StringUtils.replace("dingsibumsi", 'i', 'o', -2));
- assertThat(StringUtils.replace("dings", 'x', 'o', 2), is("dings"));
+ assertEquals("dings", StringUtils.replace("dings", 'x', 'o', 2));
}
@Test
public void testReplaceString() {
- assertThat(StringUtils.replace(null, "in", "ox"), nullValue());
+ assertNull(StringUtils.replace(null, "in", "ox"));
- assertThat(StringUtils.replace("dings", "in", "ox"), is("doxgs"));
+ assertEquals("doxgs", StringUtils.replace("dings", "in", "ox"));
- assertThat(StringUtils.replace("dingsbins", "in", "ox"), is("doxgsboxs"));
+ assertEquals("doxgsboxs", StringUtils.replace("dingsbins", "in", "ox"));
- assertThat(StringUtils.replace("dings", "nin", "ox"), is("dings"));
+ assertEquals("dings", StringUtils.replace("dings", "nin", "ox"));
}
@Test
public void testReplace2StringMax() {
- assertThat(StringUtils.replace(null, "in", "ox", 0), nullValue());
+ assertNull(StringUtils.replace(null, "in", "ox", 0));
- assertThat(StringUtils.replace("dingsibumsi", "si", "xo", 3), is("dingxobumxo"));
+ assertEquals("dingxobumxo", StringUtils.replace("dingsibumsi", "si", "xo", 3));
- assertThat(StringUtils.replace("dingsibumsi", "si", "xo", 2), is("dingxobumxo"));
+ assertEquals("dingxobumxo", StringUtils.replace("dingsibumsi", "si", "xo", 2));
- assertThat(StringUtils.replace("dingsibumsi", "si", "xo", 1), is("dingxobumsi"));
+ assertEquals("dingxobumsi", StringUtils.replace("dingsibumsi", "si", "xo", 1));
- assertThat(StringUtils.replace("dingsibumsi", "si", "xo", 0), is("dingxobumxo"));
+ assertEquals("dingxobumxo", StringUtils.replace("dingsibumsi", "si", "xo", 0));
- assertThat(StringUtils.replace("dingsibumsi", "si", "xo", -2), is("dingxobumxo"));
+ assertEquals("dingxobumxo", StringUtils.replace("dingsibumsi", "si", "xo", -2));
- assertThat(StringUtils.replace("dings", "si", "xo", 2), is("dings"));
+ assertEquals("dings", StringUtils.replace("dings", "si", "xo", 2));
}
@Test
public void testReplaceOnceChar() {
- assertThat(StringUtils.replaceOnce(null, 'i', 'o'), nullValue());
+ assertNull(StringUtils.replaceOnce(null, 'i', 'o'));
- assertThat(StringUtils.replaceOnce("dingsibumsi", 'i', 'o'), is("dongsibumsi"));
+ assertEquals("dongsibumsi", StringUtils.replaceOnce("dingsibumsi", 'i', 'o'));
- assertThat(StringUtils.replaceOnce("dings", 'x', 'o'), is("dings"));
+ assertEquals("dings", StringUtils.replaceOnce("dings", 'x', 'o'));
}
@Test
public void testReplaceOnceString() {
- assertThat(StringUtils.replaceOnce(null, "in", "ox"), nullValue());
+ assertNull(StringUtils.replaceOnce(null, "in", "ox"));
- assertThat(StringUtils.replaceOnce("dingsibumsi", "si", "xo"), is("dingxobumsi"));
+ assertEquals("dingxobumsi", StringUtils.replaceOnce("dingsibumsi", "si", "xo"));
- assertThat(StringUtils.replaceOnce("dings", "si", "xo"), is("dings"));
+ assertEquals("dings", StringUtils.replaceOnce("dings", "si", "xo"));
}
@Test
public void testReverse() {
- assertThat(StringUtils.reverse(null), nullValue());
+ assertNull(StringUtils.reverse(null));
- assertThat(StringUtils.reverse(""), is(""));
+ assertEquals("", StringUtils.reverse(""));
- assertThat(StringUtils.reverse("dings"), is("sgnid"));
+ assertEquals("sgnid", StringUtils.reverse("dings"));
- assertThat(StringUtils.reverse(" dings "), is(" sgnid "));
+ assertEquals(" sgnid ", StringUtils.reverse(" dings "));
}
@Test
@@ -1206,15 +1192,15 @@ public class StringUtilsTest {
@Test
public void testReverseDelimitedString() {
- assertThat(StringUtils.reverseDelimitedString("dings", null), is("dings"));
+ assertEquals("dings", StringUtils.reverseDelimitedString("dings", null));
- assertThat(StringUtils.reverseDelimitedString("", " "), is(""));
+ assertEquals("", StringUtils.reverseDelimitedString("", " "));
- assertThat(StringUtils.reverseDelimitedString("dings", " "), is("dings"));
+ assertEquals("dings", StringUtils.reverseDelimitedString("dings", " "));
- assertThat(StringUtils.reverseDelimitedString(" dings ", " "), is("dings"));
+ assertEquals("dings", StringUtils.reverseDelimitedString(" dings ", " "));
- assertThat(StringUtils.reverseDelimitedString("dings bums", " "), is("bums dings"));
+ assertEquals("bums dings", StringUtils.reverseDelimitedString("dings bums", " "));
}
@Test
@@ -1229,13 +1215,13 @@ public class StringUtilsTest {
@Test
public void testRight() {
- assertThat(StringUtils.right(null, 0), nullValue());
+ assertNull(StringUtils.right(null, 0));
- assertThat(StringUtils.right("dings", 0), is(""));
+ assertEquals("", StringUtils.right("dings", 0));
- assertThat(StringUtils.right("dings", 3), is("ngs"));
+ assertEquals("ngs", StringUtils.right("dings", 3));
- assertThat(StringUtils.right("dings ", 3), is("gs "));
+ assertEquals("gs ", StringUtils.right("dings ", 3));
}
@Test
@@ -1245,11 +1231,11 @@ public class StringUtilsTest {
@Test
public void testRightPad1() {
- assertThat(StringUtils.rightPad("dings", 0), is("dings"));
+ assertEquals("dings", StringUtils.rightPad("dings", 0));
- assertThat(StringUtils.rightPad("dings", 3), is("dings"));
+ assertEquals("dings", StringUtils.rightPad("dings", 3));
- assertThat(StringUtils.rightPad("dings", 10), is("dings "));
+ assertEquals("dings ", StringUtils.rightPad("dings", 10));
}
@Test
@@ -1269,11 +1255,11 @@ public class StringUtilsTest {
@Test
public void testRightPad2() {
- assertThat(StringUtils.rightPad("dings", 0, "+"), is("dings"));
+ assertEquals("dings", StringUtils.rightPad("dings", 0, "+"));
- assertThat(StringUtils.rightPad("dings", 3, "+"), is("dings"));
+ assertEquals("dings", StringUtils.rightPad("dings", 3, "+"));
- assertThat(StringUtils.rightPad("dings", 10, "+"), is("dings+++++"));
+ assertEquals("dings+++++", StringUtils.rightPad("dings", 10, "+"));
}
@Test
@@ -1283,9 +1269,9 @@ public class StringUtilsTest {
@Test
public void testSplit1() {
- assertThat(StringUtils.split("dings"), is(new String[] {"dings"}));
+ assertArrayEquals(new String[] {"dings"}, StringUtils.split("dings"));
- assertThat(StringUtils.split("dings bums"), is(new String[] {"dings", "bums"}));
+ assertArrayEquals(new String[] {"dings", "bums"}, StringUtils.split("dings bums"));
}
@Test
@@ -1300,13 +1286,13 @@ public class StringUtilsTest {
@Test
public void testSplit2() {
- assertThat(StringUtils.split("dings", null), is(new String[] {"dings"}));
+ assertArrayEquals(new String[] {"dings"}, StringUtils.split("dings", null));
- assertThat(StringUtils.split("dings bums", null), is(new String[] {"dings", "bums"}));
+ assertArrayEquals(new String[] {"dings", "bums"}, StringUtils.split("dings bums", null));
- assertThat(StringUtils.split("dings", "+"), is(new String[] {"dings"}));
+ assertArrayEquals(new String[] {"dings"}, StringUtils.split("dings", "+"));
- assertThat(StringUtils.split("dings+bums", "+"), is(new String[] {"dings", "bums"}));
+ assertArrayEquals(new String[] {"dings", "bums"}, StringUtils.split("dings+bums", "+"));
}
@Test
@@ -1321,201 +1307,200 @@ public class StringUtilsTest {
@Test
public void testSplit3() {
- assertThat(StringUtils.split("dings", null, 3), is(new String[] {"dings"}));
+ assertArrayEquals(new String[] {"dings"}, StringUtils.split("dings", null, 3));
- assertThat(StringUtils.split("dings bums", null, 3), is(new String[] {"dings", "bums"}));
+ assertArrayEquals(new String[] {"dings", "bums"}, StringUtils.split("dings bums", null, 3));
- assertThat(StringUtils.split("dings", "+", 3), is(new String[] {"dings"}));
+ assertArrayEquals(new String[] {"dings"}, StringUtils.split("dings", "+", 3));
- assertThat(StringUtils.split("dings+bums", "+", 3), is(new String[] {"dings", "bums"}));
+ assertArrayEquals(new String[] {"dings", "bums"}, StringUtils.split("dings+bums", "+", 3));
- assertThat(StringUtils.split("dings+bums", "+", 1), is(new String[] {"dings+bums"}));
+ assertArrayEquals(new String[] {"dings+bums"}, StringUtils.split("dings+bums", "+", 1));
- assertThat(StringUtils.split("dings+bums", "+", 0), is(new String[] {"dings", "bums"}));
+ assertArrayEquals(new String[] {"dings", "bums"}, StringUtils.split("dings+bums", "+", 0));
- assertThat(StringUtils.split("dings+bums", "+", -5), is(new String[] {"dings", "bums"}));
+ assertArrayEquals(new String[] {"dings", "bums"}, StringUtils.split("dings+bums", "+", -5));
}
@Test
public void testStrip1() {
- assertThat(StringUtils.strip(null), nullValue());
+ assertNull(StringUtils.strip(null));
- assertThat(StringUtils.strip("dings"), is("dings"));
+ assertEquals("dings", StringUtils.strip("dings"));
- assertThat(StringUtils.strip(" dings \t "), is("dings"));
+ assertEquals("dings", StringUtils.strip(" dings \t "));
}
@Test
public void testStrip2() {
- assertThat(StringUtils.strip(null, " "), nullValue());
+ assertNull(StringUtils.strip(null, " "));
- assertThat(StringUtils.strip(null, null), nullValue());
+ assertNull(StringUtils.strip(null, null));
- assertThat(StringUtils.strip("dings", " "), is("dings"));
+ assertEquals("dings", StringUtils.strip("dings", " "));
- assertThat(StringUtils.strip(" dings \t ", " "), is("dings \t"));
+ assertEquals("dings \t", StringUtils.strip(" dings \t ", " "));
}
@Test
public void testStripAll1() {
- assertThat(StringUtils.stripAll(null), nullValue());
+ assertNull(StringUtils.stripAll(null));
- assertThat(StringUtils.stripAll(new String[] {}), is(new String[] {}));
+ assertArrayEquals(new String[] {}, StringUtils.stripAll());
- assertThat(StringUtils.stripAll(new String[] {"dings"}), is(new String[] {"dings"}));
+ assertArrayEquals(new String[] {"dings"}, StringUtils.stripAll("dings"));
- assertThat(StringUtils.stripAll(new String[] {" dings ", " bums \t "}), is(new String[] {"dings", "bums"}));
+ assertArrayEquals(new String[] {"dings", "bums"}, StringUtils.stripAll(" dings ", " bums \t "));
}
@Test
public void testStripAll2() {
- assertThat(StringUtils.stripAll(null, " "), nullValue());
+ assertNull(StringUtils.stripAll(null, " "));
- assertThat(StringUtils.stripAll(new String[] {}, " "), is(new String[] {}));
+ assertArrayEquals(new String[] {}, StringUtils.stripAll(new String[] {}, " "));
- assertThat(StringUtils.stripAll(new String[] {"dings"}, " "), is(new String[] {"dings"}));
+ assertArrayEquals(new String[] {"dings"}, StringUtils.stripAll(new String[] {"dings"}, " "));
- assertThat(
- StringUtils.stripAll(new String[] {" dings ", " bums \t "}, " "),
- is(new String[] {"dings", "bums \t"}));
+ assertArrayEquals(
+ new String[] {"dings", "bums \t"}, StringUtils.stripAll(new String[] {" dings ", " bums \t "}, " "));
}
@Test
public void testStripEnd() {
- assertThat(StringUtils.stripEnd(null, null), nullValue());
+ assertNull(StringUtils.stripEnd(null, null));
- assertThat(StringUtils.stripEnd("dings", null), is("dings"));
+ assertEquals("dings", StringUtils.stripEnd("dings", null));
- assertThat(StringUtils.stripEnd(" dings \t ", null), is(" dings"));
+ assertEquals(" dings", StringUtils.stripEnd(" dings \t ", null));
- assertThat(StringUtils.stripEnd(null, " "), nullValue());
+ assertNull(StringUtils.stripEnd(null, " "));
- assertThat(StringUtils.stripEnd("dings", " "), is("dings"));
+ assertEquals("dings", StringUtils.stripEnd("dings", " "));
- assertThat(StringUtils.stripEnd(" dings \t ", " "), is(" dings \t"));
+ assertEquals(" dings \t", StringUtils.stripEnd(" dings \t ", " "));
}
@Test
public void testStripStart() {
- assertThat(StringUtils.stripStart(null, null), nullValue());
+ assertNull(StringUtils.stripStart(null, null));
- assertThat(StringUtils.stripStart("dings", null), is("dings"));
+ assertEquals("dings", StringUtils.stripStart("dings", null));
- assertThat(StringUtils.stripStart(" dings \t ", null), is("dings \t "));
+ assertEquals("dings \t ", StringUtils.stripStart(" dings \t ", null));
- assertThat(StringUtils.stripStart(null, " "), nullValue());
+ assertNull(StringUtils.stripStart(null, " "));
- assertThat(StringUtils.stripStart("dings", " "), is("dings"));
+ assertEquals("dings", StringUtils.stripStart("dings", " "));
- assertThat(StringUtils.stripStart(" \t dings \t ", " "), is("\t dings \t "));
+ assertEquals("\t dings \t ", StringUtils.stripStart(" \t dings \t ", " "));
}
@Test
public void testSubstring1() {
- assertThat(StringUtils.substring(null, 0), nullValue());
- assertThat(StringUtils.substring(null, -3), nullValue());
+ assertNull(StringUtils.substring(null, 0));
+ assertNull(StringUtils.substring(null, -3));
- assertThat(StringUtils.substring("dings", 2), is("ngs"));
+ assertEquals("ngs", StringUtils.substring("dings", 2));
- assertThat(StringUtils.substring("dings", -2), is("gs"));
+ assertEquals("gs", StringUtils.substring("dings", -2));
- assertThat(StringUtils.substring("dings", 20), is(""));
+ assertEquals("", StringUtils.substring("dings", 20));
}
@Test
public void testSubstring2() {
- assertThat(StringUtils.substring(null, 0, 2), nullValue());
+ assertNull(StringUtils.substring(null, 0, 2));
- assertThat(StringUtils.substring(null, -3, 0), nullValue());
+ assertNull(StringUtils.substring(null, -3, 0));
- assertThat(StringUtils.substring("dings", 2, 4), is("ng"));
+ assertEquals("ng", StringUtils.substring("dings", 2, 4));
- assertThat(StringUtils.substring("dings", -2, 4), is("g"));
+ assertEquals("g", StringUtils.substring("dings", -2, 4));
- assertThat(StringUtils.substring("dings", 20, 23), is(""));
+ assertEquals("", StringUtils.substring("dings", 20, 23));
- assertThat(StringUtils.substring("dings", 4, 2), is(""));
+ assertEquals("", StringUtils.substring("dings", 4, 2));
}
@Test
public void testSwapCase() {
- assertThat(StringUtils.swapCase(null), nullValue());
+ assertNull(StringUtils.swapCase(null));
- assertThat(StringUtils.swapCase("dings"), is("DINGS"));
+ assertEquals("DINGS", StringUtils.swapCase("dings"));
- assertThat(StringUtils.swapCase("DinGs"), is("dINgS"));
+ assertEquals("dINgS", StringUtils.swapCase("DinGs"));
}
@Test
public void testTrim() {
- assertThat(StringUtils.trim(null), nullValue());
+ assertNull(StringUtils.trim(null));
- assertThat(StringUtils.trim(" "), is(""));
+ assertEquals("", StringUtils.trim(" "));
- assertThat(StringUtils.trim(" c "), is("c"));
+ assertEquals("c", StringUtils.trim(" c "));
- assertThat(StringUtils.trim(" dings \n "), is("dings"));
+ assertEquals("dings", StringUtils.trim(" dings \n "));
}
@Test
public void testUncapitalise() {
- assertThat(StringUtils.uncapitalise(null), nullValue());
+ assertNull(StringUtils.uncapitalise(null));
- assertThat(StringUtils.uncapitalise(" "), is(" "));
+ assertEquals(" ", StringUtils.uncapitalise(" "));
- assertThat(StringUtils.uncapitalise("dings"), is("dings"));
+ assertEquals("dings", StringUtils.uncapitalise("dings"));
- assertThat(StringUtils.uncapitalise("Dings"), is("dings"));
+ assertEquals("dings", StringUtils.uncapitalise("Dings"));
- assertThat(StringUtils.uncapitalise("DINGS"), is("dINGS"));
+ assertEquals("dINGS", StringUtils.uncapitalise("DINGS"));
}
@Test
public void testUncapitaliseAllWords() {
- assertThat(StringUtils.uncapitaliseAllWords(null), nullValue());
+ assertNull(StringUtils.uncapitaliseAllWords(null));
- assertThat(StringUtils.uncapitaliseAllWords(" "), is(" "));
+ assertEquals(" ", StringUtils.uncapitaliseAllWords(" "));
- assertThat(StringUtils.uncapitaliseAllWords("dings bums"), is("dings bums"));
+ assertEquals("dings bums", StringUtils.uncapitaliseAllWords("dings bums"));
- assertThat(StringUtils.uncapitaliseAllWords("Dings Bums"), is("dings bums"));
+ assertEquals("dings bums", StringUtils.uncapitaliseAllWords("Dings Bums"));
- assertThat(StringUtils.uncapitaliseAllWords("DINGS Bums"), is("dINGS bums"));
+ assertEquals("dINGS bums", StringUtils.uncapitaliseAllWords("DINGS Bums"));
}
@Test
public void testUnifyLineSeparators1() {
String sls = System.lineSeparator();
- assertThat(StringUtils.unifyLineSeparators(null), nullValue());
+ assertNull(StringUtils.unifyLineSeparators(null));
- assertThat(StringUtils.unifyLineSeparators(" "), is(" "));
+ assertEquals(" ", StringUtils.unifyLineSeparators(" "));
- assertThat(StringUtils.unifyLineSeparators("dings\nbums\r\ndongs"), is("dings" + sls + "bums" + sls + "dongs"));
+ assertEquals("dings" + sls + "bums" + sls + "dongs", StringUtils.unifyLineSeparators("dings\nbums\r\ndongs"));
}
@Test
public void testUnifyLineSeparators2() {
- assertThat(StringUtils.unifyLineSeparators(null, "\n"), nullValue());
+ assertNull(StringUtils.unifyLineSeparators(null, "\n"));
- assertThat(StringUtils.unifyLineSeparators(" ", "\n"), is(" "));
+ assertEquals(" ", StringUtils.unifyLineSeparators(" ", "\n"));
- assertThat(
- StringUtils.unifyLineSeparators(" ", null) // takes the sytem line separator
+ assertEquals(
+ " " // takes the sytem line separator
,
- is(" "));
+ StringUtils.unifyLineSeparators(" ", null));
- assertThat(StringUtils.unifyLineSeparators("dings\nbums\r\ndongs", "\n"), is("dings\nbums\ndongs"));
+ assertEquals("dings\nbums\ndongs", StringUtils.unifyLineSeparators("dings\nbums\r\ndongs", "\n"));
}
@Test
public void testUppercase() {
- assertThat(StringUtils.upperCase(null), nullValue());
+ assertNull(StringUtils.upperCase(null));
- assertThat(StringUtils.upperCase(" "), is(" "));
+ assertEquals(" ", StringUtils.upperCase(" "));
- assertThat(StringUtils.upperCase(""), is(""));
+ assertEquals("", StringUtils.upperCase(""));
- assertThat(StringUtils.upperCase("dings"), is("DINGS"));
+ assertEquals("DINGS", StringUtils.upperCase("dings"));
}
}
diff --git a/src/test/java/org/apache/maven/shared/utils/XmlStreamReaderTest.java b/src/test/java/org/apache/maven/shared/utils/XmlStreamReaderTest.java
index 1d79635..b6a2c61 100644
--- a/src/test/java/org/apache/maven/shared/utils/XmlStreamReaderTest.java
+++ b/src/test/java/org/apache/maven/shared/utils/XmlStreamReaderTest.java
@@ -35,23 +35,24 @@ import static org.junit.jupiter.api.Assertions.fail;
*
* @author <a href="mailto:hboutemy@apache.org">Hervé Boutemy</a>
*/
+@SuppressWarnings("deprecation")
public class XmlStreamReaderTest {
/**
* french
*/
- private static final String TEXT_LATIN1 = "eacute: \u00E9";
+ private static final String TEXT_LATIN1 = "eacute: é";
/**
* greek
*/
- private static final String TEXT_LATIN7 = "alpha: \u03B1";
+ private static final String TEXT_LATIN7 = "alpha: α";
/**
* euro support
*/
- private static final String TEXT_LATIN15 = "euro: \u20AC";
+ private static final String TEXT_LATIN15 = "euro: €";
/**
* japanese
*/
- private static final String TEXT_EUC_JP = "hiragana A: \u3042";
+ private static final String TEXT_EUC_JP = "hiragana A: あ";
/**
* Unicode: support everything
*/
@@ -91,19 +92,10 @@ public class XmlStreamReaderTest {
assertEquals(xml, result);
}
- private static void checkXmlStreamReader(String text, String encoding, String effectiveEncoding)
- throws IOException {
- checkXmlStreamReader(text, encoding, effectiveEncoding, null);
- }
-
private static void checkXmlStreamReader(String text, String encoding) throws IOException {
checkXmlStreamReader(text, encoding, encoding, null);
}
- private static void checkXmlStreamReader(String text, String encoding, byte[] bom) throws IOException {
- checkXmlStreamReader(text, encoding, encoding, bom);
- }
-
private static void checkXmlStreamReader(String text, String encoding, String effectiveEncoding, byte[] bom)
throws IOException {
String xml = createXmlContent(text, encoding);
@@ -119,14 +111,14 @@ public class XmlStreamReaderTest {
@Test
public void testDefaultEncoding() throws IOException {
- checkXmlStreamReader(TEXT_UNICODE, null, "UTF-8");
+ checkXmlStreamReader(TEXT_UNICODE, (String) null, "UTF-8", null);
checkXmlStreamReader(TEXT_UNICODE, null, "UTF-8", BOM_UTF8);
}
@Test
public void testUTF8Encoding() throws IOException {
checkXmlStreamReader(TEXT_UNICODE, "UTF-8");
- checkXmlStreamReader(TEXT_UNICODE, "UTF-8", BOM_UTF8);
+ checkXmlStreamReader(TEXT_UNICODE, "UTF-8", "UTF-8", BOM_UTF8);
}
@Test
@@ -183,22 +175,13 @@ public class XmlStreamReaderTest {
@Test
public void testEncodingAttribute() throws IOException {
- String xml = "<?xml version='1.0' encoding='US-ASCII'?><element encoding='attribute value'/>";
- checkXmlContent(xml, "US-ASCII");
-
- xml = "<?xml version='1.0' encoding = 'US-ASCII' ?><element encoding='attribute value'/>";
- checkXmlContent(xml, "US-ASCII");
-
- xml = "<?xml version='1.0'?><element encoding='attribute value'/>";
- checkXmlContent(xml, "UTF-8");
-
- xml = "<?xml\nversion='1.0'\nencoding\n=\n'US-ASCII'\n?>\n<element encoding='attribute value'/>";
- checkXmlContent(xml, "US-ASCII");
-
- xml = "<?xml\nversion='1.0'\n?>\n<element encoding='attribute value'/>";
- checkXmlContent(xml, "UTF-8");
-
- xml = "<element encoding='attribute value'/>";
- checkXmlContent(xml, "UTF-8");
+ checkXmlContent("<?xml version='1.0' encoding='US-ASCII'?><element encoding='attribute value'/>", "US-ASCII");
+ checkXmlContent(
+ "<?xml version='1.0' encoding = 'US-ASCII' ?><element encoding='attribute value'/>", "US-ASCII");
+ checkXmlContent("<?xml version='1.0'?><element encoding='attribute value'/>", "UTF-8");
+ checkXmlContent(
+ "<?xml\nversion='1.0'\nencoding\n=\n'US-ASCII'\n?>\n<element encoding='attribute value'/>", "US-ASCII");
+ checkXmlContent("<?xml\nversion='1.0'\n?>\n<element encoding='attribute value'/>", "UTF-8");
+ checkXmlContent("<element encoding='attribute value'/>", "UTF-8");
}
}
diff --git a/src/test/java/org/apache/maven/shared/utils/cli/CommandLineUtilsTest.java b/src/test/java/org/apache/maven/shared/utils/cli/CommandLineUtilsTest.java
index 5d02bb8..c4beaf7 100644
--- a/src/test/java/org/apache/maven/shared/utils/cli/CommandLineUtilsTest.java
+++ b/src/test/java/org/apache/maven/shared/utils/cli/CommandLineUtilsTest.java
@@ -27,14 +27,13 @@ import java.util.Properties;
import org.apache.maven.shared.utils.Os;
import org.junit.jupiter.api.Test;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.hasItemInArray;
-import static org.hamcrest.Matchers.not;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
+@SuppressWarnings("deprecation")
public class CommandLineUtilsTest {
/**
@@ -156,7 +155,7 @@ public class CommandLineUtilsTest {
String[] environmentVariables = commandline.getEnvironmentVariables();
assertNotNull(environmentVariables);
- assertThat(environmentVariables, not(hasItemInArray("TEST_NULL_ENV=null")));
+ assertFalse(Arrays.asList(environmentVariables).contains("TEST_NULL_ENV=null"));
}
@Test
@@ -167,7 +166,7 @@ public class CommandLineUtilsTest {
String[] environmentVariables = commandline.getEnvironmentVariables();
assertNotNull(environmentVariables);
- assertThat(environmentVariables, hasItemInArray("TEST_SHARED_ENV=TestValue"));
+ assertTrue(Arrays.asList(environmentVariables).contains("TEST_SHARED_ENV=TestValue"));
}
@Test
@@ -191,6 +190,6 @@ public class CommandLineUtilsTest {
String[] environmentVariables = commandline.getEnvironmentVariables();
assertNotNull(environmentVariables);
- assertThat(environmentVariables, not(hasItemInArray("TEST_SHARED_ENV=TestValue")));
+ assertFalse(Arrays.asList(environmentVariables).contains("TEST_SHARED_ENV=TestValue"));
}
}
diff --git a/src/test/java/org/apache/maven/shared/utils/cli/StreamPollFeederTest.java b/src/test/java/org/apache/maven/shared/utils/cli/StreamPollFeederTest.java
index 3b6652d..e1c2475 100644
--- a/src/test/java/org/apache/maven/shared/utils/cli/StreamPollFeederTest.java
+++ b/src/test/java/org/apache/maven/shared/utils/cli/StreamPollFeederTest.java
@@ -20,7 +20,6 @@ package org.apache.maven.shared.utils.cli;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
-import java.io.IOException;
import org.junit.jupiter.api.Test;
@@ -47,7 +46,7 @@ public class StreamPollFeederTest {
}
@Test
- public void dataShouldBeCopied() throws InterruptedException, IOException {
+ public void dataShouldBeCopied() throws InterruptedException {
StringBuilder testData = new StringBuilder();
for (int i = 0; i < 100; i++) {
diff --git a/src/test/java/org/apache/maven/shared/utils/cli/shell/BourneShellTest.java b/src/test/java/org/apache/maven/shared/utils/cli/shell/BourneShellTest.java
index d5282d8..db9f469 100644
--- a/src/test/java/org/apache/maven/shared/utils/cli/shell/BourneShellTest.java
+++ b/src/test/java/org/apache/maven/shared/utils/cli/shell/BourneShellTest.java
@@ -27,6 +27,7 @@ import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
+@SuppressWarnings("deprecation")
public class BourneShellTest {
Shell newShell() {
@@ -156,7 +157,7 @@ public class BourneShellTest {
}
@Test
- public void testBourneShellQuotingCharacters() throws Exception {
+ public void testBourneShellQuotingCharacters() {
// { ' ', '$', ';', '&', '|', '<', '>', '*', '?', '(', ')' };
// test with values https://steve-parker.org/sh/bourne.shtml Appendix B - Meta-characters and Reserved Words
Commandline commandline = new Commandline(newShell());
diff --git a/src/test/java/org/apache/maven/shared/utils/introspection/ReflectionValueExtractorTest.java b/src/test/java/org/apache/maven/shared/utils/introspection/ReflectionValueExtractorTest.java
index 9160e79..f3305ed 100644
--- a/src/test/java/org/apache/maven/shared/utils/introspection/ReflectionValueExtractorTest.java
+++ b/src/test/java/org/apache/maven/shared/utils/introspection/ReflectionValueExtractorTest.java
@@ -38,7 +38,7 @@ public class ReflectionValueExtractorTest {
private Project project;
@BeforeEach
- public void setUp() throws Exception {
+ public void setUp() {
Dependency dependency1 = new Dependency();
dependency1.setArtifactId("dep1");
@@ -64,7 +64,7 @@ public class ReflectionValueExtractorTest {
}
@Test
- public void testValueExtraction() throws IntrospectionException {
+ public void testValueExtraction() throws Exception {
// ----------------------------------------------------------------------
// Top level values
// ----------------------------------------------------------------------
@@ -144,14 +144,14 @@ public class ReflectionValueExtractorTest {
}
@Test
- public void testValueExtractorWithAInvalidExpression() throws IntrospectionException {
+ public void testValueExtractorWithAInvalidExpression() throws Exception {
assertNull(ReflectionValueExtractor.evaluate("project.foo", project));
assertNull(ReflectionValueExtractor.evaluate("project.dependencies[10]", project));
assertNull(ReflectionValueExtractor.evaluate("project.dependencies[0].foo", project));
}
@Test
- public void testMappedDottedKey() throws IntrospectionException {
+ public void testMappedDottedKey() throws Exception {
Map<String, String> map = new HashMap<>();
map.put("a.b", "a.b-value");
@@ -159,7 +159,7 @@ public class ReflectionValueExtractorTest {
}
@Test
- public void testIndexedMapped() throws IntrospectionException {
+ public void testIndexedMapped() throws Exception {
Map<Object, Object> map = new HashMap<>();
map.put("a", "a-value");
List<Object> list = new ArrayList<>();
@@ -169,7 +169,7 @@ public class ReflectionValueExtractorTest {
}
@Test
- public void testMappedIndexed() throws IntrospectionException {
+ public void testMappedIndexed() throws Exception {
List<Object> list = new ArrayList<>();
list.add("a-value");
Map<Object, Object> map = new HashMap<>();
@@ -178,26 +178,26 @@ public class ReflectionValueExtractorTest {
}
@Test
- public void testMappedMissingDot() throws IntrospectionException {
+ public void testMappedMissingDot() throws Exception {
Map<Object, Object> map = new HashMap<>();
map.put("a", new ValueHolder("a-value"));
assertNull(ReflectionValueExtractor.evaluate("h.value(a)value", new ValueHolder(map)));
}
@Test
- public void testIndexedMissingDot() throws IntrospectionException {
+ public void testIndexedMissingDot() throws Exception {
List<Object> list = new ArrayList<>();
list.add(new ValueHolder("a-value"));
assertNull(ReflectionValueExtractor.evaluate("h.value[0]value", new ValueHolder(list)));
}
@Test
- public void testDotDot() throws IntrospectionException {
+ public void testDotDot() throws Exception {
assertNull(ReflectionValueExtractor.evaluate("h..value", new ValueHolder("value")));
}
@Test
- public void testBadIndexedSyntax() throws IntrospectionException {
+ public void testBadIndexedSyntax() throws Exception {
List<Object> list = new ArrayList<>();
list.add("a-value");
Object value = new ValueHolder(list);
@@ -211,7 +211,7 @@ public class ReflectionValueExtractorTest {
}
@Test
- public void testBadMappedSyntax() throws IntrospectionException {
+ public void testBadMappedSyntax() throws Exception {
Map<Object, Object> map = new HashMap<>();
map.put("a", "a-value");
Object value = new ValueHolder(map);
@@ -241,12 +241,12 @@ public class ReflectionValueExtractorTest {
}
@Test
- public void testTrimRootToken() throws IntrospectionException {
+ public void testTrimRootToken() throws Exception {
assertNull(ReflectionValueExtractor.evaluate("project", project, true));
}
@Test
- public void testArtifactMap() throws IntrospectionException {
+ public void testArtifactMap() throws Exception {
assertEquals(
"g0",
((Artifact) ReflectionValueExtractor.evaluate("project.artifactMap(g0:a0:c0)", project)).getGroupId());
@@ -403,7 +403,7 @@ public class ReflectionValueExtractorTest {
public Dependency[] getDependenciesAsArray() {
List<Dependency> list = getDependencies();
- return list.toArray(new Dependency[list.size()]);
+ return list.toArray(new Dependency[0]);
}
public Map<String, Dependency> getDependenciesAsMap() {
@@ -471,7 +471,7 @@ public class ReflectionValueExtractorTest {
}
@Test
- public void testRootPropertyRegression() throws IntrospectionException {
+ public void testRootPropertyRegression() throws Exception {
Project project = new Project();
project.setDescription("c:\\\\org\\apache\\test");
Object evalued = ReflectionValueExtractor.evaluate("description", project);
diff --git a/src/test/java/org/apache/maven/shared/utils/io/DirectoryScannerTest.java b/src/test/java/org/apache/maven/shared/utils/io/DirectoryScannerTest.java
index 9ab2a5c..fc870cf 100644
--- a/src/test/java/org/apache/maven/shared/utils/io/DirectoryScannerTest.java
+++ b/src/test/java/org/apache/maven/shared/utils/io/DirectoryScannerTest.java
@@ -31,8 +31,6 @@ import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -158,9 +156,9 @@ public class DirectoryScannerTest {
/* expNotInclDirs */ new String[] {"", "folder1"},
/* expExclFiles */ NONE,
/* expExclDirs */ NONE));
- assertThat(
- exception.getMessage(),
- containsString("If a non-null " + listName + " list is given, all elements must be non-null"));
+ assertTrue(exception
+ .getMessage()
+ .contains("If a non-null " + listName + " list is given, all elements must be non-null"));
}
@Test
@@ -320,10 +318,7 @@ public class DirectoryScannerTest {
checkFiles("expectedExcludedFiles", expectedExcludedFiles, ds.getExcludedFiles());
checkFiles("expectedExcludedDirectories", expectedExcludedDirectories, ds.getExcludedDirectories());
- checkFiles(
- "visitedFiles",
- expectedIncludedFiles,
- scanConductor.visitedFiles.toArray(new String[scanConductor.visitedFiles.size()]));
+ checkFiles("visitedFiles", expectedIncludedFiles, scanConductor.visitedFiles.toArray(new String[0]));
}
/**
diff --git a/src/test/java/org/apache/maven/shared/utils/io/FileUtilsTest.java b/src/test/java/org/apache/maven/shared/utils/io/FileUtilsTest.java
index 52eb9b6..4f402f1 100644
--- a/src/test/java/org/apache/maven/shared/utils/io/FileUtilsTest.java
+++ b/src/test/java/org/apache/maven/shared/utils/io/FileUtilsTest.java
@@ -33,14 +33,12 @@ import java.io.OutputStream;
import java.io.Reader;
import java.io.StringReader;
import java.io.Writer;
-import java.lang.reflect.Method;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
-import java.util.Optional;
import java.util.concurrent.TimeUnit;
import org.apache.commons.io.IOUtils;
@@ -49,13 +47,17 @@ import org.apache.maven.shared.utils.testhelpers.FileTestHelper;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.TestInfo;
+import org.junit.jupiter.api.condition.DisabledOnOs;
+import org.junit.jupiter.api.condition.EnabledOnOs;
+import org.junit.jupiter.api.condition.OS;
import org.junit.jupiter.api.io.TempDir;
+import static java.util.Objects.requireNonNull;
import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertIterableEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -81,8 +83,6 @@ public class FileUtilsTest {
@TempDir
private File tempFolder;
- private String name;
-
/**
* Size of test directory.
*/
@@ -96,15 +96,8 @@ public class FileUtilsTest {
private long testFile2Size;
- /**
- * @see
- */
@BeforeEach
- public void setUp(TestInfo testInfo) throws Exception {
- Optional<Method> testMethod = testInfo.getTestMethod();
- if (testMethod.isPresent()) {
- this.name = testMethod.get().getName();
- }
+ public void setUp() throws Exception {
testFile1 = newFile(tempFolder, "file1-test.txt");
testFile2 = newFile(tempFolder, "file1a-test.txt");
@@ -125,7 +118,7 @@ public class FileUtilsTest {
throw new IOException("Cannot create file " + file + " as the parent directory does not exist");
}
- try (OutputStream out = new BufferedOutputStream(new FileOutputStream(file))) {
+ try (OutputStream out = new BufferedOutputStream(Files.newOutputStream(file.toPath()))) {
FileTestHelper.generateTestData(out, size);
}
}
@@ -136,7 +129,7 @@ public class FileUtilsTest {
private void assertEqualContent(byte[] b0, File file) throws IOException {
int count = 0, numRead = 0;
byte[] b1 = new byte[b0.length];
- try (InputStream is = new FileInputStream(file)) {
+ try (InputStream is = Files.newInputStream(file.toPath())) {
while (count < b0.length && numRead >= 0) {
numRead = is.read(b1, count, b0.length);
count += numRead;
@@ -159,6 +152,7 @@ public class FileUtilsTest {
public void toFile1() throws Exception {
URL url = new URL("file", null, "a/b/c/file.txt");
File file = FileUtils.toFile(url);
+ assertNotNull(file);
assertTrue(file.toString().contains("file.txt"));
}
@@ -166,20 +160,22 @@ public class FileUtilsTest {
public void toFile2() throws Exception {
URL url = new URL("file", null, "a/b/c/file%20n%61me%2520.tx%74");
File file = FileUtils.toFile(url);
+ assertNotNull(file);
assertTrue(file.toString().contains("file name%20.txt"));
}
@Test
public void toFile3() throws Exception {
assertNull(FileUtils.toFile(null));
- assertNull(FileUtils.toFile(new URL("http://jakarta.apache.org")));
+ assertNull(FileUtils.toFile(new URL("https://jakarta.apache.org")));
}
@Test
- public void toFile4() throws Exception {
+ public void toFile4() {
assertThrows(NumberFormatException.class, () -> {
URL url = new URL("file", null, "a/b/c/file%%20%me.txt%");
File file = FileUtils.toFile(url);
+ assertNotNull(file);
assertTrue(file.toString().contains("file% %me.txt%"));
});
}
@@ -191,6 +187,7 @@ public class FileUtilsTest {
public void toFile5() throws Exception {
URL url = new URL("file", null, "both%20are%20100%20%25%20true");
File file = FileUtils.toFile(url);
+ assertNotNull(file);
assertEquals("both are 100 % true", file.toString());
}
@@ -198,7 +195,8 @@ public class FileUtilsTest {
public void toFileUtf8() throws Exception {
URL url = new URL("file", null, "/home/%C3%A4%C3%B6%C3%BC%C3%9F");
File file = FileUtils.toFile(url);
- assertFalse(file.toString().contains("\u00E4\u00F6\u00FC\u00DF"));
+ assertNotNull(file);
+ assertFalse(file.toString().contains("äöüß"));
}
// toURLs
@@ -226,29 +224,29 @@ public class FileUtilsTest {
@Test
public void contentEquals() throws Exception {
// Non-existent files
- File file = new File(tempFolder, name);
- File file2 = new File(tempFolder, name + "2");
+ File file1 = new File(tempFolder, "file1");
+ File file2 = new File(tempFolder, "file2");
// both don't exist
- assertTrue(FileUtils.contentEquals(file, file));
- assertTrue(FileUtils.contentEquals(file, file2));
+ assertTrue(FileUtils.contentEquals(file1, file1));
+ assertTrue(FileUtils.contentEquals(file1, file2));
assertTrue(FileUtils.contentEquals(file2, file2));
- assertTrue(FileUtils.contentEquals(file2, file));
+ assertTrue(FileUtils.contentEquals(file2, file1));
// Directories
FileUtils.contentEquals(tempFolder, tempFolder);
// Different files
- File objFile1 = new File(tempFolder, name + ".object");
+ File objFile1 = new File(tempFolder, "file.object");
objFile1.deleteOnExit();
- FileUtils.copyURLToFile(getClass().getResource("/java/lang/Object.class"), objFile1);
+ FileUtils.copyURLToFile(requireNonNull(getClass().getResource("/java/lang/Object.class")), objFile1);
- File objFile1b = new File(tempFolder, name + ".object2");
+ File objFile1b = new File(tempFolder, "file.object2");
objFile1.deleteOnExit();
- FileUtils.copyURLToFile(getClass().getResource("/java/lang/Object.class"), objFile1b);
+ FileUtils.copyURLToFile(requireNonNull(getClass().getResource("/java/lang/Object.class")), objFile1b);
- File objFile2 = new File(tempFolder, name + ".collection");
+ File objFile2 = new File(tempFolder, "file.collection");
objFile2.deleteOnExit();
- FileUtils.copyURLToFile(getClass().getResource("/java/util/Collection.class"), objFile2);
+ FileUtils.copyURLToFile(requireNonNull(getClass().getResource("/java/util/Collection.class")), objFile2);
assertFalse(FileUtils.contentEquals(objFile1, objFile2));
assertFalse(FileUtils.contentEquals(objFile1b, objFile2));
@@ -259,10 +257,10 @@ public class FileUtilsTest {
assertTrue(FileUtils.contentEquals(objFile2, objFile2));
// Equal files
- file.createNewFile();
+ file1.createNewFile();
file2.createNewFile();
- assertTrue(FileUtils.contentEquals(file, file));
- assertTrue(FileUtils.contentEquals(file, file2));
+ assertTrue(FileUtils.contentEquals(file1, file1));
+ assertTrue(FileUtils.contentEquals(file1, file2));
}
// copyURLToFile
@@ -270,17 +268,18 @@ public class FileUtilsTest {
@Test
public void copyURLToFile() throws Exception {
// Creates file
- File file = new File(tempFolder, name);
+ File file = new File(tempFolder, "copyURLToFile");
file.deleteOnExit();
// Loads resource
String resourceName = "/java/lang/Object.class";
- FileUtils.copyURLToFile(getClass().getResource(resourceName), file);
+ FileUtils.copyURLToFile(requireNonNull(getClass().getResource(resourceName)), file);
// Tests that resource was copied correctly
try (FileInputStream fis = new FileInputStream(file)) {
assertTrue(
- IOUtil.contentEquals(getClass().getResourceAsStream(resourceName), fis), "Content is not equal.");
+ IOUtil.contentEquals(requireNonNull(getClass().getResourceAsStream(resourceName)), fis),
+ "Content is not equal.");
}
// TODO Maybe test copy to itself like for copyFile()
}
@@ -293,17 +292,13 @@ public class FileUtilsTest {
FileUtils.forceMkdir(tempFolder);
// Creates test file
- File testFile = new File(tempFolder, name);
+ File testFile = new File(tempFolder, "forceMkdir");
testFile.deleteOnExit();
testFile.createNewFile();
assertTrue(testFile.exists(), "Test file does not exist.");
// Tests with existing file
- try {
- FileUtils.forceMkdir(testFile);
- fail("Exception expected.");
- } catch (IOException ex) {
- }
+ assertThrows(IOException.class, () -> FileUtils.forceMkdir(testFile));
testFile.delete();
@@ -316,31 +311,23 @@ public class FileUtilsTest {
@Test
public void sizeOfDirectory() throws Exception {
- File file = new File(tempFolder, name);
+ File file = new File(tempFolder, "sizeOfDirectory");
// Non-existent file
- try {
- FileUtils.sizeOfDirectory(file);
- fail("Exception expected.");
- } catch (IllegalArgumentException ex) {
- }
+ assertThrows(IllegalArgumentException.class, () -> FileUtils.sizeOfDirectory(file));
// Creates file
file.createNewFile();
file.deleteOnExit();
// Existing file
- try {
- FileUtils.sizeOfDirectory(file);
- fail("Exception expected.");
- } catch (IllegalArgumentException ex) {
- }
+ assertThrows(IllegalArgumentException.class, () -> FileUtils.sizeOfDirectory(file));
// Existing directory
file.delete();
file.mkdir();
- assertEquals((long) TEST_DIRECTORY_SIZE, FileUtils.sizeOfDirectory(file), "Unexpected directory size");
+ assertEquals(TEST_DIRECTORY_SIZE, FileUtils.sizeOfDirectory(file), "Unexpected directory size");
}
// copyFile
@@ -542,7 +529,7 @@ public class FileUtilsTest {
}
@Test
- public void deleteFileNofile() throws Exception {
+ public void deleteFileNofile() {
assertThrows(IOException.class, () -> {
File destination = new File("abc/cde");
FileUtils.delete(destination);
@@ -557,7 +544,7 @@ public class FileUtilsTest {
}
@Test
- public void deleteFileLegacyNofile() throws Exception {
+ public void deleteFileLegacyNofile() {
File destination = new File("abc/cde");
assertFalse(FileUtils.deleteLegacyStyle(destination));
}
@@ -566,7 +553,8 @@ public class FileUtilsTest {
public void copyFileWithPermissions() throws Exception {
File source = new File("src/test/resources/executable");
source.setExecutable(true);
- assumeTrue(source.exists(), "Need an existing file to copy");
+ assertTrue(source.exists(), "Need an existing file to copy");
+ // On some OS (Windows) the executable bit is not supported
assumeTrue(source.canExecute(), "Need an executable file to copy");
File destination = new File(tempFolder, "executable-copy");
@@ -576,7 +564,8 @@ public class FileUtilsTest {
assertTrue(
Files.exists(destination.toPath()),
"destination not exists: " + destination.getAbsolutePath() + ", directory content: "
- + Arrays.asList(destination.getParentFile().list()));
+ + Arrays.asList(
+ requireNonNull(destination.getParentFile().list())));
assertTrue(destination.canExecute(), "Check copy executable");
}
@@ -647,39 +636,21 @@ public class FileUtilsTest {
@Test
public void copyDirectoryErrorsNullDestination() throws IOException {
- try {
- FileUtils.copyDirectory(new File("a"), null);
- fail();
- } catch (NullPointerException ex) {
- }
+ assertThrows(NullPointerException.class, () -> FileUtils.copyDirectory(new File("a"), null));
}
@Test
public void copyDirectoryErrorsCopyToSelf() {
- try {
- FileUtils.copyDirectory(tempFolder, tempFolder);
- fail();
- } catch (IOException ex) {
- }
+ assertThrows(IOException.class, () -> FileUtils.copyDirectory(tempFolder, tempFolder));
}
@Test
public void copyDirectoryErrors() throws IOException {
- try {
- FileUtils.copyDirectory(null, null);
- fail();
- } catch (NullPointerException ex) {
- }
- try {
- FileUtils.copyDirectory(null, new File("a"));
- fail();
- } catch (NullPointerException ex) {
- }
- try {
- FileUtils.copyDirectory(tempFolder, testFile1);
- fail();
- } catch (IOException ex) {
- }
+ assertThrows(NullPointerException.class, () -> FileUtils.copyDirectory(null, null));
+
+ assertThrows(NullPointerException.class, () -> FileUtils.copyDirectory(null, new File("a")));
+
+ assertThrows(IOException.class, () -> FileUtils.copyDirectory(tempFolder, testFile1));
}
// forceDelete
@@ -699,14 +670,14 @@ public class FileUtilsTest {
destination.createNewFile();
assertTrue(destination.exists(), "Copy2.txt doesn't exist to delete");
FileUtils.forceDelete(destination);
- assertTrue(!destination.exists(), "Check No Exist");
+ assertFalse(destination.exists(), "Check No Exist");
}
@Test
@Disabled("Commons test case that is failing for plexus")
public void forceDeleteAFile3() throws Exception {
File destination = new File(tempFolder, "no_such_file");
- assertTrue(!destination.exists(), "Check No Exist");
+ assertFalse(destination.exists(), "Check No Exist");
try {
FileUtils.forceDelete(destination);
fail("Should generate FileNotFoundException");
@@ -768,9 +739,9 @@ public class FileUtilsTest {
@Test
public void forceDeleteDir() throws Exception {
- File testDirectory = newFolder(tempFolder, name);
+ File testDirectory = newFolder(tempFolder, "forceDeleteDir");
FileUtils.forceDelete(testDirectory.getParentFile());
- assertTrue(!testDirectory.getParentFile().exists(), "Check No Exist");
+ assertFalse(testDirectory.getParentFile().exists(), "Check No Exist");
}
/**
@@ -783,7 +754,7 @@ public class FileUtilsTest {
String filename = file1.getAbsolutePath();
// Create test file on-the-fly
- try (OutputStream out = new java.io.FileOutputStream(file1)) {
+ try (OutputStream out = Files.newOutputStream(file1.toPath())) {
out.write("This is a test".getBytes("UTF-8"));
}
@@ -794,12 +765,12 @@ public class FileUtilsTest {
assertTrue(file2.length() > 0);
String file2contents = FileUtils.fileRead(file2, "UTF-8");
- assertTrue(filename.equals(file2contents), "Second file's contents correct");
+ assertEquals(filename, file2contents, "Second file's contents correct");
assertTrue(file2.delete());
String contents = FileUtils.fileRead(new File(filename), "UTF-8");
- assertTrue(contents.equals("This is a test"), "FileUtils.fileRead()");
+ assertEquals("This is a test", contents, "FileUtils.fileRead()");
}
@Test
@@ -940,7 +911,8 @@ public class FileUtilsTest {
}
@Test
- public void blowUpOnNull() throws IOException {
+ public void blowUpOnNull() {
+ //noinspection DataFlowIssue
assertThrows(NullPointerException.class, () -> FileUtils.deleteDirectory((File) null));
}
@@ -979,7 +951,7 @@ public class FileUtilsTest {
//// getDefaultExcludes
@Test
- public void getDefaultExcludes() throws Exception {
+ public void getDefaultExcludes() {
List<String> excludes = Arrays.asList(FileUtils.getDefaultExcludes());
assertAll(
"All minimum default excludes should be present",
@@ -990,7 +962,7 @@ public class FileUtilsTest {
//// getDefaultExcludesAsList
@Test
- public void getDefaultExcludesAsList() throws Exception {
+ public void getDefaultExcludesAsList() {
List<String> excludes = FileUtils.getDefaultExcludesAsList();
assertAll(
"All minimum default excludes should be present",
@@ -1001,7 +973,7 @@ public class FileUtilsTest {
//// getDefaultExcludesAsString
@Test
- public void getDefaultExcludesAsString() throws Exception {
+ public void getDefaultExcludesAsString() {
HashSet<String> excludes = new HashSet<>(
Arrays.asList(FileUtils.getDefaultExcludesAsString().split(",")));
assertAll(
@@ -1013,209 +985,200 @@ public class FileUtilsTest {
//// dirname(String)
@Test
- public void blowUpOnDirnameNull() throws Exception {
+ public void blowUpOnDirnameNull() {
+ //noinspection DataFlowIssue
assertThrows(NullPointerException.class, () -> FileUtils.dirname(null));
}
@Test
- public void dirnameEmpty() throws Exception {
+ public void dirnameEmpty() {
assertEquals("", FileUtils.dirname(""));
}
@Test
- public void dirnameFilename() throws Exception {
+ public void dirnameFilename() {
assertEquals("", FileUtils.dirname("foo.bar.txt"));
}
@Test
- // X @ReproducesPlexusBug( "assumes that the path is a local path" )
- public void dirnameWindowsRootPathOnUnix() throws Exception {
- assumeTrue(File.separatorChar == '/');
+ @DisabledOnOs(OS.WINDOWS)
+ public void dirnameWindowsRootPathOnUnix() {
assertEquals("", FileUtils.dirname("C:\\foo.bar.txt"));
}
@Test
- // X @ReproducesPlexusBug( "assumes that the path is a local path" )
- public void dirnameWindowsNonRootPathOnUnix() throws Exception {
- assumeTrue(File.separatorChar == '/');
+ @DisabledOnOs(OS.WINDOWS)
+ public void dirnameWindowsNonRootPathOnUnix() {
assertEquals("", FileUtils.dirname("C:\\test\\foo.bar.txt"));
}
@Test
- // X @ReproducesPlexusBug( "assumes that the path is a local path" )
- public void dirnameUnixRootPathOnWindows() throws Exception {
- assumeTrue(File.separatorChar == '\\');
+ @EnabledOnOs(OS.WINDOWS)
+ public void dirnameUnixRootPathOnWindows() {
assertEquals("", FileUtils.dirname("/foo.bar.txt"));
}
@Test
- // X @ReproducesPlexusBug( "assumes that the path is a local path" )
- public void dirnameUnixNonRootPathOnWindows() throws Exception {
- assumeTrue(File.separatorChar == '\\');
+ @EnabledOnOs(OS.WINDOWS)
+ public void dirnameUnixNonRootPathOnWindows() {
assertEquals("", FileUtils.dirname("/test/foo.bar.txt"));
}
@Test
- public void dirnameWindowsRootPathOnWindows() throws Exception {
- assumeTrue(File.separatorChar == '\\');
+ @EnabledOnOs(OS.WINDOWS)
+ public void dirnameWindowsRootPathOnWindows() {
assertEquals("C:", FileUtils.dirname("C:\\foo.bar.txt"));
}
@Test
- public void dirnameWindowsNonRootPathOnWindows() throws Exception {
- assumeTrue(File.separatorChar == '\\');
+ @EnabledOnOs(OS.WINDOWS)
+ public void dirnameWindowsNonRootPathOnWindows() {
assertEquals("C:\\test", FileUtils.dirname("C:\\test\\foo.bar.txt"));
}
@Test
- public void dirnameUnixRootPathOnUnix() throws Exception {
- assumeTrue(File.separatorChar == '/');
+ @DisabledOnOs(OS.WINDOWS)
+ public void dirnameUnixRootPathOnUnix() {
assertEquals("", FileUtils.dirname("/foo.bar.txt"));
}
@Test
- public void dirnameUnixNonRootPathOnUnix() throws Exception {
- assumeTrue(File.separatorChar == '/');
+ @DisabledOnOs(OS.WINDOWS)
+ public void dirnameUnixNonRootPathOnUnix() {
assertEquals("/test", FileUtils.dirname("/test/foo.bar.txt"));
}
//// filename(String)
@Test
- public void blowUpOnFilenameNull() throws Exception {
+ public void blowUpOnFilenameNull() {
+ //noinspection DataFlowIssue
assertThrows(NullPointerException.class, () -> FileUtils.filename(null));
}
@Test
- public void filenameEmpty() throws Exception {
+ public void filenameEmpty() {
assertEquals("", FileUtils.filename(""));
}
@Test
- public void filenameFilename() throws Exception {
+ public void filenameFilename() {
assertEquals("foo.bar.txt", FileUtils.filename("foo.bar.txt"));
}
@Test
- // X @ReproducesPlexusBug( "assumes that the path is a local path" )
- public void filenameWindowsRootPathOnUnix() throws Exception {
- assumeTrue(File.separatorChar == '/');
+ @DisabledOnOs(OS.WINDOWS)
+ public void filenameWindowsRootPathOnUnix() {
assertEquals("C:\\foo.bar.txt", FileUtils.filename("C:\\foo.bar.txt"));
}
@Test
- // X @ReproducesPlexusBug( "assumes that the path is a local path" )
- public void filenameWindowsNonRootPathOnUnix() throws Exception {
- assumeTrue(File.separatorChar == '/');
+ @DisabledOnOs(OS.WINDOWS)
+ public void filenameWindowsNonRootPathOnUnix() {
assertEquals("C:\\test\\foo.bar.txt", FileUtils.filename("C:\\test\\foo.bar.txt"));
}
@Test
- // X @ReproducesPlexusBug( "assumes that the path is a local path" )
- public void filenameUnixRootPathOnWindows() throws Exception {
- assumeTrue(File.separatorChar == '\\');
+ @EnabledOnOs(OS.WINDOWS)
+ public void filenameUnixRootPathOnWindows() {
assertEquals("/foo.bar.txt", FileUtils.filename("/foo.bar.txt"));
}
@Test
- // X @ReproducesPlexusBug( "assumes that the path is a local path" )
- public void filenameUnixNonRootPathOnWindows() throws Exception {
- assumeTrue(File.separatorChar == '\\');
+ @EnabledOnOs(OS.WINDOWS)
+ public void filenameUnixNonRootPathOnWindows() {
assertEquals("/test/foo.bar.txt", FileUtils.filename("/test/foo.bar.txt"));
}
@Test
- public void filenameWindowsRootPathOnWindows() throws Exception {
- assumeTrue(File.separatorChar == '\\');
+ @EnabledOnOs(OS.WINDOWS)
+ public void filenameWindowsRootPathOnWindows() {
assertEquals("foo.bar.txt", FileUtils.filename("C:\\foo.bar.txt"));
}
@Test
- public void filenameWindowsNonRootPathOnWindows() throws Exception {
- assumeTrue(File.separatorChar == '\\');
+ @EnabledOnOs(OS.WINDOWS)
+ public void filenameWindowsNonRootPathOnWindows() {
assertEquals("foo.bar.txt", FileUtils.filename("C:\\test\\foo.bar.txt"));
}
@Test
- public void filenameUnixRootPathOnUnix() throws Exception {
- assumeTrue(File.separatorChar == '/');
+ @DisabledOnOs(OS.WINDOWS)
+ public void filenameUnixRootPathOnUnix() {
assertEquals("foo.bar.txt", FileUtils.filename("/foo.bar.txt"));
}
@Test
- public void filenameUnixNonRootPathOnUnix() throws Exception {
- assumeTrue(File.separatorChar == '/');
+ @DisabledOnOs(OS.WINDOWS)
+ public void filenameUnixNonRootPathOnUnix() {
assertEquals("foo.bar.txt", FileUtils.filename("/test/foo.bar.txt"));
}
//// extension(String)
@Test
- public void blowUpOnNullExtension() throws Exception {
+ public void blowUpOnNullExtension() {
+ //noinspection DataFlowIssue
assertThrows(NullPointerException.class, () -> FileUtils.extension(null));
}
@Test
- public void extensionEmpty() throws Exception {
+ public void extensionEmpty() {
assertEquals("", FileUtils.extension(""));
}
@Test
- public void extensionFileName() throws Exception {
+ public void extensionFileName() {
assertEquals("txt", FileUtils.extension("foo.bar.txt"));
}
@Test
- public void extensionFileNameNoExtension() throws Exception {
+ public void extensionFileNameNoExtension() {
assertEquals("", FileUtils.extension("foo_bar_txt"));
}
@Test
// X @ReproducesPlexusBug( "assumes that the path is a local path" )
- public void extensionWindowsRootPathOnUnix() throws Exception {
- assumeTrue(File.separatorChar == '/');
+ @DisabledOnOs(OS.WINDOWS)
+ public void extensionWindowsRootPathOnUnix() {
assertEquals("txt", FileUtils.extension("C:\\foo.bar.txt"));
}
@Test
- // X @ReproducesPlexusBug( "assumes that the path is a local path" )
- public void extensionWindowsNonRootPathOnUnix() throws Exception {
- assumeTrue(File.separatorChar == '/');
+ @DisabledOnOs(OS.WINDOWS)
+ public void extensionWindowsNonRootPathOnUnix() {
assertEquals("txt", FileUtils.extension("C:\\test\\foo.bar.txt"));
}
@Test
- // X @ReproducesPlexusBug( "assumes that the path is a local path" )
- public void extensionUnixRootPathOnWindows() throws Exception {
- assumeTrue(File.separatorChar == '\\');
+ @EnabledOnOs(OS.WINDOWS)
+ public void extensionUnixRootPathOnWindows() {
assertEquals("txt", FileUtils.extension("/foo.bar.txt"));
}
@Test
- // X @ReproducesPlexusBug( "assumes that the path is a local path" )
- public void extensionUnixNonRootPathOnWindows() throws Exception {
- assumeTrue(File.separatorChar == '\\');
+ @EnabledOnOs(OS.WINDOWS)
+ public void extensionUnixNonRootPathOnWindows() {
assertEquals("txt", FileUtils.extension("/test/foo.bar.txt"));
}
@Test
- public void extensionWindowsRootPathOnWindows() throws Exception {
- assumeTrue(File.separatorChar == '\\');
+ @EnabledOnOs(OS.WINDOWS)
+ public void extensionWindowsRootPathOnWindows() {
assertEquals("txt", FileUtils.extension("C:\\foo.bar.txt"));
}
@Test
- public void extensionWindowsNonRootPathOnWindows() throws Exception {
- assumeTrue(File.separatorChar == '\\');
+ @EnabledOnOs(OS.WINDOWS)
+ public void extensionWindowsNonRootPathOnWindows() {
assertEquals("txt", FileUtils.extension("C:\\test\\foo.bar.txt"));
}
@Test
@Disabled("Wait until we can run with assembly 2.5 which will support symlinks properly")
+ @DisabledOnOs(OS.WINDOWS)
public void isASymbolicLink() throws IOException {
// This testcase will pass when running under java7 or higher
- assumeFalse(Os.isFamily(Os.FAMILY_WINDOWS));
-
File file = new File("src/test/resources/symlinks/src/symDir");
assertTrue(FileUtils.isSymbolicLink(file));
}
@@ -1228,14 +1191,14 @@ public class FileUtilsTest {
}
@Test
- public void extensionUnixRootPathOnUnix() throws Exception {
- assumeTrue(File.separatorChar == '/');
+ @DisabledOnOs(OS.WINDOWS)
+ public void extensionUnixRootPathOnUnix() {
assertEquals("txt", FileUtils.extension("/foo.bar.txt"));
}
@Test
- public void extensionUnixNonRootPathOnUnix() throws Exception {
- assumeTrue(File.separatorChar == '/');
+ @DisabledOnOs(OS.WINDOWS)
+ public void extensionUnixNonRootPathOnUnix() {
assertEquals("txt", FileUtils.extension("/test/foo.bar.txt"));
}
diff --git a/src/test/java/org/apache/maven/shared/utils/io/IOUtilTest.java b/src/test/java/org/apache/maven/shared/utils/io/IOUtilTest.java
index ed68aa6..d8a9eda 100644
--- a/src/test/java/org/apache/maven/shared/utils/io/IOUtilTest.java
+++ b/src/test/java/org/apache/maven/shared/utils/io/IOUtilTest.java
@@ -38,9 +38,13 @@ import java.util.concurrent.atomic.AtomicBoolean;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
+import static java.nio.charset.StandardCharsets.UTF_16;
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
@SuppressWarnings("deprecation")
public class IOUtilTest {
@@ -48,27 +52,27 @@ public class IOUtilTest {
private static final long INFINITE_LOOP_TIMEOUT = 500;
@Test
- public void closeReaderWithNull() throws Exception {
+ public void closeReaderWithNull() {
IOUtil.close((Reader) null);
}
@Test
- public void closeWriterWithNull() throws Exception {
+ public void closeWriterWithNull() {
IOUtil.close((Writer) null);
}
@Test
- public void closeInputStreamWithNull() throws Exception {
+ public void closeInputStreamWithNull() {
IOUtil.close(nullInputStream());
}
@Test
- public void closeOutputStreamWithNull() throws Exception {
+ public void closeOutputStreamWithNull() {
IOUtil.close(nullOutputStream());
}
@Test
- public void closeReaderWithIOE() throws Exception {
+ public void closeReaderWithIOE() {
IOUtil.close(new BufferedReader(new StringReader(emptyString())) {
@Override
public void close() throws IOException {
@@ -79,7 +83,7 @@ public class IOUtilTest {
}
@Test
- public void closeWriterWithIOE() throws Exception {
+ public void closeWriterWithIOE() {
IOUtil.close(new BufferedWriter(new StringWriter()) {
@Override
public void close() throws IOException {
@@ -90,7 +94,7 @@ public class IOUtilTest {
}
@Test
- public void closeInputStreamWithIOE() throws Exception {
+ public void closeInputStreamWithIOE() {
IOUtil.close(new BufferedInputStream(emptyInputStream()) {
@Override
public void close() throws IOException {
@@ -101,7 +105,7 @@ public class IOUtilTest {
}
@Test
- public void closeOutputStreamWithIOE() throws Exception {
+ public void closeOutputStreamWithIOE() {
IOUtil.close(new BufferedOutputStream(new ByteArrayOutputStream()) {
@Override
public void close() throws IOException {
@@ -112,7 +116,7 @@ public class IOUtilTest {
}
@Test
- public void closeReaderCloses() throws Exception {
+ public void closeReaderCloses() {
final AtomicBoolean closed = new AtomicBoolean(false);
IOUtil.close(new BufferedReader(new StringReader(emptyString())) {
@Override
@@ -121,11 +125,11 @@ public class IOUtilTest {
super.close();
}
});
- assertThat(closed.get(), is(true));
+ assertTrue(closed.get());
}
@Test
- public void closeWriterCloses() throws Exception {
+ public void closeWriterCloses() {
final AtomicBoolean closed = new AtomicBoolean(false);
IOUtil.close(new BufferedWriter(new StringWriter()) {
@Override
@@ -134,11 +138,11 @@ public class IOUtilTest {
super.close();
}
});
- assertThat(closed.get(), is(true));
+ assertTrue(closed.get());
}
@Test
- public void closeInputStreamCloses() throws Exception {
+ public void closeInputStreamCloses() {
final AtomicBoolean closed = new AtomicBoolean(false);
IOUtil.close(new BufferedInputStream(emptyInputStream()) {
@Override
@@ -147,11 +151,11 @@ public class IOUtilTest {
super.close();
}
});
- assertThat(closed.get(), is(true));
+ assertTrue(closed.get());
}
@Test
- public void closeOutputStreamCloses() throws Exception {
+ public void closeOutputStreamCloses() {
final AtomicBoolean closed = new AtomicBoolean(false);
IOUtil.close(new BufferedOutputStream(new ByteArrayOutputStream()) {
@Override
@@ -160,57 +164,64 @@ public class IOUtilTest {
super.close();
}
});
- assertThat(closed.get(), is(true));
+ assertTrue(closed.get());
}
@Test
public void toByteArrayFromString() throws Exception {
- String probe = "A string \u2345\u00ef";
- assertThat(IOUtil.toByteArray(probe), is(probe.getBytes()));
+ String probe = "A string ⍅ï";
+ assertArrayEquals(probe.getBytes(), IOUtil.toByteArray(probe));
}
@Test
public void toByteArrayFromReader() throws Exception {
- String probe = "A string \u2345\u00ef";
- assertThat(IOUtil.toByteArray(new StringReader(probe)), is(probe.getBytes()));
+ String probe = "A string ⍅ï";
+ assertArrayEquals(probe.getBytes(), IOUtil.toByteArray(new StringReader(probe)));
}
@Test
public void toByteArrayFromInputStream() throws Exception {
- String probe = "A string \u2345\u00ef";
- assertThat(
- IOUtil.toByteArray(new DontCloseByteArrayInputStream(IOUtil.toByteArray(probe))), is(probe.getBytes()));
+ String probe = "A string ⍅ï";
+ assertArrayEquals(
+ probe.getBytes(), IOUtil.toByteArray(new DontCloseByteArrayInputStream(IOUtil.toByteArray(probe))));
}
@Test
- public void toByteArrayNullString() throws Exception {
+ public void toByteArrayNullString() {
+ //noinspection DataFlowIssue
assertThrows(NullPointerException.class, () -> IOUtil.toByteArray((String) null));
}
@Test
- public void toByteArrayNullReader() throws Exception {
+ public void toByteArrayNullReader() {
+ //noinspection DataFlowIssue
assertThrows(NullPointerException.class, () -> IOUtil.toByteArray((Reader) null));
}
@Test
- public void toByteArrayNullInputStream() throws Exception {
- assertThrows(NullPointerException.class, () -> IOUtil.toByteArray(nullInputStream()));
+ public void toByteArrayNullInputStream() {
+ assertThrows(NullPointerException.class, () -> {
+ IOUtil.toByteArray(nullInputStream());
+ });
}
@Test
- public void contentEqualNullNull() throws Exception {
+ public void contentEqualNullNull() {
+ //noinspection DataFlowIssue
assertThrows(IOException.class, () -> IOUtil.contentEquals(null, null));
}
@Test
- public void contentEqualNonNullNull() throws Exception {
+ public void contentEqualNonNullNull() {
+ //noinspection DataFlowIssue
assertThrows(
IOException.class,
() -> IOUtil.contentEquals(new DontCloseByteArrayInputStream(emptyByteArray()), null));
}
@Test
- public void contentEqualNullNonNull() throws Exception {
+ public void contentEqualNullNonNull() {
+ //noinspection DataFlowIssue
assertThrows(
IOException.class,
() -> IOUtil.contentEquals(new DontCloseByteArrayInputStream(emptyByteArray()), null));
@@ -218,292 +229,273 @@ public class IOUtilTest {
@Test
public void contentEqualEmptyEmpty() throws Exception {
- assertThat(
- IOUtil.contentEquals(
- new DontCloseByteArrayInputStream(emptyByteArray()),
- new DontCloseByteArrayInputStream(emptyByteArray())),
- is(true));
+ assertTrue(IOUtil.contentEquals(
+ new DontCloseByteArrayInputStream(emptyByteArray()),
+ new DontCloseByteArrayInputStream(emptyByteArray())));
}
@Test
public void contentEqualNonEmptyEmpty() throws Exception {
- assertThat(
- IOUtil.contentEquals(
- new DontCloseByteArrayInputStream(new byte[1]),
- new DontCloseByteArrayInputStream(emptyByteArray())),
- is(false));
+ assertFalse(IOUtil.contentEquals(
+ new DontCloseByteArrayInputStream(new byte[1]), new DontCloseByteArrayInputStream(emptyByteArray())));
}
@Test
public void contentEqualEmptyNonEmpty() throws Exception {
- assertThat(
- IOUtil.contentEquals(
- new DontCloseByteArrayInputStream(emptyByteArray()),
- new DontCloseByteArrayInputStream(new byte[1])),
- is(false));
+ assertFalse(IOUtil.contentEquals(
+ new DontCloseByteArrayInputStream(emptyByteArray()), new DontCloseByteArrayInputStream(new byte[1])));
}
@Test
public void contentEqualNonEmptyNonEmpty() throws Exception {
- assertThat(
- IOUtil.contentEquals(
- new DontCloseByteArrayInputStream(new byte[1]), new DontCloseByteArrayInputStream(new byte[1])),
- is(true));
+ assertTrue(IOUtil.contentEquals(
+ new DontCloseByteArrayInputStream(new byte[1]), new DontCloseByteArrayInputStream(new byte[1])));
}
@Test
public void contentEqualMostlySame() throws Exception {
- assertThat(
- IOUtil.contentEquals(
- new DontCloseByteArrayInputStream(new byte[] {1, 2, 3, 4, 5, 6}),
- new DontCloseByteArrayInputStream(new byte[] {1, 2, 3, 4, 5, 7})),
- is(false));
+ assertFalse(IOUtil.contentEquals(
+ new DontCloseByteArrayInputStream(new byte[] {1, 2, 3, 4, 5, 6}),
+ new DontCloseByteArrayInputStream(new byte[] {1, 2, 3, 4, 5, 7})));
}
@Test
public void contentEqualLargeSame() throws Exception {
- assertThat(
- IOUtil.contentEquals(
- new DontCloseByteArrayInputStream(new byte[8192]),
- new DontCloseByteArrayInputStream(new byte[8192])),
- is(true));
+ assertTrue(IOUtil.contentEquals(
+ new DontCloseByteArrayInputStream(new byte[8192]), new DontCloseByteArrayInputStream(new byte[8192])));
}
@Test
public void contentEqualLargeDifferent() throws Exception {
byte[] buf = new byte[8192];
buf[8191] = 1;
- assertThat(
- IOUtil.contentEquals(
- new DontCloseByteArrayInputStream(new byte[8192]), new DontCloseByteArrayInputStream(buf)),
- is(false));
+ assertFalse(IOUtil.contentEquals(
+ new DontCloseByteArrayInputStream(new byte[8192]), new DontCloseByteArrayInputStream(buf)));
}
@Test
- public void toStringNullByteArray() throws Exception {
+ public void toStringNullByteArray() {
assertThrows(NullPointerException.class, () -> IOUtil.toString(nullByteArray()));
}
@Test
public void toStringEmptyByteArray() throws Exception {
- assertThat(IOUtil.toString(emptyByteArray()), is(emptyString()));
+ assertEquals(emptyString(), IOUtil.toString(emptyByteArray()));
}
@Test
public void toStringByteArray() throws Exception {
- String probe = "A string \u2345\u00ef";
- assertThat(IOUtil.toString(probe.getBytes()).getBytes(), is(probe.getBytes()));
+ String probe = "A string ⍅ï";
+ assertArrayEquals(probe.getBytes(), IOUtil.toString(probe.getBytes()).getBytes());
}
@Test
- public void toStringNullByteArrayNegBufSz() throws Exception {
+ public void toStringNullByteArrayNegBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.toString(nullByteArray(), -1));
}
@Test
- public void toStringEmptyByteArrayNegBufSz() throws Exception {
+ public void toStringEmptyByteArrayNegBufSz() {
assertThrows(
NegativeArraySizeException.class,
- () -> assertThat(IOUtil.toString(emptyByteArray(), -1), is(emptyString())));
+ () -> assertEquals(IOUtil.toString(emptyByteArray(), -1), emptyString()));
}
@Test
- public void toStringByteArrayNegBufSz() throws Exception {
+ public void toStringByteArrayNegBufSz() {
assertThrows(NegativeArraySizeException.class, () -> {
- String probe = "A string \u2345\u00ef";
- assertThat(IOUtil.toString(probe.getBytes(), -1), is(probe));
+ String probe = "A string ⍅ï";
+ assertEquals(probe, IOUtil.toString(probe.getBytes(), -1));
});
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void toStringNullByteArrayZeroBufSz() throws Exception {
+ public void toStringNullByteArrayZeroBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.toString(nullByteArray(), 0));
}
@Test
- public void toStringNullByteArrayPosBufSz() throws Exception {
+ public void toStringNullByteArrayPosBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.toString(nullByteArray(), 1));
}
@Test
public void toStringEmptyByteArrayPosBufSz() throws Exception {
- assertThat(IOUtil.toString(emptyByteArray(), 1), is(emptyString()));
+ assertEquals(emptyString(), IOUtil.toString(emptyByteArray(), 1));
}
@Test
public void toStringByteArrayPosBufSz() throws Exception {
- String probe = "A string \u2345\u00ef";
- assertThat(IOUtil.toString(probe.getBytes(), 1).getBytes(), is(probe.getBytes()));
+ String probe = "A string ⍅ï";
+ assertArrayEquals(probe.getBytes(), IOUtil.toString(probe.getBytes(), 1).getBytes());
}
@Test
- public void toStringNullByteArrayNullEncoding() throws Exception {
+ public void toStringNullByteArrayNullEncoding() {
assertThrows(NullPointerException.class, () -> IOUtil.toString(nullByteArray(), null));
}
@Test
- public void toStringEmptyByteArrayNullEncoding() throws Exception {
- assertThrows(
- NullPointerException.class,
- () -> assertThat(IOUtil.toString(emptyByteArray(), null), is(emptyString())));
+ public void toStringEmptyByteArrayNullEncoding() {
+ assertThrows(NullPointerException.class, () -> IOUtil.toString(emptyByteArray(), null));
}
@Test
- public void toStringByteArrayNullEncoding() throws Exception {
+ public void toStringByteArrayNullEncoding() {
assertThrows(NullPointerException.class, () -> {
- String probe = "A string \u2345\u00ef";
- assertThat(IOUtil.toString(probe.getBytes(), null).getBytes(), is(probe.getBytes()));
+ String probe = "A string ⍅ï";
+ IOUtil.toString(probe.getBytes(), null).getBytes();
});
}
@Test
- public void toStringNullByteArrayJunkEncoding() throws Exception {
+ public void toStringNullByteArrayJunkEncoding() {
assertThrows(NullPointerException.class, () -> IOUtil.toString(nullByteArray(), "junk"));
}
@Test
- public void toStringEmptyByteArrayJunkEncoding() throws Exception {
+ public void toStringEmptyByteArrayJunkEncoding() {
assertThrows(
UnsupportedEncodingException.class,
- () -> assertThat(IOUtil.toString(emptyByteArray(), "junk"), is(emptyString())));
+ () -> assertEquals(IOUtil.toString(emptyByteArray(), "junk"), emptyString()));
}
@Test
- public void toStringByteArrayJunkEncoding() throws Exception {
+ public void toStringByteArrayJunkEncoding() {
assertThrows(UnsupportedEncodingException.class, () -> {
- String probe = "A string \u2345\u00ef";
- assertThat(IOUtil.toString(probe.getBytes(), "junk").getBytes(), is(probe.getBytes()));
+ String probe = "A string ⍅ï";
+ assertArrayEquals(IOUtil.toString(probe.getBytes(), "junk").getBytes(), probe.getBytes());
});
}
@Test
- public void toStringNullByteArrayValidEncoding() throws Exception {
+ public void toStringNullByteArrayValidEncoding() {
assertThrows(NullPointerException.class, () -> IOUtil.toString(nullByteArray(), "utf-16"));
}
@Test
public void toStringEmptyByteArrayValidEncoding() throws Exception {
- assertThat(IOUtil.toString(emptyByteArray(), "utf-16"), is(emptyString()));
+ assertEquals(IOUtil.toString(emptyByteArray(), "utf-16"), emptyString());
}
@Test
public void toStringByteArrayValidEncoding() throws Exception {
- String probe = "A string \u2345\u00ef";
- assertThat(IOUtil.toString(probe.getBytes("utf-16"), "utf-16").getBytes("utf-8"), is(probe.getBytes("utf-8")));
+ String probe = "A string ⍅ï";
+ assertArrayEquals(
+ IOUtil.toString(probe.getBytes("utf-16"), "utf-16").getBytes("utf-8"), probe.getBytes("utf-8"));
}
@Test
- public void toStringNullByteArrayNullEncodingNegBufSz() throws Exception {
+ public void toStringNullByteArrayNullEncodingNegBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.toString(nullByteArray(), null, -1));
}
@Test
- public void toStringEmptyByteArrayNullEncodingNegBufSz() throws Exception {
+ public void toStringEmptyByteArrayNullEncodingNegBufSz() {
assertThrows(
NullPointerException.class,
- () -> assertThat(IOUtil.toString(emptyByteArray(), null, -1), is(emptyString())));
+ () -> assertEquals(IOUtil.toString(emptyByteArray(), null, -1), emptyString()));
}
@Test
- public void toStringByteArrayNullEncodingNegBufSz() throws Exception {
+ public void toStringByteArrayNullEncodingNegBufSz() {
assertThrows(NullPointerException.class, () -> {
- String probe = "A string \u2345\u00ef";
- assertThat(IOUtil.toString(probe.getBytes(), null, -1).getBytes(), is(probe.getBytes()));
+ String probe = "A string ⍅ï";
+ assertArrayEquals(IOUtil.toString(probe.getBytes(), null, -1).getBytes(), probe.getBytes());
});
}
@Test
- public void toStringNullByteArrayJunkEncodingNegBufSz() throws Exception {
+ public void toStringNullByteArrayJunkEncodingNegBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.toString(nullByteArray(), "junk", -1));
}
@Test
- public void toStringEmptyByteArrayJunkEncodingNegBufSz() throws Exception {
+ public void toStringEmptyByteArrayJunkEncodingNegBufSz() {
assertThrows(
UnsupportedEncodingException.class,
- () -> assertThat(IOUtil.toString(emptyByteArray(), "junk", -1), is(emptyString())));
+ () -> assertEquals(IOUtil.toString(emptyByteArray(), "junk", -1), emptyString()));
}
@Test
- public void toStringByteArrayJunkEncodingNegBufSz() throws Exception {
+ public void toStringByteArrayJunkEncodingNegBufSz() {
assertThrows(UnsupportedEncodingException.class, () -> {
- String probe = "A string \u2345\u00ef";
- assertThat(IOUtil.toString(probe.getBytes(), "junk", -1).getBytes(), is(probe.getBytes()));
+ String probe = "A string ⍅ï";
+ assertEquals(IOUtil.toString(probe.getBytes(), "junk", -1).getBytes(), probe.getBytes());
});
}
@Test
- public void toStringNullByteArrayValidEncodingNegBufSz() throws Exception {
+ public void toStringNullByteArrayValidEncodingNegBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.toString(nullByteArray(), "utf-16", -1));
}
@Test
- public void toStringEmptyByteArrayValidEncodingNegBufSz() throws Exception {
+ public void toStringEmptyByteArrayValidEncodingNegBufSz() {
assertThrows(
NegativeArraySizeException.class,
- () -> assertThat(IOUtil.toString(emptyByteArray(), "utf-16", -1), is(emptyString())));
+ () -> assertEquals(IOUtil.toString(emptyByteArray(), "utf-16", -1), emptyString()));
}
@Test
- public void toStringByteArrayValidEncodingNegBufSz() throws Exception {
+ public void toStringByteArrayValidEncodingNegBufSz() {
assertThrows(NegativeArraySizeException.class, () -> {
- String probe = "A string \u2345\u00ef";
- assertThat(
- IOUtil.toString(probe.getBytes("utf-16"), "utf-16", -1).getBytes("utf-8"),
- is(probe.getBytes("utf-8")));
+ String probe = "A string ⍅ï";
+ assertArrayEquals(
+ IOUtil.toString(probe.getBytes("utf-16"), "utf-16", -1).getBytes(UTF_8), probe.getBytes(UTF_8));
});
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void toStringNullByteArrayNullEncodingZeroBufSz() throws Exception {
+ public void toStringNullByteArrayNullEncodingZeroBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.toString(nullByteArray(), null, 0));
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void toStringEmptyByteArrayNullEncodingZeroBufSz() throws Exception {
+ public void toStringEmptyByteArrayNullEncodingZeroBufSz() {
assertThrows(
NullPointerException.class,
- () -> assertThat(IOUtil.toString(emptyByteArray(), null, 0), is(emptyString())));
+ () -> assertEquals(IOUtil.toString(emptyByteArray(), null, 0), emptyString()));
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void toStringByteArrayNullEncodingZeroBufSz() throws Exception {
+ public void toStringByteArrayNullEncodingZeroBufSz() {
assertThrows(NullPointerException.class, () -> {
- String probe = "A string \u2345\u00ef";
- assertThat(IOUtil.toString(probe.getBytes(), null, 0).getBytes(), is(probe.getBytes()));
+ String probe = "A string ⍅ï";
+ assertArrayEquals(IOUtil.toString(probe.getBytes(), null, 0).getBytes(), probe.getBytes());
});
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void toStringNullByteArrayJunkEncodingZeroBufSz() throws Exception {
+ public void toStringNullByteArrayJunkEncodingZeroBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.toString(nullByteArray(), "junk", 0));
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void toStringEmptyByteArrayJunkEncodingZeroBufSz() throws Exception {
+ public void toStringEmptyByteArrayJunkEncodingZeroBufSz() {
assertThrows(
UnsupportedEncodingException.class,
- () -> assertThat(IOUtil.toString(emptyByteArray(), "junk", 0), is(emptyString())));
+ () -> assertEquals(IOUtil.toString(emptyByteArray(), "junk", 0), emptyString()));
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void toStringByteArrayJunkEncodingZeroBufSz() throws Exception {
+ public void toStringByteArrayJunkEncodingZeroBufSz() {
assertThrows(UnsupportedEncodingException.class, () -> {
- String probe = "A string \u2345\u00ef";
- assertThat(IOUtil.toString(probe.getBytes(), "junk", 0).getBytes(), is(probe.getBytes()));
+ String probe = "A string ⍅ï";
+ assertArrayEquals(IOUtil.toString(probe.getBytes(), "junk", 0).getBytes(), probe.getBytes());
});
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void toStringNullByteArrayValidEncodingZeroBufSz() throws Exception {
+ public void toStringNullByteArrayValidEncodingZeroBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.toString(nullByteArray(), "utf-16", 0));
}
@@ -512,18 +504,18 @@ public class IOUtilTest {
*/
@Test
- public void copyNullByteArrayNullOutputStream() throws Exception {
+ public void copyNullByteArrayNullOutputStream() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullByteArray(), nullOutputStream()));
}
@Test
- public void copyNullByteArrayValidOutputStream() throws Exception {
+ public void copyNullByteArrayValidOutputStream() {
assertThrows(
NullPointerException.class, () -> IOUtil.copy(nullByteArray(), new DontCloseByteArrayOutputStream()));
}
@Test
- public void copyEmptyByteArrayNullOutputStream() throws Exception {
+ public void copyEmptyByteArrayNullOutputStream() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(emptyByteArray(), nullOutputStream()));
}
@@ -537,7 +529,7 @@ public class IOUtilTest {
ByteArrayOutputStream outputStream = new DontCloseByteArrayOutputStream();
byte[] input = {1, 2, 3, 4, 5, 6};
IOUtil.copy(input, outputStream);
- assertThat(outputStream.toByteArray(), is(input));
+ assertArrayEquals(input, outputStream.toByteArray());
}
/*
@@ -545,18 +537,18 @@ public class IOUtilTest {
*/
@Test
- public void copyNullByteArrayNullOutputStreamNegBufSz() throws Exception {
+ public void copyNullByteArrayNullOutputStreamNegBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullByteArray(), nullOutputStream()));
}
@Test
- public void copyNullByteArrayValidOutputStreamNegBufSz() throws Exception {
+ public void copyNullByteArrayValidOutputStreamNegBufSz() {
assertThrows(
NullPointerException.class, () -> IOUtil.copy(nullByteArray(), new DontCloseByteArrayOutputStream()));
}
@Test
- public void copyEmptyByteArrayNullOutputStreamNegBufSz() throws Exception {
+ public void copyEmptyByteArrayNullOutputStreamNegBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(emptyByteArray(), nullOutputStream()));
}
@@ -570,25 +562,25 @@ public class IOUtilTest {
ByteArrayOutputStream outputStream = new DontCloseByteArrayOutputStream();
byte[] input = {1, 2, 3, 4, 5, 6};
IOUtil.copy(input, outputStream);
- assertThat(outputStream.toByteArray(), is(input));
+ assertArrayEquals(input, outputStream.toByteArray());
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyNullByteArrayNullOutputStreamZeroBufSz() throws Exception {
+ public void copyNullByteArrayNullOutputStreamZeroBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullByteArray(), nullOutputStream()));
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyNullByteArrayValidOutputStreamZeroBufSz() throws Exception {
+ public void copyNullByteArrayValidOutputStreamZeroBufSz() {
assertThrows(
NullPointerException.class, () -> IOUtil.copy(nullByteArray(), new DontCloseByteArrayOutputStream()));
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyEmptyByteArrayNullOutputStreamZeroBufSz() throws Exception {
+ public void copyEmptyByteArrayNullOutputStreamZeroBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(emptyByteArray(), nullOutputStream()));
}
@@ -604,25 +596,25 @@ public class IOUtilTest {
ByteArrayOutputStream outputStream = new DontCloseByteArrayOutputStream();
byte[] input = {1, 2, 3, 4, 5, 6};
IOUtil.copy(input, outputStream);
- assertThat(outputStream.toByteArray(), is(input));
+ assertArrayEquals(input, outputStream.toByteArray());
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyNullByteArrayNullOutputStreamPosBufSz() throws Exception {
+ public void copyNullByteArrayNullOutputStreamPosBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullByteArray(), nullOutputStream()));
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyNullByteArrayValidOutputStreamPosBufSz() throws Exception {
+ public void copyNullByteArrayValidOutputStreamPosBufSz() {
assertThrows(
NullPointerException.class, () -> IOUtil.copy(nullByteArray(), new DontCloseByteArrayOutputStream()));
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyEmptyByteArrayNullOutputStreamPosBufSz() throws Exception {
+ public void copyEmptyByteArrayNullOutputStreamPosBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(emptyByteArray(), nullOutputStream()));
}
@@ -638,16 +630,16 @@ public class IOUtilTest {
ByteArrayOutputStream outputStream = new DontCloseByteArrayOutputStream();
byte[] input = {1, 2, 3, 4, 5, 6};
IOUtil.copy(input, outputStream);
- assertThat(outputStream.toByteArray(), is(input));
+ assertArrayEquals(input, outputStream.toByteArray());
}
@Test
- public void copyNullInputStreamNullOutputStream() throws Exception {
+ public void copyNullInputStreamNullOutputStream() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullInputStream(), nullOutputStream()));
}
@Test
- public void copyNullInputStreamValidOutputStream() throws Exception {
+ public void copyNullInputStreamValidOutputStream() {
assertThrows(
NullPointerException.class, () -> IOUtil.copy(nullInputStream(), new DontCloseByteArrayOutputStream()));
}
@@ -667,30 +659,30 @@ public class IOUtilTest {
ByteArrayOutputStream outputStream = new DontCloseByteArrayOutputStream();
byte[] input = {1, 2, 3, 4, 5, 6};
IOUtil.copy(new DontCloseByteArrayInputStream(input), outputStream);
- assertThat(outputStream.toByteArray(), is(input));
+ assertArrayEquals(input, outputStream.toByteArray());
}
@Test
- public void copyNullInputStreamNullOutputStreamNegBufSz() throws Exception {
+ public void copyNullInputStreamNullOutputStreamNegBufSz() {
assertThrows(NegativeArraySizeException.class, () -> IOUtil.copy(nullInputStream(), nullOutputStream(), -1));
}
@Test
- public void copyNullInputStreamValidOutputStreamNegBufSz() throws Exception {
+ public void copyNullInputStreamValidOutputStreamNegBufSz() {
assertThrows(
NegativeArraySizeException.class,
() -> IOUtil.copy(nullInputStream(), new DontCloseByteArrayOutputStream(), -1));
}
@Test
- public void copyEmptyInputStreamNullOutputStreamNegBufSz() throws Exception {
+ public void copyEmptyInputStreamNullOutputStreamNegBufSz() {
assertThrows(
NegativeArraySizeException.class,
() -> IOUtil.copy(new DontCloseByteArrayInputStream(emptyByteArray()), nullOutputStream(), -1));
}
@Test
- public void copyEmptyInputStreamValidOutputStreamNegBufSz() throws Exception {
+ public void copyEmptyInputStreamValidOutputStreamNegBufSz() {
assertThrows(
NegativeArraySizeException.class,
() -> IOUtil.copy(
@@ -698,24 +690,24 @@ public class IOUtilTest {
}
@Test
- public void copyInputStreamValidOutputStreamNegBufSz() throws Exception {
+ public void copyInputStreamValidOutputStreamNegBufSz() {
assertThrows(NegativeArraySizeException.class, () -> {
ByteArrayOutputStream outputStream = new DontCloseByteArrayOutputStream();
byte[] input = {1, 2, 3, 4, 5, 6};
IOUtil.copy(new DontCloseByteArrayInputStream(input), outputStream, -1);
- assertThat(outputStream.toByteArray(), is(input));
+ assertEquals(input, outputStream.toByteArray());
});
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyNullInputStreamNullOutputStreamZeroBufSz() throws Exception {
+ public void copyNullInputStreamNullOutputStreamZeroBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullInputStream(), nullOutputStream(), 0));
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyNullInputStreamValidOutputStreamZeroBufSz() throws Exception {
+ public void copyNullInputStreamValidOutputStreamZeroBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullInputStream(), new ByteArrayOutputStream(), 0));
}
@@ -733,13 +725,13 @@ public class IOUtilTest {
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyNullInputStreamNullOutputStreamPosBufSz() throws Exception {
+ public void copyNullInputStreamNullOutputStreamPosBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullInputStream(), nullOutputStream(), 1));
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyNullInputStreamValidOutputStreamPosBufSz() throws Exception {
+ public void copyNullInputStreamValidOutputStreamPosBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullInputStream(), new ByteArrayOutputStream(), 1));
}
@@ -761,257 +753,259 @@ public class IOUtilTest {
ByteArrayOutputStream outputStream = new DontCloseByteArrayOutputStream();
byte[] input = {1, 2, 3, 4, 5, 6};
IOUtil.copy(new DontCloseByteArrayInputStream(input), outputStream, 1);
- assertThat(outputStream.toByteArray(), is(input));
+ assertArrayEquals(input, outputStream.toByteArray());
}
@Test
- public void toStringNullInputStream() throws Exception {
+ public void toStringNullInputStream() {
assertThrows(NullPointerException.class, () -> IOUtil.toString(nullInputStream()));
}
@Test
public void toStringEmptyInputStream() throws Exception {
- assertThat(IOUtil.toString(emptyInputStream()), is(emptyString()));
+ assertEquals(emptyString(), IOUtil.toString(emptyInputStream()));
}
@Test
public void toStringInputStream() throws Exception {
- String probe = "A string \u2345\u00ef";
- assertThat(IOUtil.toString(new ByteArrayInputStream(probe.getBytes())).getBytes(), is(probe.getBytes()));
+ String probe = "A string ⍅ï";
+ assertArrayEquals(
+ probe.getBytes(),
+ IOUtil.toString(new ByteArrayInputStream(probe.getBytes())).getBytes());
}
@Test
- public void toStringNullInputStreamNegBufSz() throws Exception {
+ public void toStringNullInputStreamNegBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.toString(nullInputStream(), -1));
}
@Test
- public void toStringEmptyInputStreamNegBufSz() throws Exception {
+ public void toStringEmptyInputStreamNegBufSz() {
assertThrows(
NegativeArraySizeException.class,
- () -> assertThat(IOUtil.toString(emptyInputStream(), -1), is(emptyString())));
+ () -> assertEquals(IOUtil.toString(emptyInputStream(), -1), emptyString()));
}
@Test
- public void toStringInputStreamNegBufSz() throws Exception {
+ public void toStringInputStreamNegBufSz() {
assertThrows(NegativeArraySizeException.class, () -> {
- String probe = "A string \u2345\u00ef";
- assertThat(IOUtil.toString(new ByteArrayInputStream(probe.getBytes()), -1), is(probe));
+ String probe = "A string ⍅ï";
+ assertEquals(probe, IOUtil.toString(new ByteArrayInputStream(probe.getBytes()), -1));
});
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void toStringNullInputStreamZeroBufSz() throws Exception {
+ public void toStringNullInputStreamZeroBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.toString(nullInputStream(), 0));
}
@Test
- public void toStringNullInputStreamPosBufSz() throws Exception {
+ public void toStringNullInputStreamPosBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.toString(nullInputStream(), 1));
}
@Test
public void toStringEmptyInputStreamPosBufSz() throws Exception {
- assertThat(IOUtil.toString(emptyInputStream(), 1), is(emptyString()));
+ assertEquals(IOUtil.toString(emptyInputStream(), 1), emptyString());
}
@Test
public void toStringInputStreamPosBufSz() throws Exception {
- String probe = "A string \u2345\u00ef";
- assertThat(
- IOUtil.toString(new ByteArrayInputStream(probe.getBytes()), 1).getBytes(), is(probe.getBytes()));
+ String probe = "A string ⍅ï";
+ assertArrayEquals(
+ IOUtil.toString(new ByteArrayInputStream(probe.getBytes()), 1).getBytes(), probe.getBytes());
}
@Test
- public void toStringNullInputStreamNullEncoding() throws Exception {
+ public void toStringNullInputStreamNullEncoding() {
assertThrows(NullPointerException.class, () -> IOUtil.toString(nullInputStream(), null));
}
@Test
- public void toStringEmptyInputStreamNullEncoding() throws Exception {
+ public void toStringEmptyInputStreamNullEncoding() {
assertThrows(
NullPointerException.class,
- () -> assertThat(IOUtil.toString(emptyInputStream(), null), is(emptyString())));
+ () -> assertEquals(IOUtil.toString(emptyInputStream(), null), emptyString()));
}
@Test
- public void toStringInputStreamNullEncoding() throws Exception {
+ public void toStringInputStreamNullEncoding() {
assertThrows(NullPointerException.class, () -> {
- String probe = "A string \u2345\u00ef";
- assertThat(
+ String probe = "A string ⍅ï";
+ assertEquals(
IOUtil.toString(new ByteArrayInputStream(probe.getBytes()), null)
.getBytes(),
- is(probe.getBytes()));
+ probe.getBytes());
});
}
@Test
- public void toStringNullInputStreamJunkEncoding() throws Exception {
+ public void toStringNullInputStreamJunkEncoding() {
assertThrows(NullPointerException.class, () -> IOUtil.toString(nullInputStream(), "junk"));
}
@Test
- public void toStringEmptyInputStreamJunkEncoding() throws Exception {
+ public void toStringEmptyInputStreamJunkEncoding() {
assertThrows(
UnsupportedEncodingException.class,
- () -> assertThat(IOUtil.toString(emptyInputStream(), "junk"), is(emptyString())));
+ () -> assertEquals(IOUtil.toString(emptyInputStream(), "junk"), emptyString()));
}
@Test
- public void toStringInputStreamJunkEncoding() throws Exception {
+ public void toStringInputStreamJunkEncoding() {
assertThrows(UnsupportedEncodingException.class, () -> {
- String probe = "A string \u2345\u00ef";
- assertThat(
+ String probe = "A string ⍅ï";
+ assertEquals(
IOUtil.toString(new ByteArrayInputStream(probe.getBytes()), "junk")
.getBytes(),
- is(probe.getBytes()));
+ probe.getBytes());
});
}
@Test
- public void toStringNullInputStreamValidEncoding() throws Exception {
+ public void toStringNullInputStreamValidEncoding() {
assertThrows(NullPointerException.class, () -> IOUtil.toString(nullInputStream(), "utf-16"));
}
@Test
public void toStringEmptyInputStreamValidEncoding() throws Exception {
- assertThat(IOUtil.toString(emptyInputStream(), "utf-16"), is(emptyString()));
+ assertEquals(IOUtil.toString(emptyInputStream(), "utf-16"), emptyString());
}
@Test
public void toStringInputStreamValidEncoding() throws Exception {
- String probe = "A string \u2345\u00ef";
- assertThat(
+ String probe = "A string ⍅ï";
+ assertArrayEquals(
IOUtil.toString(new ByteArrayInputStream(probe.getBytes("utf-16")), "utf-16")
.getBytes("utf-8"),
- is(probe.getBytes("utf-8")));
+ probe.getBytes("utf-8"));
}
@Test
- public void toStringNullInputStreamNullEncodingNegBufSz() throws Exception {
+ public void toStringNullInputStreamNullEncodingNegBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.toString(nullInputStream(), null, -1));
}
@Test
- public void toStringEmptyInputStreamNullEncodingNegBufSz() throws Exception {
+ public void toStringEmptyInputStreamNullEncodingNegBufSz() {
assertThrows(
NullPointerException.class,
- () -> assertThat(IOUtil.toString(emptyInputStream(), null, -1), is(emptyString())));
+ () -> assertEquals(IOUtil.toString(emptyInputStream(), null, -1), emptyString()));
}
@Test
- public void toStringInputStreamNullEncodingNegBufSz() throws Exception {
+ public void toStringInputStreamNullEncodingNegBufSz() {
assertThrows(NullPointerException.class, () -> {
- String probe = "A string \u2345\u00ef";
- assertThat(
+ String probe = "A string ⍅ï";
+ assertEquals(
IOUtil.toString(new ByteArrayInputStream(probe.getBytes()), null, -1)
.getBytes(),
- is(probe.getBytes()));
+ probe.getBytes());
});
}
@Test
- public void toStringNullInputStreamJunkEncodingNegBufSz() throws Exception {
+ public void toStringNullInputStreamJunkEncodingNegBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.toString(nullInputStream(), "junk", -1));
}
@Test
- public void toStringEmptyInputStreamJunkEncodingNegBufSz() throws Exception {
+ public void toStringEmptyInputStreamJunkEncodingNegBufSz() {
assertThrows(
UnsupportedEncodingException.class,
- () -> assertThat(IOUtil.toString(emptyInputStream(), "junk", -1), is(emptyString())));
+ () -> assertEquals(IOUtil.toString(emptyInputStream(), "junk", -1), emptyString()));
}
@Test
- public void toStringInputStreamJunkEncodingNegBufSz() throws Exception {
+ public void toStringInputStreamJunkEncodingNegBufSz() {
assertThrows(UnsupportedEncodingException.class, () -> {
- String probe = "A string \u2345\u00ef";
- assertThat(
+ String probe = "A string ⍅ï";
+ assertEquals(
IOUtil.toString(new ByteArrayInputStream(probe.getBytes()), "junk", -1)
.getBytes(),
- is(probe.getBytes()));
+ probe.getBytes());
});
}
@Test
- public void toStringNullInputStreamValidEncodingNegBufSz() throws Exception {
+ public void toStringNullInputStreamValidEncodingNegBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.toString(nullInputStream(), "utf-16", -1));
}
@Test
- public void toStringEmptyInputStreamValidEncodingNegBufSz() throws Exception {
+ public void toStringEmptyInputStreamValidEncodingNegBufSz() {
assertThrows(
NegativeArraySizeException.class,
- () -> assertThat(IOUtil.toString(emptyInputStream(), "utf-16", -1), is(emptyString())));
+ () -> assertEquals(IOUtil.toString(emptyInputStream(), "utf-16", -1), emptyString()));
}
@Test
- public void toStringInputStreamValidEncodingNegBufSz() throws Exception {
+ public void toStringInputStreamValidEncodingNegBufSz() {
assertThrows(NegativeArraySizeException.class, () -> {
- String probe = "A string \u2345\u00ef";
- assertThat(
- IOUtil.toString(new ByteArrayInputStream(probe.getBytes("utf-16")), "utf-16", -1)
- .getBytes("utf-8"),
- is(probe.getBytes("utf-8")));
+ String probe = "A string ⍅ï";
+ assertArrayEquals(
+ IOUtil.toString(new ByteArrayInputStream(probe.getBytes(UTF_16)), "utf-16", -1)
+ .getBytes(UTF_8),
+ probe.getBytes(UTF_8));
});
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void toStringNullInputStreamNullEncodingZeroBufSz() throws Exception {
+ public void toStringNullInputStreamNullEncodingZeroBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.toString(nullInputStream(), null, 0));
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void toStringEmptyInputStreamNullEncodingZeroBufSz() throws Exception {
+ public void toStringEmptyInputStreamNullEncodingZeroBufSz() {
assertThrows(
NullPointerException.class,
- () -> assertThat(IOUtil.toString(emptyInputStream(), null, 0), is(emptyString())));
+ () -> assertEquals(IOUtil.toString(emptyInputStream(), null, 0), emptyString()));
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void toStringInputStreamNullEncodingZeroBufSz() throws Exception {
+ public void toStringInputStreamNullEncodingZeroBufSz() {
assertThrows(NullPointerException.class, () -> {
- String probe = "A string \u2345\u00ef";
- assertThat(
+ String probe = "A string ⍅ï";
+ assertEquals(
IOUtil.toString(new ByteArrayInputStream(probe.getBytes()), null, 0)
.getBytes(),
- is(probe.getBytes()));
+ probe.getBytes());
});
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void toStringNullInputStreamJunkEncodingZeroBufSz() throws Exception {
+ public void toStringNullInputStreamJunkEncodingZeroBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.toString(nullInputStream(), "junk", 0));
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void toStringEmptyInputStreamJunkEncodingZeroBufSz() throws Exception {
+ public void toStringEmptyInputStreamJunkEncodingZeroBufSz() {
assertThrows(
UnsupportedEncodingException.class,
- () -> assertThat(IOUtil.toString(emptyInputStream(), "junk", 0), is(emptyString())));
+ () -> assertEquals(IOUtil.toString(emptyInputStream(), "junk", 0), emptyString()));
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void toStringInputStreamJunkEncodingZeroBufSz() throws Exception {
+ public void toStringInputStreamJunkEncodingZeroBufSz() {
assertThrows(UnsupportedEncodingException.class, () -> {
- String probe = "A string \u2345\u00ef";
- assertThat(
+ String probe = "A string ⍅ï";
+ assertEquals(
IOUtil.toString(new ByteArrayInputStream(probe.getBytes()), "junk", 0)
.getBytes(),
- is(probe.getBytes()));
+ probe.getBytes());
});
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void toStringNullInputStreamValidEncodingZeroBufSz() throws Exception {
+ public void toStringNullInputStreamValidEncodingZeroBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.toString(nullInputStream(), "utf-16", 0));
}
@@ -1020,12 +1014,12 @@ public class IOUtilTest {
*/
@Test
- public void copyNullInputStreamNullWriter() throws Exception {
+ public void copyNullInputStreamNullWriter() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullInputStream(), nullWriter()));
}
@Test
- public void copyEmptyInputStreamNullWriter() throws Exception {
+ public void copyEmptyInputStreamNullWriter() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(emptyInputStream(), nullWriter()));
}
@@ -1033,23 +1027,23 @@ public class IOUtilTest {
public void copyEmptyInputStreamValidWriter() throws Exception {
StringWriter writer = new DontCloseStringWriter();
IOUtil.copy(emptyInputStream(), writer);
- assertThat(writer.toString(), is(emptyString()));
+ assertEquals(emptyString(), writer.toString());
}
@Test
- public void copyInputStreamNullWriter() throws Exception {
+ public void copyInputStreamNullWriter() {
assertThrows(NullPointerException.class, () -> {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
IOUtil.copy(new ByteArrayInputStream(probe.getBytes()), nullWriter());
});
}
@Test
public void copyInputStreamValidWriter() throws Exception {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
StringWriter writer = new DontCloseStringWriter();
IOUtil.copy(new ByteArrayInputStream(probe.getBytes()), writer);
- assertThat(writer.toString().getBytes(), is(probe.getBytes()));
+ assertArrayEquals(probe.getBytes(), writer.toString().getBytes());
}
/*
@@ -1057,70 +1051,70 @@ public class IOUtilTest {
*/
@Test
- public void copyNullInputStreamNullWriterNegBufSz() throws Exception {
+ public void copyNullInputStreamNullWriterNegBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullInputStream(), nullWriter(), -1));
}
@Test
- public void copyEmptyInputStreamNullWriterNegBufSz() throws Exception {
+ public void copyEmptyInputStreamNullWriterNegBufSz() {
assertThrows(NegativeArraySizeException.class, () -> IOUtil.copy(emptyInputStream(), nullWriter(), -1));
}
@Test
- public void copyEmptyInputStreamValidWriterNegBufSz() throws Exception {
+ public void copyEmptyInputStreamValidWriterNegBufSz() {
assertThrows(
NegativeArraySizeException.class,
() -> IOUtil.copy(emptyInputStream(), new DontCloseStringWriter(), -1));
}
@Test
- public void copyInputStreamNullWriterNegBufSz() throws Exception {
+ public void copyInputStreamNullWriterNegBufSz() {
assertThrows(NegativeArraySizeException.class, () -> {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
IOUtil.copy(new ByteArrayInputStream(probe.getBytes()), nullWriter(), -1);
});
}
@Test
- public void copyInputStreamValidWriterNegBufSz() throws Exception {
+ public void copyInputStreamValidWriterNegBufSz() {
assertThrows(NegativeArraySizeException.class, () -> {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
StringWriter writer = new DontCloseStringWriter();
IOUtil.copy(new ByteArrayInputStream(probe.getBytes()), writer, -1);
- assertThat(writer.toString().getBytes(), is(probe.getBytes()));
+ assertArrayEquals(probe.getBytes(), writer.toString().getBytes());
});
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyNullInputStreamNullWriterZeroBufSz() throws Exception {
+ public void copyNullInputStreamNullWriterZeroBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullInputStream(), nullWriter(), 0));
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyNullInputStreamValidWriterZeroBufSz() throws Exception {
+ public void copyNullInputStreamValidWriterZeroBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullInputStream(), new DontCloseStringWriter(), 0));
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyEmptyInputStreamNullWriterZeroBufSz() throws Exception {
+ public void copyEmptyInputStreamNullWriterZeroBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(emptyInputStream(), nullWriter(), 0));
}
@Test
- public void copyNullInputStreamNullWriterPosBufSz() throws Exception {
+ public void copyNullInputStreamNullWriterPosBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullInputStream(), nullWriter(), 1));
}
@Test
- public void copyNullInputStreamValidWriterPosBufSz() throws Exception {
+ public void copyNullInputStreamValidWriterPosBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullInputStream(), new DontCloseStringWriter(), 1));
}
@Test
- public void copyEmptyInputStreamNullWriterPosBufSz() throws Exception {
+ public void copyEmptyInputStreamNullWriterPosBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(emptyInputStream(), nullWriter(), 1));
}
@@ -1128,15 +1122,15 @@ public class IOUtilTest {
public void copyEmptyInputStreamValidWriterPosBufSz() throws Exception {
StringWriter writer = new DontCloseStringWriter();
IOUtil.copy(emptyInputStream(), writer, 1);
- assertThat(writer.toString(), is(emptyString()));
+ assertEquals(emptyString(), writer.toString());
}
@Test
public void copyInputStreamValidWriterPosBufSz() throws Exception {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
StringWriter writer = new DontCloseStringWriter();
IOUtil.copy(new ByteArrayInputStream(probe.getBytes()), writer, 1);
- assertThat(writer.toString().getBytes(), is(probe.getBytes()));
+ assertArrayEquals(probe.getBytes(), writer.toString().getBytes());
}
/*
@@ -1144,90 +1138,90 @@ public class IOUtilTest {
*/
@Test
- public void copyNullInputStreamNullWriterNullEncoding() throws Exception {
+ public void copyNullInputStreamNullWriterNullEncoding() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullInputStream(), nullWriter(), null));
}
@Test
- public void copyNullInputStreamValidWriterNullEncoding() throws Exception {
+ public void copyNullInputStreamValidWriterNullEncoding() {
assertThrows(
NullPointerException.class, () -> IOUtil.copy(nullInputStream(), new DontCloseStringWriter(), null));
}
@Test
- public void copyEmptyInputStreamNullWriterNullEncoding() throws Exception {
+ public void copyEmptyInputStreamNullWriterNullEncoding() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(emptyInputStream(), nullWriter(), null));
}
@Test
- public void copyEmptyInputStreamValidWriterNullEncoding() throws Exception {
+ public void copyEmptyInputStreamValidWriterNullEncoding() {
assertThrows(
NullPointerException.class, () -> IOUtil.copy(emptyInputStream(), new DontCloseStringWriter(), null));
}
@Test
- public void copyInputStreamNullEncoding() throws Exception {
+ public void copyInputStreamNullEncoding() {
assertThrows(NullPointerException.class, () -> {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
StringWriter writer = new DontCloseStringWriter();
IOUtil.copy(new ByteArrayInputStream(probe.getBytes()), writer, null);
- assertThat(writer.toString().getBytes(), is(probe.getBytes()));
+ assertArrayEquals(probe.getBytes(), writer.toString().getBytes());
});
}
@Test
- public void copyNullInputStreamNullWriterJunkEncoding() throws Exception {
+ public void copyNullInputStreamNullWriterJunkEncoding() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullInputStream(), nullWriter(), "junk"));
}
@Test
- public void copyNullInputStreamValidWriterJunkEncoding() throws Exception {
+ public void copyNullInputStreamValidWriterJunkEncoding() {
assertThrows(
NullPointerException.class, () -> IOUtil.copy(nullInputStream(), new DontCloseStringWriter(), "junk"));
}
@Test
- public void copyEmptyInputStreamNullWriterJunkEncoding() throws Exception {
+ public void copyEmptyInputStreamNullWriterJunkEncoding() {
assertThrows(UnsupportedEncodingException.class, () -> IOUtil.copy(emptyInputStream(), nullWriter(), "junk"));
}
@Test
- public void copyEmptyInputStreamValidWriterJunkEncoding() throws Exception {
+ public void copyEmptyInputStreamValidWriterJunkEncoding() {
assertThrows(
UnsupportedEncodingException.class,
() -> IOUtil.copy(emptyInputStream(), new DontCloseStringWriter(), "junk"));
}
@Test
- public void copyInputStreamNullWriterJunkEncoding() throws Exception {
+ public void copyInputStreamNullWriterJunkEncoding() {
assertThrows(UnsupportedEncodingException.class, () -> {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
IOUtil.copy(new ByteArrayInputStream(probe.getBytes()), nullWriter(), "junk");
});
}
@Test
- public void copyInputStreamValidWriterJunkEncoding() throws Exception {
+ public void copyInputStreamValidWriterJunkEncoding() {
assertThrows(UnsupportedEncodingException.class, () -> {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
StringWriter writer = new DontCloseStringWriter();
IOUtil.copy(new ByteArrayInputStream(probe.getBytes()), writer, "junk");
- assertThat(writer.toString().getBytes(), is(probe.getBytes()));
+ assertArrayEquals(probe.getBytes(), writer.toString().getBytes());
});
}
@Test
- public void copyNullInputStreamNullWriterValidEncoding() throws Exception {
+ public void copyNullInputStreamNullWriterValidEncoding() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullInputStream(), nullWriter(), "utf-16"));
}
@Test
- public void copyEmptyInputStreamNullWriterValidEncoding() throws Exception {
+ public void copyEmptyInputStreamNullWriterValidEncoding() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(emptyInputStream(), nullWriter(), "utf-16"));
}
@Test
- public void copyNullInputStreamValidWriterValidEncoding() throws Exception {
+ public void copyNullInputStreamValidWriterValidEncoding() {
assertThrows(
NullPointerException.class,
() -> IOUtil.copy(nullInputStream(), new DontCloseStringWriter(), "utf-16"));
@@ -1237,23 +1231,23 @@ public class IOUtilTest {
public void copyEmptyInputStreamValidWriterValidEncoding() throws Exception {
StringWriter writer = new DontCloseStringWriter();
IOUtil.copy(emptyInputStream(), writer, "utf-16");
- assertThat(writer.toString(), is(emptyString()));
+ assertEquals(emptyString(), writer.toString());
}
@Test
- public void copyInputStreamNullWriterValidEncoding() throws Exception {
+ public void copyInputStreamNullWriterValidEncoding() {
assertThrows(NullPointerException.class, () -> {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
IOUtil.copy(new ByteArrayInputStream(probe.getBytes("utf-16")), nullWriter(), "utf-16");
});
}
@Test
public void copyInputStreamValidWriterValidEncoding() throws Exception {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
StringWriter writer = new DontCloseStringWriter();
- IOUtil.copy(new ByteArrayInputStream(probe.getBytes("utf-16")), writer, "utf-16");
- assertThat(writer.toString().getBytes("utf-8"), is(probe.getBytes("utf-8")));
+ IOUtil.copy(new ByteArrayInputStream(probe.getBytes(UTF_16)), writer, "utf-16");
+ assertArrayEquals(probe.getBytes(UTF_8), writer.toString().getBytes(UTF_8));
}
/*
@@ -1261,197 +1255,197 @@ public class IOUtilTest {
*/
@Test
- public void copyNullInputStreamNullWriterNullEncodingNegBufSz() throws Exception {
+ public void copyNullInputStreamNullWriterNullEncodingNegBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullInputStream(), nullWriter(), null, -1));
}
@Test
- public void copyNullInputStreamValidWriterNullEncodingNegBufSz() throws Exception {
+ public void copyNullInputStreamValidWriterNullEncodingNegBufSz() {
assertThrows(
NullPointerException.class,
() -> IOUtil.copy(nullInputStream(), new DontCloseStringWriter(), null, -1));
}
@Test
- public void copyEmptyInputStreamNullWriterNullEncodingNegBufSz() throws Exception {
+ public void copyEmptyInputStreamNullWriterNullEncodingNegBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(emptyInputStream(), nullWriter(), null, -1));
}
@Test
- public void copyEmptyInputStreamValidWriterNullEncodingNegBufSz() throws Exception {
+ public void copyEmptyInputStreamValidWriterNullEncodingNegBufSz() {
assertThrows(NullPointerException.class, () -> {
StringWriter writer = new DontCloseStringWriter();
IOUtil.copy(emptyInputStream(), writer, null, -1);
- assertThat(writer.toString(), is(emptyString()));
+ assertEquals(emptyString(), writer.toString());
});
}
@Test
- public void copyInputStreamNullWriterNullEncodingNegBufSz() throws Exception {
+ public void copyInputStreamNullWriterNullEncodingNegBufSz() {
assertThrows(NullPointerException.class, () -> {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
IOUtil.copy(new ByteArrayInputStream(probe.getBytes()), nullWriter(), null, -1);
});
}
@Test
- public void copyInputStreamValidWriterNullEncodingNegBufSz() throws Exception {
+ public void copyInputStreamValidWriterNullEncodingNegBufSz() {
assertThrows(NullPointerException.class, () -> {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
StringWriter writer = new DontCloseStringWriter();
IOUtil.copy(new ByteArrayInputStream(probe.getBytes()), writer, null, -1);
- assertThat(writer.toString().getBytes(), is(probe.getBytes()));
+ assertArrayEquals(probe.getBytes(), writer.toString().getBytes());
});
}
@Test
- public void copyNullInputStreamNullWriterJunkEncodingNegBufSz() throws Exception {
+ public void copyNullInputStreamNullWriterJunkEncodingNegBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullInputStream(), nullWriter(), "junk", -1));
}
@Test
- public void copyNullInputStreamValidWriterJunkEncodingNegBufSz() throws Exception {
+ public void copyNullInputStreamValidWriterJunkEncodingNegBufSz() {
assertThrows(
NullPointerException.class,
() -> IOUtil.copy(nullInputStream(), new DontCloseStringWriter(), "junk", -1));
}
@Test
- public void copyEmptyInputStreamNullWriterJunkEncodingNegBufSz() throws Exception {
+ public void copyEmptyInputStreamNullWriterJunkEncodingNegBufSz() {
assertThrows(
UnsupportedEncodingException.class, () -> IOUtil.copy(emptyInputStream(), nullWriter(), "junk", -1));
}
@Test
- public void copyEmptyInputStreamJunkEncodingNegBufSz() throws Exception {
+ public void copyEmptyInputStreamJunkEncodingNegBufSz() {
assertThrows(UnsupportedEncodingException.class, () -> {
StringWriter writer = new DontCloseStringWriter();
IOUtil.copy(emptyInputStream(), writer, "junk", -1);
- assertThat(writer.toString(), is(emptyString()));
+ assertEquals(emptyString(), writer.toString());
});
}
@Test
- public void copyInputStreamNullWriterJunkEncodingNegBufSz() throws Exception {
+ public void copyInputStreamNullWriterJunkEncodingNegBufSz() {
assertThrows(UnsupportedEncodingException.class, () -> {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
IOUtil.copy(new ByteArrayInputStream(probe.getBytes()), nullWriter(), "junk", -1);
});
}
@Test
- public void copyInputStreamValidWriterJunkEncodingNegBufSz() throws Exception {
+ public void copyInputStreamValidWriterJunkEncodingNegBufSz() {
assertThrows(UnsupportedEncodingException.class, () -> {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
StringWriter writer = new DontCloseStringWriter();
IOUtil.copy(new ByteArrayInputStream(probe.getBytes()), writer, "junk", -1);
- assertThat(writer.toString().getBytes(), is(probe.getBytes()));
+ assertArrayEquals(probe.getBytes(), writer.toString().getBytes());
});
}
@Test
- public void copyNullInputStreamNullWriterValidEncodingNegBufSz() throws Exception {
+ public void copyNullInputStreamNullWriterValidEncodingNegBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullInputStream(), nullWriter(), "utf-16", -1));
}
@Test
- public void copyNullInputStreamValidWriterValidEncodingNegBufSz() throws Exception {
+ public void copyNullInputStreamValidWriterValidEncodingNegBufSz() {
assertThrows(
NullPointerException.class,
() -> IOUtil.copy(nullInputStream(), new DontCloseStringWriter(), "utf-16", -1));
}
@Test
- public void copyEmptyInputStreamNullWriterValidEncodingNegBufSz() throws Exception {
+ public void copyEmptyInputStreamNullWriterValidEncodingNegBufSz() {
assertThrows(
NegativeArraySizeException.class, () -> IOUtil.copy(emptyInputStream(), nullWriter(), "utf-16", -1));
}
@Test
- public void copyEmptyInputStreamValidWriterValidEncodingNegBufSz() throws Exception {
+ public void copyEmptyInputStreamValidWriterValidEncodingNegBufSz() {
assertThrows(NegativeArraySizeException.class, () -> {
StringWriter writer = new DontCloseStringWriter();
IOUtil.copy(emptyInputStream(), writer, "utf-16", -1);
- assertThat(writer.toString(), is(emptyString()));
+ assertEquals(emptyString(), writer.toString());
});
}
@Test
- public void copyInputStreamNullWriterValidEncodingNegBufSz() throws Exception {
+ public void copyInputStreamNullWriterValidEncodingNegBufSz() {
assertThrows(NegativeArraySizeException.class, () -> {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
IOUtil.copy(new ByteArrayInputStream(probe.getBytes("utf-16")), nullWriter(), -1);
});
}
@Test
- public void copyInputStreamValidEncodingNegBufSz() throws Exception {
+ public void copyInputStreamValidEncodingNegBufSz() {
assertThrows(NegativeArraySizeException.class, () -> {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
StringWriter writer = new DontCloseStringWriter();
- IOUtil.copy(new ByteArrayInputStream(probe.getBytes("utf-16")), writer, "utf-16", -1);
- assertThat(writer.toString().getBytes("utf-8"), is(probe.getBytes("utf-8")));
+ IOUtil.copy(new ByteArrayInputStream(probe.getBytes(UTF_16)), writer, "utf-16", -1);
+ assertEquals(probe.getBytes(UTF_8), writer.toString().getBytes(UTF_8));
});
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyNullInputStreamNullWriterNullEncodingZeroBufSz() throws Exception {
+ public void copyNullInputStreamNullWriterNullEncodingZeroBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullInputStream(), nullWriter(), null, 0));
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyNullInputStreamValidWriterNullEncodingZeroBufSz() throws Exception {
+ public void copyNullInputStreamValidWriterNullEncodingZeroBufSz() {
assertThrows(
NullPointerException.class, () -> IOUtil.copy(nullInputStream(), new DontCloseStringWriter(), null, 0));
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyEmptyInputStreamNullWriterNullEncodingZeroBufSz() throws Exception {
+ public void copyEmptyInputStreamNullWriterNullEncodingZeroBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(emptyInputStream(), nullWriter(), null, 0));
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyEmptyInputStreamValidWriterNullEncodingZeroBufSz() throws Exception {
+ public void copyEmptyInputStreamValidWriterNullEncodingZeroBufSz() {
assertThrows(NullPointerException.class, () -> {
StringWriter writer = new DontCloseStringWriter();
IOUtil.copy(emptyInputStream(), writer, null, 0);
- assertThat(writer.toString(), is(emptyString()));
+ assertEquals(emptyString(), writer.toString());
});
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyInputStreamNullWriterNullEncodingZeroBufSz() throws Exception {
+ public void copyInputStreamNullWriterNullEncodingZeroBufSz() {
assertThrows(NullPointerException.class, () -> {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
IOUtil.copy(new ByteArrayInputStream(probe.getBytes()), nullWriter(), null, 0);
});
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyInputStreamValidWriterNullEncodingZeroBufSz() throws Exception {
+ public void copyInputStreamValidWriterNullEncodingZeroBufSz() {
assertThrows(NullPointerException.class, () -> {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
StringWriter writer = new DontCloseStringWriter();
IOUtil.copy(new ByteArrayInputStream(probe.getBytes()), writer, null, 0);
- assertThat(writer.toString().getBytes(), is(probe.getBytes()));
+ assertArrayEquals(probe.getBytes(), writer.toString().getBytes());
});
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyNullInputStreamNullWriterJunkEncodingZeroBufSz() throws Exception {
+ public void copyNullInputStreamNullWriterJunkEncodingZeroBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullInputStream(), nullWriter(), "junk", 0));
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyNullInputStreamValidWriterJunkEncodingZeroBufSz() throws Exception {
+ public void copyNullInputStreamValidWriterJunkEncodingZeroBufSz() {
assertThrows(
NullPointerException.class,
() -> IOUtil.copy(nullInputStream(), new DontCloseStringWriter(), "junk", 0));
@@ -1459,50 +1453,50 @@ public class IOUtilTest {
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyEmptyInputStreamNullWriterJunkEncodingZeroBufSz() throws Exception {
+ public void copyEmptyInputStreamNullWriterJunkEncodingZeroBufSz() {
assertThrows(
UnsupportedEncodingException.class, () -> IOUtil.copy(emptyInputStream(), nullWriter(), "junk", 0));
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyEmptyInputStreamValidWriterJunkEncodingZeroBufSz() throws Exception {
+ public void copyEmptyInputStreamValidWriterJunkEncodingZeroBufSz() {
assertThrows(UnsupportedEncodingException.class, () -> {
StringWriter writer = new DontCloseStringWriter();
IOUtil.copy(emptyInputStream(), writer, "junk", 0);
- assertThat(writer.toString(), is(emptyString()));
+ assertEquals(emptyString(), writer.toString());
});
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyInputStreamNullWriterJunkEncodingZeroBufSz() throws Exception {
+ public void copyInputStreamNullWriterJunkEncodingZeroBufSz() {
assertThrows(UnsupportedEncodingException.class, () -> {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
IOUtil.copy(new ByteArrayInputStream(probe.getBytes()), nullWriter(), "junk", 0);
});
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyInputStreamValidWriterJunkEncodingZeroBufSz() throws Exception {
+ public void copyInputStreamValidWriterJunkEncodingZeroBufSz() {
assertThrows(UnsupportedEncodingException.class, () -> {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
StringWriter writer = new DontCloseStringWriter();
IOUtil.copy(new ByteArrayInputStream(probe.getBytes()), writer, "junk", 0);
- assertThat(writer.toString().getBytes(), is(probe.getBytes()));
+ assertArrayEquals(probe.getBytes(), writer.toString().getBytes());
});
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyNullInputStreamNullWriterValidEncodingZeroBufSz() throws Exception {
+ public void copyNullInputStreamNullWriterValidEncodingZeroBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullInputStream(), nullWriter(), "utf-16", 0));
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyNullInputStreamValidWriterValidEncodingZeroBufSz() throws Exception {
+ public void copyNullInputStreamValidWriterValidEncodingZeroBufSz() {
assertThrows(
NullPointerException.class,
() -> IOUtil.copy(nullInputStream(), new DontCloseStringWriter(), "utf-16", 0));
@@ -1513,12 +1507,12 @@ public class IOUtilTest {
*/
@Test
- public void copyNullStringNullWriter() throws Exception {
+ public void copyNullStringNullWriter() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullString(), nullWriter()));
}
@Test
- public void copyEmptyStringNullWriter() throws Exception {
+ public void copyEmptyStringNullWriter() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(emptyString(), nullWriter()));
}
@@ -1531,37 +1525,37 @@ public class IOUtilTest {
public void copyEmptyStringValidWriter() throws Exception {
StringWriter writer = new DontCloseStringWriter();
IOUtil.copy(emptyString(), writer);
- assertThat(writer.toString(), is(emptyString()));
+ assertEquals(emptyString(), writer.toString());
}
@Test
- public void copyStringNullWriter() throws Exception {
+ public void copyStringNullWriter() {
assertThrows(NullPointerException.class, () -> {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
IOUtil.copy(probe, nullWriter());
});
}
@Test
public void copyStringValidWriter() throws Exception {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
StringWriter writer = new DontCloseStringWriter();
IOUtil.copy(probe, writer);
- assertThat(writer.toString(), is(probe));
+ assertEquals(probe, writer.toString());
}
@Test
- public void copyNullStringNullOutputStream() throws Exception {
+ public void copyNullStringNullOutputStream() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullString(), nullOutputStream()));
}
@Test
- public void copyEmptyStringNullOutputStream() throws Exception {
+ public void copyEmptyStringNullOutputStream() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(emptyString(), nullOutputStream()));
}
@Test
- public void copyNullStringValidOutputStream() throws Exception {
+ public void copyNullStringValidOutputStream() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullString(), new DontCloseByteArrayOutputStream()));
}
@@ -1569,99 +1563,99 @@ public class IOUtilTest {
public void copyEmptyStringValidOutputStream() throws Exception {
ByteArrayOutputStream os = new DontCloseByteArrayOutputStream();
IOUtil.copy(emptyString(), os);
- assertThat(os.toByteArray(), is(emptyString().getBytes()));
+ assertArrayEquals(os.toByteArray(), emptyString().getBytes());
}
@Test
- public void copyStringNullOutputStream() throws Exception {
+ public void copyStringNullOutputStream() {
assertThrows(NullPointerException.class, () -> {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
IOUtil.copy(probe, nullOutputStream());
});
}
@Test
public void copyStringValidOutputStream() throws Exception {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
ByteArrayOutputStream os = new DontCloseByteArrayOutputStream();
IOUtil.copy(probe, os);
- assertThat(os.toByteArray(), is(probe.getBytes()));
+ assertArrayEquals(probe.getBytes(), os.toByteArray());
}
@Test
- public void copyNullStringNullOutputStreamNegBufSz() throws Exception {
+ public void copyNullStringNullOutputStreamNegBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullString(), nullOutputStream(), -1));
}
@Test
- public void copyEmptyStringNullOutputStreamNegBufSz() throws Exception {
+ public void copyEmptyStringNullOutputStreamNegBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(emptyString(), nullOutputStream(), -1));
}
@Test
- public void copyNullStringValidOutputStreamNegBufSz() throws Exception {
+ public void copyNullStringValidOutputStreamNegBufSz() {
assertThrows(
NullPointerException.class, () -> IOUtil.copy(nullString(), new DontCloseByteArrayOutputStream(), -1));
}
@Test
- public void copyEmptyStringValidOutputStreamNegBufSz() throws Exception {
+ public void copyEmptyStringValidOutputStreamNegBufSz() {
assertThrows(NegativeArraySizeException.class, () -> {
ByteArrayOutputStream os = new DontCloseByteArrayOutputStream();
IOUtil.copy(emptyString(), os, -1);
- assertThat(os.toByteArray(), is(emptyString().getBytes()));
+ assertArrayEquals(os.toByteArray(), emptyString().getBytes());
});
}
@Test
- public void copyStringNullOutputStreamNegBufSz() throws Exception {
+ public void copyStringNullOutputStreamNegBufSz() {
assertThrows(NullPointerException.class, () -> {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
IOUtil.copy(probe, nullOutputStream(), -1);
});
}
@Test
- public void copyStringValidOutputStreamNegBufSz() throws Exception {
+ public void copyStringValidOutputStreamNegBufSz() {
assertThrows(NegativeArraySizeException.class, () -> {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
ByteArrayOutputStream os = new DontCloseByteArrayOutputStream();
IOUtil.copy(probe, os, -1);
- assertThat(os.toByteArray(), is(probe.getBytes()));
+ assertEquals(probe.getBytes(), os.toByteArray());
});
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyNullStringNullOutputStreamZeroBufSz() throws Exception {
+ public void copyNullStringNullOutputStreamZeroBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullString(), nullOutputStream(), 0));
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyEmptyStringNullOutputStreamZeroBufSz() throws Exception {
+ public void copyEmptyStringNullOutputStreamZeroBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(emptyString(), nullOutputStream(), 0));
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyNullStringValidOutputStreamZeroBufSz() throws Exception {
+ public void copyNullStringValidOutputStreamZeroBufSz() {
assertThrows(
NullPointerException.class, () -> IOUtil.copy(nullString(), new DontCloseByteArrayOutputStream(), 0));
}
@Test
- public void copyNullStringNullOutputStreamPosBufSz() throws Exception {
+ public void copyNullStringNullOutputStreamPosBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullString(), nullOutputStream(), 1));
}
@Test
- public void copyEmptyStringNullOutputStreamPosBufSz() throws Exception {
+ public void copyEmptyStringNullOutputStreamPosBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(emptyString(), nullOutputStream(), 1));
}
@Test
- public void copyNullStringValidOutputStreamPosBufSz() throws Exception {
+ public void copyNullStringValidOutputStreamPosBufSz() {
assertThrows(
NullPointerException.class, () -> IOUtil.copy(nullString(), new DontCloseByteArrayOutputStream(), 1));
}
@@ -1670,37 +1664,37 @@ public class IOUtilTest {
public void copyEmptyStringValidOutputStreamPosBufSz() throws Exception {
ByteArrayOutputStream os = new DontCloseByteArrayOutputStream();
IOUtil.copy(emptyString(), os, 1);
- assertThat(os.toByteArray(), is(emptyString().getBytes()));
+ assertArrayEquals(os.toByteArray(), emptyString().getBytes());
}
@Test
- public void copyStringNullOutputStreamPosBufSz() throws Exception {
+ public void copyStringNullOutputStreamPosBufSz() {
assertThrows(NullPointerException.class, () -> {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
IOUtil.copy(probe, nullOutputStream(), 1);
});
}
@Test
public void copyStringValidOutputStreamPosBufSz() throws Exception {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
ByteArrayOutputStream os = new DontCloseByteArrayOutputStream();
IOUtil.copy(probe, os, 1);
- assertThat(os.toByteArray(), is(probe.getBytes()));
+ assertArrayEquals(probe.getBytes(), os.toByteArray());
}
@Test
- public void copyNullReaderNullWriter() throws Exception {
+ public void copyNullReaderNullWriter() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullReader(), nullWriter()));
}
@Test
- public void copyEmptyReaderNullWriter() throws Exception {
+ public void copyEmptyReaderNullWriter() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(emptyReader(), nullWriter()));
}
@Test
- public void copyNullReaderValidWriter() throws Exception {
+ public void copyNullReaderValidWriter() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullReader(), new DontCloseStringWriter()));
}
@@ -1708,23 +1702,23 @@ public class IOUtilTest {
public void copyEmptyReaderValidWriter() throws Exception {
StringWriter writer = new DontCloseStringWriter();
IOUtil.copy(emptyReader(), writer);
- assertThat(writer.toString(), is(emptyString()));
+ assertEquals(emptyString(), writer.toString());
}
@Test
- public void copyReaderNullWriter() throws Exception {
+ public void copyReaderNullWriter() {
assertThrows(NullPointerException.class, () -> {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
IOUtil.copy(new StringReader(probe), nullWriter());
});
}
@Test
public void copyReaderValidWriter() throws Exception {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
StringWriter writer = new DontCloseStringWriter();
IOUtil.copy(new StringReader(probe), writer);
- assertThat(writer.toString(), is(probe));
+ assertEquals(probe, writer.toString());
}
/*
@@ -1732,78 +1726,78 @@ public class IOUtilTest {
*/
@Test
- public void copyNullReaderNullWriterNegBufSz() throws Exception {
+ public void copyNullReaderNullWriterNegBufSz() {
assertThrows(NegativeArraySizeException.class, () -> IOUtil.copy(nullReader(), nullWriter(), -1));
}
@Test
- public void copyEmptyReaderNullWriterNegBufSz() throws Exception {
+ public void copyEmptyReaderNullWriterNegBufSz() {
assertThrows(NegativeArraySizeException.class, () -> IOUtil.copy(emptyReader(), nullWriter(), -1));
}
@Test
- public void copyNullReaderValidWriterNegBufSz() throws Exception {
+ public void copyNullReaderValidWriterNegBufSz() {
assertThrows(
NegativeArraySizeException.class, () -> IOUtil.copy(nullReader(), new DontCloseStringWriter(), -1));
}
@Test
- public void copyEmptyReaderValidWriterNegBufSz() throws Exception {
+ public void copyEmptyReaderValidWriterNegBufSz() {
assertThrows(NegativeArraySizeException.class, () -> {
StringWriter writer = new DontCloseStringWriter();
IOUtil.copy(emptyReader(), writer, -1);
- assertThat(writer.toString(), is(emptyString()));
+ assertEquals(emptyString(), writer.toString());
});
}
@Test
- public void copyReaderNullWriterNegBufSz() throws Exception {
+ public void copyReaderNullWriterNegBufSz() {
assertThrows(NegativeArraySizeException.class, () -> {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
IOUtil.copy(new StringReader(probe), nullWriter(), -1);
});
}
@Test
- public void copyReaderValidWriterNegBufSz() throws Exception {
+ public void copyReaderValidWriterNegBufSz() {
assertThrows(NegativeArraySizeException.class, () -> {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
StringWriter writer = new DontCloseStringWriter();
IOUtil.copy(new StringReader(probe), writer, -1);
- assertThat(writer.toString(), is(probe));
+ assertEquals(probe, writer.toString());
});
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyNullReaderNullWriterZeroBufSz() throws Exception {
+ public void copyNullReaderNullWriterZeroBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullReader(), nullWriter(), 0));
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyEmptyReaderNullWriterZeroBufSz() throws Exception {
+ public void copyEmptyReaderNullWriterZeroBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(emptyReader(), nullWriter(), 0));
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyNullReaderValidWriterZeroBufSz() throws Exception {
+ public void copyNullReaderValidWriterZeroBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullReader(), new DontCloseStringWriter(), 0));
}
@Test
- public void copyNullReaderNullWriterPosBufSz() throws Exception {
+ public void copyNullReaderNullWriterPosBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullReader(), nullWriter(), 1));
}
@Test
- public void copyEmptyReaderNullWriterPosBufSz() throws Exception {
+ public void copyEmptyReaderNullWriterPosBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(emptyReader(), nullWriter(), 1));
}
@Test
- public void copyNullReaderValidWriterPosBufSz() throws Exception {
+ public void copyNullReaderValidWriterPosBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullReader(), new DontCloseStringWriter(), 1));
}
@@ -1811,23 +1805,23 @@ public class IOUtilTest {
public void copyEmptyReaderValidWriterPosBufSz() throws Exception {
StringWriter writer = new DontCloseStringWriter();
IOUtil.copy(emptyReader(), writer, 1);
- assertThat(writer.toString(), is(emptyString()));
+ assertEquals(emptyString(), writer.toString());
}
@Test
- public void copyReaderNullWriterPosBufSz() throws Exception {
+ public void copyReaderNullWriterPosBufSz() {
assertThrows(NullPointerException.class, () -> {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
IOUtil.copy(new StringReader(probe), nullWriter(), 1);
});
}
@Test
public void copyReaderValidWriterPosBufSz() throws Exception {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
StringWriter writer = new DontCloseStringWriter();
IOUtil.copy(new StringReader(probe), writer, 1);
- assertThat(writer.toString(), is(probe));
+ assertEquals(probe, writer.toString());
}
/*
@@ -1835,30 +1829,29 @@ public class IOUtilTest {
*/
@Test
- public void toByteArrayFromInputStreamNegBufSz() throws Exception {
+ public void toByteArrayFromInputStreamNegBufSz() {
assertThrows(NegativeArraySizeException.class, () -> {
- String probe = "A string \u2345\u00ef";
- assertThat(
+ String probe = "A string ⍅ï";
+ assertEquals(
IOUtil.toByteArray(new DontCloseByteArrayInputStream(IOUtil.toByteArray(probe)), -1),
- is(probe.getBytes()));
+ probe.getBytes());
});
}
@Test
- public void toByteArrayNullInputStreamNegBufSz() throws Exception {
+ public void toByteArrayNullInputStreamNegBufSz() {
assertThrows(NegativeArraySizeException.class, () -> IOUtil.toByteArray(nullInputStream(), -1));
}
@Test
public void toByteArrayFromInputStreamPosBufSz() throws Exception {
- String probe = "A string \u2345\u00ef";
- assertThat(
- IOUtil.toByteArray(new DontCloseByteArrayInputStream(IOUtil.toByteArray(probe)), +1),
- is(probe.getBytes()));
+ String probe = "A string ⍅ï";
+ assertArrayEquals(
+ IOUtil.toByteArray(new DontCloseByteArrayInputStream(IOUtil.toByteArray(probe)), +1), probe.getBytes());
}
@Test
- public void toByteArrayNullInputStreamPosBufSz() throws Exception {
+ public void toByteArrayNullInputStreamPosBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.toByteArray(nullInputStream(), +1));
}
@@ -1867,26 +1860,26 @@ public class IOUtilTest {
*/
@Test
- public void toByteArrayFromReaderNegBufSz() throws Exception {
+ public void toByteArrayFromReaderNegBufSz() {
assertThrows(NegativeArraySizeException.class, () -> {
- String probe = "A string \u2345\u00ef";
- assertThat(IOUtil.toByteArray(new DontCloseStringReader(probe), -1), is(probe.getBytes()));
+ String probe = "A string ⍅ï";
+ assertEquals(IOUtil.toByteArray(new DontCloseStringReader(probe), -1), probe.getBytes());
});
}
@Test
- public void toByteArrayNullReaderNegBufSz() throws Exception {
+ public void toByteArrayNullReaderNegBufSz() {
assertThrows(NegativeArraySizeException.class, () -> IOUtil.toByteArray(nullReader(), -1));
}
@Test
public void toByteArrayFromReaderPosBufSz() throws Exception {
- String probe = "A string \u2345\u00ef";
- assertThat(IOUtil.toByteArray(new DontCloseStringReader(probe), +1), is(probe.getBytes()));
+ String probe = "A string ⍅ï";
+ assertArrayEquals(IOUtil.toByteArray(new DontCloseStringReader(probe), +1), probe.getBytes());
}
@Test
- public void toByteArrayNullReaderPosBufSz() throws Exception {
+ public void toByteArrayNullReaderPosBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.toByteArray(nullReader(), +1));
}
@@ -1895,26 +1888,26 @@ public class IOUtilTest {
*/
@Test
- public void toByteArrayFromStringNegBufSz() throws Exception {
+ public void toByteArrayFromStringNegBufSz() {
assertThrows(NegativeArraySizeException.class, () -> {
- String probe = "A string \u2345\u00ef";
- assertThat(IOUtil.toByteArray(probe, -1), is(probe.getBytes()));
+ String probe = "A string ⍅ï";
+ assertEquals(IOUtil.toByteArray(probe, -1), probe.getBytes());
});
}
@Test
- public void toByteArrayNullStringNegBufSz() throws Exception {
+ public void toByteArrayNullStringNegBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.toByteArray(nullString(), -1));
}
@Test
public void toByteArrayFromStringPosBufSz() throws Exception {
- String probe = "A string \u2345\u00ef";
- assertThat(IOUtil.toByteArray(probe, +1), is(probe.getBytes()));
+ String probe = "A string ⍅ï";
+ assertArrayEquals(IOUtil.toByteArray(probe, +1), probe.getBytes());
}
@Test
- public void toByteArrayNullStringPosBufSz() throws Exception {
+ public void toByteArrayNullStringPosBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.toByteArray(nullString(), +1));
}
@@ -1923,26 +1916,26 @@ public class IOUtilTest {
*/
@Test
- public void toStringFromReaderNegBufSz() throws Exception {
+ public void toStringFromReaderNegBufSz() {
assertThrows(NegativeArraySizeException.class, () -> {
- String probe = "A string \u2345\u00ef";
- assertThat(IOUtil.toString(new DontCloseStringReader(probe), -1), is(probe));
+ String probe = "A string ⍅ï";
+ assertEquals(probe, IOUtil.toString(new DontCloseStringReader(probe), -1));
});
}
@Test
- public void toStringNullReaderNegBufSz() throws Exception {
+ public void toStringNullReaderNegBufSz() {
assertThrows(NegativeArraySizeException.class, () -> IOUtil.toString(nullReader(), -1));
}
@Test
public void toStringFromReaderPosBufSz() throws Exception {
- String probe = "A string \u2345\u00ef";
- assertThat(IOUtil.toString(new DontCloseStringReader(probe), +1), is(probe));
+ String probe = "A string ⍅ï";
+ assertEquals(probe, IOUtil.toString(new DontCloseStringReader(probe), +1));
}
@Test
- public void toStringNullReaderPosBufSz() throws Exception {
+ public void toStringNullReaderPosBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.toString(nullReader(), +1));
}
@@ -1951,17 +1944,17 @@ public class IOUtilTest {
*/
@Test
- public void copyNullReaderNullOutputStream() throws Exception {
+ public void copyNullReaderNullOutputStream() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullReader(), nullOutputStream()));
}
@Test
- public void copyNullReaderValidOutputStream() throws Exception {
+ public void copyNullReaderValidOutputStream() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullReader(), new DontCloseByteArrayOutputStream()));
}
@Test
- public void copyEmptyReaderNullOutputStream() throws Exception {
+ public void copyEmptyReaderNullOutputStream() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(emptyReader(), nullOutputStream()));
}
@@ -1973,9 +1966,9 @@ public class IOUtilTest {
@Test
public void copyReaderValidOutputStream() throws Exception {
ByteArrayOutputStream outputStream = new DontCloseByteArrayOutputStream();
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
IOUtil.copy(new DontCloseStringReader(probe), outputStream);
- assertThat(outputStream.toByteArray(), is(probe.getBytes()));
+ assertArrayEquals(probe.getBytes(), outputStream.toByteArray());
}
/*
@@ -1983,71 +1976,71 @@ public class IOUtilTest {
*/
@Test
- public void copyNullReaderNullOutputStreamNegBufSz() throws Exception {
+ public void copyNullReaderNullOutputStreamNegBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullReader(), nullOutputStream(), -1));
}
@Test
- public void copyNullReaderValidOutputStreamNegBufSz() throws Exception {
+ public void copyNullReaderValidOutputStreamNegBufSz() {
assertThrows(
NegativeArraySizeException.class,
() -> IOUtil.copy(nullReader(), new DontCloseByteArrayOutputStream(), -1));
}
@Test
- public void copyEmptyReaderNullOutputStreamNegBufSz() throws Exception {
+ public void copyEmptyReaderNullOutputStreamNegBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(emptyReader(), nullOutputStream(), -1));
}
@Test
- public void copyEmptyReaderValidOutputStreamNegBufSz() throws Exception {
+ public void copyEmptyReaderValidOutputStreamNegBufSz() {
assertThrows(
NegativeArraySizeException.class,
() -> IOUtil.copy(emptyReader(), new DontCloseByteArrayOutputStream(), -1));
}
@Test
- public void copyReaderValidOutputStreamNegBufSz() throws Exception {
+ public void copyReaderValidOutputStreamNegBufSz() {
assertThrows(NegativeArraySizeException.class, () -> {
ByteArrayOutputStream outputStream = new DontCloseByteArrayOutputStream();
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
IOUtil.copy(new DontCloseStringReader(probe), outputStream, -1);
- assertThat(outputStream.toByteArray(), is(probe.getBytes()));
+ assertEquals(probe.getBytes(), outputStream.toByteArray());
});
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyNullReaderNullOutputStreamZeroBufSz() throws Exception {
+ public void copyNullReaderNullOutputStreamZeroBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullReader(), nullOutputStream(), 0));
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyNullReaderValidOutputStreamZeroBufSz() throws Exception {
+ public void copyNullReaderValidOutputStreamZeroBufSz() {
assertThrows(
NullPointerException.class, () -> IOUtil.copy(nullReader(), new DontCloseByteArrayOutputStream(), 0));
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyEmptyReaderNullOutputStreamZeroBufSz() throws Exception {
+ public void copyEmptyReaderNullOutputStreamZeroBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(emptyReader(), nullOutputStream(), 0));
}
@Test
- public void copyNullReaderNullOutputStreamPosBufSz() throws Exception {
+ public void copyNullReaderNullOutputStreamPosBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullReader(), nullOutputStream(), 1));
}
@Test
- public void copyNullReaderValidOutputStreamPosBufSz() throws Exception {
+ public void copyNullReaderValidOutputStreamPosBufSz() {
assertThrows(
NullPointerException.class, () -> IOUtil.copy(nullReader(), new DontCloseByteArrayOutputStream(), 1));
}
@Test
- public void copyEmptyReaderNullOutputStreamPosBufSz() throws Exception {
+ public void copyEmptyReaderNullOutputStreamPosBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(emptyReader(), nullOutputStream(), 1));
}
@@ -2059,9 +2052,9 @@ public class IOUtilTest {
@Test
public void copyReaderValidOutputStreamPosBufSz() throws Exception {
ByteArrayOutputStream outputStream = new DontCloseByteArrayOutputStream();
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
IOUtil.copy(new DontCloseStringReader(probe), outputStream, 1);
- assertThat(outputStream.toByteArray(), is(probe.getBytes()));
+ assertArrayEquals(probe.getBytes(), outputStream.toByteArray());
}
/*
@@ -2084,12 +2077,12 @@ public class IOUtilTest {
*/
@Test
- public void copyNullByteArrayNullWriter() throws Exception {
+ public void copyNullByteArrayNullWriter() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullByteArray(), nullWriter()));
}
@Test
- public void copyEmptyByteArrayNullWriter() throws Exception {
+ public void copyEmptyByteArrayNullWriter() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(emptyByteArray(), nullWriter()));
}
@@ -2097,23 +2090,23 @@ public class IOUtilTest {
public void copyEmptyByteArrayValidWriter() throws Exception {
StringWriter writer = new DontCloseStringWriter();
IOUtil.copy(emptyByteArray(), writer);
- assertThat(writer.toString(), is(emptyString()));
+ assertEquals(emptyString(), writer.toString());
}
@Test
- public void copyByteArrayNullWriter() throws Exception {
+ public void copyByteArrayNullWriter() {
assertThrows(NullPointerException.class, () -> {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
IOUtil.copy(probe.getBytes(), nullWriter());
});
}
@Test
public void copyByteArrayValidWriter() throws Exception {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
StringWriter writer = new DontCloseStringWriter();
IOUtil.copy(probe.getBytes(), writer);
- assertThat(writer.toString().getBytes(), is(probe.getBytes()));
+ assertArrayEquals(probe.getBytes(), writer.toString().getBytes());
}
/*
@@ -2121,69 +2114,69 @@ public class IOUtilTest {
*/
@Test
- public void copyNullByteArrayNullWriterNegBufSz() throws Exception {
+ public void copyNullByteArrayNullWriterNegBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullByteArray(), nullWriter(), -1));
}
@Test
- public void copyEmptyByteArrayNullWriterNegBufSz() throws Exception {
+ public void copyEmptyByteArrayNullWriterNegBufSz() {
assertThrows(NegativeArraySizeException.class, () -> IOUtil.copy(emptyByteArray(), nullWriter(), -1));
}
@Test
- public void copyEmptyByteArrayValidWriterNegBufSz() throws Exception {
+ public void copyEmptyByteArrayValidWriterNegBufSz() {
assertThrows(
NegativeArraySizeException.class, () -> IOUtil.copy(emptyByteArray(), new DontCloseStringWriter(), -1));
}
@Test
- public void copyByteArrayNullWriterNegBufSz() throws Exception {
+ public void copyByteArrayNullWriterNegBufSz() {
assertThrows(NegativeArraySizeException.class, () -> {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
IOUtil.copy(probe.getBytes(), nullWriter(), -1);
});
}
@Test
- public void copyByteArrayValidWriterNegBufSz() throws Exception {
+ public void copyByteArrayValidWriterNegBufSz() {
assertThrows(NegativeArraySizeException.class, () -> {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
StringWriter writer = new DontCloseStringWriter();
IOUtil.copy(probe.getBytes(), writer, -1);
- assertThat(writer.toString().getBytes(), is(probe.getBytes()));
+ assertArrayEquals(probe.getBytes(), writer.toString().getBytes());
});
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyNullByteArrayNullWriterZeroBufSz() throws Exception {
+ public void copyNullByteArrayNullWriterZeroBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullByteArray(), nullWriter(), 0));
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyNullByteArrayValidWriterZeroBufSz() throws Exception {
+ public void copyNullByteArrayValidWriterZeroBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullByteArray(), new DontCloseStringWriter(), 0));
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyEmptyByteArrayNullWriterZeroBufSz() throws Exception {
+ public void copyEmptyByteArrayNullWriterZeroBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(emptyByteArray(), nullWriter(), 0));
}
@Test
- public void copyNullByteArrayNullWriterPosBufSz() throws Exception {
+ public void copyNullByteArrayNullWriterPosBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullByteArray(), nullWriter(), 1));
}
@Test
- public void copyNullByteArrayValidWriterPosBufSz() throws Exception {
+ public void copyNullByteArrayValidWriterPosBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullByteArray(), new DontCloseStringWriter(), 1));
}
@Test
- public void copyEmptyByteArrayNullWriterPosBufSz() throws Exception {
+ public void copyEmptyByteArrayNullWriterPosBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(emptyByteArray(), nullWriter(), 1));
}
@@ -2191,15 +2184,15 @@ public class IOUtilTest {
public void copyEmptyByteArrayValidWriterPosBufSz() throws Exception {
StringWriter writer = new DontCloseStringWriter();
IOUtil.copy(emptyByteArray(), writer, 1);
- assertThat(writer.toString(), is(emptyString()));
+ assertEquals(emptyString(), writer.toString());
}
@Test
public void copyByteArrayValidWriterPosBufSz() throws Exception {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
StringWriter writer = new DontCloseStringWriter();
IOUtil.copy(probe.getBytes(), writer, 1);
- assertThat(writer.toString().getBytes(), is(probe.getBytes()));
+ assertArrayEquals(probe.getBytes(), writer.toString().getBytes());
}
/*
@@ -2207,89 +2200,89 @@ public class IOUtilTest {
*/
@Test
- public void copyNullByteArrayNullWriterNullEncoding() throws Exception {
+ public void copyNullByteArrayNullWriterNullEncoding() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullByteArray(), nullWriter(), null));
}
@Test
- public void copyNullByteArrayValidWriterNullEncoding() throws Exception {
+ public void copyNullByteArrayValidWriterNullEncoding() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullByteArray(), new DontCloseStringWriter(), null));
}
@Test
- public void copyEmptyByteArrayNullWriterNullEncoding() throws Exception {
+ public void copyEmptyByteArrayNullWriterNullEncoding() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(emptyByteArray(), nullWriter(), null));
}
@Test
- public void copyEmptyByteArrayValidWriterNullEncoding() throws Exception {
+ public void copyEmptyByteArrayValidWriterNullEncoding() {
assertThrows(
NullPointerException.class, () -> IOUtil.copy(emptyByteArray(), new DontCloseStringWriter(), null));
}
@Test
- public void copyByteArrayNullEncoding() throws Exception {
+ public void copyByteArrayNullEncoding() {
assertThrows(NullPointerException.class, () -> {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
StringWriter writer = new DontCloseStringWriter();
IOUtil.copy(probe.getBytes(), writer, null);
- assertThat(writer.toString().getBytes(), is(probe.getBytes()));
+ assertArrayEquals(probe.getBytes(), writer.toString().getBytes());
});
}
@Test
- public void copyNullByteArrayNullWriterJunkEncoding() throws Exception {
+ public void copyNullByteArrayNullWriterJunkEncoding() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullByteArray(), nullWriter(), "junk"));
}
@Test
- public void copyNullByteArrayValidWriterJunkEncoding() throws Exception {
+ public void copyNullByteArrayValidWriterJunkEncoding() {
assertThrows(
NullPointerException.class, () -> IOUtil.copy(nullByteArray(), new DontCloseStringWriter(), "junk"));
}
@Test
- public void copyEmptyByteArrayNullWriterJunkEncoding() throws Exception {
+ public void copyEmptyByteArrayNullWriterJunkEncoding() {
assertThrows(UnsupportedEncodingException.class, () -> IOUtil.copy(emptyByteArray(), nullWriter(), "junk"));
}
@Test
- public void copyEmptyByteArrayValidWriterJunkEncoding() throws Exception {
+ public void copyEmptyByteArrayValidWriterJunkEncoding() {
assertThrows(
UnsupportedEncodingException.class,
() -> IOUtil.copy(emptyByteArray(), new DontCloseStringWriter(), "junk"));
}
@Test
- public void copyByteArrayNullWriterJunkEncoding() throws Exception {
+ public void copyByteArrayNullWriterJunkEncoding() {
assertThrows(UnsupportedEncodingException.class, () -> {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
IOUtil.copy(probe.getBytes(), nullWriter(), "junk");
});
}
@Test
- public void copyByteArrayValidWriterJunkEncoding() throws Exception {
+ public void copyByteArrayValidWriterJunkEncoding() {
assertThrows(UnsupportedEncodingException.class, () -> {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
StringWriter writer = new DontCloseStringWriter();
IOUtil.copy(probe.getBytes(), writer, "junk");
- assertThat(writer.toString().getBytes(), is(probe.getBytes()));
+ assertArrayEquals(probe.getBytes(), writer.toString().getBytes());
});
}
@Test
- public void copyNullByteArrayNullWriterValidEncoding() throws Exception {
+ public void copyNullByteArrayNullWriterValidEncoding() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullByteArray(), nullWriter(), "utf-16"));
}
@Test
- public void copyEmptyByteArrayNullWriterValidEncoding() throws Exception {
+ public void copyEmptyByteArrayNullWriterValidEncoding() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(emptyByteArray(), nullWriter(), "utf-16"));
}
@Test
- public void copyNullByteArrayValidWriterValidEncoding() throws Exception {
+ public void copyNullByteArrayValidWriterValidEncoding() {
assertThrows(
NullPointerException.class, () -> IOUtil.copy(nullByteArray(), new DontCloseStringWriter(), "utf-16"));
}
@@ -2298,23 +2291,23 @@ public class IOUtilTest {
public void copyEmptyByteArrayValidWriterValidEncoding() throws Exception {
StringWriter writer = new DontCloseStringWriter();
IOUtil.copy(emptyByteArray(), writer, "utf-16");
- assertThat(writer.toString(), is(emptyString()));
+ assertEquals(emptyString(), writer.toString());
}
@Test
- public void copyByteArrayNullWriterValidEncoding() throws Exception {
+ public void copyByteArrayNullWriterValidEncoding() {
assertThrows(NullPointerException.class, () -> {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
IOUtil.copy(probe.getBytes("utf-16"), nullWriter(), "utf-16");
});
}
@Test
public void copyByteArrayValidWriterValidEncoding() throws Exception {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
StringWriter writer = new DontCloseStringWriter();
- IOUtil.copy(probe.getBytes("utf-16"), writer, "utf-16");
- assertThat(writer.toString().getBytes("utf-8"), is(probe.getBytes("utf-8")));
+ IOUtil.copy(probe.getBytes(UTF_16), writer, "utf-16");
+ assertArrayEquals(probe.getBytes(UTF_8), writer.toString().getBytes(UTF_8));
}
/*
@@ -2322,243 +2315,243 @@ public class IOUtilTest {
*/
@Test
- public void copyNullByteArrayNullWriterNullEncodingNegBufSz() throws Exception {
+ public void copyNullByteArrayNullWriterNullEncodingNegBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullByteArray(), nullWriter(), null, -1));
}
@Test
- public void copyNullByteArrayValidWriterNullEncodingNegBufSz() throws Exception {
+ public void copyNullByteArrayValidWriterNullEncodingNegBufSz() {
assertThrows(
NullPointerException.class, () -> IOUtil.copy(nullByteArray(), new DontCloseStringWriter(), null, -1));
}
@Test
- public void copyEmptyByteArrayNullWriterNullEncodingNegBufSz() throws Exception {
+ public void copyEmptyByteArrayNullWriterNullEncodingNegBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(emptyByteArray(), nullWriter(), null, -1));
}
@Test
- public void copyEmptyByteArrayValidWriterNullEncodingNegBufSz() throws Exception {
+ public void copyEmptyByteArrayValidWriterNullEncodingNegBufSz() {
assertThrows(NullPointerException.class, () -> {
StringWriter writer = new DontCloseStringWriter();
IOUtil.copy(emptyByteArray(), writer, null, -1);
- assertThat(writer.toString(), is(emptyString()));
+ assertEquals(emptyString(), writer.toString());
});
}
@Test
- public void copyByteArrayNullWriterNullEncodingNegBufSz() throws Exception {
+ public void copyByteArrayNullWriterNullEncodingNegBufSz() {
assertThrows(NullPointerException.class, () -> {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
IOUtil.copy(probe.getBytes(), nullWriter(), null, -1);
});
}
@Test
- public void copyByteArrayValidWriterNullEncodingNegBufSz() throws Exception {
+ public void copyByteArrayValidWriterNullEncodingNegBufSz() {
assertThrows(NullPointerException.class, () -> {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
StringWriter writer = new DontCloseStringWriter();
IOUtil.copy(probe.getBytes(), writer, null, -1);
- assertThat(writer.toString().getBytes(), is(probe.getBytes()));
+ assertArrayEquals(probe.getBytes(), writer.toString().getBytes());
});
}
@Test
- public void copyNullByteArrayNullWriterJunkEncodingNegBufSz() throws Exception {
+ public void copyNullByteArrayNullWriterJunkEncodingNegBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullByteArray(), nullWriter(), "junk", -1));
}
@Test
- public void copyNullByteArrayValidWriterJunkEncodingNegBufSz() throws Exception {
+ public void copyNullByteArrayValidWriterJunkEncodingNegBufSz() {
assertThrows(
NullPointerException.class,
() -> IOUtil.copy(nullByteArray(), new DontCloseStringWriter(), "junk", -1));
}
@Test
- public void copyEmptyByteArrayNullWriterJunkEncodingNegBufSz() throws Exception {
+ public void copyEmptyByteArrayNullWriterJunkEncodingNegBufSz() {
assertThrows(UnsupportedEncodingException.class, () -> IOUtil.copy(emptyByteArray(), nullWriter(), "junk", -1));
}
@Test
- public void copyEmptyByteArrayJunkEncodingNegBufSz() throws Exception {
+ public void copyEmptyByteArrayJunkEncodingNegBufSz() {
assertThrows(UnsupportedEncodingException.class, () -> {
StringWriter writer = new DontCloseStringWriter();
IOUtil.copy(emptyByteArray(), writer, "junk", -1);
- assertThat(writer.toString(), is(emptyString()));
+ assertEquals(emptyString(), writer.toString());
});
}
@Test
- public void copyByteArrayNullWriterJunkEncodingNegBufSz() throws Exception {
+ public void copyByteArrayNullWriterJunkEncodingNegBufSz() {
assertThrows(UnsupportedEncodingException.class, () -> {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
IOUtil.copy(probe.getBytes(), nullWriter(), "junk", -1);
});
}
@Test
- public void copyByteArrayValidWriterJunkEncodingNegBufSz() throws Exception {
+ public void copyByteArrayValidWriterJunkEncodingNegBufSz() {
assertThrows(UnsupportedEncodingException.class, () -> {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
StringWriter writer = new DontCloseStringWriter();
IOUtil.copy(probe.getBytes(), writer, "junk", -1);
- assertThat(writer.toString().getBytes(), is(probe.getBytes()));
+ assertArrayEquals(probe.getBytes(), writer.toString().getBytes());
});
}
@Test
- public void copyNullByteArrayNullWriterValidEncodingNegBufSz() throws Exception {
+ public void copyNullByteArrayNullWriterValidEncodingNegBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullByteArray(), nullWriter(), "utf-16", -1));
}
@Test
- public void copyNullByteArrayValidWriterValidEncodingNegBufSz() throws Exception {
+ public void copyNullByteArrayValidWriterValidEncodingNegBufSz() {
assertThrows(
NullPointerException.class,
() -> IOUtil.copy(nullByteArray(), new DontCloseStringWriter(), "utf-16", -1));
}
@Test
- public void copyEmptyByteArrayNullWriterValidEncodingNegBufSz() throws Exception {
+ public void copyEmptyByteArrayNullWriterValidEncodingNegBufSz() {
assertThrows(NegativeArraySizeException.class, () -> IOUtil.copy(emptyByteArray(), nullWriter(), "utf-16", -1));
}
@Test
- public void copyEmptyByteArrayValidWriterValidEncodingNegBufSz() throws Exception {
+ public void copyEmptyByteArrayValidWriterValidEncodingNegBufSz() {
assertThrows(NegativeArraySizeException.class, () -> {
StringWriter writer = new DontCloseStringWriter();
IOUtil.copy(emptyByteArray(), writer, "utf-16", -1);
- assertThat(writer.toString(), is(emptyString()));
+ assertEquals(emptyString(), writer.toString());
});
}
@Test
- public void copyByteArrayNullWriterValidEncodingNegBufSz() throws Exception {
+ public void copyByteArrayNullWriterValidEncodingNegBufSz() {
assertThrows(NegativeArraySizeException.class, () -> {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
IOUtil.copy(probe.getBytes("utf-16"), nullWriter(), -1);
});
}
@Test
- public void copyByteArrayValidEncodingNegBufSz() throws Exception {
+ public void copyByteArrayValidEncodingNegBufSz() {
assertThrows(NegativeArraySizeException.class, () -> {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
StringWriter writer = new DontCloseStringWriter();
IOUtil.copy(probe.getBytes("utf-16"), writer, "utf-16", -1);
- assertThat(writer.toString().getBytes("utf-8"), is(probe.getBytes("utf-8")));
+ assertEquals(probe.getBytes("utf-8"), writer.toString().getBytes("utf-8"));
});
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyNullByteArrayNullWriterNullEncodingZeroBufSz() throws Exception {
+ public void copyNullByteArrayNullWriterNullEncodingZeroBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullByteArray(), nullWriter(), null, 0));
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyNullByteArrayValidWriterNullEncodingZeroBufSz() throws Exception {
+ public void copyNullByteArrayValidWriterNullEncodingZeroBufSz() {
assertThrows(
NullPointerException.class, () -> IOUtil.copy(nullByteArray(), new DontCloseStringWriter(), null, 0));
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyEmptyByteArrayNullWriterNullEncodingZeroBufSz() throws Exception {
+ public void copyEmptyByteArrayNullWriterNullEncodingZeroBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(emptyByteArray(), nullWriter(), null, 0));
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyEmptyByteArrayValidWriterNullEncodingZeroBufSz() throws Exception {
+ public void copyEmptyByteArrayValidWriterNullEncodingZeroBufSz() {
assertThrows(NullPointerException.class, () -> {
StringWriter writer = new DontCloseStringWriter();
IOUtil.copy(emptyByteArray(), writer, null, 0);
- assertThat(writer.toString(), is(emptyString()));
+ assertEquals(emptyString(), writer.toString());
});
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyByteArrayNullWriterNullEncodingZeroBufSz() throws Exception {
+ public void copyByteArrayNullWriterNullEncodingZeroBufSz() {
assertThrows(NullPointerException.class, () -> {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
IOUtil.copy(probe.getBytes(), nullWriter(), null, 0);
});
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyByteArrayValidWriterNullEncodingZeroBufSz() throws Exception {
+ public void copyByteArrayValidWriterNullEncodingZeroBufSz() {
assertThrows(NullPointerException.class, () -> {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
StringWriter writer = new DontCloseStringWriter();
IOUtil.copy(probe.getBytes(), writer, null, 0);
- assertThat(writer.toString().getBytes(), is(probe.getBytes()));
+ assertArrayEquals(probe.getBytes(), writer.toString().getBytes());
});
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyNullByteArrayNullWriterJunkEncodingZeroBufSz() throws Exception {
+ public void copyNullByteArrayNullWriterJunkEncodingZeroBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullByteArray(), nullWriter(), "junk", 0));
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyNullByteArrayValidWriterJunkEncodingZeroBufSz() throws Exception {
+ public void copyNullByteArrayValidWriterJunkEncodingZeroBufSz() {
assertThrows(
NullPointerException.class, () -> IOUtil.copy(nullByteArray(), new DontCloseStringWriter(), "junk", 0));
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyEmptyByteArrayNullWriterJunkEncodingZeroBufSz() throws Exception {
+ public void copyEmptyByteArrayNullWriterJunkEncodingZeroBufSz() {
assertThrows(UnsupportedEncodingException.class, () -> IOUtil.copy(emptyByteArray(), nullWriter(), "junk", 0));
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyEmptyByteArrayValidWriterJunkEncodingZeroBufSz() throws Exception {
+ public void copyEmptyByteArrayValidWriterJunkEncodingZeroBufSz() {
assertThrows(UnsupportedEncodingException.class, () -> {
StringWriter writer = new DontCloseStringWriter();
IOUtil.copy(emptyByteArray(), writer, "junk", 0);
- assertThat(writer.toString(), is(emptyString()));
+ assertEquals(emptyString(), writer.toString());
});
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyByteArrayNullWriterJunkEncodingZeroBufSz() throws Exception {
+ public void copyByteArrayNullWriterJunkEncodingZeroBufSz() {
assertThrows(UnsupportedEncodingException.class, () -> {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
IOUtil.copy(probe.getBytes(), nullWriter(), "junk", 0);
});
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyByteArrayValidWriterJunkEncodingZeroBufSz() throws Exception {
+ public void copyByteArrayValidWriterJunkEncodingZeroBufSz() {
assertThrows(UnsupportedEncodingException.class, () -> {
- String probe = "A string \u2345\u00ef";
+ String probe = "A string ⍅ï";
StringWriter writer = new DontCloseStringWriter();
IOUtil.copy(probe.getBytes(), writer, "junk", 0);
- assertThat(writer.toString().getBytes(), is(probe.getBytes()));
+ assertArrayEquals(probe.getBytes(), writer.toString().getBytes());
});
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyNullByteArrayNullWriterValidEncodingZeroBufSz() throws Exception {
+ public void copyNullByteArrayNullWriterValidEncodingZeroBufSz() {
assertThrows(NullPointerException.class, () -> IOUtil.copy(nullByteArray(), nullWriter(), "utf-16", 0));
}
@Test
@Timeout(value = INFINITE_LOOP_TIMEOUT, unit = TimeUnit.MILLISECONDS)
- public void copyNullByteArrayValidWriterValidEncodingZeroBufSz() throws Exception {
+ public void copyNullByteArrayValidWriterValidEncodingZeroBufSz() {
assertThrows(
NullPointerException.class,
() -> IOUtil.copy(nullByteArray(), new DontCloseStringWriter(), "utf-16", 0));
@@ -2609,7 +2602,7 @@ public class IOUtilTest {
private static class DontCloseStringWriter extends StringWriter {
@Override
- public void close() throws IOException {
+ public void close() {
throw new UnsupportedOperationException("should not be called");
}
}
@@ -2632,14 +2625,14 @@ public class IOUtilTest {
}
@Override
- public void close() throws IOException {
+ public void close() {
throw new UnsupportedOperationException("should not be called");
}
}
private static class DontCloseByteArrayOutputStream extends ByteArrayOutputStream {
@Override
- public void close() throws IOException {
+ public void close() {
throw new UnsupportedOperationException("should not be called");
}
}
diff --git a/src/test/java/org/apache/maven/shared/utils/io/SelectorUtilsTest.java b/src/test/java/org/apache/maven/shared/utils/io/SelectorUtilsTest.java
index 286c78f..9d544ae 100644
--- a/src/test/java/org/apache/maven/shared/utils/io/SelectorUtilsTest.java
+++ b/src/test/java/org/apache/maven/shared/utils/io/SelectorUtilsTest.java
@@ -43,7 +43,7 @@ public class SelectorUtilsTest {
}
@Test
- public void testRegexPrefix() throws Exception {
+ public void testRegexPrefix() {
assertTrue(SelectorUtils.matchPatternStart(
SelectorUtils.REGEX_HANDLER_PREFIX + File.separator + "aaa" + SelectorUtils.PATTERN_HANDLER_SUFFIX,
""));
diff --git a/src/test/java/org/apache/maven/shared/utils/logging/AnsiMessageBuilderTest.java b/src/test/java/org/apache/maven/shared/utils/logging/AnsiMessageBuilderTest.java
index bdc3eb2..e112e92 100644
--- a/src/test/java/org/apache/maven/shared/utils/logging/AnsiMessageBuilderTest.java
+++ b/src/test/java/org/apache/maven/shared/utils/logging/AnsiMessageBuilderTest.java
@@ -21,8 +21,7 @@ package org.apache.maven.shared.utils.logging;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class AnsiMessageBuilderTest {
@@ -37,62 +36,62 @@ public class AnsiMessageBuilderTest {
public void shouldColorDebug() {
ansiMessageBuilder.debug("DEBUG");
- assertThat(ansiMessageBuilder.toString(), equalTo("\u001B[1;36mDEBUG\u001B[m"));
+ assertEquals("\u001B[1;36mDEBUG\u001B[m", ansiMessageBuilder.toString());
}
@Test
public void shouldColorInfo() {
ansiMessageBuilder.info("INFO");
- assertThat(ansiMessageBuilder.toString(), equalTo("\u001B[1;34mINFO\u001B[m"));
+ assertEquals("\u001B[1;34mINFO\u001B[m", ansiMessageBuilder.toString());
}
@Test
public void shouldColorWarningAndReset() {
ansiMessageBuilder.warning("WARNING");
- assertThat(ansiMessageBuilder.toString(), equalTo("\u001B[1;33mWARNING\u001B[m"));
+ assertEquals("\u001B[1;33mWARNING\u001B[m", ansiMessageBuilder.toString());
}
@Test
public void shouldColorError() {
ansiMessageBuilder.error("ERROR");
- assertThat(ansiMessageBuilder.toString(), equalTo("\u001B[1;31mERROR\u001B[m"));
+ assertEquals("\u001B[1;31mERROR\u001B[m", ansiMessageBuilder.toString());
}
@Test
public void shouldColorSuccessWithMessage() {
ansiMessageBuilder.success("a success message");
- assertThat(ansiMessageBuilder.toString(), equalTo("\u001B[1;32ma success message\u001B[m"));
+ assertEquals("\u001B[1;32ma success message\u001B[m", ansiMessageBuilder.toString());
}
@Test
public void shouldColorFailureAndReset() {
ansiMessageBuilder.failure("a failure message");
- assertThat(ansiMessageBuilder.toString(), equalTo("\u001B[1;31ma failure message\u001B[m"));
+ assertEquals("\u001B[1;31ma failure message\u001B[m", ansiMessageBuilder.toString());
}
@Test
public void shouldColorStrongAndReset() {
ansiMessageBuilder.strong("a strong message");
- assertThat(ansiMessageBuilder.toString(), equalTo("\u001B[1ma strong message\u001B[m"));
+ assertEquals("\u001B[1ma strong message\u001B[m", ansiMessageBuilder.toString());
}
@Test
public void shouldColorMojoAndReset() {
ansiMessageBuilder.mojo("a mojo");
- assertThat(ansiMessageBuilder.toString(), equalTo("\u001B[32ma mojo\u001B[m"));
+ assertEquals("\u001B[32ma mojo\u001B[m", ansiMessageBuilder.toString());
}
@Test
public void shouldColorProjectAndReset() {
ansiMessageBuilder.project("a project");
- assertThat(ansiMessageBuilder.toString(), equalTo("\u001B[36ma project\u001B[m"));
+ assertEquals("\u001B[36ma project\u001B[m", ansiMessageBuilder.toString());
}
}
diff --git a/src/test/java/org/apache/maven/shared/utils/logging/MessageUtilsTest.java b/src/test/java/org/apache/maven/shared/utils/logging/MessageUtilsTest.java
index e371e58..3eb6e83 100644
--- a/src/test/java/org/apache/maven/shared/utils/logging/MessageUtilsTest.java
+++ b/src/test/java/org/apache/maven/shared/utils/logging/MessageUtilsTest.java
@@ -30,10 +30,9 @@ import org.fusesource.jansi.AnsiType;
import org.fusesource.jansi.io.AnsiOutputStream;
import org.junit.jupiter.api.Test;
-import static org.hamcrest.CoreMatchers.not;
-import static org.hamcrest.CoreMatchers.sameInstance;
-import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertSame;
public class MessageUtilsTest {
@Test
@@ -41,7 +40,7 @@ public class MessageUtilsTest {
PrintStream currentOut = System.out;
try {
MessageUtils.systemInstall();
- assertThat(System.out, not(sameInstance(currentOut)));
+ assertNotSame(System.out, currentOut);
} catch (LinkageError e) {
// assumeNoException("JAnsi not supported for this platform", e);
} finally {
@@ -53,17 +52,13 @@ public class MessageUtilsTest {
// ignore any thrown exception like NPE here
}
}
- assertThat(System.out, sameInstance(currentOut));
+ assertSame(System.out, currentOut);
}
@Test
+ @SuppressWarnings("deprecation")
public void testTerminalWidth() {
- AnsiOutputStream.WidthSupplier width = new AnsiOutputStream.WidthSupplier() {
- @Override
- public int getTerminalWidth() {
- return 33;
- }
- };
+ AnsiOutputStream.WidthSupplier width = () -> 33;
AnsiOutputStream aos = new AnsiOutputStream(
new ByteArrayOutputStream(),
width,
diff --git a/src/test/java/org/apache/maven/shared/utils/xml/PrettyPrintXmlWriterTest.java b/src/test/java/org/apache/maven/shared/utils/xml/PrettyPrintXmlWriterTest.java
index e25443a..39b509b 100644
--- a/src/test/java/org/apache/maven/shared/utils/xml/PrettyPrintXmlWriterTest.java
+++ b/src/test/java/org/apache/maven/shared/utils/xml/PrettyPrintXmlWriterTest.java
@@ -32,9 +32,10 @@ import org.junit.jupiter.api.Test;
*
* @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
*/
+@SuppressWarnings("deprecation")
public class PrettyPrintXmlWriterTest {
- private StringWriter w = new StringWriter();
- private PrettyPrintXMLWriter writer = new PrettyPrintXMLWriter(w);
+ private final StringWriter w = new StringWriter();
+ private final PrettyPrintXMLWriter writer = new PrettyPrintXMLWriter(w);
@Test
public void testNoStartTag() throws IOException {
@@ -163,34 +164,30 @@ public class PrettyPrintXmlWriterTest {
private static String expectedResult(String lineIndenter) {
String lineSeparator = "\n";
- StringBuilder expected = new StringBuilder();
-
- expected.append("<html>").append(lineSeparator);
- expected.append(StringUtils.repeat(lineIndenter, 1)).append("<head>").append(lineSeparator);
- expected.append(StringUtils.repeat(lineIndenter, 2))
- .append("<title>title</title>")
- .append(lineSeparator);
- expected.append(StringUtils.repeat(lineIndenter, 2))
- .append("<meta name=\"author\" content=\"Author\"/>")
- .append(lineSeparator);
- expected.append(StringUtils.repeat(lineIndenter, 2))
- .append("<meta name=\"date\" content=\"Date\"/>")
- .append(lineSeparator);
- expected.append(StringUtils.repeat(lineIndenter, 1)).append("</head>").append(lineSeparator);
- expected.append(StringUtils.repeat(lineIndenter, 1)).append("<body>").append(lineSeparator);
- expected.append(StringUtils.repeat(lineIndenter, 2))
- .append("<p>Paragraph 1, line 1. Paragraph 1, line 2.</p>")
- .append(lineSeparator);
- expected.append(StringUtils.repeat(lineIndenter, 2))
- .append("<div class=\"section\">")
- .append(lineSeparator);
- expected.append(StringUtils.repeat(lineIndenter, 3))
- .append("<h2>Section title</h2>")
- .append(lineSeparator);
- expected.append(StringUtils.repeat(lineIndenter, 2)).append("</div>").append(lineSeparator);
- expected.append(StringUtils.repeat(lineIndenter, 1)).append("</body>").append(lineSeparator);
- expected.append("</html>");
-
- return expected.toString();
+
+ return "<html>" + lineSeparator + StringUtils.repeat(lineIndenter, 1)
+ + "<head>" + lineSeparator + StringUtils.repeat(lineIndenter, 2)
+ + "<title>title</title>"
+ + lineSeparator
+ + StringUtils.repeat(lineIndenter, 2)
+ + "<meta name=\"author\" content=\"Author\"/>"
+ + lineSeparator
+ + StringUtils.repeat(lineIndenter, 2)
+ + "<meta name=\"date\" content=\"Date\"/>"
+ + lineSeparator
+ + StringUtils.repeat(lineIndenter, 1)
+ + "</head>" + lineSeparator + StringUtils.repeat(lineIndenter, 1)
+ + "<body>" + lineSeparator + StringUtils.repeat(lineIndenter, 2)
+ + "<p>Paragraph 1, line 1. Paragraph 1, line 2.</p>"
+ + lineSeparator
+ + StringUtils.repeat(lineIndenter, 2)
+ + "<div class=\"section\">"
+ + lineSeparator
+ + StringUtils.repeat(lineIndenter, 3)
+ + "<h2>Section title</h2>"
+ + lineSeparator
+ + StringUtils.repeat(lineIndenter, 2)
+ + "</div>" + lineSeparator + StringUtils.repeat(lineIndenter, 1)
+ + "</body>" + lineSeparator + "</html>";
}
}
diff --git a/src/test/java/org/apache/maven/shared/utils/xml/XmlWriterUtilTest.java b/src/test/java/org/apache/maven/shared/utils/xml/XmlWriterUtilTest.java
index 5370ad0..d6b2594 100644
--- a/src/test/java/org/apache/maven/shared/utils/xml/XmlWriterUtilTest.java
+++ b/src/test/java/org/apache/maven/shared/utils/xml/XmlWriterUtilTest.java
@@ -35,6 +35,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
* @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
*
*/
+@SuppressWarnings("deprecation")
public class XmlWriterUtilTest {
private OutputStream output;
@@ -148,7 +149,7 @@ public class XmlWriterUtilTest {
public void testWriteCommentXMLWriterString() throws Exception {
XmlWriterUtil.writeComment(xmlWriter, "hello");
writer.close();
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append("<!-- hello -->")
.append("\r\n");
assertEquals(output.toString(), sb.toString());
@@ -160,7 +161,7 @@ public class XmlWriterUtilTest {
XmlWriterUtil.writeComment(
xmlWriter, "hellooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo");
writer.close();
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append("<!-- hellooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo -->")
.append("\r\n");
assertEquals(output.toString(), sb.toString());
@@ -171,7 +172,7 @@ public class XmlWriterUtilTest {
public void testWriteComment2() throws IOException {
XmlWriterUtil.writeComment(xmlWriter, "hello\nworld");
writer.close();
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append("<!-- hello -->")
.append("\r\n");
sb.append("<!-- world -->")
@@ -191,7 +192,7 @@ public class XmlWriterUtilTest {
XmlWriterUtil.writeComment(xmlWriter, "hello", 2);
writer.close();
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append(indent);
sb.append("<!-- hello -->")
.append("\r\n");
@@ -206,7 +207,7 @@ public class XmlWriterUtilTest {
String indent = StringUtils.repeat(" ", 2 * XmlWriterUtil.DEFAULT_INDENTATION_SIZE);
XmlWriterUtil.writeComment(xmlWriter, "hello\nworld", 2);
writer.close();
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append(indent);
sb.append("<!-- hello -->")
.append("\r\n");
@@ -230,7 +231,7 @@ public class XmlWriterUtilTest {
XmlWriterUtil.writeComment(xmlWriter, "hello", 2, 4);
writer.close();
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append(repeat);
sb.append("<!-- hello -->")
.append("\r\n");
@@ -243,7 +244,7 @@ public class XmlWriterUtilTest {
String repeat = StringUtils.repeat(" ", 2 * 4);
XmlWriterUtil.writeComment(xmlWriter, "hello\nworld", 2, 4);
writer.close();
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append(repeat);
sb.append("<!-- hello -->")
.append("\r\n");
@@ -267,7 +268,7 @@ public class XmlWriterUtilTest {
XmlWriterUtil.writeComment(xmlWriter, "hello", 2, 4, 50);
writer.close();
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append(indent);
sb.append("<!-- hello -->").append("\r\n");
assertEquals(output.toString(), sb.toString());
@@ -279,7 +280,7 @@ public class XmlWriterUtilTest {
String indent = StringUtils.repeat(" ", 2 * 4);
XmlWriterUtil.writeComment(xmlWriter, "hello", 2, 4, 10);
writer.close();
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append(indent);
sb.append("<!-- hello -->").append("\r\n");
assertEquals(output.toString(), sb.toString());
@@ -295,7 +296,7 @@ public class XmlWriterUtilTest {
public void testWriteCommentTextXMLWriterStringInt() throws Exception {
XmlWriterUtil.writeCommentText(xmlWriter, "hello", 0);
writer.close();
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append("\r\n");
sb.append("<!-- ====================================================================== -->")
.append("\r\n");
@@ -318,7 +319,7 @@ public class XmlWriterUtilTest {
+ "loooooooooooooooooooooooooooooooooooooooooooooooooooooonnnnnnnnnnong line",
2);
writer.close();
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append("\r\n");
sb.append(indent)
.append("<!-- ====================================================================== -->")
diff --git a/src/test/java/org/apache/maven/shared/utils/xml/Xpp3DomBuilderTest.java b/src/test/java/org/apache/maven/shared/utils/xml/Xpp3DomBuilderTest.java
index 75b263a..42e9942 100644
--- a/src/test/java/org/apache/maven/shared/utils/xml/Xpp3DomBuilderTest.java
+++ b/src/test/java/org/apache/maven/shared/utils/xml/Xpp3DomBuilderTest.java
@@ -31,18 +31,19 @@ import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.fail;
/**
* @author Kristian Rosenvold
*/
+@SuppressWarnings("deprecation")
public class Xpp3DomBuilderTest {
private static final String XML_DECLARATION = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
@Test
- public void selfClosingTag() throws Exception {
+ public void selfClosingTag() {
String domString = selfClosingTagSource();
@@ -62,12 +63,12 @@ public class Xpp3DomBuilderTest {
Xpp3DomBuilder.build(in, "nosuch encoding");
fail();
} catch (XmlPullParserException expected) {
- assertTrue(expected.getCause() instanceof UnsupportedEncodingException);
+ assertInstanceOf(UnsupportedEncodingException.class, expected.getCause());
}
}
@Test
- public void trimming() throws Exception {
+ public void trimming() {
String domString = createDomString();
Xpp3Dom dom = Xpp3DomBuilder.build(new StringReader(domString), true);
@@ -114,63 +115,36 @@ public class Xpp3DomBuilderTest {
}
private static String getAttributeEncodedString() {
- StringBuilder domString = new StringBuilder();
- domString.append("<root>");
- domString.append("\n");
- domString.append(" <el att=\"<foo>\">bar</el>");
- domString.append("\n");
- domString.append("</root>");
-
- return domString.toString();
+ return "<root>\n" + " <el att=\"<foo>\">bar</el>\n" + "</root>";
}
private static String getEncodedString() {
- StringBuilder domString = new StringBuilder();
- domString.append("<root>\n");
- domString.append(" <a1>\"msg\"</a1>\n");
- domString.append(" <a2><![CDATA[<b>\"msg\"</b>]]></a2>\n");
- domString.append(" <a3><b>"msg"</b></a3>\n");
- domString.append("</root>");
-
- return domString.toString();
+ return "<root>\n" + " <a1>\"msg\"</a1>\n"
+ + " <a2><![CDATA[<b>\"msg\"</b>]]></a2>\n"
+ + " <a3><b>"msg"</b></a3>\n"
+ + "</root>";
}
private static String getExpectedString() {
- StringBuilder domString = new StringBuilder();
- domString.append("<root>");
- domString.append("\n");
- domString.append(" <a1>\"msg\"</a1>");
- domString.append("\n");
- domString.append(" <a2><b>\"msg\"</b></a2>");
- domString.append("\n");
- domString.append(" <a3><b>\"msg\"</b></a3>");
- domString.append("\n");
- domString.append("</root>");
- return domString.toString();
+ return "<root>\n" + " <a1>\"msg\"</a1>\n"
+ + " <a2><b>\"msg\"</b></a2>\n"
+ + " <a3><b>\"msg\"</b></a3>\n"
+ + "</root>";
}
private static String createDomString() {
- StringBuilder buf = new StringBuilder();
- buf.append("<root>\n");
- buf.append(" <element1> element1value\n </element1>\n");
- buf.append(" <element2 att2='attribute2 nextline'>\n");
- buf.append(" <element3 att3='attribute3'>element3value</element3>\n");
- buf.append(" </element2>\n");
- buf.append(" <element4></element4>\n");
- buf.append(" <element5/>\n");
- buf.append(" <element6 xml:space=\"preserve\"> preserve space </element6>\n");
- buf.append("</root>\n");
-
- return buf.toString();
+ return "<root>\n" + " <element1> element1value\n </element1>\n"
+ + " <element2 att2='attribute2 nextline'>\n"
+ + " <element3 att3='attribute3'>element3value</element3>\n"
+ + " </element2>\n"
+ + " <element4></element4>\n"
+ + " <element5/>\n"
+ + " <element6 xml:space=\"preserve\"> preserve space </element6>\n"
+ + "</root>\n";
}
private static String selfClosingTagSource() {
- StringBuilder buf = new StringBuilder();
- buf.append("<root>\n");
- buf.append(" <el4></el4>\n");
- buf.append(" <el5></el5>\n");
- buf.append("</root>");
- return buf.toString();
+ return "<root>\n" + " <el4></el4>\n" + " <el5></el5>\n" + "</root>";
}
private static String expectedSelfClosingTag() {
diff --git a/src/test/java/org/apache/maven/shared/utils/xml/pull/Xpp3DomTest.java b/src/test/java/org/apache/maven/shared/utils/xml/pull/Xpp3DomTest.java
index acb99b1..557553e 100644
--- a/src/test/java/org/apache/maven/shared/utils/xml/pull/Xpp3DomTest.java
+++ b/src/test/java/org/apache/maven/shared/utils/xml/pull/Xpp3DomTest.java
@@ -18,7 +18,6 @@
*/
package org.apache.maven.shared.utils.xml.pull;
-import java.io.IOException;
import java.io.StringReader;
import org.apache.maven.shared.utils.xml.Xpp3Dom;
@@ -27,7 +26,6 @@ import org.junit.jupiter.api.Test;
import static org.apache.maven.shared.utils.xml.Xpp3Dom.mergeXpp3Dom;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -35,6 +33,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
/**
* @author Kristian Rosenvold
*/
+@SuppressWarnings("deprecation")
public class Xpp3DomTest {
private Xpp3Dom createElement(String element, String value) {
@@ -44,7 +43,7 @@ public class Xpp3DomTest {
}
@Test
- public void mergePrecedenceSelfClosed() throws XmlPullParserException, IOException {
+ public void mergePrecedenceSelfClosed() throws XmlPullParserException {
Xpp3Dom parentConfig = build("<configuration><items><item/></items></configuration>");
Xpp3Dom childConfig = build("<configuration><items><item>ooopise</item></items></configuration>");
@@ -57,7 +56,7 @@ public class Xpp3DomTest {
}
@Test
- public void mergePrecedenceOpenClose() throws XmlPullParserException, IOException {
+ public void mergePrecedenceOpenClose() throws XmlPullParserException {
Xpp3Dom parentConfig = build("<configuration><items><item></item></items></configuration>");
Xpp3Dom childConfig = build("<configuration><items><item>ooopise</item></items></configuration>");
@@ -134,20 +133,12 @@ public class Xpp3DomTest {
@Test
public void nullValue() {
- assertThrows(
- NullPointerException.class,
- () ->
- //noinspection ConstantConditions
- new Xpp3Dom("top").setAttribute(null, "value"));
+ assertThrows(NullPointerException.class, () -> new Xpp3Dom("top").setAttribute(null, "value"));
}
@Test
public void nullAttribute() {
- assertThrows(
- NullPointerException.class,
- () ->
- //noinspection ConstantConditions
- new Xpp3Dom("root").setAttribute("attr", null));
+ assertThrows(NullPointerException.class, () -> new Xpp3Dom("root").setAttribute("attr", null));
}
@Test
@@ -158,10 +149,11 @@ public class Xpp3DomTest {
Xpp3Dom other = new Xpp3Dom("single");
other.addChild(new Xpp3Dom("kid2"));
+ //noinspection EqualsWithItself
assertEquals(dom, dom);
//noinspection ObjectEqualsNull
- assertFalse(dom.equals(null));
- assertNotEquals(dom, new Xpp3Dom((String) null));
+ assertNotEquals(null, dom);
+ assertNotEquals(new Xpp3Dom((String) null), dom);
assertNotEquals(dom, other);
}
@@ -198,7 +190,7 @@ public class Xpp3DomTest {
}
@Test
- public void unchangedWithFirstOrLastEmpty() throws Exception {
+ public void unchangedWithFirstOrLastEmpty() {
String configStr = "<root><entries><entry/><entry>test</entry><entry/></entries></root>";
Xpp3Dom dominant = build(configStr);
Xpp3Dom duplicatedDominant = build(configStr);
@@ -225,7 +217,7 @@ public class Xpp3DomTest {
}
@Test
- public void recessiveChildrenIncludedWhenDominantEmpty() throws Exception {
+ public void recessiveChildrenIncludedWhenDominantEmpty() {
String dominant = "<root><baz>bazzy</baz></root>";
String recessive = "<root><bar>barry</bar></root>";
@@ -241,7 +233,7 @@ public class Xpp3DomTest {
}
@Test
- public void duplicatedChildren() throws IOException, XmlPullParserException {
+ public void duplicatedChildren() throws XmlPullParserException {
String dupes = "<root><baz>x</baz><baz>y</baz></root>";
assertEquals("y", build(dupes).getChild("baz").getValue());
}