12 changed files with 4824 additions and 47 deletions
@ -1,17 +1,45 @@
|
||||
|
||||
package com.jayway.jsonpath.internal.token; |
||||
|
||||
import java.util.logging.Logger; |
||||
|
||||
/** |
||||
* |
||||
* @author Hunter Payne |
||||
**/ |
||||
public interface TokenStackElement |
||||
public abstract class TokenStackElement |
||||
{ |
||||
public TokenType getType(); // otherwise its an object
|
||||
private static Logger log = Logger.getLogger(TokenStackElement.class.getName()); |
||||
|
||||
private boolean matched = false; |
||||
|
||||
private TokenStackElement parent; |
||||
|
||||
public abstract TokenType getType(); // otherwise its an object
|
||||
|
||||
public abstract TokenStackElement getValue(); |
||||
|
||||
public abstract void setValue(TokenStackElement elem); |
||||
|
||||
public TokenStackElement getParent() { |
||||
if (parent == null) { |
||||
return this; |
||||
} |
||||
//log.trace("parent: " + parent);
|
||||
return parent; |
||||
} |
||||
|
||||
public TokenStackElement getValue(); |
||||
public void setParent(TokenStackElement parent) { |
||||
this.parent = parent; |
||||
} |
||||
|
||||
public void setValue(TokenStackElement elem); |
||||
public void setMatched() { |
||||
this.matched = true; |
||||
} |
||||
|
||||
public boolean getMatched() { |
||||
return matched; |
||||
} |
||||
} |
||||
|
||||
// End TokenStackElement.java
|
||||
|
@ -0,0 +1,58 @@
|
||||
package com.jayway.jsonpath; |
||||
|
||||
import static org.junit.Assert.*; |
||||
import com.fasterxml.jackson.core.JsonFactory; |
||||
import com.fasterxml.jackson.core.JsonParseException; |
||||
import com.jayway.jsonpath.internal.Path; |
||||
import com.jayway.jsonpath.internal.PathCompiler; |
||||
import com.jayway.jsonpath.internal.token.TokenStack; |
||||
|
||||
import java.io.IOException; |
||||
import java.io.InputStream; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.junit.Test; |
||||
|
||||
public class JacksonTest_Split extends BaseTest implements EvaluationCallback { |
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(JacksonTest_Split.class); |
||||
private List<Object> results = new ArrayList<Object>(); |
||||
|
||||
@Test |
||||
public void json_Test() throws Exception { |
||||
jsonSplit_Test(JACKSON_CONFIGURATION); |
||||
results.clear(); |
||||
jsonSplit_Test(JSON_SMART_CONFIGURATION); |
||||
results.clear(); |
||||
} |
||||
|
||||
private void jsonSplit_Test(Configuration jsonProviderCfg) throws JsonParseException, IOException, Exception { |
||||
|
||||
String res = "json_opsview1.json"; |
||||
try (InputStream stream = getClass().getClassLoader().getResourceAsStream(res)) { |
||||
Path path = PathCompiler.compile("$.list[*]"); |
||||
|
||||
TokenStack stack = new TokenStack(jsonProviderCfg); |
||||
|
||||
JsonFactory factory = new JsonFactory(); |
||||
stack.registerPath(path); |
||||
stack.read(factory.createParser(stream), this, false); |
||||
} |
||||
log.debug("results: " + results.size()); |
||||
assertTrue(results.size() == 96); |
||||
} |
||||
|
||||
@Override |
||||
public void resultFound(Object source, Object obj, Path path) throws Exception { |
||||
//log.debug(source + ":" + String.valueOf(obj));
|
||||
results.add(obj); |
||||
} |
||||
|
||||
@Override |
||||
public void resultFoundExit(Object source, Object obj, Path path) throws Exception { |
||||
//log.debug(source + ":" + String.valueOf(obj));
|
||||
} |
||||
} |
Loading…
Reference in new issue