* Testing the except function.
*
* @throws Exception
*/
public void testFunction() throws Exception {
final Function exceptFunction = new ExceptFunction();
try {
exceptFunction.invoke(expressionContextMock, new Value[0]);
fail("Exception wasn't thrown when empty arguments passed" +
" to function");
} catch (Exception e) {
// ignore it, expected situation
}
assertSame("Function invoked with the empty sequences didn't" +
" return the empty sequence",
Sequence.EMPTY,
exceptFunction.invoke(expressionContextMock, new Value[] {
Sequence.EMPTY, Sequence.EMPTY
}));
final Sequence firstSequence =
expressionContextMock.getFactory().createSequence(
new Item[] {
expressionContextMock.getFactory()
.createStringValue("value0"),
expressionContextMock.getFactory()
.createStringValue("value0"),
expressionContextMock.getFactory()
.createStringValue("value2"),
expressionContextMock.getFactory()
.createBooleanValue(true)});
final Sequence secondSequence =
expressionContextMock.getFactory().createSequence(
new Item[] {
expressionContextMock.getFactory()
.createStringValue("value2"),
expressionContextMock.getFactory()
.createStringValue("value3"),
expressionContextMock.getFactory()
.createStringValue("value3"),
expressionContextMock.getFactory()
.createBooleanValue(false)});
final Sequence result = (Sequence) exceptFunction.invoke(
expressionContextMock, new Value[] {firstSequence,
secondSequence});
assertEquals("number of elements in returned sequence is incorrect",
2, result.getLength());
assertEquals("incorrect element in returned sequence",