
com.dthoffman.tomcatmock.junit.spring.WebAppInit Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of junit-example Show documentation
Show all versions of junit-example Show documentation
Helper code to spin up a tomcat app during tests and mocking downstream http calls
The newest version!
package com.dthoffman.tomcatmock.junit.spring;
import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
public class WebAppInit implements WebApplicationInitializer {
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
AnnotationConfigWebApplicationContext annotationConfigApplicationContext = new AnnotationConfigWebApplicationContext();
annotationConfigApplicationContext.register(JokeAppSpringConfig.class);
DispatcherServlet dispatcherServlet = new DispatcherServlet(annotationConfigApplicationContext);
servletContext.addServlet("dispatcherServlet", dispatcherServlet).addMapping("/*");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy