asterisk-java-cvs Mailing List for Asterisk-Java Library (Page 88)
Brought to you by:
srt
You can subscribe to this list here.
2005 |
Jan
(4) |
Feb
(75) |
Mar
(211) |
Apr
(70) |
May
(12) |
Jun
(7) |
Jul
(96) |
Aug
(90) |
Sep
(11) |
Oct
(42) |
Nov
(45) |
Dec
(4) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(20) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(32) |
Aug
|
Sep
(4) |
Oct
(2) |
Nov
(10) |
Dec
|
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(4) |
Jul
(3) |
Aug
(73) |
Sep
(13) |
Oct
(4) |
Nov
(1) |
Dec
(7) |
2009 |
Jan
(1) |
Feb
(2) |
Mar
(48) |
Apr
(21) |
May
(14) |
Jun
(11) |
Jul
(9) |
Aug
(2) |
Sep
(11) |
Oct
(14) |
Nov
(6) |
Dec
(4) |
2010 |
Jan
(3) |
Feb
(2) |
Mar
|
Apr
|
May
(3) |
Jun
(3) |
Jul
|
Aug
|
Sep
|
Oct
(9) |
Nov
|
Dec
(12) |
2011 |
Jan
(1) |
Feb
(5) |
Mar
(7) |
Apr
(1) |
May
(1) |
Jun
|
Jul
|
Aug
(10) |
Sep
|
Oct
(5) |
Nov
|
Dec
|
2012 |
Jan
(3) |
Feb
|
Mar
(3) |
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
(3) |
Oct
|
Nov
(2) |
Dec
(2) |
2013 |
Jan
|
Feb
(2) |
Mar
(1) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
(3) |
Sep
|
Oct
(2) |
Nov
|
Dec
(1) |
2014 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
(1) |
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
(5) |
2015 |
Jan
(1) |
Feb
|
Mar
|
Apr
(25) |
May
(10) |
Jun
(4) |
Jul
(7) |
Aug
(4) |
Sep
(1) |
Oct
(1) |
Nov
(3) |
Dec
(1) |
2016 |
Jan
|
Feb
(42) |
Mar
(6) |
Apr
(15) |
May
(3) |
Jun
(1) |
Jul
(11) |
Aug
|
Sep
|
Oct
(17) |
Nov
(2) |
Dec
|
2017 |
Jan
|
Feb
(4) |
Mar
(1) |
Apr
(3) |
May
(2) |
Jun
(3) |
Jul
(7) |
Aug
(11) |
Sep
(5) |
Oct
(7) |
Nov
(4) |
Dec
(4) |
2018 |
Jan
(11) |
Feb
(11) |
Mar
(3) |
Apr
|
May
(9) |
Jun
(6) |
Jul
(17) |
Aug
(9) |
Sep
(2) |
Oct
(4) |
Nov
(3) |
Dec
(3) |
2019 |
Jan
(13) |
Feb
(1) |
Mar
(1) |
Apr
|
May
(5) |
Jun
|
Jul
(1) |
Aug
(6) |
Sep
|
Oct
|
Nov
(3) |
Dec
|
2020 |
Jan
(2) |
Feb
(72) |
Mar
(8) |
Apr
(11) |
May
(12) |
Jun
(3) |
Jul
(12) |
Aug
(3) |
Sep
(5) |
Oct
(4) |
Nov
|
Dec
(9) |
2021 |
Jan
|
Feb
(31) |
Mar
(6) |
Apr
(3) |
May
|
Jun
(2) |
Jul
|
Aug
(2) |
Sep
|
Oct
(9) |
Nov
|
Dec
(32) |
2022 |
Jan
(5) |
Feb
(7) |
Mar
(2) |
Apr
(3) |
May
|
Jun
|
Jul
(3) |
Aug
|
Sep
(2) |
Oct
(111) |
Nov
(105) |
Dec
(26) |
2023 |
Jan
(25) |
Feb
(6) |
Mar
(10) |
Apr
(54) |
May
(41) |
Jun
(24) |
Jul
(6) |
Aug
(11) |
Sep
(9) |
Oct
(8) |
Nov
(55) |
Dec
(34) |
2024 |
Jan
(6) |
Feb
(4) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
(89) |
Sep
(48) |
Oct
(31) |
Nov
(9) |
Dec
(19) |
2025 |
Jan
(12) |
Feb
(18) |
Mar
(9) |
Apr
(7) |
May
|
Jun
(7) |
Jul
(5) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Stefan R. <sr...@us...> - 2005-03-13 11:28:10
|
Update of /cvsroot/asterisk-java/asterisk-java/integrationtest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21155/integrationtest Log Message: Directory /cvsroot/asterisk-java/asterisk-java/integrationtest added to the repository |
From: Stefan R. <sr...@us...> - 2005-03-13 11:28:08
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/event In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20829/src/java/net/sf/asterisk/manager/event Modified Files: ManagerEvent.java Log Message: Removed dependcy on commons-lang Index: ManagerEvent.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/event/ManagerEvent.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -p -r1.2 -r1.3 --- ManagerEvent.java 23 Feb 2005 22:50:58 -0000 1.2 +++ ManagerEvent.java 13 Mar 2005 11:26:49 -0000 1.3 @@ -20,16 +20,13 @@ import java.io.Serializable; import java.util.Date; import java.util.EventObject; -import org.apache.commons.lang.builder.EqualsBuilder; -import org.apache.commons.lang.builder.HashCodeBuilder; -import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; - /** - * Abstract base class for all Events that can be received from the Asterisk server.<br> - * Events contain data pertaining to an event generated from within the Asterisk core or an - * extension module.<br> - * There is one conrete subclass of ManagerEvent per each supported Asterisk Event. + * Abstract base class for all Events that can be received from the Asterisk + * server.<br> + * Events contain data pertaining to an event generated from within the Asterisk + * core or an extension module.<br> + * There is one conrete subclass of ManagerEvent per each supported Asterisk + * Event. * * @author srt * @version $Id$ @@ -53,9 +50,11 @@ public abstract class ManagerEvent exten } /** - * Returns the point in time this event was received from the asterisk server.<br> - * Pseudo events that are not directly received from the asterisk server (for example - * ConnectEvent and DisconnectEvent) may return <code>null</code>. + * Returns the point in time this event was received from the asterisk + * server.<br> + * Pseudo events that are not directly received from the asterisk server + * (for example ConnectEvent and DisconnectEvent) may return + * <code>null</code>. */ public Date getDateReceived() { @@ -72,16 +71,13 @@ public abstract class ManagerEvent exten public String toString() { - return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); - } + StringBuffer sb; - public boolean equals(Object o) - { - return EqualsBuilder.reflectionEquals(this, o); - } + sb = new StringBuffer(getClass().getName() + ": "); + sb.append("dateReceived=" + getDateReceived() + "; "); + // TODO print attributes + sb.append("systemHashcode=" + System.identityHashCode(this)); - public int hashCode() - { - return HashCodeBuilder.reflectionHashCode(this); + return sb.toString(); } } |
From: Stefan R. <sr...@us...> - 2005-03-13 11:28:00
|
Update of /cvsroot/asterisk-java/asterisk-java/src/test/net/sf/asterisk/manager In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20829/src/test/net/sf/asterisk/manager Modified Files: DefaultManagerConnectionTest.java Added Files: ChannelStateEnumTest.java Log Message: Removed dependcy on commons-lang --- NEW FILE: ChannelStateEnumTest.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 junit.framework.TestCase; public class ChannelStateEnumTest extends TestCase { public void testGetEnum() { assertEquals(ChannelStateEnum.BUSY, ChannelStateEnum.getEnum("Busy")); } public void testToString() { assertEquals("Busy", ChannelStateEnum.BUSY.toString()); } } Index: DefaultManagerConnectionTest.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/test/net/sf/asterisk/manager/DefaultManagerConnectionTest.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -p -r1.7 -r1.8 --- DefaultManagerConnectionTest.java 9 Mar 2005 15:50:28 -0000 1.7 +++ DefaultManagerConnectionTest.java 13 Mar 2005 11:26:49 -0000 1.8 @@ -17,12 +17,15 @@ package net.sf.asterisk.manager; import java.io.IOException; +import java.util.ArrayList; +import java.util.List; import junit.framework.TestCase; import net.sf.asterisk.io.SocketConnectionFacade; import net.sf.asterisk.manager.action.StatusAction; import net.sf.asterisk.manager.event.ConnectEvent; import net.sf.asterisk.manager.event.DisconnectEvent; +import net.sf.asterisk.manager.event.ManagerEvent; import net.sf.asterisk.manager.response.ManagerResponse; import org.easymock.MockControl; @@ -50,7 +53,8 @@ public class DefaultManagerConnectionTes socketMC = MockControl.createControl(SocketConnectionFacade.class); mockSocket = (SocketConnectionFacade) socketMC.getMock(); - dmc = new MockedDefaultManagerConnection(mockReader, mockWriter, mockSocket); + dmc = new MockedDefaultManagerConnection(mockReader, mockWriter, + mockSocket); // make tests faster that expect a TimeoutException dmc.setSleepTime(5); @@ -62,15 +66,18 @@ public class DefaultManagerConnectionTes public void testDefaultConstructor() { - assertEquals("Invalid default hostname", "localhost", dmc.getAsteriskServer().getHostname()); - assertEquals("Invalid default port", 5038, dmc.getAsteriskServer().getPort()); + assertEquals("Invalid default hostname", "localhost", dmc + .getAsteriskServer().getHostname()); + assertEquals("Invalid default port", 5038, dmc.getAsteriskServer() + .getPort()); } public void testFullConstructor() { dmc = new MockedDefaultManagerConnection("host", 1234, "u", "p"); - assertEquals("Invalid hostname", "host", dmc.getAsteriskServer().getHostname()); + assertEquals("Invalid hostname", "host", dmc.getAsteriskServer() + .getHostname()); assertEquals("Invalid port", 1234, dmc.getAsteriskServer().getPort()); assertEquals("Invalid username", "u", dmc.getUsername()); assertEquals("Invalid password", "p", dmc.getPassword()); @@ -87,11 +94,14 @@ public class DefaultManagerConnectionTes managerReader.registerEventClass(MyUserEvent.class); managerReaderMC.replay(); - dmc = new MockedDefaultManagerConnection(managerReader, mockWriter, mockSocket); + dmc = new MockedDefaultManagerConnection(managerReader, mockWriter, + mockSocket); dmc.registerUserEventClass(MyUserEvent.class); - assertEquals("unexpected call to createSocket", 0, dmc.createSocketCalls); - assertEquals("unexpected call to createWriter", 0, dmc.createWriterCalls); + assertEquals("unexpected call to createSocket", 0, + dmc.createSocketCalls); + assertEquals("unexpected call to createWriter", 0, + dmc.createWriterCalls); assertEquals("createReader not called 1 time", 1, dmc.createReaderCalls); managerReaderMC.verify(); @@ -99,17 +109,13 @@ public class DefaultManagerConnectionTes public void testLogin() throws Exception { - MockControl managerEventHandlerMC; - ManagerEventHandler managerEventHandler; + MockedManagerEventHandler managerEventHandler; ConnectEvent connectEvent; - managerEventHandlerMC = MockControl.createControl(ManagerEventHandler.class); - managerEventHandler = (ManagerEventHandler) managerEventHandlerMC.getMock(); + managerEventHandler = new MockedManagerEventHandler(); connectEvent = new ConnectEvent(asteriskServer); connectEvent.setProtocolIdentifier("Asterisk Call Manager/1.0"); - managerEventHandler.handleEvent(connectEvent); - managerEventHandlerMC.replay(); socketMC.replay(); @@ -122,12 +128,17 @@ public class DefaultManagerConnectionTes assertEquals("createWriter not called 1 time", 1, dmc.createWriterCalls); assertEquals("createReader not called 1 time", 1, dmc.createReaderCalls); - assertEquals("challenge action not sent 1 time", 1, mockWriter.challengeActionsSent); - assertEquals("login action not sent 1 time", 1, mockWriter.loginActionsSent); - assertEquals("unexpected other actions sent", 0, mockWriter.otherActionsSent); + assertEquals("challenge action not sent 1 time", 1, + mockWriter.challengeActionsSent); + assertEquals("login action not sent 1 time", 1, + mockWriter.loginActionsSent); + assertEquals("unexpected other actions sent", 0, + mockWriter.otherActionsSent); - assertEquals("setSocket() not called 1 time", 1, mockReader.setSocketCalls); - // Some time for the reader thread to be started. Otherwise run() might not yet have been + assertEquals("setSocket() not called 1 time", 1, + mockReader.setSocketCalls); + // Some time for the reader thread to be started. Otherwise run() might + // not yet have been // called. Thread.sleep(10); assertEquals("run() not called 1 time", 1, mockReader.runCalls); @@ -135,8 +146,13 @@ public class DefaultManagerConnectionTes assertTrue("keepAlive not set", dmc.getKeepAlive()); + assertEquals("must have handled exactly one event", 1, + managerEventHandler.eventsHandled.size()); + + assertTrue("eventHandled must be a ConnectEvent", + managerEventHandler.eventsHandled.get(0) instanceof ConnectEvent); + socketMC.verify(); - managerEventHandlerMC.verify(); } public void testLoginIncorrectKey() throws Exception @@ -166,12 +182,17 @@ public class DefaultManagerConnectionTes assertEquals("createWriter not called 1 time", 1, dmc.createWriterCalls); assertEquals("createReader not called 1 time", 1, dmc.createReaderCalls); - assertEquals("challenge action not sent 1 time", 1, mockWriter.challengeActionsSent); - assertEquals("login action not sent 1 time", 1, mockWriter.loginActionsSent); - assertEquals("unexpected other actions sent", 0, mockWriter.otherActionsSent); + assertEquals("challenge action not sent 1 time", 1, + mockWriter.challengeActionsSent); + assertEquals("login action not sent 1 time", 1, + mockWriter.loginActionsSent); + assertEquals("unexpected other actions sent", 0, + mockWriter.otherActionsSent); - assertEquals("setSocket() not called 1 time", 1, mockReader.setSocketCalls); - // Some time for the reader thread to be started. Otherwise run() might not yet have been + assertEquals("setSocket() not called 1 time", 1, + mockReader.setSocketCalls); + // Some time for the reader thread to be started. Otherwise run() might + // not yet have been // called. Thread.sleep(10); assertEquals("run() not called 1 time", 1, mockReader.runCalls); @@ -198,11 +219,15 @@ public class DefaultManagerConnectionTes assertEquals("createWriter not called 1 time", 1, dmc.createWriterCalls); assertEquals("createReader not called 1 time", 1, dmc.createReaderCalls); - assertEquals("unexpected challenge action sent", 0, mockWriter.challengeActionsSent); - assertEquals("unexpected login action sent", 0, mockWriter.loginActionsSent); - assertEquals("unexpected other actions sent", 0, mockWriter.otherActionsSent); + assertEquals("unexpected challenge action sent", 0, + mockWriter.challengeActionsSent); + assertEquals("unexpected login action sent", 0, + mockWriter.loginActionsSent); + assertEquals("unexpected other actions sent", 0, + mockWriter.otherActionsSent); - assertEquals("unexpected call to setSocket()", 0, mockReader.setSocketCalls); + assertEquals("unexpected call to setSocket()", 0, + mockReader.setSocketCalls); assertEquals("unexpected call to run()", 0, mockReader.runCalls); assertEquals("unexpected call to die()", 0, mockReader.dieCalls); @@ -224,19 +249,25 @@ public class DefaultManagerConnectionTes } catch (TimeoutException e) { - assertEquals("Timeout waiting for protocol identifier", e.getMessage()); + assertEquals("Timeout waiting for protocol identifier", e + .getMessage()); } assertEquals("createSocket not called 1 time", 1, dmc.createSocketCalls); assertEquals("createWriter not called 1 time", 1, dmc.createWriterCalls); assertEquals("createReader not called 1 time", 1, dmc.createReaderCalls); - assertEquals("unexpected challenge action sent", 0, mockWriter.challengeActionsSent); - assertEquals("unexpected login action sent", 0, mockWriter.loginActionsSent); - assertEquals("unexpected other actions sent", 0, mockWriter.otherActionsSent); + assertEquals("unexpected challenge action sent", 0, + mockWriter.challengeActionsSent); + assertEquals("unexpected login action sent", 0, + mockWriter.loginActionsSent); + assertEquals("unexpected other actions sent", 0, + mockWriter.otherActionsSent); - assertEquals("setSocket() not called 1 time", 1, mockReader.setSocketCalls); - // Some time for the reader thread to be started. Otherwise run() might not yet have been + assertEquals("setSocket() not called 1 time", 1, + mockReader.setSocketCalls); + // Some time for the reader thread to be started. Otherwise run() might + // not yet have been // called. Thread.sleep(10); assertEquals("run() not called 1 time", 1, mockReader.runCalls); @@ -259,19 +290,25 @@ public class DefaultManagerConnectionTes } catch (TimeoutException e) { - assertEquals("Timeout waiting for response to Challenge", e.getMessage()); + assertEquals("Timeout waiting for response to Challenge", e + .getMessage()); } assertEquals("createSocket not called 1 time", 1, dmc.createSocketCalls); assertEquals("createWriter not called 1 time", 1, dmc.createWriterCalls); assertEquals("createReader not called 1 time", 1, dmc.createReaderCalls); - assertEquals("challenge action not sent 1 time", 1, mockWriter.challengeActionsSent); - assertEquals("unexpected login action sent", 0, mockWriter.loginActionsSent); - assertEquals("unexpected other actions sent", 0, mockWriter.otherActionsSent); + assertEquals("challenge action not sent 1 time", 1, + mockWriter.challengeActionsSent); + assertEquals("unexpected login action sent", 0, + mockWriter.loginActionsSent); + assertEquals("unexpected other actions sent", 0, + mockWriter.otherActionsSent); - assertEquals("setSocket() not called 1 time", 1, mockReader.setSocketCalls); - // Some time for the reader thread to be started. Otherwise run() might not yet have been + assertEquals("setSocket() not called 1 time", 1, + mockReader.setSocketCalls); + // Some time for the reader thread to be started. Otherwise run() might + // not yet have been // called. Thread.sleep(10); assertEquals("run() not called 1 time", 1, mockReader.runCalls); @@ -290,7 +327,8 @@ public class DefaultManagerConnectionTes dmc.logoff(); - assertEquals("logoff action not sent 1 time", 1, mockWriter.logoffActionsSent); + assertEquals("logoff action not sent 1 time", 1, + mockWriter.logoffActionsSent); socketMC.verify(); } @@ -300,7 +338,8 @@ public class DefaultManagerConnectionTes dmc.logoff(); - assertEquals("unexpected logoff action sent", 0, mockWriter.logoffActionsSent); + assertEquals("unexpected logoff action sent", 0, + mockWriter.logoffActionsSent); socketMC.verify(); } @@ -346,10 +385,12 @@ public class DefaultManagerConnectionTes dmc.connect(); response = dmc.sendAction(statusAction); - assertEquals("incorrect actionId in response", "123", response.getActionId()); + assertEquals("incorrect actionId in response", "123", response + .getActionId()); assertEquals("incorrect response", "Success", response.getResponse()); - assertEquals("other actions not sent 1 time", 1, mockWriter.otherActionsSent); + assertEquals("other actions not sent 1 time", 1, + mockWriter.otherActionsSent); } public void testSendActionTimeout() throws Exception @@ -372,7 +413,8 @@ public class DefaultManagerConnectionTes { } - assertEquals("other actions not sent 1 time", 1, mockWriter.otherActionsSent); + assertEquals("other actions not sent 1 time", 1, + mockWriter.otherActionsSent); } public void testDispatchResponseUnexpectedResponse() @@ -437,9 +479,12 @@ public class DefaultManagerConnectionTes assertEquals("createWriter not called 1 time", 1, dmc.createWriterCalls); assertEquals("createReader not called 1 time", 1, dmc.createReaderCalls); - assertEquals("challenge action not sent 1 time", 1, mockWriter.challengeActionsSent); - assertEquals("login action not sent 1 time", 1, mockWriter.loginActionsSent); - assertEquals("unexpected other actions sent", 0, mockWriter.otherActionsSent); + assertEquals("challenge action not sent 1 time", 1, + mockWriter.challengeActionsSent); + assertEquals("login action not sent 1 time", 1, + mockWriter.loginActionsSent); + assertEquals("unexpected other actions sent", 0, + mockWriter.otherActionsSent); assertTrue("keepAlive not enabled", dmc.getKeepAlive()); @@ -467,9 +512,12 @@ public class DefaultManagerConnectionTes assertEquals("createWriter not called 1 time", 1, dmc.createWriterCalls); assertEquals("createReader not called 1 time", 1, dmc.createReaderCalls); - assertEquals("challenge action not sent 1 time", 1, mockWriter.challengeActionsSent); - assertEquals("login action not sent 1 time", 1, mockWriter.loginActionsSent); - assertEquals("unexpected other actions sent", 0, mockWriter.otherActionsSent); + assertEquals("challenge action not sent 1 time", 1, + mockWriter.challengeActionsSent); + assertEquals("login action not sent 1 time", 1, + mockWriter.loginActionsSent); + assertEquals("unexpected other actions sent", 0, + mockWriter.otherActionsSent); assertTrue("keepAlive not enabled", dmc.getKeepAlive()); @@ -495,16 +543,20 @@ public class DefaultManagerConnectionTes assertEquals("createWriter not called 1 time", 1, dmc.createWriterCalls); assertEquals("createReader not called 1 time", 1, dmc.createReaderCalls); - assertEquals("challenge action not sent 1 time", 1, mockWriter.challengeActionsSent); - assertEquals("login action not sent 1 time", 1, mockWriter.loginActionsSent); - assertEquals("unexpected other actions sent", 0, mockWriter.otherActionsSent); + assertEquals("challenge action not sent 1 time", 1, + mockWriter.challengeActionsSent); + assertEquals("login action not sent 1 time", 1, + mockWriter.loginActionsSent); + assertEquals("unexpected other actions sent", 0, + mockWriter.otherActionsSent); assertFalse("keepAlive not disabled", dmc.getKeepAlive()); socketMC.verify(); } - public void testReconnectWithKeepAliveAfterAuthenticationFailure() throws Exception + public void testReconnectWithKeepAliveAfterAuthenticationFailure() + throws Exception { DisconnectEvent disconnectEvent; @@ -517,7 +569,8 @@ public class DefaultManagerConnectionTes // fake successful login dmc.setKeepAlive(true); - // to prevent an infinite loop we will be able to log in after two unsuccessful attempts + // to prevent an infinite loop we will be able to log in after two + // unsuccessful attempts // even if the password is not correct. dmc.setKeepAliveAfterAuthenticationFailure(true); dmc.setUsername("username"); @@ -528,16 +581,36 @@ public class DefaultManagerConnectionTes assertEquals("createWriter not called 1 time", 1, dmc.createWriterCalls); assertEquals("createReader not called 1 time", 1, dmc.createReaderCalls); - assertEquals("challenge action not sent 3 time", 3, mockWriter.challengeActionsSent); - assertEquals("login action not sent 3 time", 3, mockWriter.loginActionsSent); - assertEquals("unexpected other actions sent", 0, mockWriter.otherActionsSent); + assertEquals("challenge action not sent 3 time", 3, + mockWriter.challengeActionsSent); + assertEquals("login action not sent 3 time", 3, + mockWriter.loginActionsSent); + assertEquals("unexpected other actions sent", 0, + mockWriter.otherActionsSent); assertTrue("keepAlive not enabled", dmc.getKeepAlive()); socketMC.verify(); } - private class MockedDefaultManagerConnection extends DefaultManagerConnection + private class MockedManagerEventHandler implements ManagerEventHandler + { + List eventsHandled; + + public MockedManagerEventHandler() + { + this.eventsHandled = new ArrayList(); + } + + public void handleEvent(ManagerEvent event) + { + eventsHandled.add(event); + } + } + + private class MockedDefaultManagerConnection + extends + DefaultManagerConnection { ManagerReader mockReader; ManagerWriter mockWriter; @@ -549,8 +622,8 @@ public class DefaultManagerConnectionTes public int createWriterCalls = 0; public int createSocketCalls = 0; - public MockedDefaultManagerConnection(ManagerReader mockReader, ManagerWriter mockWriter, - SocketConnectionFacade mockSocket) + public MockedDefaultManagerConnection(ManagerReader mockReader, + ManagerWriter mockWriter, SocketConnectionFacade mockSocket) { super(); this.mockReader = mockReader; @@ -558,12 +631,14 @@ public class DefaultManagerConnectionTes this.mockSocket = mockSocket; } - public MockedDefaultManagerConnection(String hostname, int port, String username, String password) + public MockedDefaultManagerConnection(String hostname, int port, + String username, String password) { super(hostname, port, username, password); } - public void setThrowIOExceptionOnFirstSocketCreate(boolean throwIOExceptionOnSocketCreate) + public void setThrowIOExceptionOnFirstSocketCreate( + boolean throwIOExceptionOnSocketCreate) { this.throwIOExceptionOnFirstSocketCreate = throwIOExceptionOnSocketCreate; } |
From: Stefan R. <sr...@us...> - 2005-03-13 11:28:00
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20829/src/java/net/sf/asterisk/fastagi/command Modified Files: AGICommand.java Log Message: Removed dependcy on commons-lang Index: AGICommand.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/command/AGICommand.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -p -r1.3 -r1.4 --- AGICommand.java 8 Mar 2005 16:48:34 -0000 1.3 +++ AGICommand.java 13 Mar 2005 11:26:48 -0000 1.4 @@ -18,11 +18,6 @@ package net.sf.asterisk.fastagi.command; import java.io.Serializable; -import org.apache.commons.lang.builder.EqualsBuilder; -import org.apache.commons.lang.builder.HashCodeBuilder; -import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; - /** * Abstract base class for all commands supported by asterisk's FastAGI. * @@ -60,17 +55,12 @@ public abstract class AGICommand impleme public String toString() { - return ToStringBuilder.reflectionToString(this, - ToStringStyle.MULTI_LINE_STYLE); - } + StringBuffer sb; - public boolean equals(Object o) - { - return EqualsBuilder.reflectionEquals(this, o); - } + sb = new StringBuffer(getClass().getName() + ": "); + sb.append("command='" + buildCommand() + "'; "); + sb.append("systemHashcode=" + System.identityHashCode(this)); - public int hashCode() - { - return HashCodeBuilder.reflectionHashCode(this); + return sb.toString(); } } |
From: Stefan R. <sr...@us...> - 2005-03-13 11:28:00
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20829/src/java/net/sf/asterisk/manager Modified Files: ChannelStateEnum.java Channel.java Log Message: Removed dependcy on commons-lang Index: ChannelStateEnum.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/ChannelStateEnum.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -p -r1.2 -r1.3 --- ChannelStateEnum.java 23 Feb 2005 22:50:57 -0000 1.2 +++ ChannelStateEnum.java 13 Mar 2005 11:26:48 -0000 1.3 @@ -16,24 +16,27 @@ */ package net.sf.asterisk.manager; -import java.util.Iterator; -import java.util.List; +import java.io.Serializable; +import java.util.HashMap; import java.util.Map; -import org.apache.commons.lang.enums.Enum; - /** * Enumeration that represents the state of a channel. * * @author srt * @version $Id$ */ -public class ChannelStateEnum extends Enum +public class ChannelStateEnum implements Serializable { /** * Serializable version identifier */ private static final long serialVersionUID = 6436381500165485011L; + + private static Map literals = new HashMap(); + + private String state; + public static final ChannelStateEnum DOWN = new ChannelStateEnum("Down"); public static final ChannelStateEnum OFF_HOOK = new ChannelStateEnum("OffHook"); public static final ChannelStateEnum DIALING = new ChannelStateEnum("Dialing"); @@ -46,27 +49,17 @@ public class ChannelStateEnum extends En private ChannelStateEnum(String state) { - super(state); + this.state = state; + literals.put(state, this); } public static ChannelStateEnum getEnum(String state) { - return (ChannelStateEnum) getEnum(ChannelStateEnum.class, state); - } - - public static Map getEnumMap() - { - return getEnumMap(ChannelStateEnum.class); - } - - public static List getEnumList() - { - return getEnumList(ChannelStateEnum.class); + return (ChannelStateEnum) literals.get(state); } - public static Iterator iterator() + public String toString() { - return iterator(ChannelStateEnum.class); + return state; } - } Index: Channel.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/Channel.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -p -r1.3 -r1.4 --- Channel.java 23 Feb 2005 22:50:57 -0000 1.3 +++ Channel.java 13 Mar 2005 11:26:48 -0000 1.4 @@ -19,9 +19,6 @@ package net.sf.asterisk.manager; import java.io.Serializable; import java.util.Date; -import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; - /** * @author srt * @version $Id$ @@ -71,8 +68,8 @@ public class Channel implements Serializ private Date dateOfCreation; /** - * If this channel is bridged to another channel, the linkedChannel contains the channel this - * channel is bridged with. + * If this channel is bridged to another channel, the linkedChannel contains + * the channel this channel is bridged with. */ private Channel linkedChannel; @@ -95,7 +92,8 @@ public class Channel implements Serializ * @param id unique id of this channel, for example "1099015093.165". * @param server the Asterisk server this channel exists on. */ - public Channel(final String name, final String id, final AsteriskServer server) + public Channel(final String name, final String id, + final AsteriskServer server) { this.name = name; this.id = id; @@ -285,8 +283,8 @@ public class Channel implements Serializ /** * Returns the channel this channel is bridged with, if any. * - * @return the channel this channel is bridged with, or <code>null</code> if this channel is - * currently not bridged to another channel. + * @return the channel this channel is bridged with, or <code>null</code> + * if this channel is currently not bridged to another channel. */ public final Channel getLinkedChannel() { @@ -303,23 +301,38 @@ public class Channel implements Serializ this.linkedChannel = linkedChannel; } - public boolean equals(Object obj) + public String toString() { - if (!(obj instanceof Channel)) + StringBuffer sb; + + sb = new StringBuffer(getClass().getName() + ": "); + sb.append("id='" + getId() + "'; "); + sb.append("name='" + getName() + "'; "); + sb.append("callerId='" + getCallerId() + "'; "); + sb.append("state='" + getState() + "'; "); + sb.append("account='" + getAccount() + "'; "); + sb.append("context='" + getContext() + "'; "); + sb.append("extension='" + getExtension() + "'; "); + sb.append("priority='" + getPriority() + "'; "); + sb.append("application='" + getApplication() + "'; "); + sb.append("appData='" + getAppData() + "'; "); + sb.append("dateOfCreation=" + getDateOfCreation() + "; "); + if (linkedChannel == null) { - return false; + sb.append("linkedChannel=null; "); } + else + { + sb.append("linkedChannel=["); + sb.append(linkedChannel.getClass().getName() + ": "); + sb.append("id='" + linkedChannel.getId() + "'; "); + sb.append("name='" + linkedChannel.getName() + "'; "); + sb.append("systemHashcode=" + + System.identityHashCode(linkedChannel)); + sb.append("]; "); + } + sb.append("systemHashcode=" + System.identityHashCode(this)); - return id.equals(((Channel) obj).getId()); - } - - public int hashCode() - { - return id.hashCode(); - } - - public String toString() - { - return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); + return sb.toString(); } } |
From: Stefan R. <sr...@us...> - 2005-03-13 11:27:59
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/action In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20829/src/java/net/sf/asterisk/manager/action Modified Files: ManagerAction.java Log Message: Removed dependcy on commons-lang Index: ManagerAction.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/action/ManagerAction.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -p -r1.2 -r1.3 --- ManagerAction.java 23 Feb 2005 22:50:58 -0000 1.2 +++ ManagerAction.java 13 Mar 2005 11:26:49 -0000 1.3 @@ -18,11 +18,6 @@ package net.sf.asterisk.manager.action; import java.io.Serializable; -import org.apache.commons.lang.builder.EqualsBuilder; -import org.apache.commons.lang.builder.HashCodeBuilder; -import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; - /** * Abstract base class for all Actions that can be sent to the Asterisk server.<br> * Instances of this class represent a command sent to Asterisk, requesting a particular Action be @@ -68,16 +63,13 @@ public abstract class ManagerAction impl public String toString() { - return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); - } - - public boolean equals(Object o) - { - return EqualsBuilder.reflectionEquals(this, o); - } + StringBuffer sb; + + sb = new StringBuffer(getClass().getName() + ": "); + sb.append("action='" + getAction() + "'; "); + //TODO print attributes + sb.append("systemHashcode=" + System.identityHashCode(this)); - public int hashCode() - { - return HashCodeBuilder.reflectionHashCode(this); + return sb.toString(); } } |
From: Stefan R. <sr...@us...> - 2005-03-13 11:27:46
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/response In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20829/src/java/net/sf/asterisk/manager/response Modified Files: ManagerError.java ManagerResponse.java Log Message: Removed dependcy on commons-lang Index: ManagerError.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/response/ManagerError.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -p -r1.2 -r1.3 --- ManagerError.java 23 Feb 2005 22:50:58 -0000 1.2 +++ ManagerError.java 13 Mar 2005 11:26:49 -0000 1.3 @@ -16,12 +16,9 @@ */ package net.sf.asterisk.manager.response; -import org.apache.commons.lang.builder.EqualsBuilder; -import org.apache.commons.lang.builder.HashCodeBuilder; - /** - * Represents an "Response: Error" response received from the asterisk server. The cause for the - * error is given in the message attribute. + * Represents an "Response: Error" response received from the asterisk server. + * The cause for the error is given in the message attribute. * * @author srt * @version $Id$ @@ -34,20 +31,10 @@ public class ManagerError extends Manage static final long serialVersionUID = -8753149536715547476L; /** - * + * Creates a new ManagerError. */ public ManagerError() { } - - public boolean equals(Object o) - { - return EqualsBuilder.reflectionEquals(this, o); - } - - public int hashCode() - { - return HashCodeBuilder.reflectionHashCode(this); - } } Index: ManagerResponse.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/response/ManagerResponse.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -p -r1.2 -r1.3 --- ManagerResponse.java 23 Feb 2005 22:50:58 -0000 1.2 +++ ManagerResponse.java 13 Mar 2005 11:26:49 -0000 1.3 @@ -19,15 +19,12 @@ package net.sf.asterisk.manager.response import java.io.Serializable; import java.util.Date; -import org.apache.commons.lang.builder.EqualsBuilder; -import org.apache.commons.lang.builder.HashCodeBuilder; -import org.apache.commons.lang.builder.ToStringBuilder; - /** - * Represents a response received from the Asterisk server as the result of a previously sent - * ManagerAction.<br> - * The response can be linked with the action that caused it by looking the action id attribute that - * will match the action id of the corresponding action. + * Represents a response received from the Asterisk server as the result of a + * previously sent ManagerAction.<br> + * The response can be linked with the action that caused it by looking the + * action id attribute that will match the action id of the corresponding + * action. * * @see net.sf.asterisk.manager.action.ManagerAction * @author srt @@ -47,7 +44,8 @@ public class ManagerResponse implements private String uniqueId; /** - * Returns the point in time this response was received from the asterisk server. + * Returns the point in time this response was received from the asterisk + * server. */ public Date getDateReceived() { @@ -55,7 +53,8 @@ public class ManagerResponse implements } /** - * Sets the point in time this response was received from the asterisk server. + * Sets the point in time this response was received from the asterisk + * server. */ public void setDateReceived(Date dateReceived) { @@ -63,8 +62,8 @@ public class ManagerResponse implements } /** - * Returns the action id received with this response referencing the action that generated this - * response. + * Returns the action id received with this response referencing the action + * that generated this response. */ public String getActionId() { @@ -80,8 +79,8 @@ public class ManagerResponse implements } /** - * Returns the message received with this response. The content depends on the action that - * generated this response. + * Returns the message received with this response. The content depends on + * the action that generated this response. */ public String getMessage() { @@ -97,8 +96,9 @@ public class ManagerResponse implements } /** - * Returns the value of the "Response:" line. This typically a String like "Success" or "Error" - * but depends on the action that generated this response. + * Returns the value of the "Response:" line. This typically a String like + * "Success" or "Error" but depends on the action that generated this + * response. */ public String getResponse() { @@ -114,8 +114,9 @@ public class ManagerResponse implements } /** - * Returns the unique id received with this response. The unique id is used to keep track of - * channels created by the action sent, for example an OriginateAction. + * Returns the unique id received with this response. The unique id is used + * to keep track of channels created by the action sent, for example an + * OriginateAction. */ public String getUniqueId() { @@ -130,18 +131,17 @@ public class ManagerResponse implements this.uniqueId = uniqueId; } - final public String toString() + public String toString() { - return ToStringBuilder.reflectionToString(this); - } + StringBuffer sb; - public boolean equals(Object o) - { - return EqualsBuilder.reflectionEquals(this, o); - } + sb = new StringBuffer(getClass().getName() + ": "); + sb.append("actionId='" + getActionId() + "'; "); + sb.append("message='" + getMessage() + "'; "); + sb.append("response='" + getResponse() + "'; "); + sb.append("uniqueId='" + getUniqueId() + "'; "); + sb.append("systemHashcode=" + System.identityHashCode(this)); - public int hashCode() - { - return HashCodeBuilder.reflectionHashCode(this); + return sb.toString(); } } |
From: Stefan R. <sr...@us...> - 2005-03-13 11:27:46
|
Update of /cvsroot/asterisk-java/asterisk-java In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20829 Modified Files: project.properties project.xml Log Message: Removed dependcy on commons-lang Index: project.properties =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/project.properties,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -p -r1.5 -r1.6 --- project.properties 26 Feb 2005 20:12:28 -0000 1.5 +++ project.properties 13 Mar 2005 11:26:48 -0000 1.6 @@ -17,8 +17,8 @@ maven.repo.asterisk-java.directory = /va maven.repo.asterisk-java.username = ${maven.username} maven.jar.override = on -maven.jar.commons-lang = lib/commons-lang-2.0.jar maven.jar.clover-ant=1.3.3_01 +maven.jar.mainclass=net.sf.asterisk.Main maven.clover.license.path=lib/clover/clover.license maven.checkstyle.properties = checkstyle.xml Index: project.xml =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/project.xml,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -p -r1.9 -r1.10 --- project.xml 10 Mar 2005 23:16:10 -0000 1.9 +++ project.xml 13 Mar 2005 11:26:48 -0000 1.10 @@ -110,14 +110,6 @@ <url>http://jakarta.apache.org/commons/logging/</url> </dependency> <dependency> - <groupId>commons-lang</groupId> - <artifactId>commons-lang</artifactId> - <version>2.0</version> - <jar>lib/commons-lang-2.0.jar</jar> - <type>jar</type> - <url>http://jakarta.apache.org/commons/lang/</url> - </dependency> - <dependency> <groupId>easymock</groupId> <artifactId>easymock</artifactId> <version>1.1</version> @@ -134,15 +126,16 @@ <includes> <include>**/*Test.java</include> </includes> - <excludes> - <exclude>**/RepositoryTest.java</exclude> - </excludes> - <resources><resource> -<directory>${basedir}/src/resources/fastagi</directory> - <includes> - <include>test-mapping.properties</include> - </includes> </resource></resources> - </unitTest> + <resources> + <resource> + <directory>${basedir}/src/resources/fastagi</directory> + <includes> + <include>test-mapping.properties</include> + </includes> + <filtering>false</filtering> + </resource> + </resources> + </unitTest> </build> </project> |
From: Stefan R. <sr...@us...> - 2005-03-13 11:27:36
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/reply In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20829/src/java/net/sf/asterisk/fastagi/reply Modified Files: AGIReply.java Log Message: Removed dependcy on commons-lang Index: AGIReply.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/reply/AGIReply.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -p -r1.10 -r1.11 --- AGIReply.java 11 Mar 2005 13:40:06 -0000 1.10 +++ AGIReply.java 13 Mar 2005 11:26:51 -0000 1.11 @@ -20,11 +20,6 @@ import java.io.Serializable; import java.util.HashMap; import java.util.Map; -import org.apache.commons.lang.builder.EqualsBuilder; -import org.apache.commons.lang.builder.HashCodeBuilder; -import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; - /** * Reply received in response to an AGICommand.<br> * The AGIReply contains information about success or failure of the execution @@ -33,7 +28,6 @@ import org.apache.commons.lang.builder.T * GetVariableCommand. * * @see net.sf.asterisk.fastagi.command.AGICommand - * * @author srt * @version $Id$ */ @@ -296,17 +290,22 @@ public class AGIReply implements Seriali public String toString() { - return ToStringBuilder.reflectionToString(this, - ToStringStyle.MULTI_LINE_STYLE); - } + StringBuffer sb; - public boolean equals(Object o) - { - return EqualsBuilder.reflectionEquals(this, o); - } + sb = new StringBuffer(getClass().getName() + ": "); + sb.append("status='" + getStatus() + "'; "); + if (status == SC_SUCCESS) + { + sb.append("result='" + getResult() + "'; "); + sb.append("extra='" + getExtra() + "'; "); + sb.append("attributes=" + attributes + "; "); + } + if (status == SC_INVALID_COMMAND_SYNTAX) + { + sb.append("synopsis='" + getSynopsis() + "'; "); + } + sb.append("systemHashcode=" + System.identityHashCode(this)); - public int hashCode() - { - return HashCodeBuilder.reflectionHashCode(this); + return sb.toString(); } } |
From: Stefan R. <sr...@us...> - 2005-03-13 11:27:36
|
Update of /cvsroot/asterisk-java/asterisk-java/src/test/net/sf/asterisk/manager/impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20829/src/test/net/sf/asterisk/manager/impl Modified Files: ManagerReaderImplTest.java Log Message: Removed dependcy on commons-lang Index: ManagerReaderImplTest.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/test/net/sf/asterisk/manager/impl/ManagerReaderImplTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -p -r1.2 -r1.3 --- ManagerReaderImplTest.java 11 Mar 2005 15:31:47 -0000 1.2 +++ ManagerReaderImplTest.java 13 Mar 2005 11:26:51 -0000 1.3 @@ -29,6 +29,7 @@ import net.sf.asterisk.manager.ManagerRe import net.sf.asterisk.manager.MyUserEvent; import net.sf.asterisk.manager.event.ConnectEvent; import net.sf.asterisk.manager.event.DisconnectEvent; +import net.sf.asterisk.manager.event.ManagerEvent; import net.sf.asterisk.manager.event.StatusCompleteEvent; import net.sf.asterisk.manager.response.CommandResponse; import net.sf.asterisk.manager.response.ManagerResponse; @@ -39,8 +40,7 @@ import org.easymock.MockControl; public class ManagerReaderImplTest extends TestCase { private Date now; - private MockControl dispatcherMC; - private Dispatcher dispatcher; + private MockedDispatcher dispatcher; private MockControl socketConnectionFacadeMC; private SocketConnectionFacade socketConnectionFacade; private AsteriskServer asteriskServer; @@ -51,12 +51,13 @@ public class ManagerReaderImplTest exten now = new Date(); DateUtil.overrideCurrentDate(now); asteriskServer = new AsteriskServer(); - dispatcherMC = MockControl.createControl(Dispatcher.class); - dispatcher = (Dispatcher) dispatcherMC.getMock(); + dispatcher = new MockedDispatcher(); managerReader = new ManagerReaderImpl(dispatcher, asteriskServer); - socketConnectionFacadeMC = MockControl.createControl(SocketConnectionFacade.class); - socketConnectionFacade = (SocketConnectionFacade) socketConnectionFacadeMC.getMock(); + socketConnectionFacadeMC = MockControl + .createControl(SocketConnectionFacade.class); + socketConnectionFacade = (SocketConnectionFacade) socketConnectionFacadeMC + .getMock(); } protected void tearDown() @@ -73,7 +74,8 @@ public class ManagerReaderImplTest exten } catch (IllegalStateException e) { - assertTrue("Exception must be of type IllegalStateException", e instanceof IllegalStateException); + assertTrue("Exception must be of type IllegalStateException", + e instanceof IllegalStateException); } } @@ -87,23 +89,35 @@ public class ManagerReaderImplTest exten socketConnectionFacade.readLine(); socketConnectionFacadeMC.setReturnValue(null); - connectEvent = new ConnectEvent(asteriskServer); - connectEvent.setProtocolIdentifier("Asterisk Call Manager/1.0"); - connectEvent.setDateReceived(now); - dispatcher.dispatchEvent(connectEvent); - - disconnectEvent = new DisconnectEvent(asteriskServer); - disconnectEvent.setDateReceived(now); - dispatcher.dispatchEvent(disconnectEvent); - socketConnectionFacadeMC.replay(); - dispatcherMC.replay(); managerReader.setSocket(socketConnectionFacade); managerReader.run(); socketConnectionFacadeMC.verify(); - dispatcherMC.verify(); + + assertEquals("not exactly two events dispatched", 2, + dispatcher.dispatchedEvents.size()); + + assertEquals("first event must be a ConnectEvent", ConnectEvent.class, + dispatcher.dispatchedEvents.get(0).getClass()); + + assertEquals("ConnectEvent contains incorrect protocol identifier", + "Asterisk Call Manager/1.0", + ((ConnectEvent) dispatcher.dispatchedEvents.get(0)) + .getProtocolIdentifier()); + + assertEquals("ConnectEvent contains incorrect dateReceived", now, + ((ConnectEvent) dispatcher.dispatchedEvents.get(0)) + .getDateReceived()); + + assertEquals("second event must be a DisconnectEvent", + DisconnectEvent.class, dispatcher.dispatchedEvents.get(1) + .getClass()); + + assertEquals("DisconnectEvent contains incorrect dateReceived", now, + ((DisconnectEvent) dispatcher.dispatchedEvents.get(1)) + .getDateReceived()); } public void testRunReceivingEvent() throws Exception @@ -118,22 +132,23 @@ public class ManagerReaderImplTest exten socketConnectionFacade.readLine(); socketConnectionFacadeMC.setReturnValue(null); - statusCompleteEvent = new StatusCompleteEvent(asteriskServer); - statusCompleteEvent.setDateReceived(now); - dispatcher.dispatchEvent(statusCompleteEvent); - - disconnectEvent = new DisconnectEvent(asteriskServer); - disconnectEvent.setDateReceived(now); - dispatcher.dispatchEvent(disconnectEvent); - socketConnectionFacadeMC.replay(); - dispatcherMC.replay(); managerReader.setSocket(socketConnectionFacade); managerReader.run(); socketConnectionFacadeMC.verify(); - dispatcherMC.verify(); + + assertEquals("not exactly two events dispatched", 2, + dispatcher.dispatchedEvents.size()); + + assertEquals("first event must be a StatusCompleteEvent", + StatusCompleteEvent.class, dispatcher.dispatchedEvents.get(0) + .getClass()); + + assertEquals("second event must be a DisconnectEvent", + DisconnectEvent.class, dispatcher.dispatchedEvents.get(1) + .getClass()); } public void testRunReceivingUserEvent() throws Exception @@ -150,22 +165,22 @@ public class ManagerReaderImplTest exten socketConnectionFacade.readLine(); socketConnectionFacadeMC.setReturnValue(null); - myUserEvent = new MyUserEvent(asteriskServer); - myUserEvent.setDateReceived(now); - dispatcher.dispatchEvent(myUserEvent); - - disconnectEvent = new DisconnectEvent(asteriskServer); - disconnectEvent.setDateReceived(now); - dispatcher.dispatchEvent(disconnectEvent); - socketConnectionFacadeMC.replay(); - dispatcherMC.replay(); managerReader.setSocket(socketConnectionFacade); managerReader.run(); socketConnectionFacadeMC.verify(); - dispatcherMC.verify(); + + assertEquals("not exactly two events dispatched", 2, + dispatcher.dispatchedEvents.size()); + + assertEquals("first event must be a MyUserEvent", MyUserEvent.class, + dispatcher.dispatchedEvents.get(0).getClass()); + + assertEquals("second event must be a DisconnectEvent", + DisconnectEvent.class, dispatcher.dispatchedEvents.get(1) + .getClass()); } public void testRunReceivingResponse() throws Exception @@ -176,30 +191,46 @@ public class ManagerReaderImplTest exten socketConnectionFacade.readLine(); socketConnectionFacadeMC.setReturnValue("Response: Success"); socketConnectionFacade.readLine(); - socketConnectionFacadeMC.setReturnValue("Message: Authentication accepted"); + socketConnectionFacadeMC + .setReturnValue("Message: Authentication accepted"); socketConnectionFacade.readLine(); socketConnectionFacadeMC.setReturnValue(""); socketConnectionFacade.readLine(); socketConnectionFacadeMC.setReturnValue(null); - response = new ManagerResponse(); - response.setResponse("Success"); - response.setMessage("Authentication accepted"); - response.setDateReceived(now); - dispatcher.dispatchResponse(response); - - disconnectEvent = new DisconnectEvent(asteriskServer); - disconnectEvent.setDateReceived(now); - dispatcher.dispatchEvent(disconnectEvent); - socketConnectionFacadeMC.replay(); - dispatcherMC.replay(); managerReader.setSocket(socketConnectionFacade); managerReader.run(); socketConnectionFacadeMC.verify(); - dispatcherMC.verify(); + + assertEquals("not exactly one response dispatched", 1, + dispatcher.dispatchedResponses.size()); + + assertEquals("first response must be a ManagerResponse", + ManagerResponse.class, dispatcher.dispatchedResponses.get(0) + .getClass()); + + assertEquals("ManagerResponse contains incorrect response", "Success", + ((ManagerResponse) dispatcher.dispatchedResponses.get(0)) + .getResponse()); + + assertEquals("ManagerResponse contains incorrect message", + "Authentication accepted", + ((ManagerResponse) dispatcher.dispatchedResponses.get(0)) + .getMessage()); + + assertEquals("ManagerResponse contains incorrect dateReceived", now, + ((ManagerResponse) dispatcher.dispatchedResponses.get(0)) + .getDateReceived()); + + assertEquals("not exactly one events dispatched", 1, + dispatcher.dispatchedEvents.size()); + + assertEquals("first event must be a DisconnectEvent", + DisconnectEvent.class, dispatcher.dispatchedEvents.get(0) + .getClass()); } public void testRunReceivingCommandResponse() throws Exception @@ -223,27 +254,38 @@ public class ManagerReaderImplTest exten socketConnectionFacade.readLine(); socketConnectionFacadeMC.setReturnValue(null); - response = new CommandResponse(); - response.setResponse("Follows"); - response.setActionId("12345"); result.add("Line1"); result.add("Line2"); - response.setResult(result); - response.setDateReceived(now); - dispatcher.dispatchResponse(response); - - disconnectEvent = new DisconnectEvent(asteriskServer); - disconnectEvent.setDateReceived(now); - dispatcher.dispatchEvent(disconnectEvent); socketConnectionFacadeMC.replay(); - dispatcherMC.replay(); managerReader.setSocket(socketConnectionFacade); managerReader.run(); socketConnectionFacadeMC.verify(); - dispatcherMC.verify(); + + assertEquals("not exactly one response dispatched", 1, + dispatcher.dispatchedResponses.size()); + + assertEquals("first response must be a CommandResponse", + CommandResponse.class, dispatcher.dispatchedResponses.get(0) + .getClass()); + + assertEquals("CommandResponse contains incorrect response", "Follows", + ((CommandResponse) dispatcher.dispatchedResponses.get(0)) + .getResponse()); + + assertEquals("CommandResponse contains incorrect actionId", "12345", + ((CommandResponse) dispatcher.dispatchedResponses.get(0)) + .getActionId()); + + assertEquals("CommandResponse contains incorrect result", result, + ((CommandResponse) dispatcher.dispatchedResponses.get(0)) + .getResult()); + + assertEquals("CommandResponse contains incorrect dateReceived", now, + ((CommandResponse) dispatcher.dispatchedResponses.get(0)) + .getDateReceived()); } public void testRunCatchingIOException() throws Exception @@ -251,19 +293,46 @@ public class ManagerReaderImplTest exten DisconnectEvent disconnectEvent; socketConnectionFacade.readLine(); - socketConnectionFacadeMC.setThrowable(new IOException("Something happened to the network...")); - - disconnectEvent = new DisconnectEvent(asteriskServer); - disconnectEvent.setDateReceived(now); - dispatcher.dispatchEvent(disconnectEvent); + socketConnectionFacadeMC.setThrowable(new IOException( + "Something happened to the network...")); socketConnectionFacadeMC.replay(); - dispatcherMC.replay(); managerReader.setSocket(socketConnectionFacade); managerReader.run(); socketConnectionFacadeMC.verify(); - dispatcherMC.verify(); + + assertEquals("must not dispatch a response", 0, + dispatcher.dispatchedResponses.size()); + + assertEquals("not exactly one events dispatched", 1, + dispatcher.dispatchedEvents.size()); + + assertEquals("first event must be a DisconnectEvent", + DisconnectEvent.class, dispatcher.dispatchedEvents.get(0) + .getClass()); + } + + private class MockedDispatcher implements Dispatcher + { + List dispatchedEvents; + List dispatchedResponses; + + public MockedDispatcher() + { + this.dispatchedEvents = new ArrayList(); + this.dispatchedResponses = new ArrayList(); + } + + public void dispatchResponse(ManagerResponse response) + { + dispatchedResponses.add(response); + } + + public void dispatchEvent(ManagerEvent event) + { + dispatchedEvents.add(event); + } } } |
From: Stefan R. <sr...@us...> - 2005-03-13 11:27:33
|
Update of /cvsroot/asterisk-java/asterisk-java/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20829/lib Removed Files: commons-lang-2.0.jar Log Message: Removed dependcy on commons-lang --- commons-lang-2.0.jar DELETED --- |
From: Stefan R. <sr...@us...> - 2005-03-13 11:27:33
|
Update of /cvsroot/asterisk-java/asterisk-java/src/test/net/sf/asterisk/fastagi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20829/src/test/net/sf/asterisk/fastagi Modified Files: ResourceBundleMappingStrategyTest.java Log Message: Removed dependcy on commons-lang Index: ResourceBundleMappingStrategyTest.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/test/net/sf/asterisk/fastagi/ResourceBundleMappingStrategyTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -p -r1.3 -r1.4 --- ResourceBundleMappingStrategyTest.java 11 Mar 2005 15:20:51 -0000 1.3 +++ ResourceBundleMappingStrategyTest.java 13 Mar 2005 11:26:51 -0000 1.4 @@ -42,8 +42,8 @@ public class ResourceBundleMappingStrate scriptFirstPass = mappingStrategy.determineScript(request); scriptSecondPass = mappingStrategy.determineScript(request); - assertTrue("incorrect script determined", - scriptFirstPass instanceof HelloAGIScript); + assertEquals("incorrect script determined", + scriptFirstPass.getClass(), HelloAGIScript.class); assertTrue("script instances are not cached", scriptFirstPass == scriptSecondPass); |
From: Stefan R. <sr...@us...> - 2005-03-13 11:27:32
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20829/src/java/net/sf/asterisk/fastagi/impl Modified Files: AGIRequestImpl.java Log Message: Removed dependcy on commons-lang Index: AGIRequestImpl.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/impl/AGIRequestImpl.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -p -r1.1 -r1.2 --- AGIRequestImpl.java 11 Mar 2005 15:20:50 -0000 1.1 +++ AGIRequestImpl.java 13 Mar 2005 11:26:50 -0000 1.2 @@ -20,11 +20,6 @@ import java.io.Serializable; import net.sf.asterisk.fastagi.AGIRequest; -import org.apache.commons.lang.builder.EqualsBuilder; -import org.apache.commons.lang.builder.HashCodeBuilder; -import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; - /** * Default implementation of the AGIRequest interface. * @@ -413,17 +408,26 @@ public class AGIRequestImpl implements S public String toString() { - return ToStringBuilder.reflectionToString(this, - ToStringStyle.MULTI_LINE_STYLE); - } - - public boolean equals(Object o) - { - return EqualsBuilder.reflectionEquals(this, o); - } + StringBuffer sb; + + sb = new StringBuffer(getClass().getName() + ": "); + sb.append("script='" + getScript() + "'; "); + sb.append("requestURL='" + getRequestURL() + "'; "); + sb.append("channel='" + getChannel() + "'; "); + sb.append("uniqueId='" + getUniqueId() + "'; "); + sb.append("type='" + getType() + "'; "); + sb.append("language='" + getLanguage() + "'; "); + sb.append("callerId='" + getCallerId() + "'; "); + sb.append("callerIdName='" + getCallerIdName() + "'; "); + sb.append("dnid='" + getDnid() + "'; "); + sb.append("rdnis='" + getRdnis() + "'; "); + sb.append("context='" + getContext() + "'; "); + sb.append("extension='" + getExtension() + "'; "); + sb.append("priority='" + getPriority() + "'; "); + sb.append("enhanced='" + getEnhanced() + "'; "); + sb.append("accountCode='" + getAccountCode() + "'; "); + sb.append("systemHashcode=" + System.identityHashCode(this)); - public int hashCode() - { - return HashCodeBuilder.reflectionHashCode(this); + return sb.toString(); } } |
From: Stefan R. <sr...@us...> - 2005-03-12 09:57:43
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2340/src/java/net/sf/asterisk Added Files: Main.java Log Message: Added --- NEW FILE: Main.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; import net.sf.asterisk.fastagi.AGIServer; import net.sf.asterisk.fastagi.DefaultAGIServer; /** * Starts the DefaultAGIServer. * * @author srt * @version $Id: Main.java,v 1.1 2005/03/12 09:57:32 srt Exp $ */ public class Main { public static void main(String[] args) throws Exception { AGIServer agiServer; agiServer = new DefaultAGIServer(); agiServer.startup(); } } |
From: Stefan R. <sr...@us...> - 2005-03-12 09:57:01
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2210/src/java/net/sf/asterisk/fastagi Modified Files: AbstractAGIScript.java Log Message: Added some more convinience methods Index: AbstractAGIScript.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/AbstractAGIScript.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -p -r1.7 -r1.8 --- AbstractAGIScript.java 11 Mar 2005 16:18:13 -0000 1.7 +++ AbstractAGIScript.java 12 Mar 2005 09:56:50 -0000 1.8 @@ -17,10 +17,20 @@ package net.sf.asterisk.fastagi; import net.sf.asterisk.fastagi.command.AnswerCommand; +import net.sf.asterisk.fastagi.command.ChannelStatusCommand; +import net.sf.asterisk.fastagi.command.ExecCommand; import net.sf.asterisk.fastagi.command.GetVariableCommand; import net.sf.asterisk.fastagi.command.HangupCommand; +import net.sf.asterisk.fastagi.command.SayDigitsCommand; +import net.sf.asterisk.fastagi.command.SayNumberCommand; +import net.sf.asterisk.fastagi.command.SayPhoneticCommand; +import net.sf.asterisk.fastagi.command.SayTimeCommand; +import net.sf.asterisk.fastagi.command.SetAutoHangupCommand; +import net.sf.asterisk.fastagi.command.SetCallerIdCommand; import net.sf.asterisk.fastagi.command.SetContextCommand; import net.sf.asterisk.fastagi.command.SetExtensionCommand; +import net.sf.asterisk.fastagi.command.SetMusicOffCommand; +import net.sf.asterisk.fastagi.command.SetMusicOnCommand; import net.sf.asterisk.fastagi.command.SetPriorityCommand; import net.sf.asterisk.fastagi.command.SetVariableCommand; import net.sf.asterisk.fastagi.command.StreamFileCommand; @@ -28,7 +38,8 @@ import net.sf.asterisk.fastagi.reply.AGI /** * The AbstractAGIScript provides some convinience methods to make it easier to - * write custom AGIScripts. + * write custom AGIScripts.<br> + * Just extend it by your own AGIScripts. * * @author srt * @version $Id$ @@ -51,18 +62,148 @@ public abstract class AbstractAGIScript channel.sendCommand(new HangupCommand()); } + /** + * Cause the channel to automatically hangup at the given number of seconds + * in the future. + * + * @param time the number of seconds before this channel is automatically + * hung up.<br> + * 0 disables the autohangup feature. + */ + protected void setAutoHangup(AGIChannel channel, int time) + throws AGIException + { + channel.sendCommand(new SetAutoHangupCommand(time)); + } + + /** + * Sets the caller id on the current channel. + * + * @param callerId the raw caller id to set, for example "John Doe<1234>". + */ + protected void setCallerId(AGIChannel channel, String callerId) + throws AGIException + { + channel.sendCommand(new SetCallerIdCommand(callerId)); + } + + /** + * Plays music on hold from the default music on hold class. + */ + protected void playMusicOnHold(AGIChannel channel) throws AGIException + { + channel.sendCommand(new SetMusicOnCommand()); + } + + /** + * Plays music on hold from the given music on hold class. + * + * @param musicOnHoldClass the music on hold class to play music from as + * configures in Asterisk's <code><musiconhold.conf/code>. + */ + protected void playMusicOnHold(AGIChannel channel, String musicOnHoldClass) + throws AGIException + { + channel.sendCommand(new SetMusicOnCommand(musicOnHoldClass)); + } + + /** + * Stops playing music on hold. + */ + protected void stopMusicOnHold(AGIChannel channel) throws AGIException + { + channel.sendCommand(new SetMusicOffCommand()); + } + + /** + * Returns the status of the channel.<br> + * Return values: + * <ul> + * <li>0 Channel is down and available + * <li>1 Channel is down, but reserved + * <li>2 Channel is off hook + * <li>3 Digits (or equivalent) have been dialed + * <li>4 Line is ringing + * <li>5 Remote end is ringing + * <li>6 Line is up + * <li>7 Line is busy + * </ul> + * + * @return the status of the channel. + */ + protected int getChannelStatus(AGIChannel channel) throws AGIException + { + AGIReply reply; + + reply = channel.sendCommand(new ChannelStatusCommand()); + return reply.getResultCode(); + } + + /** + * Executes the given command. + * + * @param application the name of the application to execute, for example + * "Dial". + * @return the return code of the application of -2 if the application was + * not found. + */ + protected int execCommand(AGIChannel channel, String application) + throws AGIException + { + AGIReply reply; + + reply = channel.sendCommand(new ExecCommand(application)); + return reply.getResultCode(); + } + + /** + * Executes the given command. + * + * @param application the name of the application to execute, for example + * "Dial". + * @param options the parameters to pass to the application, for example + * "SIP/123". + * @return the return code of the application of -2 if the application was + * not found. + */ + protected int execCommand(AGIChannel channel, String application, + String options) throws AGIException + { + AGIReply reply; + + reply = channel.sendCommand(new ExecCommand(application, options)); + return reply.getResultCode(); + } + + /** + * Sets the context for continuation upon exiting the application. + * + * @param context the context for continuation upon exiting the application. + */ protected void setContext(AGIChannel channel, String context) throws AGIException { channel.sendCommand(new SetContextCommand(context)); } + /** + * Sets the extension for continuation upon exiting the application. + * + * @param extension the extension for continuation upon exiting the + * application. + */ protected void setExtension(AGIChannel channel, String extension) throws AGIException { channel.sendCommand(new SetExtensionCommand(extension)); } + /** + * Sets the priority for continuation upon exiting the application. + * + * @param priority the priority for continuation upon exiting the + * application. + */ protected void setPriority(AGIChannel channel, int priority) throws AGIException { @@ -85,9 +226,9 @@ public abstract class AbstractAGIScript * given digit. * * @param file name of the file to play. - * @param escapeDigits a String containing the dtmf digits that allow the + * @param escapeDigits a String containing the DTMF digits that allow the * user to escape. - * @return the dtmf digit pressed or 0x0 if none was pressed. + * @return the DTMF digit pressed or 0x0 if none was pressed. */ protected char streamFile(AGIChannel channel, String file, String escapeDigits) throws AGIException @@ -99,6 +240,122 @@ public abstract class AbstractAGIScript } /** + * Says the given digit string. + * + * @param digits the digit string to say. + */ + protected void sayDigits(AGIChannel channel, String digits) + throws AGIException + { + channel.sendCommand(new SayDigitsCommand(digits)); + } + + /** + * Says the given number, returning early if any of the given DTMF number + * are received on the channel. + * + * @param digits the digit string to say. + * @param escapeDigits a String containing the DTMF digits that allow the + * user to escape. + * @return the DTMF digit pressed or 0x0 if none was pressed. + */ + protected char sayDigits(AGIChannel channel, String digits, + String escapeDigits) throws AGIException + { + AGIReply reply; + + reply = channel.sendCommand(new SayDigitsCommand(digits)); + return reply.getResultCodeAsChar(); + } + + /** + * Says the given number. + * + * @param number the number to say. + */ + protected void sayNumber(AGIChannel channel, String number) + throws AGIException + { + channel.sendCommand(new SayNumberCommand(number)); + } + + /** + * Says the given number, returning early if any of the given DTMF number + * are received on the channel. + * + * @param number the number to say. + * @param escapeDigits a String containing the DTMF digits that allow the + * user to escape. + * @return the DTMF digit pressed or 0x0 if none was pressed. + */ + protected char sayNumber(AGIChannel channel, String number, + String escapeDigits) throws AGIException + { + AGIReply reply; + + reply = channel.sendCommand(new SayNumberCommand(number)); + return reply.getResultCodeAsChar(); + } + + /** + * Says the given character string with phonetics. + * + * @param text the text to say. + */ + protected void sayPhonetic(AGIChannel channel, String text) + throws AGIException + { + channel.sendCommand(new SayPhoneticCommand(text)); + } + + /** + * Says the given character string with phonetics, returning early if any of + * the given DTMF number are received on the channel. + * + * @param text the text to say. + * @param escapeDigits a String containing the DTMF digits that allow the + * user to escape. + * @return the DTMF digit pressed or 0x0 if none was pressed. + */ + protected char sayPhonetic(AGIChannel channel, String text, + String escapeDigits) throws AGIException + { + AGIReply reply; + + reply = channel.sendCommand(new SayPhoneticCommand(text)); + return reply.getResultCodeAsChar(); + } + + /** + * Says the given character string with phonetics. + * + * @param time the time to say in seconds since 00:00:00 on January 1, 1970. + */ + protected void sayTime(AGIChannel channel, long time) + throws AGIException + { + channel.sendCommand(new SayTimeCommand(time)); + } + + /** + * Says the given character string with phonetics, returning early if any of + * the given DTMF number are received on the channel. + * + * @param time the time to say in seconds since 00:00:00 on January 1, 1970. + * @param escapeDigits a String containing the DTMF digits that allow the + * user to escape. + * @return the DTMF digit pressed or 0x0 if none was pressed. + */ + protected char sayTime(AGIChannel channel, long time, + String escapeDigits) throws AGIException + { + AGIReply reply; + + reply = channel.sendCommand(new SayTimeCommand(time)); + return reply.getResultCodeAsChar(); + } + + /** * Returns the value of the given channel variable. * * @param name the name of the variable to retrieve. |
From: Stefan R. <sr...@us...> - 2005-03-12 09:56:29
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2094/src/java/net/sf/asterisk/fastagi Modified Files: AGIConnectionHandler.java Log Message: Added logging of missing mapping via VerboseCommand() Index: AGIConnectionHandler.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/AGIConnectionHandler.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -p -r1.8 -r1.9 --- AGIConnectionHandler.java 11 Mar 2005 20:15:15 -0000 1.8 +++ AGIConnectionHandler.java 12 Mar 2005 09:56:17 -0000 1.9 @@ -18,6 +18,7 @@ package net.sf.asterisk.fastagi; import java.io.IOException; +import net.sf.asterisk.fastagi.command.VerboseCommand; import net.sf.asterisk.fastagi.impl.AGIChannelImpl; import net.sf.asterisk.fastagi.impl.AGIReaderImpl; import net.sf.asterisk.fastagi.impl.AGIWriterImpl; @@ -38,12 +39,12 @@ import org.apache.commons.logging.LogFac public class AGIConnectionHandler implements Runnable { private final Log logger = LogFactory.getLog(getClass()); - + /** * The socket connection. */ private SocketConnectionFacade socket; - + /** * The strategy to use to determine which script to run. */ @@ -93,22 +94,28 @@ public class AGIConnectionHandler implem script = mappingStrategy.determineScript(request); threadName = Thread.currentThread().getName(); - + if (script != null) { - logger.info("Begin AGIScript " + script.getClass().getName() + " on " + threadName); + logger.info("Begin AGIScript " + script.getClass().getName() + + " on " + threadName); script.service(request, channel); - logger.info("End AGIScript " + script.getClass().getName() + " on " + threadName); + logger.info("End AGIScript " + script.getClass().getName() + + " on " + threadName); } else { - logger.error("Unable to determine which script to run for " - + request.getRequestURL()); + String error; + + error = "No script configured for " + request.getRequestURL(); + channel.sendCommand(new VerboseCommand(error, 1)); + logger.error(error); } } catch (AGIException e) { - logger.error("AGIException while handling request: " + e.getMessage()); + logger.error("AGIException while handling request: " + + e.getMessage()); } catch (Exception e) { |
From: Stefan R. <sr...@us...> - 2005-03-12 09:55:21
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1883/src/java/net/sf/asterisk/fastagi Modified Files: DefaultAGIServer.java Log Message: Changed logging on startup Index: DefaultAGIServer.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/DefaultAGIServer.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -p -r1.4 -r1.5 --- DefaultAGIServer.java 10 Mar 2005 23:42:35 -0000 1.4 +++ DefaultAGIServer.java 12 Mar 2005 09:55:10 -0000 1.5 @@ -186,7 +186,7 @@ public class DefaultAGIServer implements try { serverSocket = createServerSocket(); - logger.info("Waiting for new connections."); + logger.info("Listening on *:" + bindPort + "."); while ((socket = serverSocket.accept()) != null) { |
From: Stefan R. <sr...@us...> - 2005-03-11 23:39:43
|
Update of /cvsroot/asterisk-java/asterisk-java/xdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23186/xdocs Modified Files: index.xml Log Message: Added information on FastAGI support and licenses of referenced projects Index: index.xml =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/xdocs/index.xml,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -p -r1.6 -r1.7 --- index.xml 11 Mar 2005 13:41:51 -0000 1.6 +++ index.xml 11 Mar 2005 23:39:29 -0000 1.7 @@ -27,13 +27,17 @@ <section name="Asterisk Java"> <subsection name="What is asterisk-java?"> <p>The asterisk-java package consists of a set of Java classes - that allow you to connect to an <a - href="http://www.asterisk.org/">Asterisk PBX Server</a> via - <a - href="http://www.voip-info.org/wiki-Asterisk+manager+API">Asterisk's - Manager API</a> from any Java application.</p> - <p>It supports receiving events from the Asterisk server (e.g. - call progess, registered peers, channel state) and sending + that allow you to easily build Java application that interact with an <a + href="http://www.asterisk.org/">Asterisk PBX Server</a>. Asterisk-java + supports both interfaces that Asterisk provides for this scenario: + The <a href="http://www.voip-info.org/wiki-Asterisk+AGI">FastAGI</a> + protocol and the <a + href="http://www.voip-info.org/wiki-Asterisk+manager+API">Manager API</a>.</p> + <p>The FastAGI implementation supports all <a + href="apidocs/net/sf/asterisk/fastagi/command/package-summary.html">commands</a> + currently available from Asterisk.</p> + <p>The Manager API implementation supports receiving events from the Asterisk + server (e.g. call progess, registered peers, channel state) and sending actions to Asterisk (e.g. originate call, agent login/logoff, start/stop voice recording).</p> <p>A complete list of the available <a @@ -49,24 +53,22 @@ License, Version 2.0</a>.</p> </subsection> <subsection name="Status"> - <p>Currently asterisk-java supports the actions and events - provided by the standard installation of Asterisk but you can - easily extend them by your own events and actions.</p> + <p>I am currently preparing the first release of asterisk-java. It will probably + be available by the end of april. Meanwhile you can try it out by accessing + the code base in cvs (see below).</p> <p>Ideas for the future include a stateful higher level API that supports operations like "get list of currently active calls" or "place call" with objects like "Call" or "Channel" that are transparently updated as the state of the corresponding object within the asterisk server changes.</p> - <p>There is also some work on an implementation of the FastAGI protocol - as the currently available java implementations (see below) are both - subject to the strict terms of the GPL.</p> </subsection> <subsection name="Download"> <p>Asterisk-java is currently available via cvs only.</p> -<source><![CDATA[cvs -d:pserver:ano...@cv...:/cvsroot/asterisk-java login -cvs -z3 -d:pserver:ano...@cv...:/cvsroot/asterisk-java co asterisk-java]]> - </source> +<source><![CDATA[ +cvs -d:pserver:ano...@cv...:/cvsroot/asterisk-java login +cvs -z3 -d:pserver:ano...@cv...:/cvsroot/asterisk-java co asterisk-java +]]></source> <p>When prompted for a password for <i>anonymous</i>, simply press the Enter key.</p> <p>More information is available on the <a @@ -74,24 +76,19 @@ cvs -z3 -d:pserver:ano...@cv...urcef project page</a>.</p> </subsection> <subsection name="Related Projects"> - <p>_dw has developed a similar kind of software for Python - called <a - href="http://www.botanicus.net/dw/py-asterisk.php">py-Asterisk</a>. - </p> - <p><a href="http://sourceforge.net/projects/jasterisk/">JAsterisk</a> - is a set of JNI classes providing direct access to Asterisk - PBX functionality from Java. It is not a socket-level - interface into the Asterisk manager app (like - asterisk-java) but a true Java-Asterisk integration at the - Thread level.</p> + <p><a href="http://tanesha.net/Wiki/JastAgi.html">Jast Agi</a> + is another toolkit for writing Java applications that connect to + Asterisk using the FastAGI protocol. Available under Apache License.</p> <p><a href="http://www.voip-info.org/wiki-JAGIServer">JAGIServer</a> is a 100% Pure Java application server for Asterisk using the FastAGI protocol, which is a TCP/IP wrapper around the Asterisk Gateway Interface AGI protocol for call handling - and processing caller input.</p> - <p><a href="http://tanesha.net/Wiki/JastAgi.html">Jast Agi</a> - is another toolkit for writing Java applications that connect to - Asterisk using the FastAGI protocol.</p> + and processing caller input. Available under GNU General Public License.</p> + <p><a href="http://sourceforge.net/projects/jasterisk/">JAsterisk</a> + is a set of JNI classes providing direct access to Asterisk + PBX functionality from Java. It is not a socket-level + interface to Asterisk (like asterisk-java) but a true Java-Asterisk + integration at the Thread level. Available under GNU General Public License.</p> </subsection> <subsection name="Contact"> <p>You can reach me at <code>srt</code> at <code>reucon</code> dot <code>net</code></p>. </subsection> |
From: Stefan R. <sr...@us...> - 2005-03-11 23:17:58
|
Update of /cvsroot/asterisk-java/asterisk-java/xdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17522/xdocs Modified Files: navigation.xml Added Files: tutorial.xml Removed Files: samples.xml Log Message: Added tutorial covering basic FastAGI usage --- NEW FILE: tutorial.xml --- <?xml version="1.0"?> <!-- /* * 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. * */ --> <document> <properties> <author email="srt at users.sourceforge.net">Stefan Reuter</author> <title>Samples</title> </properties> <meta name="keywords" content="Asterisk,asterisk,Java,java,Manager API,FastAGI,AGI,tutorial,example"/> <body> <section name="The FastAGI Protocol"> <p>The easiest way to interact with Asterisk from Java applications is via the FastAGI protocol.</p> <p>The AGI (Asterisk Gateway Interface) facility allows you to launch scripts, from the Asterisk dial plan. Traditionally communication between the scripts and Asterisk was via standard input and standard output and scripts had to run on the same machine as Asterisk. Due to the large amount of time a Java Virtual Machine needs for startup and the discomfort of having to install a Java environment on the PBX box(es) Java has not been the language of choice for writing AGI scripts.</p> <p>These drawbacks have been addressed by the addition of FastAGI to Asterisk. FastAGI is basically AGI over TCP/IP socket connections instead of using standard input and standard output as communication medium.</p> <p>Using FastAGI you can run a Java application (on the same machine that runs Asterisk or on a seperate machine) that is only started once and serves AGI scripts until it is shut down. Combined with Java's multithreading support you can build pretty fast AGI scripts using this protocol.</p> <p>Asterisk-java helps you with running your Java based AGI scripts by providing a container that recives connections from the Asterisk server, parses the request and calls your scripts mapped to the called URL.</p> <subsection name="Hello AGI!"> <p>To write your own AGI scripts you must implement the AGIScript interface. You can do so by simply extending AbstractAGIScript that provides some convenience methods that further simplify that task.</p> <p>A simple AGIScript might look as follows:</p> <source><![CDATA[ import net.sf.asterisk.fastagi.AGIChannel; import net.sf.asterisk.fastagi.AGIException; import net.sf.asterisk.fastagi.AGIRequest; import net.sf.asterisk.fastagi.AbstractAGIScript; public class HelloAGIScript extends AbstractAGIScript { public void service(AGIRequest request, AGIChannel channel) throws AGIException { // Answer the channel... answer(channel); // ...say hello... streamFile(channel, "welcome"); // ...and hangup. hangup(channel); } } ]]></source> <p>Put this Java source file into a directory of your choice, add the <code>asterisk-java.jar</code> and <code>commons-logging.jar</code> and compile it:</p> <source><![CDATA[ $ javac -cp asterisk-java.jar:commons-logging.jar HelloAGIScript.java $ ]]></source> <p>Next you have to add a call to your script to your dialplan in Asterisk.</p> <p>You might want to add an extension 1300 to the default section of your <code>extensions.conf</code>:</p> <source><![CDATA[ [default] ... exten => 1300,1,Agi(agi://localhost/hello.agi) ]]></source> <p>Replace localhost with the hostname of the machine that runs Asterisk-java.</p> <p>Be sure to reload Asterisk for this change to take effect. You can do so by executing <code>extensions reload</code> on the Asterisk CLI.</p> <p>Now you must map the script name <code>hello.agi</code> to the HelloAGIScript we just created. By default this is done in a properties file called <code>fastagi-mapping.properties</code> that must be on the classpath when we start the AGIServer. In this case it looks like:</p> <source><![CDATA[ hello.agi = HelloAGIScript ]]></source> <p>Your directory should now contain the following files:</p> <source><![CDATA[ $ ls -l -rw-r--r-- 1 srt srt 163689 2005-03-11 22:07 asterisk-java.jar -rw-r--r-- 1 srt srt 26388 2005-03-11 22:06 commons-logging.jar -rw-r--r-- 1 srt srt 26 2005-03-11 20:50 fastagi-mapping.properties -rw-r--r-- 1 srt srt 624 2005-03-11 22:07 HelloAGIScript.class -rw-r--r-- 1 srt srt 438 2005-03-11 20:50 HelloAGIScript.java ]]></source> <p>Finally we start the AGIServer:</p> <source><![CDATA[ $ java -cp commons-logging.jar:asterisk-java.jar:. net.sf.asterisk.fastagi.DefaultAGIServer ]]></source> <p>You should see some logging output indicating that the AGIServer has been successfully started and is listening for incoming connections:</p> <source><![CDATA[ Mar 11, 2005 10:20:12 PM net.sf.asterisk.fastagi.DefaultAGIServer run INFO: Thread pool started. Mar 11, 2005 10:20:12 PM net.sf.asterisk.fastagi.DefaultAGIServer run INFO: Listening on *:4573. ]]></source> <p>When you call extension 1300 you will see the AGI script being launched:</p> <source><![CDATA[ Mar 11, 2005 10:22:47 PM net.sf.asterisk.fastagi.DefaultAGIServer run INFO: Received connection. Mar 11, 2005 10:22:47 PM net.sf.asterisk.fastagi.AGIConnectionHandler run INFO: Begin AGIScript HelloAGIScript on AGIServer-TaskThread-0 Mar 11, 2005 10:22:48 PM net.sf.asterisk.fastagi.AGIConnectionHandler run INFO: End AGIScript HelloAGIScript on AGIServer-TaskThread-0 ]]></source> </subsection> <subsection name="Configuration"> <p>You can tune the DefaultAGIServer by setting two properties: The bindPort and the poolSize.</p> <p>The bindPort determines the TCP port the server will listen on. By default this is the FastAGI port 4573. If you change it make sure to include the new port in your URLs used in <code>extensions.conf</code>. When using bindPort 1234 your <code>extensions.conf</code> will look like:</p> <source><![CDATA[ exten => 1300,1,Agi(agi://localhost:1234/hello.agi) ]]></source> <p>To understand the poolSize property you need to know that the DefaultAGIServer uses a fixed size thread pool to serve your AGIScripts. The poolSize determines how many threads are spawned at startup and thus limits the number of AGIScripts that can run at the same time. So you should set the poolSize to at least the number of concurrent calls your AGIServer should be able to handle. The default value is 10.</p> <p>These configuration properties can be set by providing a <code>fastagi.properties</code> file on the classpath.</p> <p>This might look like:</p> <source><![CDATA[ bindPort = 1234 poolSize = 20 ]]></source> </subsection> </section> </body> </document> Index: navigation.xml =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/xdocs/navigation.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -p -r1.2 -r1.3 --- navigation.xml 24 Feb 2005 23:05:18 -0000 1.2 +++ navigation.xml 11 Mar 2005 23:17:46 -0000 1.3 @@ -29,7 +29,7 @@ <item name="Mailing Lists" href="mail-lists.html"/> </menu> <menu name="Documentation"> - <item name="Samples" href="samples.html"/> + <item name="Tutorial" href="tutorial.html"/> </menu> <search/> <menu type="footer"> --- samples.xml DELETED --- |
From: Stefan R. <sr...@us...> - 2005-03-11 23:15:49
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17071/src/java/net/sf/asterisk/fastagi/command Modified Files: GetDataCommand.java Log Message: Added Constructor with file and timeout Index: GetDataCommand.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/command/GetDataCommand.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -p -r1.2 -r1.3 --- GetDataCommand.java 8 Mar 2005 16:48:34 -0000 1.2 +++ GetDataCommand.java 11 Mar 2005 23:15:39 -0000 1.3 @@ -64,7 +64,23 @@ public class GetDataCommand extends AGIC } /** - * Creates a new GetDataCommand. + * Creates a new GetDataCommand with the given timeout and maxDigits set to + * 1024. + * + * @param file the name of the file to stream, must not include extension. + * @param timeout the timeout to wait for data.<br> + * 0 means standard timeout value, -1 means "ludicrous time" + * (essentially never times out). + */ + public GetDataCommand(String file, int timeout) + { + this.file = file; + this.timeout = timeout; + this.maxDigits = 1024; + } + + /** + * Creates a new GetDataCommand with the given timeout and maxDigits. * * @param file the name of the file to stream, must not include extension. * @param timeout the timeout to wait for data.<br> |
From: Stefan R. <sr...@us...> - 2005-03-11 22:30:05
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5191/src/java/net/sf/asterisk/manager Modified Files: DefaultManagerConnection.java Log Message: Replaced @see references to impl classes by references to the appropriate interface Index: DefaultManagerConnection.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/DefaultManagerConnection.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -p -r1.11 -r1.12 --- DefaultManagerConnection.java 11 Mar 2005 15:27:22 -0000 1.11 +++ DefaultManagerConnection.java 11 Mar 2005 22:29:54 -0000 1.12 @@ -513,7 +513,7 @@ public class DefaultManagerConnection im * * @param response the resonse received by the reader * - * @see ManagerReaderImpl + * @see ManagerReader */ public void dispatchResponse(ManagerResponse response) { @@ -581,7 +581,7 @@ public class DefaultManagerConnection im * * @see #addEventHandler(ManagerEventHandler) * @see #removeEventHandler(ManagerEventHandler) - * @see ManagerReaderImpl + * @see ManagerReader */ public void dispatchEvent(ManagerEvent event) { |
From: Stefan R. <sr...@us...> - 2005-03-11 22:28:02
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4693/src/java/net/sf/asterisk/manager Modified Files: ManagerReader.java Log Message: Fixed parameter javadoc Index: ManagerReader.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/ManagerReader.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -p -r1.10 -r1.11 --- ManagerReader.java 11 Mar 2005 15:27:22 -0000 1.10 +++ ManagerReader.java 11 Mar 2005 22:27:49 -0000 1.11 @@ -49,7 +49,7 @@ public interface ManagerReader extends R * @see EventBuilder * @see ManagerEvent * - * @param eventClass class of the event to register. + * @param event class of the event to register. */ void registerEventClass(Class event); |
From: Stefan R. <sr...@us...> - 2005-03-11 22:28:01
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4693/src/java/net/sf/asterisk/fastagi/command Modified Files: SayDigitsCommand.java Log Message: Fixed parameter javadoc Index: SayDigitsCommand.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/command/SayDigitsCommand.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -p -r1.4 -r1.5 --- SayDigitsCommand.java 11 Mar 2005 19:32:11 -0000 1.4 +++ SayDigitsCommand.java 11 Mar 2005 22:27:49 -0000 1.5 @@ -48,9 +48,9 @@ public class SayDigitsCommand extends AG * * @param digits the digits to say. */ - public SayDigitsCommand(String number) + public SayDigitsCommand(String digits) { - this.digits = number; + this.digits = digits; this.escapeDigits = null; } |
From: Stefan R. <sr...@us...> - 2005-03-11 20:15:28
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1009/src/java/net/sf/asterisk/fastagi Modified Files: AGIConnectionHandler.java Log Message: Added begin and end logging for AGIScript execution Index: AGIConnectionHandler.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/AGIConnectionHandler.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -p -r1.7 -r1.8 --- AGIConnectionHandler.java 11 Mar 2005 15:20:49 -0000 1.7 +++ AGIConnectionHandler.java 11 Mar 2005 20:15:15 -0000 1.8 @@ -82,6 +82,7 @@ public class AGIConnectionHandler implem AGIRequest request; AGIChannel channel; AGIScript script; + String threadName; reader = createReader(); writer = createWriter(); @@ -91,10 +92,13 @@ public class AGIConnectionHandler implem script = mappingStrategy.determineScript(request); + threadName = Thread.currentThread().getName(); + if (script != null) { - logger.info("Running AGIScript " + script.getClass().getName()); + logger.info("Begin AGIScript " + script.getClass().getName() + " on " + threadName); script.service(request, channel); + logger.info("End AGIScript " + script.getClass().getName() + " on " + threadName); } else { @@ -118,6 +122,7 @@ public class AGIConnectionHandler implem } catch (IOException e) { + // swallow } } } |
From: Stefan R. <sr...@us...> - 2005-03-11 19:50:52
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27145/src/java/net/sf/asterisk/fastagi/command Modified Files: SetMusicOnCommand.java Log Message: Added constructor with musicOnHoldClass parameter Index: SetMusicOnCommand.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/command/SetMusicOnCommand.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -p -r1.2 -r1.3 --- SetMusicOnCommand.java 8 Mar 2005 16:48:34 -0000 1.2 +++ SetMusicOnCommand.java 11 Mar 2005 19:50:35 -0000 1.3 @@ -45,6 +45,17 @@ public class SetMusicOnCommand extends A } /** + * Creates a new SetMusicOnCommand playing music from the default music on + * hold class. + * + * @param musicOnHoldClass the music on hold class to play music from. + */ + public SetMusicOnCommand(String musicOnHoldClass) + { + this.musicOnHoldClass = musicOnHoldClass; + } + + /** * Returns the music on hold class to play music from. * * @return the music on hold class to play music from or <code>null</code> |