From 7d153d8f22fc767108103cd8fdfc056e2656b914 Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Wed, 21 Nov 2012 23:15:44 +0000 Subject: Added .to_json method to serialize our tests. --- lib/custodian/protocoltest.rb | 3 +++ lib/custodian/protocoltest/ftp.rb | 14 ++++++++++++++ lib/custodian/protocoltest/jabber.rb | 15 +++++++++++++++ lib/custodian/protocoltest/rsync.rb | 15 +++++++++++++++ lib/custodian/protocoltest/smtp.rb | 15 +++++++++++++++ lib/custodian/protocoltest/ssh.rb | 16 ++++++++++++++++ lib/custodian/protocoltest/tcp.rb | 16 ++++++++++++++++ 7 files changed, 94 insertions(+) (limited to 'lib/custodian') diff --git a/lib/custodian/protocoltest.rb b/lib/custodian/protocoltest.rb index 252946f..9a843c2 100644 --- a/lib/custodian/protocoltest.rb +++ b/lib/custodian/protocoltest.rb @@ -1,3 +1,5 @@ +require 'json' + # # @@ -10,6 +12,7 @@ # derived class for a given line from our configuration # file. # +# TODO: We also wish to create from json. # class ProtocolTest diff --git a/lib/custodian/protocoltest/ftp.rb b/lib/custodian/protocoltest/ftp.rb index 8894de0..1d60e43 100644 --- a/lib/custodian/protocoltest/ftp.rb +++ b/lib/custodian/protocoltest/ftp.rb @@ -59,6 +59,20 @@ class FTPTest < TCPTest # + # Convert this class to JSON such that it may be serialized. + # + def to_json + hash = { + :test_type => 'ftp', + :test_target => @host, + :test_port => @port, + } + hash.to_json + end + + + + # Run the TCP-protocol test. # def run_test diff --git a/lib/custodian/protocoltest/jabber.rb b/lib/custodian/protocoltest/jabber.rb index a9920f0..1aef8b5 100644 --- a/lib/custodian/protocoltest/jabber.rb +++ b/lib/custodian/protocoltest/jabber.rb @@ -57,6 +57,21 @@ class JABBERTest < TCPTest + # + # Convert this class to JSON such that it may be serialized. + # + def to_json + hash = { + :test_type => 'jabber', + :test_target => @host, + :test_port => @port, + } + hash.to_json + end + + + + # # Run the TCP-protocol test. # diff --git a/lib/custodian/protocoltest/rsync.rb b/lib/custodian/protocoltest/rsync.rb index 3b63465..c35758e 100644 --- a/lib/custodian/protocoltest/rsync.rb +++ b/lib/custodian/protocoltest/rsync.rb @@ -58,6 +58,21 @@ class RSYNCTest < TCPTest + # + # Convert this class to JSON such that it may be serialized. + # + def to_json + hash = { + :test_type => 'rsync', + :test_target => @host, + :test_port => @port, + } + hash.to_json + end + + + + # # Run the protocol test. # diff --git a/lib/custodian/protocoltest/smtp.rb b/lib/custodian/protocoltest/smtp.rb index 3a38f5a..dce5ddf 100644 --- a/lib/custodian/protocoltest/smtp.rb +++ b/lib/custodian/protocoltest/smtp.rb @@ -58,6 +58,21 @@ class SMTPTest < TCPTest + # + # Convert this class to JSON such that it may be serialized. + # + def to_json + hash = { + :test_type => 'smtp', + :test_target => @host, + :test_port => @port, + } + hash.to_json + end + + + + # # Run the TCP-protocol test. # diff --git a/lib/custodian/protocoltest/ssh.rb b/lib/custodian/protocoltest/ssh.rb index ec7752f..18f13bc 100644 --- a/lib/custodian/protocoltest/ssh.rb +++ b/lib/custodian/protocoltest/ssh.rb @@ -59,6 +59,22 @@ class SSHTest < TCPTest + # + # Convert this class to JSON such that it may be + # serialized. + # + def to_json + hash = { + :test_type => 'ssh', + :test_target => @host, + :test_port => @port + } + hash.to_json + end + + + + # # Run the TCP-protocol test. # diff --git a/lib/custodian/protocoltest/tcp.rb b/lib/custodian/protocoltest/tcp.rb index 9e141fe..5f29b7f 100644 --- a/lib/custodian/protocoltest/tcp.rb +++ b/lib/custodian/protocoltest/tcp.rb @@ -86,6 +86,22 @@ class TCPTest < ProtocolTest + # + # Convert this class to JSON such that it may be serialized. + # + def to_json + hash = { + :test_type => 'tcp', + :test_target => @host, + :test_port => @port, + :banner => @banner + } + hash.to_json + end + + + + # # Run the TCP-protocol test. # -- cgit v1.2.1