KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mockobjects > servlet > MockServletInputStream


1 package com.mockobjects.servlet;
2
3 import com.mockobjects.Verifiable;
4 import com.mockobjects.util.Verifier;
5
6 import javax.servlet.ServletInputStream JavaDoc;
7
8 public class MockServletInputStream extends ServletInputStream JavaDoc implements
9     Verifiable {
10
11     private byte[] myData;
12     private int myIndex;
13
14     public void verify() {
15         Verifier.verifyObject(this);
16     }
17
18     public void setupRead(byte[] data) {
19         myData = data;
20     }
21
22     public int read() {
23         if(myData!=null && myIndex < myData.length) {
24             return myData[myIndex++];
25         } else {
26             return -1;
27         }
28     }
29 }
30
Popular Tags