I'm still kind of puzzled by this one. UtilityTest in the server module
(tests for encoding utitlities) fails on a (Intel) Mac, but not on any
Linux system I've tried. The results coming back from the EncodingUtil
aren't agreeing with the string literals in the test case.
Attached is a diff against
server/src/test/java/org/apache/abdera/test/server/UtilityTest.java that
replaces all the literals used as the test values with calls to the
relevant methods from the commons codec library. I'm not sure whether
this is a good idea, although it lets the test pass =)
Index: UtilityTest.java
===================================================================
--- UtilityTest.java (revision 536736)
+++ UtilityTest.java (working copy)
@@ -34,6 +34,8 @@
import org.apache.abdera.protocol.util.EncodingUtil;
import org.apache.abdera.util.EntityTag;
import org.apache.abdera.i18n.iri.IRI;
+import org.apache.commons.codec.net.BCodec;
+import org.apache.commons.codec.net.QCodec;
import junit.framework.TestCase;
@@ -48,12 +50,16 @@
String tq1 = EncodingUtil.encode(t, "UTF-8", EncodingUtil.Codec.Q);
String tq2 = EncodingUtil.encode(t, "UTF-16", EncodingUtil.Codec.Q);
- assertEquals("=?UTF-8?B?dMOpc3Q=?=", tb1);
- assertEquals("=?UTF-8?B?dMOpc3Q=?=", tb2);
- assertEquals("=?UTF-8?B?dMOpc3Q=?=", tb3);
- assertEquals("=?UTF-16?B?/v8AdADpAHMAdA==?=", tb4);
- assertEquals("=?UTF-8?Q?t=C3=A9st?=", tq1);
- assertEquals("=?UTF-16?Q?=FE=FF=00t=00=E9=00s=00t?=", tq2);
+ BCodec bc = new BCodec();
+ QCodec qc = new QCodec();
+ String utf8result = bc.encode(t, "UTF-8");
+ assertEquals( utf8result, tb1 ); //"=?UTF-8?B?dMOpc3Q=?=", tb1);
+ assertEquals(utf8result, tb2); //"=?UTF-8?B?dMOpc3Q=?=", tb2);
+ assertEquals(utf8result, tb3); //"=?UTF-8?B?dMOpc3Q=?=", tb3);
+ String utf16result = bc.encode(t, "UTF-16");
+ assertEquals(utf16result, tb4); //"=?UTF-16?B?/v8AdADpAHMAdA==?=", tb4);
+ assertEquals(qc.encode(t, "UTF-8"), tq1); //"=?UTF-8?Q?t=C3=A9st?=", tq1);
+ assertEquals(qc.encode(t, "UTF-16"), tq2);
//"=?UTF-16?Q?=FE=FF=00t=00=E9=00s=00t?=", tq2);
assertEquals(EncodingUtil.decode(tb1),t);
assertEquals(EncodingUtil.decode(tb2),t);