Package ognl

Examples of ognl.TypeConverter


  }

  @Test
  public void shouldNotInstantiateIfLastTerm() throws OgnlException, NoSuchMethodException {
    final TypeConverter typeConverter = mock(TypeConverter.class);
    final House house = new House();
    final Mouse tom = new Mouse();
    Method method = House.class.getDeclaredMethod("setMouse", Mouse.class);
    when(typeConverter.convertValue(context, house, method,  "mouse", "22", Mouse.class)).thenReturn(tom);

    Ognl.setTypeConverter(context, typeConverter);
    Ognl.setValue("mouse", context, house, "22");
    assertThat(house.getMouse(), is(equalTo(tom)));
  }
View Full Code Here


            }

            return;
        }

        TypeConverter conv = getTypeConverterFromContext(context);
        Map contextFrom = Ognl.createDefaultContext(from);
        Ognl.setTypeConverter(contextFrom, conv);
        Map contextTo = Ognl.createDefaultContext(to);
        Ognl.setTypeConverter(contextTo, conv);
View Full Code Here

    public void test_Type_Converter() throws Exception
    {
        IApplicationSpecification as = newMock(IApplicationSpecification.class);
       
        TypeConverter tc = newMock(TypeConverter.class);

        // Training

        expect(as.checkExtension(Tapestry.OGNL_TYPE_CONVERTER)).andReturn(true);
View Full Code Here

            }

            return;
        }

        TypeConverter conv = getTypeConverterFromContext(context);
        Map contextFrom = Ognl.createDefaultContext(from);
        Ognl.setTypeConverter(contextFrom, conv);
        Map contextTo = Ognl.createDefaultContext(to);
        Ognl.setTypeConverter(contextTo, conv);
View Full Code Here

        if (_root.getPage() != null) {
            if (_root.getPage().getEngine() != null) {
                IApplicationSpecification appSpec =
                        _root.getPage().getEngine().getSpecification();
                if (appSpec != null && appSpec.checkExtension(Tapestry.OGNL_TYPE_CONVERTER)) {
                    TypeConverter typeConverter =
                            (TypeConverter) appSpec.getExtension(
                                    Tapestry.OGNL_TYPE_CONVERTER,
                                    TypeConverter.class);

                    Ognl.setTypeConverter(_context, typeConverter);
View Full Code Here

            {
                IApplicationSpecification appSpec = _root.getPage().getEngine().getSpecification();

                if (appSpec != null && appSpec.checkExtension(Tapestry.OGNL_TYPE_CONVERTER))
                {
                    TypeConverter typeConverter =
                        (TypeConverter) appSpec.getExtension(
                            Tapestry.OGNL_TYPE_CONVERTER,
                            TypeConverter.class);

                    Ognl.setTypeConverter(_context, typeConverter);
View Full Code Here

            }

            return;
        }

        TypeConverter conv = getTypeConverterFromContext(context);
        final Map contextFrom = createDefaultContext(from, null);
        Ognl.setTypeConverter(contextFrom, conv);
        final Map contextTo = createDefaultContext(to, null);
        Ognl.setTypeConverter(contextTo, conv);
View Full Code Here

    {
        MockControl asc = newControl(IApplicationSpecification.class);
        IApplicationSpecification as = (IApplicationSpecification) asc.getMock();

        MockControl tcc = newControl(TypeConverter.class);
        TypeConverter tc = (TypeConverter) tcc.getMock();

        // Training

        as.checkExtension(Tapestry.OGNL_TYPE_CONVERTER);
        asc.setReturnValue(true);

        as.getExtension(Tapestry.OGNL_TYPE_CONVERTER, TypeConverter.class);
        asc.setReturnValue(tc);

        replayControls();

        ExpressionCache cache = new ExpressionCacheImpl();

        ExpressionEvaluatorImpl ee = new ExpressionEvaluatorImpl();

        ee.setExpressionCache(cache);
        ee.setApplicationSpecification(as);
        ee.setContributions(Collections.EMPTY_LIST);

        ee.initializeService();

        verifyControls();

        Fixture f = new Fixture();

        Method m = Fixture.class.getMethod("setValue", new Class[]
        { String.class });

        Date d = new Date();

        // Training

        // Since we have no idea what OGNL will stuff into that Map parameter,
        // we just ignore it.
        tc.convertValue(null, f, m, "value", d, String.class);
        tcc.setMatcher(new NullMeansIgnoreMatcher());

        tcc.setReturnValue("FROM-TYPE-CONVERTER");

        replayControls();
View Full Code Here

            {
                IApplicationSpecification appSpec = _root.getPage().getEngine().getSpecification();

                if (appSpec != null && appSpec.checkExtension(Tapestry.OGNL_TYPE_CONVERTER))
                {
                    TypeConverter typeConverter = (TypeConverter) appSpec.getExtension(
                        Tapestry.OGNL_TYPE_CONVERTER, TypeConverter.class);

                    Ognl.setTypeConverter(_context, typeConverter);
                }
            }
View Full Code Here

TOP

Related Classes of ognl.TypeConverter

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.