abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r1173209 [43/49] - in /abdera/abdera2: ./ .settings/ activities/ activities/src/ activities/src/main/ activities/src/main/java/ activities/src/main/java/org/ activities/src/main/java/org/apache/ activities/src/main/java/org/apache/abdera2/ ...
Date Tue, 20 Sep 2011 15:57:20 GMT
Added: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/http/AuthenticationTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/http/AuthenticationTest.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/http/AuthenticationTest.java (added)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/http/AuthenticationTest.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,39 @@
+package org.apache.abdera2.test.common.http;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Iterator;
+
+import org.apache.abdera2.common.http.Authentication;
+import org.junit.Test;
+
+public class AuthenticationTest {
+
+  @Test
+  public void basicTest() {
+    Authentication auth = Authentication.basic("a", "b");
+    assertEquals("basic",auth.getScheme());
+    assertEquals("YTpi",auth.getBase64Token());
+  }
+  
+  @Test
+  public void parseTest() {
+    Iterable<Authentication> ia = Authentication.parse("Custom a=b, Custom2 xyz, Custom3 c=\"foo\"");
+    Iterator<Authentication> i = ia.iterator();
+    Authentication auth = i.next();
+    assertEquals("custom",auth.getScheme());
+    assertTrue(auth.hasParam("a"));
+    assertEquals("b",auth.getParam("a"));
+    
+    auth = i.next();
+    assertEquals("custom2",auth.getScheme());
+    assertEquals("xyz",auth.getBase64Token());
+    
+    auth = i.next();
+    assertEquals("custom3",auth.getScheme());
+    assertTrue(auth.hasParam("c"));
+    assertEquals("foo",auth.getParam("c"));
+  }
+  
+}

Propchange: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/http/AuthenticationTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/http/CacheControlTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/http/CacheControlTest.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/http/CacheControlTest.java (added)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/http/CacheControlTest.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,80 @@
+package org.apache.abdera2.test.common.http;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.abdera2.common.http.CacheControl;
+import org.junit.Test;
+
+public class CacheControlTest {
+
+  public static final String CC = "private=\"A\", public, no-cache=\"A\", no-store, no-transform, only-if-cached, must-revalidate, proxy-revalidate, max-age=10, max-stale=10, min-fresh=10, stale-if-error=10, stale-while-revalidate=10, a=\"b\"";
+  
+  @Test
+  public void testCacheControl() {
+    CacheControl cc = new CacheControl();
+    cc.setExtension("a", "b");
+    assertEquals("b",cc.getExtension("a"));
+    cc.setMaxAge(10);
+    assertEquals(10,cc.getMaxAge());
+    cc.setMaxStale(10);
+    assertEquals(10,cc.getMaxStale());
+    cc.setMinFresh(10);
+    assertEquals(10,cc.getMinFresh());
+    cc.setMustRevalidate(true);
+    assertTrue(cc.isMustRevalidate());
+    cc.setNoCache(true);
+    assertTrue(cc.isNoCache());
+    cc.setNoCacheHeaders("A");
+    String[] hs = cc.getNoCacheHeaders();
+    assertEquals(1,hs.length);
+    assertEquals("A",hs[0]);
+    cc.setNoStore(true);
+    assertTrue(cc.isNoStore());
+    cc.setNoTransform(true);
+    assertTrue(cc.isNoTransform());
+    cc.setOnlyIfCached(true);
+    assertTrue(cc.isOnlyIfCached());
+    cc.setPrivate(true);
+    assertTrue(cc.isPrivate());
+    cc.setPrivateHeaders("A");
+    hs = cc.getNoCacheHeaders();
+    assertEquals(1,hs.length);
+    assertEquals("A",hs[0]);
+    cc.setProxyRevalidate(true);
+    assertTrue(cc.isProxyRevalidate());
+    cc.setPublic(true);
+    assertTrue(cc.isPublic());
+    cc.setStaleIfError(10);
+    assertEquals(10,cc.getStaleIfError());
+    cc.setStaleWhileRevalidate(10);
+    assertEquals(10,cc.getStaleWhileRevalidate());
+    assertEquals(CC,cc.toString());
+  }
+  
+  @Test
+  public void testCacheControl2() {
+    CacheControl cc = new CacheControl(CC);
+    assertEquals("b",cc.getExtension("a"));
+    assertEquals(10,cc.getMaxAge());
+    assertEquals(10,cc.getMaxStale());
+    assertEquals(10,cc.getMinFresh());
+    assertTrue(cc.isMustRevalidate());
+    assertTrue(cc.isNoCache());
+    String[] hs = cc.getNoCacheHeaders();
+    assertEquals(1,hs.length);
+    assertEquals("A",hs[0]);
+    assertTrue(cc.isNoStore());
+    assertTrue(cc.isNoTransform());
+    assertTrue(cc.isOnlyIfCached());
+    assertTrue(cc.isPrivate());
+    hs = cc.getNoCacheHeaders();
+    assertEquals(1,hs.length);
+    assertEquals("A",hs[0]);
+    assertTrue(cc.isProxyRevalidate());
+    assertTrue(cc.isPublic());
+    assertEquals(10,cc.getStaleIfError());
+    assertEquals(10,cc.getStaleWhileRevalidate());
+    assertEquals(CC,cc.toString());
+  }
+}

Propchange: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/http/CacheControlTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/http/EntityTagTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/http/EntityTagTest.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/http/EntityTagTest.java (added)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/http/EntityTagTest.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,59 @@
+package org.apache.abdera2.test.common.http;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Arrays;
+
+import org.apache.abdera2.common.http.EntityTag;
+import org.junit.Test;
+
+public class EntityTagTest {
+  @Test
+  public void testEntityTag() throws Exception {
+      String[] tags = {"hello", "\"hello\"", "W/\"hello\"", "*"};
+      EntityTag[] etags = new EntityTag[tags.length];
+      for (int n = 0; n < tags.length; n++) {
+          etags[n] = new EntityTag(tags[n]);
+      }
+      assertFalse(etags[0].isWeak());
+      assertFalse(etags[0].isWild());
+      assertFalse(etags[1].isWeak());
+      assertFalse(etags[1].isWild());
+      assertTrue(etags[2].isWeak());
+      assertFalse(etags[2].isWild());
+      assertFalse(etags[3].isWeak());
+      assertTrue(etags[3].isWild());
+      assertEquals("hello", etags[0].getTag());
+      assertEquals("hello", etags[1].getTag());
+      assertEquals("hello", etags[2].getTag());
+      assertEquals("*", etags[3].getTag());
+      assertEquals(tags[1], etags[0].toString());
+      assertEquals(tags[1], etags[1].toString());
+      assertEquals(tags[2], etags[2].toString());
+      assertEquals(tags[3], etags[3].toString());
+
+      assertTrue(EntityTag.matches(etags[3], etags[0]));
+      assertTrue(EntityTag.matches(etags[3], etags[1]));
+      assertTrue(EntityTag.matches(etags[3], etags[2]));
+      assertTrue(EntityTag.matches(etags[3], etags[3]));
+
+      assertTrue(EntityTag.matches(etags[0], etags[1]));
+      assertFalse(EntityTag.matches(etags[0], etags[2]));
+
+      assertTrue(EntityTag.matchesAny(etags[3], Arrays.asList(new EntityTag[] {etags[0], etags[1], etags[2]})));
+      assertTrue(EntityTag.matchesAny(etags[0], Arrays.asList(new EntityTag[] {etags[3], etags[1], etags[2]})));
+      assertTrue(EntityTag.matchesAny(etags[1], Arrays.asList(new EntityTag[] {etags[0], etags[3], etags[2]})));
+      assertTrue(EntityTag.matchesAny(etags[2], Arrays.asList(new EntityTag[] {etags[0], etags[1], etags[3]})));
+
+      java.util.Arrays.sort(etags);
+      assertEquals(tags[3], etags[0].toString());
+      assertEquals(tags[1], etags[1].toString());
+      assertEquals(tags[1], etags[2].toString());
+      assertEquals(tags[2], etags[3].toString());
+      EntityTag etag = EntityTag.generate("a", "b", "c", "d");
+      assertEquals("\"e2fc714c4727ee9395f324cd2e7f331f\"", etag.toString().toLowerCase());
+  }
+
+}

