Update of /cvsroot/asterisk-java/asterisk-java/src/test/net/sf/asterisk/fastagi
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16005/src/test/net/sf/asterisk/fastagi
Added Files:
DefaultAGIServerTest.java
Log Message:
Added DefaultAGIServer
--- NEW FILE: DefaultAGIServerTest.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.io.IOException;
import org.easymock.MockControl;
import net.sf.asterisk.io.ServerSocketFacade;
import net.sf.asterisk.io.SocketConnectionFacade;
import junit.framework.TestCase;
public class DefaultAGIServerTest extends TestCase
{
private DefaultAGIServer server;
private MockControl serverSocketMC;
private ServerSocketFacade serverSocket;
protected void setUp() throws Exception
{
super.setUp();
serverSocketMC = MockControl.createControl(ServerSocketFacade.class);
serverSocket = (ServerSocketFacade) serverSocketMC.getMock();
server = new MockedDefaultAGIServer();
}
protected void tearDown() throws Exception
{
super.tearDown();
server.shutdown();
}
public void testStartup() throws Exception
{
MockControl socketMC;
SocketConnectionFacade socket;
socketMC = MockControl.createControl(SocketConnectionFacade.class);
socket = (SocketConnectionFacade) socketMC.getMock();
socket.readLine();
socketMC.setReturnValue(null);
socket.close();
socketMC.replay();
serverSocket.accept();
serverSocketMC.setReturnValue(socket);
serverSocket.accept();
serverSocketMC.setThrowable(new IOException());
serverSocket.close();
serverSocketMC.replay();
server.startup();
serverSocketMC.verify();
socketMC.verify();
}
class MockedDefaultAGIServer extends DefaultAGIServer
{
protected ServerSocketFacade createServerSocket()
{
return serverSocket;
}
}
}
|