org.jmockring.spring.ServletContextUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jmockring-core Show documentation
Show all versions of jmockring-core Show documentation
jmockring - Java test MOCKing tool for spRING.
A test harness tool for projects using the following technology stack:
- Java 6+
- Spring 3.1 or greater as a DI/Deployment container
- JUnit 4 and Mockito for testing
- Jetty/Servlet API 3.0 for web app (war) deployment - for testing only
Main features:
1) Partial Spring context deployment with automatic bean mocking for unavailable beans
2) Bootstrapping embedded Jetty server via JUnit runners
3) Configurable web application contexts
4) Automatic injection of Spring beans and mocks in JUnit tests via Java5 annotations
The newest version!
package org.jmockring.spring;
import javax.servlet.ServletContext;
import org.jmockring.configuration.BaseContextConfiguration;
import org.jmockring.configuration.ConfigurationConstants;
import org.jmockring.configuration.ServerConfiguration;
/**
* @author Pavel Lechev
* @since 15/07/13
*/
public class ServletContextUtils {
/**
* @param context
*
* @return
*/
public static ServerConfiguration getConfigurationFromContext(ServletContext context) {
return (ServerConfiguration) context.getAttribute(ConfigurationConstants.SERVER_CONFIGURATION_KEY);
}
/**
* @param context
*
* @return
*/
public static BaseContextConfiguration getContextConfigurationFromContext(ServletContext context) {
return (BaseContextConfiguration) context.getAttribute(ConfigurationConstants.CONTEXT_CONFIGURATION_KEY);
}
}