Package org.codehaus.activemq.util

Source Code of org.codehaus.activemq.util.AsyncProxyTest

/**
*
* Copyright 2004 Protique Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
**/
package org.codehaus.activemq.util;

import EDU.oswego.cs.dl.util.concurrent.PooledExecutor;
import junit.framework.TestCase;

/**
* @version $Revision: 1.2 $
*/
public class AsyncProxyTest extends TestCase {

    public void testAsyncProxy() throws Exception {
        MockServer service = new MockServerImpl();
       
        // thread pool to execute tasks in
        PooledExecutor executor = new PooledExecutor(1);
       
        // async proxy
        MockServer proxy = (MockServer) AsyncProxy.createProxy(MockServer.class, service, executor);

        // lets make an async call
        System.out.println("Making an async call from thread: " + Thread.currentThread());
        proxy.foo();
       
        // wait a moment for async stuff
        Thread.sleep(1000);

        assertEquals("Should have invoked foo by now", 1, service.getFooCount());

        ExecutorHelper.stopExecutor(executor);
    }
}
TOP

Related Classes of org.codehaus.activemq.util.AsyncProxyTest

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.