Examples of ValueStack


Examples of com.opensymphony.xwork2.util.ValueStack

        assertEquals(value, conversionErrors.get("date"));
    }

    public void testFieldErrorMessageAddedWhenConversionFailsOnModelDriven() {
        ModelDrivenAnnotationAction action = new ModelDrivenAnnotationAction();
        ValueStack stack = ActionContext.getContext().getValueStack();
        stack.push(action);
        stack.push(action.getModel());

        Map<String, Object> ognlStackContext = stack.getContext();
        ognlStackContext.put(XWorkConverter.REPORT_CONVERSION_ERRORS, Boolean.TRUE);

        String[] value = new String[]{"invalid date"};
        assertEquals("Conversion should have failed.", OgnlRuntime.NoConversionPossible, converter.convertValue(ognlStackContext, action, null, "birth", value, Date.class));
        stack.pop();
        stack.pop();

        Map conversionErrors = (Map) ognlStackContext.get(ActionContext.CONVERSION_ERRORS);
        assertNotNull(conversionErrors);
        assertEquals(1, conversionErrors.size());
        assertNotNull(conversionErrors.get("birth"));
View Full Code Here

Examples of com.opensymphony.xwork2.util.ValueStack

        assertEquals(value, conversionErrors.get("birth"));
    }

    public void testFindConversionErrorMessage() {
        ModelDrivenAnnotationAction action = new ModelDrivenAnnotationAction();
        ValueStack stack = ActionContext.getContext().getValueStack();
        stack.push(action);
        stack.push(action.getModel());

        String message = XWorkConverter.getConversionErrorMessage("birth", stack);
        assertNotNull(message);
        assertEquals("Invalid date for birth.", message);
View Full Code Here

Examples of com.opensymphony.xwork2.util.ValueStack

        assertEquals("Invalid field value for field \"foo\".", message);
    }

    public void testFindConversionMappingForInterface() {
        ModelDrivenAnnotationAction2 action = new ModelDrivenAnnotationAction2();
        ValueStack stack = ActionContext.getContext().getValueStack();
        stack.push(action);
        stack.push(action.getModel());

        Map<String, Object> ognlStackContext = stack.getContext();
        ognlStackContext.put(XWorkConverter.REPORT_CONVERSION_ERRORS, Boolean.TRUE);

        String value = "asdf:123";
        Object o = converter.convertValue(ognlStackContext, action.getModel(), null, "barObj", value, Bar.class);
        assertNotNull(o);
View Full Code Here

Examples of com.opensymphony.xwork2.util.ValueStack

        }, Set.class));
    }

    // TODO: Fixme... This test does not work with GenericsObjectDeterminer!
    public void testStringToCollectionConversion() {
        ValueStack stack = ActionContext.getContext().getValueStack();
        Map<String, Object> stackContext = stack.getContext();
        stackContext.put(ReflectionContextState.CREATE_NULL_OBJECTS, Boolean.TRUE);
        stackContext.put(ReflectionContextState.DENY_METHOD_EXECUTION, Boolean.TRUE);
        stackContext.put(XWorkConverter.REPORT_CONVERSION_ERRORS, Boolean.TRUE);

        AnnotationUser user = new AnnotationUser();
        stack.push(user);

        stack.setValue("list", "asdf");
        assertNotNull(user.getList());
        assertEquals(1, user.getList().size());
        assertEquals(String.class, user.getList().get(0).getClass());
        assertEquals("asdf", user.getList().get(0));
    }
View Full Code Here

Examples of com.opensymphony.xwork2.util.ValueStack

        assertEquals(new BigDecimal(123.5), converter.convertValue(context, null, null, null, "123.5", BigDecimal.class));
        assertEquals(new BigInteger("123"), converter.convertValue(context, null, null, null, "123", BigInteger.class));
    }

    public void testValueStackWithTypeParameter() {
        ValueStack stack = ActionContext.getContext().getValueStack();
        stack.push(new Foo1());
        Bar1 bar = (Bar1) stack.findValue("bar", Bar1.class);
        assertNotNull(bar);
    }
View Full Code Here

Examples of com.opensymphony.xwork2.util.ValueStack

        assertNotNull(bar);
    }

    public void testGenericProperties() {
        GenericsBean gb = new GenericsBean();
        ValueStack stack = ac.getValueStack();
        stack.push(gb);

        String[] value = new String[] {"123.12", "123.45"};
        stack.setValue("doubles", value);
        assertEquals(2, gb.getDoubles().size());
        assertEquals(Double.class, gb.getDoubles().get(0).getClass());
        assertEquals(new Double(123.12), gb.getDoubles().get(0));
        assertEquals(new Double(123.45), gb.getDoubles().get(1));
    }
