Skip to content

Commit 8f7c9b9

Browse files
committed
Test refactoring
1 parent ae170b2 commit 8f7c9b9

File tree

3 files changed

+15
-27
lines changed

3 files changed

+15
-27
lines changed

smile/src/test/java/com/fasterxml/jackson/dataformat/smile/BaseTestForSmile.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
import org.junit.Assert;
1010

1111
import com.fasterxml.jackson.core.*;
12-
12+
import com.fasterxml.jackson.core.io.ContentReference;
13+
import com.fasterxml.jackson.core.io.IOContext;
14+
import com.fasterxml.jackson.core.util.BufferRecycler;
1315
import com.fasterxml.jackson.dataformat.smile.databind.SmileMapper;
1416

1517
public abstract class BaseTestForSmile
@@ -149,6 +151,16 @@ protected SmileGenerator smileGenerator(SmileFactory f,
149151
return f.createGenerator(result, null);
150152
}
151153

154+
/**
155+
* Factory method for creating {@link IOContext}s for tests
156+
*/
157+
public static IOContext testIOContext() {
158+
return new IOContext(StreamReadConstraints.defaults(),
159+
StreamWriteConstraints.defaults(),
160+
ErrorReportConfiguration.defaults(),
161+
new BufferRecycler(), ContentReference.unknown(), false);
162+
}
163+
152164
/*
153165
/**********************************************************
154166
/* Additional assertion methods

smile/src/test/java/com/fasterxml/jackson/dataformat/smile/ParserInternalsTest.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22

33
import java.io.InputStream;
44

5-
import com.fasterxml.jackson.core.StreamReadConstraints;
65
import com.fasterxml.jackson.core.exc.StreamReadException;
7-
import com.fasterxml.jackson.core.io.ContentReference;
8-
import com.fasterxml.jackson.core.io.IOContext;
96
import com.fasterxml.jackson.core.sym.ByteQuadsCanonicalizer;
107
import com.fasterxml.jackson.dataformat.smile.testutil.ThrottledInputStream;
118

@@ -74,9 +71,7 @@ private void _verifyVIntBad(byte[] doc, String... msgs) throws Exception
7471
}
7572

7673
private SmileParser _minimalParser(byte[] doc) {
77-
IOContext ctxt = new IOContext(StreamReadConstraints.defaults(),
78-
null, ContentReference.rawReference(doc), false);
79-
return new SmileParser(ctxt, // IOContext
74+
return new SmileParser(testIOContext(),
8075
0, 0, // flags
8176
null, // (codec)
8277
ROOT_SYMBOLS.makeChild(0), // ByteQuadsCanonicalizer
@@ -85,9 +80,7 @@ private SmileParser _minimalParser(byte[] doc) {
8580
}
8681

8782
private SmileParser _minimalParser(InputStream in) {
88-
IOContext ctxt = new IOContext(StreamReadConstraints.defaults(),
89-
null, ContentReference.rawReference(in), false);
90-
return new SmileParser(ctxt, // IOContext
83+
return new SmileParser(testIOContext(),
9184
0, 0, // flags
9285
null, // (codec)
9386
ROOT_SYMBOLS.makeChild(0), // ByteQuadsCanonicalizer

smile/src/test/java/com/fasterxml/jackson/dataformat/smile/SmileFactoryPropertiesTest.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -137,23 +137,6 @@ public void testFallbackWriteAsJson() throws Exception
137137
assertEquals("[]", w.toString());
138138
}
139139

140-
// There is one constructor designed for direct generator instantiation,
141-
// not used by factory; need to ensure it does not fail spectacularly
142-
public void testGeneratorConstruction() throws Exception
143-
{
144-
SmileFactory f = new SmileFactory();
145-
IOContext ctxt = new IOContext(StreamReadConstraints.defaults(),
146-
f._getBufferRecycler(),
147-
ContentReference.rawReference("doc"), false);
148-
OutputStream bytes = new ByteArrayOutputStream();
149-
byte[] buf = new byte[1000];
150-
SmileGenerator g = new SmileGenerator(ctxt, 0, 0,
151-
null, bytes, buf, 0, false);
152-
g.writeStartArray();
153-
g.writeEndArray();
154-
g.close();
155-
}
156-
157140
public void testCanonicalization() throws Exception
158141
{
159142
try (NonBlockingByteArrayParser parser = new SmileFactory()

0 commit comments

Comments
 (0)