Search in sources :

Example 31 with TestEngine

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

the class XMLUserDatabaseTest method setUp.

/**
 */
@Before
public void setUp() throws Exception {
    Properties props = TestEngine.getTestProperties();
    props.put(XMLUserDatabase.PROP_USERDATABASE, "target/test-classes/userdatabase.xml");
    WikiEngine engine = new TestEngine(props);
    m_db = new XMLUserDatabase();
    m_db.initialize(engine, props);
}
Also used : TestEngine(org.apache.wiki.TestEngine) Properties(java.util.Properties) WikiEngine(org.apache.wiki.WikiEngine) Before(org.junit.Before)

Example 32 with TestEngine

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

the class TableOfContentsTest method setUp.

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

Example 33 with TestEngine

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

the class UndefinedPagesPluginTest method setUp.

@Before
public void setUp() throws Exception {
    CacheManager.getInstance().removeAllCaches();
    testEngine = new TestEngine(props);
    testEngine.saveText("TestPage", "Reference to [Foobar].");
    testEngine.saveText("Foobar", "Reference to [Foobar 2], [Foobars]");
    context = new WikiContext(testEngine, new WikiPage(testEngine, "TestPage"));
    manager = new DefaultPluginManager(testEngine, props);
}
Also used : WikiContext(org.apache.wiki.WikiContext) WikiPage(org.apache.wiki.WikiPage) TestEngine(org.apache.wiki.TestEngine) Before(org.junit.Before)

Example 34 with TestEngine

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

the class CachingProviderTest method testInitialization.

/**
 *  Checks that at startup we call the provider once, and once only.
 */
@Test
public void testInitialization() throws Exception {
    Properties props = TestEngine.getTestProperties();
    props.setProperty("jspwiki.usePageCache", "true");
    props.setProperty("jspwiki.pageProvider", "org.apache.wiki.providers.CounterProvider");
    props.setProperty("jspwiki.cachingProvider.capacity", "100");
    TestEngine engine = new TestEngine(props);
    CounterProvider p = (CounterProvider) ((CachingProvider) engine.getPageManager().getProvider()).getRealProvider();
    Assert.assertEquals("init", 1, p.m_initCalls);
    Assert.assertEquals("getAllPages", 1, p.m_getAllPagesCalls);
    Assert.assertEquals("pageExists", 0, p.m_pageExistsCalls);
    Assert.assertEquals("getPageText", 4, p.m_getPageTextCalls);
    engine.getPage("Foo");
    Assert.assertEquals("pageExists2", 0, p.m_pageExistsCalls);
}
Also used : TestEngine(org.apache.wiki.TestEngine) Properties(java.util.Properties) Test(org.junit.Test)

Example 35 with TestEngine

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

the class CachingProviderTest method testSneakyAdd.

@Test
public void testSneakyAdd() throws Exception {
    Properties props = TestEngine.getTestProperties();
    props.setProperty("jspwiki.cachingProvider.cacheCheckInterval", "2");
    TestEngine engine = new TestEngine(props);
    String dir = props.getProperty(FileSystemProvider.PROP_PAGEDIR);
    File f = new File(dir, "Testi.txt");
    String content = "[fuufaa]";
    PrintWriter out = new PrintWriter(new FileWriter(f));
    FileUtil.copyContents(new StringReader(content), out);
    out.close();
    // Make sure we wait long enough
    Thread.sleep(4000L);
    WikiPage p = engine.getPage("Testi");
    Assert.assertNotNull("page did not exist?", p);
    String text = engine.getText("Testi");
    Assert.assertEquals("text", "[fuufaa]", text);
// TODO: ReferenceManager check as well
}
Also used : FileWriter(java.io.FileWriter) WikiPage(org.apache.wiki.WikiPage) StringReader(java.io.StringReader) TestEngine(org.apache.wiki.TestEngine) Properties(java.util.Properties) File(java.io.File) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

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