Search in sources :

Example 11 with NameValuePair

use of org.apache.hc.core5.http.copied.NameValuePair in project httpcomponents-core by apache.

the class TestNameValuePair method testToString.

@Test
public void testToString() {
    final NameValuePair param1 = new BasicNameValuePair("name1", "value1");
    Assertions.assertEquals("name1=value1", param1.toString());
    final NameValuePair param2 = new BasicNameValuePair("name1", null);
    Assertions.assertEquals("name1", param2.toString());
}
Also used : NameValuePair(org.apache.hc.core5.http.NameValuePair) Test(org.junit.jupiter.api.Test)

Example 12 with NameValuePair

use of org.apache.hc.core5.http.copied.NameValuePair in project httpcomponents-core by apache.

the class TestNameValuePair method testNullNotEqual.

@Test
public void testNullNotEqual() throws Exception {
    final NameValuePair NameValuePair = new BasicNameValuePair("name", "value");
    Assertions.assertNotEquals(null, NameValuePair);
}
Also used : NameValuePair(org.apache.hc.core5.http.NameValuePair) Test(org.junit.jupiter.api.Test)

Example 13 with NameValuePair

use of org.apache.hc.core5.http.copied.NameValuePair in project httpcomponents-core by apache.

the class TestNameValuePair method testNullValuesEquals.

@Test
public void testNullValuesEquals() throws Exception {
    final NameValuePair NameValuePair = new BasicNameValuePair("name", null);
    final NameValuePair NameValuePair2 = new BasicNameValuePair("name", null);
    Assertions.assertEquals(NameValuePair, NameValuePair2);
    Assertions.assertEquals(NameValuePair.hashCode(), NameValuePair2.hashCode());
}
Also used : NameValuePair(org.apache.hc.core5.http.NameValuePair) Test(org.junit.jupiter.api.Test)

Example 14 with NameValuePair

use of org.apache.hc.core5.http.copied.NameValuePair in project httpcomponents-core by apache.

the class TestNameValuePair method testNameEquals.

@Test
public void testNameEquals() throws Exception {
    final NameValuePair NameValuePair = new BasicNameValuePair("name", "value");
    final NameValuePair NameValuePair2 = new BasicNameValuePair("NAME", "value");
    Assertions.assertEquals(NameValuePair, NameValuePair2);
    Assertions.assertEquals(NameValuePair.hashCode(), NameValuePair2.hashCode());
    final NameValuePair NameValuePair3 = new BasicNameValuePair("NAME", "value");
    final NameValuePair NameValuePair4 = new BasicNameValuePair("name", "value");
    Assertions.assertEquals(NameValuePair3, NameValuePair4);
    Assertions.assertEquals(NameValuePair3.hashCode(), NameValuePair4.hashCode());
}
Also used : NameValuePair(org.apache.hc.core5.http.NameValuePair) Test(org.junit.jupiter.api.Test)

Example 15 with NameValuePair

use of org.apache.hc.core5.http.copied.NameValuePair in project httpcomponents-core by apache.

the class TestBasicHeaderValueFormatter method testHEFormatting.

@Test
public void testHEFormatting() throws Exception {
    final NameValuePair param1 = new BasicNameValuePair("param", "regular_stuff");
    final NameValuePair param2 = new BasicNameValuePair("param", "this\\that");
    final NameValuePair param3 = new BasicNameValuePair("param", "this,that");
    final NameValuePair param4 = new BasicNameValuePair("param", null);
    final NameValuePair[] params = new NameValuePair[] { param1, param2, param3, param4 };
    final HeaderElement element = new BasicHeaderElement("name", "value", params);
    final CharArrayBuffer buf = new CharArrayBuffer(64);
    this.formatter.formatHeaderElement(buf, element, false);
    Assertions.assertEquals("name=value; param=regular_stuff; param=\"this\\\\that\"; param=\"this,that\"; param", buf.toString());
}
Also used : NameValuePair(org.apache.hc.core5.http.NameValuePair) HeaderElement(org.apache.hc.core5.http.HeaderElement) CharArrayBuffer(org.apache.hc.core5.util.CharArrayBuffer) Test(org.junit.jupiter.api.Test)

Aggregations

NameValuePair (org.apache.hc.core5.http.NameValuePair)56 Test (org.junit.jupiter.api.Test)26 BasicNameValuePair (org.apache.hc.core5.http.message.BasicNameValuePair)25 ArrayList (java.util.ArrayList)15 URI (java.net.URI)13 UrlEncodedFormEntity (org.apache.hc.client5.http.entity.UrlEncodedFormEntity)12 HttpPost (org.apache.hc.client5.http.classic.methods.HttpPost)11 Map (java.util.Map)10 CharArrayBuffer (org.apache.hc.core5.util.CharArrayBuffer)9 IOException (java.io.IOException)7 CloseableHttpResponse (org.apache.hc.client5.http.impl.classic.CloseableHttpResponse)7 URIBuilder (org.apache.hc.core5.net.URIBuilder)7 URISyntaxException (java.net.URISyntaxException)6 HashMap (java.util.HashMap)5 HeaderElement (org.apache.hc.core5.http.HeaderElement)5 HttpGet (org.apache.hc.client5.http.classic.methods.HttpGet)4 BasicHeader (org.apache.hc.core5.http.message.BasicHeader)4 List (java.util.List)3 CloseableHttpClient (org.apache.hc.client5.http.impl.classic.CloseableHttpClient)3 HttpEntity (org.apache.hc.core5.http.HttpEntity)3