Skip to content

Commit

Permalink
Merge branch '2.19'
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jan 12, 2025
2 parents f9a5ef3 + 9359af8 commit 8f9911e
Show file tree
Hide file tree
Showing 33 changed files with 214 additions and 69 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package tools.jackson.dataformat.csv.testutil;

import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.Writer;
import java.io.*;

import tools.jackson.core.io.IOContext;
import tools.jackson.core.io.OutputDecorator;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package tools.jackson.dataformat.javaprop;

import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Properties;
import java.util.*;

import tools.jackson.core.JsonParser;
import tools.jackson.core.Version;
Expand All @@ -12,10 +10,7 @@
import tools.jackson.databind.DeserializationFeature;
import tools.jackson.databind.JavaType;
import tools.jackson.databind.ObjectMapper;
import tools.jackson.databind.cfg.CoercionAction;
import tools.jackson.databind.cfg.CoercionInputShape;
import tools.jackson.databind.cfg.MapperBuilder;
import tools.jackson.databind.cfg.MapperBuilderState;
import tools.jackson.databind.cfg.*;
import tools.jackson.databind.ser.SerializationContextExt;

public class JavaPropsMapper extends ObjectMapper
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package tools.jackson.dataformat.javaprop.impl;

import java.io.*;
import java.io.IOException;
import java.io.Writer;

import tools.jackson.core.*;
import tools.jackson.core.io.IOContext;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package tools.jackson.dataformat.javaprop.io;

import java.util.*;
import java.util.Iterator;
import java.util.Map;

import tools.jackson.core.*;
import tools.jackson.core.TokenStreamContext;
import tools.jackson.core.JsonToken;
import tools.jackson.dataformat.javaprop.util.JPropNode;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package tools.jackson.dataformat.javaprop.io;

import tools.jackson.core.*;
//import tools.jackson.core.json.JsonWriteContext;
import tools.jackson.core.TokenStreamContext;

public class JPropWriteContext
extends TokenStreamContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.util.Map;

import tools.jackson.dataformat.javaprop.*;
import tools.jackson.dataformat.javaprop.JavaPropsSchema;

public class JPropNodeBuilder
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@
import java.util.Map;
import java.util.Properties;

import org.junit.jupiter.api.Test;

import tools.jackson.dataformat.javaprop.util.Markers;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class ArrayGenerationTest extends ModuleTestBase
{
private final JavaPropsMapper MAPPER = newPropertiesMapper();

@Test
public void testPointListSimple() throws Exception
{
Points input = new Points
Expand All @@ -35,6 +40,7 @@ public void testPointListSimple() throws Exception
}
}

@Test
public void testPointListWithIndex() throws Exception
{
JavaPropsSchema schema = JavaPropsSchema.emptySchema()
Expand Down Expand Up @@ -65,6 +71,7 @@ public void testPointListWithIndex() throws Exception
}
}

