Package org.apache.tapestry5.ioc.util

Examples of org.apache.tapestry5.ioc.util.IdAllocator


        linker.setInitialization(InitializationPriority.NORMAL, new JSONObject(
                "{ 'evalScript' : [ 'doSomething();' ] }"));

        replay();

        JavaScriptSupportImpl jss = new JavaScriptSupportImpl(linker, null, null, new IdAllocator(), true);

        jss.addScript("doSomething();");

        jss.commit();
View Full Code Here


        linker.setInitialization(InitializationPriority.NORMAL, new JSONObject(
                "{ 'evalScript' : [ 'doSomething();' ] }"));

        replay();

        JavaScriptSupportImpl jss = new JavaScriptSupportImpl(linker, null, null, new IdAllocator(), true);

        jss.addScript("doSomething();");

        jss.commit();
View Full Code Here

{

    @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

            {
                String uid = Long.toHexString(System.currentTimeMillis());

                String namespace = "_" + uid;

                IdAllocator idAllocator = new IdAllocator(namespace);

                DocumentLinker linker = environment.peekRequired(DocumentLinker.class);

                JavaScriptSupportImpl support = new JavaScriptSupportImpl(linker, javascriptStackSource,
                        javascriptStackPathConstructor, idAllocator, true);
View Full Code Here

        clientId = javascriptSupport.allocateClientId(resources);

        // Pre-register some names, to prevent client-side collisions with function names
        // attached to the JS Form object.

        IdAllocator allocator = new IdAllocator();

        preallocateNames(allocator);

        formSupport = createRenderTimeFormSupport(clientId, actionSink, allocator);
View Full Code Here

TOP

Related Classes of org.apache.tapestry5.ioc.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.