
com.dthoffman.tomcatmock.spock.spring.WebAppInit.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spock-example Show documentation
Show all versions of spock-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.spock.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
/**
* Created by dhoffman on 7/29/16.
*/
class WebAppInit implements WebApplicationInitializer {
@Override
void onStartup(ServletContext servletContext) throws ServletException {
AnnotationConfigWebApplicationContext annotationConfigApplicationContext = new AnnotationConfigWebApplicationContext()
annotationConfigApplicationContext.register(SpringConfig)
DispatcherServlet dispatcherServlet = new DispatcherServlet(annotationConfigApplicationContext)
servletContext.addServlet('dispatcherServlet', dispatcherServlet).addMapping("/*")
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy