class JcrTemplate extends JcrAccessor implements JcrOperations {

    @Override
    public QueryResult query(final Node node) {

        if (node == null)
            throw new IllegalArgumentException("node can't be null");

        return execute(new JcrCallback<QueryResult>() {
            /**
             * @see JcrCallback#doInJcr(javax.jcr.Session)
             */
            @Override
            public QueryResult doInJcr(Session session) throws RepositoryException {
                boolean debug = LOG.isDebugEnabled();

                // get query manager
                QueryManager manager = session.getWorkspace().getQueryManager();
                if (debug)
                    LOG.debug("retrieved manager " + manager);

                Query query = manager.getQuery(node);
                if (debug)
                    LOG.debug("created query " + query);

                return query.execute();
            }
        }, true);
    }

}

class JcrTemplateTest {

    private SessionFactory sessionFactory;
    private Repository repository;
    private Session session;
    private JcrTemplate jcrTemplate;

    @Test
    public void testExecuteQuerySimple() throws RepositoryException {

        try {
            jcrTemplate.query((String) null);
            fail("should have thrown exception");
        } catch (IllegalArgumentException e) {
            // it's okay
        }
        // the rest of the test is covered by testExecuteQuery

    }

}