Esempio n. 1
0
 /**
  * Test method for {@link com.googlecode.socofo.common.impl.IOHelperImpl#createString(byte[],
  * java.lang.String)} .
  */
 @Test
 public final void testCreateString() {
   final String s = "test";
   byte[] b = null;
   try {
     b = s.getBytes("utf-8");
   } catch (final UnsupportedEncodingException e) {
     Assert.fail(e.getLocalizedMessage());
   }
   final String s2 = to.createString(b, "utf-8");
   Assert.assertEquals(s, s2);
 }
Esempio n. 2
0
 /**
  * Test method for {@link com.googlecode.socofo.common.impl.IOHelperImpl#read(java.io.InputStream,
  * byte[])} .
  */
 @Test
 public final void testRead() {
   final byte[] buffer = new byte[5000];
   final BufferedInputStream bis =
       new BufferedInputStream(getClass().getResourceAsStream("/buffertest.txt"));
   final int read = to.read(bis, buffer);
   Assert.assertTrue(read > 0);
   to.closeInputstream(bis);
   String str = to.createString(buffer, "utf-8");
   Assert.assertNotNull(str);
   str = str.trim();
   Assert.assertEquals("test", str);
 }