From 08d31b137005570c3abd89522d4820405ac82039 Mon Sep 17 00:00:00 2001 From: "KIRSTEN W. HILDRUM" Date: Wed, 30 Sep 2015 11:10:31 -0400 Subject: [PATCH] Add a test --- tests/InetSource/NoNewlineAtEnd/Main.spl | 35 ++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 tests/InetSource/NoNewlineAtEnd/Main.spl diff --git a/tests/InetSource/NoNewlineAtEnd/Main.spl b/tests/InetSource/NoNewlineAtEnd/Main.spl new file mode 100644 index 0000000..8f05931 --- /dev/null +++ b/tests/InetSource/NoNewlineAtEnd/Main.spl @@ -0,0 +1,35 @@ + + +composite Main { + +graph + stream NoNewline = com.ibm.streamsx.inet::InetSource() { + param + // the data returned by this URL does not have a newline at the end. + URIList: ["http://services.faa.gov/airport/status/ATL?format=application/xml"]; + fetchInterval: 5.0; + + } + + // make sure we got the last line. + () as checkNoNewline = Custom(NoNewline) { + logic state: { + mutable int32 numEnter = 0; + mutable int32 numExits = 0; + } + onTuple NoNewline: { + if (size(regexMatch(result,"\\s*\\s*")) > 0) { + numEnter++; + } + else if (size(regexMatch(result,"\\s*0) { + numExits++; + } + if (numEnter-numExits > 1) { + abort(); + } + if (numEnter == numExits && numExits > 0) { + shutdownPE(); + } + } + } +}