Created
December 26, 2011 18:19
-
-
Save greghelton/1521810 to your computer and use it in GitHub Desktop.
Java: JUnit test for StringReaderHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package us.greg; | |
import java.io.ByteArrayInputStream; | |
import java.net.URLEncoder; | |
import org.junit.Test; | |
import static org.junit.Assert.assertEquals; | |
import static org.junit.Assert.assertTrue; | |
import static org.junit.Assert.fail; | |
public class StreamReaderHelperTest { | |
String request = "http://localhost:8080/atm/prefs?customerID=123456789&atm=FG3781"; | |
/* | |
* this is the test for my helper function | |
*/ | |
@Test | |
public void streamReaderTest() { | |
try { | |
String testData = URLEncoder.encode(request, "UTF-8"); | |
byte[] bytes = testData.getBytes(); | |
ByteArrayInputStream bais = new ByteArrayInputStream(bytes); | |
String data = StreamReaderHelper.readStream(bais); | |
assertEquals("http", data.substring(0, 4)); | |
} catch(Exception e) { | |
fail(); | |
} | |
assertTrue(true); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment