[java-support] branch master updated: Add unit test for StringSupport method.

Scott Cantor cantor.2 at osu.edu
Thu Dec 29 14:22:42 EST 2016


This is an automated email from the git hooks/post-receive script.

scantor pushed a commit to branch master
in repository java-support.

View the commit online:
http://git.shibboleth.net/view/?p=java-support.git;a=commit;h=a30f7bdb991fd419706c336fd4ce927bea4c95ab

The following commit(s) were added to refs/heads/master by this push:
       new  a30f7bd   Add unit test for StringSupport method.
a30f7bd is described below

commit a30f7bdb991fd419706c336fd4ce927bea4c95ab
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu Dec 29 14:22:40 2016 -0500

    Add unit test for StringSupport method.
---
 .../java/support/primitive/StringSupportTest.java       | 17 +++++++++++++++++
 .../utilities/java/support/primitive/data.txt           |  3 +++
 2 files changed, 20 insertions(+)

diff --git a/src/test/java/net/shibboleth/utilities/java/support/primitive/StringSupportTest.java b/src/test/java/net/shibboleth/utilities/java/support/primitive/StringSupportTest.java
index 0c5c9ce..fbc3c3a 100644
--- a/src/test/java/net/shibboleth/utilities/java/support/primitive/StringSupportTest.java
+++ b/src/test/java/net/shibboleth/utilities/java/support/primitive/StringSupportTest.java
@@ -17,6 +17,8 @@
 
 package net.shibboleth.utilities.java.support.primitive;
 
+import java.io.IOException;
+import java.io.InputStream;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashSet;
@@ -24,6 +26,8 @@ import java.util.List;
 
 import net.shibboleth.utilities.java.support.logic.ConstraintViolationException;
 
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
 import org.testng.Assert;
 import org.testng.annotations.Test;
 
@@ -42,6 +46,19 @@ public class StringSupportTest {
 
     private static final List<String> TEST_LIST_AS_LIST = Arrays.asList("1", "x2", "y3", "z4", "5", "6", "");
 
+    @Test public void testInputStreamToString() throws IOException {
+        String str = null;
+        final Resource resource = new ClassPathResource("/net/shibboleth/utilities/java/support/primitive/data.txt");
+        try (final InputStream stream = resource.getInputStream()) {
+            str = StringSupport.inputStreamToString(stream, null);
+        }
+        Assert.assertNotNull(str);
+        Assert.assertEquals(str,
+                "The quick, brown lizard jumped over the lazy fish.\n" +
+                "Wait, I mean the slow, blue elephant jumped over the motivated squirrel.\n" +
+                "No, that's wrong too.\n");
+    }
+    
     @Test public void testListToStringValue() {
         Assert.assertEquals(StringSupport.listToStringValue(TEST_LIST_AS_LIST, SEPARATOR), TEST_LIST,
                 "toList<String> fails");
diff --git a/src/test/resources/net/shibboleth/utilities/java/support/primitive/data.txt b/src/test/resources/net/shibboleth/utilities/java/support/primitive/data.txt
new file mode 100644
index 0000000..6237f66
--- /dev/null
+++ b/src/test/resources/net/shibboleth/utilities/java/support/primitive/data.txt
@@ -0,0 +1,3 @@
+The quick, brown lizard jumped over the lazy fish.
+Wait, I mean the slow, blue elephant jumped over the motivated squirrel.
+No, that's wrong too.
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list