Package org.jencks.factory

Source Code of org.jencks.factory.WorkManagerFactoryBeanTest

package org.jencks.factory;

import EDU.oswego.cs.dl.util.concurrent.SynchronizedBoolean;
import org.jencks.SpringTestSupport;

import javax.resource.spi.work.Work;
import javax.resource.spi.work.WorkManager;

/**
* @version $Revision: 1.1 $
*/
public class WorkManagerFactoryBeanTest extends SpringTestSupport {

    SynchronizedBoolean flag = new SynchronizedBoolean(false);
    Object lock = new Object();

    public void testWorkManager() throws Exception {
        WorkManager workManager = (WorkManager) getBean("workManager");
        workManager.scheduleWork(new Work() {
            public void release() {
            }

            public void run() {
                flag.set(true);
                synchronized (lock) {
                    lock.notifyAll();
                }
            }
        });


        if (!flag.get()) {
            synchronized (lock) {
                lock.wait(2000);
            }
        }

        assertTrue("Should have set the flag by now", flag.get());
    }

    protected String getApplicationContextXml() {
        return "org/jencks/factory/workManager.xml";
    }
}
TOP

Related Classes of org.jencks.factory.WorkManagerFactoryBeanTest

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.