| 
									
										
										
										
											2009-02-18 16:29:06 -05:00
										 |  |  | USING: calendar ftp.server io.encodings.ascii io.files | 
					
						
							| 
									
										
										
										
											2016-03-19 12:50:01 -04:00
										 |  |  | io.files.temp io.files.unique namespaces threads tools.test | 
					
						
							|  |  |  | kernel io.servers ftp.client accessors urls | 
					
						
							| 
									
										
										
										
											2010-09-19 14:38:02 -04:00
										 |  |  | io.pathnames io.directories sequences fry io.backend | 
					
						
							|  |  |  | continuations ;
 | 
					
						
							| 
									
										
										
										
											2009-05-16 01:29:21 -04:00
										 |  |  | FROM: ftp.client => ftp-get ;
 | 
					
						
							| 
									
										
										
										
											2009-02-18 16:29:06 -05:00
										 |  |  | IN: ftp.server.tests | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-09-19 14:38:02 -04:00
										 |  |  | CONSTANT: test-file-contents "Files are so boring anymore." | 
					
						
							| 
									
										
										
										
											2009-02-18 16:29:06 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | : create-test-file ( -- path )
 | 
					
						
							|  |  |  |     test-file-contents | 
					
						
							| 
									
										
										
										
											2016-03-18 13:57:54 -04:00
										 |  |  |     "ftp.server" "test" unique-file | 
					
						
							| 
									
										
										
										
											2009-10-28 18:25:50 -04:00
										 |  |  |     [ ascii set-file-contents ] [ normalize-path ] bi ;
 | 
					
						
							| 
									
										
										
										
											2009-02-18 16:29:06 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | : test-ftp-server ( quot -- )
 | 
					
						
							| 
									
										
										
										
											2016-03-18 13:57:54 -04:00
										 |  |  |     [ | 
					
						
							|  |  |  |         '[ | 
					
						
							|  |  |  |             "." 0 <ftp-server> [ | 
					
						
							|  |  |  |                 "ftp://localhost" >url insecure-addr set-url-addr | 
					
						
							|  |  |  |                     "ftp" >>protocol | 
					
						
							|  |  |  |                     create-test-file >>path | 
					
						
							|  |  |  |                     @ | 
					
						
							|  |  |  |             ] with-threaded-server | 
					
						
							|  |  |  |         ] cleanup-unique-directory | 
					
						
							|  |  |  |     ] with-temp-directory ; inline
 | 
					
						
							| 
									
										
										
										
											2009-02-18 16:29:06 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-03 12:39:59 -04:00
										 |  |  | { t } | 
					
						
							| 
									
										
										
										
											2009-02-18 16:29:06 -05:00
										 |  |  | [ | 
					
						
							|  |  |  |     [ | 
					
						
							| 
									
										
										
										
											2010-09-19 14:38:02 -04:00
										 |  |  |         [ | 
					
						
							| 
									
										
										
										
											2016-03-18 13:57:54 -04:00
										 |  |  |             [ | 
					
						
							|  |  |  |                 [ ftp-get ] | 
					
						
							|  |  |  |                 [ path>> file-name ascii file-contents ] bi
 | 
					
						
							|  |  |  |             ] cleanup-unique-directory | 
					
						
							|  |  |  |         ] with-temp-directory | 
					
						
							| 
									
										
										
										
											2009-02-18 16:29:06 -05:00
										 |  |  |     ] test-ftp-server test-file-contents =
 | 
					
						
							|  |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ | 
					
						
							| 
									
										
										
										
											2015-07-02 13:34:01 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-18 16:29:06 -05:00
										 |  |  |     [ | 
					
						
							|  |  |  |         "/" >>path | 
					
						
							| 
									
										
										
										
											2010-09-19 14:38:02 -04:00
										 |  |  |         [ | 
					
						
							| 
									
										
										
										
											2016-03-18 13:57:54 -04:00
										 |  |  |             [ | 
					
						
							|  |  |  |                 [ ftp-get ] | 
					
						
							|  |  |  |                 [ path>> file-name ascii file-contents ] bi
 | 
					
						
							|  |  |  |             ] cleanup-unique-directory | 
					
						
							|  |  |  |         ] with-temp-directory | 
					
						
							| 
									
										
										
										
											2009-02-18 16:29:06 -05:00
										 |  |  |     ] test-ftp-server test-file-contents =
 | 
					
						
							|  |  |  | ] must-fail |