JCRStoreService jcrService = ServicesRegistry.getInstance()
.getJCRStoreService();
JCRSessionWrapper session = jcrService.getSessionFactory()
.getCurrentUserSession();
try {
QueryManager queryManager = session.getWorkspace()
.getQueryManager();
if (queryManager != null) {
String query = "select indexFields.* from [test_templates:fieldsWithIndexOptions] as indexFields order by indexFields.[sortableFloat] asc";
Query q = queryManager.createQuery(query, Query.JCR_SQL2);
QueryResult queryResult = q.execute();
Node previousNode = null;
for (NodeIterator it = queryResult.getNodes(); it.hasNext();) {
Node currentNode = (Node) it.next();
if (previousNode != null) {
double previousDouble = 0;
double currentDouble = 0;
try {
previousDouble = previousNode.getProperty(
"sortableFloat").getDouble();
} catch (Exception ex) {
}
try {
currentDouble = currentNode.getProperty(
"sortableFloat").getDouble();
} catch (Exception ex) {
}
assertTrue(previousDouble <= currentDouble);
}
previousNode = currentNode;
}
query = "select indexFields.* from [test_templates:fieldsWithIndexOptions] as indexFields order by indexFields.[nofulltextSmallText] asc";
q = queryManager.createQuery(query, Query.JCR_SQL2);
queryResult = q.execute();
previousNode = null;
for (NodeIterator it = queryResult.getNodes(); it.hasNext();) {
Node currentNode = (Node) it.next();
if (previousNode != null) {
String previousString = "";
String currentString = "";
try {
previousString = previousNode.getProperty(
"nofulltextSmallText").getString();
} catch (Exception ex) {
}
try {
currentString = currentNode.getProperty(
"nofulltextSmallText").getString();
} catch (Exception ex) {
}
assertTrue(previousString.compareTo(currentString) < 0);
}
previousNode = currentNode;
}
query = "select indexFields.* from [test_templates:fieldsWithIndexOptions] as indexFields order by indexFields.[simpleSmallText] asc";
q = queryManager.createQuery(query, Query.JCR_SQL2);
queryResult = q.execute();
previousNode = null;
for (NodeIterator it = queryResult.getNodes(); it.hasNext();) {
Node currentNode = (Node) it.next();
if (previousNode != null) {
String previousString = "";
String currentString = "";
try {
previousString = previousNode.getProperty(
"simpleSmallText").getString();
} catch (Exception ex) {
}
try {
currentString = currentNode.getProperty(
"simpleSmallText").getString();
} catch (Exception ex) {
}
assertTrue(previousString.compareTo(currentString) < 0);
}
previousNode = currentNode;
}
query = "select indexFields.* from [test_templates:fieldsWithIndexOptions] as indexFields order by indexFields.[untokenizedDate] asc";
q = queryManager.createQuery(query, Query.JCR_SQL2);
queryResult = q.execute();
previousNode = null;
for (NodeIterator it = queryResult.getNodes(); it.hasNext();) {
Node currentNode = (Node) it.next();
if (previousNode != null) {