Examples of XWikiPage


Examples of org.xwiki.xmlrpc.model.XWikiPage

        super.setUp();

        try {
            this.rpc.getPage(TestConstants.TEST_PAGE);
        } catch (Exception e) {
            XWikiPage page = new XWikiPage();
            page.setId(TestConstants.TEST_PAGE);
            page.setTitle("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);
            this.rpc.storePage(page);
        }

        try {
            this.rpc.getPage(TestConstants.TEST_PAGE_WITH_TRANSLATIONS);
        } catch (Exception e) {
            XWikiPage page = new XWikiPage();
            page.setId(TestConstants.TEST_PAGE_WITH_TRANSLATIONS);
            page.setTitle("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);
            this.rpc.storePage(page);
        }
    }
View Full Code Here

Examples of org.xwiki.xmlrpc.model.XWikiPage

    public void testGetPage() throws Exception
    {
        List<SpaceSummary> spaces = this.rpc.getSpaces();
        List<XWikiPageSummary> pages = this.rpc.getPages(spaces.get(0).getKey());
        XWikiPage page = this.rpc.getPage(pages.get(0).getId());

        TestUtils.banner("TEST: getPage()");
        System.out.format("%s\n", page);

        assertEquals(page.getId(), pages.get(0).getId());
    }
View Full Code Here

Examples of org.xwiki.xmlrpc.model.XWikiPage

        assertEquals(page.getId(), pages.get(0).getId());
    }

    public void testStorePage() 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: storePage()");
        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());
    }
View Full Code Here

Examples of org.xwiki.xmlrpc.model.XWikiPage

        }

        TestUtils.banner("TEST: changeParentId()");
        System.out.format("Setting page '%s' parent id to '%s'. Now: '%s'\n", pageSummary1.getId(),
            pageSummary2.getId(), pageSummary1.getParentId());
        XWikiPage page = this.rpc.getPage(pageSummary1.getId());
        assertNotSame(pageSummary2.getId(), page.getParentId());

        page.setParentId(pageSummary2.getId());
        page = this.rpc.storePage(page);

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

        assertEquals(pageSummary2.getId(), page.getParentId());
    }
View Full Code Here

Examples of org.xwiki.xmlrpc.model.XWikiPage

    }

    public void testStoreNewPageTranslation() throws Exception
    {
        /* Get the current page and all its available translations */
        XWikiPage page = this.rpc.getPage(TestConstants.TEST_PAGE_WITH_TRANSLATIONS);
        Map<String, XWikiPage> before = new HashMap<String, XWikiPage>();
        before.put(page.getLanguage(), page);
        for (String l : page.getTranslations()) {
            XWikiPage p = this.rpc.getPage(TestConstants.TEST_PAGE_WITH_TRANSLATIONS, l);
            before.put(l, p);
        }

        /* Add a translation in a fake language */
        String[] languages = Locale.getISOLanguages();
        String fakeLanguage = languages[random.nextInt(languages.length)];
        String translatedContent =
            String.format("This is the content in the '%s' language. (This will be version: %d)", fakeLanguage,
                page.getVersion() + 1);
        XWikiPage translatedPage = new XWikiPage();

        translatedPage.setId(TestConstants.TEST_PAGE_WITH_TRANSLATIONS);
        translatedPage.setSpace(TestConstants.TEST_SPACE);
        translatedPage.setTitle("Translated page");
        translatedPage.setContent(translatedContent);
        translatedPage.setLanguage(fakeLanguage);
        translatedPage = this.rpc.storePage(translatedPage);

        /* Re-get the page and all its translations */
        page = this.rpc.getPage(TestConstants.TEST_PAGE_WITH_TRANSLATIONS);
        Map<String, XWikiPage> after = new HashMap<String, XWikiPage>();
        after.put(page.getLanguage(), page);
        for (String l : page.getTranslations()) {
            XWikiPage p = this.rpc.getPage(TestConstants.TEST_PAGE_WITH_TRANSLATIONS, l);
            after.put(l, p);
        }

        TestUtils.banner("TEST: storeNewPageTranslation()");
        System.out.format("Adding the '%s' translation...\n", fakeLanguage);
        System.out.format("*********************************\n");
        System.out.format("Before: %s\n", before);
        System.out.format("*********************************\n");
        System.out.format("After: %s\n", after);

        /* Check for correctenss */
        assertFalse(before.containsKey(fakeLanguage));
        assertTrue(after.containsKey(fakeLanguage));
        assertEquals(translatedContent, after.get(fakeLanguage).getContent());

        for (String l : before.keySet()) {
            assertTrue(after.containsKey(l));
            XWikiPage b = before.get(l);
            XWikiPage a = after.get(l);

            assertEquals(b.getVersion(), a.getVersion());
            assertEquals(b.getContent(), a.getContent());
        }
    }
View Full Code Here

Examples of org.xwiki.xmlrpc.model.XWikiPage

        }
    }

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

        Map<String, String> translatedContents = new HashMap<String, String>();
        translatedContents.put("", page.getContent());
        for (String l : page.getTranslations()) {
            XWikiPage p = this.rpc.getPage(TestConstants.TEST_PAGE_WITH_TRANSLATIONS, l);
            translatedContents.put(l, p.getContent());
        }

        TestUtils.banner("TEST: storeTranslatedPage()");
        System.out.format("%s\n", page);

        String targetLanguage = page.getTranslations().get(0);
        String content =
            String.format("This is a new translation for language '%s' @ %s (this will be version %d)", targetLanguage,
                new Date(), page.getVersion() + 1);

        XWikiPage translatedPage = new XWikiPage();

        translatedPage.setId(TestConstants.TEST_PAGE_WITH_TRANSLATIONS);
        translatedPage.setSpace(TestConstants.TEST_SPACE);
        translatedPage.setTitle("Translated page");
        translatedPage.setContent(content);
        translatedPage.setLanguage(targetLanguage);
        translatedPage = this.rpc.storePage(translatedPage);

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

        /* The following command could be removed. Check it! */
        translatedPage = this.rpc.getPage(TestConstants.TEST_PAGE_WITH_TRANSLATIONS);
        Map<String, String> newTranslatedContents = new HashMap<String, String>();
        newTranslatedContents.put("", page.getContent());
        for (String l : page.getTranslations()) {
            XWikiPage p = this.rpc.getPage(TestConstants.TEST_PAGE_WITH_TRANSLATIONS, l);
            newTranslatedContents.put(l, p.getContent());
        }

        System.out.format("Old translations: %s\n", translatedContents);
        System.out.format("New translations: %s\n", newTranslatedContents);

View Full Code Here

Examples of org.xwiki.xmlrpc.model.XWikiPage

        }
    }

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

        TestUtils.banner("TEST: getPageWithTranslations()");
        System.out.format("%s\n", page);

        assertFalse(page.getTranslations().isEmpty());
    }
View Full Code Here

Examples of org.xwiki.xmlrpc.model.XWikiPage

        assertFalse(page.getTranslations().isEmpty());
    }

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

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

        for (String language : page.getTranslations()) {
            XWikiPage translatedPage = this.rpc.getPage(TestConstants.TEST_PAGE_WITH_TRANSLATIONS, language);
            System.out.format("XWikiPage for language '%s': %s\n", language, translatedPage);

            assertEquals(language, translatedPage.getLanguage());
        }
    }
View Full Code Here

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: createPage()");

        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);
        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.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
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.