use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.
the class DerefQueryLevel1Test method testDerefMultiPropWithNodeStar.
/**
* Test a deref query on a multi valued reference property with a '*' node.
* @throws NotExecutableException if the workspace does not have sufficient
* content.
*/
public void testDerefMultiPropWithNodeStar() throws RepositoryException, NotExecutableException {
Property refProp = PropertyUtil.searchMultivalProp(testRootNode, PropertyType.REFERENCE);
if (refProp == null) {
throw new NotExecutableException("Workspace does not contain a node with a multivalue reference property.");
}
Value[] targets = refProp.getValues();
Node[] targetNodes = new Node[targets.length];
for (int i = 0; i < targets.length; i++) {
targetNodes[i] = session.getNodeByUUID(targets[i].getString());
}
if (targetNodes.length == 0) {
throw new NotExecutableException("Reference property does not contain a value");
}
String xpath = createStatement(refProp, "*");
executeDerefQuery(session, xpath, targetNodes);
}
use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.
the class DerefQueryLevel1Test method testDerefSinglePropWithNodeStar.
/**
* Test a deref query on a single valued reference property with a '*' node
* test.
* @throws NotExecutableException if the workspace does not have sufficient
* content.
*/
public void testDerefSinglePropWithNodeStar() throws RepositoryException, NotExecutableException {
Property refProp = PropertyUtil.searchProp(session, testRootNode, PropertyType.REFERENCE, Boolean.FALSE);
if (refProp == null) {
throw new NotExecutableException("Workspace does not contain a node with a reference property.");
}
Node target = refProp.getNode();
String xpath = createStatement(refProp, "*");
executeDerefQuery(session, xpath, new Node[] { target });
}
use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.
the class GetLanguageTest method testSQL.
/**
* Tests if a SQL query returns {@link Query#SQL} when calling
* {@link Query#getLanguage()}.
*/
public void testSQL() throws RepositoryException, NotExecutableException {
if (isSupportedLanguage(qsSQL)) {
String stmt = "select * from " + testNodeType;
Query q = session.getWorkspace().getQueryManager().createQuery(stmt, qsSQL);
assertEquals("Query returns wrong language.", qsSQL, q.getLanguage());
} else {
throw new NotExecutableException("SQL not supported");
}
}
use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.
the class TextNodeTest method testTextNodeTestWithPosition.
/**
* Tests text() node test with various position predicates: position(),
* first(), last().
* @throws NotExecutableException if the repository does not support queries
* with position inidex.
*/
public void testTextNodeTestWithPosition() throws RepositoryException, NotExecutableException {
if (!isSupported(Repository.QUERY_XPATH_POS_INDEX)) {
throw new NotExecutableException("Repository does not support position index");
}
Node text1 = testRootNode.addNode(jcrXMLText);
text1.setProperty(jcrXMLCharacters, "foo");
if (!text1.getDefinition().allowsSameNameSiblings()) {
throw new NotExecutableException("Node at path: " + testRoot + " does not allow same name siblings with name: " + jcrXMLText);
}
testRootNode.addNode(nodeName1, testNodeType);
Node text2 = testRootNode.addNode(jcrXMLText);
text2.setProperty(jcrXMLCharacters, "foo");
testRootNode.getSession().save();
String xpath = "/" + jcrRoot + testRoot + "/text()[2]";
executeXPathQuery(superuser, xpath, new Node[] { text2 });
xpath = "/" + jcrRoot + testRoot + "/text()[last()]";
executeXPathQuery(superuser, xpath, new Node[] { text2 });
xpath = "/" + jcrRoot + testRoot + "/text()[position() = 2]";
executeXPathQuery(superuser, xpath, new Node[] { text2 });
xpath = "/" + jcrRoot + testRoot + "/text()[first()]";
executeXPathQuery(superuser, xpath, new Node[] { text1 });
}
use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.
the class QueryResultNodeIteratorTest method testGetSize.
/**
* Tests if {@link javax.jcr.NodeIterator#getSize()} returns the correct
* size.
*
* @throws org.apache.jackrabbit.test.NotExecutableException
* if getSize() returns -1 (unavailable).
*/
public void testGetSize() throws RepositoryException, NotExecutableException {
NodeIterator it = execute(xpathRoot + "//*", qsXPATH).getNodes();
long size = testRootNode.getNodes().getSize();
if (size != -1) {
long count = 0;
while (it.hasNext()) {
it.nextNode();
count++;
}
assertEquals("NodeIterator.getSize does not return correct number.", size, count);
} else {
throw new NotExecutableException("NodeIterator.getSize() does not return size information.");
}
}
Aggregations