4 * Author:: Francis Cianfrocca (gmail: blackhedd)
5 * Homepage:: http://rubyeventmachine.com
8 * See EventMachine and EventMachine::Connection for documentation and
12 *----------------------------------------------------------------------------
14 * Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of either: 1) the GNU General Public License
19 * as published by the Free Software Foundation; either version 2 of the
20 * License, or (at your option) any later version; or 2) Ruby's License.
22 * See the file COPYING for complete licensing information.
24 *---------------------------------------------------------------------------
31 package com.rubyeventmachine.tests;
34 import org.junit.After;
35 import org.junit.AfterClass;
36 import org.junit.Before;
37 import org.junit.BeforeClass;
38 import org.junit.Test;
39 import org.junit.Assert;
44 import com.rubyeventmachine.*;
45 import com.rubyeventmachine.application.*;
47 public class ApplicationTest {
50 public static void setUpBeforeClass() throws Exception {
54 public static void tearDownAfterClass() throws Exception {
58 public void setUp() throws Exception {
62 public void tearDown() throws Exception {
66 public void testRunnableArgument() {
67 final Application a = new Application();
68 a.run (new Runnable() {
77 class F implements ConnectionFactory {
78 public Connection connection() {
79 return new Connection() {
80 public void receiveData (ByteBuffer bb) {
89 public void testTcpServer() throws EmReactorException {
90 final Application a = new Application();
91 final SocketAddress saddr = new InetSocketAddress ("127.0.0.1", 9008);
92 a.run (new Runnable() {
95 a.startServer (saddr, new F());
96 } catch (EmReactorException e) { Assert.fail(); }
100 Socket s = new Socket ("127.0.0.1", 9008);
101 s.getOutputStream().write(new String ("boo").getBytes());
102 } catch (UnknownHostException e) {
103 } catch (IOException e) {}