@Before
  public void setUp() throws Exception {
    MockHttpSession session =
        new MockHttpSession(servletContext) {
          @Override
          public String getId() {
            return "TEST$SESSION";
          }
        };
    MockHttpServletRequest request = new MockHttpServletRequest(servletContext);
    request.setSession(session);
    MockHttpServletResponse response = new MockHttpServletResponse();

    Configuration cfg = new ConfigurationImpl();
    cfg.setGraniteConfig("/WEB-INF/granite/granite-config-spring.xml");
    cfg.setFlexServicesConfig("/WEB-INF/flex/services-config-spring.xml");
    servletContext.setAttribute(ServletGraniteConfig.GRANITE_CONFIG_CONFIGURATION_KEY, cfg);
    GraniteConfig graniteConfig = ServletGraniteConfig.loadConfig(servletContext);
    ServicesConfig servicesConfig = ServletServicesConfig.loadConfig(servletContext);
    HttpGraniteContext.createThreadIntance(
        graniteConfig, servicesConfig, servletContext, request, response);

    springServiceFactory = new SpringServiceFactory();
    springServiceFactory.configure(new XMap("properties"));
    springServiceFactory.setApplicationContext(applicationContext);
  }
 protected InvocationResult invokeComponent(
     String componentName,
     Class<?> componentClass,
     String operation,
     Object[] params,
     String[] listeners,
     Object[] updates,
     String[] results,
     String conversationId) {
   RemotingMessage callMessage = new RemotingMessage();
   callMessage.setDestination("spring");
   callMessage.setOperation("invokeComponent");
   Object[] args = new Object[5];
   args[0] = componentName;
   args[1] = componentClass != null ? componentClass.getName() : null;
   args[2] = operation;
   args[3] = params;
   InvocationCall call = new InvocationCall();
   if (listeners != null) call.setListeners(Arrays.asList(listeners));
   else call.setListeners(new ArrayList<String>());
   List<ContextUpdate> cus = new ArrayList<ContextUpdate>();
   if (updates != null) {
     for (int i = 0; i < updates.length; i++) {
       Object[] u = (Object[]) updates[i];
       boolean inConv = u.length > 3 ? (Boolean) u[3] : false;
       ContextUpdate cu =
           new ContextUpdate((String) u[0], (String) u[1], u[2], inConv ? 2 : 1, false);
       cus.add(cu);
     }
   }
   call.setUpdates(cus);
   Object[] res = results != null ? new Object[results.length] : new Object[] {};
   if (results != null) {
     for (int i = 0; i < results.length; i++) {
       int idx = results[i].indexOf(".");
       if (idx > 0)
         res[i] = new ContextResult(results[i].substring(0, idx), results[i].substring(idx + 1));
       else res[i] = new ContextResult(results[i], null);
     }
   }
   call.setResults(res);
   args[4] = call;
   callMessage.setBody(args);
   return (InvocationResult)
       springServiceFactory.getServiceInstance(callMessage).invoke(callMessage);
 };