

package org.springframework.mock.web;

import java.io.IOException;
import java.io.InputStream;

import javax.servlet.ServletInputStream;

/**
 * Delegating implementation of ServletInputStream.
 *
 * <p>Used by MockHttpServletRequest; typically not
 * necessary for testing application controllers.
 *
 * @author Juergen Hoeller
 * @since 27.04.2004
 * @see org.springframework.mock.web.MockHttpServletRequest
 */
public class DelegatingServletInputStream extends ServletInputStream {

	private final InputStream sourceStream;

	/**
	 * Create a new DelegatingServletInputStream.
	 * @param sourceStream the sourceStream InputStream
	 */
	public DelegatingServletInputStream(InputStream sourceStream) {
		this.sourceStream = sourceStream;
	}

	public InputStream getSourceStream() {
		return sourceStream;
	}

	public int read() throws IOException {
		return this.sourceStream.read();
	}

	public void close() throws IOException {
		super.close();
		this.sourceStream.close();
	}

}