Propchange: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/http/EntityTagTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/http/QualityHelperTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/http/QualityHelperTest.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/http/QualityHelperTest.java (added)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/http/QualityHelperTest.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,22 @@
+package org.apache.abdera2.test.common.http;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.abdera2.common.http.QualityHelper;
+import org.apache.abdera2.common.http.QualityHelper.QToken;
+import org.junit.Test;
+
+public class QualityHelperTest {
+
+  @Test
+  public void qualityTest() {
+    String qs = "A;q=0.1, B;q=0.7, C;q=0.5, D";
+    QToken[] tokens = QualityHelper.orderByQ(qs);
+    assertEquals(4,tokens.length);
+    assertEquals("D",tokens[0].token());
+    assertEquals("B",tokens[1].token());
+    assertEquals("C",tokens[2].token());
+    assertEquals("A",tokens[3].token());
+  }
+  
+}

Propchange: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/http/QualityHelperTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/http/ResponseTypeTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/http/ResponseTypeTest.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/http/ResponseTypeTest.java (added)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/http/ResponseTypeTest.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,20 @@
+package org.apache.abdera2.test.common.http;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.abdera2.common.http.ResponseType;
+import org.junit.Test;
+
+public class ResponseTypeTest {
+
+  @Test
+  public void responseTypeTest() {
+    assertEquals(ResponseType.SUCCESSFUL, ResponseType.select(201));
+    assertEquals(ResponseType.REDIRECTION, ResponseType.select(301));
+    assertEquals(ResponseType.CLIENT_ERROR, ResponseType.select(401));
+    assertEquals(ResponseType.SERVER_ERROR, ResponseType.select(501));
+    assertEquals(ResponseType.UNKNOWN, ResponseType.select(601));
+    assertEquals(ResponseType.INFORMATIONAL, ResponseType.select(101));
+  }
+  
+}

Propchange: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/http/ResponseTypeTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/io/CharsetSniffingInputStreamTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/io/CharsetSniffingInputStreamTest.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/io/CharsetSniffingInputStreamTest.java (added)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/io/CharsetSniffingInputStreamTest.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,35 @@
+package org.apache.abdera2.test.common.io;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.ByteArrayInputStream;
+
+import org.apache.abdera2.common.io.CharsetSniffingInputStream;
+import org.junit.Test;
+
+public class CharsetSniffingInputStreamTest {
+
+  @Test
+  public void charsetSniffingInputStreamTest() {
+    try {
+      byte[] data = 
+        {0xFFFFFFEF,  // UTF-8
+         0xFFFFFFBB,
+         0xFFFFFFBF,'A','B','C'};
+      
+      ByteArrayInputStream in = 
+        new ByteArrayInputStream(data);
+      CharsetSniffingInputStream c = 
+        new CharsetSniffingInputStream(in,false);
+      assertEquals("UTF-8",c.getEncoding());
+      byte[] buf = new byte[5];
+      int r = c.read(buf);
+      assertEquals(3,r);
+      assertEquals('A',buf[0]);
+      assertEquals('B',buf[1]);
+      assertEquals('C',buf[2]);
+      assertEquals(0x0,buf[3]);
+    } catch (Throwable t) {}
+  }
+  
+}

Propchange: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/io/CharsetSniffingInputStreamTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/io/CompressionTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/io/CompressionTest.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/io/CompressionTest.java (added)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/io/CompressionTest.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,58 @@
+package org.apache.abdera2.test.common.io;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.apache.abdera2.common.io.Compression;
+import org.apache.abdera2.common.io.Compression.CompressionCodec;
+import org.junit.Test;
+
+public class CompressionTest {
+
+  @Test
+  public void gzipTest() {
+    try {
+    String orig = "ABCDEFG";
+    int len = orig.getBytes("UTF-8").length;
+    ByteArrayOutputStream out = new ByteArrayOutputStream();
+    OutputStream wout = Compression.wrap(out, new CompressionCodec[] {CompressionCodec.GZIP});
+    wout.write(orig.getBytes("UTF-8"));
+    wout.close();
+    byte[] data = out.toByteArray();
+    
+    ByteArrayInputStream in = new ByteArrayInputStream(data);
+    InputStream win = Compression.wrap(in, new CompressionCodec[] {CompressionCodec.GZIP});
+    data = new byte[len+1];
+    int r = win.read(data);
+    assertEquals(len,r);
+    String done = new String(data,0,r,"UTF-8");
+    assertEquals(orig,done);
+    } catch (Throwable t) {}
+  }
+  
+  @Test
+  public void deflateTest() {
+    try {
+    String orig = "ABCDEFG";
+    int len = orig.getBytes("UTF-8").length;
+    ByteArrayOutputStream out = new ByteArrayOutputStream();
+    OutputStream wout = Compression.wrap(out, new CompressionCodec[] {CompressionCodec.DEFLATE});
+    wout.write(orig.getBytes("UTF-8"));
+    wout.close();
+    byte[] data = out.toByteArray();
+    
+    ByteArrayInputStream in = new ByteArrayInputStream(data);
+    InputStream win = Compression.wrap(in, new CompressionCodec[] {CompressionCodec.DEFLATE});
+    data = new byte[len+1];
+    int r = win.read(data);
+    assertEquals(len,r);
+    String done = new String(data,0,r,"UTF-8");
+    assertEquals(orig,done);
+    } catch (Throwable t) {}
+  }
+  
+}

Propchange: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/io/CompressionTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/io/DynamicPushbackInputStreamTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/io/DynamicPushbackInputStreamTest.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/io/DynamicPushbackInputStreamTest.java (added)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/io/DynamicPushbackInputStreamTest.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,30 @@
+package org.apache.abdera2.test.common.io;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.ByteArrayInputStream;
+
+import org.apache.abdera2.common.io.DynamicPushbackInputStream;
+import org.junit.Test;
+
+public class DynamicPushbackInputStreamTest {
+
+  @Test
+  public void dynamicPushbackInputStreamTest() {
+    try {
+      byte[] data = {'A','B','C'};
+      ByteArrayInputStream in = 
+        new ByteArrayInputStream(data);
+      DynamicPushbackInputStream din = 
+        new DynamicPushbackInputStream(in);
+      byte[] buf = new byte[2];
+      int r = din.read(buf);
+      assertEquals(2,r);
+      assertEquals('A',buf[0]);
+      din.unread(1);
+      din.read(buf);
+      assertEquals('B',buf[0]);
+    } catch (Throwable t) {}
+  }
+  
+}

Propchange: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/io/DynamicPushbackInputStreamTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/io/FilteredCharReaderTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/io/FilteredCharReaderTest.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/io/FilteredCharReaderTest.java (added)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/io/FilteredCharReaderTest.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,26 @@
+package org.apache.abdera2.test.common.io;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.CharArrayReader;
+
+import org.apache.abdera2.common.io.FilteredCharReader;
+import org.apache.abdera2.common.text.CharUtils.Profile;
+import org.junit.Test;
+
+public class FilteredCharReaderTest {
+
+  @Test
+  public void filteredCharReaderTest() {
+    try {
+      char[] cs = {0x0,'A',0x0,'B'};
+      CharArrayReader car = new CharArrayReader(cs);
+      FilteredCharReader fcar = new FilteredCharReader(car,Profile.XML1RESTRICTED);
+      char[] data = new char[2];
+      fcar.read(data);
+      assertEquals('A',data[0]);
+      assertEquals('B',data[1]);
+    } catch (Throwable t) {}
+  }
+  
+}

