Package org.apache.commons.httpclient.methods

Examples of org.apache.commons.httpclient.methods.PutMethod


        createPageIfDoesntExist(TestConstants.TEST_SPACE_NAME, TestConstants.TRANSLATIONS_PAGE_NAME, "Translations");

        Page page = objectFactory.createPage();
        page.setContent(languageId);

        PutMethod putMethod =
            executePutXml(getUriBuilder(PageTranslationResource.class).build(getWiki(), TestConstants.TEST_SPACE_NAME,
                TestConstants.TRANSLATIONS_PAGE_NAME, languageId).toString(), page, "Admin", "admin");
        Assert.assertEquals(getHttpMethodInfo(putMethod), HttpStatus.SC_CREATED, putMethod.getStatusCode());

        GetMethod getMethod =
            executeGet(getUriBuilder(PageTranslationResource.class).build(getWiki(), TestConstants.TEST_SPACE_NAME,
                TestConstants.TRANSLATIONS_PAGE_NAME, languageId).toString());
        Assert.assertEquals(getHttpMethodInfo(getMethod), HttpStatus.SC_OK, getMethod.getStatusCode());
View Full Code Here


        originalPage.setSyntax(newSyntax);

        Link link = getFirstLinkByRelation(originalPage, Relations.SELF);
        Assert.assertNotNull(link);

        PutMethod putMethod = executePutXml(link.getHref(), originalPage, "Admin", "admin");
        Assert.assertEquals(getHttpMethodInfo(putMethod), HttpStatus.SC_ACCEPTED, putMethod.getStatusCode());

        Page modifiedPage = (Page) unmarshaller.unmarshal(putMethod.getResponseBodyAsStream());

        Assert.assertEquals(newSyntax, modifiedPage.getSyntax());
    }
View Full Code Here

        Assert.assertEquals(getHttpMethodInfo(getMethod), HttpStatus.SC_OK, getMethod.getStatusCode());

        Object objectSummary = (Object) unmarshaller.unmarshal(getMethod.getResponseBodyAsStream());
        getProperty(objectSummary, "tags").setValue(TAG_VALUE);

        PutMethod putMethod =
            executePutXml(getUriBuilder(ObjectResource.class).build(getWiki(), "Main", "WebHome",
                objectToBePut.getClassName(), objectToBePut.getNumber()).toString(), objectSummary, "Admin", "admin");
        Assert.assertEquals(getHttpMethodInfo(putMethod), HttpStatus.SC_ACCEPTED, putMethod.getStatusCode());

        Object updatedObjectSummary = (Object) unmarshaller.unmarshal(putMethod.getResponseBodyAsStream());

        Assert.assertEquals(TAG_VALUE, getProperty(updatedObjectSummary, "tags").getValue());
        Assert.assertEquals(objectSummary.getClassName(), updatedObjectSummary.getClassName());
        Assert.assertEquals(objectSummary.getNumber(), updatedObjectSummary.getNumber());
    }
View Full Code Here

        Object object = (Object) unmarshaller.unmarshal(getMethod.getResponseBodyAsStream());
        String originalTagValue = getProperty(object, "tags").getValue();
        getProperty(object, "tags").setValue(TAG_VALUE);

        PutMethod putMethod =
            executePutXml(getUriBuilder(ObjectResource.class).build(getWiki(), "Main", "WebHome",
                objectToBePut.getClassName(), objectToBePut.getNumber()).toString(), object);
        Assert.assertEquals(getHttpMethodInfo(putMethod), HttpStatus.SC_UNAUTHORIZED, putMethod.getStatusCode());

        getMethod =
            executeGet(getUriBuilder(ObjectResource.class).build(getWiki(), "Main", "WebHome",
                objectToBePut.getClassName(), objectToBePut.getNumber()).toString());
        Assert.assertEquals(getHttpMethodInfo(getMethod), HttpStatus.SC_OK, getMethod.getStatusCode());
View Full Code Here

        Assert.assertNotNull(tagsPropertyLink);

        Property newTags = objectFactory.createProperty();
        newTags.setValue(TAG_VALUE);

        PutMethod putMethod = executePutXml(tagsPropertyLink.getHref(), newTags, "Admin", "admin");
        Assert.assertEquals(getHttpMethodInfo(putMethod), HttpStatus.SC_ACCEPTED, putMethod.getStatusCode());

        getMethod =
            executeGet(getUriBuilder(ObjectResource.class).build(getWiki(), "Main", "WebHome",
                currentObject.getClassName(), currentObject.getNumber()).toString());
        Assert.assertEquals(HttpStatus.SC_OK, getMethod.getStatusCode());
View Full Code Here

        Link tagsPropertyLink = getFirstLinkByRelation(tagsProperty, Relations.SELF);

        Assert.assertNotNull(tagsPropertyLink);

        PutMethod putMethod = executePut(tagsPropertyLink.getHref(), TAG_VALUE, MediaType.TEXT_PLAIN, "Admin", "admin");
        Assert.assertEquals(getHttpMethodInfo(putMethod), HttpStatus.SC_ACCEPTED, putMethod.getStatusCode());

        getMethod =
            executeGet(getUriBuilder(ObjectResource.class).build(getWiki(), "Main", "WebHome",
                currentObject.getClassName(), currentObject.getNumber()).toString());
        Assert.assertEquals(HttpStatus.SC_OK, getMethod.getStatusCode());
