use of jakarta.ws.rs.core.MultivaluedHashMap in project OpenGrok by OpenGrok.
the class CorsFilterTest method testBoth.
private void testBoth(String origin, List<Object> headerValue) {
CorsFilter filter = new CorsFilter();
ContainerRequestContext request = mock(ContainerRequestContext.class);
when(request.getHeaderString(CORS_REQUEST_HEADER)).thenReturn(origin);
ContainerResponseContext response = mock(ContainerResponseContext.class);
MultivaluedMap<String, Object> headers = new MultivaluedHashMap<>();
when(response.getHeaders()).thenReturn(headers);
filter.filter(request, response);
assertEquals(headerValue, headers.get(ALLOW_CORS_HEADER));
}
use of jakarta.ws.rs.core.MultivaluedHashMap in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method constructorMultivaluedMapArgTest.
/*
* @testName: constructorMultivaluedMapArgTest
*
* @assertion_ids: JAXRS:JAVADOC:768; JAXRS:JAVADOC:765;
*
* @test_Strategy: Create a new form data instance with a single parameter
* entry.
*/
@Test
public void constructorMultivaluedMapArgTest() throws Fault {
MultivaluedHashMap<String, String> init = new MultivaluedHashMap<String, String>();
init.add(tck, cts);
init.add(cts, cts);
Form form = new Form(init);
assertTrue(form != null, "No Form created");
MultivaluedMap<String, String> map = form.asMap();
assertTrue(map.containsKey(tck), "No given key " + tck + " exists in form instance");
assertTrue(map.getFirst(tck).equals(cts), "Different value has been given from map for key " + tck + ": " + map.getFirst(tck));
assertTrue(map.containsKey(cts), "No given key " + cts + " exists in form instance");
assertTrue(map.getFirst(cts).equals(cts), "Different value has been given from map for key " + cts + ": " + map.getFirst(cts));
logMsg("Form instance with MultivaluedMap argument sucessfully created");
}
use of jakarta.ws.rs.core.MultivaluedHashMap in project jaxrs-api by eclipse-ee4j.
the class BasicExamples method commonFluentUseCases.
public void commonFluentUseCases() {
Client client = ClientBuilder.newClient();
// Invocation
client.target("http://examples.jaxrs.com/");
client.target("http://examples.jaxrs.com/").request("text/plain").get();
client.target("http://examples.jaxrs.com/").request("text/plain").async().get();
client.target("http://examples.jaxrs.com/").request().buildPut(text("Hi")).invoke();
client.target("http://examples.jaxrs.com/").request("text/plain").buildGet().submit();
client.target("http://examples.jaxrs.com/").path("123").request("text/plain").get();
client.target("http://examples.jaxrs.com/").path("123").request("text/plain").async().get();
client.target("http://examples.jaxrs.com/").path("123").request("text/plain").buildGet().invoke();
client.target("http://examples.jaxrs.com/").path("123").request("text/plain").buildGet().submit();
client.target("http://examples.jaxrs.com/").path("123").request("text/plain").get();
client.target("http://examples.jaxrs.com/").path("123").request("text/plain").async().get();
client.target("http://examples.jaxrs.com/").path("123").request("text/plain").buildGet().invoke();
client.target("http://examples.jaxrs.com/").path("123").request("text/plain").buildGet().submit();
client.target("http://examples.jaxrs.com/").path("123").request("text/plain").header("custom-name", "custom_value").get();
client.target("http://examples.jaxrs.com/").path("123").request("text/plain").header("custom-name", "custom_value").async().get();
client.target("http://examples.jaxrs.com/").path("123").request("text/plain").header("custom-name", "custom_value").buildGet().invoke();
client.target("http://examples.jaxrs.com/").path("123").request("text/plain").header("custom-name", "custom_value").buildGet().submit();
// POSTing Forms
client.target("http://examples.jaxrs.com/").path("123").request(MediaType.APPLICATION_JSON).post(form(new Form("param1", "a").param("param2", "b")));
MultivaluedMap<String, String> formData = new MultivaluedHashMap<String, String>();
formData.add("param1", "a");
formData.add("param2", "b");
client.target("http://examples.jaxrs.com/").path("123").request(MediaType.APPLICATION_JSON).post(form(formData));
// Configuration
TestFeature testFeature = new TestFeature();
client.register(testFeature);
client.target("http://examples.jaxrs.com/").register(testFeature);
client.target("http://examples.jaxrs.com/").request("text/plain").property("foo", "bar");
client.target("http://examples.jaxrs.com/").request("text/plain").buildGet().property("foo", "bar");
}
use of jakarta.ws.rs.core.MultivaluedHashMap in project minijax by minijax.
the class MinijaxPathPattern method tryMatch.
public MultivaluedMap<String, String> tryMatch(final MinijaxUriInfo uriInfo) {
final String requestPath = uriInfo.getRequestUri().getPath();
if (params == null) {
// Simple case, no params, no regex
return patternString.equals(requestPath) ? EMPTY_PARAMS : null;
}
final Matcher matcher = pattern.matcher(requestPath);
if (!matcher.matches()) {
return null;
}
final MultivaluedMap<String, String> pathParameters = new MultivaluedHashMap<>();
for (final String name : params) {
pathParameters.add(name, matcher.group(name));
}
return pathParameters;
}
Aggregations