当前位置: 首页>>代码示例>>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;未经允许,请勿转载。