Package org.springframework.mock.web.test

Examples of org.springframework.mock.web.test.MockServletContext


  public void testFreeMarkerViewResolver() throws Exception {
    FreeMarkerConfigurer configurer = new FreeMarkerConfigurer();
    configurer.setConfiguration(new TestConfiguration());

    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.setServletContext(new MockServletContext());
    wac.getBeanFactory().registerSingleton("configurer", configurer);
    wac.refresh();

    FreeMarkerViewResolver vr = new FreeMarkerViewResolver();
    vr.setPrefix("prefix_");
View Full Code Here


  @SuppressWarnings("resource")
  public void setup() throws Exception {
    this.filterChain = new MockFilterChain(this.servlet, new ResourceUrlEncodingFilter());

    AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
    context.setServletContext(new MockServletContext());
    context.register(WebConfig.class);
    context.refresh();

    this.request = new MockHttpServletRequest("GET", "/");
    this.request.setContextPath("/myapp");
View Full Code Here

* */
public class TilesConfigurerTests {

  @Test
  public void simpleBootstrap() {
    MockServletContext sc = new MockServletContext();
    TilesConfigurer tc = new TilesConfigurer();
    tc.setDefinitions("/org/springframework/web/servlet/view/tiles2/tiles-definitions.xml");
    tc.setCheckRefresh(true);
    tc.setServletContext(sc);
    tc.afterPropertiesSet();
View Full Code Here

* @author Sam Brannen
*/
public abstract class AbstractTagTests extends TestCase {

  protected MockPageContext createPageContext() {
    MockServletContext sc = new MockServletContext();
    SimpleWebApplicationContext wac = new SimpleWebApplicationContext();
    wac.setServletContext(sc);
    wac.setNamespace("test");
    wac.refresh();

    MockHttpServletRequest request = new MockHttpServletRequest(sc);
    MockHttpServletResponse response = new MockHttpServletResponse();
    if (inDispatcherServlet()) {
      request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
      LocaleResolver lr = new AcceptHeaderLocaleResolver();
      request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, lr);
      ThemeResolver tr = new FixedThemeResolver();
      request.setAttribute(DispatcherServlet.THEME_RESOLVER_ATTRIBUTE, tr);
      request.setAttribute(DispatcherServlet.THEME_SOURCE_ATTRIBUTE, wac);
    }
    else {
      sc.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
    }

    return new MockPageContext(sc, request, response);
  }
View Full Code Here

    model.put("foo", "bar");

    final String templateName = "test.vm";

    WebApplicationContext wac = mock(WebApplicationContext.class);
    MockServletContext sc = new MockServletContext();
    sc.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);

    final Template expectedTemplate = new Template();
    VelocityConfig vc = new VelocityConfig() {
      @Override
      public VelocityEngine getVelocityEngine() {
View Full Code Here

  protected AbstractJasperReportsView getView(String url) throws Exception {
    AbstractJasperReportsView view = getViewImplementation();
    view.setUrl(url);
    StaticWebApplicationContext ac = new StaticWebApplicationContext();
    ac.setServletContext(new MockServletContext());
    ac.addMessage("page", Locale.GERMAN, "MeineSeite");
    ac.refresh();
    request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, ac);
    view.setApplicationContext(ac);
    return view;
View Full Code Here

  @Test
  public void testKeepExistingContentType() throws Exception {
    final String templateName = "test.vm";

    WebApplicationContext wac = mock(WebApplicationContext.class);
    MockServletContext sc = new MockServletContext();
    sc.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);

    final Template expectedTemplate = new Template();
    VelocityConfig vc = new VelocityConfig() {
      @Override
      public VelocityEngine getVelocityEngine() {
View Full Code Here

  @Test
  public void testExposeHelpers() throws Exception {
    final String templateName = "test.vm";

    WebApplicationContext wac = mock(WebApplicationContext.class);
    given(wac.getServletContext()).willReturn(new MockServletContext());

    final Template expectedTemplate = new Template();
    VelocityConfig vc = new VelocityConfig() {
      @Override
      public VelocityEngine getVelocityEngine() {
View Full Code Here

  public ExpectedException thrown = ExpectedException.none();

  @Before
  public void setUp() throws Exception {
    wac = new StaticWebApplicationContext();
    wac.setServletContext(new MockServletContext());

    final Template expectedTemplate = new Template();
    VelocityConfig vc = new VelocityConfig() {
      @Override
      public VelocityEngine getVelocityEngine() {
View Full Code Here

*/
public class BaseViewTests extends TestCase {

  public void testRenderWithoutStaticAttributes() throws Exception {
    WebApplicationContext wac = mock(WebApplicationContext.class);
    given(wac.getServletContext()).willReturn(new MockServletContext());

    HttpServletRequest request = new MockHttpServletRequest();
    HttpServletResponse response = new MockHttpServletResponse();
    TestView tv = new TestView(wac);

View Full Code Here

TOP

Related Classes of org.springframework.mock.web.test.MockServletContext

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.