View Javadoc

1   /*
2    * $Id: MockServletInputStream.java 20875 2011-01-04 16:09:25Z aperepel $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.transport.servlet;
12  
13  import java.io.ByteArrayInputStream;
14  import java.io.IOException;
15  import java.io.InputStream;
16  
17  import javax.servlet.ServletInputStream;
18  
19  public class MockServletInputStream extends ServletInputStream
20  {
21      private InputStream input;
22  
23      public MockServletInputStream(InputStream dataStream)
24      {
25          super();
26          input = dataStream;
27      }
28  
29      public MockServletInputStream()
30      {
31          this(new ByteArrayInputStream(new byte[0]));
32      }
33  
34      @Override
35      public int read() throws IOException
36      {
37          return input.read();
38      }
39  }
40