001 package com.mockrunner.mock.web;
002
003 import javax.servlet.Servlet;
004 import javax.servlet.ServletContext;
005 import javax.servlet.ServletRequest;
006 import javax.servlet.ServletResponse;
007 import javax.servlet.jsp.JspApplicationContext;
008 import javax.servlet.jsp.JspEngineInfo;
009 import javax.servlet.jsp.JspFactory;
010 import javax.servlet.jsp.PageContext;
011
012 /**
013 * Mock implementation of <code>JspFactory</code>.
014 * This implementation returns <code>null</code>
015 * for {@link #getJspApplicationContext}. For full
016 * support of <code>JspApplicationContext</code> use
017 * {@link JasperJspFactory}.
018 */
019 public class MockJspFactory extends JspFactory
020 {
021 private JspEngineInfo engineInfo;
022 private JspApplicationContext applicationContext;
023 private PageContext pageContext;
024
025 public MockJspFactory()
026 {
027 engineInfo = new MockJspEngineInfo();
028 }
029
030 /**
031 * Set the <code>JspEngineInfo</code>. Per default,
032 * {@link MockJspEngineInfo} is used.
033 * @param engineInfo the <code>JspEngineInfo</code>
034 */
035 public void setEngineInfo(JspEngineInfo engineInfo)
036 {
037 this.engineInfo = engineInfo;
038 }
039
040 /**
041 * Set the <code>JspApplicationContext</code>.
042 * @param applicationContext the <code>JspApplicationContext</code>
043 */
044 public void setJspApplicationContext(JspApplicationContext applicationContext)
045 {
046 this.applicationContext = applicationContext;
047 }
048
049 /**
050 * Set the <code>PageContext</code>.
051 * @param pageContext the <code>PageContext</code>
052 */
053 public void setPageContext(PageContext pageContext)
054 {
055 this.pageContext = pageContext;
056 }
057
058 /**
059 * Returns the <code>PageContext</code>.
060 * @return the <code>PageContext</code>
061 */
062 public PageContext getPageContext()
063 {
064 return pageContext;
065 }
066
067 public JspEngineInfo getEngineInfo()
068 {
069 return engineInfo;
070 }
071
072 public JspApplicationContext getJspApplicationContext(ServletContext context)
073 {
074 return applicationContext;
075 }
076
077 public PageContext getPageContext(Servlet servlet, ServletRequest request, ServletResponse response, String errorPageURL, boolean needsSession, int buffer, boolean autoflush)
078 {
079 return pageContext;
080 }
081
082 public void releasePageContext(PageContext pageContext)
083 {
084
085 }
086 }