A test to ensure Bio::PrimarySeqI->trunc() doesn't use clone() for a Bio::Seq::RichSe...
[bioperl-live.git] / t / Root / HTTPget.t
blobaea8d96c3ac06f7a3ee55425d393a8fe77b0aa4c
1 # -*-Perl-*- Test Harness script for Bioperl
2 # $Id: RootIO.t 16840 2010-02-16 17:14:12Z cjfields $
4 use strict;
5 use warnings;
7 BEGIN {
8     use lib '.';
9     use Bio::Root::Test;
10     
11     test_begin(-tests => 29,
12                -requires_networking => 1);
13         
14     use_ok('Bio::Root::HTTPget');
17 my $TESTURL = 'http://www.google.com/index.html';
19 my $TEST_PROXY = 'http://myproxy';
21 my @TEST_AUTHENTICATION = qw(foo bar);
23 my ($fh, $proxy);
25 my @auth;
27 =head1 Bio::Root::HTTPget comments
29 This module is a bit schizophrenic in that it is called in three different
30 ways; as an instance method, a class method, or as an explicit subroutine.
32 These tests check for all call types.  They are by no means incomplete.
34 =cut 
36 # test object method calls
37 my $obj = Bio::Root::HTTPget->new();
39 ok defined($obj) && $obj->isa('Bio::Root::Root');
41 lives_ok {$obj->get($TESTURL)};
42 lives_ok {$fh = $obj->getFH($TESTURL)};
43 isa_ok($fh, 'IO::Socket::INET');
45 undef($fh);
47 is ($obj->proxy(), undef);
48 is_deeply([$obj->authentication], []);
49 $obj->proxy('http', $TEST_PROXY);
50 $obj->authentication(@TEST_AUTHENTICATION);
51 is ($obj->proxy(), $TEST_PROXY);
52 is_deeply([$obj->authentication], \@TEST_AUTHENTICATION);
54 # test class method calls; note that mixing class and sub calls pollutes the
55 # class attributes
57 lives_ok {Bio::Root::HTTPget->get($TESTURL)};
58 lives_ok {$fh = Bio::Root::HTTPget->getFH($TESTURL)};
59 isa_ok($fh, 'IO::Socket::INET');
61 undef($fh);
63 is (Bio::Root::HTTPget->proxy(), undef);
64 is_deeply([Bio::Root::HTTPget->authentication], []);
65 Bio::Root::HTTPget->proxy('http', $TEST_PROXY);
66 Bio::Root::HTTPget->authentication(@TEST_AUTHENTICATION);
67 is (Bio::Root::HTTPget->proxy('http'), $TEST_PROXY);
68 is_deeply([Bio::Root::HTTPget->authentication], \@TEST_AUTHENTICATION);
70 # test sub calls (not called as method)
72 lives_ok {Bio::Root::HTTPget::get($TESTURL)};
73 lives_ok {$fh = Bio::Root::HTTPget::getFH($TESTURL)};
74 isa_ok($fh, 'IO::Socket::INET');
76 undef($fh);
78 # note that mixing class and sub calls pollutes the class attributes, have to
79 # manually reset
80 Bio::Root::HTTPget->authentication(undef, undef);
82 my $old = Bio::Root::HTTPget->clear_proxy('http');
83 is (Bio::Root::HTTPget::proxy(), undef);
84 is ($old, $TEST_PROXY);
86 is_deeply([Bio::Root::HTTPget->authentication], [undef, undef]);
87 Bio::Root::HTTPget::proxy('http', $TEST_PROXY);
88 Bio::Root::HTTPget::authentication(@TEST_AUTHENTICATION);
89 is (Bio::Root::HTTPget::proxy('http'), $TEST_PROXY);
90 is_deeply([Bio::Root::HTTPget->authentication], \@TEST_AUTHENTICATION);
92 # check to make sure new instance attributes are not polluted by class attrbutes
93 # from previous tests
95 my $newobj = Bio::Root::HTTPget->new();
97 ok defined($newobj) && $obj->isa('Bio::Root::Root');
99 is ($newobj->proxy(), undef);
100 is_deeply([$newobj->authentication], []);
101 $newobj->proxy('http', $TEST_PROXY);
102 $newobj->authentication(@TEST_AUTHENTICATION);
103 is ($newobj->proxy(), $TEST_PROXY);
104 is_deeply([$newobj->authentication], \@TEST_AUTHENTICATION);