use of com.mongodb.OakFongo in project jackrabbit-oak by apache.
the class MongoCacheConsistencyTest method getFixture.
@Override
public DocumentStoreFixture getFixture() throws Exception {
Fongo fongo = new OakFongo("fongo") {
private String suppressedEx = null;
@Override
protected void afterInsert(WriteResult result) {
maybeThrow();
}
@Override
protected void afterFindAndModify(DBObject result) {
maybeThrow();
}
@Override
protected void afterUpdate(WriteResult result) {
maybeThrow();
}
@Override
protected void afterRemove(WriteResult result) {
maybeThrow();
}
@Override
protected void beforeExecuteBulkWriteOperation(boolean ordered, Boolean bypassDocumentValidation, List<?> writeRequests, WriteConcern aWriteConcern) {
// suppress potentially set exception message because
// fongo bulk writes call other update methods
suppressedEx = exceptionMsg;
exceptionMsg = null;
}
@Override
protected void afterExecuteBulkWriteOperation(BulkWriteResult result) {
exceptionMsg = suppressedEx;
suppressedEx = null;
maybeThrow();
}
private void maybeThrow() {
if (exceptionMsg != null) {
throw new MongoException(exceptionMsg);
}
}
};
DocumentMK.Builder builder = provider.newBuilder().setAsyncDelay(0);
final DocumentStore store = new MongoDocumentStore(fongo.getMongo(), "oak", builder);
return new DocumentStoreFixture() {
@Override
public String getName() {
return "MongoDB";
}
@Override
public DocumentStore createDocumentStore(DocumentMK.Builder builder) {
return store;
}
};
}
use of com.mongodb.OakFongo in project jackrabbit-oak by apache.
the class MongoDBExceptionTest method before.
@Before
public void before() throws Exception {
OakFongo fongo = new OakFongo("fongo") {
@Override
protected void beforeExecuteBulkWriteOperation(boolean ordered, Boolean bypassDocumentValidation, List<?> writeRequests, WriteConcern aWriteConcern) {
maybeThrow();
}
@Override
protected void beforeFindAndModify(DBObject query, DBObject fields, DBObject sort, boolean remove, DBObject update, boolean returnNew, boolean upsert) {
maybeThrow();
}
@Override
protected void beforeUpdate(DBObject q, DBObject o, boolean upsert, boolean multi, WriteConcern concern, DBEncoder encoder) {
maybeThrow();
}
@Override
protected void beforeFind(DBObject query, DBObject projection) {
maybeThrow();
}
private void maybeThrow() {
if (exceptionMsg != null) {
throw new MongoException(exceptionMsg);
}
}
};
store = new MongoDocumentStore(fongo.getMongo(), "oak", new DocumentMK.Builder());
}
Aggregations