本文整理汇总了Java中com.sun.jersey.api.client.WebResource.queryParam方法的典型用法代码示例。如果您正苦于以下问题:Java WebResource.queryParam方法的具体用法?Java WebResource.queryParam怎么用?Java WebResource.queryParam使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.jersey.api.client.WebResource
的用法示例。
在下文中一共展示了WebResource.queryParam方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getParameterMap
import com.sun.jersey.api.client.WebResource; //导入方法依赖的package包/类
/**
* Copies all parameter values from the given HTTPServletRequest to a new
* Jersey WebResource, using the given WebResource as a basis.
*
* @param request
* The HttpServletRequest to copy parameters from.
*
* @param resource
* The WebResource to use as a basis.
*
* @return
* A new WebResource identical to the provided WebResource, but with
* query parameters copied from the given HttpServletRequest.
*/
@SuppressWarnings("unchecked") // getParameterMap() is defined as returning Map<String, String[]>
private WebResource copyParameters(HttpServletRequest request, WebResource resource) {
// Get explicitly-typed parameter map
Map<String, String[]> parameterMap = (Map<String, String[]>)
request.getParameterMap();
// For each parameter
for (Map.Entry<String, String[]> entry : parameterMap.entrySet()) {
// Add each name/value pair
String name = entry.getKey();
for (String value : entry.getValue())
resource = resource.queryParam(name, value);
}
return resource;
}
示例2: constructWebResource
import com.sun.jersey.api.client.WebResource; //导入方法依赖的package包/类
private WebResource constructWebResource(WebResource r, String... paths) {
WebResource rt = r;
for (String path : paths) {
rt = rt.path(path);
}
if (isAuthenticationEnabled()) {
rt = rt.queryParam("user.name", webserviceUserName);
}
return rt;
}
示例3: testSingleAppKill
import com.sun.jersey.api.client.WebResource; //导入方法依赖的package包/类
@Test(timeout = 120000)
public void testSingleAppKill() throws Exception {
rm.start();
MockNM amNodeManager = rm.registerNode("127.0.0.1:1234", 2048);
String[] mediaTypes =
{ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML };
MediaType[] contentTypes =
{ MediaType.APPLICATION_JSON_TYPE, MediaType.APPLICATION_XML_TYPE };
for (String mediaType : mediaTypes) {
for (MediaType contentType : contentTypes) {
RMApp app = rm.submitApp(CONTAINER_MB, "", webserviceUserName);
amNodeManager.nodeHeartbeat(true);
AppState targetState =
new AppState(YarnApplicationState.KILLED.toString());
Object entity;
if (contentType.equals(MediaType.APPLICATION_JSON_TYPE)) {
entity = appStateToJSON(targetState);
} else {
entity = targetState;
}
ClientResponse response =
this
.constructWebResource("apps", app.getApplicationId().toString(),
"state").entity(entity, contentType).accept(mediaType)
.put(ClientResponse.class);
if (!isAuthenticationEnabled()) {
assertEquals(Status.UNAUTHORIZED, response.getClientResponseStatus());
continue;
}
assertEquals(Status.ACCEPTED, response.getClientResponseStatus());
if (mediaType.equals(MediaType.APPLICATION_JSON)) {
verifyAppStateJson(response, RMAppState.FINAL_SAVING,
RMAppState.KILLED, RMAppState.KILLING, RMAppState.ACCEPTED);
} else {
verifyAppStateXML(response, RMAppState.FINAL_SAVING,
RMAppState.KILLED, RMAppState.KILLING, RMAppState.ACCEPTED);
}
String locationHeaderValue =
response.getHeaders().getFirst(HttpHeaders.LOCATION);
Client c = Client.create();
WebResource tmp = c.resource(locationHeaderValue);
if (isAuthenticationEnabled()) {
tmp = tmp.queryParam("user.name", webserviceUserName);
}
response = tmp.get(ClientResponse.class);
assertEquals(Status.OK, response.getClientResponseStatus());
assertTrue(locationHeaderValue.endsWith("/ws/v1/cluster/apps/"
+ app.getApplicationId().toString() + "/state"));
while (true) {
Thread.sleep(100);
response =
this
.constructWebResource("apps",
app.getApplicationId().toString(), "state").accept(mediaType)
.entity(entity, contentType).put(ClientResponse.class);
assertTrue((response.getClientResponseStatus() == Status.ACCEPTED)
|| (response.getClientResponseStatus() == Status.OK));
if (response.getClientResponseStatus() == Status.OK) {
assertEquals(RMAppState.KILLED, app.getState());
if (mediaType.equals(MediaType.APPLICATION_JSON)) {
verifyAppStateJson(response, RMAppState.KILLED);
} else {
verifyAppStateXML(response, RMAppState.KILLED);
}
break;
}
}
}
}
rm.stop();
}