FragmentFactory { public String process(FragmentContext context) throws PageAction { if (context.getRequestDepth() > 100) throw new UiFrameworkException("Fragment inclusion > 100 levels deep. Check your code for infinite loops."); long startTime = System.currentTimeMillis(); if (log.isDebugEnabled()) { log.debug("processing " + context.getRequest()); } context.setRequest(mapFragmentProviderAndId(context.getRequest())); applyDefaultConfiguration(context); configureModel(context); if (context.getRequest().getConfiguration().containsKey("decorator")) { String decoratorProvider = (String) context.getRequest().getConfiguration().get("decoratorProvider"); if (decoratorProvider == null) { decoratorProvider = "*"; } String decoratorName = "decorator/" + context.getRequest().getConfiguration().get("decorator"); @SuppressWarnings("unchecked") Map<String, Object> decoratorConfigurationMap = (Map<String, Object>) context.getRequest().getConfiguration() .get("decoratorConfig"); FragmentConfiguration decoratorConfiguration = new FragmentConfiguration(decoratorConfigurationMap); FragmentRequest decorator = new FragmentRequest(decoratorProvider, decoratorName, decoratorConfiguration); context.setDecorateWith(decorator); } String result = processThisFragment(context); if (context.getDecorateWith() == null) return result; FragmentRequest decoratorRequest = context.getDecorateWith(); decoratorRequest.getConfiguration().put("content", result); decoratorRequest.getConfiguration().put("contentFragmentId", context.getRequest().getConfiguration().get("id")); FragmentContext decoratorContext = new FragmentContext(decoratorRequest, context); String ret = process(decoratorContext); if (log.isDebugEnabled()) { log.debug("\thandled " + context.getRequest() + " in " + (System.currentTimeMillis() - startTime) + " ms"); } return ret; } FragmentFactory(); String process(FragmentContext context); Object getController(String providerName, String fragmentName); boolean isDevelopmentMode(); void setDevelopmentMode(boolean developmentMode); Map<String, FragmentControllerProvider> getControllerProviders(); void setControllerProviders(Map<String, FragmentControllerProvider> newControllerProviders); void setAdditionalControllerProviders(Map<String, FragmentControllerProvider> additional); void addControllerProvider(String key, FragmentControllerProvider provider); Map<String, FragmentViewProvider> getViewProviders(); void setViewProviders(Map<String, FragmentViewProvider> newViewProviders); void setAdditionalViewProviders(Map<String, FragmentViewProvider> additional); void addViewProvider(String key, FragmentViewProvider provider); Object invokeFragmentAction(String providerName, String fragmentName, String action, HttpServletRequest httpRequest, HttpServletResponse httpServletResponse); boolean fragmentExists(String providerName, String fragmentName); T convert(Object obs, Class<T> toType); Map<String, T> getSpringBeansOfType(Class<T> ofType); MessageSource getMessageSource(); ExtensionManager getExtensionManager(); ConversionService getConversionService(); FormatterService getFormatterService(); ServletContext getServletContext(); List<FragmentModelConfigurator> getModelConfigurators(); void setModelConfigurators(List<FragmentModelConfigurator> modelConfigurators); void setPossibleFragmentControllerArgumentProviders(List<PossibleFragmentControllerArgumentProvider> possibleFragmentControllerArgumentProviders); void setPossibleFragmentActionArgumentProviders(List<PossibleFragmentActionArgumentProvider> possibleFragmentActionArgumentProviders); void setSessionFactory(SessionFactory sessionFactory); List<FragmentRequestMapper> getRequestMappers(); void setRequestMappers(List<FragmentRequestMapper> requestMappers);  }
@Test public void process_shouldSetCustomModelProperties() throws Exception { PageContext pageContext = buildPageContext(); FragmentRequest fragmentRequest = new FragmentRequest("somemodule", "groovy"); FragmentContext fragmentContext = new FragmentContext(fragmentRequest, pageContext); String result = factory.process(fragmentContext); Assert.assertThat(result, new Contains("Testing Success!!!")); }