Propchange: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/io/FilteredCharReaderTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/io/MultipartInputStreamTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/io/MultipartInputStreamTest.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/io/MultipartInputStreamTest.java (added)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/io/MultipartInputStreamTest.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,36 @@
+package org.apache.abdera2.test.common.io;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.ByteArrayInputStream;
+
+import org.apache.abdera2.common.io.MultipartInputStream;
+import org.junit.Test;
+
+public class MultipartInputStreamTest {
+
+  @Test
+  public void multipartInputStreamTest() {
+    try {
+      String data = "MIME-Version: 1.0\nContent-Type: multipart/mixed; boundary=\"frontier\"\n\nThis is a message with multiple parts in MIME format.\n--frontier\nContent-Type: text/plain\n\nThis is the body of the message.";
+      ByteArrayInputStream in = new ByteArrayInputStream(data.getBytes("UTF-8"));
+      MultipartInputStream mis = new MultipartInputStream(in,"--frontier".getBytes("UTF-8"));
+      
+      int r = -1;
+      byte[] buf = new byte[100];
+      r = mis.read(buf);
+      String s = new String(buf,0,r,"UTF-8");
+
+      assertEquals("MIME-Version: 1.0\nContent-Type: multipart/mixed; boundary=\"frontier\"\n\nThis is a message with multiple parts in MIME format.\n",s);
+      
+      r = -1;
+      buf = new byte[10];
+      r = mis.read(buf);
+      s = new String(buf,0,r,"UTF-8");
+      
+      assertEquals("Content-Type: text/plain\n\nThis is the body of the message.",s);
+      
+    } catch (Throwable t) {}
+  }
+  
+}

Propchange: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/io/MultipartInputStreamTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/io/PeekAheadInputStreamTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/io/PeekAheadInputStreamTest.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/io/PeekAheadInputStreamTest.java (added)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/io/PeekAheadInputStreamTest.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,28 @@
+package org.apache.abdera2.test.common.io;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.ByteArrayInputStream;
+
+import org.apache.abdera2.common.io.PeekAheadInputStream;
+import org.junit.Test;
+
+public class PeekAheadInputStreamTest {
+
+  @Test
+  public void dynamicPushbackInputStreamTest() {
+    try {
+      byte[] data = {'A','B','C'};
+      ByteArrayInputStream in = 
+        new ByteArrayInputStream(data);
+      PeekAheadInputStream din = 
+        new PeekAheadInputStream(in);
+      byte[] buf = new byte[2];
+      din.peek(buf);
+      assertEquals('A',buf[0]);
+      din.read(buf);
+      assertEquals('A',buf[0]);
+    } catch (Throwable t) {}
+  }
+  
+}

Propchange: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/io/PeekAheadInputStreamTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/iri/IriTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/iri/IriTest.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/iri/IriTest.java (added)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/iri/IriTest.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,35 @@
+package org.apache.abdera2.test.common.iri;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.abdera2.common.iri.IRI;
+import org.junit.Test;
+
+public class IriTest {
+
+  @Test
+  public void testIri() {
+    IRI iri = new IRI("http://www.example.org:81/Bar/%3F/foo/?foo#bar");
+    assertEquals("http",iri.getScheme());
+    assertEquals("www.example.org",iri.getHost());
+    assertEquals(81,iri.getPort());
+    assertEquals("/Bar/%3F/foo/",iri.getPath());
+    assertEquals("foo",iri.getQuery());
+    assertEquals("bar",iri.getFragment());
+    assertTrue(iri.isAbsolute());
+  }
+  
+  @Test
+  public void testUriNormalization() {
+      assertEquals("http://www.example.org/Bar/%3F/foo/", IRI
+          .normalizeString("HTTP://www.EXAMPLE.org:80/foo/../Bar/%3f/./foo/."));
+      assertEquals("https://www.example.org/Bar/%3F/foo/", IRI
+          .normalizeString("HTTPs://www.EXAMPLE.org:443/foo/../Bar/%3f/./foo/."));
+      assertEquals("http://www.example.org:81/Bar/%3F/foo/", IRI
+          .normalizeString("HTTP://www.EXAMPLE.org:81/foo/../Bar/%3f/./foo/."));
+      assertEquals("https://www.example.org:444/Bar/%3F/foo/", IRI
+          .normalizeString("HTTPs://www.EXAMPLE.org:444/foo/../Bar/%3f/./foo/."));
+  }
+  
+}

Propchange: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/iri/IriTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/lang/LangTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/lang/LangTest.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/lang/LangTest.java (added)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/lang/LangTest.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,26 @@
+package org.apache.abdera2.test.common.lang;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.abdera2.common.lang.Lang;
+import org.apache.abdera2.common.lang.Range;
+import org.junit.Test;
+
+public class LangTest {
+
+  @Test
+  public void langTest() {
+    Lang lang = new Lang("fr-Latn-CA-A-123-B-456-789-X-ZZZ");
+    assertEquals("fr",lang.language().name());
+    assertEquals("Latn",lang.script().name());
+    assertEquals("CA",lang.region().name());
+    assertEquals("a",lang.extension().name());
+    assertEquals("123",lang.extension().next().name());
+    assertEquals("x",lang.privateUse().name());
+    assertEquals("zzz",lang.privateUse().next().name());
+    Range range = new Range("*-Latn-CA",true);
+    assertTrue(range.matches(lang));
+  }
+  
+}

Propchange: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/lang/LangTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/mediatype/MimeTypeHelperTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/mediatype/MimeTypeHelperTest.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/mediatype/MimeTypeHelperTest.java (added)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/mediatype/MimeTypeHelperTest.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.test.common.mediatype;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertNull;
+
+import javax.activation.MimeType;
+
+import org.apache.abdera2.common.mediatype.MimeTypeHelper;
+import org.apache.abdera2.model.Element.Helper;
+import org.apache.abdera2.model.Entry;
+import org.apache.abdera2.model.Feed;
+import org.apache.abdera2.model.Service;
+import org.easymock.EasyMock;
+import org.junit.Test;
+
+public class MimeTypeHelperTest {
+
+    @Test
+    public void testCondense() {
+        String[] types = MimeTypeHelper.condense("image/png", "image/gif", "image/png", "image/*");
+        assertEquals(1, types.length);
+        assertEquals("image/*", types[0]);
+    }
+
+    @Test
+    public void testGetCharset() {
+        String charsetIso = MimeTypeHelper.getCharset("text/html; charset=utf-8");
+        assertEquals("utf-8", charsetIso);
+
+        String charsetEmpty = MimeTypeHelper.getCharset("text/plain");
+        assertNull(charsetEmpty);
+    }
+
+    @Test
+    public void testGetMimeType() {
+        String mimeType1 = Helper.getMimeType(EasyMock.createMock(Feed.class));
+        assertEquals("application/atom+xml;type=feed", mimeType1);
+        String mimeType2 = Helper.getMimeType(EasyMock.createMock(Entry.class));
+        assertEquals("application/atom+xml;type=entry", mimeType2);
+        String mimeType3 = Helper.getMimeType(EasyMock.createMock(Service.class));
+        assertEquals("application/atomsvc+xml", mimeType3);
+    }
+
+    @Test
+    public void testIsApp() {
+        assertTrue(MimeTypeHelper.isApp("application/atomsvc+xml"));
+        assertFalse(MimeTypeHelper.isApp("application/atomserv+xml"));
+    }
+
+    @Test
+    public void testIsAtom() {
+        assertTrue(MimeTypeHelper.isAtom("application/atom+xml"));
+        assertTrue(MimeTypeHelper.isAtom("application/atom+xml;type=\"entry\""));
+        assertTrue(MimeTypeHelper.isAtom("application/atom+xml;type=\"feed\""));
+    }
+
+    @Test
+    public void testIsEntry() {
+        assertTrue(MimeTypeHelper.isEntry("application/atom+xml;type=\"entry\""));
+    }
+
+    @Test
+    public void testIsFeed() {
+        assertTrue(MimeTypeHelper.isFeed("application/atom+xml;type=\"feed\""));
+    }
+
+    @Test
+    public void testIsMatch() throws Exception {
+        assertTrue(MimeTypeHelper.isMatch("application/atom+xml;type=entry", "application/atom+xml;type=feed"));
+        assertTrue(MimeTypeHelper.isMatch("*/*", "application/atom+xml;type=feed"));
+        assertTrue(MimeTypeHelper.isMatch("application/atom+xml;type=entry", "*/*"));
+        assertFalse(MimeTypeHelper.isMatch(null, "application/atom+xml;type=feed"));
+        assertFalse(MimeTypeHelper.isMatch("blafasel", "application/atom+xml;type=feed"));
+
+        MimeType mimeType1 = new MimeType("application/atom+xml;type=entry");
+        MimeType mimeType2 = new MimeType("application/atom+xml;type=feed");
+        assertFalse(MimeTypeHelper.isMatch(mimeType1, mimeType2, true));
+    }
+
+    @Test
+    public void testIsMimeType() {
+        assertTrue(MimeTypeHelper.isMimeType("text/html"));
+        assertTrue(MimeTypeHelper.isMimeType("*/*"));
+        assertTrue(MimeTypeHelper.isMimeType("blafasel/pdf"));
+        assertFalse(MimeTypeHelper.isMimeType("text"));
+    }
+
+    @Test
+    public void testIsMultipart() {
+        assertTrue(MimeTypeHelper.isMultipart("multipart/related"));
+    }
+
+    @Test
+    public void testIsText() {
+        assertTrue(MimeTypeHelper.isText("text/plain"));
+    }
+
+    @Test
+    public void testIsXml() {
+        assertTrue(MimeTypeHelper.isXml("application/xml"));
+    }
+}

