Package org.mojavemvc.core

Examples of org.mojavemvc.core.BaseActionSignature


public class TestBaseActionSignature {
   
    @Test
    public void noParameters() {

        ActionSignature sig = new BaseActionSignature(1, "testAction", new Class[] {},
                new Annotation[][] {}, new Annotation[]{});

        assertEquals(0, sig.parameterTypes().length);
        assertEquals(0, sig.getArgs(new HashMap<String, Object>(), null).length);
    }
View Full Code Here


    }

    @Test
    public void getArgsWithStringArrayParameters() {

        ActionSignature sig = new BaseActionSignature(1, "testAction", new Class[] { String.class, Integer.class,
                Double.class, Date.class, Long.class, InputStream.class },
                new Annotation[][] { { createParam("p1") }, { createParam("p2") },
                { createParam("p3") }, { createParam("p4") }, { createParam("p5") }, { createResource() } },
                new Annotation[]{});

        InputStream in = Mockito.mock(InputStream.class);
       
        Map<String, String[]> parameterMap = new HashMap<String, String[]>();
        parameterMap.put("p1", new String[] { "hello" });
        parameterMap.put("p2", new String[] { "123" });
        parameterMap.put("p3", new String[] { "1.23" });
        parameterMap.put("p4", new String[] { "2011-03-01" });
        parameterMap.put("p5", new String[] { "123456" });

        Class<?>[] paramTypes = sig.parameterTypes();
        assertEquals(6, paramTypes.length);
        assertEquals(String.class, paramTypes[0]);
        assertEquals(Integer.class, paramTypes[1]);
        assertEquals(Double.class, paramTypes[2]);
        assertEquals(Date.class, paramTypes[3]);
        assertEquals(Long.class, paramTypes[4]);
        assertEquals(InputStream.class, paramTypes[5]);
       
        Object[] args = sig.getArgs(parameterMap, in);
        assertEquals(6, args.length);
        assertEquals("hello", args[0]);
        assertEquals(123, args[1]);
        assertEquals(1.23, args[2]);
        assertEquals(Date.valueOf("2011-03-01"), args[3]);
View Full Code Here

    }

    @Test
    public void getArgsWithObjectParameters() {

        ActionSignature sig = new BaseActionSignature(1, "testAction", new Class[] { String.class, Integer.class,
                Double.class, Date.class, SomeUserDefinedType.class, Long.class }, new Annotation[][] { { createParam("p1") },
                { createParam("p2") }, { createParam("p3") }, { createParam("p4") }, { createParam("p5") },
                { createParam("p6") } }, new Annotation[]{});

        SomeUserDefinedType userDefinedType = new SomeUserDefinedType();

        Map<String, Object> parameterMap = new HashMap<String, Object>();
        parameterMap.put("p1", "hello");
        parameterMap.put("p2", 123);
        parameterMap.put("p3", 1.23);
        parameterMap.put("p4", Date.valueOf("2011-03-01"));
        parameterMap.put("p5", userDefinedType);
        parameterMap.put("p6", 123456L);

        Class<?>[] paramTypes = sig.parameterTypes();
        assertEquals(6, paramTypes.length);
        assertEquals(String.class, paramTypes[0]);
        assertEquals(Integer.class, paramTypes[1]);
        assertEquals(Double.class, paramTypes[2]);
        assertEquals(Date.class, paramTypes[3]);
        assertEquals(SomeUserDefinedType.class, paramTypes[4]);
        assertEquals(Long.class, paramTypes[5]);
       
        Object[] args = sig.getArgs(parameterMap, null);
        assertEquals(6, args.length);
        assertEquals("hello", args[0]);
        assertEquals(123, args[1]);
        assertEquals(1.23, args[2]);
        assertEquals(Date.valueOf("2011-03-01"), args[3]);
View Full Code Here

TOP

Related Classes of org.mojavemvc.core.BaseActionSignature

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.