    1   /*
    2    * Copyright 2002-2004 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   */
    16
    17  package org.huihoo.jfox.soaf.util.filter;
    18
    19  import java.io.IOException;
    20  import java.io.OutputStream;
    21
    22  import javax.servlet.ServletOutputStream;
    23
    24  /***
    25   * Delegating implementation of ServletOutputStream.
    26   *
    27   * <p>Used by MockHttpServletResponse; typically not
    28   * directly used for testing application controllers.
    29   *
    30   * @author Juergen Hoeller
    31   * @since 1.0.2
    32   * @see MockHttpServletResponse
    33   */
    34  public class MockServletOutputStream extends ServletOutputStream {
    35
    36  	private final OutputStream targetStream;
    37
    38  	/***
    39  	 * Create a new DelegatingServletOutputStream.
    40  	 * @param targetStream the target OutputStream
    41  	 */
    42  	public MockServletOutputStream(OutputStream targetStream) {
    43  		this.targetStream = targetStream;
    44  	}
    45
    46  	public void write(int b) throws IOException {
    47  		this.targetStream.write(b);
    48  	}
    49
    50  	public void flush() throws IOException {
    51  		super.flush();
    52  		this.targetStream.flush();
    53  	}
    54
    55  	public void close() throws IOException {
    56  		super.close();
    57  		this.targetStream.close();
    58  	}
    59
    60  }