abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r522048 - /incubator/abdera/java/trunk/server/src/test/java/org/apache/abdera/test/server/UtilityTest.java
Date Sat, 24 Mar 2007 16:09:36 GMT
Author: jmsnell
Date: Sat Mar 24 09:09:35 2007
New Revision: 522048

URL: http://svn.apache.org/viewvc?view=rev&rev=522048
Log:
Testing the B and Q encoding code

Modified:
    incubator/abdera/java/trunk/server/src/test/java/org/apache/abdera/test/server/UtilityTest.java

Modified: incubator/abdera/java/trunk/server/src/test/java/org/apache/abdera/test/server/UtilityTest.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/test/java/org/apache/abdera/test/server/UtilityTest.java?view=diff&rev=522048&r1=522047&r2=522048
==============================================================================
--- incubator/abdera/java/trunk/server/src/test/java/org/apache/abdera/test/server/UtilityTest.java
(original)
+++ incubator/abdera/java/trunk/server/src/test/java/org/apache/abdera/test/server/UtilityTest.java
Sat Mar 24 09:09:35 2007
@@ -32,12 +32,37 @@
 import org.apache.abdera.protocol.server.provider.TargetType;
 import org.apache.abdera.protocol.server.util.RegexTargetResolver;
 import org.apache.abdera.protocol.server.util.SimpleSubjectResolver;
+import org.apache.abdera.protocol.util.EncodingUtil;
 import org.apache.abdera.i18n.iri.IRI;
 
 import junit.framework.TestCase;
 
 public class UtilityTest extends TestCase {
 
+  public static void testEncoding() throws Exception {
+    String t = "tést";
+    String tb1 = EncodingUtil.encode(t);
+    String tb2 = EncodingUtil.encode(t, "UTF-8");
+    String tb3 = EncodingUtil.encode(t, "UTF-8", EncodingUtil.Codec.B);
+    String tb4 = EncodingUtil.encode(t, "UTF-16", EncodingUtil.Codec.B);
+    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);
+    
+    assertEquals(EncodingUtil.decode(tb1),t);
+    assertEquals(EncodingUtil.decode(tb2),t);
+    assertEquals(EncodingUtil.decode(tb3),t);
+    assertEquals(EncodingUtil.decode(tb4),t);
+    assertEquals(EncodingUtil.decode(tq1),t);
+    assertEquals(EncodingUtil.decode(tq2),t);
+  }
+  
   public static void testServiceManager() throws Exception {
     ServiceManager sm = ServiceManager.getInstance();
     assertNotNull(sm);



Mime
View raw message