aboutsummaryrefslogtreecommitdiff
path: root/plugins/t/check_jabber.t
diff options
context:
space:
mode:
authorGravatar Ton Voon <tonvoon@users.sourceforge.net> 2007-01-31 22:50:54 +0000
committerGravatar Ton Voon <tonvoon@users.sourceforge.net> 2007-01-31 22:50:54 +0000
commita48b7fd824730cd2766e9a6ebeb05245c43f116d (patch)
tree8a72809a44ed5cbff34c7ae0220c7c079b99a06e /plugins/t/check_jabber.t
parent1f7821a657f95398ff6533e7665cbeeab9ddd8a5 (diff)
downloadmonitoring-plugins-a48b7fd824730cd2766e9a6ebeb05245c43f116d.tar.gz
Converted to new style object and Test::More testing. Skipped jabber server
tests if not defined git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1601 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/t/check_jabber.t')
-rw-r--r--plugins/t/check_jabber.t34
1 files changed, 22 insertions, 12 deletions
diff --git a/plugins/t/check_jabber.t b/plugins/t/check_jabber.t
index be232f2c..07742214 100644
--- a/plugins/t/check_jabber.t
+++ b/plugins/t/check_jabber.t
@@ -6,11 +6,10 @@
#
use strict;
-use Test;
+use Test::More;
use NPTest;
-use vars qw($tests);
-BEGIN {$tests = 10; plan tests => $tests}
+plan tests => 10;
my $host_tcp_jabber = getTestParameter(
"NP_HOST_TCP_JABBER",
@@ -30,7 +29,6 @@ my $hostname_invalid = getTestParameter(
"nosuchhost",
);
-my %exceptions = ( 2 => "No Jabber Server present?" );
my $jabberOK = '/JABBER OK\s-\s\d+\.\d+\ssecond response time on port 5222/';
@@ -38,18 +36,30 @@ my $jabberUnresponsive = '/CRITICAL\s-\sSocket timeout after\s\d+\sseconds/';
my $jabberInvalid = '/check_JABBER: Invalid hostname, address or socket\s-\s.+/';
-my $t;
+my $r;
-$t += checkCmd( "./check_jabber $host_tcp_jabber", 0, $jabberOK );
+SKIP: {
+ skip "No jabber server defined", 6 unless $host_tcp_jabber;
-$t += checkCmd( "./check_jabber -H $host_tcp_jabber -w 9 -c 9 -t 10", 0, $jabberOK );
+ $r = NPTest->testCmd( "./check_jabber $host_tcp_jabber" );
+ is( $r->return_code, 0, "Connected okay");
+ like( $r->output, $jabberOK, "Output as expected" );
-$t += checkCmd( "./check_jabber $host_tcp_jabber -wt 9 -ct 9 -to 10", 0, $jabberOK );
+ $r = NPTest->testCmd( "./check_jabber -H $host_tcp_jabber -w 9 -c 9 -t 10" );
+ is( $r->return_code, 0, "Connected okay, within limits" );
+ like( $r->output, $jabberOK, "Output as expected" );
+
+ $r = NPTest->testCmd( "./check_jabber $host_tcp_jabber -wt 9 -ct 9 -to 10" );
+ is( $r->return_code, 0, "Old syntax okay" );
+ like( $r->output, $jabberOK, "Output as expected" );
-$t += checkCmd( "./check_jabber $host_nonresponsive", 2, $jabberUnresponsive );
+}
-$t += checkCmd( "./check_jabber $hostname_invalid", 2, $jabberInvalid );
+$r = NPTest->testCmd( "./check_jabber $host_nonresponsive" );
+is( $r->return_code, 2, "Unresponsive host gives critical" );
+like( $r->output, $jabberUnresponsive );
-exit(0) if defined($Test::Harness::VERSION);
-exit($tests - $t);
+$r = NPTest->testCmd( "./check_jabber $hostname_invalid" );
+is( $r->return_code, 2, "Invalid hostname gives critical" );
+like( $r->output, $jabberInvalid );