context.addContextInitParameter(contextParamName, contextParams.get(contextParamName));
@Before public void setUp() throws Exception { if (server == null) { System.out.println("Initializing an instance of Grizzly Container"); final ResourceConfig rc = new ResourceConfig(A.class, B.class); WebappContext ctx = new WebappContext() {}; ctx.addContextInitParameter("contextConfigLocation", "classpath:applicationContext.xml"); ctx.addListener("com.package.something.AServletContextListener"); server = GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI), rc); ctx.deploy(server); } }
@Before public void setup() throws Exception { if (server == null) { System.out.println("Initializing an instance of Grizzly Container ..."); final ResourceConfig rc = new ResourceConfig(ResourceEndpointIntegrationTest.class, ..., ..., ...); //update WebappContext ctx = new WebappContext("IntegrationTestContext"); //register your listeners from web.xml in here ctx.addListener("com.xxx.yyy.XEndpointServletContextListener"); //register your applicationContext.xml here ctx.addContextInitParameter("contextConfigLocation", "classpath:applicationContext.xml"); //ServletRegistration is needed to load the ResourceConfig rc inside ServletContainer or you will have no //Servlet-based features available ServletRegistration registration = ctx.addServlet("ServletContainer", new ServletContainer(rc)); //Initialize the Grizzly server passing it base URL server = GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI)); //Deploy the server using our custom context ctx.deploy(server); } }
final ServletRegistration reg = ctx.addServlet("spring", new SpringServlet()); reg.addMapping("/*"); ctx.addContextInitParameter("contextConfigLocation", "classpath:spring-context.xml"); ctx.addListener("org.springframework.web.context.ContextLoaderListener"); ctx.addListener("org.springframework.web.context.request.RequestContextListener");
context.addContextInitParameter(contextParamName, contextParams.get(contextParamName));
context.addContextInitParameter(contextParamName, contextParams.get(contextParamName));