boolean exceptionThrowed = false; String message = ""; try { result = queryAndAssert(service, "let $doc := <element attribute=''/>" + "	return boolean( (1,2,$doc) )", 1, ""); } catch (XMLDBException e) { exceptionThrowed = true; message = e.getMessage(); } assertTrue("Exception wanted: " + message, exceptionThrowed);
boolean exceptionThrown = false; String message = ""; try { result = queryAndAssert(service, "let $doc := <element attribute=''/>" + " return boolean( (1,2,$doc) )", 1, ""); } catch (XMLDBException e) { exceptionThrown = true; message = e.getMessage(); } assertTrue("Exception wanted: " + message, exceptionThrown);
	public void testConvertToBoolean() throws XMLDBException {		XQueryService service = getQueryService();		ResourceSet result;		try {			result = queryAndAssert(					service,					"let $doc := <element attribute=''/>" + "return ("							+ "  <true>{boolean(($doc,2,3))}</true> ,"							+ "  <true>{boolean(($doc/@*,2,3))}</true> ,"							+ "  <true>{boolean(true())}</true> ,"							+ "  <true>{boolean('test')}</true> ,"							+ "  <true>{boolean(number(1))}</true> ,"							+ "  <false>{boolean((0))}</false> ,"							+ "  <false>{boolean(false())}</false> ,"							+ "  <false>{boolean('')}</false> ,"							+ "  <false>{boolean(number(0))}</false> ,"							+ "  <false>{boolean(number('NaN'))}</false>" + ")",					10, "");			for (int i = 0; i < 5; i++) {				assertEquals("true " + (i + 1), "<true>true</true>", result						.getResource(i).getContent());			}			for (int i = 5; i < 10; i++) {				assertEquals("false " + (i + 1), "<false>false</false>", result						.getResource(i).getContent());			}		} catch (XMLDBException e) {			fail(e.getMessage());		}		boolean exceptionThrowed = false;		String message = "";		try {			result = queryAndAssert(service,					"let $doc := <element attribute=''/>"							+ "	return boolean( (1,2,$doc) )", 1, "");		} catch (XMLDBException e) {			exceptionThrowed = true;			message = e.getMessage();		}		assertTrue("Exception wanted: " + message, exceptionThrowed);	}