Package org.apache.tapestry.services

Examples of org.apache.tapestry.services.ObjectPool


{
    public void testStoreAndGet()
    {
        String key = "POOLED-KEY";
        String pooled = "POOLED";
        ObjectPool p = new ObjectPoolImpl();

        assertNull(p.get(key));

        p.store(key, pooled);

        assertSame(pooled, p.get(key));

        assertNull(p.get(key));
    }
View Full Code Here


        assertNull(p.get(key));
    }

    public void testStoreMany()
    {
        ObjectPool p = new ObjectPoolImpl();

        Object pooled1 = new Object();
        Object pooled2 = new Object();

        String key = "POOLED-KEY";

        p.store(key, pooled1);
        p.store(key, pooled2);

        // No guarantee that we'll get them out in the order they were put in.

        List l = new ArrayList();
        l.add(pooled1);
        l.add(pooled2);

        for (int i = 0; i < 2; i++)
        {
            Object pooled = p.get(key);

            assertTrue(l.remove(pooled));
        }

        assertNull(p.get(key));
    }
View Full Code Here

        MockControl extractorControl = newControl(RequestLocaleManager.class);
        RequestLocaleManager extractor = (RequestLocaleManager) extractorControl.getMock();

        MockControl poolControl = newControl(ObjectPool.class);
        ObjectPool pool = (ObjectPool) poolControl.getMock();

        // Training

        extractor.extractLocaleForCurrentRequest();
        extractorControl.setReturnValue(Locale.CHINESE);

        IEngine engine = (IEngine) newMock(IEngine.class);

        pool.get(Locale.CHINESE);
        poolControl.setReturnValue(engine);

        replayControls();

        EngineManagerImpl m = new EngineManagerImpl();
View Full Code Here

        MockControl extractorControl = newControl(RequestLocaleManager.class);
        RequestLocaleManager extractor = (RequestLocaleManager) extractorControl.getMock();

        MockControl poolControl = newControl(ObjectPool.class);
        ObjectPool pool = (ObjectPool) poolControl.getMock();

        // Training

        extractor.extractLocaleForCurrentRequest();
        extractorControl.setReturnValue(Locale.CHINESE);

        IEngine engine = (IEngine) newMock(IEngine.class);

        pool.get(Locale.CHINESE);
        poolControl.setReturnValue(null);

        MockControl factoryControl = newControl(EngineFactory.class);
        EngineFactory factory = (EngineFactory) factoryControl.getMock();
View Full Code Here

    {

        MockControl engineControl = newControl(IEngine.class);
        IEngine engine = (IEngine) engineControl.getMock();

        ObjectPool pool = (ObjectPool) newMock(ObjectPool.class);

        // Training

        engine.getLocale();
        engineControl.setReturnValue(Locale.KOREAN);

        pool.store(Locale.KOREAN, engine);

        replayControls();

        EngineManagerImpl m = new EngineManagerImpl();
View Full Code Here

        MockControl extractorControl = newControl(RequestLocaleManager.class);
        RequestLocaleManager extractor = (RequestLocaleManager) extractorControl.getMock();

        MockControl poolControl = newControl(ObjectPool.class);
        ObjectPool pool = (ObjectPool) poolControl.getMock();

        // Training

        extractor.extractLocaleForCurrentRequest();
        extractorControl.setReturnValue(Locale.CHINESE);

        IEngine engine = (IEngine) newMock(IEngine.class);

        pool.get(Locale.CHINESE);
        poolControl.setReturnValue(engine);

        replayControls();

        EngineManagerImpl m = new EngineManagerImpl();
View Full Code Here

        MockControl extractorControl = newControl(RequestLocaleManager.class);
        RequestLocaleManager extractor = (RequestLocaleManager) extractorControl.getMock();

        MockControl poolControl = newControl(ObjectPool.class);
        ObjectPool pool = (ObjectPool) poolControl.getMock();

        // Training

        extractor.extractLocaleForCurrentRequest();
        extractorControl.setReturnValue(Locale.CHINESE);

        IEngine engine = (IEngine) newMock(IEngine.class);

        pool.get(Locale.CHINESE);
        poolControl.setReturnValue(null);

        MockControl factoryControl = newControl(EngineFactory.class);
        EngineFactory factory = (EngineFactory) factoryControl.getMock();
View Full Code Here

    {

        MockControl engineControl = newControl(IEngine.class);
        IEngine engine = (IEngine) engineControl.getMock();

        ObjectPool pool = (ObjectPool) newMock(ObjectPool.class);

        // Training

        engine.getLocale();
        engineControl.setReturnValue(Locale.KOREAN);

        pool.store(Locale.KOREAN, engine);

        replayControls();

        EngineManagerImpl m = new EngineManagerImpl();
View Full Code Here

{
    public void testStoreAndGet()
    {
        String key = "POOLED-KEY";
        String pooled = "POOLED";
        ObjectPool p = new ObjectPoolImpl();

        assertNull(p.get(key));

        p.store(key, pooled);

        assertSame(pooled, p.get(key));

        assertNull(p.get(key));
    }
View Full Code Here

        assertNull(p.get(key));
    }

    public void testStoreMany()
    {
        ObjectPool p = new ObjectPoolImpl();

        Object pooled1 = new Object();
        Object pooled2 = new Object();

        String key = "POOLED-KEY";

        p.store(key, pooled1);
        p.store(key, pooled2);

        // No guarantee that we'll get them out in the order they were put in.

        List l = new ArrayList();
        l.add(pooled1);
        l.add(pooled2);

        for (int i = 0; i < 2; i++)
        {
            Object pooled = p.get(key);

            assertTrue(l.remove(pooled));
        }

        assertNull(p.get(key));
    }
View Full Code Here

TOP

Related Classes of org.apache.tapestry.services.ObjectPool

Copyright © 2018 www.massapicom. 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.