use of org.datanucleus.api.jdo.JDOQuery in project tests by datanucleus.
the class JDOQLSingleStringParserTest method testSubselectWithMissingCloseParen.
/**
* Test that we give an appropriate exception when parsing a subselect with a missing close paren.
*/
public void testSubselectWithMissingCloseParen() {
PersistenceManager pm = pmf.getPersistenceManager();
Query q = pm.newQuery("JDOQL", null);
AbstractJDOQLQuery query = (AbstractJDOQLQuery) ((JDOQuery) q).getInternalQuery();
String str = "SELECT FROM org.jpox.samples.MyClass WHERE field1 > (SELECT avg(f.field1) FROM org.jpox.samples.MyClass f";
JDOQLSingleStringParser parser = new JDOQLSingleStringParser(query, str);
try {
parser.parse();
// Should preserve spaces in the WHERE
fail("Expected NucleusException");
} catch (NucleusUserException e) {
// Expected since we're missing a close parent
}
}
Aggregations