use of org.jpl7.JPLException in project packages-jpl by SWI-Prolog.
the class TestJUnit method testOpenGetClose2.
public void testOpenGetClose2() {
// we're not going to open this...
Query q = new Query("dummy");
try {
// should throw exception (query not open)
q.getSolution();
// shouldn't get
fail("getSolution() succeeds on unopened Query");
// to here
} catch (JPLException e) {
// expected exception class
if (e.getMessage().endsWith("Query is not open")) {
// OK: an appropriate exception was thrown
} else {
fail("jpl.Query#getSolution() threw wrong JPLException: " + e);
}
} catch (Exception e) {
fail("jpl.Query#getSolution() threw wrong exception class: " + e);
}
}
use of org.jpl7.JPLException in project packages-jpl by SWI-Prolog.
the class TestJUnit method testGetSolution2.
public void testGetSolution2() {
// this query has no solutions
Query q = new Query("fail");
// this opens the query
q.open();
// this finds no solution, and closes the query
q.getSolution();
try {
// this call is invalid, as the query is closed
q.getSolution();
// shouldn't get to here
fail("jpl.Query#getSolution() shoulda thrown JPLException");
} catch (JPLException e) {
// in detail?
if (e.getMessage().endsWith("Query is not open")) {
// ...which
// should throw
// a
// JPLException
// like this
// OK: an appropriate exception was thrown
} else {
fail("jpl.Query#getSolution() threw incorrect JPLException: " + e);
}
} catch (Exception e) {
fail("jpl.Query#getSolution() threw wrong class of exception: " + e);
}
}
Aggregations