From 00c32fe5d39f78340651710cea19178680350f1b Mon Sep 17 00:00:00 2001 From: Jochen Berger Date: Fri, 13 Feb 2015 15:35:15 +0100 Subject: [PATCH] add a test for https://code.google.com/p/json-path/issues/detail?id=58 --- .../com/jayway/jsonpath/old/JsonPathTest.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/json-path/src/test/java/com/jayway/jsonpath/old/JsonPathTest.java b/json-path/src/test/java/com/jayway/jsonpath/old/JsonPathTest.java index 8c5f773b..ecec7ea4 100644 --- a/json-path/src/test/java/com/jayway/jsonpath/old/JsonPathTest.java +++ b/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.Configuration; +import com.jayway.jsonpath.InvalidPathException; import com.jayway.jsonpath.JsonPath; import com.jayway.jsonpath.Option; import com.jayway.jsonpath.PathNotFoundException; import com.jayway.jsonpath.internal.PathCompiler; + import org.assertj.core.api.Assertions; 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()); + } + } + } + + }