package org.ovirt.engine.core.utils.ssh;

import java.io.ByteArrayOutputStream;
import java.io.IOException;

import org.junit.Test;
import static org.junit.Assert.*;

/**
 * SSHClient.ConstraintByteArrayOutputStream tests.
 */
public class ConstraintByteArrayOutputStreamTest {
    @Test
    public void testLimit() throws IOException {
        int limit = 1000;
        ByteArrayOutputStream os = new ConstraintByteArrayOutputStream(limit);
        byte buffer[] = new byte[100];
        for (int i = 0;i<limit*5/buffer.length;i++) {
            os.write(buffer);
        }
        assertTrue(os.size() >= limit);
        assertTrue(os.size() < limit*3/2);
    }
}

