Package org.springframework.mock.web.test

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


  public void testDispatcherServletContextRefresh() throws ServletException {
    MockServletContext servletContext = new MockServletContext("org/springframework/web/context");
    DispatcherServlet servlet = new DispatcherServlet();

    servlet.init(new MockServletConfig(servletContext, "empty"));
    ServletContextAwareBean contextBean =
        (ServletContextAwareBean) servlet.getWebApplicationContext().getBean("servletContextAwareBean");
    ServletConfigAwareBean configBean =
        (ServletConfigAwareBean) servlet.getWebApplicationContext().getBean("servletConfigAwareBean");
    assertSame(servletContext, contextBean.getServletContext());
View Full Code Here


  @Test
  public void testFrameworkServletWithDefaultLocation() throws Exception {
    DispatcherServlet servlet = new DispatcherServlet();
    servlet.setContextClass(XmlWebApplicationContext.class);
    try {
      servlet.init(new MockServletConfig(new MockServletContext(""), "test"));
      fail("Should have thrown BeanDefinitionStoreException");
    }
    catch (BeanDefinitionStoreException ex) {
      // expected
      assertTrue(ex.getCause() instanceof IOException);
View Full Code Here

  @Test
  public void testFrameworkServletWithCustomLocation() throws Exception {
    DispatcherServlet servlet = new DispatcherServlet();
    servlet.setContextConfigLocation("/org/springframework/web/context/WEB-INF/testNamespace.xml "
        + "/org/springframework/web/context/WEB-INF/context-addition.xml");
    servlet.init(new MockServletConfig(new MockServletContext(""), "test"));
    assertTrue(servlet.getWebApplicationContext().containsBean("kerry"));
    assertTrue(servlet.getWebApplicationContext().containsBean("kerryX"));
  }
View Full Code Here

        wac.registerBeanDefinition("handlerMapping", mappingDef);
        wac.refresh();
        return wac;
      }
    };
    servlet.init(new MockServletConfig());

    MockHttpServletRequest request = new MockHttpServletRequest("GET", "/lat/1.2/long/3.4");
    MockHttpServletResponse response = new MockHttpServletResponse();
    servlet.service(request, response);
View Full Code Here

        wac.registerBeanDefinition("controller", new RootBeanDefinition(controllerclass));
        wac.refresh();
        return wac;
      }
    };
    servlet.init(new MockServletConfig());
  }
View Full Code Here

        wac.registerBeanDefinition("handlerMapping", mappingDef);
        wac.refresh();
        return wac;
      }
    };
    servlet.init(new MockServletConfig());

    MockHttpServletRequest request = new MockHttpServletRequest("GET", "/hotels/hotel.with.dot");
    MockHttpServletResponse response = new MockHttpServletResponse();
    servlet.service(request, response);
    assertEquals("test-hotel.with.dot", response.getContentAsString());
View Full Code Here

        wac.registerBeanDefinition("handlerMapping", mappingDef);
        wac.refresh();
        return wac;
      }
    };
    servlet.init(new MockServletConfig());

    MockHttpServletRequest request = new MockHttpServletRequest("GET", "/test/jsmith@mail.com");
    MockHttpServletResponse response = new MockHttpServletResponse();
    servlet.service(request, response);
    assertEquals("foo-jsmith@mail.com", response.getContentAsString());
View Full Code Here

        wac.registerBeanDefinition("handlerMapping", mapping);
        wac.refresh();
        return wac;
      }
    };
    servlet.init(new MockServletConfig());

    MockHttpServletRequest request = new MockHttpServletRequest("GET", "/controllerclassname/bar");
    MockHttpServletResponse response = new MockHttpServletResponse();
    servlet.service(request, response);
    assertEquals("plain-bar", response.getContentAsString());
View Full Code Here

        wac.getBeanFactory().registerSingleton("advisor", new DefaultPointcutAdvisor(new SimpleTraceInterceptor(true)));
        wac.refresh();
        return wac;
      }
    };
    servlet.init(new MockServletConfig());
  }
View Full Code Here

        wac.refresh();
        return wac;
      }
    };

    servlet.init(new MockServletConfig());

    return wac;
  }
View Full Code Here

TOP

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

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.