本文整理汇总了Java中javax.ws.rs.core.MultivaluedHashMap类的典型用法代码示例。如果您正苦于以下问题:Java MultivaluedHashMap类的具体用法?Java MultivaluedHashMap怎么用?Java MultivaluedHashMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MultivaluedHashMap类属于javax.ws.rs.core包,在下文中一共展示了MultivaluedHashMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testAuthFilter
import javax.ws.rs.core.MultivaluedHashMap; //导入依赖的package包/类
@Test
public void testAuthFilter() throws IOException {
final MultivaluedMap<String, String> headers = new MultivaluedHashMap<>();
when(mockContext.getHeaders()).thenReturn(headers);
final AuthFilter<String, Principal> filter = new AnonymousAuthFilter.Builder()
.setAuthenticator(new AnonymousAuthenticator()).buildAuthFilter();
filter.filter(mockContext);
verify(mockContext).setSecurityContext(securityCaptor.capture());
assertEquals(Trellis.AnonymousAgent.getIRIString(), securityCaptor.getValue().getUserPrincipal().getName());
assertFalse(securityCaptor.getValue().isUserInRole("role"));
assertFalse(securityCaptor.getValue().isSecure());
assertEquals("NONE", securityCaptor.getValue().getAuthenticationScheme());
}
示例2: testFindFixedVariable
import javax.ws.rs.core.MultivaluedHashMap; //导入依赖的package包/类
@Test
public void testFindFixedVariable() throws MappingException {
Mapping mapping1 = new Mapping("/fixed/{variable: [a-zA-Z]+}", null);
Mapping mapping2 = new Mapping("/fixed/{variable: \\d+}", null);
MappingTree mappingTree = new MappingTree();
mappingTree.put(mapping1);
mappingTree.put(mapping2);
MultivaluedHashMap<String,String> pathVariables1 = new MultivaluedHashMap<String,String>();
MultivaluedHashMap<String,String> pathVariables2 = new MultivaluedHashMap<String,String>();
Mapping find1 = mappingTree.find("fixed/aaa", pathVariables1);
Mapping find2 = mappingTree.find("fixed/123", pathVariables2);
Mapping find3 = mappingTree.find("fixed/");
Mapping find4 = mappingTree.find("fixed");
assertEquals(mapping1, find1);
assertEquals(mapping2, find2);
assertNull(find3);
assertNull(find4);
assertEquals(true, pathVariables1.containsKey("variable"));
assertEquals(true, pathVariables2.containsKey("variable"));
assertEquals(1, pathVariables1.get("variable").size());
assertEquals(1, pathVariables2.get("variable").size());
assertEquals("aaa", pathVariables1.get("variable").get(0));
assertEquals("123", pathVariables2.get("variable").get(0));
}
示例3: testVersionFilter
import javax.ws.rs.core.MultivaluedHashMap; //导入依赖的package包/类
@SuppressWarnings("boxing")
private MultivaluedMap<String, String> testVersionFilter(String version) throws WebApplicationException, NoSuchMethodException {
ResourceInfo resourceInfo = mock(ResourceInfo.class);
ContainerRequestContext request = mock(ContainerRequestContext.class);
UriInfo uriInfo = mock(UriInfo.class);
when(request.getUriInfo()).thenReturn(uriInfo);
Method method = SinceClass.class.getMethod("dummy");
MultivaluedMap<String, String> prop = new MultivaluedHashMap<>();
prop.putSingle(CommonParams.PARAM_VERSION, version);
when(uriInfo.getPathParameters()).thenReturn(prop);
VersionFilter filter = spy(new VersionFilter());
when(filter.getResourceInfo()).thenReturn(resourceInfo);
when(resourceInfo.getResourceMethod()).thenReturn(method);
filter.filter(request);
return prop;
}
示例4: map_ReturnsCorrectParameterName_ForQueryParameter
import javax.ws.rs.core.MultivaluedHashMap; //导入依赖的package包/类
@Test
public void map_ReturnsCorrectParameterName_ForQueryParameter() {
// Arrange
QueryParameter queryParameter = new QueryParameter();
queryParameter.setName("param1");
queryParameter.setIn("query");
queryParameter.setVendorExtension(OpenApiSpecificationExtensions.PARAMETER,
parameter.getIdentifier().stringValue());
Operation operation = new Operation();
operation.addParameter(queryParameter);
MultivaluedMap<String, String> queryParameters = new MultivaluedHashMap<>();
queryParameters.put(queryParameter.getName(), ImmutableList.of("value", "valueB"));
// Act
Map<String, String> result = mapper.map(operation, product, requestParameters);
// Assert
assertThat(result.size(), is(1));
assertThat(result, hasEntry(parameter.getName(), "value"));
}
示例5: map_ReturnsRequiredParameter_WithValidData
import javax.ws.rs.core.MultivaluedHashMap; //导入依赖的package包/类
@Test
public void map_ReturnsRequiredParameter_WithValidData() {
// Arrange
MultivaluedMap<String, String> queryParameters = new MultivaluedHashMap<>();
// Note there are multiple values for this parameter, to test that the first value is used only
queryParameters.put(requiredParameter.getName(), ImmutableList.of("value", "valueB"));
when(uriInfoMock.getQueryParameters()).thenReturn(queryParameters);
// Act
Map<String, String> result = representationRequestParameterMapper.map(product, contextMock);
// Assert
assertThat(result.size(), is(1));
assertThat(result, hasEntry(requiredParameter.getName(), "value"));
}
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:18,代码来源:RepresentationRequestParameterMapperTest.java
示例6: map_ReturnsOptionalParameter_WithValidData
import javax.ws.rs.core.MultivaluedHashMap; //导入依赖的package包/类
@Test
public void map_ReturnsOptionalParameter_WithValidData() {
// Arrange
MultivaluedMap<String, String> queryParameters = new MultivaluedHashMap<>();
// Note there are multiple values for this parameter, to test that the first value is used only
queryParameters.put(optionalParameter.getName(), ImmutableList.of("value", "valueB"));
when(uriInfoMock.getQueryParameters()).thenReturn(queryParameters);
// Act
Map<String, String> result = representationRequestParameterMapper.map(product, contextMock);
// Assert
assertThat(result.size(), is(1));
assertThat(result, hasEntry(optionalParameter.getName(), "value"));
}
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:18,代码来源:RepresentationRequestParameterMapperTest.java
示例7: MinijaxHttpHeaders
import javax.ws.rs.core.MultivaluedHashMap; //导入依赖的package包/类
public MinijaxHttpHeaders(final HttpServletRequest request) {
headers = new MultivaluedHashMap<>();
final Enumeration<String> ne = request.getHeaderNames();
while (ne.hasMoreElements()) {
final String name = ne.nextElement();
final Enumeration<String> ve = request.getHeaders(name);
while (ve.hasMoreElements()) {
headers.add(name, ve.nextElement());
}
}
cookies = CookieUtils.convertServletToJax(request.getCookies());
}
示例8: changeInstance
import javax.ws.rs.core.MultivaluedHashMap; //导入依赖的package包/类
/**
* Change a broker Instance
*
* @param brokerName
* @throws CloudKarafkaServiceException
*/
public void changeInstance(final String instanseId,
final String brokerName,
final String plan) throws CloudKarafkaServiceException {
// build input form
final MultivaluedMap<String, String> form = new MultivaluedHashMap<>();
form.add("name", brokerName);
form.add("plan", plan);
//build post request
final String target = String.format("%s/%s/%s", brokerConfig.getCloudkarafkaApiUrl(), "instances",instanseId);
final WebTarget webTarget = client.target(target);
// call create broker instances API
webTarget.request(MediaType.APPLICATION_JSON).put(Entity.form(form));
}
示例9: mapResponse_withHeaders
import javax.ws.rs.core.MultivaluedHashMap; //导入依赖的package包/类
@Test
public void mapResponse_withHeaders() {
MultivaluedMap<String, Object> headers = new MultivaluedHashMap<>();
headers.add("h", "v");
new Expectations() {
{
jaxrsResponse.getStatusInfo();
result = Status.OK;
jaxrsResponse.getEntity();
result = "result";
jaxrsResponse.getHeaders();
result = headers;
}
};
Response response = mapper.mapResponse(null, jaxrsResponse);
Assert.assertEquals(Status.OK, response.getStatus());
Assert.assertEquals("result", response.getResult());
Assert.assertEquals(1, response.getHeaders().getHeaderMap().size());
Assert.assertThat(response.getHeaders().getHeader("h"), Matchers.contains("v"));
}
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:22,代码来源:TestJaxrsProducerResponseMapper.java
示例10: getValidSessionParamsWithHetu
import javax.ws.rs.core.MultivaluedHashMap; //导入依赖的package包/类
private MultivaluedMap<String,String> getValidSessionParamsWithHetu() {
MultivaluedMap<String,String> sessionParams = new MultivaluedHashMap<>();
sessionParams.putSingle("token", "token");
sessionParams.putSingle("B02K_VERS", "0002");
sessionParams.putSingle("B02K_TIMESTMP", "000" + bankReady.instant().atZone(ZoneId.systemDefault()).format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))+"000000");
sessionParams.putSingle("B02K_IDNBR", "0000000000");
sessionParams.putSingle("B02K_STAMP", VALID_IDENTIFIER);
sessionParams.putSingle("B02K_CUSTNAME", "CUSTNAME");
sessionParams.putSingle("B02K_KEYVERS", "0001");
sessionParams.putSingle("B02K_ALG", "03");
sessionParams.putSingle("B02K_CUSTID", "210280-928R");
sessionParams.putSingle("B02K_CUSTTYPE", "01");
sessionParams.putSingle("B02K_MAC", "1D609B7B2CAF04AF1C50C7C7A04FBE081E77566C7BDB023F26EB2739C63718E0");
return sessionParams;
}
开发者ID:vrk-kpa,项目名称:e-identification-tupas-idp-public,代码行数:17,代码来源:SessionParserServiceSessionTest.java
示例11: filter404NoParameter
import javax.ws.rs.core.MultivaluedHashMap; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Test
public void filter404NoParameter() {
final ContainerRequestContext requestContext = Mockito.mock(ContainerRequestContext.class);
final ContainerResponseContext responseContext = Mockito.mock(ContainerResponseContext.class);
Mockito.when(responseContext.getStatus()).thenReturn(204);
final Annotation anno1 = Mockito.mock(Annotation.class);
final Annotation anno2 = Mockito.mock(Annotation.class);
final Annotation[] annotations = new Annotation[] { anno1, anno2 };
Mockito.when((Class) anno2.annotationType()).thenReturn(OnNullReturn404.class);
Mockito.when(responseContext.getEntityAnnotations()).thenReturn(annotations);
final UriInfo uriInfo = Mockito.mock(UriInfo.class);
final MultivaluedMap<String, String> parameters = new MultivaluedHashMap<>();
Mockito.when(uriInfo.getPathParameters()).thenReturn(parameters);
Mockito.when(requestContext.getUriInfo()).thenReturn(uriInfo);
filter.filter(requestContext, responseContext);
Mockito.verify(responseContext, VerificationModeFactory.atLeastOnce()).setStatus(404);
Mockito.verify(responseContext, VerificationModeFactory.atLeastOnce())
.setEntity("{\"code\":\"data\",\"message\":null,\"parameters\":null,\"cause\":null}", annotations, MediaType.APPLICATION_JSON_TYPE);
}
示例12: filter404SingleParameter
import javax.ws.rs.core.MultivaluedHashMap; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Test
public void filter404SingleParameter() {
final ContainerRequestContext requestContext = Mockito.mock(ContainerRequestContext.class);
final ContainerResponseContext responseContext = Mockito.mock(ContainerResponseContext.class);
Mockito.when(responseContext.getStatus()).thenReturn(204);
final Annotation anno1 = Mockito.mock(Annotation.class);
final Annotation anno2 = Mockito.mock(Annotation.class);
final Annotation[] annotations = new Annotation[] { anno1, anno2 };
Mockito.when((Class) anno2.annotationType()).thenReturn(OnNullReturn404.class);
Mockito.when(responseContext.getEntityAnnotations()).thenReturn(annotations);
final UriInfo uriInfo = Mockito.mock(UriInfo.class);
final MultivaluedMap<String, String> parameters = new MultivaluedHashMap<>();
parameters.putSingle("id", "2000");
Mockito.when(uriInfo.getPathParameters()).thenReturn(parameters);
Mockito.when(requestContext.getUriInfo()).thenReturn(uriInfo);
filter.filter(requestContext, responseContext);
Mockito.verify(responseContext, VerificationModeFactory.atLeastOnce()).setStatus(404);
Mockito.verify(responseContext, VerificationModeFactory.atLeastOnce()).setEntity(
"{\"code\":\"entity\",\"message\":\"2000\",\"parameters\":null,\"cause\":null}", annotations, MediaType.APPLICATION_JSON_TYPE);
}
示例13: testAcceptableLanguages
import javax.ws.rs.core.MultivaluedHashMap; //导入依赖的package包/类
@Test
public void testAcceptableLanguages() throws IOException {
final MultivaluedMap<String, String> mockHeaders = new MultivaluedHashMap<>();
mockHeaders.add("Accept-Language", "en-US");
final MockHttpServletRequest mockRequest = new MockHttpServletRequest("GET", URI.create("/"), mockHeaders, null, null);
try (final MinijaxRequestContext context = new MinijaxRequestContext(null, mockRequest, null)) {
final List<Locale> locales = context.getAcceptableLanguages();
assertEquals(1, locales.size());
assertEquals("en-US", locales.get(0).toLanguageTag());
// Assert that same cached object
assertTrue(locales == context.getAcceptableLanguages());
}
}
示例14: testQuoteInPathAndDatasetName
import javax.ws.rs.core.MultivaluedHashMap; //导入依赖的package包/类
@Test
public void testQuoteInPathAndDatasetName() throws Exception {
QlikAppMessageBodyGenerator generator = new QlikAppMessageBodyGenerator();
VirtualDataset dataset = new VirtualDataset()
.setSqlFieldsList(Arrays.asList(new ViewFieldType("test dimension", "VARCHAR"), new ViewFieldType("test \" measure", "INTEGER")));
DatasetConfig datasetConfig = new DatasetConfig()
.setName("UNTITLED")
.setType(DatasetType.VIRTUAL_DATASET)
.setFullPathList(Arrays.asList("@dremio", "fol\"der.ext", "foo", "bar"))
.setVirtualDataset(dataset);
MultivaluedMap<String, Object> httpHeaders = new MultivaluedHashMap<>();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
assertTrue(generator.isWriteable(datasetConfig.getClass(), null, null, WebServer.MediaType.TEXT_PLAIN_QLIK_APP_TYPE));
generator.writeTo(datasetConfig, DatasetConfig.class, null, new Annotation[] {}, WebServer.MediaType.TEXT_PLAIN_QLIK_APP_TYPE, httpHeaders, baos);
String script = new String(baos.toByteArray(), UTF_8);
// make sure everything is escaped correctly
assertTrue(script.contains(" DIMENSION \"test dimension\""));
assertTrue(script.contains(" MEASURE \"test \"\" measure\""));
assertTrue(script.contains(" FROM \"@dremio\".\"fol\"\"der.ext\".\"foo\".\"bar\""));
}
示例15: testPost
import javax.ws.rs.core.MultivaluedHashMap; //导入依赖的package包/类
@Test
public void testPost() throws Exception {
MockRepresentation content = new MockRepresentation();
content.setId(1L);
MockRequestParameters params = new MockRequestParameters();
params.setId(1L);
UriInfo uriinfo = mock(UriInfo.class);
MultivaluedMap<String, String> map = new MultivaluedHashMap<>();
map.putSingle(CommonParams.PARAM_VERSION, "v" + Integer.valueOf(CommonParams.VERSION_1).toString());
Mockito.when(uriinfo.getPathParameters()).thenReturn(map);
Response response = post(uriinfo, backendPost, content, params);
assertEquals(Status.CREATED.getStatusCode(), response.getStatus());
}