Skip to content

Commit

Permalink
Loosen access restrictions for test base
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jan 13, 2025
1 parent 31ba155 commit 699f645
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions src/test/java/tools/jackson/core/testutil/JacksonTestUtilBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static IOContext testIOContext() {
ErrorReportConfiguration.defaults());
}

private static IOContext testIOContext(StreamReadConstraints src,
protected static IOContext testIOContext(StreamReadConstraints src,
StreamWriteConstraints swc,
ErrorReportConfiguration erc) {
return new IOContext(src, swc, erc,
Expand All @@ -58,7 +58,7 @@ public static ObjectReadContext testObjectReadContext() {
/**********************************************************************
*/

protected String q(String str) {
public static String q(String str) {
return '"'+str+'"';
}

Expand All @@ -72,14 +72,14 @@ public static String a2q(String json) {
/**********************************************************************
*/

public void assertToken(JsonToken expToken, JsonToken actToken)
public static void assertToken(JsonToken expToken, JsonToken actToken)
{
if (actToken != expToken) {
fail("Expected token "+expToken+", current token "+actToken);
}
}

public void assertToken(JsonToken expToken, JsonParser p)
public static void assertToken(JsonToken expToken, JsonParser p)
{
assertToken(expToken, p.currentToken());
}
Expand Down Expand Up @@ -143,11 +143,11 @@ public static byte[] encodeInUTF32BE(String input)
return result;
}

protected static byte[] utf8Bytes(String str) {
public static byte[] utf8Bytes(String str) {
return str.getBytes(StandardCharsets.UTF_8);
}

protected String utf8String(ByteArrayOutputStream bytes) {
public String utf8String(ByteArrayOutputStream bytes) {
return new String(bytes.toByteArray(), StandardCharsets.UTF_8);
}

Expand All @@ -159,25 +159,25 @@ protected String utf8String(ByteArrayOutputStream bytes) {

public static byte[] readResource(String ref)
{
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
final byte[] buf = new byte[4000];

InputStream in = JacksonCoreTestBase.class.getResourceAsStream(ref);
if (in != null) {
try {
int len;
while ((len = in.read(buf)) > 0) {
bytes.write(buf, 0, len);
}
in.close();
} catch (IOException e) {
throw new RuntimeException("Failed to read resource '"+ref+"': "+e);
}
}
if (bytes.size() == 0) {
throw new IllegalArgumentException("Failed to read resource '"+ref+"': empty resource?");
}
return bytes.toByteArray();
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
final byte[] buf = new byte[4000];

InputStream in = JacksonCoreTestBase.class.getResourceAsStream(ref);
if (in != null) {
try {
int len;
while ((len = in.read(buf)) > 0) {
bytes.write(buf, 0, len);
}
in.close();
} catch (IOException e) {
throw new RuntimeException("Failed to read resource '"+ref+"': "+e);
}
}
if (bytes.size() == 0) {
throw new IllegalArgumentException("Failed to read resource '"+ref+"': empty resource?");
}
return bytes.toByteArray();
}

/*
Expand Down

0 comments on commit 699f645

Please sign in to comment.