Search in sources :

Example 6 with ClusterConfig

use of org.apache.jackrabbit.core.config.ClusterConfig in project jackrabbit by apache.

the class FileJournalTest method testRevisionIsOptional.

/**
     * Create a journal with no revision file name. Verify that the journal
     * is created nonetheless, with a revision file in the repository home.
     *
     * @throws Exception
     * @see <a href="http://issues.apache.org/jira/browse/JCR-904">JCR-904</a>
     */
public void testRevisionIsOptional() throws Exception {
    final FileJournal journal = new FileJournal();
    journal.setDirectory(journalDirectory.getPath());
    JournalFactory jf = new JournalFactory() {

        public Journal getJournal(NamespaceResolver resolver) {
            return journal;
        }
    };
    ClusterConfig cc = new ClusterConfig(CLUSTER_NODE_ID, SYNC_DELAY, jf);
    SimpleClusterContext context = new SimpleClusterContext(cc, repositoryHome);
    journal.setRepositoryHome(repositoryHome);
    journal.init(CLUSTER_NODE_ID, context.getNamespaceResolver());
    ClusterNode clusterNode = new ClusterNode();
    clusterNode.init(context);
    try {
        File revisionFile = new File(repositoryHome, FileJournal.DEFAULT_INSTANCE_FILE_NAME);
        assertTrue(revisionFile.exists());
    } finally {
        clusterNode.stop();
    }
}
Also used : ClusterNode(org.apache.jackrabbit.core.cluster.ClusterNode) SimpleClusterContext(org.apache.jackrabbit.core.cluster.SimpleClusterContext) NamespaceResolver(org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver) File(java.io.File) ClusterConfig(org.apache.jackrabbit.core.config.ClusterConfig)

Example 7 with ClusterConfig

use of org.apache.jackrabbit.core.config.ClusterConfig in project jackrabbit by apache.

the class FileJournalTest method testClusterInitIncompleteBadJournalClass.

/**
     * Verify that <code>ClusterNode.stop</code> can be invoked even when
     * <code>ClusterNode.init</code> throws because of a bad journal class.
     *
     * @throws Exception
     */
public void testClusterInitIncompleteBadJournalClass() throws Exception {
    JournalFactory jf = new JournalFactory() {

        public Journal getJournal(NamespaceResolver resolver) throws RepositoryException {
            throw new RepositoryException("Journal not available");
        }
    };
    ClusterConfig cc = new ClusterConfig(CLUSTER_NODE_ID, SYNC_DELAY, jf);
    SimpleClusterContext context = new SimpleClusterContext(cc);
    ClusterNode clusterNode = new ClusterNode();
    try {
        clusterNode.init(context);
        fail("Bad cluster configuration.");
    } catch (Exception e) {
    }
    clusterNode.stop();
}
Also used : ClusterNode(org.apache.jackrabbit.core.cluster.ClusterNode) SimpleClusterContext(org.apache.jackrabbit.core.cluster.SimpleClusterContext) NamespaceResolver(org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver) RepositoryException(javax.jcr.RepositoryException) RepositoryException(javax.jcr.RepositoryException) ClusterConfig(org.apache.jackrabbit.core.config.ClusterConfig)

Aggregations

ClusterConfig (org.apache.jackrabbit.core.config.ClusterConfig)7 NamespaceResolver (org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver)6 ClusterNode (org.apache.jackrabbit.core.cluster.ClusterNode)4 SimpleClusterContext (org.apache.jackrabbit.core.cluster.SimpleClusterContext)4 RepositoryException (javax.jcr.RepositoryException)3 JournalFactory (org.apache.jackrabbit.core.journal.JournalFactory)3 MemoryJournal (org.apache.jackrabbit.core.journal.MemoryJournal)3 File (java.io.File)1 JournalException (org.apache.jackrabbit.core.journal.JournalException)1