001package com.identityworksllc.iiq.common;
002
003import java.io.IOException;
004import java.io.InputStream;
005
006/**
007 * An input stream primarily for testing purposes that always contains the given
008 * number of zeroes.
009 */
010public class NullInputStream extends InputStream {
011    private int size;
012
013    public NullInputStream() {
014        this(0);
015    }
016
017    public NullInputStream(int size) {
018        this.size = size;
019    }
020
021    @Override
022    public boolean markSupported() {
023        return false;
024    }
025
026    @Override
027    public int read() throws IOException {
028        if (size-- > 0) {
029            return 0;
030        }
031        return -1;
032    }
033}