[Asterisk-java-cvs] CVS: asterisk-java/src/test/net/sf/asterisk/manager EventBuilderTest.java,NONE,1
Brought to you by:
srt
From: Stefan R. <sr...@us...> - 2005-02-24 00:43:17
|
Update of /cvsroot/asterisk-java/asterisk-java/src/test/net/sf/asterisk/manager In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28524/src/test/net/sf/asterisk/manager Added Files: EventBuilderTest.java Removed Files: TestEventBuilder.java Log Message: --- NEW FILE: EventBuilderTest.java --- /* * Copyright 2004-2005 Stefan Reuter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package net.sf.asterisk.manager; import java.util.HashMap; import java.util.Map; import junit.framework.TestCase; import net.sf.asterisk.manager.event.ChannelEvent; import net.sf.asterisk.manager.event.ManagerEvent; import net.sf.asterisk.manager.event.NewChannelEvent; import net.sf.asterisk.manager.event.NewExtenEvent; import net.sf.asterisk.manager.event.ShutdownEvent; /** * @author srt * @version $Id: EventBuilderTest.java,v 1.1 2005/02/24 00:43:09 srt Exp $ */ public class EventBuilderTest extends TestCase { private EventBuilder eventBuilder; public void setUp() { this.eventBuilder = new EventBuilder(); } public void testRegisterEvent() { eventBuilder.registerEventClass(NewChannelEvent.class); } public void testRegisterEventWithAbstractEvent() { try { eventBuilder.registerEventClass(ChannelEvent.class); fail("registerEvent() must not accept abstract classes"); } catch (IllegalArgumentException ex) { } } public void testRegisterEventWithWrongClass() { try { eventBuilder.registerEventClass(String.class); fail("registerEvent() must only accept subclasses of ManagerEvent"); } catch (IllegalArgumentException ex) { } } /* * public void testGetSetters() { Map setters; EventBuilder eventBuilder = getEventBuilder(); * * setters = eventBuilder.getSetters(NewChannelEvent.class); * * assertTrue("Setter not found", setters.containsKey("callerid")); } */ public void testBuildEventWithMixedCaseSetter() { Map properties = new HashMap(); String callerid = "1234"; NewChannelEvent event; properties.put("event", "Newchannel"); properties.put("callerid", callerid); event = (NewChannelEvent) eventBuilder.buildEvent(this, properties); assertNotNull(event); assertEquals("Returned event is of wrong type", NewChannelEvent.class, event.getClass()); assertEquals("String property not set correctly", callerid, event.getCallerId()); assertEquals("Source not set correctly", this, event.getSource()); } public void testBuildEventWithIntegerProperty() { Map properties = new HashMap(); String channel = "SIP/1234"; Integer priority = new Integer(1); NewExtenEvent event; properties.put("event", "newexten"); properties.put("channel", channel); properties.put("priority", priority.toString()); event = (NewExtenEvent) eventBuilder.buildEvent(this, properties); assertNotNull(event); assertEquals("Returned event is of wrong type", NewExtenEvent.class, event.getClass()); assertEquals("String property not set correctly", channel, event.getChannel()); assertEquals("Integer property not set correctly", priority, event.getPriority()); } public void testBuildEventWithBooleanProperty() { Map properties = new HashMap(); ShutdownEvent event; eventBuilder.registerEventClass(ShutdownEvent.class); properties.put("event", "shutdown"); properties.put("restart", "True"); event = (ShutdownEvent) eventBuilder.buildEvent(this, properties); assertNotNull(event); assertEquals("Returned event is of wrong type", ShutdownEvent.class, event.getClass()); assertEquals("Boolean property not set correctly", Boolean.TRUE, event.getRestart()); } public void testBuildEventWithUnregisteredEvent() { Map properties = new HashMap(); ManagerEvent event; properties.put("event", "Nonexisting"); event = eventBuilder.buildEvent(this, properties); assertNull(event); } } --- TestEventBuilder.java DELETED --- |