// Path: core/src/main/java/net/javacrumbs/mocksocket/MockSocketException.java
// public class MockSocketException extends RuntimeException {
// 	private static final long serialVersionUID = -6476984055059688027L;
// 
// 	public MockSocketException(String message, Throwable cause) {
// 		super(message, cause);
// 	}
// 
// 	public MockSocketException(String message) {
// 		super(message);
// 	}
// 
// 	public MockSocketException(Throwable cause) {
// 		super(cause);
// 	}
// 
// 
// }
// 
// Path: core/src/main/java/net/javacrumbs/mocksocket/socket/MockSocketImplFactory.java
// public class MockSocketImplFactory implements SocketImplFactory {
// 	private final ConnectionFactory connectionFactory;
// 	
// 	public MockSocketImplFactory(ConnectionFactory connectionFactory) {
// 		this.connectionFactory = connectionFactory;
// 	}
// 
// 	public SocketImpl createSocketImpl() {
// 		return new ConnectionFactoryMockSocketImpl(connectionFactory);
// 	}
// 
// }


import java.io.IOException;
import java.net.Socket;
import java.net.SocketImplFactory;
import net.javacrumbs.mocksocket.MockSocketException;
import net.javacrumbs.mocksocket.socket.MockSocketImplFactory;
/**
 * Copyright 2009-2011 the original author or authors.
 *
 * 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.javacrumbs.mocksocket.connection;




/**
 * Stores connections in a static field. It is NOT threads safe so you can not execute multiple tests in parallel. 
 * You also can not use it if there is a {@link SocketImplFactory} already set.
 * @author Lukas Krecan
 * @see Socket#setSocketImplFactory(SocketImplFactory)
 */
public class StaticConnectionFactory implements ConnectionFactory {
	private static ConnectionFactory connectionFactory;

	static 
	{
		bootstrap();
	}
	
	static void bootstrap()
	{
		try {
// Path: core/src/main/java/net/javacrumbs/mocksocket/MockSocketException.java
// public class MockSocketException extends RuntimeException {
// 	private static final long serialVersionUID = -6476984055059688027L;
// 
// 	public MockSocketException(String message, Throwable cause) {
// 		super(message, cause);
// 	}
// 
// 	public MockSocketException(String message) {
// 		super(message);
// 	}
// 
// 	public MockSocketException(Throwable cause) {
// 		super(cause);
// 	}
// 
// 
// }
// 
// Path: core/src/main/java/net/javacrumbs/mocksocket/socket/MockSocketImplFactory.java
// public class MockSocketImplFactory implements SocketImplFactory {
// 	private final ConnectionFactory connectionFactory;
// 	
// 	public MockSocketImplFactory(ConnectionFactory connectionFactory) {
// 		this.connectionFactory = connectionFactory;
// 	}
// 
// 	public SocketImpl createSocketImpl() {
// 		return new ConnectionFactoryMockSocketImpl(connectionFactory);
// 	}
// 
// }


// Path: core/src/main/java/net/javacrumbs/mocksocket/connection/StaticConnectionFactory.java
import java.io.IOException;
import java.net.Socket;
import java.net.SocketImplFactory;
import net.javacrumbs.mocksocket.MockSocketException;
import net.javacrumbs.mocksocket.socket.MockSocketImplFactory;

/**
 * Copyright 2009-2011 the original author or authors.
 *
 * 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.javacrumbs.mocksocket.connection;




/**
 * Stores connections in a static field. It is NOT threads safe so you can not execute multiple tests in parallel. 
 * You also can not use it if there is a {@link SocketImplFactory} already set.
 * @author Lukas Krecan
 * @see Socket#setSocketImplFactory(SocketImplFactory)
 */
public class StaticConnectionFactory implements ConnectionFactory {
	private static ConnectionFactory connectionFactory;

	static 
	{
		bootstrap();
	}
	
	static void bootstrap()
	{
		try {
			Socket.setSocketImplFactory(new MockSocketImplFactory(new StaticConnectionFactory()));