StubServerSocketFactory.java revision 93102446a7b7c3d17888064b4e2e4e5cb534e6d0
1/* 2 * Copyright 2007 the original author or authors. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16package org.mockftpserver.core.socket; 17 18import java.io.IOException; 19import java.net.ServerSocket; 20 21import org.mockftpserver.core.socket.ServerSocketFactory; 22 23/** 24 * Test-only implementation of ServerSocketFactory. It always returns the predefined 25 * ServerSocket instance specified on the constructor. 26 * 27 * @version $Revision: 88 $ - $Date: 2007-10-27 20:18:11 -0400 (Sat, 27 Oct 2007) $ 28 * 29 * @author Chris Mair 30 */ 31public class StubServerSocketFactory implements ServerSocketFactory { 32 private StubServerSocket stubServerSocket; 33 34 /** 35 * Construct a new factory instance that always returns the specified 36 * ServerSocket instance. 37 * @param serverSocket - the ServerSocket instance to be returned by this factory 38 */ 39 public StubServerSocketFactory(StubServerSocket serverSocket) { 40 this.stubServerSocket = serverSocket; 41 } 42 43 /** 44 * Return the predefined ServerSocket instance. 45 * @see org.mockftpserver.core.socket.ServerSocketFactory#createServerSocket(int) 46 */ 47 public ServerSocket createServerSocket(int port) throws IOException { 48 return stubServerSocket; 49 } 50}