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..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,23 +415,9 @@ public void testNoMatchFiltering6() throws Exception assertEquals(0, p.getMatchCount()); } - 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()); - } - 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 +425,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 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()); + } +}