|
From: <jgr...@us...> - 2003-07-26 17:14:45
|
Update of /cvsroot/popfile/engine/tests
In directory sc8-pr-cvs1:/tmp/cvs-serv1930/tests
Modified Files:
TestProxy.tst
Log Message:
Completed test suite for Proxy::Proxy, now have 100% line coverage
Index: TestProxy.tst
===================================================================
RCS file: /cvsroot/popfile/engine/tests/TestProxy.tst,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** TestProxy.tst 26 Jul 2003 16:14:08 -0000 1.9
--- TestProxy.tst 26 Jul 2003 17:14:43 -0000 1.10
***************
*** 267,270 ****
--- 267,342 ----
close TEMP;
+ # Test get_response_ with undefined mail server
+
+ $sp->{connection_timeout_error_} = 'timeout error';
+ open TEMP, ">temp.tmp";
+ test_assert_regexp( $sp->get_response_( undef, \*TEMP, "HELLO" ), 'timeout error' );
+ close TEMP;
+ open TEMP, "<temp.tmp";
+ $line = <TEMP>;
+ test_assert_regexp( $line, 'timeout error' );
+ close TEMP;
+
+ # Test get_response_ with timeout
+
+ $sp->global_config_( 'timeout', 1 );
+ open TEMP, ">temp.tmp";
+ test_assert_regexp( $sp->get_response_( $client, \*TEMP, "HELLO" ), 'timeout error' );
+ close TEMP;
+ open TEMP, "<temp.tmp";
+ $line = <TEMP>;
+ test_assert_regexp( $line, 'timeout error' );
+ close TEMP;
+
+ # Test get_response_ with null response not allowed
+
+ open TEMP, ">temp.tmp";
+ test_assert_equal( $sp->get_response_( $client, \*TEMP, "HELLO", 1 ), '' );
+ close TEMP;
+ open TEMP, "<temp.tmp";
+ $line = <TEMP>;
+ test_assert( !defined( $line ) );
+ close TEMP;
+
+ # Test get_response_ with valid response
+
+ $sp->send( 'HELLO response');
+ $sp->service_server();
+
+ open TEMP, ">temp.tmp";
+ test_assert_regexp( $sp->get_response_( $client, \*TEMP, "HELLO" ), 'HELLO response' );
+ close TEMP;
+ open TEMP, "<temp.tmp";
+ $line = <TEMP>;
+ test_assert_regexp( $line, 'HELLO response' );
+ close TEMP;
+
+ # Test echo_response_ with good response
+
+ $sp->send( 'GOOD');
+ $sp->service_server();
+
+ $sp->{good_response_} = 'GOOD';
+ open TEMP, ">temp.tmp";
+ test_assert( $sp->echo_response_( $client, \*TEMP, "HOWRU?" ) );
+ close TEMP;
+ open TEMP, "<temp.tmp";
+ $line = <TEMP>;
+ test_assert_regexp( $line, 'GOOD' );
+ close TEMP;
+
+ # Test echo_response_ with bad response
+
+ $sp->send( 'BAD');
+ $sp->service_server();
+
+ open TEMP, ">temp.tmp";
+ test_assert( !$sp->echo_response_( $client, \*TEMP, "HOWRU?" ) );
+ close TEMP;
+ open TEMP, "<temp.tmp";
+ $line = <TEMP>;
+ test_assert_regexp( $line, 'BAD' );
+ close TEMP;
+
# Check that we receive the messages sent up the pipe
***************
*** 400,401 ****
--- 472,527 ----
@kids = keys %{$sp->{children__}};
}
+
+ # Test that verify_connected_ does what we expect
+
+ $sp = new Test::SimpleProxy;
+
+ $sp->configuration( $c );
+ $sp->mq( $mq );
+ $sp->logger( $l );
+
+ $sp->forker( \&forker );
+ $sp->pipeready( \&pipeready );
+
+ $sp->initialize();
+ $sp->config_( 'port', $port );
+
+ $sp->{connection_failed_error_} = 'failed error';
+
+ undef $client;
+ open TEMP, ">temp.tmp";
+ test_assert( !defined( $sp->verify_connected_( $client, \*TEMP, 'localhost', $port ) ) );
+ close TEMP;
+ open TEMP, "<temp.tmp";
+ $line = <TEMP>;
+ test_assert_regexp( $line, 'failed error' );
+ test_assert_regexp( $line, 'localhost' );
+ test_assert_regexp( $line, "$port" );
+ close TEMP;
+
+ test_assert( $sp->start() );
+
+ my $sp2 = new Test::SimpleProxy;
+
+ $sp2->configuration( $c );
+ $sp2->mq( $mq );
+ $sp2->logger( $l );
+
+ $sp2->forker( \&forker );
+ $sp2->pipeready( \&pipeready );
+
+ $sp2->initialize();
+ $sp2->config_( 'port', 0 );
+
+ open (STDERR, ">stdout.tmp");
+ test_assert( !$sp2->start() );
+ close STDERR;
+ open TEMP, "<stdout.tmp";
+ $line = <TEMP>;
+ $line = <TEMP>;
+ $line = <TEMP>;
+ test_assert_regexp( $line, "Couldn't start the simple proxy" );
+ close TEMP;
+
+ $sp->stop();
+ $sp2->stop();
\ No newline at end of file
|