root/test/t/004_simple_stratcon.t

Revision 65401ed4ea2de6867afad03da41e4ebfcb28bef9, 1.0 kB (checked in by Theo Schlossnagle <jesus@omniti.com>, 4 years ago)

basic stratcon test, refs #230

  • Property mode set to 100644
Line 
1 use Test::More tests => 9;
2 use XML::LibXML;
3 use XML::LibXML::XPathContext;
4 use testconfig;
5 use apiclient;
6
7 use strict;
8 my $xp = XML::LibXML->new();
9 my $xpc = XML::LibXML::XPathContext->new();
10 my $doc;
11
12 ok(start_stratcon("004"), 'starting stratcon');
13 sleep(1);
14 my $c = apiclient->new('localhost', $STRATCON_API_PORT);
15 my @r = $c->get("/noits/show");
16 is($r[0], 200, 'show noits');
17 $doc = $xp->parse_string($r[1]);
18 my @nonoits = $xpc->findnodes("/noits/noit", $doc);
19 is(@nonoits, 0, 'no noits');
20 @r = $c->put("/noits/set/127.0.0.1:$NOIT_API_PORT");
21 is($r[0], 200, 'add noit');
22 @r = $c->get("/noits/show");
23 is($r[0], 200, 'show noits');
24 $doc = $xp->parse_string($r[1]);
25 my @noits = $xpc->findnodes("/noits/noit", $doc);
26 is(@noits, 2, 'noits added');
27 @r = $c->delete("/noits/delete/127.0.0.1:$NOIT_API_PORT");
28 is($r[0], 200, 'delete noit');
29 @r = $c->get("/noits/show");
30 is($r[0], 200, 'show noits');
31 $doc = $xp->parse_string($r[1]);
32 @nonoits = $xpc->findnodes("/noits/noit", $doc);
33 is(@nonoits, 0, 'removed noit');
34
35 1;
Note: See TracBrowser for help on using the browser.