Search in sources :

Example 1 with MessageHeaders

use of com.linkedin.r2.message.MessageHeaders in project rest.li by linkedin.

the class TestRestBuilders method testHeaderWithNullListElem.

@Test
public void testHeaderWithNullListElem() {
    final String headerName = "key";
    final String headerVal1 = "value1";
    final String headerVal2 = "value2";
    final String headerValue = headerVal1 + ", ," + headerVal2;
    final MessageHeaders msg = new RestResponseBuilder().addHeaderValue(headerName, headerValue).build();
    Assert.assertEquals(headerValue, msg.getHeader(headerName));
    Assert.assertEquals(Arrays.asList(headerVal1, headerVal2), msg.getHeaderValues(headerName));
}
Also used : RestResponseBuilder(com.linkedin.r2.message.rest.RestResponseBuilder) MessageHeaders(com.linkedin.r2.message.MessageHeaders) Test(org.testng.annotations.Test)

Example 2 with MessageHeaders

use of com.linkedin.r2.message.MessageHeaders in project rest.li by linkedin.

the class TestRestBuilders method testSetMultiValueHeader.

@Test
public void testSetMultiValueHeader() {
    final String headerName = "key";
    final String headerVal1 = "value1";
    final String headerVal2 = "value2";
    final String headerValue = headerVal1 + ',' + headerVal2;
    final MessageHeaders msg = new RestResponseBuilder().setHeader(headerName, headerValue).build();
    Assert.assertEquals(headerValue, msg.getHeader(headerName));
    Assert.assertEquals(Arrays.asList(headerVal1, headerVal2), msg.getHeaderValues(headerName));
}
Also used : RestResponseBuilder(com.linkedin.r2.message.rest.RestResponseBuilder) MessageHeaders(com.linkedin.r2.message.MessageHeaders) Test(org.testng.annotations.Test)

Example 3 with MessageHeaders

use of com.linkedin.r2.message.MessageHeaders in project rest.li by linkedin.

the class TestRestBuilders method testAddMultipleValuesToHeader.

@Test
public void testAddMultipleValuesToHeader() {
    final String headerName = "key";
    final String headerVal1 = "value1";
    final String headerVal2 = "value2";
    final String headerValue = headerVal1 + ',' + headerVal2;
    final MessageHeaders msg = new RestResponseBuilder().addHeaderValue(headerName, headerVal1).addHeaderValue(headerName, headerVal2).build();
    Assert.assertEquals(headerValue, msg.getHeader(headerName));
    Assert.assertEquals(Arrays.asList(headerVal1, headerVal2), msg.getHeaderValues(headerName));
}
Also used : RestResponseBuilder(com.linkedin.r2.message.rest.RestResponseBuilder) MessageHeaders(com.linkedin.r2.message.MessageHeaders) Test(org.testng.annotations.Test)

Example 4 with MessageHeaders

use of com.linkedin.r2.message.MessageHeaders in project rest.li by linkedin.

the class TestRestBuilders method testAddMultipleValuesToHeader2.

@Test
public void testAddMultipleValuesToHeader2() {
    final String headerName = "key";
    final String headerVal1a = "value1a";
    final String headerVal1b = "value1b";
    final String headerVal1 = headerVal1a + "," + headerVal1b;
    final String headerVal2 = "value2";
    final String headerValue = headerVal1 + ',' + headerVal2;
    final MessageHeaders msg = new RestResponseBuilder().addHeaderValue(headerName, headerVal1).addHeaderValue(headerName, headerVal2).build();
    Assert.assertEquals(headerValue, msg.getHeader(headerName));
    Assert.assertEquals(Arrays.asList(headerVal1a, headerVal1b, headerVal2), msg.getHeaderValues(headerName));
}
Also used : RestResponseBuilder(com.linkedin.r2.message.rest.RestResponseBuilder) MessageHeaders(com.linkedin.r2.message.MessageHeaders) Test(org.testng.annotations.Test)

Aggregations

MessageHeaders (com.linkedin.r2.message.MessageHeaders)4 RestResponseBuilder (com.linkedin.r2.message.rest.RestResponseBuilder)4 Test (org.testng.annotations.Test)4