Search in sources :

Example 11 with TestEngine

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

the class GroupManagerTest method setUp.

@Before
public void setUp() throws Exception {
    Properties props = TestEngine.getTestProperties();
    m_engine = new TestEngine(props);
    m_groupMgr = m_engine.getGroupManager();
    m_session = WikiSessionTest.adminSession(m_engine);
    // Flush any pre-existing groups (left over from previous Assert.failures, perhaps)
    try {
        m_groupMgr.removeGroup("Test");
        m_groupMgr.removeGroup("Test2");
        m_groupMgr.removeGroup("Test3");
    } catch (NoSuchPrincipalException e) {
    // It's not a problem if we can't find the principals...
    }
    m_groupMgr.addWikiEventListener(m_trap);
    m_trap.clearEvents();
    // Add 3 test groups
    Group group;
    group = m_groupMgr.parseGroup("Test", "Alice \n Bob \n Charlie", true);
    m_groupMgr.setGroup(m_session, group);
    group = m_groupMgr.parseGroup("Test2", "Bob", true);
    m_groupMgr.setGroup(m_session, group);
    group = m_groupMgr.parseGroup("Test3", "Fred Flintstone", true);
    m_groupMgr.setGroup(m_session, group);
    // We should see 3 events: 1 for each group add
    Assert.assertEquals(3, m_trap.events().length);
    m_trap.clearEvents();
}
Also used : Group(org.apache.wiki.auth.authorize.Group) TestEngine(org.apache.wiki.TestEngine) Properties(java.util.Properties) Before(org.junit.Before)

Example 12 with TestEngine

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

the class UserManagerTest method setUpWithWorkflow.

/**
 * Call this setup program to use the save-profile workflow.
 */
protected void setUpWithWorkflow() throws Exception {
    Properties props = TestEngine.getTestProperties();
    // Turn on user profile saves by the Admin group
    props.put("jspwiki.approver." + UserManager.SAVE_APPROVER, "Admin");
    // Make sure we are using the XML user database
    props.put(XMLUserDatabase.PROP_USERDATABASE, "target/test-classes/userdatabase.xml");
    m_engine = new TestEngine(props);
    m_mgr = m_engine.getUserManager();
    m_db = m_mgr.getUserDatabase();
}
Also used : TestEngine(org.apache.wiki.TestEngine) Properties(java.util.Properties)

Example 13 with TestEngine

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

the class JSPWikiMarkupParserTest method translate_nofollow.

private String translate_nofollow(String src) throws IOException, NoRequiredPropertyException, ServletException, WikiException {
    props = TestEngine.getTestProperties();
    props.setProperty("jspwiki.translatorReader.useRelNofollow", "true");
    TestEngine testEngine2 = new TestEngine(props);
    WikiContext context = new WikiContext(testEngine2, new WikiPage(testEngine2, PAGE_NAME));
    JSPWikiMarkupParser r = new JSPWikiMarkupParser(context, new BufferedReader(new StringReader(src)));
    XHTMLRenderer conv = new XHTMLRenderer(context, r.parse());
    return conv.getString();
}
Also used : WikiContext(org.apache.wiki.WikiContext) WikiPage(org.apache.wiki.WikiPage) BufferedReader(java.io.BufferedReader) StringReader(java.io.StringReader) XHTMLRenderer(org.apache.wiki.render.XHTMLRenderer) TestEngine(org.apache.wiki.TestEngine)

Example 14 with TestEngine

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

the class JSPWikiMarkupParserTest method testHTMLWhenAllowed.

@Test
public void testHTMLWhenAllowed() throws Exception {
    String src = "<p>";
    props.setProperty("jspwiki.translatorReader.allowHTML", "true");
    testEngine = new TestEngine(props);
    WikiPage page = new WikiPage(testEngine, PAGE_NAME);
    String out = translate(testEngine, page, src);
    Assert.assertEquals("<p>", out);
}
Also used : WikiPage(org.apache.wiki.WikiPage) TestEngine(org.apache.wiki.TestEngine) Test(org.junit.Test)

Example 15 with TestEngine

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

the class DefaultPluginManagerTest method setUp.

@Before
public void setUp() throws Exception {
    engine = new TestEngine(props);
    context = new WikiContext(engine, new WikiPage(engine, "Testpage"));
    manager = new DefaultPluginManager(engine, props);
}
Also used : WikiContext(org.apache.wiki.WikiContext) WikiPage(org.apache.wiki.WikiPage) TestEngine(org.apache.wiki.TestEngine) 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