FileDocCategorySizeDatePackage
TestApplicationScope.javaAPI DocApache Axis 1.44877Sat Apr 22 18:57:28 BST 2006test.concurrency

TestApplicationScope

public class TestApplicationScope extends TestCase
Test the "application" scope option - lots of threads call the same service multiple times, and we confirm that only a single instance of the service object was created.
author
Glen Daniels (gdaniels@apache.org)

Fields Summary
protected static Log
log
private org.apache.axis.configuration.BasicServerConfig
config
private org.apache.axis.server.AxisServer
server
private String
SERVICE_NAME
private Exception
error
Constructors Summary
public TestApplicationScope(String s)


       
        super(s);
    
Methods Summary
synchronized voidsetError(java.lang.Exception e)

        
        if (error == null) {
            error = e;
        }
    
protected voidsetUp()

        config = new BasicServerConfig();
        server = new AxisServer(config);

        // Deploy a service which contains an option that we expect to be
        // available by asking the MessageContext in the service method (see
        // PropertyHandler.java).

        RPCProvider provider = new RPCProvider();
        SOAPService service = new SOAPService(provider);
        service.setName(SERVICE_NAME);
        service.setOption("className", TestService.class.getName());
        service.setOption("scope", "application");
        service.setOption("allowedMethods", "*");
        config.deployService(SERVICE_NAME, service);
    
public voidtestApplicationScope()

        int threads = 50;
        int reps = 10;

        ThreadGroup group = new ThreadGroup("TestThreads");

        for (int i = 0; i < threads; i++) {
            TestRunnable tr = new TestRunnable(reps);
            Thread thread = new Thread(group, tr, "TestThread #" + i);
            thread.start();
        }

        while (group.activeCount() > 0 && error == null) {
            Thread.sleep(100);
        }

        if (error != null) {
            throw error;
        }