本文整理匯總了Java中org.apache.commons.httpclient.methods.PutMethod.setQueryString方法的典型用法代碼示例。如果您正苦於以下問題:Java PutMethod.setQueryString方法的具體用法?Java PutMethod.setQueryString怎麽用?Java PutMethod.setQueryString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.httpclient.methods.PutMethod
的用法示例。
在下文中一共展示了PutMethod.setQueryString方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testBasicSecurityPutCall
import org.apache.commons.httpclient.methods.PutMethod; //導入方法依賴的package包/類
@Test
public void testBasicSecurityPutCall() throws IOException {
final HttpClient c = loginWithCookie("rest-catalog-two", "A6B7C8");
final URI uri = UriBuilder.fromUri(getContextURI()).path("catalog").path(entry1.getKey().toString()).build();
final PutMethod method = createPut(uri, MediaType.APPLICATION_JSON, true);
method.setQueryString(new NameValuePair[] { new NameValuePair("name", "Not-sub-entry-3"), new NameValuePair("description", "Not-sub-entry-description-3"),
new NameValuePair("type", String.valueOf(CatalogEntry.TYPE_NODE)) });
final int code = c.executeMethod(method);
assertEquals(401, code);
method.releaseConnection();
final List<CatalogEntry> children = catalogService.getChildrenOf(entry1);
boolean saved = false;
for (final CatalogEntry child : children) {
if ("Not-sub-entry-3".equals(child.getName())) {
saved = true;
break;
}
}
assertFalse(saved);
}
示例2: testAdminCanEditCourse
import org.apache.commons.httpclient.methods.PutMethod; //導入方法依賴的package包/類
@Test
public void testAdminCanEditCourse() throws IOException {
final HttpClient c = loginWithCookie("administrator", "olat");
// create an structure node
final URI newStructureUri = getElementsUri(course).path("structure").build();
final PutMethod method = createPut(newStructureUri, MediaType.APPLICATION_JSON, true);
method.setQueryString(new NameValuePair[] { new NameValuePair("position", "0"), new NameValuePair("shortTitle", "Structure-admin-0"),
new NameValuePair("longTitle", "Structure-long-admin-0"), new NameValuePair("objectives", "Structure-objectives-admin-0") });
final int code = c.executeMethod(method);
assertEquals(200, code);
}
示例3: testIdCannotEditCourse
import org.apache.commons.httpclient.methods.PutMethod; //導入方法依賴的package包/類
@Test
public void testIdCannotEditCourse() throws IOException {
final HttpClient c = loginWithCookie("id-c-s-0", "A6B7C8");
// create an structure node
final URI newStructureUri = getElementsUri(course).path("structure").build();
final PutMethod method = createPut(newStructureUri, MediaType.APPLICATION_JSON, true);
method.setQueryString(new NameValuePair[] { new NameValuePair("position", "0"), new NameValuePair("shortTitle", "Structure-id-0"),
new NameValuePair("longTitle", "Structure-long-id-0"), new NameValuePair("objectives", "Structure-objectives-id-0") });
final int code = c.executeMethod(method);
assertEquals(401, code);
}
示例4: testAuthorCannotEditCourse
import org.apache.commons.httpclient.methods.PutMethod; //導入方法依賴的package包/類
@Test
public void testAuthorCannotEditCourse() throws IOException {
// author but not owner
final HttpClient c = loginWithCookie("id-c-s-1", "A6B7C8");
// create an structure node
final URI newStructureUri = getElementsUri(course).path("structure").build();
final PutMethod method = createPut(newStructureUri, MediaType.APPLICATION_JSON, true);
method.setQueryString(new NameValuePair[] { new NameValuePair("position", "0"), new NameValuePair("shortTitle", "Structure-id-0"),
new NameValuePair("longTitle", "Structure-long-id-0"), new NameValuePair("objectives", "Structure-objectives-id-0") });
final int code = c.executeMethod(method);
assertEquals(401, code);
}
示例5: testAuthorCanEditCourse
import org.apache.commons.httpclient.methods.PutMethod; //導入方法依賴的package包/類
@Test
public void testAuthorCanEditCourse() throws IOException {
// author and owner
final HttpClient c = loginWithCookie("id-c-s-2", "A6B7C8");
// create an structure node
final URI newStructureUri = getElementsUri(course).path("structure").build();
final PutMethod method = createPut(newStructureUri, MediaType.APPLICATION_JSON, true);
method.setQueryString(new NameValuePair[] { new NameValuePair("position", "0"), new NameValuePair("shortTitle", "Structure-id-0"),
new NameValuePair("longTitle", "Structure-long-id-0"), new NameValuePair("objectives", "Structure-objectives-id-0") });
final int code = c.executeMethod(method);
assertEquals(200, code);
}
示例6: testPutCategoryQuery
import org.apache.commons.httpclient.methods.PutMethod; //導入方法依賴的package包/類
@Test
public void testPutCategoryQuery() throws IOException {
final HttpClient c = loginWithCookie("administrator", "olat");
final URI uri = UriBuilder.fromUri(getContextURI()).path("catalog").path(entry1.getKey().toString()).build();
final PutMethod method = createPut(uri, MediaType.APPLICATION_JSON, true);
method.setQueryString(new NameValuePair[] { new NameValuePair("name", "Sub-entry-2"), new NameValuePair("description", "Sub-entry-description-2"),
new NameValuePair("type", String.valueOf(CatalogEntry.TYPE_NODE)) });
final int code = c.executeMethod(method);
assertEquals(200, code);
final String body = method.getResponseBodyAsString();
method.releaseConnection();
final CatalogEntryVO vo = parse(body, CatalogEntryVO.class);
assertNotNull(vo);
final List<CatalogEntry> children = catalogService.getChildrenOf(entry1);
boolean saved = false;
for (final CatalogEntry child : children) {
if (vo.getKey().equals(child.getKey())) {
saved = true;
break;
}
}
assertTrue(saved);
}
示例7: testPutCatalogEntryQuery
import org.apache.commons.httpclient.methods.PutMethod; //導入方法依賴的package包/類
@Test
public void testPutCatalogEntryQuery() throws IOException {
final RepositoryEntry re = createRepository("put-cat-entry-query", 6458439l);
final HttpClient c = loginWithCookie("administrator", "olat");
final URI uri = UriBuilder.fromUri(getContextURI()).path("catalog").path(entry1.getKey().toString()).build();
final PutMethod method = createPut(uri, MediaType.APPLICATION_JSON, true);
method.setQueryString(new NameValuePair[] { new NameValuePair("name", "Sub-entry-2"), new NameValuePair("description", "Sub-entry-description-2"),
new NameValuePair("type", String.valueOf(CatalogEntry.TYPE_NODE)), new NameValuePair("repoEntryKey", re.getKey().toString()) });
final int code = c.executeMethod(method);
assertEquals(200, code);
final String body = method.getResponseBodyAsString();
method.releaseConnection();
final CatalogEntryVO vo = parse(body, CatalogEntryVO.class);
assertNotNull(vo);
final List<CatalogEntry> children = catalogService.getChildrenOf(entry1);
CatalogEntry ce = null;
for (final CatalogEntry child : children) {
if (vo.getKey().equals(child.getKey())) {
ce = child;
break;
}
}
assertNotNull(ce);
assertNotNull(ce.getRepositoryEntry());
assertEquals(re.getKey(), ce.getRepositoryEntry().getKey());
}