Skip to content

Commit db9bab8

Browse files
committed
test refactoring
1 parent a402c75 commit db9bab8

File tree

3 files changed

+69
-35
lines changed

3 files changed

+69
-35
lines changed

src/test/java/tools/jackson/core/unittest/tofix/async/AsyncTokenBranchErrorTest.java renamed to src/test/java/tools/jackson/core/unittest/json/async/AsyncParserInvalidKeywordsTest.java

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package tools.jackson.core.unittest.tofix.async;
1+
package tools.jackson.core.unittest.json.async;
22

33
import org.junit.jupiter.api.Test;
44

@@ -7,13 +7,12 @@
77
import tools.jackson.core.json.JsonFactory;
88
import tools.jackson.core.unittest.async.AsyncTestBase;
99
import tools.jackson.core.unittest.testutil.AsyncReaderWrapper;
10-
import tools.jackson.core.unittest.testutil.failure.JacksonTestFailureExpected;
1110

1211
import static org.junit.jupiter.api.Assertions.fail;
1312

1413
// Tests for handling token decoding fails for non-Root values
1514
// (within Object / Array)
16-
class AsyncTokenBranchErrorTest extends AsyncTestBase
15+
class AsyncParserInvalidKeywordsTest extends AsyncTestBase
1716
{
1817
private final JsonFactory JSON_F = newStreamFactory();
1918

@@ -65,32 +64,6 @@ private void _doTestInvalidKeyword(String value)
6564
}
6665
}
6766

68-
@JacksonTestFailureExpected
69-
@Test
70-
void mangledNonRootInts() throws Exception
71-
{
72-
try (AsyncReaderWrapper p = _createParser("[ 123true ]")) {
73-
assertToken(JsonToken.START_ARRAY, p.nextToken());
74-
JsonToken t = p.nextToken();
75-
fail("Should have gotten an exception; instead got token: "+t);
76-
} catch (StreamReadException e) {
77-
verifyException(e, "expected space");
78-
}
79-
}
80-
81-
@JacksonTestFailureExpected
82-
@Test
83-
void mangledNonRootFloats() throws Exception
84-
{
85-
try (AsyncReaderWrapper p = _createParser("[ 1.5false ]")) {
86-
assertToken(JsonToken.START_ARRAY, p.nextToken());
87-
JsonToken t = p.nextToken();
88-
fail("Should have gotten an exception; instead got token: "+t);
89-
} catch (StreamReadException e) {
90-
verifyException(e, "expected space");
91-
}
92-
}
93-
9467
private AsyncReaderWrapper _createParser(String doc)
9568
{
9669
return asyncForBytes(JSON_F, 1, _jsonDoc(doc), 1);

src/test/java/tools/jackson/core/unittest/tofix/ParserErrorHandling105Test.java

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,35 @@ class ParserErrorHandling105Test
1717
@JacksonTestFailureExpected
1818
@Test
1919
void mangledIntsBytes() throws Exception {
20+
_testMangledNonRootInts(MODE_INPUT_STREAM);
21+
_testMangledNonRootInts(MODE_INPUT_STREAM_THROTTLED);
22+
}
23+
24+
@JacksonTestFailureExpected
25+
@Test
26+
void mangledIntsDataInput() throws Exception {
2027
// 02-Jun-2017, tatu: Fails to fail; should check whether this is expected
2128
// (since DataInput can't do look-ahead)
2229
_testMangledNonRootInts(MODE_DATA_INPUT);
2330
}
2431

2532
@JacksonTestFailureExpected
2633
@Test
27-
void mangledFloatsBytes() throws Exception {
28-
// _testMangledNonRootFloats(MODE_INPUT_STREAM);
29-
// _testMangledNonRootFloats(MODE_INPUT_STREAM_THROTTLED);
34+
void mangledIntsChars() throws Exception {
35+
_testMangledNonRootInts(MODE_READER);
36+
}
3037

31-
_testMangledNonRootFloats(MODE_DATA_INPUT);
38+
@JacksonTestFailureExpected
39+
@Test
40+
void mangledFloatsBytes() throws Exception {
41+
_testMangledNonRootFloats(MODE_INPUT_STREAM);
42+
_testMangledNonRootFloats(MODE_INPUT_STREAM_THROTTLED);
3243
}
3344

3445
@JacksonTestFailureExpected
3546
@Test
36-
void mangledIntsChars() throws Exception {
37-
_testMangledNonRootInts(MODE_READER);
47+
void mangledFloatsDataInput() throws Exception {
48+
_testMangledNonRootFloats(MODE_DATA_INPUT);
3849
}
3950

4051
@JacksonTestFailureExpected
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package tools.jackson.core.unittest.tofix.async;
2+
3+
import org.junit.jupiter.api.Test;
4+
5+
import tools.jackson.core.JsonToken;
6+
import tools.jackson.core.exc.StreamReadException;
7+
import tools.jackson.core.json.JsonFactory;
8+
import tools.jackson.core.unittest.async.AsyncTestBase;
9+
import tools.jackson.core.unittest.testutil.AsyncReaderWrapper;
10+
import tools.jackson.core.unittest.testutil.failure.JacksonTestFailureExpected;
11+
12+
import static org.junit.jupiter.api.Assertions.fail;
13+
14+
// Tests for handling token decoding fails for non-Root values
15+
// (within Object / Array)
16+
class AsyncTokenBranchNumberErrorTest extends AsyncTestBase
17+
{
18+
private final JsonFactory JSON_F = newStreamFactory();
19+
20+
@JacksonTestFailureExpected
21+
@Test
22+
void mangledNonRootInts() throws Exception
23+
{
24+
try (AsyncReaderWrapper p = _createParser("[ 123true ]")) {
25+
assertToken(JsonToken.START_ARRAY, p.nextToken());
26+
JsonToken t = p.nextToken();
27+
fail("Should have gotten an exception; instead got token: "+t);
28+
} catch (StreamReadException e) {
29+
verifyException(e, "expected space");
30+
}
31+
}
32+
33+
@JacksonTestFailureExpected
34+
@Test
35+
void mangledNonRootFloats() throws Exception
36+
{
37+
try (AsyncReaderWrapper p = _createParser("[ 1.5false ]")) {
38+
assertToken(JsonToken.START_ARRAY, p.nextToken());
39+
JsonToken t = p.nextToken();
40+
fail("Should have gotten an exception; instead got token: "+t);
41+
} catch (StreamReadException e) {
42+
verifyException(e, "expected space");
43+
}
44+
}
45+
46+
private AsyncReaderWrapper _createParser(String doc)
47+
{
48+
return asyncForBytes(JSON_F, 1, _jsonDoc(doc), 1);
49+
}
50+
}

0 commit comments

Comments
 (0)