PageRenderTime 44ms CodeModel.GetById 28ms app.highlight 11ms RepoModel.GetById 1ms app.codeStats 1ms

/protocols/smpp/src/test/java/org/mobicents/protocols/smpp/event/SimpleEventDispatcherTest.java

http://mobicents.googlecode.com/
Java | 73 lines | 41 code | 8 blank | 24 comment | 0 complexity | a9702111e1bee76eda862eaed1b5d959 MD5 | raw file
 1/*
 2 * JBoss, Home of Professional Open Source
 3 * Copyright 2011, Red Hat, Inc. and individual contributors
 4 * by the @authors tag. See the copyright.txt in the distribution for a
 5 * full listing of individual contributors.
 6 *
 7 * This is free software; you can redistribute it and/or modify it
 8 * under the terms of the GNU Lesser General Public License as
 9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */
22
23package org.mobicents.protocols.smpp.event;
24
25import static org.testng.Assert.assertTrue;
26
27import org.easymock.EasyMock;
28import org.testng.annotations.Test;
29
30import org.mobicents.protocols.smpp.Session;
31import org.mobicents.protocols.smpp.event.ReceiverExitEvent;
32import org.mobicents.protocols.smpp.event.SessionObserver;
33import org.mobicents.protocols.smpp.event.SimpleEventDispatcher;
34import org.mobicents.protocols.smpp.message.SMPPPacket;
35import org.mobicents.protocols.smpp.message.SubmitSM;
36
37/**
38 * @version $Id:$
39 */
40@Test
41public class SimpleEventDispatcherTest {
42    
43    public void testConstructWithObserver() {
44        SessionObserver observer1 = EasyMock.createMock(SessionObserver.class);
45        EasyMock.replay(observer1);
46        SimpleEventDispatcher dispatcher = new SimpleEventDispatcher(observer1);
47        assertTrue(dispatcher.contains(observer1));
48        EasyMock.verify(observer1);
49    }
50    
51    public void testNotifyOfEvent() {
52        SessionObserver observer1 = EasyMock.createMock(SessionObserver.class);
53        observer1.update(
54                (Session) EasyMock.isNull(),
55                EasyMock.isA(ReceiverExitEvent.class));
56        EasyMock.replay(observer1);
57        SimpleEventDispatcher dispatcher = new SimpleEventDispatcher(observer1);
58        dispatcher.notifyObservers(null, new ReceiverExitEvent(null));
59        EasyMock.verify(observer1);
60    }
61    
62    public void testNotifyOfPacket() {
63        SessionObserver observer1 = EasyMock.createMock(SessionObserver.class);
64        observer1.packetReceived(
65                (Session) EasyMock.isNull(),
66                EasyMock.isA(SMPPPacket.class));
67        EasyMock.replay(observer1);
68        SimpleEventDispatcher dispatcher = new SimpleEventDispatcher(observer1);
69        assertTrue(dispatcher.contains(observer1));
70        dispatcher.notifyObservers(null, new SubmitSM());
71        EasyMock.verify(observer1);
72    }
73}