Thread: [Asterisk-java-cvs] CVS: asterisk-java/src/test/net/sf/asterisk/manager/impl A.java,NONE,1.1 UserEve
Brought to you by:
srt
From: Stefan R. <sr...@us...> - 2005-03-15 18:01:56
|
Update of /cvsroot/asterisk-java/asterisk-java/src/test/net/sf/asterisk/manager/impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4812/src/test/net/sf/asterisk/manager/impl Modified Files: EventBuilderImplTest.java Added Files: A.java UserEventDEvent.java BEvent.java UserEventC.java Log Message: Fixed UserEvent registration --- NEW FILE: A.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.impl; import net.sf.asterisk.manager.event.UserEvent; public class A extends UserEvent { private static final long serialVersionUID = 3545240219457894199L; public A(Object source) { super(source); } } --- NEW FILE: UserEventDEvent.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.impl; import net.sf.asterisk.manager.event.UserEvent; public class UserEventDEvent extends UserEvent { private static final long serialVersionUID = 3545240219457894199L; public UserEventDEvent(Object source) { super(source); } } --- NEW FILE: BEvent.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.impl; import net.sf.asterisk.manager.event.UserEvent; public class BEvent extends UserEvent { private static final long serialVersionUID = 3545240219457894199L; public BEvent(Object source) { super(source); } } --- NEW FILE: UserEventC.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.impl; import net.sf.asterisk.manager.event.UserEvent; public class UserEventC extends UserEvent { private static final long serialVersionUID = 3545240219457894199L; public UserEventC(Object source) { super(source); } } Index: EventBuilderImplTest.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/test/net/sf/asterisk/manager/impl/EventBuilderImplTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -p -r1.1 -r1.2 --- EventBuilderImplTest.java 11 Mar 2005 15:27:24 -0000 1.1 +++ EventBuilderImplTest.java 15 Mar 2005 18:01:45 -0000 1.2 @@ -48,6 +48,54 @@ public class EventBuilderImplTest extend eventBuilder.registerEventClass(NewChannelEvent.class); } + public void testRegisterUserEventWithA() + { + Map properties = new HashMap(); + ManagerEvent event; + + eventBuilder.registerEventClass(A.class); + properties.put("event", "UserEventA"); + event = eventBuilder.buildEvent(this, properties); + + assertTrue("Wrong type", event instanceof A); + } + + public void testRegisterUserEventWithBEvent() + { + Map properties = new HashMap(); + ManagerEvent event; + + eventBuilder.registerEventClass(BEvent.class); + properties.put("event", "UserEventB"); + event = eventBuilder.buildEvent(this, properties); + + assertTrue("Wrong type", event instanceof BEvent); + } + + public void testRegisterUserEventWithUserEventC() + { + Map properties = new HashMap(); + ManagerEvent event; + + eventBuilder.registerEventClass(UserEventC.class); + properties.put("event", "UserEventC"); + event = eventBuilder.buildEvent(this, properties); + + assertTrue("Wrong type", event instanceof UserEventC); + } + + public void testRegisterUserEventWithUserEventDEvent() + { + Map properties = new HashMap(); + ManagerEvent event; + + eventBuilder.registerEventClass(UserEventDEvent.class); + properties.put("event", "UserEventD"); + event = eventBuilder.buildEvent(this, properties); + + assertTrue("Wrong type", event instanceof UserEventDEvent); + } + public void testRegisterEventWithAbstractEvent() { try @@ -74,11 +122,9 @@ public class EventBuilderImplTest extend /* * public void testGetSetters() { Map setters; EventBuilderImpl eventBuilder = - * getEventBuilder(); - * - * setters = eventBuilder.getSetters(NewChannelEvent.class); - * - * assertTrue("Setter not found", setters.containsKey("callerid")); } + * getEventBuilder(); setters = + * eventBuilder.getSetters(NewChannelEvent.class); assertTrue("Setter not + * found", setters.containsKey("callerid")); } */ public void testBuildEventWithMixedCaseSetter() @@ -92,8 +138,10 @@ public class EventBuilderImplTest extend 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("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()); } @@ -110,9 +158,12 @@ public class EventBuilderImplTest extend 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()); + 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() @@ -126,8 +177,10 @@ public class EventBuilderImplTest extend 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()); + assertEquals("Returned event is of wrong type", ShutdownEvent.class, + event.getClass()); + assertEquals("Boolean property not set correctly", Boolean.TRUE, event + .getRestart()); } public void testBuildEventWithUnregisteredEvent() @@ -161,8 +214,10 @@ public class EventBuilderImplTest extend event = eventBuilder.buildEvent(this, properties); assertNotNull(event); - assertEquals("Returned event is of wrong type", StatusCompleteEvent.class, event.getClass()); - assertEquals("ActionId not set correctly", "origId", ((ResponseEvent) event).getActionId()); + assertEquals("Returned event is of wrong type", + StatusCompleteEvent.class, event.getClass()); + assertEquals("ActionId not set correctly", "origId", + ((ResponseEvent) event).getActionId()); } public void testBuildEventWithSourceProperty() @@ -175,6 +230,7 @@ public class EventBuilderImplTest extend event = eventBuilder.buildEvent(this, properties); assertNotNull(event); - assertEquals("Src property not set correctly", "source value", ((CdrEvent) event).getSrc()); + assertEquals("Src property not set correctly", "source value", + ((CdrEvent) event).getSrc()); } } |