use of java.util.EmptyStackException in project core-java by SpineEventEngine.
the class VerifyShould method pass_assertThrows_if_callable_throws_specified_exception.
@Test
public void pass_assertThrows_if_callable_throws_specified_exception() {
final Callable throwsEmptyStackException = new Callable() {
@Override
public Object call() throws Exception {
throw new EmptyStackException();
}
};
assertThrows(EmptyStackException.class, throwsEmptyStackException);
}
use of java.util.EmptyStackException in project core-java by SpineEventEngine.
the class VerifyShould method pass_assertThrowsWithCause_if_callable_throws_specified_exception_with_specified_cause.
@Test
public void pass_assertThrowsWithCause_if_callable_throws_specified_exception_with_specified_cause() {
final Throwable cause = new EmptyStackException();
final RuntimeException runtimeException = new RuntimeException(cause);
final Callable throwsRuntimeException = new Callable() {
@Override
public Object call() {
throw runtimeException;
}
};
assertThrowsWithCause(runtimeException.getClass(), cause.getClass(), throwsRuntimeException);
}
use of java.util.EmptyStackException in project core-java by SpineEventEngine.
the class VerifyShould method fail_assertThrowsWithCause_if_runnable_expected_cause_is_null.
@SuppressWarnings("ConstantConditions")
@Test(expected = AssertionError.class)
public void fail_assertThrowsWithCause_if_runnable_expected_cause_is_null() {
final Runnable throwsRuntimeException = new Runnable() {
@Override
public void run() {
throw new RuntimeException(new EmptyStackException());
}
};
assertThrowsWithCause(EmptyStackException.class, null, throwsRuntimeException);
}
use of java.util.EmptyStackException in project voltdb by VoltDB.
the class PlannerTestCase method assertTopDownTree.
/**
* Assert that a plan node tree contains the expected types of plan nodes
* in the order listed, assuming a top-down left-to-right depth-first
* traversal through the child vector. A null plan node type in the list
* will match any plan node or subtree at the corresponding position.
**/
protected static void assertTopDownTree(AbstractPlanNode start, PlanNodeType... nodeTypes) {
Stack<AbstractPlanNode> stack = new Stack<>();
stack.push(start);
for (PlanNodeType type : nodeTypes) {
// Process each node before its children or later siblings.
AbstractPlanNode parent;
try {
parent = stack.pop();
} catch (EmptyStackException ese) {
fail("No node was found in the tree to match node type " + type);
// This dead code hushes warnings.
return;
}
int childCount = parent.getChildCount();
if (type == null) {
// A null type wildcard matches any child TREE or NODE.
System.out.println("DEBUG: Suggestion -- expect " + parent.getPlanNodeType() + " with " + childCount + " direct children.");
continue;
}
assertEquals(type, parent.getPlanNodeType());
// Iterate from the last child to the first.
while (childCount > 0) {
// Push each child to be processed before its parent's
// or its own later (already pushed) siblings.
stack.push(parent.getChild(--childCount));
}
}
assertTrue("Extra plan node(s) (" + stack.size() + ") were found in the tree with no node type to match", stack.isEmpty());
}
use of java.util.EmptyStackException in project voltdb by VoltDB.
the class PlannerTestCase method assertExprTopDownTree.
/**
* Assert that an expression tree contains the expected types of expressions
* in the order listed, assuming a top-down left-to-right depth-first
* traversal through left, right, and args children.
* A null expression type in the list will match any expression
* node or tree at the corresponding position.
**/
protected static void assertExprTopDownTree(AbstractExpression start, ExpressionType... exprTypes) {
assertNotNull(start);
Stack<AbstractExpression> stack = new Stack<>();
stack.push(start);
for (ExpressionType type : exprTypes) {
// Process each node before its children or later siblings.
AbstractExpression parent;
try {
parent = stack.pop();
} catch (EmptyStackException ese) {
fail("No expression was found in the tree to match type " + type);
// This dead code hushes warnings.
return;
}
List<AbstractExpression> args = parent.getArgs();
AbstractExpression rightExpr = parent.getRight();
AbstractExpression leftExpr = parent.getLeft();
int argCount = (args == null) ? 0 : args.size();
int childCount = argCount + (rightExpr == null ? 0 : 1) + (leftExpr == null ? 0 : 1);
if (type == null) {
// A null type wildcard matches any child TREE or NODE.
System.out.println("DEBUG: Suggestion -- expect " + parent.getExpressionType() + " with " + childCount + " direct children.");
continue;
}
assertEquals(type, parent.getExpressionType());
// Iterate from the last child to the first.
while (argCount > 0) {
// Push each child to be processed before its parent's
// or its own later siblings (already pushed).
stack.push(parent.getArgs().get(--argCount));
}
if (rightExpr != null) {
stack.push(rightExpr);
}
if (leftExpr != null) {
stack.push(leftExpr);
}
}
assertTrue("Extra expression node(s) (" + stack.size() + ") were found in the tree with no expression type to match", stack.isEmpty());
}
Aggregations