@Test
public void testPointListWithCustomMarkers() throws Exception
{
JavaPropsSchema schema = JavaPropsSchema.emptySchema()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@
import java.util.List;
import java.util.Map;

import org.junit.jupiter.api.Test;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;

import tools.jackson.databind.ObjectMapper;
import tools.jackson.databind.ObjectReader;

import static org.junit.jupiter.api.Assertions.*;

public class ArrayParsingTest extends ModuleTestBase
{
static class ZKConfig {
Expand Down Expand Up @@ -58,6 +62,7 @@ static class StringArrayWrapper {

private final ObjectMapper MAPPER = newPropertiesMapper();

@Test
public void testArrayWithBranch() throws Exception
{
// basically "extra" branch should become as first element, and
Expand Down Expand Up @@ -93,6 +98,7 @@ public void testArrayWithBranch() throws Exception
assertTrue(ob instanceof Map);
}

@Test
public void testPointList() throws Exception
{
_testPointList(false, false);
Expand Down Expand Up @@ -130,6 +136,7 @@ private void _testPointList(boolean useBytes, boolean allowIndex) throws Excepti
assertEquals(6, result.p.get(2).y);
}

@Test
public void testPointListWithIndex() throws Exception
{
_testPointListWithIndex(false);
Expand All @@ -154,6 +161,7 @@ private void _testPointListWithIndex(boolean useBytes) throws Exception
assertEquals(4, result.p.get(1).y);
}

@Test
public void testZKPojo() throws Exception
{
_testZKPojo(false, false);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package tools.jackson.dataformat.javaprop;

import static org.junit.Assert.assertArrayEquals;

import java.nio.ByteBuffer;
import java.util.Map;
import java.util.Properties;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

public class BinaryParsingTest extends ModuleTestBase
{
// [dataformats-text#74]: problem with multiple binary fields
Expand All @@ -31,6 +33,7 @@ public MyBean(boolean bogus) {
private final JavaPropsMapper MAPPER = newPropertiesMapper();

// [dataformats-text#74]
@Test
public void testMultipleBinaryFields() throws Exception
{
final MyBean src = new MyBean(true);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package tools.jackson.dataformat.javaprop;

import org.junit.jupiter.api.Test;

import tools.jackson.databind.ObjectMapper;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class CustomSeparatorsTest extends ModuleTestBase
{
private final ObjectMapper MAPPER = newPropertiesMapper();

@Test
public void testCustomPathSeparator() throws Exception
{
JavaPropsSchema schema = JavaPropsSchema.emptySchema()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

import java.io.StringWriter;

import tools.jackson.core.JsonGenerator;
import tools.jackson.core.JsonParser;
import tools.jackson.core.ObjectReadContext;
import tools.jackson.core.ObjectWriteContext;
import tools.jackson.core.Version;
import tools.jackson.core.Versioned;
import org.junit.jupiter.api.Test;

import tools.jackson.core.*;

import static org.junit.jupiter.api.Assertions.*;

public class DefaultConfigsTest extends ModuleTestBase
{
private final String ARTIFACT_ID = "jackson-dataformat-properties";

@Test
public void testFactoryBaseConfig()
{
JavaPropsFactory f = new JavaPropsFactory();
Expand All @@ -25,6 +25,7 @@ public void testFactoryBaseConfig()
assertFalse(f.canUseCharArrays());
}

@Test
public void testGeneratorConfig() throws Exception
{
JavaPropsFactory f = new JavaPropsFactory();
Expand All @@ -37,6 +38,7 @@ public void testGeneratorConfig() throws Exception
gen.close();
}

@Test
public void testParserConfig() throws Exception
{
JavaPropsFactory f = new JavaPropsFactory();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
package tools.jackson.dataformat.javaprop;

import java.util.*;
import java.util.HashMap;
import java.util.Map;

import org.junit.jupiter.api.Test;

import tools.jackson.databind.ObjectMapper;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class GenerationEscapingTest extends ModuleTestBase
{
private final ObjectMapper MAPPER = newPropertiesMapper();

@Test
public void testKeyEscaping() throws Exception
{
Map<String,String> input = new HashMap<>();
Expand All @@ -23,6 +29,7 @@ public void testKeyEscaping() throws Exception
assertEquals("combo\\tkey=value\n", MAPPER.writeValueAsString(input));
}

@Test
public void testValueEscaping() throws Exception
{
/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@
import java.util.LinkedHashMap;
import java.util.Map;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

public class JDKSerializabilityTest extends ModuleTestBase
{
@Test
public void testApacheMapperWithModule() throws Exception {
// very simple validation: should still work wrt serialization
JavaPropsMapper unfrozenMapper = serializeAndDeserialize(new JavaPropsMapper());
Expand All @@ -29,6 +34,7 @@ public void testApacheMapperWithModule() throws Exception {
assertEquals(input, result2);
}

@Test
private JavaPropsMapper serializeAndDeserialize(JavaPropsMapper mapper) throws Exception {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
ObjectOutputStream outputStream = new ObjectOutputStream(byteArrayOutputStream);
Expand All @@ -38,8 +44,9 @@ private JavaPropsMapper serializeAndDeserialize(JavaPropsMapper mapper) throws E
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(serializedBytes);
ObjectInputStream inputStream = new ObjectInputStream(byteArrayInputStream);
Object deserializedObject = inputStream.readObject();
assertTrue("Deserialized object should be an instance of JavaPropsMapper",
deserializedObject instanceof JavaPropsMapper);
assertTrue(deserializedObject instanceof JavaPropsMapper,
"Deserialized object should be an instance of JavaPropsMapper"
);
return (JavaPropsMapper) deserializedObject;
}

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

import java.util.Map;

import org.junit.jupiter.api.Test;

import tools.jackson.databind.ObjectMapper;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

public class MapParsingTest extends ModuleTestBase
{
static class MapWrapper {
Expand All @@ -16,6 +21,7 @@ static class MapWrapper {
/**********************************************************************
*/

@Test
public void testMapWithBranchNoEscaping() throws Exception
{
ObjectMapper mapper = newPropertiesMapper();
Expand All @@ -36,6 +42,7 @@ public void testMapWithBranchNoEscaping() throws Exception
assertEquals("fourth", ((Map<?,?>) w.map.get("ab\\")).get("c"));
}

@Test
public void testMapWithBranchBackslashEscape() throws Exception
{
JavaPropsMapper mapper = newPropertiesMapper();
Expand Down Expand Up @@ -73,6 +80,7 @@ public void testMapWithBranchBackslashEscape() throws Exception
assertEquals("twelfth", ((Map<?,?>) w.map.get("xy\\.d")).get("ij"));
}

@Test
public void testMapWithBranchHashEscape() throws Exception
{
JavaPropsMapper mapper = newPropertiesMapper();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package tools.jackson.dataformat.javaprop;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonPropertyOrder;

import tools.jackson.core.*;
import tools.jackson.databind.ObjectMapper;
import tools.jackson.databind.ObjectReader;

import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;

public abstract class ModuleTestBase extends junit.framework.TestCase
public abstract class ModuleTestBase
{
@JsonPropertyOrder({ "topLeft", "bottomRight" })
protected static class Rectangle {
Expand Down
Loading

0 comments on commit 8f9911e

Please sign in to comment.