DATACOUCH-44 - Expose PersistTo/ReplicateTo on template

While users benefit from the exposure in terms of control, it is also
needed to make the unit tests more reliable as reported in the ticket.
This commit is contained in:
Michael Nitschinger
2014-01-23 14:35:03 +01:00
parent 9452c40eeb
commit 5414ee556b
3 changed files with 243 additions and 85 deletions

View File

@@ -19,6 +19,8 @@ package org.springframework.data.couchbase.repository;
import com.couchbase.client.CouchbaseClient;
import com.couchbase.client.protocol.views.DesignDocument;
import com.couchbase.client.protocol.views.ViewDesign;
import net.spy.memcached.PersistTo;
import net.spy.memcached.ReplicateTo;
import org.springframework.data.couchbase.core.CouchbaseTemplate;
import org.springframework.test.context.TestContext;
import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
@@ -40,13 +42,15 @@ public class SimpleCouchbaseRepositoryListener extends DependencyInjectionTestEx
for (int i = 0; i < 100; i++) {
User u = new User("testuser-" + i, "uname-" + i);
template.save(u);
template.save(u, PersistTo.MASTER, ReplicateTo.ZERO);
}
}
private void createAndWaitForDesignDocs(CouchbaseClient client) {
DesignDocument designDoc = new DesignDocument("user");
String mapFunction = "function (doc, meta) { if(doc._class == \"org.springframework.data.couchbase.repository.User\") { emit(null, null); } }";
String mapFunction = "function (doc, meta) { if(doc._class == \"org.springframework.data.couchbase.repository." +
"User\") { emit(null, null); } }";
designDoc.setView(new ViewDesign("all", mapFunction, "_count"));
client.createDesignDoc(designDoc);
}