Browse Source

Merge pull request #67 from jochenberger/fix-string-index-out-of-bounds

add a test for https://code.google.com/p/json-path/issues/detail?id=58
pull/69/head
kallestenflo 10 years ago
parent
commit
73244289e7
  1. 17
      json-path/src/test/java/com/jayway/jsonpath/old/JsonPathTest.java

17
json-path/src/test/java/com/jayway/jsonpath/old/JsonPathTest.java

@ -2,10 +2,12 @@ package com.jayway.jsonpath.old;
import com.jayway.jsonpath.BaseTest; import com.jayway.jsonpath.BaseTest;
import com.jayway.jsonpath.Configuration; import com.jayway.jsonpath.Configuration;
import com.jayway.jsonpath.InvalidPathException;
import com.jayway.jsonpath.JsonPath; import com.jayway.jsonpath.JsonPath;
import com.jayway.jsonpath.Option; import com.jayway.jsonpath.Option;
import com.jayway.jsonpath.PathNotFoundException; import com.jayway.jsonpath.PathNotFoundException;
import com.jayway.jsonpath.internal.PathCompiler; import com.jayway.jsonpath.internal.PathCompiler;
import org.assertj.core.api.Assertions; import org.assertj.core.api.Assertions;
import org.junit.Test; import org.junit.Test;
@ -308,4 +310,19 @@ public class JsonPathTest extends BaseTest {
} }
@Test
// see https://code.google.com/p/json-path/issues/detail?id=58
public void invalid_paths_throw_invalid_path_exception() throws Exception {
for (String path : new String[]{"$.", "$.results[?"}){
try{
JsonPath.compile(path);
} catch (InvalidPathException e){
// that's expected
} catch (Exception e){
fail("Expected an InvalidPathException trying to compile '"+path+"', but got a "+e.getClass().getName());
}
}
}
} }

Loading…
Cancel
Save