URITest.java :  » CouchDB » ektorp » org » ektorp » http » Java Open Source

Java Open Source » CouchDB » ektorp 
ektorp » org » ektorp » http » URITest.java
package org.ektorp.http;

import static org.junit.Assert.*;

import org.junit.*;

public class URITest {

  @Test
  public void basic_uri() {
    assertEquals("http://example.com:4510", URI.of("http://example.com:4510").toString());
  }
  
  @Test
  public void appended_path() {
    assertEquals("http://example.com:4510/my_db", URI.of("http://example.com:4510").append("my_db").toString());
  }

  @Test
  public void appended_path_with_slash() {
    assertEquals("/database/my_db", URI.of("/database/").append("my_db").toString());
  }
  
  @Test
  public void appended_path2() {
    assertEquals("http://example.com:4510/my_db/my_doc", URI.of("http://example.com:4510")
                              .append("my_db")
                              .append("my_doc").toString());
  }
  
  @Test
  public void params() {
    assertEquals("http://example.com:4510/my_db/my_doc?startKey=%22test%22&endKey=%22test%22", URI.of("http://example.com:4510")
                              .append("my_db")
                              .append("my_doc")
                              .param("startKey", "\"test\"")
                              .param("endKey", "\"test\"")
                              .toString());
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.