Search in sources :

Example 36 with TestEngine

use of org.apache.wiki.TestEngine in project jspwiki by apache.

the class FileSystemProviderTest method setUp.

@Before
public void setUp() throws Exception {
    m_pagedir = "./target/jspwiki.test.pages";
    props.setProperty(PageManager.PROP_PAGEPROVIDER, "FileSystemProvider");
    props.setProperty(FileSystemProvider.PROP_PAGEDIR, m_pagedir);
    Properties props2 = new Properties();
    PropertyConfigurator.configure(props2);
    m_engine = new TestEngine(props);
    m_provider = new FileSystemProvider();
    m_provider.initialize(m_engine, props);
    props.setProperty(WikiEngine.PROP_ENCODING, "UTF-8");
    m_providerUTF8 = new FileSystemProvider();
    m_providerUTF8.initialize(m_engine, props);
}
Also used : TestEngine(org.apache.wiki.TestEngine) Properties(java.util.Properties) Before(org.junit.Before)

Example 37 with TestEngine

use of org.apache.wiki.TestEngine in project jspwiki by apache.

the class VersioningFileProviderTest method testMigrationMultiChangesNoCache.

/*
     * A variation of testMigrationMultiChangesHistory when caching
     * is disabled.
     */
@Test
public void testMigrationMultiChangesNoCache() throws Exception {
    // discard the default engine, and get another with different properties
    // note: the originating properties file is unchanged.
    String cacheState = PROPS.getProperty(PageManager.PROP_USECACHE);
    Assert.assertEquals("should cache", "true", cacheState);
    cacheState = "false";
    PROPS.setProperty(PageManager.PROP_USECACHE, cacheState);
    engine = new TestEngine(PROPS);
    // the new TestEngine will have assigned a new page directory
    files = PROPS.getProperty(AbstractFileProvider.PROP_PAGEDIR);
    // we cannot switch PageProviders within a single test, so the
    // initial FileSystemProvider wiki page must be faked.
    final String fakeWikiPage = "foobar";
    injectFile(NAME1 + AbstractFileProvider.FILE_EXT, fakeWikiPage);
    // also create an associated properties file with some history
    injectFile(NAME1 + FileSystemProvider.PROP_EXT, FAKE_HISTORY);
    // next update the wiki page to create a version number 2
    // with a different user name
    final String text2 = "diddo\r\n";
    engine.saveTextAsJanne(NAME1, text2);
    // finally update the wiki page to create a version number 3
    final String text3 = "whateverNext\r\n";
    engine.saveText(NAME1, text3);
    // confirm the right number of versions have been recorded
    Collection versionHistory = engine.getVersionHistory(NAME1);
    Assert.assertEquals("number of versions", 3, versionHistory.size());
    // fetch the latest version of the page
    String result = engine.getText(NAME1);
    Assert.assertEquals("latest should be newest version", text3, result);
    String result2 = engine.getText(NAME1, 3);
    Assert.assertEquals("fetch new by version did not work", text3, result2);
    // confirm the original page was archived
    String result3 = engine.getText(NAME1, 1);
    Assert.assertEquals("fetch original by version Assert.failed", fakeWikiPage, result3);
    // confirm the first update was archived
    String result4 = engine.getText(NAME1, 2);
    Assert.assertEquals("fetch original by version Assert.failed", text2, result4);
    WikiPage pageNew = engine.getPage(NAME1);
    Assert.assertEquals("newest version", 3, pageNew.getVersion());
    Assert.assertEquals("newest author", "Guest", pageNew.getAuthor());
    WikiPage pageMiddle = engine.getPage(NAME1, 2);
    Assert.assertEquals("middle version", 2, pageMiddle.getVersion());
    Assert.assertEquals("middle author", Users.JANNE, pageMiddle.getAuthor());
    WikiPage pageOld = engine.getPage(NAME1, 1);
    Assert.assertEquals("old version", 1, pageOld.getVersion());
    Assert.assertEquals("old author", OLD_AUTHOR, pageOld.getAuthor());
}
Also used : WikiPage(org.apache.wiki.WikiPage) Collection(java.util.Collection) TestEngine(org.apache.wiki.TestEngine) Test(org.junit.Test)

Example 38 with TestEngine

use of org.apache.wiki.TestEngine in project jspwiki by apache.

the class VersioningFileProviderTest method setUp.

@Before
public void setUp() throws Exception {
    // make sure that the reference manager cache is cleaned first
    TestEngine.emptyWorkDir(null);
    engine = new TestEngine(PROPS);
    files = PROPS.getProperty(AbstractFileProvider.PROP_PAGEDIR);
}
Also used : TestEngine(org.apache.wiki.TestEngine) Before(org.junit.Before)

Example 39 with TestEngine

use of org.apache.wiki.TestEngine in project jspwiki by apache.

the class ApprovalWorkflowTest method setUp.

@Before
public void setUp() throws Exception {
    Properties props = TestEngine.getTestProperties();
    // Explicitly turn on Admin approvals for page saves and our sample approval workflow
    props.put("jspwiki.approver.workflow.saveWikiPage", "Admin");
    props.put("jspwiki.approver.workflow.approvalWorkflow", Users.JANNE);
    // Start the wiki engine
    m_engine = new TestEngine(props);
    m_wm = m_engine.getWorkflowManager();
    m_dq = m_wm.getDecisionQueue();
    m_builder = WorkflowBuilder.getBuilder(m_engine);
}
Also used : TestEngine(org.apache.wiki.TestEngine) Properties(java.util.Properties) Before(org.junit.Before)

Example 40 with TestEngine

use of org.apache.wiki.TestEngine in project jspwiki by apache.

the class CreoleRendererTest method setUp.

@Before
public void setUp() throws Exception {
    Properties props = TestEngine.getTestProperties();
    m_testEngine = new TestEngine(props);
}
Also used : TestEngine(org.apache.wiki.TestEngine) Properties(java.util.Properties) Before(org.junit.Before)

Aggregations

TestEngine (org.apache.wiki.TestEngine)70 Before (org.junit.Before)49 Properties (java.util.Properties)42 WikiPage (org.apache.wiki.WikiPage)15 Test (org.junit.Test)15 WikiContext (org.apache.wiki.WikiContext)11 WikiEngine (org.apache.wiki.WikiEngine)8 File (java.io.File)4 Subject (javax.security.auth.Subject)4 WikiSessionTest (org.apache.wiki.WikiSessionTest)4 NoRequiredPropertyException (org.apache.wiki.api.exceptions.NoRequiredPropertyException)4 XMLUserDatabase (org.apache.wiki.auth.user.XMLUserDatabase)4 Attachment (org.apache.wiki.attachment.Attachment)3 WikiPrincipal (org.apache.wiki.auth.WikiPrincipal)3 StringReader (java.io.StringReader)2 Principal (java.security.Principal)2 WikiSession (org.apache.wiki.WikiSession)2 GroupPrincipal (org.apache.wiki.auth.GroupPrincipal)2 Group (org.apache.wiki.auth.authorize.Group)2 BufferedReader (java.io.BufferedReader)1