You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by jo...@apache.org on 2015/04/27 17:54:49 UTC
[05/12] incubator-nifi git commit: NIFI-271
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d29a2d68/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestEvaluateXQuery.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestEvaluateXQuery.java b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestEvaluateXQuery.java
index 99d5858..aae4411 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestEvaluateXQuery.java
+++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestEvaluateXQuery.java
@@ -43,8 +43,7 @@ import org.junit.Test;
public class TestEvaluateXQuery {
- private static final Path XML_SNIPPET = Paths.
- get("src/test/resources/TestXml/fruit.xml");
+ private static final Path XML_SNIPPET = Paths.get("src/test/resources/TestXml/fruit.xml");
private static final String[] fruitNames = {"apple", "apple", "banana", "orange", "blueberry", "raspberry", "none"};
private static final String[] methods = {EvaluateXQuery.OUTPUT_METHOD_XML, EvaluateXQuery.OUTPUT_METHOD_HTML, EvaluateXQuery.OUTPUT_METHOD_TEXT};
@@ -56,15 +55,11 @@ public class TestEvaluateXQuery {
for (int i = 0; i < methods.length; i++) {
for (int j = 0; j < booleans.length; j++) {
for (int k = 0; k < booleans.length; k++) {
- Properties props = EvaluateXQuery.
- getTransformerProperties(methods[i], booleans[j], booleans[k]);
+ Properties props = EvaluateXQuery.getTransformerProperties(methods[i], booleans[j], booleans[k]);
assertEquals(3, props.size());
- assertEquals(methods[i], props.
- getProperty(OutputKeys.METHOD));
- assertEquals(booleans[j] ? "yes" : "no", props.
- getProperty(OutputKeys.INDENT));
- assertEquals(booleans[k] ? "yes" : "no", props.
- getProperty(OutputKeys.OMIT_XML_DECLARATION));
+ assertEquals(methods[i], props.getProperty(OutputKeys.METHOD));
+ assertEquals(booleans[j] ? "yes" : "no", props.getProperty(OutputKeys.INDENT));
+ assertEquals(booleans[k] ? "yes" : "no", props.getProperty(OutputKeys.OMIT_XML_DECLARATION));
}
}
}
@@ -162,14 +157,10 @@ public class TestEvaluateXQuery {
List<String> resultStrings = new ArrayList<>();
runnerProps.clear();
- runnerProps.
- put(EvaluateXQuery.DESTINATION.getName(), EvaluateXQuery.DESTINATION_CONTENT);
+ runnerProps.put(EvaluateXQuery.DESTINATION.getName(), EvaluateXQuery.DESTINATION_CONTENT);
runnerProps.put(EvaluateXQuery.XML_OUTPUT_METHOD.getName(), method);
- runnerProps.put(EvaluateXQuery.XML_OUTPUT_INDENT.getName(), Boolean.
- toString(indent));
- runnerProps.
- put(EvaluateXQuery.XML_OUTPUT_OMIT_XML_DECLARATION.getName(), Boolean.
- toString(omitDeclaration));
+ runnerProps.put(EvaluateXQuery.XML_OUTPUT_INDENT.getName(), Boolean.toString(indent));
+ runnerProps.put(EvaluateXQuery.XML_OUTPUT_OMIT_XML_DECLARATION.getName(), Boolean.toString(omitDeclaration));
runnerProps.put("xquery", xQuery);
resultFlowFiles = runXquery(xml, runnerProps);
@@ -185,26 +176,22 @@ public class TestEvaluateXQuery {
@Test(expected = java.lang.AssertionError.class)
public void testBadXQuery() throws Exception {
- doXqueryTest(XML_SNIPPET, "counttttttt(*:fruitbasket/fruit)", Arrays.
- asList("7"));
+ doXqueryTest(XML_SNIPPET, "counttttttt(*:fruitbasket/fruit)", Arrays.asList("7"));
}
@Test
public void testXQueries() throws Exception {
/* count matches */
- doXqueryTest(XML_SNIPPET, "count(*:fruitbasket/fruit)", Arrays.
- asList("7"));
+ doXqueryTest(XML_SNIPPET, "count(*:fruitbasket/fruit)", Arrays.asList("7"));
doXqueryTest(XML_SNIPPET, "count(//fruit)", Arrays.asList("7"));
/* Using a namespace */
- doXqueryTest(XML_SNIPPET, "declare namespace fb = \"http://namespace/1\"; count(fb:fruitbasket/fruit)", Arrays.
- asList("7"));
+ doXqueryTest(XML_SNIPPET, "declare namespace fb = \"http://namespace/1\"; count(fb:fruitbasket/fruit)", Arrays.asList("7"));
/* determine if node exists */
doXqueryTest(XML_SNIPPET, "boolean(//fruit[1])", Arrays.asList("true"));
- doXqueryTest(XML_SNIPPET, "boolean(//fruit[100])", Arrays.
- asList("false"));
+ doXqueryTest(XML_SNIPPET, "boolean(//fruit[100])", Arrays.asList("false"));
/* XML first match */
doXqueryTest(XML_SNIPPET, "//fruit[1]", Arrays.asList(
@@ -242,16 +229,13 @@ public class TestEvaluateXQuery {
+ "</wrap>"));
/* String all matches fruit names*/
- doXqueryTest(XML_SNIPPET, "for $x in //fruit return $x/name/text()", Arrays.
- asList(fruitNames));
+ doXqueryTest(XML_SNIPPET, "for $x in //fruit return $x/name/text()", Arrays.asList(fruitNames));
/* String first match fruit name (XPath)*/
- doXqueryTest(XML_SNIPPET, "//fruit[1]/name/text()", Arrays.
- asList("apple"));
+ doXqueryTest(XML_SNIPPET, "//fruit[1]/name/text()", Arrays.asList("apple"));
/* String first match fruit color (XPath)*/
- doXqueryTest(XML_SNIPPET, "//fruit[1]/color/text()", Arrays.
- asList("red"));
+ doXqueryTest(XML_SNIPPET, "//fruit[1]/color/text()", Arrays.asList("red"));
/* String first match fruit name (XQuery)*/
doXqueryTest(XML_SNIPPET, "for $x in //fruit[1] return string-join(($x/name/text() , $x/color/text()), ' - ')",
@@ -296,31 +280,25 @@ public class TestEvaluateXQuery {
/* String all matches name only, comma delimited (one result)*/
doXqueryTest(XML_SNIPPET, "string-join((for $x in //fruit return $x/name/text()), ', ')",
- Arrays.
- asList("apple, apple, banana, orange, blueberry, raspberry, none"));
+ Arrays.asList("apple, apple, banana, orange, blueberry, raspberry, none"));
/* String all matches color and name, comma delimited (one result)*/
doXqueryTest(XML_SNIPPET, "string-join((for $y in (for $x in //fruit return string-join(($x/color/text() , $x/name/text()), ' ')) return $y), ', ')",
- Arrays.
- asList("red apple, green apple, yellow banana, orange orange, blue blueberry, red raspberry, none"));
+ Arrays.asList("red apple, green apple, yellow banana, orange orange, blue blueberry, red raspberry, none"));
/* String all matches color and name, comma delimited using let(one result)*/
doXqueryTest(XML_SNIPPET, "string-join((for $y in (for $x in //fruit let $d := string-join(($x/color/text() , $x/name/text()), ' ') return $d) return $y), ', ')",
- Arrays.
- asList("red apple, green apple, yellow banana, orange orange, blue blueberry, red raspberry, none"));
+ Arrays.asList("red apple, green apple, yellow banana, orange orange, blue blueberry, red raspberry, none"));
/* Query for attribute */
- doXqueryTest(XML_SNIPPET, "string(//fruit[1]/@taste)", Arrays.
- asList("crisp"));
+ doXqueryTest(XML_SNIPPET, "string(//fruit[1]/@taste)", Arrays.asList("crisp"));
/* Query for comment */
- doXqueryTest(XML_SNIPPET, "//fruit/comment()", Arrays.
- asList(" Apples are my favorite "));
+ doXqueryTest(XML_SNIPPET, "//fruit/comment()", Arrays.asList(" Apples are my favorite "));
/* Query for processing instruction */
- doXqueryTest(XML_SNIPPET, "//processing-instruction()[name()='xml-stylesheet']", Arrays.
- asList("type=\"text/xsl\" href=\"foo.xsl\""));
+ doXqueryTest(XML_SNIPPET, "//processing-instruction()[name()='xml-stylesheet']", Arrays.asList("type=\"text/xsl\" href=\"foo.xsl\""));
}
@@ -332,8 +310,7 @@ public class TestEvaluateXQuery {
// test read from content, write to attribute
{
runnerProps.clear();
- runnerProps.
- put(EvaluateXQuery.DESTINATION.getName(), EvaluateXQuery.DESTINATION_ATTRIBUTE);
+ runnerProps.put(EvaluateXQuery.DESTINATION.getName(), EvaluateXQuery.DESTINATION_ATTRIBUTE);
runnerProps.put("xquery", xQuery);
resultFlowFiles = runXquery(xml, runnerProps);
@@ -346,10 +323,8 @@ public class TestEvaluateXQuery {
if (expectedResults.size() > 1) {
key += "." + ((int) i + 1);
}
- final String actual = out.getAttribute(key).
- replaceAll(">\\s+<", "><");
- final String expected = expectedResults.get(i).
- replaceAll(">\\s+<", "><");
+ final String actual = out.getAttribute(key).replaceAll(">\\s+<", "><");
+ final String expected = expectedResults.get(i).replaceAll(">\\s+<", "><");
assertEquals(expected, actual);
}
}
@@ -357,8 +332,7 @@ public class TestEvaluateXQuery {
// test read from content, write to content
{
runnerProps.clear();
- runnerProps.
- put(EvaluateXQuery.DESTINATION.getName(), EvaluateXQuery.DESTINATION_CONTENT);
+ runnerProps.put(EvaluateXQuery.DESTINATION.getName(), EvaluateXQuery.DESTINATION_CONTENT);
runnerProps.put("xquery", xQuery);
resultFlowFiles = runXquery(xml, runnerProps);
@@ -368,11 +342,9 @@ public class TestEvaluateXQuery {
final MockFlowFile out = resultFlowFiles.get(i);
final byte[] outData = out.toByteArray();
- final String outXml = new String(outData, "UTF-8").
- replaceAll(">\\s+<", "><");
+ final String outXml = new String(outData, "UTF-8").replaceAll(">\\s+<", "><");
final String actual = outXml;
- final String expected = expectedResults.get(i).
- replaceAll(">\\s+<", "><");
+ final String expected = expectedResults.get(i).replaceAll(">\\s+<", "><");
assertEquals(expected, actual);
}
}
@@ -384,8 +356,7 @@ public class TestEvaluateXQuery {
private List<MockFlowFile> runXquery(Path xml, Map<String, String> runnerProps, Map<String, String> flowFileAttributes) throws Exception {
- final TestRunner testRunner = TestRunners.
- newTestRunner(new EvaluateXQuery());
+ final TestRunner testRunner = TestRunners.newTestRunner(new EvaluateXQuery());
for (Entry<String, String> entry : runnerProps.entrySet()) {
testRunner.setProperty(entry.getKey(), entry.getValue());
@@ -401,109 +372,81 @@ public class TestEvaluateXQuery {
@Test
public void testRootPath() throws XPathFactoryConfigurationException, IOException {
- final TestRunner testRunner = TestRunners.
- newTestRunner(new EvaluateXQuery());
- testRunner.
- setProperty(EvaluateXQuery.DESTINATION, EvaluateXQuery.DESTINATION_ATTRIBUTE);
+ final TestRunner testRunner = TestRunners.newTestRunner(new EvaluateXQuery());
+ testRunner.setProperty(EvaluateXQuery.DESTINATION, EvaluateXQuery.DESTINATION_ATTRIBUTE);
testRunner.setProperty("xquery.result1", "/");
testRunner.enqueue(XML_SNIPPET);
testRunner.run();
testRunner.assertAllFlowFilesTransferred(EvaluateXQuery.REL_MATCH, 1);
- final MockFlowFile out = testRunner.
- getFlowFilesForRelationship(EvaluateXQuery.REL_MATCH).
- get(0);
- final String attributeString = out.getAttribute("xquery.result1").
- replaceAll(">\\s+<", "><");
- final String xmlSnippetString = new String(Files.
- readAllBytes(XML_SNIPPET), "UTF-8").replaceAll(">\\s+<", "><");
+ final MockFlowFile out = testRunner.getFlowFilesForRelationship(EvaluateXQuery.REL_MATCH).get(0);
+ final String attributeString = out.getAttribute("xquery.result1").replaceAll(">\\s+<", "><");
+ final String xmlSnippetString = new String(Files.readAllBytes(XML_SNIPPET), "UTF-8").replaceAll(">\\s+<", "><");
assertEquals(xmlSnippetString, attributeString);
}
@Test
public void testCheckIfElementExists() throws XPathFactoryConfigurationException, IOException {
- final TestRunner testRunner = TestRunners.
- newTestRunner(new EvaluateXQuery());
- testRunner.
- setProperty(EvaluateXQuery.DESTINATION, EvaluateXQuery.DESTINATION_ATTRIBUTE);
- testRunner.
- setProperty("xquery.result.exist.1", "boolean(/*:fruitbasket/fruit[1])");
- testRunner.
- setProperty("xquery.result.exist.2", "boolean(/*:fruitbasket/fruit[100])");
+ final TestRunner testRunner = TestRunners.newTestRunner(new EvaluateXQuery());
+ testRunner.setProperty(EvaluateXQuery.DESTINATION, EvaluateXQuery.DESTINATION_ATTRIBUTE);
+ testRunner.setProperty("xquery.result.exist.1", "boolean(/*:fruitbasket/fruit[1])");
+ testRunner.setProperty("xquery.result.exist.2", "boolean(/*:fruitbasket/fruit[100])");
testRunner.enqueue(XML_SNIPPET);
testRunner.run();
testRunner.assertAllFlowFilesTransferred(EvaluateXQuery.REL_MATCH, 1);
- final MockFlowFile out = testRunner.
- getFlowFilesForRelationship(EvaluateXQuery.REL_MATCH).
- get(0);
+ final MockFlowFile out = testRunner.getFlowFilesForRelationship(EvaluateXQuery.REL_MATCH).get(0);
out.assertAttributeEquals("xquery.result.exist.1", "true");
out.assertAttributeEquals("xquery.result.exist.2", "false");
}
@Test
public void testUnmatchedContent() throws XPathFactoryConfigurationException, IOException {
- final TestRunner testRunner = TestRunners.
- newTestRunner(new EvaluateXQuery());
- testRunner.
- setProperty(EvaluateXQuery.DESTINATION, EvaluateXQuery.DESTINATION_CONTENT);
+ final TestRunner testRunner = TestRunners.newTestRunner(new EvaluateXQuery());
+ testRunner.setProperty(EvaluateXQuery.DESTINATION, EvaluateXQuery.DESTINATION_CONTENT);
testRunner.setProperty("xquery.result.exist.2", "/*:fruitbasket/node2");
testRunner.enqueue(XML_SNIPPET);
testRunner.run();
testRunner.assertAllFlowFilesTransferred(EvaluateXQuery.REL_NO_MATCH, 1);
- testRunner.getFlowFilesForRelationship(EvaluateXQuery.REL_NO_MATCH).
- get(0).
- assertContentEquals(XML_SNIPPET);
+ testRunner.getFlowFilesForRelationship(EvaluateXQuery.REL_NO_MATCH).get(0).assertContentEquals(XML_SNIPPET);
}
@Test
public void testUnmatchedAttribute() throws XPathFactoryConfigurationException, IOException {
- final TestRunner testRunner = TestRunners.
- newTestRunner(new EvaluateXQuery());
- testRunner.
- setProperty(EvaluateXQuery.DESTINATION, EvaluateXQuery.DESTINATION_ATTRIBUTE);
+ final TestRunner testRunner = TestRunners.newTestRunner(new EvaluateXQuery());
+ testRunner.setProperty(EvaluateXQuery.DESTINATION, EvaluateXQuery.DESTINATION_ATTRIBUTE);
testRunner.setProperty("xquery.result.exist.2", "/*:fruitbasket/node2");
testRunner.enqueue(XML_SNIPPET);
testRunner.run();
testRunner.assertAllFlowFilesTransferred(EvaluateXQuery.REL_NO_MATCH, 1);
- final MockFlowFile out = testRunner.
- getFlowFilesForRelationship(EvaluateXQuery.REL_NO_MATCH).
- get(0);
+ final MockFlowFile out = testRunner.getFlowFilesForRelationship(EvaluateXQuery.REL_NO_MATCH).get(0);
out.assertAttributeEquals("xquery.result.exist.2", null);
- testRunner.getFlowFilesForRelationship(EvaluateXQuery.REL_NO_MATCH).
- get(0).
- assertContentEquals(XML_SNIPPET);
+ testRunner.getFlowFilesForRelationship(EvaluateXQuery.REL_NO_MATCH).get(0).assertContentEquals(XML_SNIPPET);
}
@Test
public void testNoXQueryAttribute() throws XPathFactoryConfigurationException, IOException {
- final TestRunner testRunner = TestRunners.
- newTestRunner(new EvaluateXQuery());
- testRunner.
- setProperty(EvaluateXQuery.DESTINATION, EvaluateXQuery.DESTINATION_ATTRIBUTE);
+ final TestRunner testRunner = TestRunners.newTestRunner(new EvaluateXQuery());
+ testRunner.setProperty(EvaluateXQuery.DESTINATION, EvaluateXQuery.DESTINATION_ATTRIBUTE);
testRunner.enqueue(XML_SNIPPET);
testRunner.run();
testRunner.assertAllFlowFilesTransferred(EvaluateXQuery.REL_NO_MATCH, 1);
- testRunner.getFlowFilesForRelationship(EvaluateXQuery.REL_NO_MATCH).
- get(0).
- assertContentEquals(XML_SNIPPET);
+ testRunner.getFlowFilesForRelationship(EvaluateXQuery.REL_NO_MATCH).get(0).assertContentEquals(XML_SNIPPET);
}
@Test(expected = java.lang.AssertionError.class)
public void testNoXQueryContent() throws XPathFactoryConfigurationException, IOException {
- final TestRunner testRunner = TestRunners.
- newTestRunner(new EvaluateXQuery());
- testRunner.
- setProperty(EvaluateXQuery.DESTINATION, EvaluateXQuery.DESTINATION_CONTENT);
+ final TestRunner testRunner = TestRunners.newTestRunner(new EvaluateXQuery());
+ testRunner.setProperty(EvaluateXQuery.DESTINATION, EvaluateXQuery.DESTINATION_CONTENT);
testRunner.enqueue(XML_SNIPPET);
testRunner.run();
@@ -511,10 +454,8 @@ public class TestEvaluateXQuery {
@Test
public void testOneMatchOneUnmatchAttribute() throws XPathFactoryConfigurationException, IOException {
- final TestRunner testRunner = TestRunners.
- newTestRunner(new EvaluateXQuery());
- testRunner.
- setProperty(EvaluateXQuery.DESTINATION, EvaluateXQuery.DESTINATION_ATTRIBUTE);
+ final TestRunner testRunner = TestRunners.newTestRunner(new EvaluateXQuery());
+ testRunner.setProperty(EvaluateXQuery.DESTINATION, EvaluateXQuery.DESTINATION_ATTRIBUTE);
testRunner.setProperty("some.property", "//fruit/name/text()");
testRunner.setProperty("xquery.result.exist.2", "/*:fruitbasket/node2");
@@ -523,51 +464,37 @@ public class TestEvaluateXQuery {
testRunner.assertAllFlowFilesTransferred(EvaluateXQuery.REL_MATCH, 1);
- final MockFlowFile out = testRunner.
- getFlowFilesForRelationship(EvaluateXQuery.REL_MATCH).
- get(0);
+ final MockFlowFile out = testRunner.getFlowFilesForRelationship(EvaluateXQuery.REL_MATCH).get(0);
for (int i = 0; i < fruitNames.length; i++) {
- final String outXml = out.
- getAttribute("some.property." + ((int) i + 1));
+ final String outXml = out.getAttribute("some.property." + ((int) i + 1));
assertEquals(fruitNames[i], outXml.trim());
}
out.assertAttributeEquals("xquery.result.exist.2", null);
- testRunner.getFlowFilesForRelationship(EvaluateXQuery.REL_MATCH).
- get(0).
- assertContentEquals(XML_SNIPPET);
+ testRunner.getFlowFilesForRelationship(EvaluateXQuery.REL_MATCH).get(0).assertContentEquals(XML_SNIPPET);
}
@Test
public void testMatchedEmptyStringAttribute() throws XPathFactoryConfigurationException, IOException {
- final TestRunner testRunner = TestRunners.
- newTestRunner(new EvaluateXQuery());
- testRunner.
- setProperty(EvaluateXQuery.DESTINATION, EvaluateXQuery.DESTINATION_ATTRIBUTE);
- testRunner.
- setProperty("xquery.result.exist.2", "/*:fruitbasket/*[name='none']/color/text()");
+ final TestRunner testRunner = TestRunners.newTestRunner(new EvaluateXQuery());
+ testRunner.setProperty(EvaluateXQuery.DESTINATION, EvaluateXQuery.DESTINATION_ATTRIBUTE);
+ testRunner.setProperty("xquery.result.exist.2", "/*:fruitbasket/*[name='none']/color/text()");
testRunner.enqueue(XML_SNIPPET);
testRunner.run();
testRunner.assertAllFlowFilesTransferred(EvaluateXQuery.REL_NO_MATCH, 1);
- final MockFlowFile out = testRunner.
- getFlowFilesForRelationship(EvaluateXQuery.REL_NO_MATCH).
- get(0);
+ final MockFlowFile out = testRunner.getFlowFilesForRelationship(EvaluateXQuery.REL_NO_MATCH).get(0);
out.assertAttributeEquals("xquery.result.exist.2", null);
- testRunner.getFlowFilesForRelationship(EvaluateXQuery.REL_NO_MATCH).
- get(0).
- assertContentEquals(XML_SNIPPET);
+ testRunner.getFlowFilesForRelationship(EvaluateXQuery.REL_NO_MATCH).get(0).assertContentEquals(XML_SNIPPET);
}
@Test(expected = java.lang.AssertionError.class)
public void testMultipleXPathForContent() throws IOException {
- final TestRunner testRunner = TestRunners.
- newTestRunner(new EvaluateXQuery());
- testRunner.
- setProperty(EvaluateXQuery.DESTINATION, EvaluateXQuery.DESTINATION_CONTENT);
+ final TestRunner testRunner = TestRunners.newTestRunner(new EvaluateXQuery());
+ testRunner.setProperty(EvaluateXQuery.DESTINATION, EvaluateXQuery.DESTINATION_CONTENT);
testRunner.setProperty("some.property.1", "/*:fruitbasket/fruit[1]");
testRunner.setProperty("some.property.2", "/*:fruitbasket/fruit[2]");
@@ -577,98 +504,71 @@ public class TestEvaluateXQuery {
@Test
public void testWriteStringToAttribute() throws XPathFactoryConfigurationException, IOException {
- final TestRunner testRunner = TestRunners.
- newTestRunner(new EvaluateXQuery());
- testRunner.
- setProperty(EvaluateXQuery.DESTINATION, EvaluateXQuery.DESTINATION_ATTRIBUTE);
- testRunner.
- setProperty("xquery.result2", "/*:fruitbasket/fruit[1]/name/text()");
+ final TestRunner testRunner = TestRunners.newTestRunner(new EvaluateXQuery());
+ testRunner.setProperty(EvaluateXQuery.DESTINATION, EvaluateXQuery.DESTINATION_ATTRIBUTE);
+ testRunner.setProperty("xquery.result2", "/*:fruitbasket/fruit[1]/name/text()");
testRunner.enqueue(XML_SNIPPET);
testRunner.run();
testRunner.assertAllFlowFilesTransferred(EvaluateXQuery.REL_MATCH, 1);
- final MockFlowFile out = testRunner.
- getFlowFilesForRelationship(EvaluateXQuery.REL_MATCH).
- get(0);
+ final MockFlowFile out = testRunner.getFlowFilesForRelationship(EvaluateXQuery.REL_MATCH).get(0);
out.assertAttributeEquals("xquery.result2", "apple");
- testRunner.getFlowFilesForRelationship(EvaluateXQuery.REL_MATCH).
- get(0).
- assertContentEquals(XML_SNIPPET);
+ testRunner.getFlowFilesForRelationship(EvaluateXQuery.REL_MATCH).get(0).assertContentEquals(XML_SNIPPET);
}
@Test
public void testWriteStringToContent() throws XPathFactoryConfigurationException, IOException {
- final TestRunner testRunner = TestRunners.
- newTestRunner(new EvaluateXQuery());
- testRunner.
- setProperty(EvaluateXQuery.DESTINATION, EvaluateXQuery.DESTINATION_CONTENT);
- testRunner.
- setProperty("some.property", "/*:fruitbasket/fruit[1]/name/text()");
+ final TestRunner testRunner = TestRunners.newTestRunner(new EvaluateXQuery());
+ testRunner.setProperty(EvaluateXQuery.DESTINATION, EvaluateXQuery.DESTINATION_CONTENT);
+ testRunner.setProperty("some.property", "/*:fruitbasket/fruit[1]/name/text()");
testRunner.enqueue(XML_SNIPPET);
testRunner.run();
testRunner.assertAllFlowFilesTransferred(EvaluateXQuery.REL_MATCH, 1);
- final MockFlowFile out = testRunner.
- getFlowFilesForRelationship(EvaluateXQuery.REL_MATCH).
- get(0);
+ final MockFlowFile out = testRunner.getFlowFilesForRelationship(EvaluateXQuery.REL_MATCH).get(0);
final byte[] outData = testRunner.getContentAsByteArray(out);
final String outXml = new String(outData, "UTF-8");
- assertTrue(outXml.trim().
- equals("apple"));
+ assertTrue(outXml.trim().equals("apple"));
}
@Test
public void testWriteXmlToAttribute() throws XPathFactoryConfigurationException, IOException {
- final TestRunner testRunner = TestRunners.
- newTestRunner(new EvaluateXQuery());
- testRunner.
- setProperty(EvaluateXQuery.DESTINATION, EvaluateXQuery.DESTINATION_ATTRIBUTE);
+ final TestRunner testRunner = TestRunners.newTestRunner(new EvaluateXQuery());
+ testRunner.setProperty(EvaluateXQuery.DESTINATION, EvaluateXQuery.DESTINATION_ATTRIBUTE);
testRunner.setProperty("some.property", "/*:fruitbasket/fruit[1]/name");
testRunner.enqueue(XML_SNIPPET);
testRunner.run();
testRunner.assertAllFlowFilesTransferred(EvaluateXQuery.REL_MATCH, 1);
- final MockFlowFile out = testRunner.
- getFlowFilesForRelationship(EvaluateXQuery.REL_MATCH).
- get(0);
+ final MockFlowFile out = testRunner.getFlowFilesForRelationship(EvaluateXQuery.REL_MATCH).get(0);
final String outXml = out.getAttribute("some.property");
- assertTrue(outXml.
- contains("<name xmlns:ns=\"http://namespace/1\">apple</name>"));
- testRunner.getFlowFilesForRelationship(EvaluateXQuery.REL_MATCH).
- get(0).
- assertContentEquals(XML_SNIPPET);
+ assertTrue(outXml.contains("<name xmlns:ns=\"http://namespace/1\">apple</name>"));
+ testRunner.getFlowFilesForRelationship(EvaluateXQuery.REL_MATCH).get(0).assertContentEquals(XML_SNIPPET);
}
@Test
public void testWriteXmlToContent() throws XPathFactoryConfigurationException, IOException {
- final TestRunner testRunner = TestRunners.
- newTestRunner(new EvaluateXQuery());
- testRunner.
- setProperty(EvaluateXQuery.DESTINATION, EvaluateXQuery.DESTINATION_CONTENT);
+ final TestRunner testRunner = TestRunners.newTestRunner(new EvaluateXQuery());
+ testRunner.setProperty(EvaluateXQuery.DESTINATION, EvaluateXQuery.DESTINATION_CONTENT);
testRunner.setProperty("some.property", "/*:fruitbasket/fruit[1]/name");
testRunner.enqueue(XML_SNIPPET);
testRunner.run();
testRunner.assertAllFlowFilesTransferred(EvaluateXQuery.REL_MATCH, 1);
- final MockFlowFile out = testRunner.
- getFlowFilesForRelationship(EvaluateXQuery.REL_MATCH).
- get(0);
+ final MockFlowFile out = testRunner.getFlowFilesForRelationship(EvaluateXQuery.REL_MATCH).get(0);
final byte[] outData = testRunner.getContentAsByteArray(out);
final String outXml = new String(outData, "UTF-8");
- assertTrue(outXml.
- contains("<name xmlns:ns=\"http://namespace/1\">apple</name>"));
+ assertTrue(outXml.contains("<name xmlns:ns=\"http://namespace/1\">apple</name>"));
}
@Test
public void testMatchesMultipleStringContent() throws XPathFactoryConfigurationException, IOException {
- final TestRunner testRunner = TestRunners.
- newTestRunner(new EvaluateXQuery());
- testRunner.
- setProperty(EvaluateXQuery.DESTINATION, EvaluateXQuery.DESTINATION_CONTENT);
+ final TestRunner testRunner = TestRunners.newTestRunner(new EvaluateXQuery());
+ testRunner.setProperty(EvaluateXQuery.DESTINATION, EvaluateXQuery.DESTINATION_CONTENT);
testRunner.setProperty("some.property", "//fruit/name/text()");
testRunner.enqueue(XML_SNIPPET);
@@ -676,8 +576,7 @@ public class TestEvaluateXQuery {
testRunner.assertAllFlowFilesTransferred(EvaluateXQuery.REL_MATCH, 7);
- final List<MockFlowFile> flowFilesForRelMatch = testRunner.
- getFlowFilesForRelationship(EvaluateXQuery.REL_MATCH);
+ final List<MockFlowFile> flowFilesForRelMatch = testRunner.getFlowFilesForRelationship(EvaluateXQuery.REL_MATCH);
for (int i = 0; i < flowFilesForRelMatch.size(); i++) {
final MockFlowFile out = flowFilesForRelMatch.get(i);
@@ -689,10 +588,8 @@ public class TestEvaluateXQuery {
@Test
public void testMatchesMultipleStringAttribute() throws XPathFactoryConfigurationException, IOException {
- final TestRunner testRunner = TestRunners.
- newTestRunner(new EvaluateXQuery());
- testRunner.
- setProperty(EvaluateXQuery.DESTINATION, EvaluateXQuery.DESTINATION_ATTRIBUTE);
+ final TestRunner testRunner = TestRunners.newTestRunner(new EvaluateXQuery());
+ testRunner.setProperty(EvaluateXQuery.DESTINATION, EvaluateXQuery.DESTINATION_ATTRIBUTE);
testRunner.setProperty("some.property", "//fruit/name/text()");
testRunner.enqueue(XML_SNIPPET);
@@ -700,26 +597,19 @@ public class TestEvaluateXQuery {
testRunner.assertAllFlowFilesTransferred(EvaluateXQuery.REL_MATCH, 1);
- final MockFlowFile out = testRunner.
- getFlowFilesForRelationship(EvaluateXQuery.REL_MATCH).
- get(0);
+ final MockFlowFile out = testRunner.getFlowFilesForRelationship(EvaluateXQuery.REL_MATCH).get(0);
for (int i = 0; i < fruitNames.length; i++) {
- final String outXml = out.
- getAttribute("some.property." + ((int) i + 1));
+ final String outXml = out.getAttribute("some.property." + ((int) i + 1));
assertEquals(fruitNames[i], outXml.trim());
}
- testRunner.getFlowFilesForRelationship(EvaluateXQuery.REL_MATCH).
- get(0).
- assertContentEquals(XML_SNIPPET);
+ testRunner.getFlowFilesForRelationship(EvaluateXQuery.REL_MATCH).get(0).assertContentEquals(XML_SNIPPET);
}
@Test
public void testMatchesMultipleXmlContent() throws XPathFactoryConfigurationException, IOException {
- final TestRunner testRunner = TestRunners.
- newTestRunner(new EvaluateXQuery());
- testRunner.
- setProperty(EvaluateXQuery.DESTINATION, EvaluateXQuery.DESTINATION_CONTENT);
+ final TestRunner testRunner = TestRunners.newTestRunner(new EvaluateXQuery());
+ testRunner.setProperty(EvaluateXQuery.DESTINATION, EvaluateXQuery.DESTINATION_CONTENT);
testRunner.setProperty("some.property", "//fruit/name");
testRunner.enqueue(XML_SNIPPET);
@@ -727,8 +617,7 @@ public class TestEvaluateXQuery {
testRunner.assertAllFlowFilesTransferred(EvaluateXQuery.REL_MATCH, 7);
- final List<MockFlowFile> flowFilesForRelMatch = testRunner.
- getFlowFilesForRelationship(EvaluateXQuery.REL_MATCH);
+ final List<MockFlowFile> flowFilesForRelMatch = testRunner.getFlowFilesForRelationship(EvaluateXQuery.REL_MATCH);
for (int i = 0; i < flowFilesForRelMatch.size(); i++) {
final MockFlowFile out = flowFilesForRelMatch.get(i);
@@ -741,10 +630,8 @@ public class TestEvaluateXQuery {
@Test
public void testMatchesMultipleXmlAttribute() throws XPathFactoryConfigurationException, IOException {
- final TestRunner testRunner = TestRunners.
- newTestRunner(new EvaluateXQuery());
- testRunner.
- setProperty(EvaluateXQuery.DESTINATION, EvaluateXQuery.DESTINATION_ATTRIBUTE);
+ final TestRunner testRunner = TestRunners.newTestRunner(new EvaluateXQuery());
+ testRunner.setProperty(EvaluateXQuery.DESTINATION, EvaluateXQuery.DESTINATION_ATTRIBUTE);
testRunner.setProperty("some.property", "//fruit/name");
testRunner.enqueue(XML_SNIPPET);
@@ -752,18 +639,13 @@ public class TestEvaluateXQuery {
testRunner.assertAllFlowFilesTransferred(EvaluateXQuery.REL_MATCH, 1);
- final MockFlowFile out = testRunner.
- getFlowFilesForRelationship(EvaluateXQuery.REL_MATCH).
- get(0);
+ final MockFlowFile out = testRunner.getFlowFilesForRelationship(EvaluateXQuery.REL_MATCH).get(0);
for (int i = 0; i < fruitNames.length; i++) {
- final String outXml = out.
- getAttribute("some.property." + ((int) i + 1));
+ final String outXml = out.getAttribute("some.property." + ((int) i + 1));
String expectedXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><name xmlns:ns=\"http://namespace/1\">" + fruitNames[i] + "</name>";
assertEquals(expectedXml, outXml.trim());
}
- testRunner.getFlowFilesForRelationship(EvaluateXQuery.REL_MATCH).
- get(0).
- assertContentEquals(XML_SNIPPET);
+ testRunner.getFlowFilesForRelationship(EvaluateXQuery.REL_MATCH).get(0).assertContentEquals(XML_SNIPPET);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d29a2d68/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestExecuteProcess.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestExecuteProcess.java b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestExecuteProcess.java
index 0907f38..7529e6d 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestExecuteProcess.java
+++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestExecuteProcess.java
@@ -43,19 +43,16 @@ public class TestExecuteProcess {
assertEquals(1, singleArg.size());
assertEquals("hello", singleArg.get(0));
- final List<String> twoArg = ExecuteProcess.
- splitArgs(" hello good-bye ");
+ final List<String> twoArg = ExecuteProcess.splitArgs(" hello good-bye ");
assertEquals(2, twoArg.size());
assertEquals("hello", twoArg.get(0));
assertEquals("good-bye", twoArg.get(1));
- final List<String> singleQuotedArg = ExecuteProcess.
- splitArgs(" \"hello\" ");
+ final List<String> singleQuotedArg = ExecuteProcess.splitArgs(" \"hello\" ");
assertEquals(1, singleQuotedArg.size());
assertEquals("hello", singleQuotedArg.get(0));
- final List<String> twoQuotedArg = ExecuteProcess.
- splitArgs(" hello \"good bye\"");
+ final List<String> twoQuotedArg = ExecuteProcess.splitArgs(" hello \"good bye\"");
assertEquals(2, twoQuotedArg.size());
assertEquals("hello", twoQuotedArg.get(0));
assertEquals("good bye", twoQuotedArg.get(1));
@@ -63,19 +60,16 @@ public class TestExecuteProcess {
@Test
public void testEcho() {
- System.
- setProperty("org.slf4j.simpleLogger.log.org.apache.nifi", "TRACE");
+ System.setProperty("org.slf4j.simpleLogger.log.org.apache.nifi", "TRACE");
- final TestRunner runner = TestRunners.
- newTestRunner(ExecuteProcess.class);
+ final TestRunner runner = TestRunners.newTestRunner(ExecuteProcess.class);
runner.setProperty(ExecuteProcess.COMMAND, "echo");
runner.setProperty(ExecuteProcess.COMMAND_ARGUMENTS, "test-args");
runner.setProperty(ExecuteProcess.BATCH_DURATION, "500 millis");
runner.run();
- final List<MockFlowFile> flowFiles = runner.
- getFlowFilesForRelationship(ExecuteProcess.REL_SUCCESS);
+ final List<MockFlowFile> flowFiles = runner.getFlowFilesForRelationship(ExecuteProcess.REL_SUCCESS);
for (final MockFlowFile flowFile : flowFiles) {
System.out.println(flowFile);
System.out.println(new String(flowFile.toByteArray()));
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d29a2d68/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestExecuteStreamCommand.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestExecuteStreamCommand.java b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestExecuteStreamCommand.java
index f95d644..4e4a6b0 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestExecuteStreamCommand.java
+++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestExecuteStreamCommand.java
@@ -16,7 +16,6 @@
*/
package org.apache.nifi.processors.standard;
-import org.apache.nifi.processors.standard.ExecuteStreamCommand;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -48,10 +47,8 @@ public class TestExecuteStreamCommand {
public static void init() {
System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "info");
System.setProperty("org.slf4j.simpleLogger.showDateTime", "true");
- System.
- setProperty("org.slf4j.simpleLogger.log.nifi.processors.standard.ExecuteStreamCommand", "debug");
- System.
- setProperty("org.slf4j.simpleLogger.log.nifi.processors.standard.TestExecuteStreamCommand", "debug");
+ System.setProperty("org.slf4j.simpleLogger.log.nifi.processors.standard.ExecuteStreamCommand", "debug");
+ System.setProperty("org.slf4j.simpleLogger.log.nifi.processors.standard.TestExecuteStreamCommand", "debug");
LOGGER = LoggerFactory.getLogger(TestExecuteStreamCommand.class);
}
@@ -61,46 +58,31 @@ public class TestExecuteStreamCommand {
File dummy = new File("src/test/resources/ExecuteCommand/1000bytes.txt");
String jarPath = exJar.getAbsolutePath();
exJar.setExecutable(true);
- final TestRunner controller = TestRunners.
- newTestRunner(ExecuteStreamCommand.class);
+ final TestRunner controller = TestRunners.newTestRunner(ExecuteStreamCommand.class);
controller.setValidateExpressionUsage(false);
controller.enqueue(dummy.toPath());
controller.setProperty(ExecuteStreamCommand.EXECUTION_COMMAND, "java");
- controller.
- setProperty(ExecuteStreamCommand.EXECUTION_ARGUMENTS, "-jar;" + jarPath);
+ controller.setProperty(ExecuteStreamCommand.EXECUTION_ARGUMENTS, "-jar;" + jarPath);
controller.run(1);
- controller.
- assertTransferCount(ExecuteStreamCommand.ORIGINAL_RELATIONSHIP, 1);
- controller.
- assertTransferCount(ExecuteStreamCommand.OUTPUT_STREAM_RELATIONSHIP, 1);
+ controller.assertTransferCount(ExecuteStreamCommand.ORIGINAL_RELATIONSHIP, 1);
+ controller.assertTransferCount(ExecuteStreamCommand.OUTPUT_STREAM_RELATIONSHIP, 1);
- List<MockFlowFile> flowFiles = controller.
- getFlowFilesForRelationship(ExecuteStreamCommand.OUTPUT_STREAM_RELATIONSHIP);
+ List<MockFlowFile> flowFiles = controller.getFlowFilesForRelationship(ExecuteStreamCommand.OUTPUT_STREAM_RELATIONSHIP);
MockFlowFile outputFlowFile = flowFiles.get(0);
byte[] byteArray = outputFlowFile.toByteArray();
String result = new String(byteArray);
- assertTrue("Test was a success\r\n".equals(result) || "Test was a success\n".
- equals(result));
+ assertTrue("Test was a success\r\n".equals(result) || "Test was a success\n".equals(result));
assertEquals("0", outputFlowFile.getAttribute("execution.status"));
assertEquals("java", outputFlowFile.getAttribute("execution.command"));
- assertEquals("-jar;", outputFlowFile.
- getAttribute("execution.command.args").
- substring(0, 5));
+ assertEquals("-jar;", outputFlowFile.getAttribute("execution.command.args").substring(0, 5));
String attribute = outputFlowFile.getAttribute("execution.command.args");
- String expected = "src" + File.separator + "test" + File.separator + "resources" + File.separator + "ExecuteCommand" + File.separator
- + "TestSuccess.jar";
- assertEquals(expected, attribute.
- substring(attribute.length() - expected.length()));
-
- MockFlowFile originalFlowFile = controller.
- getFlowFilesForRelationship(ExecuteStreamCommand.ORIGINAL_RELATIONSHIP).
- get(0);
- assertEquals(outputFlowFile.getAttribute("execution.status"), originalFlowFile.
- getAttribute("execution.status"));
- assertEquals(outputFlowFile.getAttribute("execution.command"), originalFlowFile.
- getAttribute("execution.command"));
- assertEquals(outputFlowFile.getAttribute("execution.command.args"), originalFlowFile.
- getAttribute("execution.command.args"));
+ String expected = "src" + File.separator + "test" + File.separator + "resources" + File.separator + "ExecuteCommand" + File.separator + "TestSuccess.jar";
+ assertEquals(expected, attribute.substring(attribute.length() - expected.length()));
+
+ MockFlowFile originalFlowFile = controller.getFlowFilesForRelationship(ExecuteStreamCommand.ORIGINAL_RELATIONSHIP).get(0);
+ assertEquals(outputFlowFile.getAttribute("execution.status"), originalFlowFile.getAttribute("execution.status"));
+ assertEquals(outputFlowFile.getAttribute("execution.command"), originalFlowFile.getAttribute("execution.command"));
+ assertEquals(outputFlowFile.getAttribute("execution.command.args"), originalFlowFile.getAttribute("execution.command.args"));
}
@Test
@@ -109,25 +91,17 @@ public class TestExecuteStreamCommand {
File dummy = new File("src/test/resources/ExecuteCommand/1000bytes.txt");
String jarPath = exJar.getAbsolutePath();
exJar.setExecutable(true);
- final TestRunner controller = TestRunners.
- newTestRunner(ExecuteStreamCommand.class);
+ final TestRunner controller = TestRunners.newTestRunner(ExecuteStreamCommand.class);
controller.setValidateExpressionUsage(false);
controller.enqueue(dummy.toPath());
controller.setProperty(ExecuteStreamCommand.EXECUTION_COMMAND, "java");
- controller.
- setProperty(ExecuteStreamCommand.EXECUTION_ARGUMENTS, "-jar;" + jarPath);
+ controller.setProperty(ExecuteStreamCommand.EXECUTION_ARGUMENTS, "-jar;" + jarPath);
controller.run(1);
- controller.
- assertTransferCount(ExecuteStreamCommand.ORIGINAL_RELATIONSHIP, 1);
- controller.
- assertTransferCount(ExecuteStreamCommand.OUTPUT_STREAM_RELATIONSHIP, 1);
- List<MockFlowFile> flowFiles = controller.
- getFlowFilesForRelationship(ExecuteStreamCommand.OUTPUT_STREAM_RELATIONSHIP);
- assertEquals(0, flowFiles.get(0).
- getSize());
- assertEquals("Error: Unable to access jarfile", flowFiles.get(0).
- getAttribute("execution.error").
- substring(0, 31));
+ controller.assertTransferCount(ExecuteStreamCommand.ORIGINAL_RELATIONSHIP, 1);
+ controller.assertTransferCount(ExecuteStreamCommand.OUTPUT_STREAM_RELATIONSHIP, 1);
+ List<MockFlowFile> flowFiles = controller.getFlowFilesForRelationship(ExecuteStreamCommand.OUTPUT_STREAM_RELATIONSHIP);
+ assertEquals(0, flowFiles.get(0).getSize());
+ assertEquals("Error: Unable to access jarfile", flowFiles.get(0).getAttribute("execution.error").substring(0, 31));
}
@Test
@@ -146,28 +120,20 @@ public class TestExecuteStreamCommand {
fos.close();
String jarPath = exJar.getAbsolutePath();
exJar.setExecutable(true);
- final TestRunner controller = TestRunners.
- newTestRunner(ExecuteStreamCommand.class);
+ final TestRunner controller = TestRunners.newTestRunner(ExecuteStreamCommand.class);
controller.setValidateExpressionUsage(false);
controller.enqueue(dummy100MBytes.toPath());
controller.setProperty(ExecuteStreamCommand.EXECUTION_COMMAND, "java");
- controller.
- setProperty(ExecuteStreamCommand.EXECUTION_ARGUMENTS, "-jar;" + jarPath);
+ controller.setProperty(ExecuteStreamCommand.EXECUTION_ARGUMENTS, "-jar;" + jarPath);
controller.run(1);
- controller.
- assertTransferCount(ExecuteStreamCommand.ORIGINAL_RELATIONSHIP, 1);
- controller.
- assertTransferCount(ExecuteStreamCommand.OUTPUT_STREAM_RELATIONSHIP, 1);
- List<MockFlowFile> flowFiles = controller.
- getFlowFilesForRelationship(ExecuteStreamCommand.OUTPUT_STREAM_RELATIONSHIP);
- byte[] byteArray = flowFiles.get(0).
- toByteArray();
+ controller.assertTransferCount(ExecuteStreamCommand.ORIGINAL_RELATIONSHIP, 1);
+ controller.assertTransferCount(ExecuteStreamCommand.OUTPUT_STREAM_RELATIONSHIP, 1);
+ List<MockFlowFile> flowFiles = controller.getFlowFilesForRelationship(ExecuteStreamCommand.OUTPUT_STREAM_RELATIONSHIP);
+ byte[] byteArray = flowFiles.get(0).toByteArray();
String result = new String(byteArray);
- assertTrue(result.
- contains(File.separator + "nifi-standard-processors:ModifiedResult\r\n")
- || result.
- contains(File.separator + "nifi-standard-processors:ModifiedResult\n"));
+ assertTrue(result.contains(File.separator + "nifi-standard-processors:ModifiedResult\r\n")
+ || result.contains(File.separator + "nifi-standard-processors:ModifiedResult\n"));
}
@Test
@@ -176,28 +142,20 @@ public class TestExecuteStreamCommand {
File dummy = new File("src/test/resources/ExecuteCommand/1000bytes.txt");
String jarPath = exJar.getAbsolutePath();
exJar.setExecutable(true);
- final TestRunner controller = TestRunners.
- newTestRunner(ExecuteStreamCommand.class);
+ final TestRunner controller = TestRunners.newTestRunner(ExecuteStreamCommand.class);
controller.setValidateExpressionUsage(false);
controller.enqueue(dummy.toPath());
controller.setProperty(ExecuteStreamCommand.WORKING_DIR, "target");
controller.setProperty(ExecuteStreamCommand.EXECUTION_COMMAND, "java");
- controller.
- setProperty(ExecuteStreamCommand.EXECUTION_ARGUMENTS, "-jar;" + jarPath);
+ controller.setProperty(ExecuteStreamCommand.EXECUTION_ARGUMENTS, "-jar;" + jarPath);
controller.run(1);
- controller.
- assertTransferCount(ExecuteStreamCommand.ORIGINAL_RELATIONSHIP, 1);
- controller.
- assertTransferCount(ExecuteStreamCommand.OUTPUT_STREAM_RELATIONSHIP, 1);
- List<MockFlowFile> flowFiles = controller.
- getFlowFilesForRelationship(ExecuteStreamCommand.OUTPUT_STREAM_RELATIONSHIP);
- byte[] byteArray = flowFiles.get(0).
- toByteArray();
+ controller.assertTransferCount(ExecuteStreamCommand.ORIGINAL_RELATIONSHIP, 1);
+ controller.assertTransferCount(ExecuteStreamCommand.OUTPUT_STREAM_RELATIONSHIP, 1);
+ List<MockFlowFile> flowFiles = controller.getFlowFilesForRelationship(ExecuteStreamCommand.OUTPUT_STREAM_RELATIONSHIP);
+ byte[] byteArray = flowFiles.get(0).toByteArray();
String result = new String(byteArray);
- assertTrue(result.
- contains(File.separator + "nifi-standard-processors" + File.separator + "target:ModifiedResult\r\n")
- || result.
- contains(File.separator + "nifi-standard-processors" + File.separator + "target:ModifiedResult\n"));
+ assertTrue(result.contains(File.separator + "nifi-standard-processors" + File.separator + "target:ModifiedResult\r\n")
+ || result.contains(File.separator + "nifi-standard-processors" + File.separator + "target:ModifiedResult\n"));
}
// this is dependent on window with cygwin...so it's not enabled
@@ -207,8 +165,7 @@ public class TestExecuteStreamCommand {
File testFile = new File("target/test.txt");
testFile.delete();
File dummy = new File("src/test/resources/ExecuteCommand/1000bytes.txt");
- final TestRunner controller = TestRunners.
- newTestRunner(ExecuteStreamCommand.class);
+ final TestRunner controller = TestRunners.newTestRunner(ExecuteStreamCommand.class);
controller.setValidateExpressionUsage(false);
controller.enqueue(dummy.toPath());
controller.enqueue(dummy.toPath());
@@ -217,17 +174,13 @@ public class TestExecuteStreamCommand {
controller.enqueue(dummy.toPath());
controller.setProperty(ExecuteStreamCommand.WORKING_DIR, "target/xx1");
controller.setThreadCount(6);
- controller.
- setProperty(ExecuteStreamCommand.EXECUTION_COMMAND, "c:\\cygwin\\bin\\touch");
- controller.
- setProperty(ExecuteStreamCommand.EXECUTION_ARGUMENTS, "test.txt");
+ controller.setProperty(ExecuteStreamCommand.EXECUTION_COMMAND, "c:\\cygwin\\bin\\touch");
+ controller.setProperty(ExecuteStreamCommand.EXECUTION_ARGUMENTS, "test.txt");
controller.assertValid();
controller.run(6);
- List<MockFlowFile> flowFiles = controller.
- getFlowFilesForRelationship(ExecuteStreamCommand.OUTPUT_STREAM_RELATIONSHIP);
+ List<MockFlowFile> flowFiles = controller.getFlowFilesForRelationship(ExecuteStreamCommand.OUTPUT_STREAM_RELATIONSHIP);
assertEquals(5, flowFiles.size());
- assertEquals(0, flowFiles.get(0).
- getSize());
+ assertEquals(0, flowFiles.get(0).getSize());
}
}
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d29a2d68/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestExtractText.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestExtractText.java b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestExtractText.java
index 045a4f9..fd47cf7 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestExtractText.java
+++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestExtractText.java
@@ -37,14 +37,12 @@ public class TestExtractText {
@Test
public void testProcessor() throws Exception {
- final TestRunner testRunner = TestRunners.
- newTestRunner(new ExtractText());
+ final TestRunner testRunner = TestRunners.newTestRunner(new ExtractText());
testRunner.setProperty("regex.result1", "(?s)(.*)");
testRunner.setProperty("regex.result2", "(?s).*(bar1).*");
testRunner.setProperty("regex.result3", "(?s).*?(bar\\d).*"); // reluctant gets first
- testRunner.
- setProperty("regex.result4", "(?s).*?(?:bar\\d).*?(bar\\d).*?(bar3).*"); // reluctant w/ repeated pattern gets second
+ testRunner.setProperty("regex.result4", "(?s).*?(?:bar\\d).*?(bar\\d).*?(bar3).*"); // reluctant w/ repeated pattern gets second
testRunner.setProperty("regex.result5", "(?s).*(bar\\d).*"); // greedy gets last
testRunner.setProperty("regex.result6", "(?s)^(.*)$");
testRunner.setProperty("regex.result7", "(?s)(XXX)");
@@ -53,9 +51,7 @@ public class TestExtractText {
testRunner.run();
testRunner.assertAllFlowFilesTransferred(ExtractText.REL_MATCH, 1);
- final MockFlowFile out = testRunner.
- getFlowFilesForRelationship(ExtractText.REL_MATCH).
- get(0);
+ final MockFlowFile out = testRunner.getFlowFilesForRelationship(ExtractText.REL_MATCH).get(0);
out.assertAttributeEquals("regex.result1", SAMPLE_STRING);
out.assertAttributeEquals("regex.result2", "bar1");
out.assertAttributeEquals("regex.result3", "bar1");
@@ -72,8 +68,7 @@ public class TestExtractText {
@Test
public void testProcessorWithDotall() throws Exception {
- final TestRunner testRunner = TestRunners.
- newTestRunner(new ExtractText());
+ final TestRunner testRunner = TestRunners.newTestRunner(new ExtractText());
testRunner.setProperty(ExtractText.DOTALL, "true");
@@ -89,9 +84,7 @@ public class TestExtractText {
testRunner.run();
testRunner.assertAllFlowFilesTransferred(ExtractText.REL_MATCH, 1);
- final MockFlowFile out = testRunner.
- getFlowFilesForRelationship(ExtractText.REL_MATCH).
- get(0);
+ final MockFlowFile out = testRunner.getFlowFilesForRelationship(ExtractText.REL_MATCH).get(0);
out.assertAttributeEquals("regex.result1", SAMPLE_STRING);
out.assertAttributeEquals("regex.result2", "bar1");
out.assertAttributeEquals("regex.result3", "bar1");
@@ -105,8 +98,7 @@ public class TestExtractText {
@Test
public void testProcessorWithMultiline() throws Exception {
- final TestRunner testRunner = TestRunners.
- newTestRunner(new ExtractText());
+ final TestRunner testRunner = TestRunners.newTestRunner(new ExtractText());
testRunner.setProperty(ExtractText.MULTILINE, "true");
@@ -124,9 +116,7 @@ public class TestExtractText {
testRunner.run();
testRunner.assertAllFlowFilesTransferred(ExtractText.REL_MATCH, 1);
- final MockFlowFile out = testRunner.
- getFlowFilesForRelationship(ExtractText.REL_MATCH).
- get(0);
+ final MockFlowFile out = testRunner.getFlowFilesForRelationship(ExtractText.REL_MATCH).get(0);
out.assertAttributeEquals("regex.result1", "foo"); // matches everything on the first line
out.assertAttributeEquals("regex.result2", "bar1");
out.assertAttributeEquals("regex.result3", "bar1");
@@ -141,8 +131,7 @@ public class TestExtractText {
@Test
public void testProcessorWithMultilineAndDotall() throws Exception {
- final TestRunner testRunner = TestRunners.
- newTestRunner(new ExtractText());
+ final TestRunner testRunner = TestRunners.newTestRunner(new ExtractText());
testRunner.setProperty(ExtractText.MULTILINE, "true");
testRunner.setProperty(ExtractText.DOTALL, "true");
@@ -161,9 +150,7 @@ public class TestExtractText {
testRunner.run();
testRunner.assertAllFlowFilesTransferred(ExtractText.REL_MATCH, 1);
- final MockFlowFile out = testRunner.
- getFlowFilesForRelationship(ExtractText.REL_MATCH).
- get(0);
+ final MockFlowFile out = testRunner.getFlowFilesForRelationship(ExtractText.REL_MATCH).get(0);
out.assertAttributeEquals("regex.result1", SAMPLE_STRING);
out.assertAttributeEquals("regex.result2", "bar1");
@@ -179,8 +166,7 @@ public class TestExtractText {
@Test
public void testProcessorWithNoMatches() throws Exception {
- final TestRunner testRunner = TestRunners.
- newTestRunner(new ExtractText());
+ final TestRunner testRunner = TestRunners.newTestRunner(new ExtractText());
testRunner.setProperty(ExtractText.MULTILINE, "true");
testRunner.setProperty(ExtractText.DOTALL, "true");
@@ -197,9 +183,7 @@ public class TestExtractText {
testRunner.run();
testRunner.assertAllFlowFilesTransferred(ExtractText.REL_NO_MATCH, 1);
- final MockFlowFile out = testRunner.
- getFlowFilesForRelationship(ExtractText.REL_NO_MATCH).
- get(0);
+ final MockFlowFile out = testRunner.getFlowFilesForRelationship(ExtractText.REL_NO_MATCH).get(0);
out.assertAttributeEquals("regex.result1", null);
out.assertAttributeEquals("regex.result2", null);
@@ -214,8 +198,7 @@ public class TestExtractText {
@Test(expected = java.lang.AssertionError.class)
public void testNoCaptureGroups() throws UnsupportedEncodingException {
- final TestRunner testRunner = TestRunners.
- newTestRunner(new ExtractText());
+ final TestRunner testRunner = TestRunners.newTestRunner(new ExtractText());
testRunner.setProperty("regex.result1", ".*");
testRunner.enqueue(SAMPLE_STRING.getBytes("UTF-8"));
testRunner.run();
@@ -223,8 +206,7 @@ public class TestExtractText {
@Test
public void testNoFlowFile() throws UnsupportedEncodingException {
- final TestRunner testRunner = TestRunners.
- newTestRunner(new ExtractText());
+ final TestRunner testRunner = TestRunners.newTestRunner(new ExtractText());
testRunner.run();
testRunner.assertAllFlowFilesTransferred(ExtractText.REL_MATCH, 0);
@@ -232,8 +214,7 @@ public class TestExtractText {
@Test
public void testMatchOutsideBuffer() throws Exception {
- final TestRunner testRunner = TestRunners.
- newTestRunner(new ExtractText());
+ final TestRunner testRunner = TestRunners.newTestRunner(new ExtractText());
testRunner.setProperty(ExtractText.MAX_BUFFER_SIZE, "3 B");//only read the first 3 chars ("foo")
@@ -244,9 +225,7 @@ public class TestExtractText {
testRunner.run();
testRunner.assertAllFlowFilesTransferred(ExtractText.REL_MATCH, 1);
- final MockFlowFile out = testRunner.
- getFlowFilesForRelationship(ExtractText.REL_MATCH).
- get(0);
+ final MockFlowFile out = testRunner.getFlowFilesForRelationship(ExtractText.REL_MATCH).get(0);
out.assertAttributeEquals("regex.result1", "foo");
out.assertAttributeEquals("regex.result2", null); // null because outsk
@@ -267,63 +246,53 @@ public class TestExtractText {
// UNIX_LINES
testRunner = TestRunners.newTestRunner(processor);
testRunner.setProperty(ExtractText.UNIX_LINES, "true");
- assertEquals(Pattern.UNIX_LINES, processor.getCompileFlags(testRunner.
- getProcessContext()));
+ assertEquals(Pattern.UNIX_LINES, processor.getCompileFlags(testRunner.getProcessContext()));
// CASE_INSENSITIVE
testRunner = TestRunners.newTestRunner(processor);
testRunner.setProperty(ExtractText.CASE_INSENSITIVE, "true");
- assertEquals(Pattern.CASE_INSENSITIVE, processor.
- getCompileFlags(testRunner.getProcessContext()));
+ assertEquals(Pattern.CASE_INSENSITIVE, processor.getCompileFlags(testRunner.getProcessContext()));
// COMMENTS
testRunner = TestRunners.newTestRunner(processor);
testRunner.setProperty(ExtractText.COMMENTS, "true");
- assertEquals(Pattern.COMMENTS, processor.getCompileFlags(testRunner.
- getProcessContext()));
+ assertEquals(Pattern.COMMENTS, processor.getCompileFlags(testRunner.getProcessContext()));
// MULTILINE
testRunner = TestRunners.newTestRunner(processor);
testRunner.setProperty(ExtractText.MULTILINE, "true");
- assertEquals(Pattern.MULTILINE, processor.getCompileFlags(testRunner.
- getProcessContext()));
+ assertEquals(Pattern.MULTILINE, processor.getCompileFlags(testRunner.getProcessContext()));
// LITERAL
testRunner = TestRunners.newTestRunner(processor);
testRunner.setProperty(ExtractText.LITERAL, "true");
- assertEquals(Pattern.LITERAL, processor.getCompileFlags(testRunner.
- getProcessContext()));
+ assertEquals(Pattern.LITERAL, processor.getCompileFlags(testRunner.getProcessContext()));
// DOTALL
testRunner = TestRunners.newTestRunner(processor);
testRunner.setProperty(ExtractText.DOTALL, "true");
- assertEquals(Pattern.DOTALL, processor.getCompileFlags(testRunner.
- getProcessContext()));
+ assertEquals(Pattern.DOTALL, processor.getCompileFlags(testRunner.getProcessContext()));
// UNICODE_CASE
testRunner = TestRunners.newTestRunner(processor);
testRunner.setProperty(ExtractText.UNICODE_CASE, "true");
- assertEquals(Pattern.UNICODE_CASE, processor.getCompileFlags(testRunner.
- getProcessContext()));
+ assertEquals(Pattern.UNICODE_CASE, processor.getCompileFlags(testRunner.getProcessContext()));
// CANON_EQ
testRunner = TestRunners.newTestRunner(processor);
testRunner.setProperty(ExtractText.CANON_EQ, "true");
- assertEquals(Pattern.CANON_EQ, processor.getCompileFlags(testRunner.
- getProcessContext()));
+ assertEquals(Pattern.CANON_EQ, processor.getCompileFlags(testRunner.getProcessContext()));
// UNICODE_CHARACTER_CLASS
testRunner = TestRunners.newTestRunner(processor);
testRunner.setProperty(ExtractText.UNICODE_CHARACTER_CLASS, "true");
- assertEquals(Pattern.UNICODE_CHARACTER_CLASS, processor.
- getCompileFlags(testRunner.getProcessContext()));
+ assertEquals(Pattern.UNICODE_CHARACTER_CLASS, processor.getCompileFlags(testRunner.getProcessContext()));
// DOTALL and MULTILINE
testRunner = TestRunners.newTestRunner(processor);
testRunner.setProperty(ExtractText.DOTALL, "true");
testRunner.setProperty(ExtractText.MULTILINE, "true");
- assertEquals(Pattern.DOTALL | Pattern.MULTILINE, processor.
- getCompileFlags(testRunner.getProcessContext()));
+ assertEquals(Pattern.DOTALL | Pattern.MULTILINE, processor.getCompileFlags(testRunner.getProcessContext()));
}
@Test
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d29a2d68/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestGetFile.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestGetFile.java b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestGetFile.java
index f0526d9..018cbdc 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestGetFile.java
+++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestGetFile.java
@@ -46,8 +46,7 @@ public class TestGetFile {
public void testFilePickedUp() throws IOException {
final File directory = new File("target/test/data/in");
deleteDirectory(directory);
- assertTrue("Unable to create test data directory " + directory.
- getAbsolutePath(), directory.exists() || directory.mkdirs());
+ assertTrue("Unable to create test data directory " + directory.getAbsolutePath(), directory.exists() || directory.mkdirs());
final File inFile = new File("src/test/resources/hello.txt");
final Path inPath = inFile.toPath();
@@ -62,16 +61,12 @@ public class TestGetFile {
runner.run();
runner.assertAllFlowFilesTransferred(GetFile.REL_SUCCESS, 1);
- final List<MockFlowFile> successFiles = runner.
- getFlowFilesForRelationship(GetFile.REL_SUCCESS);
- successFiles.get(0).
- assertContentEquals("Hello, World!".getBytes("UTF-8"));
+ final List<MockFlowFile> successFiles = runner.getFlowFilesForRelationship(GetFile.REL_SUCCESS);
+ successFiles.get(0).assertContentEquals("Hello, World!".getBytes("UTF-8"));
- final String path = successFiles.get(0).
- getAttribute("path");
+ final String path = successFiles.get(0).getAttribute("path");
assertEquals("/", path);
- final String absolutePath = successFiles.get(0).
- getAttribute(CoreAttributes.ABSOLUTE_PATH.key());
+ final String absolutePath = successFiles.get(0).getAttribute(CoreAttributes.ABSOLUTE_PATH.key());
assertEquals(absTargetPathStr, absolutePath);
}
@@ -82,8 +77,7 @@ public class TestGetFile {
deleteDirectory(file);
}
- assertTrue("Could not delete " + file.getAbsolutePath(), file.
- delete());
+ assertTrue("Could not delete " + file.getAbsolutePath(), file.delete());
}
}
}
@@ -95,8 +89,7 @@ public class TestGetFile {
final File directory = new File("target/test/data/in/" + dirStruc);
deleteDirectory(directory);
- assertTrue("Unable to create test data directory " + directory.
- getAbsolutePath(), directory.exists() || directory.mkdirs());
+ assertTrue("Unable to create test data directory " + directory.getAbsolutePath(), directory.exists() || directory.mkdirs());
final File inFile = new File("src/test/resources/hello.txt");
final Path inPath = inFile.toPath();
@@ -105,15 +98,12 @@ public class TestGetFile {
Files.copy(inPath, targetPath);
final TestRunner runner = TestRunners.newTestRunner(new GetFile());
- runner.
- setProperty(GetFile.DIRECTORY, "target/test/data/in/${now():format('yyyy/MM/dd')}");
+ runner.setProperty(GetFile.DIRECTORY, "target/test/data/in/${now():format('yyyy/MM/dd')}");
runner.run();
runner.assertAllFlowFilesTransferred(GetFile.REL_SUCCESS, 1);
- final List<MockFlowFile> successFiles = runner.
- getFlowFilesForRelationship(GetFile.REL_SUCCESS);
- successFiles.get(0).
- assertContentEquals("Hello, World!".getBytes("UTF-8"));
+ final List<MockFlowFile> successFiles = runner.getFlowFilesForRelationship(GetFile.REL_SUCCESS);
+ successFiles.get(0).assertContentEquals("Hello, World!".getBytes("UTF-8"));
}
@Test
@@ -123,16 +113,14 @@ public class TestGetFile {
final File directory = new File("target/test/data/in/" + dirStruc);
deleteDirectory(new File("target/test/data/in"));
- assertTrue("Unable to create test data directory " + directory.
- getAbsolutePath(), directory.exists() || directory.mkdirs());
+ assertTrue("Unable to create test data directory " + directory.getAbsolutePath(), directory.exists() || directory.mkdirs());
final File inFile = new File("src/test/resources/hello.txt");
final Path inPath = inFile.toPath();
final File destFile = new File(directory, inFile.getName());
final Path targetPath = destFile.toPath();
final Path absTargetPath = targetPath.toAbsolutePath();
- final String absTargetPathStr = absTargetPath.getParent().
- toString() + "/";
+ final String absTargetPathStr = absTargetPath.getParent().toString() + "/";
Files.copy(inPath, targetPath);
final TestRunner runner = TestRunners.newTestRunner(new GetFile());
@@ -140,16 +128,12 @@ public class TestGetFile {
runner.run();
runner.assertAllFlowFilesTransferred(GetFile.REL_SUCCESS, 1);
- final List<MockFlowFile> successFiles = runner.
- getFlowFilesForRelationship(GetFile.REL_SUCCESS);
- successFiles.get(0).
- assertContentEquals("Hello, World!".getBytes("UTF-8"));
+ final List<MockFlowFile> successFiles = runner.getFlowFilesForRelationship(GetFile.REL_SUCCESS);
+ successFiles.get(0).assertContentEquals("Hello, World!".getBytes("UTF-8"));
- final String path = successFiles.get(0).
- getAttribute("path");
+ final String path = successFiles.get(0).getAttribute("path");
assertEquals(dirStruc, path.replace('\\', '/'));
- final String absolutePath = successFiles.get(0).
- getAttribute(CoreAttributes.ABSOLUTE_PATH.key());
+ final String absolutePath = successFiles.get(0).getAttribute(CoreAttributes.ABSOLUTE_PATH.key());
assertEquals(absTargetPathStr, absolutePath);
}
@@ -157,8 +141,7 @@ public class TestGetFile {
public void testAttributes() throws IOException {
final File directory = new File("target/test/data/in/");
deleteDirectory(directory);
- assertTrue("Unable to create test data directory " + directory.
- getAbsolutePath(), directory.exists() || directory.mkdirs());
+ assertTrue("Unable to create test data directory " + directory.getAbsolutePath(), directory.exists() || directory.mkdirs());
final File inFile = new File("src/test/resources/hello.txt");
final Path inPath = inFile.toPath();
@@ -175,8 +158,7 @@ public class TestGetFile {
boolean verifyPermissions = false;
try {
- Files.setPosixFilePermissions(targetPath, PosixFilePermissions.
- fromString("r--r-----"));
+ Files.setPosixFilePermissions(targetPath, PosixFilePermissions.fromString("r--r-----"));
verifyPermissions = true;
} catch (Exception donothing) {
}
@@ -186,22 +168,19 @@ public class TestGetFile {
runner.run();
runner.assertAllFlowFilesTransferred(GetFile.REL_SUCCESS, 1);
- final List<MockFlowFile> successFiles = runner.
- getFlowFilesForRelationship(GetFile.REL_SUCCESS);
+ final List<MockFlowFile> successFiles = runner.getFlowFilesForRelationship(GetFile.REL_SUCCESS);
if (verifyLastModified) {
try {
final DateFormat formatter = new SimpleDateFormat(GetFile.FILE_MODIFY_DATE_ATTR_FORMAT, Locale.US);
- final Date fileModifyTime = formatter.parse(successFiles.get(0).
- getAttribute("file.lastModifiedTime"));
+ final Date fileModifyTime = formatter.parse(successFiles.get(0).getAttribute("file.lastModifiedTime"));
assertEquals(new Date(1000000000), fileModifyTime);
} catch (ParseException e) {
fail();
}
}
if (verifyPermissions) {
- successFiles.get(0).
- assertAttributeEquals("file.permissions", "r--r-----");
+ successFiles.get(0).assertAttributeEquals("file.permissions", "r--r-----");
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d29a2d68/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestGetHTTP.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestGetHTTP.java b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestGetHTTP.java
index 7a76ffd..bd975f2 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestGetHTTP.java
+++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestGetHTTP.java
@@ -53,10 +53,8 @@ public class TestGetHTTP {
public static void before() {
System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "info");
System.setProperty("org.slf4j.simpleLogger.showDateTime", "true");
- System.
- setProperty("org.slf4j.simpleLogger.log.nifi.processors.standard.GetHTTP", "debug");
- System.
- setProperty("org.slf4j.simpleLogger.log.nifi.processors.standard.TestGetHTTP", "debug");
+ System.setProperty("org.slf4j.simpleLogger.log.nifi.processors.standard.GetHTTP", "debug");
+ System.setProperty("org.slf4j.simpleLogger.log.nifi.processors.standard.TestGetHTTP", "debug");
File confDir = new File("conf");
if (!confDir.exists()) {
confDir.mkdir();
@@ -96,26 +94,21 @@ public class TestGetHTTP {
controller.setProperty(GetHTTP.CONNECTION_TIMEOUT, "5 secs");
controller.setProperty(GetHTTP.URL, destination);
controller.setProperty(GetHTTP.FILENAME, "testFile");
- controller.
- setProperty(GetHTTP.ACCEPT_CONTENT_TYPE, "application/json");
+ controller.setProperty(GetHTTP.ACCEPT_CONTENT_TYPE, "application/json");
GetHTTP getHTTPProcessor = (GetHTTP) controller.getProcessor();
assertEquals("", getHTTPProcessor.entityTagRef.get());
- assertEquals("Thu, 01 Jan 1970 00:00:00 GMT", getHTTPProcessor.lastModifiedRef.
- get());
+ assertEquals("Thu, 01 Jan 1970 00:00:00 GMT", getHTTPProcessor.lastModifiedRef.get());
controller.run(2);
// verify the lastModified and entityTag are updated
assertFalse("".equals(getHTTPProcessor.entityTagRef.get()));
- assertFalse("Thu, 01 Jan 1970 00:00:00 GMT".
- equals(getHTTPProcessor.lastModifiedRef.get()));
+ assertFalse("Thu, 01 Jan 1970 00:00:00 GMT".equals(getHTTPProcessor.lastModifiedRef.get()));
// ran twice, but got one...which is good
controller.assertTransferCount(GetHTTP.REL_SUCCESS, 1);
// verify remote.source flowfile attribute
- controller.getFlowFilesForRelationship(GetHTTP.REL_SUCCESS).
- get(0).
- assertAttributeEquals("gethttp.remote.source", "localhost");
+ controller.getFlowFilesForRelationship(GetHTTP.REL_SUCCESS).get(0).assertAttributeEquals("gethttp.remote.source", "localhost");
controller.clearTransferState();
@@ -153,8 +146,7 @@ public class TestGetHTTP {
// turn off checking for Etag, turn on checking for lastModified, but change value
RESTServiceContentModified.IGNORE_LAST_MODIFIED = false;
RESTServiceContentModified.IGNORE_ETAG = true;
- RESTServiceContentModified.modificationDate = System.
- currentTimeMillis() / 1000 * 1000 + 5000;
+ RESTServiceContentModified.modificationDate = System.currentTimeMillis() / 1000 * 1000 + 5000;
String lastMod = getHTTPProcessor.lastModifiedRef.get();
controller.run(2);
// ran twice, got 1...but should have new cached etag
@@ -196,14 +188,12 @@ public class TestGetHTTP {
controller.setProperty(GetHTTP.CONNECTION_TIMEOUT, "5 secs");
controller.setProperty(GetHTTP.FILENAME, "testFile");
controller.setProperty(GetHTTP.URL, destination);
- controller.
- setProperty(GetHTTP.ACCEPT_CONTENT_TYPE, "application/json");
+ controller.setProperty(GetHTTP.ACCEPT_CONTENT_TYPE, "application/json");
GetHTTP getHTTPProcessor = (GetHTTP) controller.getProcessor();
assertEquals("", getHTTPProcessor.entityTagRef.get());
- assertEquals("Thu, 01 Jan 1970 00:00:00 GMT", getHTTPProcessor.lastModifiedRef.
- get());
+ assertEquals("Thu, 01 Jan 1970 00:00:00 GMT", getHTTPProcessor.lastModifiedRef.get());
controller.run(2);
// verify the lastModified and entityTag are updated
@@ -226,9 +216,7 @@ public class TestGetHTTP {
assertEquals(etag, props.getProperty(GetHTTP.ETAG));
assertEquals(lastMod, props.getProperty(GetHTTP.LAST_MODIFIED));
- ProcessorInitializationContext pic = new MockProcessorInitializationContext(controller.
- getProcessor(),
- (MockProcessContext) controller.getProcessContext());
+ ProcessorInitializationContext pic = new MockProcessorInitializationContext(controller.getProcessor(), (MockProcessContext) controller.getProcessContext());
// init causes read from file
getHTTPProcessor.init(pic);
assertEquals(etag, getHTTPProcessor.entityTagRef.get());
@@ -274,8 +262,7 @@ public class TestGetHTTP {
controller.setProperty(GetHTTP.CONNECTION_TIMEOUT, "5 secs");
controller.setProperty(GetHTTP.URL, destination);
controller.setProperty(GetHTTP.FILENAME, "testFile");
- controller.
- setProperty(GetHTTP.ACCEPT_CONTENT_TYPE, "application/json");
+ controller.setProperty(GetHTTP.ACCEPT_CONTENT_TYPE, "application/json");
controller.run();
controller.assertTransferCount(GetHTTP.REL_SUCCESS, 0);
@@ -292,15 +279,11 @@ public class TestGetHTTP {
private Map<String, String> getSslProperties() {
Map<String, String> props = new HashMap<String, String>();
- props.
- put(StandardSSLContextService.KEYSTORE.getName(), "src/test/resources/localhost-ks.jks");
- props.
- put(StandardSSLContextService.KEYSTORE_PASSWORD.getName(), "localtest");
+ props.put(StandardSSLContextService.KEYSTORE.getName(), "src/test/resources/localhost-ks.jks");
+ props.put(StandardSSLContextService.KEYSTORE_PASSWORD.getName(), "localtest");
props.put(StandardSSLContextService.KEYSTORE_TYPE.getName(), "JKS");
- props.
- put(StandardSSLContextService.TRUSTSTORE.getName(), "src/test/resources/localhost-ts.jks");
- props.
- put(StandardSSLContextService.TRUSTSTORE_PASSWORD.getName(), "localtest");
+ props.put(StandardSSLContextService.TRUSTSTORE.getName(), "src/test/resources/localhost-ts.jks");
+ props.put(StandardSSLContextService.TRUSTSTORE_PASSWORD.getName(), "localtest");
props.put(StandardSSLContextService.TRUSTSTORE_TYPE.getName(), "JKS");
return props;
}
@@ -308,8 +291,7 @@ public class TestGetHTTP {
private void useSSLContextService() {
final SSLContextService service = new StandardSSLContextService();
try {
- controller.
- addControllerService("ssl-service", service, getSslProperties());
+ controller.addControllerService("ssl-service", service, getSslProperties());
controller.enableControllerService(service);
} catch (InitializationException ex) {
ex.printStackTrace();
@@ -341,14 +323,11 @@ public class TestGetHTTP {
controller.setProperty(GetHTTP.CONNECTION_TIMEOUT, "5 secs");
controller.setProperty(GetHTTP.URL, destination);
controller.setProperty(GetHTTP.FILENAME, "testFile");
- controller.
- setProperty(GetHTTP.ACCEPT_CONTENT_TYPE, "application/json");
+ controller.setProperty(GetHTTP.ACCEPT_CONTENT_TYPE, "application/json");
controller.run();
controller.assertAllFlowFilesTransferred(GetHTTP.REL_SUCCESS, 1);
- final MockFlowFile mff = controller.
- getFlowFilesForRelationship(GetHTTP.REL_SUCCESS).
- get(0);
+ final MockFlowFile mff = controller.getFlowFilesForRelationship(GetHTTP.REL_SUCCESS).get(0);
mff.assertContentEquals("Hello, World!");
} finally {
server.shutdownServer();
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/d29a2d68/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestGetJMSQueue.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestGetJMSQueue.java b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestGetJMSQueue.java
index b6c79d5..9c833f5 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestGetJMSQueue.java
+++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestGetJMSQueue.java
@@ -36,16 +36,12 @@ public class TestGetJMSQueue {
@org.junit.Ignore
public void testSendTextToQueue() throws Exception {
final TestRunner runner = TestRunners.newTestRunner(GetJMSQueue.class);
- runner.
- setProperty(JmsProperties.JMS_PROVIDER, JmsProperties.ACTIVEMQ_PROVIDER);
+ runner.setProperty(JmsProperties.JMS_PROVIDER, JmsProperties.ACTIVEMQ_PROVIDER);
runner.setProperty(JmsProperties.URL, "tcp://localhost:61616");
- runner.
- setProperty(JmsProperties.DESTINATION_TYPE, JmsProperties.DESTINATION_TYPE_QUEUE);
+ runner.setProperty(JmsProperties.DESTINATION_TYPE, JmsProperties.DESTINATION_TYPE_QUEUE);
runner.setProperty(JmsProperties.DESTINATION_NAME, "queue.testing");
- runner.
- setProperty(JmsProperties.ACKNOWLEDGEMENT_MODE, JmsProperties.ACK_MODE_AUTO);
- WrappedMessageProducer wrappedProducer = JmsFactory.
- createMessageProducer(runner.getProcessContext(), true);
+ runner.setProperty(JmsProperties.ACKNOWLEDGEMENT_MODE, JmsProperties.ACK_MODE_AUTO);
+ WrappedMessageProducer wrappedProducer = JmsFactory.createMessageProducer(runner.getProcessContext(), true);
final Session jmsSession = wrappedProducer.getSession();
final MessageProducer producer = wrappedProducer.getProducer();
@@ -60,16 +56,12 @@ public class TestGetJMSQueue {
@org.junit.Ignore
public void testSendBytesToQueue() throws Exception {
final TestRunner runner = TestRunners.newTestRunner(GetJMSQueue.class);
- runner.
- setProperty(JmsProperties.JMS_PROVIDER, JmsProperties.ACTIVEMQ_PROVIDER);
+ runner.setProperty(JmsProperties.JMS_PROVIDER, JmsProperties.ACTIVEMQ_PROVIDER);
runner.setProperty(JmsProperties.URL, "tcp://localhost:61616");
- runner.
- setProperty(JmsProperties.DESTINATION_TYPE, JmsProperties.DESTINATION_TYPE_QUEUE);
+ runner.setProperty(JmsProperties.DESTINATION_TYPE, JmsProperties.DESTINATION_TYPE_QUEUE);
runner.setProperty(JmsProperties.DESTINATION_NAME, "queue.testing");
- runner.
- setProperty(JmsProperties.ACKNOWLEDGEMENT_MODE, JmsProperties.ACK_MODE_AUTO);
- WrappedMessageProducer wrappedProducer = JmsFactory.
- createMessageProducer(runner.getProcessContext(), true);
+ runner.setProperty(JmsProperties.ACKNOWLEDGEMENT_MODE, JmsProperties.ACK_MODE_AUTO);
+ WrappedMessageProducer wrappedProducer = JmsFactory.createMessageProducer(runner.getProcessContext(), true);
final Session jmsSession = wrappedProducer.getSession();
final MessageProducer producer = wrappedProducer.getProducer();
@@ -85,16 +77,12 @@ public class TestGetJMSQueue {
@org.junit.Ignore
public void testSendStreamToQueue() throws Exception {
final TestRunner runner = TestRunners.newTestRunner(GetJMSQueue.class);
- runner.
- setProperty(JmsProperties.JMS_PROVIDER, JmsProperties.ACTIVEMQ_PROVIDER);
+ runner.setProperty(JmsProperties.JMS_PROVIDER, JmsProperties.ACTIVEMQ_PROVIDER);
runner.setProperty(JmsProperties.URL, "tcp://localhost:61616");
- runner.
- setProperty(JmsProperties.DESTINATION_TYPE, JmsProperties.DESTINATION_TYPE_QUEUE);
+ runner.setProperty(JmsProperties.DESTINATION_TYPE, JmsProperties.DESTINATION_TYPE_QUEUE);
runner.setProperty(JmsProperties.DESTINATION_NAME, "queue.testing");
- runner.
- setProperty(JmsProperties.ACKNOWLEDGEMENT_MODE, JmsProperties.ACK_MODE_AUTO);
- WrappedMessageProducer wrappedProducer = JmsFactory.
- createMessageProducer(runner.getProcessContext(), true);
+ runner.setProperty(JmsProperties.ACKNOWLEDGEMENT_MODE, JmsProperties.ACK_MODE_AUTO);
+ WrappedMessageProducer wrappedProducer = JmsFactory.createMessageProducer(runner.getProcessContext(), true);
final Session jmsSession = wrappedProducer.getSession();
final MessageProducer producer = wrappedProducer.getProducer();
@@ -110,16 +98,12 @@ public class TestGetJMSQueue {
@org.junit.Ignore
public void testSendMapToQueue() throws Exception {
final TestRunner runner = TestRunners.newTestRunner(GetJMSQueue.class);
- runner.
- setProperty(JmsProperties.JMS_PROVIDER, JmsProperties.ACTIVEMQ_PROVIDER);
+ runner.setProperty(JmsProperties.JMS_PROVIDER, JmsProperties.ACTIVEMQ_PROVIDER);
runner.setProperty(JmsProperties.URL, "tcp://localhost:61616");
- runner.
- setProperty(JmsProperties.DESTINATION_TYPE, JmsProperties.DESTINATION_TYPE_QUEUE);
+ runner.setProperty(JmsProperties.DESTINATION_TYPE, JmsProperties.DESTINATION_TYPE_QUEUE);
runner.setProperty(JmsProperties.DESTINATION_NAME, "queue.testing");
- runner.
- setProperty(JmsProperties.ACKNOWLEDGEMENT_MODE, JmsProperties.ACK_MODE_AUTO);
- WrappedMessageProducer wrappedProducer = JmsFactory.
- createMessageProducer(runner.getProcessContext(), true);
+ runner.setProperty(JmsProperties.ACKNOWLEDGEMENT_MODE, JmsProperties.ACK_MODE_AUTO);
+ WrappedMessageProducer wrappedProducer = JmsFactory.createMessageProducer(runner.getProcessContext(), true);
final Session jmsSession = wrappedProducer.getSession();
final MessageProducer producer = wrappedProducer.getProducer();
@@ -136,22 +120,17 @@ public class TestGetJMSQueue {
@org.junit.Ignore
public void testSendObjectToQueue() throws Exception {
final TestRunner runner = TestRunners.newTestRunner(GetJMSQueue.class);
- runner.
- setProperty(JmsProperties.JMS_PROVIDER, JmsProperties.ACTIVEMQ_PROVIDER);
+ runner.setProperty(JmsProperties.JMS_PROVIDER, JmsProperties.ACTIVEMQ_PROVIDER);
runner.setProperty(JmsProperties.URL, "tcp://localhost:61616");
- runner.
- setProperty(JmsProperties.DESTINATION_TYPE, JmsProperties.DESTINATION_TYPE_QUEUE);
+ runner.setProperty(JmsProperties.DESTINATION_TYPE, JmsProperties.DESTINATION_TYPE_QUEUE);
runner.setProperty(JmsProperties.DESTINATION_NAME, "queue.testing");
- runner.
- setProperty(JmsProperties.ACKNOWLEDGEMENT_MODE, JmsProperties.ACK_MODE_AUTO);
- WrappedMessageProducer wrappedProducer = JmsFactory.
- createMessageProducer(runner.getProcessContext(), true);
+ runner.setProperty(JmsProperties.ACKNOWLEDGEMENT_MODE, JmsProperties.ACK_MODE_AUTO);
+ WrappedMessageProducer wrappedProducer = JmsFactory.createMessageProducer(runner.getProcessContext(), true);
final Session jmsSession = wrappedProducer.getSession();
final MessageProducer producer = wrappedProducer.getProducer();
// Revision class is used because test just needs any Serializable class in core NiFi
- final ObjectMessage message = jmsSession.
- createObjectMessage(new Revision(1L, "ID"));
+ final ObjectMessage message = jmsSession.createObjectMessage(new Revision(1L, "ID"));
producer.send(message);
jmsSession.commit();