Search in sources :

Example 16 with TestEngine

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

the class JDBCGroupDatabaseTest method setUp.

/**
 */
@Before
public void setUp() throws Exception {
    m_hu.setUp();
    Properties props = TestEngine.getTestProperties();
    WikiEngine engine = new TestEngine(props);
    m_wiki = engine.getApplicationName();
    // Set up the mock JNDI initial context
    TestJNDIContext.initialize();
    Context initCtx = new InitialContext();
    try {
        initCtx.bind("java:comp/env", new TestJNDIContext());
    } catch (NameAlreadyBoundException e) {
    // ignore
    }
    Context ctx = (Context) initCtx.lookup("java:comp/env");
    DataSource ds = new TestJDBCDataSource(new File("target/test-classes/jspwiki-custom.properties"));
    ctx.bind(JDBCGroupDatabase.DEFAULT_GROUPDB_DATASOURCE, ds);
    try {
        m_conn = ds.getConnection();
    } catch (SQLException e) {
        Assert.fail("Looks like your database could not be connected to - " + "please make sure that you have started your database, exception: " + e.getMessage());
    }
    // Initialize the user database
    m_db = new JDBCGroupDatabase();
    m_db.initialize(engine, new Properties());
}
Also used : InitialContext(javax.naming.InitialContext) TestJNDIContext(org.apache.wiki.TestJNDIContext) Context(javax.naming.Context) NameAlreadyBoundException(javax.naming.NameAlreadyBoundException) TestJDBCDataSource(org.apache.wiki.TestJDBCDataSource) SQLException(java.sql.SQLException) TestEngine(org.apache.wiki.TestEngine) Properties(java.util.Properties) WikiEngine(org.apache.wiki.WikiEngine) TestJNDIContext(org.apache.wiki.TestJNDIContext) File(java.io.File) InitialContext(javax.naming.InitialContext) TestJDBCDataSource(org.apache.wiki.TestJDBCDataSource) DataSource(javax.sql.DataSource) Before(org.junit.Before)

Example 17 with TestEngine

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

the class XMLGroupDatabaseTest method setUp.

/**
 */
@Before
public void setUp() throws Exception {
    Properties props = TestEngine.getTestProperties();
    WikiEngine engine = new TestEngine(props);
    m_db = new XMLGroupDatabase();
    m_db.initialize(engine, props);
    m_wiki = engine.getApplicationName();
}
Also used : TestEngine(org.apache.wiki.TestEngine) Properties(java.util.Properties) WikiEngine(org.apache.wiki.WikiEngine) Before(org.junit.Before)

Example 18 with TestEngine

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

the class CookieAssertionLoginModuleTest method setUp.

/**
 */
@Before
public void setUp() throws Exception {
    Properties props = TestEngine.getTestProperties();
    props.put(XMLUserDatabase.PROP_USERDATABASE, "target/test-classes/userdatabase.xml");
    m_engine = new TestEngine(props);
    m_db = new XMLUserDatabase();
    m_subject = new Subject();
    try {
        m_db.initialize(m_engine, props);
    } catch (NoRequiredPropertyException e) {
        System.err.println(e.getMessage());
        Assert.assertTrue(false);
    }
}
Also used : TestEngine(org.apache.wiki.TestEngine) XMLUserDatabase(org.apache.wiki.auth.user.XMLUserDatabase) Properties(java.util.Properties) NoRequiredPropertyException(org.apache.wiki.api.exceptions.NoRequiredPropertyException) Subject(javax.security.auth.Subject) Before(org.junit.Before)

Example 19 with TestEngine

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

the class BasicAttachmentProviderTest method setUp.

@Before
public void setUp() throws Exception {
    m_engine = new TestEngine(props);
    TestEngine.deleteAll(new File(TextUtil.getRequiredProperty(props, BasicAttachmentProvider.PROP_STORAGEDIR)));
    m_provider = new BasicAttachmentProvider();
    m_provider.initialize(m_engine, props);
    m_engine.saveText(NAME1, "Foobar");
    m_engine.saveText(NAME2, "Foobar2");
}
Also used : TestEngine(org.apache.wiki.TestEngine) File(java.io.File) Before(org.junit.Before)

Example 20 with TestEngine

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

the class CachingProviderTest method setUp.

@Before
public void setUp() throws Exception {
    TestEngine.emptyWorkDir();
    CacheManager.getInstance().removeAllCaches();
    Properties props2 = TestEngine.getTestProperties();
    testEngine = new TestEngine(props2);
    PropertyConfigurator.configure(props2);
}
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