Propchange: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/mediatype/MimeTypeHelperTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/misc/MiscTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/misc/MiscTest.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/misc/MiscTest.java (added)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/misc/MiscTest.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,58 @@
+package org.apache.abdera2.test.common.misc;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import org.apache.abdera2.common.misc.MultiIterator;
+import org.apache.abdera2.common.misc.PoolManager;
+import org.junit.Test;
+
+public class MiscTest {
+
+  @SuppressWarnings("unchecked")
+  @Test
+  public void multiIteratorTest() {
+    Set<String> a1 = new LinkedHashSet<String>();
+    a1.add("a");
+    a1.add("b");
+    a1.add("c");
+    Set<String> a2 = new LinkedHashSet<String>();
+    a2.add("d");
+    a2.add("e");
+    a2.add("f");
+    MultiIterator<String> mi = 
+      new MultiIterator<String>(a1.iterator(),a2.iterator());
+    assertEquals("a",mi.next());
+    assertEquals("b",mi.next());
+    assertEquals("c",mi.next());
+    assertTrue(mi.hasNext());
+    assertEquals("d",mi.next());
+    assertEquals("e",mi.next());
+    assertEquals("f",mi.next());
+    assertFalse(mi.hasNext());
+  }
+  
+  @Test
+  public void poolManagerTest() {
+    PoolManager<String,String> pm = 
+      new PoolManager<String,String>(2) {
+        private int c = 0;
+        protected String internalNewInstance() {
+          return "A"+(c++);
+        }
+    };
+    assertEquals("A0",pm.get(""));
+    assertEquals("A1",pm.get(""));
+    pm.release("A0");
+    assertEquals("A0",pm.get(""));
+    pm.release("A0");
+    pm.release("A1");
+    pm.release("A2");
+    assertEquals("A1",pm.get(""));
+    assertEquals("A2",pm.get(""));
+  }
+}

Propchange: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/misc/MiscTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/templates/TemplateTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/templates/TemplateTest.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/templates/TemplateTest.java (added)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/templates/TemplateTest.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,108 @@
+package org.apache.abdera2.test.common.templates;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.abdera2.common.templates.DefaultingContext;
+import org.apache.abdera2.common.templates.MapContext;
+import org.apache.abdera2.common.templates.Route;
+import org.apache.abdera2.common.templates.Template;
+import org.apache.abdera2.common.anno.Name;
+import org.junit.Test;
+
+public class TemplateTest {
+
+  private static final String template = "{scheme}://www{.host*}{/path*}{;g}{?a,b}{&c,d}{#e,f}";
+  
+  @Test
+  public void templateTest() {
+    
+    MapContext map = new MapContext();
+    map.put("scheme","http");
+    map.put("host", new String[] {"example","org"});
+    map.put("path", new String[] {"a","b","c","d"});
+    map.put("a",1);
+    map.put("b",2);
+    map.put("c",3);
+    map.put("d",4);
+    map.put("e",5);
+    map.put("f",6);
+    map.put("g",7);
+    assertEquals(
+      "http://www.example.org/a/b/c/d;g=7?a=1&b=2&c=3&d=4#5,6",
+      Template.expand(template,map));
+  }
+  
+  @Test
+  public void objectContextTest() {
+    Foo foo = new Foo();
+    assertEquals(
+        "http://www.example.org/a/b/c/d;g=7?a=1&b=2&c=3&d=4#5,6",
+        Template.expand(template,foo));
+  }
+  
+  public static class Foo {
+    @Name("scheme") public String thescheme = "http";
+    public String[] getHost() {
+      return new String[] {"example","org"};
+    }
+    public Iterable<String> getPath() {
+      List<String> l = new ArrayList<String>();
+      l.add("a");
+      l.add("b");
+      l.add("c");
+      l.add("d");
+      return l;
+    }
+    @Name("a")
+    public int get_a() {
+      return 1;
+    }
+    public Integer getB() {
+      return new Integer(2);
+    }
+    public Integer getC() {
+      return 3;
+    }
+    public int getD() {
+      return 4;
+    }
+    public short getE() {
+      return 5;
+    }
+    public short getF() {
+      return 6;
+    }
+    public long getG() {
+      return 7;
+    }
+  }
+  
+  @Test
+  public void defaultingContextTest() {
+    MapContext m1 = new MapContext();
+    m1.put("a", "b");
+    MapContext m2 = new MapContext();
+    m2.put("b", "c");
+    m2.put("c", "d");
+    DefaultingContext dc = 
+      new DefaultingContext(m2,m1);
+    assertEquals(dc.resolve("a"),"b");
+    assertEquals(dc.resolve("b"),"c");
+    m2.put("a", "z"); // changing the main context
+    assertEquals(dc.resolve("a"),"z");
+    assertEquals(m1.resolve("a"),"b"); // does not change the default
+  }
+  
+  @Test
+  public void routeTest() {
+    Route<String> route = new Route<String>("A","http://foo/:a/:b/:c");
+    Map<String,String> map = route.parse("http://foo/1/2/3");
+    assertEquals(map.get("a"),"1");
+    assertEquals(map.get("b"),"2");
+    assertEquals(map.get("c"),"3");
+  }
+}

