"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "httpclient/src/test/java/org/apache/http/client/utils/TestURLEncodedUtils.java" between
httpcomponents-client-4.5.7-src.tar.gz and httpcomponents-client-4.5.8-src.tar.gz

About: HttpComponents is an Apache project responsible for creating and maintaining a toolset of low level Java components focused on HTTP and associated protocols. Java sources.

TestURLEncodedUtils.java  (httpcomponents-client-4.5.7-src):TestURLEncodedUtils.java  (httpcomponents-client-4.5.8-src)
skipping to change at line 32 skipping to change at line 32
* individuals on behalf of the Apache Software Foundation. For more * individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see * information on the Apache Software Foundation, please see
* <http://www.apache.org/>. * <http://www.apache.org/>.
* *
*/ */
package org.apache.http.client.utils; package org.apache.http.client.utils;
import java.net.URI; import java.net.URI;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List; import java.util.List;
import org.apache.http.Consts; import org.apache.http.Consts;
import org.apache.http.NameValuePair; import org.apache.http.NameValuePair;
import org.apache.http.entity.ContentType; import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity; import org.apache.http.entity.StringEntity;
import org.apache.http.message.BasicNameValuePair; import org.apache.http.message.BasicNameValuePair;
import org.apache.http.protocol.HTTP; import org.apache.http.protocol.HTTP;
import org.hamcrest.CoreMatchers;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
public class TestURLEncodedUtils { public class TestURLEncodedUtils {
@Test @Test
public void testParseURLCodedContent() throws Exception { public void testParseURLCodedContent() throws Exception {
List <NameValuePair> result; List <NameValuePair> result;
result = parse(""); result = parse("");
skipping to change at line 106 skipping to change at line 109
Assert.assertEquals(1, result.size()); Assert.assertEquals(1, result.size());
assertNameValuePair(result.get(0), "price", "10 \u20AC"); assertNameValuePair(result.get(0), "price", "10 \u20AC");
result = parse("a=b\"c&d=e"); result = parse("a=b\"c&d=e");
Assert.assertEquals(2, result.size()); Assert.assertEquals(2, result.size());
assertNameValuePair(result.get(0), "a", "b\"c"); assertNameValuePair(result.get(0), "a", "b\"c");
assertNameValuePair(result.get(1), "d", "e"); assertNameValuePair(result.get(1), "d", "e");
} }
@Test @Test
public void testParseSegments() throws Exception {
Assert.assertThat(URLEncodedUtils.parsePathSegments("/this/that"),
CoreMatchers.equalTo(Arrays.asList("this", "that")));
Assert.assertThat(URLEncodedUtils.parsePathSegments("this/that"),
CoreMatchers.equalTo(Arrays.asList("this", "that")));
Assert.assertThat(URLEncodedUtils.parsePathSegments("this//that"),
CoreMatchers.equalTo(Arrays.asList("this", "", "that")));
Assert.assertThat(URLEncodedUtils.parsePathSegments("this//that/"),
CoreMatchers.equalTo(Arrays.asList("this", "", "that", "")));
Assert.assertThat(URLEncodedUtils.parsePathSegments("this//that/%2fthis%
20and%20that"),
CoreMatchers.equalTo(Arrays.asList("this", "", "that", "/this an
d that")));
Assert.assertThat(URLEncodedUtils.parsePathSegments("this///that//"),
CoreMatchers.equalTo(Arrays.asList("this", "", "", "that", "", "
")));
Assert.assertThat(URLEncodedUtils.parsePathSegments("/"),
CoreMatchers.equalTo(Collections.singletonList("")));
Assert.assertThat(URLEncodedUtils.parsePathSegments(""),
CoreMatchers.equalTo(Collections.<String>emptyList()));
}
@Test
public void testFormatSegments() throws Exception {
Assert.assertThat(URLEncodedUtils.formatSegments("this", "that"),
CoreMatchers.equalTo("/this/that"));
Assert.assertThat(URLEncodedUtils.formatSegments("this", "", "that"),
CoreMatchers.equalTo("/this//that"));
Assert.assertThat(URLEncodedUtils.formatSegments("this", "", "that", "/t
his and that"),
CoreMatchers.equalTo("/this//that/%2Fthis%20and%20that"));
Assert.assertThat(URLEncodedUtils.formatSegments("this", "", "", "that",
"", ""),
CoreMatchers.equalTo("/this///that//"));
Assert.assertThat(URLEncodedUtils.formatSegments(""),
CoreMatchers.equalTo("/"));
Assert.assertThat(URLEncodedUtils.formatSegments(),
CoreMatchers.equalTo(""));
}
@Test
public void testParseURLCodedContentString() throws Exception { public void testParseURLCodedContentString() throws Exception {
List <NameValuePair> result; List <NameValuePair> result;
result = parseString(""); result = parseString("");
Assert.assertTrue(result.isEmpty()); Assert.assertTrue(result.isEmpty());
result = parseString("Name0"); result = parseString("Name0");
Assert.assertEquals(1, result.size()); Assert.assertEquals(1, result.size());
assertNameValuePair(result.get(0), "Name0", null); assertNameValuePair(result.get(0), "Name0", null);
 End of changes. 3 change blocks. 
0 lines changed or deleted 44 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)