Package com.gemstone.gemfire.cache.execute

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


public class FunctionArgumentResolverTest {

  @Test
  public void testDefaultFunctionArgumentResolverWithNoArguments() {
    FunctionArgumentResolver functionArgumentResolver = new DefaultFunctionArgumentResolver();
    FunctionContext mockFunctionContext = mock(FunctionContext.class);

    when(mockFunctionContext.getArguments()).thenReturn(null);

    Object[] args = functionArgumentResolver.resolveFunctionArguments(mockFunctionContext);

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


  }

  @Test
  public void testDefaultFunctionArgumentResolverWithArgumentArray() {
    FunctionArgumentResolver functionArgumentResolver = new DefaultFunctionArgumentResolver();
    FunctionContext functionContext = mock(FunctionContext.class);

    when(functionContext.getArguments()).thenReturn(new String[] { "one", "two", "three" });

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

    assertNotNull(args);
    assertFalse(args instanceof String[]);
View Full Code Here

  }

  @Test
    public void testDefaultFunctionArgumentResolverWithSingleArgument() {
        FunctionArgumentResolver functionArgumentResolver = new DefaultFunctionArgumentResolver();
        FunctionContext functionContext = mock(FunctionContext.class);

        when(functionContext.getArguments()).thenReturn("test");

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

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

    }

    @Test
  @SuppressWarnings("unchecked")
    public void testMethodWithFunctionContextAndResultSender() throws NoSuchMethodException {
        FunctionContext functionContext = mock(FunctionContext.class);
        ResultSender resultSender = mock(ResultSender.class);
        Method method = TestFunction.class.getDeclaredMethod("methodWithFunctionContextAndResultSender",
      FunctionContext.class, ResultSender.class);

        FunctionArgumentResolver far = new FunctionContextInjectingArgumentResolver(method);

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

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

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

TOP

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

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.