View Full Code Here

Examples of com.opensymphony.xwork2.util.ValueStack

        assertEquals(new Double(123.45), gb.getDoubles().get(1));
    }

    public void testGenericPropertiesFromField() {
        GenericsBean gb = new GenericsBean();
        ValueStack stack = ac.getValueStack();
        stack.push(gb);

        stack.setValue("genericMap[123.12]", "66");
        stack.setValue("genericMap[456.12]", "42");

        assertEquals(2, gb.getGenericMap().size());
        assertEquals(Integer.class, stack.findValue("genericMap.get(123.12).class"));
        assertEquals(Integer.class, stack.findValue("genericMap.get(456.12).class"));
        assertEquals(66, stack.findValue("genericMap.get(123.12)"));
        assertEquals(42, stack.findValue("genericMap.get(456.12)"));
        assertEquals(true, stack.findValue("genericMap.containsValue(66)"));
        assertEquals(true, stack.findValue("genericMap.containsValue(42)"));
        assertEquals(true, stack.findValue("genericMap.containsKey(123.12)"));
        assertEquals(true, stack.findValue("genericMap.containsKey(456.12)"));
    }
View Full Code Here

Examples of com.opensymphony.xwork2.util.ValueStack

        assertEquals(true, stack.findValue("genericMap.containsKey(456.12)"));
    }

    public void testGenericPropertiesFromSetter() {
        GenericsBean gb = new GenericsBean();
        ValueStack stack = ac.getValueStack();
        stack.push(gb);

        stack.setValue("genericMap[123.12]", "66");
        stack.setValue("genericMap[456.12]", "42");

        assertEquals(2, gb.getGenericMap().size());
        assertEquals(Integer.class, stack.findValue("genericMap.get(123.12).class"));
        assertEquals(Integer.class, stack.findValue("genericMap.get(456.12).class"));
        assertEquals(66, stack.findValue("genericMap.get(123.12)"));
        assertEquals(42, stack.findValue("genericMap.get(456.12)"));
        assertEquals(true, stack.findValue("genericMap.containsValue(66)"));
        assertEquals(true, stack.findValue("genericMap.containsValue(42)"));
        assertEquals(true, stack.findValue("genericMap.containsKey(123.12)"));
        assertEquals(true, stack.findValue("genericMap.containsKey(456.12)"));
    }
View Full Code Here

Examples of com.opensymphony.xwork2.util.ValueStack

        assertEquals(true, stack.findValue("genericMap.containsKey(456.12)"));
    }

    public void testGenericPropertiesFromGetter() {
        GenericsBean gb = new GenericsBean();
        ValueStack stack = ac.getValueStack();
        stack.push(gb);

        assertEquals(1, gb.getGetterList().size());
        assertEquals(Double.class, stack.findValue("getterList.get(0).class"));
        assertEquals(new Double(42.42), stack.findValue("getterList.get(0)"));
        assertEquals(new Double(42.42), gb.getGetterList().get(0));

    }
View Full Code Here

Examples of com.opensymphony.xwork2.util.ValueStack


    // FIXME: Implement nested Generics such as: List of Generics List, Map of Generic keys/values, etc...
    public void no_testGenericPropertiesWithNestedGenerics() {
        GenericsBean gb = new GenericsBean();
        ValueStack stack = ac.getValueStack();
        stack.push(gb);

        stack.setValue("extendedMap[123.12]", new String[] {"1", "2", "3", "4"});
        stack.setValue("extendedMap[456.12]", new String[] {"5", "6", "7", "8", "9"});

        System.out.println("gb.getExtendedMap(): " + gb.getExtendedMap());

        assertEquals(2, gb.getExtendedMap().size());
        System.out.println(stack.findValue("extendedMap"));
        assertEquals(4, stack.findValue("extendedMap.get(123.12).size"));
        assertEquals(5, stack.findValue("extendedMap.get(456.12).size"));

        assertEquals("1", stack.findValue("extendedMap.get(123.12).get(0)"));
        assertEquals("5", stack.findValue("extendedMap.get(456.12).get(0)"));
        assertEquals(Integer.class, stack.findValue("extendedMap.get(123.12).get(0).class"));
        assertEquals(Integer.class, stack.findValue("extendedMap.get(456.12).get(0).class"));

        assertEquals(List.class, stack.findValue("extendedMap.get(123.12).class"));
        assertEquals(List.class, stack.findValue("extendedMap.get(456.12).class"));

    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.