Examples of QueuedObjectHolder


Examples of org.jbehave.core.threaded.QueuedObjectHolder

    public void shouldStopQueueWhenRequested() throws Exception {
      // Can't think how to test this.
    }
   
    public void shouldPassCaughtExceptionsToHandler() throws Exception {
        final QueuedObjectHolder exceptionHolder = new QueuedObjectHolder();
        final RuntimeException exception = new RuntimeException("An exception occurred");
       
        Mock handler = mock(ErrorHandler.class);
        handler.expects("handle").will(new InvocationHandler() {
            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                exceptionHolder.set(args[0]);
                return null;
            }
        });
       
        ThreadedQueue queue = new ThreadedQueue("test queue", (ErrorHandler) handler) {
            protected void perform(Runnable action) {
                action.run();
            }
        };
       
        queue.queue(new Runnable(){ public void run() {
            throw exception;
        }});

        ensureThat(exceptionHolder.get(), is(exception));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.