本文整理汇总了Java中javax.ws.rs.core.MultivaluedHashMap.add方法的典型用法代码示例。如果您正苦于以下问题:Java MultivaluedHashMap.add方法的具体用法?Java MultivaluedHashMap.add怎么用?Java MultivaluedHashMap.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.ws.rs.core.MultivaluedHashMap
的用法示例。
在下文中一共展示了MultivaluedHashMap.add方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: filter_AddAcceptHeader_WhenFormatIsJson
import javax.ws.rs.core.MultivaluedHashMap; //导入方法依赖的package包/类
@Test
public void filter_AddAcceptHeader_WhenFormatIsJson() throws Exception {
// Arrange
MultivaluedHashMap queryParameters = new MultivaluedHashMap();
queryParameters.add("format", "json");
when(uriInfo.getQueryParameters()).thenReturn(queryParameters);
when(containerRequestContext.getUriInfo()).thenReturn(uriInfo);
when(containerRequestContext.getHeaders()).thenReturn(headers);
// Act
formatPreMatchingRequestFilter.filter(containerRequestContext);
// Assert
verify(headers).put(HttpHeaders.ACCEPT,
Arrays.asList(MediaType.APPLICATION_JSON, MediaTypes.LDJSON));
}
示例2: filter_AddAcceptHeader_WhenFormatIsXml
import javax.ws.rs.core.MultivaluedHashMap; //导入方法依赖的package包/类
@Test
public void filter_AddAcceptHeader_WhenFormatIsXml() throws Exception {
// Arrange
MultivaluedHashMap queryParameters = new MultivaluedHashMap();
queryParameters.add("format", "xml");
when(uriInfo.getQueryParameters()).thenReturn(queryParameters);
when(containerRequestContext.getUriInfo()).thenReturn(uriInfo);
when(containerRequestContext.getHeaders()).thenReturn(headers);
// Act
formatPreMatchingRequestFilter.filter(containerRequestContext);
// Assert
verify(headers).put(HttpHeaders.ACCEPT,
Arrays.asList(MediaType.APPLICATION_XML, MediaTypes.RDFXML));
}
示例3: headers
import javax.ws.rs.core.MultivaluedHashMap; //导入方法依赖的package包/类
public static MultivaluedHashMap<String, String> headers() {
MultivaluedHashMap<String, String> headerValues = new MultivaluedHashMap<>();
headerValues.add("User-Agent", "Postmark Java Library: " + libraryVersion());
headerValues.add("Accept", "application/json");
headerValues.add("Content-Type", "application/json");
return headerValues;
}
示例4: filter_AddAcceptHeader_WhenFormatIsTtl
import javax.ws.rs.core.MultivaluedHashMap; //导入方法依赖的package包/类
@Test
public void filter_AddAcceptHeader_WhenFormatIsTtl() throws Exception {
// Arrange
MultivaluedHashMap queryParameters = new MultivaluedHashMap();
queryParameters.add("format", "ttl");
when(uriInfo.getQueryParameters()).thenReturn(queryParameters);
when(containerRequestContext.getUriInfo()).thenReturn(uriInfo);
when(containerRequestContext.getHeaders()).thenReturn(headers);
// Act
formatPreMatchingRequestFilter.filter(containerRequestContext);
// Assert
verify(headers).put(HttpHeaders.ACCEPT, Arrays.asList(MediaTypes.TURTLE));
}
示例5: filter_DoNothing_WhenFormatIsUnknown
import javax.ws.rs.core.MultivaluedHashMap; //导入方法依赖的package包/类
@Test
public void filter_DoNothing_WhenFormatIsUnknown() throws Exception {
// Arrange
MultivaluedHashMap queryParameters = new MultivaluedHashMap();
queryParameters.add("format", "unknown");
when(uriInfo.getQueryParameters()).thenReturn(queryParameters);
when(containerRequestContext.getUriInfo()).thenReturn(uriInfo);
// Act
formatPreMatchingRequestFilter.filter(containerRequestContext);
// Assert
verify(headers, never()).clear();
}
示例6: getHeadersWithAuth
import javax.ws.rs.core.MultivaluedHashMap; //导入方法依赖的package包/类
private static MultivaluedHashMap getHeadersWithAuth(DEFAULTS authType, String apiToken) {
MultivaluedHashMap headers = DefaultHeaders.headers();
headers.add(authType.value, apiToken);
return headers;
}