package com.thoughtworks.acceptance;

import java.text.DecimalFormatSymbols;
import java.util.Locale;


public class EncodingTest extends AbstractAcceptanceTest {

    public void testCanDealWithUtfText() {
        assertBothWays("J\u00F6rg", "<string>J\u00F6rg</string>");
    }

    public void testCanDealWithNullCharactersInText() {
        assertBothWays("X\0Y", "<string>X&#x0;Y</string>");
    }

    public void testEscapesXmlUnfriendlyChars() {
        assertBothWays("<", "<string>&lt;</string>");
        assertBothWays(">", "<string>&gt;</string>");
        assertBothWays("<>", "<string>&lt;&gt;</string>");
        assertBothWays("<=", "<string>&lt;=</string>");
        assertBothWays(">=", "<string>&gt;=</string>");
        assertBothWays("&", "<string>&amp;</string>");
        assertBothWays("'", "<string>&apos;</string>");
        assertBothWays("\"", "<string>&quot;</string>");
    }

    public void testDecimalFormatSymbols() {
        final DecimalFormatSymbols format = new DecimalFormatSymbols(Locale.GERMANY);
        assertBothWays(format, "<java.text.DecimalFormatSymbols serialization=\"custom\">\n"
                + "  <java.text.DecimalFormatSymbols>\n"
                + "    <default>\n"
                + "      <decimalSeparator>,</decimalSeparator>\n"
                + "      <digit>#</digit>\n"
                + "      <exponential>E</exponential>\n"
                + "      <groupingSeparator>.</groupingSeparator>\n"
                + "      <minusSign>-</minusSign>\n"
                + "      <monetarySeparator>,</monetarySeparator>\n"
                + "      <patternSeparator>;</patternSeparator>\n"
                + "      <perMill>\u2030</perMill>\n"
                + "      <percent>%</percent>\n"
                + "      <serialVersionOnStream>2</serialVersionOnStream>\n"
                + "      <zeroDigit>0</zeroDigit>\n"
                + "      <NaN>\ufffd</NaN>\n"
                + "      <currencySymbol>\u20ac</currencySymbol>\n"
                + "      <infinity>\u221e</infinity>\n"
                + "      <intlCurrencySymbol>EUR</intlCurrencySymbol>\n"
                + "      <locale>de_DE</locale>\n"
                + "    </default>\n"
                + "  </java.text.DecimalFormatSymbols>\n"
                + "</java.text.DecimalFormatSymbols>");
    }
}

@@ -96,16 +96,59 @@
 ocale;%0A%0A
+import com.thoughtworks.xstream.core.JVM;%0A%0A
 %0Apublic 
@@ -1007,110 +1007,1394 @@
 nal 
-DecimalFormatSymbols format = new DecimalFormatSymbols(Locale.GERMANY);%0A        assertBothWays(format,
+String xml;%0A        if (!JVM.is14()) %7B%0A            xml =%0A                    %22%3Cjava.text.DecimalFormatSymbols serialization=%5C%22custom%5C%22%3E%5Cn%22%0A                + %22  %3Cjava.text.DecimalFormatSymbols%3E%5Cn%22%0A                + %22    %3Cdefault%3E%5Cn%22%0A                + %22      %3CdecimalSeparator%3E,%3C/decimalSeparator%3E%5Cn%22%0A                + %22      %3Cdigit%3E#%3C/digit%3E%5Cn%22%0A                + %22      %3Cexponential%3EE%3C/exponential%3E%5Cn%22%0A                + %22      %3CgroupingSeparator%3E.%3C/groupingSeparator%3E%5Cn%22%0A                + %22      %3CminusSign%3E-%3C/minusSign%3E%5Cn%22%0A                + %22      %3CmonetarySeparator%3E,%3C/monetarySeparator%3E%5Cn%22%0A                + %22      %3CpatternSeparator%3E;%3C/patternSeparator%3E%5Cn%22%0A                + %22      %3CperMill%3E%5Cu2030%3C/perMill%3E%5Cn%22%0A                + %22      %3Cpercent%3E%25%3C/percent%3E%5Cn%22%0A                + %22      %3CserialVersionOnStream%3E1%3C/serialVersionOnStream%3E%5Cn%22%0A                + %22      %3CzeroDigit%3E0%3C/zeroDigit%3E%5Cn%22%0A                + %22      %3CNaN%3E%5Cufffd%3C/NaN%3E%5Cn%22%0A                + %22      %3CcurrencySymbol%3EDM%3C/currencySymbol%3E%5Cn%22%0A                + %22      %3Cinfinity%3E%5Cu221e%3C/infinity%3E%5Cn%22%0A                + %22      %3CintlCurrencySymbol%3EDEM%3C/intlCurrencySymbol%3E%5Cn%22%0A                + %22      %3Clocale%3Ede_DE%3C/locale%3E%5Cn%22%0A                + %22    %3C/default%3E%5Cn%22%0A                + %22  %3C/java.text.DecimalFormatSymbols%3E%5Cn%22%0A                + %22%3C/java.text.DecimalFormatSymbols%3E%22;%0A        %7D else %7B%0A            xml =%0A                   
  %22%3Cj
@@ -3586,32 +3586,32 @@
 rmatSymbols%3E%5Cn%22%0A
-
                 
@@ -3647,16 +3647,148 @@
 ymbols%3E%22
+;%0A        %7D%0A        final DecimalFormatSymbols format = new DecimalFormatSymbols(Locale.GERMANY);%0A        assertBothWays(format, xml
 );%0A    %7D

Fix DecimalFormatSymbols for JDK 1.3.