Package com.gemstone.gemfire.cache.execute

Examples of com.gemstone.gemfire.cache.execute.RegionFunctionContext


        assertEquals("test", args[0]);
    }

    @Test
    public void testMethodWithNoSpecialArgs() throws SecurityException, NoSuchMethodException {
        RegionFunctionContext functionContext = mock(RegionFunctionContext.class);

        Method method = TestFunction.class.getDeclaredMethod("methodWithNoSpecialArgs", String.class, int.class,
                boolean.class);
        FunctionArgumentResolver far = new FunctionContextInjectingArgumentResolver(method);

        Object[] originalArgs = new Object[]{"hello", 0, false};
        when(functionContext.getArguments()).thenReturn(originalArgs);

        Object[] args = far.resolveFunctionArguments(functionContext);

        assertEquals(originalArgs.length, args.length);
View Full Code Here


        }
    }

    @Test
    public void testMethodWithRegionType() throws SecurityException, NoSuchMethodException {
        RegionFunctionContext functionContext = mock(RegionFunctionContext.class);
        @SuppressWarnings("unchecked")
        Region<Object, Object> region = mock(Region.class);

        Method method = TestFunction.class.getDeclaredMethod("methodWithRegionType", String.class, Region.class);
        FunctionArgumentResolver far = new FunctionContextInjectingArgumentResolver(method);

        Object[] originalArgs = new Object[]{"hello"};
        when(functionContext.getArguments()).thenReturn(originalArgs);
        when(functionContext.getDataSet()).thenReturn(region);

        Object[] args = far.resolveFunctionArguments(functionContext);

        assertEquals(originalArgs.length + 1, args.length);
View Full Code Here

        }
    }

    @Test
    public void testMethodWithOneArgRegionType() throws SecurityException, NoSuchMethodException {
        RegionFunctionContext functionContext = mock(RegionFunctionContext.class);
        @SuppressWarnings("unchecked")
        Region<Object, Object> region = mock(Region.class);

        Method method = TestFunction.class.getDeclaredMethod("methodWithOneArgRegionType", Region.class);
        FunctionArgumentResolver far = new FunctionContextInjectingArgumentResolver(method);

        Object[] originalArgs = new Object[]{};
        when(functionContext.getArguments()).thenReturn(originalArgs);
        when(functionContext.getDataSet()).thenReturn(region);

        Object[] args = far.resolveFunctionArguments(functionContext);

        assertEquals(1, args.length);
        assertSame(region, args[0]);
View Full Code Here

        assertSame(region, args[0]);
    }

    @Test
    public void testMethodWithAnnotatedRegion() throws SecurityException, NoSuchMethodException {
        RegionFunctionContext functionContext = mock(RegionFunctionContext.class);
        @SuppressWarnings("unchecked")
        Region<Object, Object> region = mock(Region.class);

        Method method = TestFunction.class.getDeclaredMethod("methodWithAnnotatedRegion", Region.class, String.class);
        FunctionArgumentResolver far = new FunctionContextInjectingArgumentResolver(method);

        Object[] originalArgs = new Object[]{"hello"};
        when(functionContext.getArguments()).thenReturn(originalArgs);
        when(functionContext.getDataSet()).thenReturn(region);

        Object[] args = far.resolveFunctionArguments(functionContext);

        assertEquals(2, args.length);
        assertSame(region, args[0]);
View Full Code Here

        assertSame(originalArgs[0], args[1]);
    }

    @Test
    public void testMethodWithFunctionContext() throws SecurityException, NoSuchMethodException {
        RegionFunctionContext functionContext = mock(RegionFunctionContext.class);
        @SuppressWarnings("unchecked")
        Region<Object, Object> region = mock(Region.class);

        Method method = TestFunction.class.getDeclaredMethod("methodWithFunctionContext", Map.class, String.class,
                FunctionContext.class);
        FunctionArgumentResolver far = new FunctionContextInjectingArgumentResolver(method);

        Object[] originalArgs = new Object[]{"hello"};
        when(functionContext.getArguments()).thenReturn(originalArgs);
        when(functionContext.getDataSet()).thenReturn(region);

        Object[] args = far.resolveFunctionArguments(functionContext);

        assertEquals(3, args.length);
        assertSame(region, args[0]);
View Full Code Here

    }

    @SuppressWarnings({"unchecked", "rawtypes"})
    @Test
    public void testMethodWithResultSender() throws SecurityException, NoSuchMethodException {
        RegionFunctionContext functionContext = mock(RegionFunctionContext.class);
        ResultSender resultSender = mock(ResultSender.class);
        Region<Object, Object> region = mock(Region.class);

        Method method = TestFunction.class.getDeclaredMethod("methodWithResultSender", Map.class, ResultSender.class);
        FunctionArgumentResolver far = new FunctionContextInjectingArgumentResolver(method);

        Object[] originalArgs = new Object[]{};
        when(functionContext.getArguments()).thenReturn(originalArgs);
        when(functionContext.getDataSet()).thenReturn(region);
        when(functionContext.getResultSender()).thenReturn(resultSender);

        Object[] args = far.resolveFunctionArguments(functionContext);

        assertEquals(2, args.length);
        assertSame(region, args[0]);
View Full Code Here


    @SuppressWarnings("unchecked")
    @Test
    public void testMethodWithFilterAndRegion() throws SecurityException, NoSuchMethodException {
        RegionFunctionContext functionContext = mock(RegionFunctionContext.class);
        Region<Object, Object> region = mock(Region.class);

        Method method = TestFunction.class.getDeclaredMethod("methodWithFilterAndRegion", Map.class, Set.class,
                Object.class);
        FunctionArgumentResolver far = new FunctionContextInjectingArgumentResolver(method);

        Object[] originalArgs = new Object[]{new Object()};
        when(functionContext.getArguments()).thenReturn(originalArgs);
        when(functionContext.getDataSet()).thenReturn(region);
        @SuppressWarnings("rawtypes")
        Set keys = new HashSet<String>();
        when(functionContext.getFilter()).thenReturn(keys);

        Object[] args = far.resolveFunctionArguments(functionContext);

        assertEquals(3, args.length);
        assertSame(region, args[0]);
View Full Code Here

TOP

Related Classes of com.gemstone.gemfire.cache.execute.RegionFunctionContext

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.