use of org.apache.jackrabbit.core.cluster.SimpleClusterContext in project jackrabbit by apache.
the class ConsistencyCheckerImplTest method createClusterNode.
private ClusterNode createClusterNode(String id) throws Exception {
final MemoryJournal journal = new MemoryJournal() {
protected boolean syncAgainOnNewRecords() {
return true;
}
};
JournalFactory jf = new JournalFactory() {
public Journal getJournal(NamespaceResolver resolver) throws RepositoryException {
return journal;
}
};
ClusterConfig cc = new ClusterConfig(id, SYNC_DELAY, jf);
SimpleClusterContext context = new SimpleClusterContext(cc);
journal.setRepositoryHome(context.getRepositoryHome());
journal.init(id, context.getNamespaceResolver());
journal.setRecords(records);
ClusterNode clusterNode = new ClusterNode();
clusterNode.init(context);
return clusterNode;
}
use of org.apache.jackrabbit.core.cluster.SimpleClusterContext in project jackrabbit by apache.
the class FileJournalTest method testClusterInitIncompleteMissingParam.
/**
* Verify that <code>ClusterNode.stop</code> can be invoked even when
* <code>ClusterNode.init</code> throws because the journal can not
* be initialized. Note: this is done by omitting the required argument
* <code>directory</code>.
*
* @throws Exception
*/
public void testClusterInitIncompleteMissingParam() throws Exception {
JournalFactory jf = new JournalFactory() {
public Journal getJournal(NamespaceResolver resolver) throws RepositoryException {
try {
FileJournal journal = new FileJournal();
// no setDirectory() call here
journal.init(CLUSTER_NODE_ID, resolver);
return journal;
} catch (JournalException e) {
throw new RepositoryException("Expected failure", e);
}
}
};
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();
}
use of org.apache.jackrabbit.core.cluster.SimpleClusterContext 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();
}
use of org.apache.jackrabbit.core.cluster.SimpleClusterContext 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();
}
}
Aggregations