diff --git a/CHANGELOG.md b/CHANGELOG.md
index a920d8b..56f2ddd 100755
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,9 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
-## Unreleased
+## 2.1.0 - 2021-01-23
### Added
* Tests for JSON patch move operation on nonexistent value.
+* Test case for failure of character encoding detection.
### Changed
* Add operation on empty JSON pointer to structure type now accepts both array and object. This change is due to the requirement in the TCK.
diff --git a/README.md b/README.md
index 995f1f8..3dbb3bf 100644
--- a/README.md
+++ b/README.md
@@ -34,7 +34,7 @@ The jar-packaged artifact of this test suite is available from [JitPack] reposit
org.leadpony
jsonp-test-suite
- 2.0.0
+ 2.1.0
test
@@ -84,7 +84,7 @@ mvn test -P test-with-joy
```
## Copyright Notice
-Copyright 2019-2020 the original author or authors. All rights reserved.
+Copyright 2019-2021 the original author or authors. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this product except in compliance with the License.
diff --git a/pom.xml b/pom.xml
index f0c5a60..d92ff26 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
org.leadpony
jsonp-test-suite
- 2.1.0-SNAPSHOT
+ 2.1.0
jar
JSON-P Test Suite
@@ -244,7 +244,7 @@
org.leadpony.joy
joy-classic
- 2.0.0
+ 2.1.0
test
diff --git a/src/main/java/org/leadpony/jsonp/testsuite/tests/CharsetDetectionTest.java b/src/main/java/org/leadpony/jsonp/testsuite/tests/CharsetDetectionTest.java
index afc7113..a8e3ae8 100644
--- a/src/main/java/org/leadpony/jsonp/testsuite/tests/CharsetDetectionTest.java
+++ b/src/main/java/org/leadpony/jsonp/testsuite/tests/CharsetDetectionTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2019-2020 the JSON-P Test Suite Authors.
+ * Copyright 2019-2021 the JSON-P Test Suite Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,9 @@
*/
package org.leadpony.jsonp.testsuite.tests;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
+import static org.assertj.core.api.Assertions.catchThrowable;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
@@ -24,10 +26,12 @@
import java.nio.charset.StandardCharsets;
import jakarta.json.Json;
+import jakarta.json.JsonException;
import jakarta.json.stream.JsonParser;
import jakarta.json.stream.JsonParserFactory;
import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource;
@@ -112,19 +116,27 @@ public void utf32leWithBom(JsonTestCase test) {
testParser(test, UTF_32LE, UTF_32LE_BOM);
}
+ @Test
+ public void shouldFailToDetectEncoding() {
+ byte[] bytes = {0x00};
+ InputStream in = new ByteArrayInputStream(bytes);
+ Throwable thrown = catchThrowable(() -> {
+ parserFactory.createParser(in);
+ });
+ assertThat(thrown).isInstanceOf(JsonException.class);
+ }
+
private void testParser(JsonTestCase test, Charset charset) {
InputStream in = createEncodedStream(test.getJson(), charset);
- assertThatCode(() -> {
- JsonParser parser = parserFactory.createParser(in);
- while (parser.hasNext()) {
- parser.next();
- }
- parser.close();
- }).doesNotThrowAnyException();
+ testParserWithStream(in);
}
private void testParser(JsonTestCase test, Charset charset, byte[] bom) {
InputStream in = createEncodedStream(test.getJson(), charset, bom);
+ testParserWithStream(in);
+ }
+
+ private void testParserWithStream(InputStream in) {
assertThatCode(() -> {
JsonParser parser = parserFactory.createParser(in);
while (parser.hasNext()) {