| EventListenerTest.java |
1 /*
2 * CVS: $Id: EventListenerTest.java,v 1.4 2004/07/22 18:02:08 marcus Exp $
3 *
4 * This file is part of Zuul.
5 *
6 * Zuul is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * Zuul is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with Zuul; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 * Copyrigth 2004 by marcus, leh
21 *
22 */
23
24package org.jzuul.engine.test;
25
26import junit.framework.TestCase;
27
28import org.jzuul.engine.Event;
29import org.jzuul.engine.EventHandler;
30import org.jzuul.engine.EventListener;
31import org.jzuul.engine.exceptions.NoSuchEventException;
32
33
34
35/**
36 *
37 */
38public class EventListenerTest extends TestCase {
39 EventListener el;
40
41 public void testDoEvent() {
42 // this should not blow up
43 el.doEvent(0);
44 el.doEvent(Event.COUNT - 1);
45 //neither should this
46 try {
47 el.doEvent(Event.COUNT);
48 fail("Illegal argument expected");
49 } catch (IllegalArgumentException e) {
50 // Silent Catch
51 }
52 try {
53 el.doEvent(-1);
54 fail("Illegal argument expected");
55 } catch (IllegalArgumentException e) {
56 // Silent Catch
57 }
58 }
59
60 public void testSetHandler() {
61 //work tests
62 el.setHandler("default", new EventHandler());
63
64 // blow up tests
65 try {
66 el.setHandler("Fooobar", new EventHandler());
67 fail("Exception expected");
68 } catch (NoSuchEventException e) {
69 }
70
71
72 //TODO Fix those tests
73 try {
74 el.setHandler(null, null);
75
76 } catch (IllegalArgumentException e) {
77
78 }
79
80 try {
81 el.setHandler(null, new EventHandler());
82
83 } catch (IllegalArgumentException e) {
84
85 }
86
87 try {
88 el.setHandler("default", null);
89 } catch (IllegalArgumentException e) {
90
91 }
92
93
94 }
95
96}
97