View Full Code Here

            String value = String.format("Value%d", i);

            Property property = getProperty(objectToBePut, "tags");
            property.setValue(value);

            PutMethod putMethod =
                executePutXml(getUriBuilder(ObjectResource.class).build(getWiki(), "Main", "WebHome",
                    objectToBePut.getClassName(), objectToBePut.getNumber()).toString(), objectToBePut, "Admin",
                    "admin");
            Assert.assertEquals(getHttpMethodInfo(putMethod), HttpStatus.SC_ACCEPTED, putMethod.getStatusCode());

            GetMethod getMethod =
                executeGet(getUriBuilder(PageResource.class).build(getWiki(), "Main", "WebHome").toString());
            Assert.assertEquals(getHttpMethodInfo(getMethod), HttpStatus.SC_OK, getMethod.getStatusCode());
View Full Code Here

        String newContent = "New Content";
        DeleteMethod deleteMethod = new DeleteMethod();
        deleteMethod.setDoAuthentication(true);
        MkcolMethod mkColMethod = new MkcolMethod();
        mkColMethod.setDoAuthentication(true);
        PutMethod putMethod = new PutMethod();
        putMethod.setDoAuthentication(true);
        GetMethod getMethod = new GetMethod();
        getMethod.setDoAuthentication(true);
        try {
            deleteMethod.setPath(spaceUrl);
            assertEquals(DavServletResponse.SC_NO_CONTENT, getHttpClient().executeMethod(deleteMethod));
            mkColMethod.setPath(spaceUrl);
            assertEquals(DavServletResponse.SC_CREATED, getHttpClient().executeMethod(mkColMethod));
            mkColMethod.setPath(pageUrl);
            assertEquals(DavServletResponse.SC_CREATED, getHttpClient().executeMethod(mkColMethod));
            putMethod.setPath(wikiTextFileUrl);
            putMethod.setRequestEntity(new InputStreamRequestEntity(new ByteArrayInputStream(newContent.getBytes())));
            // Already existing resource, in which case SC_NO_CONTENT will be the return status.
            assertEquals(DavServletResponse.SC_NO_CONTENT, getHttpClient().executeMethod(putMethod));
            getMethod.setPath(wikiTextFileUrl);
            assertEquals(DavServletResponse.SC_OK, getHttpClient().executeMethod(getMethod));
            assertEquals(newContent, getMethod.getResponseBodyAsString());
            putMethod.setPath(wikiXMLFileUrl);
            putMethod.setRequestEntity(new InputStreamRequestEntity(new ByteArrayInputStream(newContent.getBytes())));
            // XML saving was disabled recently. See http://jira.xwiki.org/jira/browse/XWIKI-2910
            assertEquals(DavServletResponse.SC_METHOD_NOT_ALLOWED, getHttpClient().executeMethod(putMethod));
            deleteMethod.setPath(pageUrl);
            assertEquals(DavServletResponse.SC_NO_CONTENT, getHttpClient().executeMethod(deleteMethod));
            deleteMethod.setPath(spaceUrl);
View Full Code Here

        String attachmentContent = "Attachment Content";
        DeleteMethod deleteMethod = new DeleteMethod();
        deleteMethod.setDoAuthentication(true);
        MkcolMethod mkColMethod = new MkcolMethod();
        mkColMethod.setDoAuthentication(true);
        PutMethod putMethod = new PutMethod();
        putMethod.setDoAuthentication(true);
        GetMethod getMethod = new GetMethod();
        getMethod.setDoAuthentication(true);
        try {
            deleteMethod.setPath(spaceUrl);
            assertEquals(DavServletResponse.SC_NO_CONTENT, getHttpClient().executeMethod(deleteMethod));
            mkColMethod.setPath(spaceUrl);
            assertEquals(DavServletResponse.SC_CREATED, getHttpClient().executeMethod(mkColMethod));
            mkColMethod.setPath(pageUrl);
            assertEquals(DavServletResponse.SC_CREATED, getHttpClient().executeMethod(mkColMethod));
            getMethod.setPath(attachmentUrl);
            assertEquals(DavServletResponse.SC_NOT_FOUND, getHttpClient().executeMethod(getMethod));
            putMethod.setPath(attachmentUrl);
            putMethod.setRequestEntity(new InputStreamRequestEntity(new ByteArrayInputStream(attachmentContent
                .getBytes())));
            assertEquals(DavServletResponse.SC_CREATED, getHttpClient().executeMethod(putMethod));
            getMethod.setPath(attachmentUrl);
            assertEquals(DavServletResponse.SC_OK, getHttpClient().executeMethod(getMethod));
            assertEquals(attachmentContent, getMethod.getResponseBodyAsString());
View Full Code Here

            getUriBuilder(AttachmentResource.class).build(getWiki(), SPACE_NAME, PAGE_NAME, attachmentName).toString();

        GetMethod getMethod = executeGet(attachmentUri);
        Assert.assertEquals(getHttpMethodInfo(getMethod), HttpStatus.SC_NOT_FOUND, getMethod.getStatusCode());

        PutMethod putMethod = executePut(attachmentUri, content, MediaType.TEXT_PLAIN, "Admin", "admin");
        Assert.assertEquals(getHttpMethodInfo(putMethod), HttpStatus.SC_CREATED, putMethod.getStatusCode());

        getMethod = executeGet(attachmentUri);
        Assert.assertEquals(getHttpMethodInfo(getMethod), HttpStatus.SC_OK, getMethod.getStatusCode());

        Assert.assertEquals(content, getMethod.getResponseBodyAsString());
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.methods.PutMethod

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.