-
-
Notifications
You must be signed in to change notification settings - Fork 795
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3a4f156
commit 75b060e
Showing
4 changed files
with
122 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...test/java/com/fasterxml/jackson/core/ErrorReportConfigurationMaxRawContentLengthTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.fasterxml.jackson.core; | ||
|
||
import com.fasterxml.jackson.core.io.ContentReference; | ||
|
||
/** | ||
* Unit tests for class {@link ErrorReportConfiguration#getMaxRawContentLength()}. | ||
*/ | ||
public class ErrorReportConfigurationMaxRawContentLengthTest extends BaseTest { | ||
/* | ||
/********************************************************** | ||
/* Unit Tests | ||
/********************************************************** | ||
*/ | ||
|
||
public void testBasicToStringErrorConfig() throws Exception { | ||
// Truncated result | ||
_verifyToString("abc", 2, | ||
"[Source: (String)\"ab\"[truncated 1 chars]; line: 1, column: 1]"); | ||
// Exact length | ||
_verifyToString("abc", 3, | ||
"[Source: (String)\"abc\"; line: 1, column: 1]"); | ||
// Enough length | ||
_verifyToString("abc", 4, | ||
"[Source: (String)\"abc\"; line: 1, column: 1]"); | ||
} | ||
|
||
/* | ||
/********************************************************** | ||
/* Internal helper methods | ||
/********************************************************** | ||
*/ | ||
|
||
private void _verifyToString(String rawSrc, int rawContentLength, String expectedMessage) { | ||
ContentReference reference = _sourceRefWithErrorReportConfig(rawSrc, rawContentLength); | ||
String location = new JsonLocation(reference, 10L, 10L, 1, 1).toString(); | ||
assertEquals(expectedMessage, location); | ||
} | ||
|
||
private ContentReference _sourceRefWithErrorReportConfig(String rawSrc, int rawContentLength) { | ||
return _sourceRef(rawSrc, | ||
ErrorReportConfiguration.builder().maxRawContentLength(rawContentLength).build()); | ||
} | ||
|
||
private ContentReference _sourceRef(String rawSrc, ErrorReportConfiguration errorReportConfiguration) { | ||
return ContentReference.construct(true, rawSrc, 0, rawSrc.length(),errorReportConfiguration); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters