From 77d0e5785ab32375550242e1c9287c70d5064113 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Wed, 24 Jun 2015 22:29:09 -0700 Subject: [PATCH] Update release notes wrt #74 --- release-notes/VERSION | 1 + .../csv/failing/NullRead72Test.java | 6 ---- .../PropertyOrder74Test.java | 2 +- .../dataformat/csv/schema/SchemaTest.java | 36 ++++++++++++++----- 4 files changed, 30 insertions(+), 15 deletions(-) rename src/test/java/com/fasterxml/jackson/dataformat/csv/{failing => schema}/PropertyOrder74Test.java (94%) diff --git a/release-notes/VERSION b/release-notes/VERSION index 487a1d7..f70c1bc 100644 --- a/release-notes/VERSION +++ b/release-notes/VERSION @@ -6,6 +6,7 @@ Project: jackson-dataformat-csv 2.6.0 (not yet released) +#74: Problems with ordering, `@JsonPropertyOrder` losing alphabetic ordering - Removed type `CsvObjectReader`, sub-classing not needed at this point, just complicates handling (for now) diff --git a/src/test/java/com/fasterxml/jackson/dataformat/csv/failing/NullRead72Test.java b/src/test/java/com/fasterxml/jackson/dataformat/csv/failing/NullRead72Test.java index 7a37f3b..408e1b9 100644 --- a/src/test/java/com/fasterxml/jackson/dataformat/csv/failing/NullRead72Test.java +++ b/src/test/java/com/fasterxml/jackson/dataformat/csv/failing/NullRead72Test.java @@ -1,14 +1,8 @@ package com.fasterxml.jackson.dataformat.csv.failing; -import java.io.ByteArrayOutputStream; -import java.util.*; - -import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.dataformat.csv.*; -import static org.junit.Assert.assertArrayEquals; - public class NullRead72Test extends ModuleTestBase { final CsvMapper MAPPER = mapperForCsv(); diff --git a/src/test/java/com/fasterxml/jackson/dataformat/csv/failing/PropertyOrder74Test.java b/src/test/java/com/fasterxml/jackson/dataformat/csv/schema/PropertyOrder74Test.java similarity index 94% rename from src/test/java/com/fasterxml/jackson/dataformat/csv/failing/PropertyOrder74Test.java rename to src/test/java/com/fasterxml/jackson/dataformat/csv/schema/PropertyOrder74Test.java index 4755b01..cebd70d 100644 --- a/src/test/java/com/fasterxml/jackson/dataformat/csv/failing/PropertyOrder74Test.java +++ b/src/test/java/com/fasterxml/jackson/dataformat/csv/schema/PropertyOrder74Test.java @@ -1,4 +1,4 @@ -package com.fasterxml.jackson.dataformat.csv.failing; +package com.fasterxml.jackson.dataformat.csv.schema; import com.fasterxml.jackson.annotation.JsonPropertyOrder; diff --git a/src/test/java/com/fasterxml/jackson/dataformat/csv/schema/SchemaTest.java b/src/test/java/com/fasterxml/jackson/dataformat/csv/schema/SchemaTest.java index 2b234d9..ca017fb 100644 --- a/src/test/java/com/fasterxml/jackson/dataformat/csv/schema/SchemaTest.java +++ b/src/test/java/com/fasterxml/jackson/dataformat/csv/schema/SchemaTest.java @@ -7,6 +7,8 @@ import com.fasterxml.jackson.dataformat.csv.CsvSchema; import com.fasterxml.jackson.dataformat.csv.ModuleTestBase; import com.fasterxml.jackson.dataformat.csv.CsvSchema.Column; +import com.fasterxml.jackson.dataformat.csv.schema.PropertyOrder74Test.Point; +import com.fasterxml.jackson.dataformat.csv.schema.PropertyOrder74Test.PointWithAnnotation; public class SchemaTest extends ModuleTestBase { @@ -22,16 +24,26 @@ static class ArrayWrapper { public List c; } + // for [databind#74] + static class Point { + public int y; + public int x; + } + + @JsonPropertyOrder() + public static class PointWithAnnotation extends Point {} + /* /********************************************************************** /* Test methods /********************************************************************** */ + final CsvMapper MAPPER = mapperForCsv(); + public void testUserWithTypedAutoSchema() throws Exception { - CsvMapper mapper = mapperForCsv(); - CsvSchema schema = mapper.typedSchemaFor(FiveMinuteUser.class); + CsvSchema schema = MAPPER.typedSchemaFor(FiveMinuteUser.class); assertEquals("[\"firstName\",\"lastName\",\"gender\",\"verified\",\"userImage\"]", schema.getColumnDesc()); assertEquals(5, schema.size()); @@ -65,8 +77,7 @@ public void testUserWithTypedAutoSchema() throws Exception public void testArrayWithTypedAutoSchema() throws Exception { - CsvMapper mapper = mapperForCsv(); - CsvSchema schema = mapper.typedSchemaFor(ArrayWrapper.class); + CsvSchema schema = MAPPER.typedSchemaFor(ArrayWrapper.class); assertEquals("[\"a\",\"b\",\"c\"]", schema.getColumnDesc()); assertEquals(3, schema.size()); @@ -88,7 +99,7 @@ public void testArrayWithTypedAutoSchema() throws Exception _verifyLinks(schema); } - // for [Issue#42] + // for [dataformat-csv#42] public void testReorderByName() throws Exception { CsvMapper mapper = mapperForCsv(); @@ -100,11 +111,10 @@ public void testReorderByName() throws Exception _verifyLinks(schema); } - // for [Issue#42] + // for [dataformat-csv#42] public void testReorderWithComparator() throws Exception { - CsvMapper mapper = mapperForCsv(); - CsvSchema schema = mapper.schemaFor(Mixed.class); + CsvSchema schema = MAPPER.schemaFor(Mixed.class); schema = schema.sortedBy(Collections.reverseOrder()); assertEquals(aposToQuotes("['d','c','b','a']"), schema.getColumnDesc()); @@ -125,4 +135,14 @@ private void _verifyLinks(CsvSchema schema) prev = curr; } } + + // For [dataformat-csv#74]: problems applying default do-sort handling + public void testSchemaWithOrdering() throws Exception + { + CsvSchema schema1 = MAPPER.schemaFor(Point.class); + CsvSchema schema2 = MAPPER.schemaFor(PointWithAnnotation.class); + + assertEquals(schema1.size(), schema2.size()); + assertEquals(schema1.column(0).getName(), schema2.column(0).getName()); + } }