Propchange: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/templates/TemplateTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/text/CharUtilsTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/text/CharUtilsTest.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/text/CharUtilsTest.java (added)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/text/CharUtilsTest.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,45 @@
+package org.apache.abdera2.test.common.text;
+
+import org.apache.abdera2.common.text.CharUtils;
+import org.apache.abdera2.common.text.InvalidCharacterException;
+import org.junit.Test;
+
+import static junit.framework.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
+
+public class CharUtilsTest {
+
+  @Test
+  public void isAlphaTest() {
+    for (char c = 'A'; c <= 'Z'; c++)
+      assertTrue(CharUtils.isAlpha(c));
+    for (char c = 'a'; c <= 'z'; c++)
+      assertTrue(CharUtils.isAlpha(c));
+    assertFalse(CharUtils.isAlpha('1'));
+  }
+  
+  @Test
+  public void isDigitTest() {
+    assertTrue(CharUtils.isDigit('0'));
+    assertTrue(CharUtils.isDigit('1'));
+    assertTrue(CharUtils.isDigit('2'));
+    assertTrue(CharUtils.isDigit('3'));
+    assertTrue(CharUtils.isDigit('4'));
+    assertTrue(CharUtils.isDigit('5'));
+    assertTrue(CharUtils.isDigit('6'));
+    assertTrue(CharUtils.isDigit('7'));
+    assertTrue(CharUtils.isDigit('8'));
+    assertTrue(CharUtils.isDigit('9'));
+    assertFalse(CharUtils.isDigit('A'));
+  }
+  
+  @Test
+  public void verifyTest() {
+    CharUtils.verify(new char[] {'t','e','s','t','1'}, CharUtils.Profile.ALPHANUM);
+  }
+  
+  @Test(expected=InvalidCharacterException.class)
+  public void verifyFailureTest() {
+    CharUtils.verify(new char[] {'t','e','s','t','1',','}, CharUtils.Profile.ALPHANUM);
+  }
+}

Propchange: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/text/CharUtilsTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/text/CodecTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/text/CodecTest.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/text/CodecTest.java (added)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/text/CodecTest.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,26 @@
+package org.apache.abdera2.test.common.text;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.abdera2.common.text.Codec;
+import org.junit.Test;
+
+public class CodecTest {
+
+  @Test 
+  public void codecTest() {
+    String foo = "\u2020abcdefg";
+    String bar = Codec.encode(foo,Codec.B);
+    assertEquals("=?UTF-8?B?4oCgYWJjZGVmZw==?=", bar);
+    assertEquals(foo, Codec.decode(bar));
+    
+    bar = Codec.encode(foo,Codec.Q);
+    assertEquals("=?UTF-8?Q?=E2=80=A0abcdefg?=", bar);
+    assertEquals(foo, Codec.decode(bar));
+    
+    bar = Codec.encode(foo,Codec.STAR);
+    assertEquals("UTF-8''%E2%80%A0abcdefg", bar);
+    assertEquals(foo, Codec.decode(bar));
+  }
+  
+}

Propchange: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/text/CodecTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/text/CodepointIteratorTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/text/CodepointIteratorTest.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/text/CodepointIteratorTest.java (added)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/text/CodepointIteratorTest.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,25 @@
+package org.apache.abdera2.test.common.text;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.NoSuchElementException;
+
+import org.apache.abdera2.common.text.CodepointIterator;
+import org.junit.Test;
+
+public class CodepointIteratorTest {
+
+  @Test(expected=NoSuchElementException.class)
+  public void codepointIteratorTest() {
+    // test supplemental codepoints...
+    char[] chars = {'A','B',0xD800,0xDEB7,'C','D'};
+    CodepointIterator ci = CodepointIterator.getInstance(chars);
+    assertEquals(new Integer(65),ci.next());
+    assertEquals(new Integer(66),ci.next());
+    assertEquals(new Integer(66231),ci.next());
+    assertEquals(new Integer(67),ci.next());
+    assertEquals(new Integer(68),ci.next());
+    ci.next(); // will throw exception
+  }
+  
+}

Propchange: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/text/CodepointIteratorTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/text/NormalizationFormTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/text/NormalizationFormTest.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/text/NormalizationFormTest.java (added)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/text/NormalizationFormTest.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,51 @@
+package org.apache.abdera2.test.common.text;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.abdera2.common.text.NormalizationForm;
+import org.junit.Test;
+
+public class NormalizationFormTest {
+
+  @Test
+  public void normalizationFormTest() {
+    
+    String data = "A\u030ABCDE\u0073\u0323\u0307";
+    
+    String C = NormalizationForm.C.normalize(data);
+
+    assertEquals(data.charAt(0),'A');
+    assertEquals(C.charAt(0),0x00C5);
+    assertEquals(C.charAt(C.length()-1),0x1E69);
+    assertEquals(data.length()-3,C.length());
+    
+    String D = NormalizationForm.D.normalize(C);
+    
+    assertEquals(D.charAt(0),'A');
+    assertEquals(D.charAt(1),0x030A);
+    
+    data = "\u1E9B\u0323";
+    
+    String KC = NormalizationForm.KC.normalize(data);
+    assertEquals(1,KC.length());
+    assertEquals(0x1E69,KC.charAt(0));
+    
+    String KD = NormalizationForm.KD.normalize(data);
+    assertEquals(3,KD.length());
+    assertEquals(0x0073,KD.charAt(0));
+    assertEquals(0x0323,KD.charAt(1));
+    assertEquals(0x0307,KD.charAt(2));
+    
+    D = NormalizationForm.D.normalize(data);
+    assertEquals(3,D.length());
+    assertEquals(0x017F,D.charAt(0));
+    assertEquals(0x0323,D.charAt(1));
+    assertEquals(0x0307,D.charAt(2));
+    
+    C = NormalizationForm.C.normalize(data);
+    assertEquals(2,C.length());
+    assertEquals(0x1E9B,C.charAt(0));
+    assertEquals(0x0323,C.charAt(1));
+  }
+  
+}

Propchange: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/text/NormalizationFormTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/text/SlugTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/text/SlugTest.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/text/SlugTest.java (added)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/text/SlugTest.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,18 @@
+package org.apache.abdera2.test.common.text;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.abdera2.common.text.NormalizationForm;
+import org.apache.abdera2.common.text.Slug;
+import org.junit.Test;
+
+public class SlugTest {
+
+  @Test
+  public void slugTest() {
+    assertEquals("a_slug",Slug.create("A Slug").toString());
+    assertEquals("a__slug",Slug.create("\u212B Slug","_").toString());
+    assertEquals("A%CC%8A_Slug",Slug.create("\u212B Slug", null, false, NormalizationForm.D).toString());
+  }
+  
+}

Propchange: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/text/SlugTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/xml/XmlTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/xml/XmlTest.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/xml/XmlTest.java (added)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/xml/XmlTest.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,32 @@
+package org.apache.abdera2.test.common.xml;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.abdera2.common.xml.XMLVersion;
+import org.apache.abdera2.common.xml.XmlRestrictedCharReader;
+import org.junit.Test;
+
+import com.sun.xml.internal.messaging.saaj.util.CharReader;
+
+public class XmlTest {
+
+  @Test
+  public void testXMLRestrictedCharReader() {
+    try {
+      char[] data = {0x0,'<','a',0x0, '/', '>'};
+      
+      CharReader cr = new CharReader(data,0,5);
+      XmlRestrictedCharReader r = 
+        new XmlRestrictedCharReader(cr,XMLVersion.XML10);
+      char[] buf = new char[6];
+      int n = r.read(buf);
+      assertEquals(4,n);
+      assertEquals('<',buf[0]);
+      assertEquals('a',buf[1]);
+      assertEquals('/',buf[2]);
+      assertEquals('>',buf[3]);
+      assertEquals(0x0,buf[4]);
+    } catch (Throwable t) {}
+  }
+  
+}

