Skip to content

Commit

Permalink
- added tests/docs for Mail::Box::Manager usage
Browse files Browse the repository at this point in the history
- 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
xdg committed Dec 14, 2007
1 parent 41a65b1 commit 8400198
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 14 deletions.
4 changes: 4 additions & 0 deletions Changes
Expand Up @@ -2,6 +2,10 @@ Revision history for Perl module Mail::Box::IMAP4::SSL


0.03 in progress 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 - added minimum perl version to Makefile.PL


0.02 Thu Dec 13 07:27:28 EST 2007 0.02 Thu Dec 13 07:27:28 EST 2007
Expand Down
1 change: 1 addition & 0 deletions MANIFEST
Expand Up @@ -18,6 +18,7 @@ t/certs/server-cert.pem
t/certs/server-key.pem t/certs/server-key.pem
t/connect.t t/connect.t
t/error_handling.t t/error_handling.t
t/manager.t
Todo Todo
xt/critic.t xt/critic.t
xt/perlcriticrc xt/perlcriticrc
Expand Down
16 changes: 14 additions & 2 deletions README
Expand Up @@ -12,12 +12,24 @@ INHERITANCE
is a Mail::Reporter is a Mail::Reporter


SYNOPSIS SYNOPSIS
# standalone
use Mail::Box::IMAP4::SSL; use Mail::Box::IMAP4::SSL;

my $folder = new Mail::Box::IMAP4::SSL( my $folder = new Mail::Box::IMAP4::SSL(
username => 'johndoe', username => 'johndoe',
password => 'x_marks_the_spot', password => 'wbuaqbr',
server_name => 'imap.example.com', 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 DESCRIPTION
This is a thin subclass of Mail::Box::IMAP4 to provide IMAP over SSL This is a thin subclass of Mail::Box::IMAP4 to provide IMAP over SSL
Expand All @@ -31,7 +43,7 @@ METHODS
"Mail::Box::IMAP4::SSL->new( %options )" "Mail::Box::IMAP4::SSL->new( %options )"
my $folder = new Mail::Box::IMAP4::SSL( my $folder = new Mail::Box::IMAP4::SSL(
username => 'johndoe', username => 'johndoe',
password => 'x_marks_the_spot', password => 'wbuaqbr',
server_name => 'imap.example.com', server_name => 'imap.example.com',
%other_options %other_options
); );
Expand Down
4 changes: 1 addition & 3 deletions Todo
@@ -1,6 +1,4 @@
TODO list for Perl module Mail::Box::IMAP4::SSL TODO list for Perl module Mail::Box::IMAP4::SSL


- Define our type different than IMAP4. When opened via a Mail::Box::Manager, - add some todos
be sure to register our type with the manager.



25 changes: 20 additions & 5 deletions lib/Mail/Box/IMAP4/SSL.pm
Expand Up @@ -96,11 +96,14 @@ sub init {
} }


# now that we have a valid transporter, mark ourselves open # 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}; delete $self->{MB_is_closed};
return $self->SUPER::init($args); $self->SUPER::init($args);

} }


sub type {'imaps'}

1; #modules must return true 1; #modules must return true


__END__ __END__
Expand Down Expand Up @@ -129,13 +132,25 @@ This documentation describes version %%VERSION%%.
= SYNOPSIS = SYNOPSIS
# standalone
use Mail::Box::IMAP4::SSL; use Mail::Box::IMAP4::SSL;
my $folder = new Mail::Box::IMAP4::SSL( my $folder = new Mail::Box::IMAP4::SSL(
username => 'johndoe', username => 'johndoe',
password => 'x_marks_the_spot', password => 'wbuaqbr',
server_name => 'imap.example.com', 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 = DESCRIPTION
This is a thin subclass of [Mail::Box::IMAP4] to provide IMAP over SSL (aka This is a thin subclass of [Mail::Box::IMAP4] to provide IMAP over SSL (aka
Expand All @@ -152,7 +167,7 @@ for documentation.
my $folder = new Mail::Box::IMAP4::SSL( my $folder = new Mail::Box::IMAP4::SSL(
username => 'johndoe', username => 'johndoe',
password => 'x_marks_the_spot', password => 'wbuaqbr',
server_name => 'imap.example.com', server_name => 'imap.example.com',
%other_options %other_options
); );
Expand Down
16 changes: 14 additions & 2 deletions lib/Mail/Box/IMAP4/SSL.pod
Expand Up @@ -20,12 +20,24 @@ This documentation describes version 0.03.


=head1 SYNOPSIS =head1 SYNOPSIS


# standalone
use Mail::Box::IMAP4::SSL; use Mail::Box::IMAP4::SSL;

my $folder = new Mail::Box::IMAP4::SSL( my $folder = new Mail::Box::IMAP4::SSL(
username => 'johndoe', username => 'johndoe',
password => 'x_marks_the_spot', password => 'wbuaqbr',
server_name => 'imap.example.com', 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 =head1 DESCRIPTION


Expand All @@ -42,7 +54,7 @@ for documentation.


my $folder = new Mail::Box::IMAP4::SSL( my $folder = new Mail::Box::IMAP4::SSL(
username => 'johndoe', username => 'johndoe',
password => 'x_marks_the_spot', password => 'wbuaqbr',
server_name => 'imap.example.com', server_name => 'imap.example.com',
%other_options %other_options
); );
Expand Down
12 changes: 10 additions & 2 deletions t/connect.t
Expand Up @@ -34,9 +34,9 @@ unless ( $imapd && $imapd->alive ) {
plan skip_all => "Couldn't launch mock imapd on localhost" 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 # tests begin here
Expand All @@ -60,3 +60,11 @@ capture sub {
ok( $imap, "connected to mock imapd" ); ok( $imap, "connected to mock imapd" );
is( $stderr, q{}, "No warnings during connection" ); 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" );



59 changes: 59 additions & 0 deletions t/manager.t
@@ -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.