root/trunk/tests/test_smtpclient.rb

Revision 668, 1.9 kB (checked in by blackhedd, 1 year ago)

migrated version_0 to trunk

  • Property svn:keywords set to Id
Line 
1 # $Id$
2 #
3 # Author:: Francis Cianfrocca (gmail: blackhedd)
4 # Homepage::  http://rubyeventmachine.com
5 # Date:: 8 April 2006
6 #
7 # See EventMachine and EventMachine::Connection for documentation and
8 # usage examples.
9 #
10 #----------------------------------------------------------------------------
11 #
12 # Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
13 # Gmail: blackhedd
14 #
15 # This program is free software; you can redistribute it and/or modify
16 # it under the terms of either: 1) the GNU General Public License
17 # as published by the Free Software Foundation; either version 2 of the
18 # License, or (at your option) any later version; or 2) Ruby's License.
19 #
20 # See the file COPYING for complete licensing information.
21 #
22 #---------------------------------------------------------------------------
23 #
24 #
25 #
26
27 $:.unshift "../lib"
28 require 'eventmachine'
29 require 'test/unit'
30
31 class TestSmtpClient < Test::Unit::TestCase
32
33         Localhost = "127.0.0.1"
34         Localport = 9801
35
36         def setup
37         end
38
39         def teardown
40         end
41
42         def test_a
43                 # No real tests until we have a server implementation to test against.
44                 # This is what the call looks like, though:
45
46                 EM.run {
47                         d = EM::Protocols::SmtpClient.send :domain=>"example.com",
48                                 :host=>Localhost,
49                                 :port=>Localport, # optional, defaults 25
50                                 :starttls=>true,
51                                 :from=>"sender@example.com",
52                                 :to=> ["to_1@example.com", "to_2@example.com"],
53                                 :header=> {"Subject" => "This is a subject line"},
54                                 :body=> "This is the body of the email",
55                                 :verbose=>true
56                         d.errback {|e|
57                                 p e
58                                 EM.stop
59                         }
60                 }
61         end
62
63         def test_content
64
65                 EM.run {
66                         d = EM::Protocols::SmtpClient.send :domain=>"example.com",
67                                 :host=>Localhost,
68                                 :port=>Localport, # optional, defaults 25
69                                 :starttls=>true,
70                                 :from=>"sender@example.com",
71                                 :to=> ["to_1@example.com", "to_2@example.com"],
72                                 :content => ["Subject: xxx\r\n\r\ndata\r\n.\r\n"],
73                                 :verbose=>true
74                         d.errback {|e|
75                                 p e
76                                 EM.stop
77                         }
78                 }
79         end
80
81 end
Note: See TracBrowser for help on using the browser.