From b42677d69de3dab1a55c81689cf2b3b45fd85d12 Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Fri, 23 Nov 2012 15:46:12 +0000 Subject: Removed duplicate member-variables for subclasses. Allow test-inversion via "must not run". --- lib/custodian/protocoltest/ftp.rb | 30 +++++++++--------------------- lib/custodian/protocoltest/jabber.rb | 27 +++++++++------------------ lib/custodian/protocoltest/ldap.rb | 29 +++++++++-------------------- lib/custodian/protocoltest/ping.rb | 24 ++++++++++-------------- lib/custodian/protocoltest/rsync.rb | 30 ++++++++++-------------------- lib/custodian/protocoltest/smtp.rb | 29 +++++++++-------------------- lib/custodian/protocoltest/ssh.rb | 31 +++++++++++-------------------- lib/custodian/protocoltest/tcp.rb | 18 +++++++++++++++++- lib/custodian/testfactory.rb | 7 +++++++ 9 files changed, 91 insertions(+), 134 deletions(-) (limited to 'lib') diff --git a/lib/custodian/protocoltest/ftp.rb b/lib/custodian/protocoltest/ftp.rb index a816bfd..25271c6 100644 --- a/lib/custodian/protocoltest/ftp.rb +++ b/lib/custodian/protocoltest/ftp.rb @@ -18,27 +18,6 @@ module Custodian class FTPTest < TCPTest - # - # The line from which we were constructed. - # - attr_reader :line - - - # - # The host to test against. - # - attr_reader :host - - - # - # The port to connect to. - # - attr_reader :port - - - - - # # Constructor # @@ -57,6 +36,15 @@ module Custodian @host = $1.dup end + # + # Is this test inverted? + # + if ( line =~ /must\s+not\s+run\s+/ ) + @inverted = true + else + @inverted = false + end + # # Save the port # diff --git a/lib/custodian/protocoltest/jabber.rb b/lib/custodian/protocoltest/jabber.rb index 9c0eb6d..1e95650 100644 --- a/lib/custodian/protocoltest/jabber.rb +++ b/lib/custodian/protocoltest/jabber.rb @@ -18,24 +18,6 @@ module Custodian class JABBERTest < TCPTest - # - # The line from which we were constructed. - # - attr_reader :line - - - # - # The host to test against. - # - attr_reader :host - - - # - # The port to connect to. - # - attr_reader :port - - # # Constructor @@ -52,6 +34,15 @@ module Custodian # @host = line.split( /\s+/)[0] + # + # Is this test inverted? + # + if ( line =~ /must\s+not\s+run\s+/ ) + @inverted = true + else + @inverted = false + end + # # Save the port # diff --git a/lib/custodian/protocoltest/ldap.rb b/lib/custodian/protocoltest/ldap.rb index b27e5d6..ab703e5 100644 --- a/lib/custodian/protocoltest/ldap.rb +++ b/lib/custodian/protocoltest/ldap.rb @@ -19,26 +19,6 @@ module Custodian class LDAPTest < TCPTest - # - # The line from which we were constructed. - # - attr_reader :line - - - # - # The host to test against. - # - attr_reader :host - - - # - # The port to connect to. - # - attr_reader :port - - - - # # Constructor # @@ -54,6 +34,15 @@ module Custodian # @host = line.split( /\s+/)[0] + # + # Is this test inverted? + # + if ( line =~ /must\s+not\s+run\s+/ ) + @inverted = true + else + @inverted = false + end + # # Save the port # diff --git a/lib/custodian/protocoltest/ping.rb b/lib/custodian/protocoltest/ping.rb index c13c17c..95b387c 100644 --- a/lib/custodian/protocoltest/ping.rb +++ b/lib/custodian/protocoltest/ping.rb @@ -18,20 +18,6 @@ module Custodian class PINGTest < TestFactory - # - # The line from which we were constructed. - # - attr_reader :line - - - # - # The host to test against. - # - attr_reader :host - - - - # # Constructor # @@ -46,6 +32,16 @@ module Custodian # Save the host # @host = line.split( /\s+/)[0] + + # + # Is this test inverted? + # + if ( line =~ /must\s+not\s+run\s+/ ) + @inverted = true + else + @inverted = false + end + end diff --git a/lib/custodian/protocoltest/rsync.rb b/lib/custodian/protocoltest/rsync.rb index 293f67c..3d38d3a 100644 --- a/lib/custodian/protocoltest/rsync.rb +++ b/lib/custodian/protocoltest/rsync.rb @@ -18,25 +18,6 @@ module Custodian class RSYNCTest < TCPTest - # - # The line from which we were constructed. - # - attr_reader :line - - - # - # The host to test against. - # - attr_reader :host - - - # - # The port to connect to. - # - attr_reader :port - - - # # Constructor @@ -49,13 +30,22 @@ module Custodian @line = line # - # Save the host + # If the target is an URL then strip to the hostname. # @host = line.split( /\s+/)[0] if ( @host =~ /^rsync:\/\/([^\/]+)\/?/ ) @host = $1.dup end + # + # Is this test inverted? + # + if ( line =~ /must\s+not\s+run\s+/ ) + @inverted = true + else + @inverted = false + end + # # Save the port diff --git a/lib/custodian/protocoltest/smtp.rb b/lib/custodian/protocoltest/smtp.rb index 0d22c95..89e2b24 100644 --- a/lib/custodian/protocoltest/smtp.rb +++ b/lib/custodian/protocoltest/smtp.rb @@ -19,26 +19,6 @@ module Custodian class SMTPTest < TCPTest - # - # The line from which we were constructed. - # - attr_reader :line - - - # - # The host to test against. - # - attr_reader :host - - - # - # The port to connect to. - # - attr_reader :port - - - - # # Constructor # @@ -54,6 +34,15 @@ module Custodian # @host = line.split( /\s+/)[0] + # + # Is this test inverted? + # + if ( line =~ /must\s+not\s+run\s+/ ) + @inverted = true + else + @inverted = false + end + # # Save the port # diff --git a/lib/custodian/protocoltest/ssh.rb b/lib/custodian/protocoltest/ssh.rb index 205099e..0d64911 100644 --- a/lib/custodian/protocoltest/ssh.rb +++ b/lib/custodian/protocoltest/ssh.rb @@ -17,26 +17,6 @@ module Custodian class SSHTest < TCPTest - - # - # The line from which we were constructed. - # - attr_reader :line - - - # - # The host to test against. - # - attr_reader :host - - - # - # The port to connect to. - # - attr_reader :port - - - # # Constructor # @@ -54,6 +34,17 @@ module Custodian # @host = line.split( /\s+/)[0] + + # + # Is this test inverted? + # + if ( line =~ /must\s+not\s+run\s+/ ) + @inverted = true + else + @inverted = false + end + + # # Save the port # diff --git a/lib/custodian/protocoltest/tcp.rb b/lib/custodian/protocoltest/tcp.rb index c14f686..1aa9db4 100644 --- a/lib/custodian/protocoltest/tcp.rb +++ b/lib/custodian/protocoltest/tcp.rb @@ -23,7 +23,7 @@ module Custodian # - # The input line + # The input line from which we were constructed. # attr_reader :line @@ -40,6 +40,12 @@ module Custodian attr_reader :port + # + # Is this test inverted? + # + attr_reader :inverted + + # # The banner to look for, may be nil. # @@ -65,6 +71,16 @@ module Custodian # @host = line.split( /\s+/)[0] + + # + # Is this test inverted? + # + if ( line =~ /must\s+not\s+run\s+/ ) + @inverted = true + else + @inverted = false + end + # # Save the port # diff --git a/lib/custodian/testfactory.rb b/lib/custodian/testfactory.rb index 934d6a7..6ae74d1 100644 --- a/lib/custodian/testfactory.rb +++ b/lib/custodian/testfactory.rb @@ -79,6 +79,13 @@ module Custodian + # + # Is this test inverted? + # + def inverted + @inverted + end + # # Return the port of this test. -- cgit v1.2.1