Permalink
Browse files

- added tests/docs for Mail::Box::Manager usage

- subclassed type() method to return 'imaps'


git-svn-id: https://dagolden.googlecode.com/svn/Mail-Box-IMAP4-SSL/trunk@1528 dfce27d5-b31c-0410-bb09-030b4413eeba
  • Loading branch information...
1 parent 41a65b1 commit 8400198d2b7b7a6b2ce66993a54ba875fab2ed11 @xdg xdg committed Dec 14, 2007
Showing with 123 additions and 14 deletions.
  1. +4 −0 Changes
  2. +1 −0 MANIFEST
  3. +14 −2 README
  4. +1 −3 Todo
  5. +20 −5 lib/Mail/Box/IMAP4/SSL.pm
  6. +14 −2 lib/Mail/Box/IMAP4/SSL.pod
  7. +10 −2 t/connect.t
  8. +59 −0 t/manager.t
View
@@ -2,6 +2,10 @@ Revision history for Perl module Mail::Box::IMAP4::SSL
0.03 in progress
+ - reports folder type as 'imaps'
+
+ - added documentation for registering type with Mail::Box::Manager
+
- added minimum perl version to Makefile.PL
0.02 Thu Dec 13 07:27:28 EST 2007
View
@@ -18,6 +18,7 @@ t/certs/server-cert.pem
t/certs/server-key.pem
t/connect.t
t/error_handling.t
+t/manager.t
Todo
xt/critic.t
xt/perlcriticrc
View
16 README
@@ -12,12 +12,24 @@ INHERITANCE
is a Mail::Reporter
SYNOPSIS
+ # standalone
use Mail::Box::IMAP4::SSL;
+
my $folder = new Mail::Box::IMAP4::SSL(
username => 'johndoe',
- password => 'x_marks_the_spot',
+ password => 'wbuaqbr',
server_name => 'imap.example.com',
);
+
+ # with Mail::Box::Manager
+ use Mail::Box::Manager;
+
+ my $mbm = Mail::Box::Manager->new;
+ $mbm->registerType( imaps => 'Mail::Box::IMAP4::SSL' );
+
+ my $inbox = $mbm->open(
+ folder => 'imaps://johndoe:wbuaqbr@imap.example.com/INBOX',
+ );
DESCRIPTION
This is a thin subclass of Mail::Box::IMAP4 to provide IMAP over SSL
@@ -31,7 +43,7 @@ METHODS
"Mail::Box::IMAP4::SSL->new( %options )"
my $folder = new Mail::Box::IMAP4::SSL(
username => 'johndoe',
- password => 'x_marks_the_spot',
+ password => 'wbuaqbr',
server_name => 'imap.example.com',
%other_options
);
View
4 Todo
@@ -1,6 +1,4 @@
TODO list for Perl module Mail::Box::IMAP4::SSL
-- Define our type different than IMAP4. When opened via a Mail::Box::Manager,
- be sure to register our type with the manager.
-
+- add some todos
View
@@ -96,11 +96,14 @@ sub init {
}
# now that we have a valid transporter, mark ourselves open
- # and let the superclass take over
+ # and let the superclass initialize
delete $self->{MB_is_closed};
- return $self->SUPER::init($args);
+ $self->SUPER::init($args);
+
}
+sub type {'imaps'}
+
1; #modules must return true
__END__
@@ -129,13 +132,25 @@ This documentation describes version %%VERSION%%.
= SYNOPSIS
+ # standalone
use Mail::Box::IMAP4::SSL;
+
my $folder = new Mail::Box::IMAP4::SSL(
username => 'johndoe',
- password => 'x_marks_the_spot',
+ password => 'wbuaqbr',
server_name => 'imap.example.com',
);
-
+
+ # with Mail::Box::Manager
+ use Mail::Box::Manager;
+
+ my $mbm = Mail::Box::Manager->new;
+ $mbm->registerType( imaps => 'Mail::Box::IMAP4::SSL' );
+
+ my $inbox = $mbm->open(
+ folder => 'imaps://johndoe:wbuaqbr@imap.example.com/INBOX',
+ );
+
= DESCRIPTION
This is a thin subclass of [Mail::Box::IMAP4] to provide IMAP over SSL (aka
@@ -152,7 +167,7 @@ for documentation.
my $folder = new Mail::Box::IMAP4::SSL(
username => 'johndoe',
- password => 'x_marks_the_spot',
+ password => 'wbuaqbr',
server_name => 'imap.example.com',
%other_options
);
View
@@ -20,12 +20,24 @@ This documentation describes version 0.03.
=head1 SYNOPSIS
+ # standalone
use Mail::Box::IMAP4::SSL;
+
my $folder = new Mail::Box::IMAP4::SSL(
username => 'johndoe',
- password => 'x_marks_the_spot',
+ password => 'wbuaqbr',
server_name => 'imap.example.com',
);
+
+ # with Mail::Box::Manager
+ use Mail::Box::Manager;
+
+ my $mbm = Mail::Box::Manager->new;
+ $mbm->registerType( imaps => 'Mail::Box::IMAP4::SSL' );
+
+ my $inbox = $mbm->open(
+ folder => 'imaps://johndoe:wbuaqbr@imap.example.com/INBOX',
+ );
=head1 DESCRIPTION
@@ -42,7 +54,7 @@ for documentation.
my $folder = new Mail::Box::IMAP4::SSL(
username => 'johndoe',
- password => 'x_marks_the_spot',
+ password => 'wbuaqbr',
server_name => 'imap.example.com',
%other_options
);
View
@@ -34,9 +34,9 @@ unless ( $imapd && $imapd->alive ) {
plan skip_all => "Couldn't launch mock imapd on localhost"
}
-plan tests => 4 ;
+plan tests => 7 ;
-my ($stdout, $stderr);
+my ($stdout, $stderr, $rc);
#--------------------------------------------------------------------------#
# tests begin here
@@ -60,3 +60,11 @@ capture sub {
ok( $imap, "connected to mock imapd" );
is( $stderr, q{}, "No warnings during connection" );
+capture sub { $rc = $imap->close } => \$stdout, \$stderr;
+
+ok( $rc, "close() returned true value" );
+ok( $imap->{MB_is_closed}, "internal close flag set" );
+is( $stderr, q{}, "no warnings during close" );
+
+
+
View
@@ -0,0 +1,59 @@
+package main;
+use strict;
+use warnings;
+
+#--------------------------------------------------------------------------#
+# requirements, fixtures and plan
+#--------------------------------------------------------------------------#
+
+use Test::More;
+use Proc::Background;
+use File::Spec;
+use IO::CaptureOutput qw/capture/;
+use Mail::Box::Manager;
+use Probe::Perl;
+
+
+# expected credentials for server and client
+my $username = 'johndoe';
+my $password = '123456';
+my $port = '31415';
+
+# fire up the local mock server or skip tests
+my $imapd = Proc::Background->new(
+ { die_upon_destroy => 1 },
+ Probe::Perl->find_perl_interpreter(),
+ File::Spec->rel2abs(File::Spec->catfile(qw/t bin imapd.pl/)),
+ $port,
+ $username,
+ $password,
+);
+
+sleep 2; # give time for imapd to fire up and listen
+
+unless ( $imapd && $imapd->alive ) {
+ plan skip_all => "Couldn't launch mock imapd on localhost"
+}
+
+plan tests => 3 ;
+
+my ($stdout, $stderr, $rc);
+
+#--------------------------------------------------------------------------#
+# tests begin here
+#--------------------------------------------------------------------------#
+
+ok( $imapd->alive, "mock imapd server is alive" );
+
+my $mbm = Mail::Box::Manager->new;
+
+$mbm->registerType( 'imaps', 'Mail::Box::IMAP4::SSL' );
+
+my $imap = $mbm->open(
+ folder => "imaps://$username\:$password\@127.0.0.1:$port/"
+);
+
+ok( $imap, "connected to mock imapd" );
+is( $imap->type, 'imaps', "imaps folder has correct type" );
+
+

0 comments on commit 8400198

Please sign in to comment.