當前位置: 首頁>>代碼示例>>Java>>正文


Java PutMethod.setQueryString方法代碼示例

本文整理匯總了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);
}
 
開發者ID:huihoo,項目名稱:olat,代碼行數:25,代碼來源:CatalogITCase.java

示例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);
}
 
開發者ID:huihoo,項目名稱:olat,代碼行數:13,代碼來源:CourseSecurityITCase.java

示例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);
}
 
開發者ID:huihoo,項目名稱:olat,代碼行數:13,代碼來源:CourseSecurityITCase.java

示例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);
}
 
開發者ID:huihoo,項目名稱:olat,代碼行數:14,代碼來源:CourseSecurityITCase.java

示例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);
}
 
開發者ID:huihoo,項目名稱:olat,代碼行數:14,代碼來源:CourseSecurityITCase.java

示例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);
}
 
開發者ID:huihoo,項目名稱:olat,代碼行數:28,代碼來源:CatalogITCase.java

示例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());
}
 
開發者ID:huihoo,項目名稱:olat,代碼行數:32,代碼來源:CatalogITCase.java


注:本文中的org.apache.commons.httpclient.methods.PutMethod.setQueryString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。