DATACOUCH-573 - use same name for count in query
This commit is contained in:
@@ -22,6 +22,7 @@ import org.springframework.dao.QueryTimeoutException;
|
||||
import org.springframework.dao.support.PersistenceExceptionTranslator;
|
||||
import org.springframework.data.couchbase.core.CouchbaseExceptionTranslator;
|
||||
import org.springframework.data.couchbase.core.OperationInterruptedException;
|
||||
import org.springframework.data.couchbase.repository.query.CountFragment;
|
||||
|
||||
/**
|
||||
* @author Subhashni Balakrishnan
|
||||
@@ -31,7 +32,7 @@ import org.springframework.data.couchbase.core.OperationInterruptedException;
|
||||
public class TemplateUtils {
|
||||
public static final String SELECT_ID = "__id";
|
||||
public static final String SELECT_CAS = "__cas";
|
||||
public static final String SELECT_COUNT = "__count";
|
||||
public static final String SELECT_COUNT = CountFragment.COUNT_ALIAS;
|
||||
private static PersistenceExceptionTranslator exceptionTranslator = new CouchbaseExceptionTranslator();
|
||||
|
||||
public static Throwable translateError(Throwable e) {
|
||||
|
||||
@@ -85,6 +85,33 @@ public class CouchbaseRepositoryQueryIntegrationTests extends ClusterAwareIntegr
|
||||
System.err.println(airports);
|
||||
}
|
||||
|
||||
@Test
|
||||
void count() {
|
||||
String[] iatas = { "JFK", "IAD", "SFO", "SJC", "SEA", "LAX", "PHX" };
|
||||
Future[] future = new Future[iatas.length];
|
||||
ExecutorService executorService = Executors.newFixedThreadPool(iatas.length);
|
||||
|
||||
try {
|
||||
Callable<Boolean>[] suppliers = new Callable[iatas.length];
|
||||
for (int i = 0; i < iatas.length; i++) {
|
||||
Airport airport = new Airport("airports::" + iatas[i], iatas[i] /*iata*/, iatas[i].toLowerCase() /* lcao */);
|
||||
airportRepository.save(airport);
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException ie) {}
|
||||
long airportCount = 0;
|
||||
airportCount = airportRepository.count();
|
||||
assertEquals(7, airportCount);
|
||||
|
||||
} finally {
|
||||
for (int i = 0; i < iatas.length; i++) {
|
||||
Airport airport = new Airport("airports::" + iatas[i], iatas[i] /*iata*/, iatas[i] /* lcao */);
|
||||
airportRepository.delete(airport);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void threadSafeParametersTest() {
|
||||
String[] iatas = { "JFK", "IAD", "SFO", "SJC", "SEA", "LAX", "PHX" };
|
||||
|
||||
Reference in New Issue
Block a user