Package org.apache.tapestry.ioc.internal.util

Examples of org.apache.tapestry.ioc.internal.util.IdAllocator


{

    @Test
    public void simple()
    {
        IdAllocator a = new IdAllocator();
        List<String> ids = newList();

        assertFalse(a.isAllocated("name"));

        assertEquals(a.allocateId("name"), "name");
        assertTrue(a.isAllocated("name"));

        ids.add("name");

        for (int i = 0; i < 10; i++)
        {

            String expected = "name_" + i;

            assertFalse(a.isAllocated(expected));

            String nextId = a.allocateId("name");

            assertTrue(a.isAllocated(expected));

            assertEquals(nextId, expected);

            ids.add(nextId);
        }

        assertEquals(a.getAllocatedIds(), ids);
    }
View Full Code Here


    }

    @Test
    public void simple_with_namespace()
    {
        IdAllocator a = new IdAllocator("_NS");

        assertEquals(a.allocateId("name"), "name_NS");

        for (int i = 0; i < 10; i++)
            assertEquals(a.allocateId("name"), "name_NS_" + i);

        // This is current behavior, but is probably something
        // that could be improved.

        assertEquals(a.allocateId("foo_NS"), "foo_NS_NS");
        assertEquals(a.allocateId("foo_NS"), "foo_NS_NS_0");
    }
View Full Code Here

    }

    @Test
    public void degenerate()
    {
        IdAllocator a = new IdAllocator();

        assertEquals(a.allocateId("d_1"), "d_1");

        assertEquals(a.allocateId("d"), "d");
        assertEquals(a.allocateId("d"), "d_0");
        assertEquals(a.allocateId("d"), "d_2");

        assertEquals(a.allocateId("d"), "d_3");
        assertEquals(a.allocateId("d_1"), "d_1_0");
    }
View Full Code Here

    }

    @Test
    public void degenerate_with_namespace()
    {
        IdAllocator a = new IdAllocator("_NS");

        assertEquals(a.allocateId("d_1"), "d_1_NS");

        assertEquals(a.allocateId("d"), "d_NS");
        assertEquals(a.allocateId("d"), "d_NS_0");
        assertEquals(a.allocateId("d"), "d_NS_1");
        assertEquals(a.allocateId("d"), "d_NS_2");
        assertEquals(a.allocateId("d"), "d_NS_3");

        assertEquals(a.allocateId("d_1"), "d_1_NS_0");

        // This is very degenerate, and maybe something that needs fixing.

        assertEquals(a.allocateId("d_1_NS"), "d_1_NS_NS");
    }
View Full Code Here

    }

    @Test
    public void clear()
    {
        IdAllocator a = new IdAllocator();

        assertEquals(a.allocateId("foo"), "foo");
        assertEquals(a.allocateId("foo_0"), "foo_0");

        a.clear();

        assertEquals(a.allocateId("foo"), "foo");
        assertEquals(a.allocateId("foo_0"), "foo_0");
    }
View Full Code Here

    }

    @Test
    public void clone_test()
    {
        IdAllocator a = new IdAllocator();

        assertEquals(a.allocateId("foo"), "foo");
        assertEquals(a.allocateId("foo_0"), "foo_0");
        assertEquals(a.allocateId("foo"), "foo_1");

        IdAllocator b = a.clone();

        // After making a clone, parallel operations should return the same results.
        // If anything under the covers was shared, then parallel operations would
        // interfere with each other.

        assertEquals(b.allocateId("bar"), a.allocateId("bar"));
        assertEquals(b.allocateId("foo"), a.allocateId("foo"));
        assertEquals(b.allocateId("foo_0"), a.allocateId("foo_0"));

    }
View Full Code Here

        _classPool = _ctClass.getClassPool();
        _classFactory = classFactory;
        _parentTransformation = null;
        _componentModel = componentModel;

        _idAllocator = new IdAllocator();

        _logger = logger;

        preloadMemberNames();
View Full Code Here

        _classPool = _ctClass.getClassPool();
        _loader = loader;
        _parentTransformation = null;
        _componentModel = componentModel;

        _idAllocator = new IdAllocator();

        _log = log;

        preloadMemberNames();
View Full Code Here

        _classPool = _ctClass.getClassPool();
        _classFactory = classFactory;
        _parentTransformation = null;
        _componentModel = componentModel;

        _idAllocator = new IdAllocator();

        _logger = logger;

        preloadMemberNames();
View Full Code Here

TOP

Related Classes of org.apache.tapestry.ioc.internal.util.IdAllocator

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.