From 589192447d82b3260cc2c941e5e4ebf36e1f6f43 Mon Sep 17 00:00:00 2001 From: jhaber Date: Sat, 7 Nov 2020 00:07:38 -0500 Subject: [PATCH 1/2] Fix failing tests --- .../jackson/core/filter/BasicGeneratorFilteringTest.java | 2 +- .../jackson/core/filter/BasicParserFilteringTest.java | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/test/java/com/fasterxml/jackson/core/filter/BasicGeneratorFilteringTest.java b/src/test/java/com/fasterxml/jackson/core/filter/BasicGeneratorFilteringTest.java index 07f125122a..16053fc91e 100644 --- a/src/test/java/com/fasterxml/jackson/core/filter/BasicGeneratorFilteringTest.java +++ b/src/test/java/com/fasterxml/jackson/core/filter/BasicGeneratorFilteringTest.java @@ -227,7 +227,7 @@ private void _testSingleMatchFilteringWithPathAlternate1(boolean exclude) throws FilteringGeneratorDelegate gen = new FilteringGeneratorDelegate(_createGenerator(w), tf, Inclusion.INCLUDE_ALL_AND_PATH, - false // multipleMatches + true // multipleMatches ); //final String JSON = "{'a':123,'array':[1,2],'ob':{'value0':2,'value':[3],'value2':'foo'},'b':true}"; diff --git a/src/test/java/com/fasterxml/jackson/core/filter/BasicParserFilteringTest.java b/src/test/java/com/fasterxml/jackson/core/filter/BasicParserFilteringTest.java index fb17bde17d..0e47b1c9c1 100644 --- a/src/test/java/com/fasterxml/jackson/core/filter/BasicParserFilteringTest.java +++ b/src/test/java/com/fasterxml/jackson/core/filter/BasicParserFilteringTest.java @@ -423,7 +423,8 @@ public void testNoMatchFiltering6() throws Exception assertEquals(0, p.getMatchCount()); } - public void testValueOmitsFieldName1() throws Exception + // https://github.com/FasterXML/jackson-core/issues/649 + public void failing_testValueOmitsFieldName1() throws Exception { String jsonString = aposToQuotes("{'a':123,'array':[1,2]}"); JsonParser p0 = JSON_F.createParser(jsonString); @@ -439,7 +440,7 @@ public void testValueOmitsFieldName1() throws Exception public void testValueOmitsFieldName2() throws Exception { - String jsonString = aposToQuotes("['a',{'value0':3,'b':{'value':4}}]"); + String jsonString = aposToQuotes("['a',{'value0':3,'b':{'value':4}},123]"); JsonParser p0 = JSON_F.createParser(jsonString); FilteringParserDelegate p = new FilteringParserDelegate(p0, new NoObjectsFilter(), @@ -447,8 +448,8 @@ public void testValueOmitsFieldName2() throws Exception true // multipleMatches ); String result = readAndWrite(JSON_F, p); - assertEquals(aposToQuotes("['a']"), result); - assertEquals(1, p.getMatchCount()); + assertEquals(aposToQuotes("['a',123]"), result); + assertEquals(2, p.getMatchCount()); } public void testIndexMatchWithPath1() throws Exception From 213b8143eef161096d11667e49de6f7e02ad8bf5 Mon Sep 17 00:00:00 2001 From: jhaber Date: Sat, 7 Nov 2020 13:52:28 -0500 Subject: [PATCH 2/2] Move test to failing directory --- .../core/filter/BasicParserFilteringTest.java | 23 ------------ .../filter/BasicParserFilteringTest.java | 36 +++++++++++++++++++ 2 files changed, 36 insertions(+), 23 deletions(-) create mode 100644 src/test/java/com/fasterxml/jackson/failing/filter/BasicParserFilteringTest.java diff --git a/src/test/java/com/fasterxml/jackson/core/filter/BasicParserFilteringTest.java b/src/test/java/com/fasterxml/jackson/core/filter/BasicParserFilteringTest.java index 0e47b1c9c1..a49c5ea2f1 100644 --- a/src/test/java/com/fasterxml/jackson/core/filter/BasicParserFilteringTest.java +++ b/src/test/java/com/fasterxml/jackson/core/filter/BasicParserFilteringTest.java @@ -80,14 +80,6 @@ public TokenFilter includeElement(int index) { protected boolean _includeScalar() { return false; } } - static class NoArraysFilter extends TokenFilter - { - @Override - public TokenFilter filterStartArray() { - return null; - } - } - static class NoObjectsFilter extends TokenFilter { @Override @@ -423,21 +415,6 @@ public void testNoMatchFiltering6() throws Exception assertEquals(0, p.getMatchCount()); } - // https://github.com/FasterXML/jackson-core/issues/649 - public void failing_testValueOmitsFieldName1() throws Exception - { - String jsonString = aposToQuotes("{'a':123,'array':[1,2]}"); - JsonParser p0 = JSON_F.createParser(jsonString); - FilteringParserDelegate p = new FilteringParserDelegate(p0, - new NoArraysFilter(), - Inclusion.INCLUDE_NON_NULL, - true // multipleMatches - ); - String result = readAndWrite(JSON_F, p); - assertEquals(aposToQuotes("{'a':123}"), result); - assertEquals(0, p.getMatchCount()); - } - public void testValueOmitsFieldName2() throws Exception { String jsonString = aposToQuotes("['a',{'value0':3,'b':{'value':4}},123]"); diff --git a/src/test/java/com/fasterxml/jackson/failing/filter/BasicParserFilteringTest.java b/src/test/java/com/fasterxml/jackson/failing/filter/BasicParserFilteringTest.java new file mode 100644 index 0000000000..c47a23d8b7 --- /dev/null +++ b/src/test/java/com/fasterxml/jackson/failing/filter/BasicParserFilteringTest.java @@ -0,0 +1,36 @@ +package com.fasterxml.jackson.failing.filter; + +import com.fasterxml.jackson.core.BaseTest; +import com.fasterxml.jackson.core.JsonFactory; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.filter.FilteringParserDelegate; +import com.fasterxml.jackson.core.filter.TokenFilter; +import com.fasterxml.jackson.core.filter.TokenFilter.Inclusion; + +public class BasicParserFilteringTest extends BaseTest { + + private final JsonFactory JSON_F = new JsonFactory(); + + static class NoArraysFilter extends TokenFilter + { + @Override + public TokenFilter filterStartArray() { + return null; + } + } + + // for [core#649] + public void testValueOmitsFieldName1() throws Exception + { + String jsonString = aposToQuotes("{'a':123,'array':[1,2]}"); + JsonParser p0 = JSON_F.createParser(jsonString); + FilteringParserDelegate p = new FilteringParserDelegate(p0, + new NoArraysFilter(), + Inclusion.INCLUDE_NON_NULL, + true // multipleMatches + ); + String result = readAndWrite(JSON_F, p); + assertEquals(aposToQuotes("{'a':123}"), result); + assertEquals(0, p.getMatchCount()); + } +}