@@ -0,0 +1,2592 @@
+package feign.ribbon;%0A%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertNotNull;%0Aimport static org.junit.Assert.assertTrue;%0A%0Aimport java.net.URI;%0Aimport java.net.URISyntaxException;%0Aimport java.nio.charset.Charset;%0Aimport java.util.Collection;%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0A%0Aimport org.junit.Test;%0A%0Aimport feign.Request;%0Aimport feign.ribbon.LBClient.RibbonRequest;%0A%0Apublic class LBClientTest %7B%0A%0A  @Test%0A  public void testRibbonRequest() throws URISyntaxException %7B%0A    // test for RibbonRequest.toRequest()%0A    // the url has a query whose value is an encoded json string%0A    String urlWithEncodedJson = %22http://test.feign.com/p?q=%257b%2522a%2522%253a1%257d%22;%0A    URI uri = new URI(urlWithEncodedJson);%0A    Map%3CString, Collection%3CString%3E%3E headers = new HashMap%3CString, Collection%3CString%3E%3E();%0A    // create a Request as baseline for recreate and assert%0A    Request requestOrign = Request.create(%22GET%22, uri.toASCIIString(), headers, null, Charset.forName(%22utf-8%22)); %0A    RibbonRequest ribbonRequest = new RibbonRequest(null, requestOrign, uri);%0A%0A    // use toRequest() recreate a Request%0A    Request requestGetFormToRequest = ribbonRequest.toRequest();%0A%0A    // test the same attributes%0A    assertEquals(requestOrign.method(), requestGetFormToRequest.method());%0A    assertEquals(requestOrign.url(), requestGetFormToRequest.url());%0A    assertEquals(urlWithEncodedJson, requestGetFormToRequest.url()); // the url in Request should not been encoded or decoded%0A    assertEquals(requestOrign.body(), requestGetFormToRequest.body());%0A    assertEquals(requestOrign.charset(), requestGetFormToRequest.charset());%0A    assertNotNull(requestOrign.headers());%0A    assertEquals(0, requestOrign.headers().size()); // double check the baseline Request%0A    assertNotNull(requestGetFormToRequest.headers()); // double check the baseline Request, header is not null, but empty%0A%0A    // test the different attributes%0A    // use toRequest() will add a %22Content-Length%22 header, test it%0A    Map%3CString, Collection%3CString%3E%3E headersFromNewRequest = requestGetFormToRequest.headers();%0A    assertNotNull(headersFromNewRequest);%0A    assertEquals(1, headersFromNewRequest.size());%0A    assertTrue(headersFromNewRequest.containsKey(%22Content-Length%22));%0A    Collection%3CString%3E contentLengthValues = headersFromNewRequest.get(%22Content-Length%22);%0A    assertNotNull(contentLengthValues);%0A    assertEquals(1, contentLengthValues.size()); // should has one value%0A    assertEquals(%220%22, contentLengthValues.iterator().next()); // the body is null, so the Content-Length value should be 0%0A  %7D%0A%7D%0A

add junit for LBClinet.RibbonRequest.toRequest()