Skip to content

Commit

Permalink
Add trivial test for max doc len
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Sep 7, 2023
1 parent 595960a commit 414de9f
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,30 @@

import static org.junit.Assert.assertEquals;

public class StreamReadConstraintsDefaultsTest {
public class StreamReadConstraintsDefaultsTest
{
@Test
public void testOverride() {
final long maxDocLen = 10_000_000L;
final int numLen = 1234;
final int strLen = 12345;
final int depth = 123;
StreamReadConstraints constraints = StreamReadConstraints.builder()
.maxDocumentLength(maxDocLen)
.maxNumberLength(numLen)
.maxStringLength(strLen)
.maxNestingDepth(depth)
.build();
try {
StreamReadConstraints.overrideDefaultStreamReadConstraints(constraints);
assertEquals(maxDocLen, StreamReadConstraints.defaults().getMaxDocumentLength());
assertEquals(depth, StreamReadConstraints.defaults().getMaxNestingDepth());
assertEquals(strLen, StreamReadConstraints.defaults().getMaxStringLength());
assertEquals(numLen, StreamReadConstraints.defaults().getMaxNumberLength());
} finally {
StreamReadConstraints.overrideDefaultStreamReadConstraints(null);
assertEquals(StreamReadConstraints.DEFAULT_MAX_DOC_LEN,
StreamReadConstraints.defaults().getMaxDocumentLength());
assertEquals(StreamReadConstraints.DEFAULT_MAX_DEPTH,
StreamReadConstraints.defaults().getMaxNestingDepth());
assertEquals(StreamReadConstraints.DEFAULT_MAX_STRING_LEN,
Expand Down

0 comments on commit 414de9f

Please sign in to comment.