String statement = "SELECT * FROM [nt:unstructured]";
QueryManager queryManager = workspace.getQueryManager();
Query query = queryManager.createQuery(statement, Query.JCR_SQL2);
Node node = query.storeAsNode("/storedQuery");
assertThat(node, is(notNullValue()));
assertThat(node.getPrimaryNodeType().getName(), is("nt:query"));
assertThat(node.getProperty("jcr:language").getString(), is(Query.JCR_SQL2));
assertThat(node.getProperty("jcr:statement").getString(), is(statement));
}