Examples of XWikiPage


Examples of org.xwiki.xmlrpc.model.XWikiPage

    {
        String pageId =
            String.format("%s.%s-%d", TestConstants.TEST_SPACE, TestConstants.TEST_PREFIX,
                Math.abs(this.random.nextInt()));
        String content = String.format("Modified by org.xwiki.xmlrpc @ %s (inital version)\n", new Date());
        XWikiPage page = null;

        TestUtils.banner("TEST: createPageWithNullSpace()");

        try {
            page = this.rpc.getPage(pageId);
            throw new RuntimeException(String.format("XWikiPage %s exists!", pageId));
        } catch (Exception e) {
            System.out.format("XWikiPage %s does not exist... Good!\n", pageId);
        }

        page = new XWikiPage();
        page.setId(pageId);
        page.setTitle("Test page");
        page.setContent(content);
        XWikiPage storedPage = this.rpc.storePage(page);

        System.out.format("Content sent: '%s'\n", Utils.truncateToFirstLine(content));
        System.out.format("%s\n", storedPage);

        assertEquals(storedPage.getContent(), content);

        assertTrue(storedPage.getVersion() == 1);
        assertEquals("", storedPage.getLanguage());
    }
View Full Code Here

Examples of org.xwiki.xmlrpc.model.XWikiPage

        String pageId =
            String.format("%s.%s-%d", TestConstants.SPACE_WITH_NO_ACCESS_RIGHTS, TestConstants.TEST_PREFIX,
                Math.abs(this.random.nextInt()));
        String content = String.format("Modified by org.xwiki.xmlrpc @ %s\n", new Date());
        XWikiPage page = null;

        TestUtils.banner("TEST: createPageInSpaceWithNoAccessRights()");

        try {
            page = this.rpc.getPage(pageId);
            throw new RuntimeException(String.format("XWikiPage %s exists!", pageId));
        } catch (Exception e) {
            System.out.format("XWikiPage %s does not exist... Good!\n", pageId);
        }

        page = new XWikiPage();
        page.setId(pageId);
        page.setSpace(TestConstants.TEST_SPACE);
        page.setTitle("Test page");
        page.setContent(content);

        try {
            this.rpc.storePage(page);
            fail();
        } catch (Exception e) {
View Full Code Here

Examples of org.xwiki.xmlrpc.model.XWikiPage

    {
        List<XWikiPageHistorySummary> pageHistorySummaries = this.rpc.getPageHistory(TestConstants.TEST_PAGE);
        XWikiPageHistorySummary pageHistorySummary =
            pageHistorySummaries.get(this.random.nextInt(pageHistorySummaries.size()));

        XWikiPage page = this.rpc.getPage(TestConstants.TEST_PAGE, pageHistorySummary.getVersion());
        TestUtils.banner("TEST: getPageAtVersion()");
        System.out.format("%s\n", pageHistorySummary);
        System.out.format("%s\n", page);

        assertEquals(pageHistorySummary.getVersion(), page.getVersion());
        assertEquals(pageHistorySummary.getModifier(), page.getModifier());

        /*
         * This test occasionally fails because the version returned as the modification date by XWiki when getting a
         * page with a given version is always equal to the current date/time. So if the previous version to
         * getPageHistory is made, let's say at 12:53:59 and the subsequent getPage at 12:54:01 then the date in the
View Full Code Here

Examples of org.xwiki.xmlrpc.model.XWikiPage

    {
        List<XWikiPageHistorySummary> pageHistorySummaries = this.rpc.getPageHistory(TestConstants.TEST_PAGE);
        XWikiPageHistorySummary pageHistorySummary =
            pageHistorySummaries.get(this.random.nextInt(pageHistorySummaries.size()));

        XWikiPage page = this.rpc.getPage(pageHistorySummary.getId());
        TestUtils.banner("TEST: getPageAtVersionUsingExtendedId()");
        System.out.format("%s\n", pageHistorySummary);
        System.out.format("%s\n", page);

        assertEquals(pageHistorySummary.getVersion(), page.getVersion());
        assertEquals(pageHistorySummary.getModifier(), page.getModifier());
    }
View Full Code Here

Examples of org.xwiki.xmlrpc.model.XWikiPage

    public void testRenamePage() throws Exception
    {
        String pageName = String.format("%s-%d", TestConstants.TEST_PREFIX, Math.abs(this.random.nextInt()));
        String pageId = String.format("%s.%s", TestConstants.TEST_SPACE, pageName);
        String content = String.format("Modified by org.xwiki.xmlrpc @ %s (inital version)\n", new Date());
        XWikiPage page = null;

        TestUtils.banner("TEST: renamePage()");

        page = new XWikiPage();
        page.setId(pageId);
        page.setContent(content);
        page = this.rpc.storePage(page);

        page.setSpace("Foo");
        page.setTitle("Bar");
        XWikiPage renamedPage = this.rpc.storePage(page);

        try {
            this.rpc.getPage(pageId);
            fail("This page should no longer exist");
        } catch (Exception e) {
            // Ignore
        }

        assertTrue(renamedPage.getId().equals("Foo.Bar"));
        assertTrue(renamedPage.getContent().equals(content));

        /* Test other cases as well */

        page = new XWikiPage();
        page.setId(pageId);
        page.setContent(content);
        page = this.rpc.storePage(page);

        page.setSpace("TargetSpace");
        renamedPage = this.rpc.storePage(page);

        try {
            this.rpc.getPage(pageId);
            fail("This page should no longer exist");
        } catch (Exception e) {
            // Ignore
        }

        assertTrue(renamedPage.getId().equals(String.format("TargetSpace.%s", pageName)));
        assertTrue(renamedPage.getContent().equals(content));

        /*-*/

        page = new XWikiPage();
        page.setId(pageId);
        page.setContent(content);
        page = this.rpc.storePage(page);

        page.setTitle("Foo");
        renamedPage = this.rpc.storePage(page);

        try {
            this.rpc.getPage(pageId);
            fail("This page should no longer exist");
        } catch (Exception e) {
            // Ignore
        }

        assertTrue(renamedPage.getId().equals(String.format("%s.Foo", TestConstants.TEST_SPACE)));
        assertTrue(renamedPage.getContent().equals(content));

    }
View Full Code Here

Examples of org.xwiki.xmlrpc.model.XWikiPage

        List<SpaceSummary> spaces = this.rpc.getSpaces();
        List<XWikiPageSummary> pages = this.rpc.getPages(spaces.get(0).getKey());

        TestUtils.banner("TEST: getAllModifiedPageHistoryCorrectness()");

        XWikiPage page = this.rpc.getPage(pages.get(0).getId());

        System.out.format("Modifying: %s\n", page);

        page.setContent(String.format("Modified %d", System.currentTimeMillis()));
        page = rpc.storePage(page);

        System.out.format("Modified: %s\n", page);

        /* Get the last 25 changes. This should be enough to catch the page modified in this test */
        List<XWikiPageHistorySummary> modifications = rpc.getModifiedPagesHistory(25, 0);

        /* Check if the modified page is listed in the retrieved modification list */
        boolean found = false;
        System.out.format("Modifications:\n");
        for (XWikiPageHistorySummary modification : modifications) {
            System.out.format("%s\n", modification);
            if (page.getId().equals(modification.getBasePageId())) {
                if (page.getModified().equals(modification.getModified())) {
                    found = true;
                }
            }
        }

View Full Code Here

Examples of org.xwiki.xmlrpc.model.XWikiPage

        assertTrue(found);
    }

    public void testStorePageWithCheckVersion() throws Exception
    {
        XWikiPage page = this.rpc.getPage(TestConstants.TEST_PAGE);

        String content =
            String.format("Modified by org.xwiki.xmlrpc @ %s (This will be version: %d)\n", new Date(),
                page.getVersion() + 1);

        page.setContent(content);
        XWikiPage storedPage = this.rpc.storePage(page);

        TestUtils.banner("TEST: storePageWithCheckVersion()");
        System.out.format("Content sent: '%s'\n", Utils.truncateToFirstLine(content));
        System.out.format("%s\n", storedPage);

        assertEquals(content, storedPage.getContent());
        assertTrue(storedPage.getVersion() == (page.getVersion() + 1));
        assertEquals(page.getLanguage(), storedPage.getLanguage());

        /* Try to store again the page */
        storedPage = this.rpc.storePage(page, true);
        assertTrue(storedPage.getId().equals(""));
    }
View Full Code Here

Examples of org.xwiki.xmlrpc.model.XWikiPage

        assertTrue(storedPage.getId().equals(""));
    }

    public void testStoreExistingPageUsingNullTitle() throws Exception
    {
        XWikiPage page = new XWikiPage();
        page.setId(TestConstants.TEST_PAGE);

        String content = String.format("Modified by org.xwiki.xmlrpc @ %s\n", new Date());

        page.setContent(content);

        page = rpc.storePage(page);

        assertEquals(TestConstants.TEST_PAGE, page.getId());
        assertEquals(content, page.getContent());
    }
View Full Code Here

Examples of org.xwiki.xmlrpc.model.XWikiPage

    public void testXWikiXmlRpcServiceWithoutLoginNoRights() throws MalformedURLException
    {
        XWikiXmlRpcClient rpc = new XWikiXmlRpcClient(TestConstants.ENDPOINT);

        try {
            XWikiPage page = rpc.getPage("Scheduler.WebHome");
            Assert.fail();
        } catch (Exception e) {
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.