Package ognl

Examples of ognl.PropertyAccessor


     * {@link TilesContextPropertyAccessorDelegateFactory#getPropertyAccessor(String, Request)}
     * .
     */
    @Test
    public void testGetPropertyAccessorSessionScope() {
        PropertyAccessor objectPropertyAccessor = createMock(PropertyAccessor.class);
        PropertyAccessor applicationContextPropertyAccessor = createMock(PropertyAccessor.class);
        PropertyAccessor requestScopePropertyAccessor = createMock(PropertyAccessor.class);
        PropertyAccessor sessionScopePropertyAccessor = createMock(PropertyAccessor.class);
        PropertyAccessor applicationScopePropertyAccessor = createMock(PropertyAccessor.class);
        Request request = createMock(Request.class);
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("attribute", 1);

        replay(objectPropertyAccessor, applicationContextPropertyAccessor, requestScopePropertyAccessor,
View Full Code Here


     * {@link TilesContextPropertyAccessorDelegateFactory#getPropertyAccessor(String, Request)}
     * .
     */
    @Test
    public void testGetPropertyAccessorApplicationScope() {
        PropertyAccessor objectPropertyAccessor = createMock(PropertyAccessor.class);
        PropertyAccessor applicationContextPropertyAccessor = createMock(PropertyAccessor.class);
        PropertyAccessor requestScopePropertyAccessor = createMock(PropertyAccessor.class);
        PropertyAccessor sessionScopePropertyAccessor = createMock(PropertyAccessor.class);
        PropertyAccessor applicationScopePropertyAccessor = createMock(PropertyAccessor.class);
        Request request = createMock(Request.class);
        ApplicationContext applicationContext = createMock(ApplicationContext.class);
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("attribute", 1);

View Full Code Here

     * {@link TilesContextPropertyAccessorDelegateFactory#getPropertyAccessor(String, Request)}
     * .
     */
    @Test
    public void testGetPropertyAccessorRequestScopeDefault() {
        PropertyAccessor objectPropertyAccessor = createMock(PropertyAccessor.class);
        PropertyAccessor applicationContextPropertyAccessor = createMock(PropertyAccessor.class);
        PropertyAccessor requestScopePropertyAccessor = createMock(PropertyAccessor.class);
        PropertyAccessor sessionScopePropertyAccessor = createMock(PropertyAccessor.class);
        PropertyAccessor applicationScopePropertyAccessor = createMock(PropertyAccessor.class);
        Request request = createMock(Request.class);
        ApplicationContext applicationContext = createMock(ApplicationContext.class);
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("anotherAttribute", 1);

View Full Code Here

     */
    @SuppressWarnings("unchecked")
    @Test
    public void testGetProperty() throws OgnlException {
        PropertyAccessorDelegateFactory<Integer> factory = createMock(PropertyAccessorDelegateFactory.class);
        PropertyAccessor mockAccessor = createMock(PropertyAccessor.class);
        Map<String, Object> context = createMock(Map.class);
        expect(factory.getPropertyAccessor("property", 1)).andReturn(mockAccessor);
        expect(mockAccessor.getProperty(context, 1, "property")).andReturn("value");

        replay(factory, mockAccessor, context);
        PropertyAccessor accessor = new DelegatePropertyAccessor<Integer>(factory);
        assertEquals("value", accessor.getProperty(context, 1, "property"));
        verify(factory, mockAccessor, context);
    }
View Full Code Here

     */
    @SuppressWarnings("unchecked")
    @Test
    public void testSetProperty() throws OgnlException {
        PropertyAccessorDelegateFactory<Integer> factory = createMock(PropertyAccessorDelegateFactory.class);
        PropertyAccessor mockAccessor = createMock(PropertyAccessor.class);
        Map<String, Object> context = createMock(Map.class);
        expect(factory.getPropertyAccessor("property", 1)).andReturn(mockAccessor);
        mockAccessor.setProperty(context, 1, "property", "value");

        replay(factory, mockAccessor, context);
        PropertyAccessor accessor = new DelegatePropertyAccessor<Integer>(factory);
        accessor.setProperty(context, 1, "property", "value");
        verify(factory, mockAccessor, context);
    }
View Full Code Here

     */
    @SuppressWarnings("unchecked")
    @Test
    public void testGetSourceAccessor() {
        PropertyAccessorDelegateFactory<Integer> factory = createMock(PropertyAccessorDelegateFactory.class);
        PropertyAccessor mockAccessor = createMock(PropertyAccessor.class);
        OgnlContext context = createMock(OgnlContext.class);
        expect(factory.getPropertyAccessor("property", 1)).andReturn(mockAccessor);
        expect(mockAccessor.getSourceAccessor(context, 1, "property")).andReturn("method");

        replay(factory, mockAccessor, context);
        PropertyAccessor accessor = new DelegatePropertyAccessor<Integer>(factory);
        assertEquals("method", accessor.getSourceAccessor(context, 1, "property"));
        verify(factory, mockAccessor, context);
    }
View Full Code Here

     */
    @SuppressWarnings("unchecked")
    @Test
    public void testGetSourceSetter() {
        PropertyAccessorDelegateFactory<Integer> factory = createMock(PropertyAccessorDelegateFactory.class);
        PropertyAccessor mockAccessor = createMock(PropertyAccessor.class);
        OgnlContext context = createMock(OgnlContext.class);
        expect(factory.getPropertyAccessor("property", 1)).andReturn(mockAccessor);
        expect(mockAccessor.getSourceSetter(context, 1, "property")).andReturn("method");

        replay(factory, mockAccessor, context);
        PropertyAccessor accessor = new DelegatePropertyAccessor<Integer>(factory);
        assertEquals("method", accessor.getSourceSetter(context, 1, "property"));
        verify(factory, mockAccessor, context);
    }
View Full Code Here

    }

    /** {@inheritDoc} */
    public PropertyAccessor getPropertyAccessor(String propertyName,
            TilesRequestContext request) {
        PropertyAccessor retValue;
        if (beanInfo.getMappedDescriptors(TilesRequestContext.class)
                .containsKey(propertyName)) {
            retValue = objectPropertyAccessor;
        } else if (beanInfo.getMappedDescriptors(TilesApplicationContext.class)
                .containsKey(propertyName)) {
View Full Code Here

     *
     * @return The OGNL evaluator.
     */
    private OGNLAttributeEvaluator createOGNLEvaluator() {
        try {
            PropertyAccessor objectPropertyAccessor = OgnlRuntime.getPropertyAccessor(Object.class);
            PropertyAccessor mapPropertyAccessor = OgnlRuntime.getPropertyAccessor(Map.class);
            PropertyAccessor applicationContextPropertyAccessor =
                new NestedObjectDelegatePropertyAccessor<TilesRequestContext>(
                    new TilesApplicationContextNestedObjectExtractor(),
                    objectPropertyAccessor);
            PropertyAccessor requestScopePropertyAccessor =
                new NestedObjectDelegatePropertyAccessor<TilesRequestContext>(
                    new RequestScopeNestedObjectExtractor(), mapPropertyAccessor);
            PropertyAccessor sessionScopePropertyAccessor =
                new NestedObjectDelegatePropertyAccessor<TilesRequestContext>(
                    new SessionScopeNestedObjectExtractor(), mapPropertyAccessor);
            PropertyAccessor applicationScopePropertyAccessor =
                new NestedObjectDelegatePropertyAccessor<TilesRequestContext>(
                    new ApplicationScopeNestedObjectExtractor(), mapPropertyAccessor);
            PropertyAccessorDelegateFactory<TilesRequestContext> factory =
                new TilesContextPropertyAccessorDelegateFactory(
                    objectPropertyAccessor, applicationContextPropertyAccessor,
                    requestScopePropertyAccessor, sessionScopePropertyAccessor,
                    applicationScopePropertyAccessor);
            PropertyAccessor tilesRequestAccessor = new DelegatePropertyAccessor<TilesRequestContext>(factory);
            OgnlRuntime.setPropertyAccessor(TilesRequestContext.class, tilesRequestAccessor);
            return new OGNLAttributeEvaluator();
        } catch (OgnlException e) {
            throw new TilesContainerFactoryException(
                    "Cannot initialize OGNL evaluator", e);
View Full Code Here

    }

    /** {@inheritDoc} */
    public PropertyAccessor getPropertyAccessor(String propertyName,
            TilesRequestContext request) {
        PropertyAccessor retValue;
        if (beanInfo.getMappedDescriptors(TilesRequestContext.class)
                .containsKey(propertyName)) {
            retValue = objectPropertyAccessor;
        } else if (beanInfo.getMappedDescriptors(TilesApplicationContext.class)
                .containsKey(propertyName)) {
View Full Code Here

TOP

Related Classes of ognl.PropertyAccessor

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.