001    package com.khubla.pragmatach.contrib.testsupport.controller;
002    
003    import static org.mockito.Mockito.mock;
004    import static org.mockito.Mockito.when;
005    
006    import java.util.Vector;
007    
008    import javax.servlet.ServletConfig;
009    import javax.servlet.ServletContext;
010    
011    import com.khubla.pragmatach.framework.api.PragmatachException;
012    import com.khubla.pragmatach.framework.controller.PragmatachController;
013    import com.khubla.pragmatach.framework.servlet.PragmatachServlet;
014    
015    /**
016     * @author tome
017     */
018    public class ControllerTestSupport {
019       /**
020        * test rendering a controller
021        */
022       public static String performRender(PragmatachController controller) throws PragmatachException {
023          try {
024             /*
025              * mock up a servlet context
026              */
027             final ServletConfig servletConfig = mock(ServletConfig.class);
028             when(servletConfig.getInitParameterNames()).thenReturn(new Vector<String>().elements());
029             final ServletContext servletContext = mock(ServletContext.class);
030             final PragmatachServlet pragmatachServlet = new PragmatachServlet();
031             pragmatachServlet.init(servletConfig);
032             when(servletConfig.getServletContext()).thenReturn(servletContext);
033             /*
034              * hm
035              */
036             return null;
037          } catch (final Exception e) {
038             throw new PragmatachException("Exception in performRender", e);
039          }
040       }
041    }