Propchange: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/xml/XmlTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/ext/bidi/BidiTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/ext/bidi/BidiTest.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/ext/bidi/BidiTest.java (added)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/ext/bidi/BidiTest.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.test.ext.bidi;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.apache.abdera2.Abdera;
+import org.apache.abdera2.ext.bidi.BidiHelper;
+import org.apache.abdera2.ext.bidi.BidiHelper.Direction;
+import org.apache.abdera2.model.Entry;
+import org.apache.abdera2.model.Feed;
+import org.junit.Test;
+
+public class BidiTest {
+
+    @Test
+    public void testBidi() throws Exception {
+
+        Abdera abdera = Abdera.getInstance();
+        Feed feed = abdera.getFactory().newFeed();
+        feed.setTitle("Testing");
+        feed.setSubtitle("Testing");
+        BidiHelper.setDirection(Direction.RTL, feed);
+        BidiHelper.setDirection(Direction.LTR, feed.getSubtitleElement());
+
+        assertNotNull(feed.getAttributeValue("dir"));
+        assertEquals(Direction.RTL, BidiHelper.getDirection(feed));
+        assertEquals(Direction.RTL, BidiHelper.getDirection(feed.getTitleElement()));
+        assertEquals(Direction.LTR, BidiHelper.getDirection(feed.getSubtitleElement()));
+        assertEquals(BidiHelper.getBidiText(Direction.RTL, "Testing"), BidiHelper.getBidiElementText(feed
+            .getTitleElement()));
+        assertEquals(BidiHelper.getBidiText(Direction.LTR, "Testing"), BidiHelper.getBidiElementText(feed
+            .getSubtitleElement()));
+
+        Entry entry = abdera.newEntry();
+        entry.setLanguage("az-arab");
+        assertEquals(Direction.RTL, BidiHelper.guessDirectionFromLanguage(entry));
+
+        entry.setLanguage("az-latn");
+        assertEquals(Direction.UNSPECIFIED, BidiHelper.guessDirectionFromLanguage(entry));
+
+        assertEquals(Direction.UNSPECIFIED, BidiHelper.guessDirectionFromEncoding(entry));
+
+        entry.getDocument().setCharset("iso-8859-6");
+        assertEquals(Direction.RTL, BidiHelper.guessDirectionFromEncoding(entry));
+    }
+
+}

Propchange: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/ext/bidi/BidiTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/ext/features/FeatureTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/ext/features/FeatureTest.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/ext/features/FeatureTest.java (added)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/ext/features/FeatureTest.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.test.ext.features;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.abdera2.Abdera;
+import org.apache.abdera2.common.selector.Selector;
+import org.apache.abdera2.ext.features.Feature;
+import org.apache.abdera2.ext.features.FeatureSelector;
+import org.apache.abdera2.ext.features.Features;
+import org.apache.abdera2.ext.features.FeaturesHelper;
+import org.apache.abdera2.model.selector.CollectionAcceptSelector;
+import org.apache.abdera2.model.selector.XPathSelector;
+import org.apache.abdera2.ext.features.FeaturesHelper.Status;
+import org.apache.abdera2.model.Collection;
+import org.apache.abdera2.model.Document;
+import org.apache.abdera2.model.Service;
+import org.apache.abdera2.model.Workspace;
+import org.junit.Test;
+
+public class FeatureTest {
+
+    @Test
+    public void testFeaturesDocument() throws Exception {
+        Abdera abdera = Abdera.getInstance();
+        Features features = FeaturesHelper.newFeatures(abdera);
+        assertNotNull(features);
+        assertNotNull(features.getDocument());
+        Document<Features> doc = features.getDocument();
+        assertTrue(doc.getRoot() instanceof Features);
+    }
+
+    @Test
+    public void testFeatures() throws Exception {
+        Abdera abdera = Abdera.getInstance();
+        Collection coll = abdera.getFactory().newCollection();
+        Features features = FeaturesHelper.addFeaturesElement(coll);
+        features.addFeature("http://example.com/features/foo", null, "foo & here");
+        features.addFeature("http://example.com/features/bar", null, null);
+
+        assertEquals(Status.SPECIFIED, FeaturesHelper.getFeatureStatus(coll, "http://example.com/features/foo"));
+        assertEquals(Status.SPECIFIED, FeaturesHelper.getFeatureStatus(coll, "http://example.com/features/bar"));
+        assertEquals(Status.UNSPECIFIED, FeaturesHelper.getFeatureStatus(coll, "http://example.com/features/baz"));
+        assertEquals(Status.UNSPECIFIED, FeaturesHelper.getFeatureStatus(coll, "http://example.com/features/pez"));
+
+    }
+
+    @Test
+    public void testSelectors() throws Exception {
+
+        Abdera abdera = Abdera.getInstance();
+        Service service = abdera.newService();
+        Workspace workspace = service.addWorkspace("a");
+        Collection collection1 = workspace.addCollection("a1", "a1");
+        collection1.setAcceptsEntry();
+        Features features = FeaturesHelper.addFeaturesElement(collection1);
+        features.addFeature(FeaturesHelper.FEATURE_SUPPORTS_DRAFTS);
+        Collection collection2 = workspace.addCollection("a2", "a2");
+        collection2.setAccept("image/*");
+
+        Selector s1 = new FeatureSelector(FeaturesHelper.FEATURE_SUPPORTS_DRAFTS);
+        
+        Iterable<Collection> collections = FeaturesHelper.select(service, s1);
+
+        assertEquals(collections.iterator().next(), collection1);
+
+        Selector s2 = new CollectionAcceptSelector("image/png");
+
+        collections = FeaturesHelper.select(service, s2);
+
+        assertEquals(collections.iterator().next(), collection2);
+
+        XPathSelector s3 = new XPathSelector("f:features/f:feature[@ref='" + FeaturesHelper.FEATURE_SUPPORTS_DRAFTS + "']");
+        s3.addNamespace("f", FeaturesHelper.FNS);
+        
+        collections = FeaturesHelper.select(service, s3);
+
+        assertEquals(collections.iterator().next(), collection1);
+    }
+
+    @Test
+    public void testType() throws Exception {
+        Abdera abdera = Abdera.getInstance();
+        Feature feature = abdera.getFactory().newElement(FeaturesHelper.FEATURE);
+        feature.addType("image/jpg", "image/gif", "image/png", "image/*");
+        Iterable<String> types = feature.getTypes();
+        assertEquals("image/*", types.iterator().next());
+    }
+}

Propchange: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/ext/features/FeatureTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/ext/history/FeedPagingTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/ext/history/FeedPagingTest.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/ext/history/FeedPagingTest.java (added)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/ext/history/FeedPagingTest.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.test.ext.history;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera2.Abdera;
+import org.apache.abdera2.ext.history.FeedPagingHelper;
+import org.apache.abdera2.model.Feed;
+import org.junit.Test;
+
+public class FeedPagingTest {
+
+    @Test
+    public void testHistory() throws Exception {
+
+        Abdera abdera = org.apache.abdera2.Abdera.getInstance();
+
+        Feed feed = abdera.newFeed();
+
+        FeedPagingHelper.setComplete(feed, true);
+        FeedPagingHelper.setArchive(feed, true);
+
+        FeedPagingHelper.setNext(feed, "http://example.org/foo");
+        FeedPagingHelper.setNext(feed, "http://example.org/bar");
+
+        FeedPagingHelper.setPrevious(feed, "http://example.org/foo");
+        FeedPagingHelper.setPrevious(feed, "http://example.org/bar");
+
+        FeedPagingHelper.setLast(feed, "http://example.org/foo");
+        FeedPagingHelper.setLast(feed, "http://example.org/bar");
+
+        FeedPagingHelper.setFirst(feed, "http://example.org/foo");
+        FeedPagingHelper.setFirst(feed, "http://example.org/bar");
+
+        FeedPagingHelper.setPreviousArchive(feed, "http://example.org/foo");
+        FeedPagingHelper.setPreviousArchive(feed, "http://example.org/bar");
+
+        FeedPagingHelper.setNextArchive(feed, "http://example.org/foo");
+        FeedPagingHelper.setNextArchive(feed, "http://example.org/bar");
+
+        FeedPagingHelper.setCurrent(feed, "http://example.org/foo");
+        FeedPagingHelper.setCurrent(feed, "http://example.org/bar");
+
+        assertTrue(FeedPagingHelper.isPaged(feed));
+        assertTrue(FeedPagingHelper.isComplete(feed));
+        assertTrue(FeedPagingHelper.isArchive(feed));
+
+        assertNotNull(FeedPagingHelper.getNext(feed));
+        assertNotNull(FeedPagingHelper.getPrevious(feed));
+        assertNotNull(FeedPagingHelper.getLast(feed));
+        assertNotNull(FeedPagingHelper.getFirst(feed));
+        assertNotNull(FeedPagingHelper.getNextArchive(feed));
+        assertNotNull(FeedPagingHelper.getPreviousArchive(feed));
+        assertNotNull(FeedPagingHelper.getCurrent(feed));
+
+        assertEquals("http://example.org/bar", FeedPagingHelper.getNext(feed).toString());
+    }
+
+    @Test
+    public void testHistory2() throws Exception {
+        Abdera abdera = Abdera.getInstance();
+        Feed feed = abdera.newFeed();
+        QName complete = new QName(FeedPagingHelper.FHNS, "complete", "x");
+        feed.addExtension(complete);
+        assertTrue(FeedPagingHelper.isComplete(feed));
+    }
+}

