package org.scribe.utils;

import java.io.ByteArrayInputStream;
import java.io.InputStream;

import org.junit.Test;

import static org.junit.Assert.*;

public class StreamUtilsTest
{

  @Test
  public void shouldCorrectlyDecodeAStream()
  {
    String value = "expected";
    InputStream is = new ByteArrayInputStream(value.getBytes());
    String decoded = StreamUtils.getStreamContents(is);
    assertEquals("expected", decoded);
  }
  
  @Test(expected = IllegalArgumentException.class)
  public void shouldFailForNullParameter()
  {
    InputStream is = null;
    StreamUtils.getStreamContents(is);
    fail("Must throw exception before getting here");
  }
}

@@ -57,16 +57,44 @@
 Stream;%0A
+import java.io.IOException;%0A
 import j
@@ -682,10 +682,427 @@
 %22);%0A  %7D%0A
+%0A  @Test(expected = IllegalStateException.class)%0A  public void shouldFailWithBrokenStream()%0A  %7B%0A    // This object simulates problems with input stream.%0A    final InputStream is = new InputStream()%0A    %7B%0A      @Override%0A      public int read() throws IOException%0A      %7B%0A        throw new IOException();%0A      %7D%0A    %7D;%0A    StreamUtils.getStreamContents(is);%0A    fail(%22Must throw exception before getting here%22);%0A  %7D%0A%0A
 %7D%0A

Add negative test for StreamUtils.getStreamContents