Package ognl

Examples of ognl.PropertyAccessor


     * {@link TilesContextPropertyAccessorDelegateFactory#getPropertyAccessor(String, TilesRequestContext)}
     * .
     */
    @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);
        TilesRequestContext request = createMock(TilesRequestContext.class);
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("attribute", 1);
        Map<String, Object> emptyMap = new HashMap<String, Object>();
        expect(request.getRequestScope()).andReturn(emptyMap);
View Full Code Here


     * {@link TilesContextPropertyAccessorDelegateFactory#getPropertyAccessor(String, TilesRequestContext)}
     * .
     */
    @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);
        TilesRequestContext request = createMock(TilesRequestContext.class);
        TilesApplicationContext applicationContext = createMock(TilesApplicationContext.class);
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("attribute", 1);
        Map<String, Object> emptyMap = new HashMap<String, Object>();
View Full Code Here

     * {@link TilesContextPropertyAccessorDelegateFactory#getPropertyAccessor(String, TilesRequestContext)}
     * .
     */
    @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);
        TilesRequestContext request = createMock(TilesRequestContext.class);
        TilesApplicationContext applicationContext = createMock(TilesApplicationContext.class);
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("anotherAttribute", 1);
        Map<String, Object> emptyMap = new HashMap<String, Object>();
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

                        //thereafter
                       
                        Object propVal=OgnlRuntime.getProperty(ogContext, object, string);
                        //use the Collection property accessor instead of the individual property accessor, because
                        //in the case of Lists otherwise the index property could be used
                        PropertyAccessor accessor=OgnlRuntime.getPropertyAccessor(Collection.class);
                        ReflectionContextState.setGettingByKeyProperty(ogContext,true);
                        return accessor.getProperty(ogContext,propVal,objects[0]);
                    }
              }
            }  catch (Exception oe) {
                //this exception should theoretically never happen
                //log it
View Full Code Here

        Set<String> names = container.getInstanceNames(PropertyAccessor.class);
        for (String name : names) {
            Class cls = Class.forName(name);
            if (cls != null) {
                if (Map.class.isAssignableFrom(cls)) {
                    PropertyAccessor acc = container.getInstance(PropertyAccessor.class, name);
                }
                OgnlRuntime.setPropertyAccessor(cls, container.getInstance(PropertyAccessor.class, name));
                if (compoundRootAccessor == null && CompoundRoot.class.isAssignableFrom(cls)) {
                    compoundRootAccessor = (CompoundRootAccessor) container.getInstance(PropertyAccessor.class, name);
                }
View Full Code Here

     */
    @SuppressWarnings("unchecked")
    @Test
    public void testGetProperty() throws OgnlException {
        NestedObjectExtractor<Integer> nestedObjectExtractor = createMock(NestedObjectExtractor.class);
        PropertyAccessor propertyAccessor = createMock(PropertyAccessor.class);
        Map<String, Object> context = createMock(Map.class);
        expect(propertyAccessor.getProperty(context, "nested", "property")).andReturn("value");
        expect(nestedObjectExtractor.getNestedObject(1)).andReturn("nested");

        replay(nestedObjectExtractor, propertyAccessor, context);
        PropertyAccessor accessor = new NestedObjectDelegatePropertyAccessor<Integer>(
                nestedObjectExtractor, propertyAccessor);
        assertEquals("value", accessor.getProperty(context, 1, "property"));
        verify(nestedObjectExtractor, propertyAccessor, context);
    }
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.