Update of /cvsroot/asterisk-java/asterisk-java/src/test/net/sf/asterisk/fastagi
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31610/src/test/net/sf/asterisk/fastagi
Added Files:
ReplyBuilderImplTest.java
Log Message:
Added ReplyBuilder
--- NEW FILE: ReplyBuilderImplTest.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 java.util.ArrayList;
import java.util.List;
import net.sf.asterisk.fastagi.reply.AGIReply;
import junit.framework.TestCase;
public class ReplyBuilderImplTest extends TestCase
{
private ReplyBuilderImpl replyBuilder;
private List lines;
protected void setUp()
{
this.replyBuilder = new ReplyBuilderImpl();
this.lines = new ArrayList();
}
public void testBuildReply()
{
AGIReply reply;
lines.add("200 result=49 endpos=2240");
reply = replyBuilder.buildReply(lines);
assertEquals("Incorrect status", AGIReply.SC_SUCCESS, reply.getStatus());
assertEquals("Incorrect result", 49, reply.getResult());
}
public void testBuildReplyInvalidOrUnknownCommand()
{
AGIReply reply;
lines.add("510 Invalid or unknown command");
reply = replyBuilder.buildReply(lines);
assertEquals("Incorrect status",
AGIReply.SC_INVALID_OR_UNKNOWN_COMMAND, reply.getStatus());
}
public void testBuildReplyInvalidCommandSyntax()
{
AGIReply reply;
lines.add("520-Invalid command syntax. Proper usage follows:");
lines.add(" Usage: DATABASE DEL <family> <key>");
lines.add(" Deletes an entry in the Asterisk database for a");
lines.add(" given family and key.");
lines.add(" Returns 1 if succesful, 0 otherwise");
lines.add("520 End of proper usage.");
reply = replyBuilder.buildReply(lines);
assertEquals("Incorrect status", AGIReply.SC_INVALID_COMMAND_SYNTAX,
reply.getStatus());
assertEquals("Incorrect synopsis", "DATABASE DEL <family> <key>", reply
.getSynopsis());
assertEquals(
"Incorrect usage",
"Deletes an entry in the Asterisk database for a given family and key. Returns 1 if succesful, 0 otherwise",
reply.getUsage());
}
public void testBuildReplyNoLines()
{
AGIReply reply;
reply = replyBuilder.buildReply(lines);
assertNull(reply);
}
}
|