Skip to content

Commit

Permalink
Merge branch '2.17'
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Nov 28, 2023
2 parents 5f069b4 + 35bd198 commit b26054e
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package tools.jackson.databind;
package tools.jackson.databind.testutil;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.LinkedHashMap;
import java.util.Map;

import tools.jackson.databind.*;
import tools.jackson.databind.json.JsonMapper;

/**
Expand All @@ -17,29 +19,29 @@ public class DatabindTestUtil
{
/*
/**********************************************************
/* Helper methods, serialization
/* Mapper construction helpers
/**********************************************************
*/

@SuppressWarnings("unchecked")
public static Map<String,Object> writeAndMap(ObjectMapper m, Object value)
{
String str = m.writeValueAsString(value);
return (Map<String,Object>) m.readValue(str, LinkedHashMap.class);
public static ObjectMapper newJsonMapper() {
return new JsonMapper();
}

public static JsonMapper.Builder jsonMapperBuilder() {
return JsonMapper.builder();
}

/*
/**********************************************************
/* Construction
/* Helper methods, serialization
/**********************************************************
*/

public static ObjectMapper newJsonMapper() {
return new JsonMapper();
}

public static JsonMapper.Builder jsonMapperBuilder() {
return JsonMapper.builder();
@SuppressWarnings("unchecked")
public static Map<String,Object> writeAndMap(ObjectMapper m, Object value)
{
String str = m.writeValueAsString(value);
return (Map<String,Object>) m.readValue(str, LinkedHashMap.class);
}

/*
Expand All @@ -51,4 +53,12 @@ public static JsonMapper.Builder jsonMapperBuilder() {
public static String a2q(String json) {
return json.replace("'", "\"");
}

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

public static byte[] utf8Bytes(String str) {
return str.getBytes(StandardCharsets.UTF_8);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package tools.jackson.databind.views;

import static org.junit.Assert.assertEquals;
import static tools.jackson.databind.DatabindTestUtil.a2q;
import static tools.jackson.databind.testutil.DatabindTestUtil.a2q;

import java.io.IOException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static tools.jackson.databind.DatabindTestUtil.a2q;
import static tools.jackson.databind.DatabindTestUtil.jsonMapperBuilder;
import static tools.jackson.databind.testutil.DatabindTestUtil.a2q;
import static tools.jackson.databind.testutil.DatabindTestUtil.jsonMapperBuilder;

import org.junit.jupiter.api.Test;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package tools.jackson.databind.views;

import static tools.jackson.databind.DatabindTestUtil.jsonMapperBuilder;
import static tools.jackson.databind.DatabindTestUtil.newJsonMapper;
import static tools.jackson.databind.DatabindTestUtil.writeAndMap;
import static tools.jackson.databind.testutil.DatabindTestUtil.jsonMapperBuilder;
import static tools.jackson.databind.testutil.DatabindTestUtil.newJsonMapper;
import static tools.jackson.databind.testutil.DatabindTestUtil.writeAndMap;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static tools.jackson.databind.DatabindTestUtil.jsonMapperBuilder;
import static tools.jackson.databind.testutil.DatabindTestUtil.jsonMapperBuilder;

import java.io.*;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package tools.jackson.databind.views;

import static org.junit.Assert.assertEquals;
import static tools.jackson.databind.DatabindTestUtil.newJsonMapper;
import static tools.jackson.databind.testutil.DatabindTestUtil.newJsonMapper;

import org.junit.jupiter.api.Test;

Expand Down

0 comments on commit b26054e

Please sign in to comment.