Skip to content

Commit

Permalink
Add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
KIRSTEN W. HILDRUM committed Sep 30, 2015
1 parent e4ff217 commit 08d31b1
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/InetSource/NoNewlineAtEnd/Main.spl
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@


composite Main {

graph
stream<rstring result> 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*<AirportStatus>\\s*")) > 0) {
numEnter++;
}
else if (size(regexMatch(result,"\\s*</AirportStatus\\s*"))>0) {
numExits++;
}
if (numEnter-numExits > 1) {
abort();
}
if (numEnter == numExits && numExits > 0) {
shutdownPE();
}
}
}
}

0 comments on commit 08d31b1

Please sign in to comment.