-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
200 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
|
||
/** | ||
* This composite is meant to be run as a test. If compiled in standalone mode and executed, | ||
* it will give return 0 if the test is successful, and non-zero if the test fails. It should | ||
* be able to be invoked by any test harness. | ||
*/ | ||
|
||
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(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
tests/tests.http/com.ibm.streamsx.inet.http.tests/URLEncode.spl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
namespace com.ibm.streamsx.inet.http.tests; | ||
use com.ibm.streamsx.inet.http::urlEncode; | ||
use com.ibm.streamsx.inet.http::urlDecode; | ||
|
||
composite URLEncodeTestMain { | ||
|
||
graph | ||
() as tester = Custom() { | ||
|
||
logic onProcess: { | ||
|
||
rstring raw = "This has spaces and newline \n."; | ||
//println(raw); | ||
rstring encoded = urlEncode(raw); | ||
//println(encoded); | ||
rstring decoded = urlDecode(encoded); | ||
if (decoded != raw) { | ||
abort(); | ||
} | ||
rstring raw2 = "This has a null \0 now stuff after the null"; | ||
//println(raw2); | ||
rstring encoded2 = urlEncode(raw2); | ||
//println(encoded2); | ||
rstring decoded2 = urlDecode(encoded2); | ||
if (raw2 != decoded2) { | ||
abort(); | ||
} | ||
|
||
} | ||
|
||
} | ||
|
||
} |