-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#29 Fix issue with complex JsonPath in filter
- Loading branch information
1 parent
84db967
commit fe67bf7
Showing
24 changed files
with
881 additions
and
804 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 0 additions & 47 deletions
47
jsurfer-all/src/test/java/org/jsfr/json/FastJsonParesrTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,17 @@ | ||
package org.jsfr.json; | ||
|
||
import org.jsfr.json.compiler.JsonPathCompiler; | ||
import org.jsfr.json.provider.FastJsonProvider; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import java.util.Iterator; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Created by Leo on 2017/3/31. | ||
*/ | ||
public class FastJsonParesrTest extends JsonSurferTest { | ||
|
||
@Override | ||
@Before | ||
public void setUp() throws Exception { | ||
provider = FastJsonProvider.INSTANCE; | ||
surfer = new JsonSurfer(FastJsonParser.INSTANCE, provider); | ||
} | ||
|
||
@Test | ||
public void testSurfingIterator() throws Exception { | ||
Iterator<Object> iterator = surfer.iterator(read("sample.json"), JsonPathCompiler.compile("$.store.book[*]")); | ||
int count = 0; | ||
while (iterator.hasNext()) { | ||
LOGGER.info("Iterator next: {}", iterator.next()); | ||
count++; | ||
} | ||
assertEquals(4, count); | ||
} | ||
|
||
@Test | ||
public void testResumableParser() throws Exception { | ||
SurfingConfiguration config = surfer.configBuilder() | ||
.bind("$.store.book[0]", new JsonPathListener() { | ||
@Override | ||
public void onValue(Object value, ParsingContext context) { | ||
LOGGER.info("First pause"); | ||
context.pause(); | ||
} | ||
}) | ||
.bind("$.store.book[1]", new JsonPathListener() { | ||
@Override | ||
public void onValue(Object value, ParsingContext context) { | ||
LOGGER.info("Second pause"); | ||
context.pause(); | ||
} | ||
}).build(); | ||
ResumableParser parser = surfer.createResumableParser(read("sample.json"), config); | ||
assertFalse(parser.resume()); | ||
LOGGER.info("Start parsing"); | ||
parser.parse(); | ||
LOGGER.info("Resume from the first pause"); | ||
assertTrue(parser.resume()); | ||
LOGGER.info("Resume from the second pause"); | ||
assertTrue(parser.resume()); | ||
LOGGER.info("Parsing stopped"); | ||
assertFalse(parser.resume()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
jsurfer-all/src/test/java/org/jsfr/json/JsonSimpleParserTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package org.jsfr.json; | ||
|
||
import org.jsfr.json.provider.JsonSimpleProvider; | ||
import org.junit.Before; | ||
import org.junit.Ignore; | ||
import org.junit.Test; | ||
|
||
/** | ||
* Created by Leo on 2017/8/26. | ||
*/ | ||
public class JsonSimpleParserTest extends JsonSurferTest { | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
provider = JsonSimpleProvider.INSTANCE; | ||
surfer = new JsonSurfer(JsonSimpleParser.INSTANCE, provider); | ||
} | ||
|
||
@Override | ||
public void testTypeBindingOne() throws Exception { | ||
// ignore | ||
} | ||
|
||
@Ignore | ||
@Override | ||
public void testTypeBindingCollection() throws Exception { | ||
// ignore | ||
} | ||
|
||
@Test(expected = UnsupportedOperationException.class) | ||
@Override | ||
public void testSurfingIterator() throws Exception { | ||
super.testSurfingIterator(); | ||
} | ||
|
||
@Test(expected = UnsupportedOperationException.class) | ||
@Override | ||
public void testResumableParser() throws Exception { | ||
super.testResumableParser(); | ||
} | ||
|
||
} |
Oops, something went wrong.