Search in sources :

Example 1 with SinglevaluedMap

use of ee.jakarta.tck.ws.rs.common.impl.SinglevaluedMap in project jaxrs-api by eclipse-ee4j.

the class MediaTypeResource method sendMap.

@GET
@Path("map")
@Produces(MediaType.SERVER_SENT_EVENTS)
public void sendMap(@Context SseEventSink sink, @Context Sse sse) {
    try (SseEventSink s = sink) {
        SinglevaluedMap<String, String> map = new SinglevaluedMap<>();
        map.add("key", SSEMessage.MESSAGE);
        s.send(sse.newEventBuilder().data(map).mediaType(mediaType).build());
    }
}
Also used : SseEventSink(jakarta.ws.rs.sse.SseEventSink) SinglevaluedMap(ee.jakarta.tck.ws.rs.common.impl.SinglevaluedMap) Path(jakarta.ws.rs.Path) Produces(jakarta.ws.rs.Produces) GET(jakarta.ws.rs.GET)

Example 2 with SinglevaluedMap

use of ee.jakarta.tck.ws.rs.common.impl.SinglevaluedMap in project jaxrs-api by eclipse-ee4j.

the class BuilderClientIT method replaceAllTest.

/*
   * @testName: replaceAllTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:883;
   * 
   * @test_Strategy: Replaces all existing headers with the newly supplied
   * headers.
   */
@Test
public void replaceAllTest() throws Fault {
    String[] headers = { "header1", "header2", "header3" };
    String header99 = "header99";
    MultivaluedMap<String, Object> mv = new SinglevaluedMap<String, Object>();
    mv.add(header99, header99);
    Response response = Response.ok().header(headers[0], headers[0]).header(headers[1], headers[1]).header(headers[2], headers[2]).replaceAll(mv).build();
    for (String header : headers) assertTrue(response.getHeaderString(header) == null, "response contains non replaced header" + header);
    assertTrue(response.getHeaderString(header99).equals(header99), "response does not contain header from replacedAll map" + header99);
}
Also used : Response(jakarta.ws.rs.core.Response) SinglevaluedMap(ee.jakarta.tck.ws.rs.common.impl.SinglevaluedMap) Test(org.junit.jupiter.api.Test)

Example 3 with SinglevaluedMap

use of ee.jakarta.tck.ws.rs.common.impl.SinglevaluedMap in project jaxrs-api by eclipse-ee4j.

the class MBWCheckResource method sendMultivaluedMap.

@GET
@Path("multivaluedmap")
@Produces(MediaType.SERVER_SENT_EVENTS)
public void sendMultivaluedMap(@Context SseEventSink sink, @Context Sse sse) {
    try (SseEventSink s = sink) {
        SinglevaluedMap<String, String> map = new SinglevaluedMap<>();
        map.add("name", MESSAGE);
        s.send(sse.newEventBuilder().data(map).mediaType(MediaType.APPLICATION_FORM_URLENCODED_TYPE).build());
    }
}
Also used : SseEventSink(jakarta.ws.rs.sse.SseEventSink) SinglevaluedMap(ee.jakarta.tck.ws.rs.common.impl.SinglevaluedMap) Path(jakarta.ws.rs.Path) Produces(jakarta.ws.rs.Produces) GET(jakarta.ws.rs.GET)

Aggregations

SinglevaluedMap (ee.jakarta.tck.ws.rs.common.impl.SinglevaluedMap)3 GET (jakarta.ws.rs.GET)2 Path (jakarta.ws.rs.Path)2 Produces (jakarta.ws.rs.Produces)2 SseEventSink (jakarta.ws.rs.sse.SseEventSink)2 Response (jakarta.ws.rs.core.Response)1 Test (org.junit.jupiter.api.Test)1