package com.github.legioth.propertysource.rebind;

import com.google.gwt.user.rebind.StringSourceWriter;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import static org.testng.Assert.*;

public class StringTypeHandlerTest
{
  @DataProvider( name = "writeValues" )
  public Object[][] actionDescriptions()
  {
    return new Object[][]{
      new Object[]{ "hi", "\"hi\"" },
      new Object[]{ "1\n2", "\"1\\n2\"" },
      new Object[]{ "&", "\"&\"" },
      new Object[]{ "Å", "\"Å\"" },
    };
  }

  @Test( dataProvider = "writeValues" )
  public void writeValues( final String input, final String output )
  {
    final StringSourceWriter writer = new StringSourceWriter();
    StringTypeHandler.INSTANCE.writeValue( null, writer, input );
    assertEquals( writer.toString(), output );
  }
}

@@ -44,16 +44,214 @@
 ebind;%0A%0A
+import com.google.gwt.core.ext.TreeLogger;%0Aimport com.google.gwt.core.ext.TreeLogger.Type;%0Aimport com.google.gwt.core.ext.UnableToCompleteException;%0Aimport com.google.gwt.core.ext.typeinfo.JMethod;%0A
 import c
@@ -292,24 +292,49 @@
 urceWriter;%0A
+import java.util.Arrays;%0A
 import org.t
@@ -401,16 +401,53 @@
 s.Test;%0A
+import static org.mockito.Mockito.*;%0A
 import s
@@ -1031,16 +1031,16 @@
 nput );%0A
-
     asse
@@ -1081,11 +1081,995 @@
 t );%0A  %7D
+%0A%0A  @Test%0A  public void getStaticReturnValue()%0A    throws Exception%0A  %7B%0A    final String result =%0A      StringTypeHandler.INSTANCE.getStaticReturnValue( mock( TreeLogger.class ),%0A                                                       Arrays.asList( %22A%22 ),%0A                                                       mock( JMethod.class ) );%0A%0A    assertEquals( result, %22A%22 );%0A  %7D%0A%0A  @Test%0A  public void getStaticReturnValue_whenMultipleValues()%0A    throws Exception%0A  %7B%0A      final TreeLogger logger = mock( TreeLogger.class );%0A    try%0A    %7B%0A      StringTypeHandler.INSTANCE.getStaticReturnValue( logger,%0A                                                       Arrays.asList( %22A%22, %22B%22 ),%0A                                                       mock( JMethod.class ) );%0A      fail( %22Should have raised an exception%22 );%0A    %7D%0A    catch ( final UnableToCompleteException utce )%0A    %7B%0A      verify( logger ).log( Type.ERROR, %22String only supported for properties with only one value%22 );%0A    %7D%0A  %7D
 %0A%7D%0A

Add some more basic tests