-
-
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
Showing
5 changed files
with
143 additions
and
87 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
49 changes: 49 additions & 0 deletions
49
src/test/java/tools/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,49 @@ | ||
package tools.jackson.core; | ||
|
||
import tools.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
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