package me.prettyprint.cassandra.serializers;


import java.io.UnsupportedEncodingException;
import java.util.Arrays;
import java.util.Collection;

import org.apache.commons.lang.RandomStringUtils;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;

@RunWith(value = Parameterized.class)
public class StringSerializerTest {

  private final String str;
  private static final StringSerializer s = StringSerializer.get();

  public StringSerializerTest(String str) {
    this.str = str;
  }

  @Parameters
  public static Collection<Object[]> data() throws UnsupportedEncodingException {
    Object[][] data = new Object[][] {
                                      {"" },
                                      {null},
                                      {"123"},
                                      {"QWER"},
                                      {"!@#$#$^%&^*fdghdfghdfgh%^&*"},
                                      {new String("\u05E9".getBytes(), "utf-8")},
                                      {RandomStringUtils.random(256*256)}
                                      };
    return Arrays.asList(data);
  }

  @Test
  public void test() {    
    Assert.assertEquals(str, s.fromByteBuffer(s.toByteBuffer(str))) ;
  }
}

@@ -141,16 +141,66 @@
 ction;%0A%0A
+import org.apache.cassandra.utils.ByteBufferUtil;%0A
 import o
@@ -1192,16 +1192,28 @@
 s.random
+Alphanumeric
 (256*256
@@ -1215,16 +1215,16 @@
 6*256)%7D%0A
-
         
@@ -1321,16 +1321,33 @@
 d test()
+ throws Exception
  %7B    %0A 
@@ -1415,14 +1415,118 @@
 tr))) ;%0A
+    if ( str != null)%0A      Assert.assertEquals(str, ByteBufferUtil.string(ByteBufferUtil.bytes(str)));%0A
   %7D%0A%7D%0A

change signature of random str creation to be more relevant