Package org.apache.velocity.tools.generic

Examples of org.apache.velocity.tools.generic.Alternator


    public @Test void testAlternatorTool() {
        AlternatorTool alternatorTool = (AlternatorTool)toolbox.get("alternator");
        assertNotNull(alternatorTool);
        /* test automatic alternator */
        Alternator auto = alternatorTool.auto(new String[] {"red","blue","yellow"});
        assertStringEquals("red", auto.getCurrent());
        assertStringEquals("red", auto.getNext());
        assertStringEquals("blue", auto);
        assertStringEquals("yellow", auto);
        assertStringEquals("red", auto);
        /* test manual alternator (use 'make()' and not 'manual()' since we define the default to be manual in toolbox.xml*/
         Alternator manual = alternatorTool.make(new String[] {"red","blue","yellow"});
        assertStringEquals("red", manual);
        assertStringEquals("red", manual);
        manual.shift();
        assertStringEquals("blue", manual);
        manual.shift();
        manual.shift();
        assertStringEquals("red", manual);
    }
View Full Code Here


    public @Test void testAlternatorTool() {
        AlternatorTool alternatorTool = (AlternatorTool)toolbox.get("alternator");
        assertNotNull(alternatorTool);
        /* test automatic alternator */
        Alternator auto = alternatorTool.auto(new String[] {"red","blue","yellow"});
        assertEquals("red",auto.getCurrent());
        assertEquals("red",auto.getNext());
        assertEquals("blue",auto.toString());
        assertEquals("yellow",auto.toString());
        assertEquals("red",auto.toString());
        /* test manual alternator (use 'make()' and not 'manual()' since we define the default to be manual in toolbox.xml*/
         Alternator manual = alternatorTool.make(new String[] {"red","blue","yellow"});
        assertEquals("red",manual.toString());
        assertEquals("red",manual.toString());
        manual.shift();
        assertEquals("blue",manual.toString());
        manual.shift();
        manual.shift();
        assertEquals("red",manual.toString());
    }
View Full Code Here

    public @Test void testAlternatorTool() {
        AlternatorTool alternatorTool = (AlternatorTool)toolbox.get("alternator");
        assertNotNull(alternatorTool);
        /* test automatic alternator */
        Alternator auto = alternatorTool.auto(new String[] {"red","blue","yellow"});
        assertStringEquals("red", auto.getCurrent());
        assertStringEquals("red", auto.getNext());
        assertStringEquals("blue", auto);
        assertStringEquals("yellow", auto);
        assertStringEquals("red", auto);
        /* test manual alternator (use 'make()' and not 'manual()' since we define the default to be manual in toolbox.xml*/
         Alternator manual = alternatorTool.make(new String[] {"red","blue","yellow"});
        assertStringEquals("red", manual);
        assertStringEquals("red", manual);
        manual.shift();
        assertStringEquals("blue", manual);
        manual.shift();
        manual.shift();
        assertStringEquals("red", manual);
    }
View Full Code Here

    public @Test void methodMake_ObjectVarArgs() throws Exception
    {
        AlternatorTool tool = new AlternatorTool();
        assertNull(tool.make());
        Alternator result = tool.make(new Object[] { true });
        assertTrue((Boolean)result.getNext());
        assertTrue((Boolean)result.getNext());
        result = tool.make("hi", true, false, 0);
        assertEquals("hi", result.getNext());
        assertTrue((Boolean)result.getNext());
        assertFalse((Boolean)result.getNext());
        assertEquals(0, result.getNext());
        assertEquals("hi", result.getNext());
        result = tool.make(new Object[] { "red", "blue" });
        result.shift();
        assertEquals("blue", result.toString());
    }
View Full Code Here

    }

    public @Test void methodMake_booleanObjectVarArgs() throws Exception
    {
        AlternatorTool tool = new AlternatorTool();
        Alternator result = tool.make(false, new Object[] { "red", "blue" });
        assertEquals("red", result.toString());
        assertEquals("red", result.toString());
        result.shift();
        assertEquals("blue", result.toString());
    }
View Full Code Here

    }

    public @Test void methodAuto_ObjectVarArgs() throws Exception
    {
        AlternatorTool tool = new AlternatorTool();
        Alternator result = tool.auto(-1,0,null,1);
        assertEquals("-1", result.toString());
        assertEquals(0, result.getCurrent());
        assertEquals("0", result.toString());
        assertEquals(null, result.toString());
        assertEquals("1", result.toString());
        assertEquals("-1", result.toString());
    }
View Full Code Here

    }

    public @Test void methodManual_ObjectVarArgs() throws Exception
    {
        AlternatorTool tool = new AlternatorTool();
        Alternator result = tool.manual(new Object[] { true, false });
        assertTrue((Boolean)result.getCurrent());
        assertEquals("true", result.toString());
        assertTrue((Boolean)result.getNext());
        assertEquals("false", result.toString());
        assertFalse((Boolean)result.getNext());
        assertEquals("true", result.toString());
    }
View Full Code Here

TOP

Related Classes of org.apache.velocity.tools.generic.Alternator

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.