summaryrefslogtreecommitdiff
path: root/test/net/ftp
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-04-01 14:06:38 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-04-01 14:06:38 +0000
commitae79409db498bb04ec5de54f851d0ac7aa8af78d (patch)
tree7bec30c3c70a95eb0a75ee4871146e60dd5e8b00 /test/net/ftp
parent69fa2fe929c2e339d73c8d0dc05d0d9c1fb57f55 (diff)
* lib/net/ftp.rb (Net::BufferedSocket): should delegate send() to @io
for Net::FTP#abort and Net::FTP#status.. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35205 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/net/ftp')
-rw-r--r--test/net/ftp/test_ftp.rb68
1 files changed, 68 insertions, 0 deletions
diff --git a/test/net/ftp/test_ftp.rb b/test/net/ftp/test_ftp.rb
index 998f8e0..f7cbf63 100644
--- a/test/net/ftp/test_ftp.rb
+++ b/test/net/ftp/test_ftp.rb
@@ -512,6 +512,74 @@ class FTPTest < Test::Unit::TestCase
end
end
+ def test_abort
+ commands = []
+ server = create_ftp_server { |sock|
+ sock.print("220 (test_ftp).\r\n")
+ commands.push(sock.gets)
+ sock.print("331 Please specify the password.\r\n")
+ commands.push(sock.gets)
+ sock.print("230 Login successful.\r\n")
+ commands.push(sock.gets)
+ sock.print("200 Switching to Binary mode.\r\n")
+ commands.push(sock.recv(1024, Socket::MSG_OOB))
+ sock.print("225 No transfer to ABOR.\r\n")
+ }
+ begin
+ begin
+ ftp = Net::FTP.new
+ #ftp.read_timeout = 0.2
+ ftp.connect(SERVER_ADDR, server.port)
+ ftp.login
+ assert_match(/\AUSER /, commands.shift)
+ assert_match(/\APASS /, commands.shift)
+ assert_equal("TYPE I\r\n", commands.shift)
+ ftp.abort
+ assert_equal("\n", commands.shift)
+ assert_equal(nil, commands.shift)
+ ensure
+ ftp.close if ftp
+ end
+ ensure
+ server.close
+ end
+ end
+
+ def test_status
+ commands = []
+ server = create_ftp_server { |sock|
+ sock.print("220 (test_ftp).\r\n")
+ commands.push(sock.gets)
+ sock.print("331 Please specify the password.\r\n")
+ commands.push(sock.gets)
+ sock.print("230 Login successful.\r\n")
+ commands.push(sock.gets)
+ sock.print("200 Switching to Binary mode.\r\n")
+ commands.push(sock.recv(1024, Socket::MSG_OOB))
+ sock.print("211-FTP server status:\r\n")
+ sock.print("\n211 End of status\r\n")
+
+ }
+ begin
+ begin
+ ftp = Net::FTP.new
+ #ftp.read_timeout = 0.2
+ ftp.connect(SERVER_ADDR, server.port)
+ ftp.login
+ assert_match(/\AUSER /, commands.shift)
+ assert_match(/\APASS /, commands.shift)
+ assert_equal("TYPE I\r\n", commands.shift)
+ ftp.status
+ assert_equal("\n", commands.shift)
+ assert_equal(nil, commands.shift)
+ ensure
+ ftp.close if ftp
+ end
+ ensure
+ server.close
+ end
+ end
+
private