abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r452626 - /incubator/abdera/java/trunk/core/src/test/java/org/apache/abdera/test/iri/TestIRI.java
Date Tue, 03 Oct 2006 21:20:27 GMT
Author: jmsnell
Date: Tue Oct  3 14:20:26 2006
New Revision: 452626

URL: http://svn.apache.org/viewvc?view=rev&rev=452626
Log:
Add a test for various uri schemes

Modified:
    incubator/abdera/java/trunk/core/src/test/java/org/apache/abdera/test/iri/TestIRI.java

Modified: incubator/abdera/java/trunk/core/src/test/java/org/apache/abdera/test/iri/TestIRI.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/test/java/org/apache/abdera/test/iri/TestIRI.java?view=diff&rev=452626&r1=452625&r2=452626
==============================================================================
--- incubator/abdera/java/trunk/core/src/test/java/org/apache/abdera/test/iri/TestIRI.java
(original)
+++ incubator/abdera/java/trunk/core/src/test/java/org/apache/abdera/test/iri/TestIRI.java
Tue Oct  3 14:20:26 2006
@@ -132,4 +132,74 @@
     assertEquals(base.resolve(".").toString(),"http://example.org/foo/");
   }
 
+  /**
+   * Try a variety of URI schemes.  If any problematic schemes pop up, 
+   * we should add a test for 'em here
+   */
+  public static void testSchemes() throws Exception {
+    
+    IRI iri = new IRI("http://a:b@c.org:80/d/e?f#g");
+    assertEquals(iri.getScheme(), "http");
+    assertEquals(iri.getUserInfo(), "a:b");
+    assertEquals(iri.getHost(),"c.org");
+    assertEquals(iri.getPort(),80);
+    assertEquals(iri.getPath(),"/d/e");
+    assertEquals(iri.getQuery(), "f");
+    assertEquals(iri.getFragment(),"g");
+    
+    iri = new IRI("https://a:b@c.org:80/d/e?f#g");
+    assertEquals(iri.getScheme(), "https");
+    assertEquals(iri.getUserInfo(), "a:b");
+    assertEquals(iri.getHost(),"c.org");
+    assertEquals(iri.getPort(),80);
+    assertEquals(iri.getPath(),"/d/e");
+    assertEquals(iri.getQuery(), "f");
+    assertEquals(iri.getFragment(),"g");
+    
+    iri = new IRI("ftp://a:b@c.org:80/d/e?f#g");
+    assertEquals(iri.getScheme(), "ftp");
+    assertEquals(iri.getUserInfo(), "a:b");
+    assertEquals(iri.getHost(),"c.org");
+    assertEquals(iri.getPort(),80);
+    assertEquals(iri.getPath(),"/d/e");
+    assertEquals(iri.getQuery(), "f");
+    assertEquals(iri.getFragment(),"g");
+    
+    iri = new IRI("mailto:joe@example.org?subject=foo");
+    assertEquals(iri.getScheme(), "mailto");
+    assertEquals(iri.getUserInfo(), null);
+    assertEquals(iri.getHost(),null);
+    assertEquals(iri.getPort(),-1);
+    assertEquals(iri.getPath(),"joe@example.org");
+    assertEquals(iri.getQuery(), "subject=foo");
+    assertEquals(iri.getFragment(),null);
+    
+    iri = new IRI("tag:example.org,2006:foo");
+    assertEquals(iri.getScheme(), "tag");
+    assertEquals(iri.getUserInfo(), null);
+    assertEquals(iri.getHost(),null);
+    assertEquals(iri.getPort(),-1);
+    assertEquals(iri.getPath(),"example.org,2006:foo");
+    assertEquals(iri.getQuery(), null);
+    assertEquals(iri.getFragment(),null);
+    
+    iri = new IRI("urn:lsid:ibm.com:example:82437234964354895798234d");
+    assertEquals(iri.getScheme(), "urn");
+    assertEquals(iri.getUserInfo(), null);
+    assertEquals(iri.getHost(),null);
+    assertEquals(iri.getPort(),-1);
+    assertEquals(iri.getPath(),"lsid:ibm.com:example:82437234964354895798234d");
+    assertEquals(iri.getQuery(), null);
+    assertEquals(iri.getFragment(),null);
+    
+    iri = new IRI("data:image/gif;base64,R0lGODdhMAAwAPAAAAAAAP");
+    assertEquals(iri.getScheme(), "data");
+    assertEquals(iri.getUserInfo(), null);
+    assertEquals(iri.getHost(),null);
+    assertEquals(iri.getPort(),-1);
+    assertEquals(iri.getPath(),"image/gif;base64,R0lGODdhMAAwAPAAAAAAAP");
+    assertEquals(iri.getQuery(), null);
+    assertEquals(iri.getFragment(),null);
+    
+  }
 }



Mime
View raw message