factor/basis/io/servers/servers-tests.factor

47 lines
1.1 KiB
Factor
Raw Normal View History

USING: accessors calendar concurrency.promises fry io
io.encodings.ascii io.servers
io.servers.private io.sockets kernel namespaces
sequences threads tools.test ;
IN: io.servers
2008-06-17 01:04:18 -04:00
{ t } [ ascii <threaded-server> listen-on empty? ] unit-test
2008-06-17 01:04:18 -04:00
{ f } [
ascii <threaded-server>
2008-06-17 01:04:18 -04:00
25 internet-server >>insecure
listen-on
empty?
] unit-test
{ t } [
T{ inet4 f "1.2.3.4" 1234 } T{ inet4 f "1.2.3.5" 1235 }
2008-06-17 01:04:18 -04:00
[ log-connection ] 2keep
[ remote-address get = ] [ local-address get = ] bi*
and
] unit-test
{ } [ ascii <threaded-server> init-server drop ] unit-test
2008-06-17 01:04:18 -04:00
{ 10 } [
ascii <threaded-server>
2008-06-17 01:04:18 -04:00
10 >>max-connections
init-server semaphore>> count>>
2008-06-17 01:04:18 -04:00
] unit-test
{ "Hello world." } [
ascii <threaded-server>
2008-06-25 17:58:19 -04:00
5 >>max-connections
0 >>insecure
2008-10-02 09:30:38 -04:00
[ "Hello world." write stop-this-server ] >>handler
[
insecure-addr ascii <client> drop stream-contents
] with-threaded-server
2008-06-17 01:04:18 -04:00
] unit-test
{ } [
ascii <threaded-server>
5 >>max-connections
0 >>insecure
start-server [ '[ _ wait-for-server ] in-thread ] [ stop-server ] bi
] unit-test