Propchange: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/ext/history/FeedPagingTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/ext/json/JSONStreamTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/ext/json/JSONStreamTest.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/ext/json/JSONStreamTest.java (added)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/ext/json/JSONStreamTest.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.test.ext.json;
+
+import static org.junit.Assert.assertTrue;
+import java.io.ByteArrayOutputStream;
+
+import org.apache.abdera2.Abdera;
+import org.apache.abdera2.common.iri.IRI;
+import org.apache.abdera2.model.Entry;
+import org.apache.abdera2.writer.Writer;
+import org.junit.Test;
+
+public class JSONStreamTest {
+
+    @Test
+    public void testJSONStreamContent() throws Exception {
+        Abdera abdera = Abdera.getInstance();
+        Entry entry = abdera.newEntry();
+
+        entry.setContent(new IRI("http://example.org/xml"), "text/xml");
+
+        Writer json = abdera.getWriterFactory().getWriter("json");
+        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+        entry.writeTo(json, outputStream);
+        String output = outputStream.toString();
+        assertTrue(output.contains("\"type\":\"text/xml\""));
+        assertTrue(output.contains("\"src\":\"http://example.org/xml\""));
+        assertTrue(output.contains("\"content\":"));
+    }
+}

Propchange: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/ext/json/JSONStreamTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/ext/license/LicenseTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/ext/license/LicenseTest.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/ext/license/LicenseTest.java (added)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/ext/license/LicenseTest.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.test.ext.license;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.abdera2.Abdera;
+import org.apache.abdera2.ext.license.LicenseHelper;
+import org.apache.abdera2.model.Entry;
+import org.apache.abdera2.model.Feed;
+import org.junit.Test;
+
+public class LicenseTest {
+
+    @Test
+    public void testLicense() throws Exception {
+
+        String license = "http://example.org";
+
+        Abdera abdera = Abdera.getInstance();
+        Feed feed = abdera.newFeed();
+
+        Entry entry = feed.addEntry();
+
+        LicenseHelper.addLicense(feed, license);
+
+        assertTrue(LicenseHelper.hasLicense(feed, license));
+        assertFalse(LicenseHelper.hasLicense(entry, license, false));
+        assertTrue(LicenseHelper.hasLicense(entry, license, true));
+
+        assertNotNull(LicenseHelper.addUnspecifiedLicense(entry));
+
+        assertFalse(LicenseHelper.hasLicense(entry, license, true));
+
+        entry = abdera.newEntry();
+        entry.setSource(feed.getAsSource());
+
+        assertFalse(LicenseHelper.hasLicense(entry, license, false));
+        assertTrue(LicenseHelper.hasLicense(entry, license, true));
+
+        boolean died = false;
+        entry = abdera.newEntry();
+        LicenseHelper.addLicense(entry, license);
+        try {
+            // will die because the license already exists
+            LicenseHelper.addLicense(entry, license);
+        } catch (IllegalStateException e) {
+            died = true;
+        }
+        assertTrue(died);
+
+        died = false;
+        try {
+            // will die because another license already exists
+            LicenseHelper.addUnspecifiedLicense(entry);
+        } catch (IllegalStateException e) {
+            died = true;
+        }
+        assertTrue(died);
+
+        died = false;
+        entry = abdera.newEntry();
+        LicenseHelper.addUnspecifiedLicense(entry);
+        try {
+            // will die because the unspecified license already exists
+            LicenseHelper.addLicense(entry, license);
+        } catch (IllegalStateException e) {
+            died = true;
+        }
+        assertTrue(died);
+
+        died = false;
+        entry = abdera.newEntry();
+        LicenseHelper.addUnspecifiedLicense(entry);
+        try {
+            // will die because the unspecified license already exists
+            LicenseHelper.addUnspecifiedLicense(entry);
+        } catch (IllegalStateException e) {
+            died = true;
+        }
+        assertTrue(died);
+
+    }
+
+}

Propchange: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/ext/license/LicenseTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/ext/media/MediaTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/ext/media/MediaTest.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/ext/media/MediaTest.java (added)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/ext/media/MediaTest.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.test.ext.media;
+
+import static org.apache.abdera2.ext.media.MediaConstants.CONTENT;
+import static org.apache.abdera2.ext.media.MediaConstants.GROUP;
+import static org.apache.abdera2.ext.media.MediaConstants.TITLE;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.util.List;
+
+import org.apache.abdera2.Abdera;
+import org.apache.abdera2.ext.media.MediaContent;
+import org.apache.abdera2.ext.media.MediaGroup;
+import org.apache.abdera2.ext.media.MediaTitle;
+import org.apache.abdera2.ext.media.MediaConstants.Expression;
+import org.apache.abdera2.ext.media.MediaConstants.Type;
+import org.apache.abdera2.factory.Factory;
+import org.apache.abdera2.model.Document;
+import org.apache.abdera2.model.Entry;
+import org.apache.abdera2.parser.Parser;
+import org.junit.Test;
+
+public class MediaTest {
+
+    @Test
+    public void testMedia() throws Exception {
+
+        Abdera abdera = Abdera.getInstance();
+        Factory factory = abdera.getFactory();
+        Entry entry = factory.newEntry();
+        MediaGroup group = entry.addExtension(GROUP);
+        MediaContent content = group.addExtension(CONTENT);
+        content.setUrl("http://example.org");
+        content.setBitrate(123);
+        content.setChannels(2);
+        content.setDuration(123);
+        content.setExpression(Expression.SAMPLE);
+        content.setFilesize(12345);
+        content.setFramerate(123);
+        content.setLanguage("en");
+        MediaTitle title = content.addExtension(TITLE);
+        title.setType(Type.PLAIN);
+        title.setText("This is a sample");
+
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        entry.writeTo(out);
+
+        ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
+        Parser parser = abdera.getParser();
+        Document<Entry> doc = parser.parse(in);
+        entry = doc.getRoot();
+
+        group = entry.getExtension(GROUP);
+        List<MediaContent> list = entry.getExtensions(CONTENT);
+        for (MediaContent item : list) {
+            assertEquals("http://example.org", item.getUrl().toString());
+            assertEquals(123, item.getBitrate());
+            assertEquals(2, item.getChannels());
+            assertEquals(123, item.getDuration());
+            assertEquals(Expression.SAMPLE, item.getExpression());
+            assertEquals(12345, item.getFilesize());
+            assertEquals(123, item.getFramerate());
+            assertEquals("en", item.getLang());
+            title = item.getExtension(TITLE);
+            assertNotNull(title);
+            assertEquals(Type.PLAIN, title.getType());
+            assertEquals("This is a sample", title.getText());
+        }
+    }
+
+}

