[Asterisk-java-cvs] CVS: asterisk-java/src/test/net/sf/asterisk/fastagi AGIReaderImplTest.java,NONE,
Brought to you by:
srt
From: Stefan R. <sr...@us...> - 2005-03-09 23:33:14
|
Update of /cvsroot/asterisk-java/asterisk-java/src/test/net/sf/asterisk/fastagi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17393/src/test/net/sf/asterisk/fastagi Added Files: AGIReaderImplTest.java Log Message: Added AGIReader --- NEW FILE: AGIReaderImplTest.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.fastagi; import net.sf.asterisk.fastagi.reply.AGIReply; import net.sf.asterisk.io.SocketConnectionFacade; import org.easymock.MockControl; import junit.framework.TestCase; public class AGIReaderImplTest extends TestCase { private AGIReader agiReader; private MockControl socketMC; private SocketConnectionFacade socket; protected void setUp() throws Exception { super.setUp(); this.socketMC = MockControl.createControl(SocketConnectionFacade.class); this.socket = (SocketConnectionFacade) socketMC.getMock(); this.agiReader = new AGIReaderImpl(socket); } public void testReadReply() throws Exception { AGIReply reply; socket.readLine(); socketMC.setReturnValue("200 result=49 endpos=2240"); socketMC.replay(); reply = agiReader.readReply(); assertEquals("Incorrect status", AGIReply.SC_SUCCESS, reply.getStatus()); assertEquals("Incorrect result", 49, reply.getResult()); socketMC.verify(); } public void testReadReplyInvalidOrUnknownCommand() throws Exception { AGIReply reply; socket.readLine(); socketMC.setReturnValue("510 Invalid or unknown command"); socketMC.replay(); reply = agiReader.readReply(); assertEquals("Incorrect status", AGIReply.SC_INVALID_OR_UNKNOWN_COMMAND, reply.getStatus()); socketMC.verify(); } public void testReadReplyInvalidCommandSyntax() throws Exception { AGIReply reply; socket.readLine(); socketMC .setReturnValue("520-Invalid command syntax. Proper usage follows:"); socket.readLine(); socketMC.setReturnValue(" Usage: DATABASE DEL <family> <key>"); socket.readLine(); socketMC .setReturnValue(" Deletes an entry in the Asterisk database for a"); socket.readLine(); socketMC.setReturnValue(" given family and key."); socket.readLine(); socketMC.setReturnValue(" Returns 1 if succesful, 0 otherwise"); socket.readLine(); socketMC.setReturnValue("520 End of proper usage."); socketMC.replay(); reply = agiReader.readReply(); assertEquals("Incorrect status", AGIReply.SC_INVALID_COMMAND_SYNTAX, reply.getStatus()); assertEquals("Incorrect synopsis", "DATABASE DEL <family> <key>", reply .getSynopsis()); socketMC.verify(); } } |