NIFI-1660: Fix formatting; update to NOTICE files of nars that bring in EL. Closed Reader that was opened in TestQuery.

This commit is contained in:
Mark Payne 2016-06-07 15:33:13 -04:00
parent abad7d805e
commit 6de738fd04
4 changed files with 34 additions and 21 deletions

View File

@ -1359,9 +1359,8 @@ public class Query {
return addToken(new JsonPathEvaluator(toStringEvaluator(subjectEvaluator), return addToken(new JsonPathEvaluator(toStringEvaluator(subjectEvaluator),
toStringEvaluator(argEvaluators.get(0), "first argument to jsonPath")), "jsonPath"); toStringEvaluator(argEvaluators.get(0), "first argument to jsonPath")), "jsonPath");
} }
default: default:
throw new AttributeExpressionLanguageParsingException( throw new AttributeExpressionLanguageParsingException("Expected a Function-type expression but got " + tree.toString());
"Expected a Function-type expression but got " + tree.toString());
} }
} }

View File

@ -241,7 +241,7 @@ public class TestQuery {
} }
@Test @Test
public void testJsonPath() { public void testJsonPath() throws IOException {
final Map<String, String> attributes = new HashMap<>(); final Map<String, String> attributes = new HashMap<>();
attributes.put("json", getResourceAsString("/json/address-book.json")); attributes.put("json", getResourceAsString("/json/address-book.json"));
verifyEquals("${json:jsonPath('$.firstName')}", attributes, "John"); verifyEquals("${json:jsonPath('$.firstName')}", attributes, "John");
@ -1315,24 +1315,22 @@ public class TestQuery {
assertEquals(expectedResult, result.getValue()); assertEquals(expectedResult, result.getValue());
} }
private String getResourceAsString(String resourceName) { private String getResourceAsString(String resourceName) throws IOException {
Reader reader = new InputStreamReader(new BufferedInputStream(getClass().getResourceAsStream(resourceName))); try (final Reader reader = new InputStreamReader(new BufferedInputStream(getClass().getResourceAsStream(resourceName)))) {
int n = 0; int n = 0;
char[] buf = new char[1024]; char[] buf = new char[1024];
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
while (n != -1) { while (n != -1) {
try { try {
n = reader.read(buf, 0, buf.length); n = reader.read(buf, 0, buf.length);
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException("failed to read resource", e); throw new RuntimeException("failed to read resource", e);
} }
if (n > 0) { if (n > 0) {
sb.append(buf, 0, n); sb.append(buf, 0, n);
}
} }
return sb.toString();
} }
return sb.toString();
} }
} }

View File

@ -100,6 +100,14 @@ The following binary components are provided under the Apache Software License v
Swagger Core 1.5.3-M1 Swagger Core 1.5.3-M1
Copyright 2015 Reverb Technologies, Inc. Copyright 2015 Reverb Technologies, Inc.
(ASLv2) JSON-SMART
The following NOTICE information applies:
Copyright 2011 JSON-SMART authors
(ASLv2) JsonPath
The following NOTICE information applies:
Copyright 2011 JsonPath authors
************************ ************************
Common Development and Distribution License 1.1 Common Development and Distribution License 1.1
************************ ************************

View File

@ -17,3 +17,11 @@ The following binary components are provided under the Apache Software License v
This product includes software from the Spring Framework, This product includes software from the Spring Framework,
under the Apache License 2.0 (see: StringUtils.containsWhitespace()) under the Apache License 2.0 (see: StringUtils.containsWhitespace())
(ASLv2) JSON-SMART
The following NOTICE information applies:
Copyright 2011 JSON-SMART authors
(ASLv2) JsonPath
The following NOTICE information applies:
Copyright 2011 JsonPath authors