Propchange: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/ext/media/MediaTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/ext/rss/RssTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/ext/rss/RssTest.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/ext/rss/RssTest.java (added)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/ext/rss/RssTest.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.test.ext.rss;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.InputStream;
+import java.util.List;
+
+import org.apache.abdera2.Abdera;
+import org.apache.abdera2.model.Document;
+import org.apache.abdera2.model.Entry;
+import org.apache.abdera2.model.Feed;
+import org.apache.abdera2.model.Person;
+import org.junit.Test;
+
+public class RssTest {
+
+    @Test
+    public void testRSS1() {
+
+        Abdera abdera = Abdera.getInstance();
+
+        InputStream in = RssTest.class.getResourceAsStream("/rss1.rdf");
+
+        Document<Feed> doc = abdera.getParser().parse(in);
+
+        Feed feed = doc.getRoot();
+
+        assertEquals("XML.com", feed.getTitle());
+        assertEquals("http://xml.com/pub", feed.getAlternateLinkResolvedHref().toASCIIString());
+        assertEquals("XML.com features a rich mix of information and services \n      for the XML community.", feed
+            .getSubtitle().trim());
+        assertNotNull(feed.getAuthor());
+        assertEquals("James Snell", feed.getAuthor().getName());
+        assertEquals("jasnell@example.com", feed.getAuthor().getEmail());
+        assertEquals(1, feed.getCategories().size());
+        assertEquals("Anything", feed.getCategories().get(0).getTerm());
+        assertEquals("foo", feed.getId().toASCIIString());
+        assertEquals("Copyright 2007 Foo", feed.getRights());
+        assertNotNull(feed.getUpdated());
+        assertEquals("en-US", feed.getLanguage());
+        assertEquals(1, feed.getContributors().size());
+        Person person = feed.getContributors().get(0);
+        assertEquals("John Doe", person.getName());
+        assertEquals("jdoe@example.org", person.getEmail());
+
+        List<Entry> entries = feed.getEntries();
+        assertEquals(2, entries.size());
+
+        Entry entry = entries.get(0);
+        assertEquals("Processing Inclusions with XSLT", entry.getTitle());
+        assertEquals("http://xml.com/pub/2000/08/09/xslt/xslt.html", entry.getId().toASCIIString());
+        assertEquals("http://xml.com/pub/2000/08/09/xslt/xslt.html", entry.getAlternateLinkResolvedHref()
+            .toASCIIString());
+        assertNotNull(entry.getSummary());
+        assertEquals("testing", entry.getContent());
+
+        person = entry.getAuthor();
+        assertEquals("Bob", person.getName());
+
+        entry = entries.get(1);
+        assertEquals("Putting RDF to Work", entry.getTitle());
+        assertEquals("http://xml.com/pub/2000/08/09/rdfdb/index.html", entry.getId().toASCIIString());
+        assertEquals("http://xml.com/pub/2000/08/09/rdfdb/index.html", entry.getAlternateLinkResolvedHref()
+            .toASCIIString());
+
+        assertNotNull(entry.getSummary());
+        assertEquals("testing", entry.getContent());
+
+        person = entry.getAuthor();
+        assertEquals("Joe", person.getName());
+
+    }
+
+}

Propchange: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/ext/rss/RssTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/ext/serializer/SerializerTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/ext/serializer/SerializerTest.java?rev=1173209&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/ext/serializer/SerializerTest.java (added)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/ext/serializer/SerializerTest.java Tue Sep 20 15:56:46 2011
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.abdera2.test.ext.serializer;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.util.Calendar;
+import java.util.Date;
+
+import org.apache.abdera2.Abdera;
+import org.apache.abdera2.ext.serializer.ConventionSerializationContext;
+import org.apache.abdera2.ext.serializer.annotation.Author;
+import org.apache.abdera2.ext.serializer.annotation.ID;
+import org.apache.abdera2.ext.serializer.annotation.Link;
+import org.apache.abdera2.ext.serializer.annotation.Published;
+import org.apache.abdera2.ext.serializer.annotation.Summary;
+import org.apache.abdera2.ext.serializer.annotation.Title;
+import org.apache.abdera2.ext.serializer.annotation.Updated;
+import org.apache.abdera2.ext.serializer.impl.EntrySerializer;
+import org.apache.abdera2.model.Document;
+import org.apache.abdera2.model.Entry;
+import org.apache.abdera2.writer.StreamWriter;
+import org.junit.Test;
+
+public class SerializerTest {
+
+    static Date date_now = new Date();
+    static Calendar cal_now = Calendar.getInstance();
+
+    @Test
+    public void testSimple() throws Exception {
+        Abdera abdera = Abdera.getInstance();
+        StreamWriter sw = abdera.create(StreamWriter.class);
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        sw.setOutputStream(out).setAutoIndent(true);
+        ConventionSerializationContext c = new ConventionSerializationContext(sw);
+        c.setSerializer(MyEntry.class, new EntrySerializer());
+        sw.startDocument();
+        c.serialize(new MyEntry());
+        sw.endDocument();
+        ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
+        Document<Entry> doc = abdera.getParser().parse(in);
+        Entry entry = doc.getRoot();
+        assertEquals("tag:example.org,2008:foo", entry.getId().toString());
+        assertEquals("This is the title", entry.getTitle());
+        assertEquals(date_now, entry.getUpdated());
+        assertEquals(cal_now.getTime(), entry.getPublished());
+        assertEquals("James", entry.getAuthor().getName());
+        assertEquals("this is the summary", entry.getSummary());
+        assertEquals("http://example.org/foo", entry.getAlternateLink().getResolvedHref().toString());
+    }
+
+    public static class MyEntry {
+        public String getId() {
+            return "tag:example.org,2008:foo";
+        }
+
+        public String getTitle() {
+            return "This is the title";
+        }
+
+        public String getAuthor() {
+            return "James";
+        }
+
+        public Date getUpdated() {
+            return date_now;
+        }
+
+        public Calendar getPublished() {
+            return cal_now;
+        }
+
+        public String getSummary() {
+            return "this is the summary";
+        }
+
+        public String getLink() {
+            return "http://example.org/foo";
+        }
+    }
+
+    @Test
+    public void testAnnotated() throws Exception {
+        Abdera abdera = Abdera.getInstance();
+        StreamWriter sw = abdera.create(StreamWriter.class);
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        sw.setOutputStream(out).setAutoIndent(true);
+        ConventionSerializationContext c = new ConventionSerializationContext(sw);
+        sw.startDocument();
+        c.serialize(new MyAnnotatedEntry());
+        sw.endDocument();
+
+        ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
+        Document<Entry> doc = abdera.getParser().parse(in);
+        Entry entry = doc.getRoot();
+        assertEquals("tag:example.org,2008:foo", entry.getId().toString());
+        assertEquals("This is the title", entry.getTitle());
+        assertEquals(date_now, entry.getUpdated());
+        assertEquals(date_now, entry.getPublished());
+        assertEquals("James", entry.getAuthor().getName());
+        assertEquals("this is the summary", entry.getSummary());
+        assertEquals("http://example.org/foo", entry.getAlternateLink().getResolvedHref().toString());
+    }
+
+    @org.apache.abdera2.ext.serializer.annotation.Entry
+    public static class MyAnnotatedEntry {
+        @ID
+        public String getFoo() {
+            return "tag:example.org,2008:foo";
+        }
+
+        @Title
+        public String getBar() {
+            return "This is the title";
+        }
+
+        @Author
+        public String getBaz() {
+            return "James";
+        }
+
+        @Updated
+        @Published
+        public Date getLastModified() {
+            return date_now;
+        }
+
+        @Summary
+        public String getText() {
+            return "this is the summary";
+        }
+
+        @Link
+        public String getUri() {
+            return "http://example.org/foo";
+        }
+    }
+}

Propchange: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/ext/serializer/SerializerTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message