servletConfig.addInitParameter("pCommon", "pCommonConfigValue"); servletConfig.addInitParameter("pConfig1", "pConfig1Value");
public void initializeContext(ConfigurableWebApplicationContext context, String yamlPath) { MockServletContext servletContext = new MockServletContext() { @Override public <Type extends EventListener> void addListener(Type t) { //no op } }; MockServletConfig servletConfig = new MockServletConfig(servletContext); servletConfig.addInitParameter("environmentConfigDefaults", yamlPath); context.setServletContext(servletContext); context.setServletConfig(servletConfig); new YamlServletProfileInitializer().initialize(context); } }
servletConfig.addInitParameter("pCommon", "pCommonConfigValue"); servletConfig.addInitParameter("pConfig1", "pConfig1Value");
context.setServletContext(servletContext); MockServletConfig servletConfig = new MockServletConfig(servletContext); servletConfig.addInitParameter("environmentConfigLocations", StringUtils.arrayToCommaDelimitedString(yamlFiles)); context.setServletConfig(servletConfig);
private void prepareSVN() throws IOException, SVNException { File tempRepo = new File(System.getProperty("java.io.tmpdir"), "repo"); fileEntityRepository.setUserRepository(new File(tempRepo, getTestUser().getUserId())); tempRepo.deleteOnExit(); File testUserRoot = fileEntityRepository.getUserRepoDirectory(getTestUser()).getParentFile(); FileUtils.deleteQuietly(testUserRoot); testUserRoot.mkdirs(); CompressionUtils.unzip(new ClassPathResource("TEST_USER.zip").getFile(), testUserRoot); testUserRoot.deleteOnExit(); MockServletConfig servletConfig = new MockServletConfig(); servletConfig.addInitParameter("SVNParentPath", testUserRoot.getAbsolutePath()); DAVConfig davConfig = new DAVConfig(servletConfig); svnController.setDAVConfig(davConfig); }
@Override protected void setUp() throws Exception { super.setUp(); servlet = (HttpServlet)Class.forName("org.apache.wink.server.internal.servlet.RestServlet") .newInstance(); MockServletConfig servletConfig = new MockServletConfig(); servletConfig.addInitParameter("javax.ws.rs.Application", getApplicationClassName()); String propertiesFile = getPropertiesFile(); if (propertiesFile != null) { servletConfig.addInitParameter("propertiesLocation", propertiesFile); } String deploymentConfigClass = getDeploymentConfigurationClassName(); if (deploymentConfigClass != null) { servletConfig.addInitParameter("deploymentConfiguration", deploymentConfigClass); } tls.set(this); servlet.init(servletConfig); }
private void createServlet(Class<?> servletClass, ApplicationContext applicationContext, Map<String, String> initParameters) { if (servletCache.containsKey(applicationContext)) { servlet = servletCache.get(applicationContext); return; } MockServletConfig config = new MockServletConfig(); config.getServletContext().setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, new ApplicationContextWrapper(applicationContext, config.getServletContext())); if (initParameters!=null) { for (Map.Entry<String, String> param: initParameters.entrySet()) { config.addInitParameter(param.getKey(), param.getValue()); } } try { servlet = (HttpServlet) BeanUtils.instantiate(servletClass); servlet.init(config); servletCache.put(applicationContext, servlet); } catch (Exception e) { throw new IllegalArgumentException("Error when creating servlet "+servletClass.getName(),e); } }
public DispatcherServletChannelInitializer() throws ServletException { MockServletContext servletContext = new MockServletContext(); MockServletConfig servletConfig = new MockServletConfig(servletContext); servletConfig.addInitParameter("contextConfigLocation","classpath:/META-INF/spring/root-context.xml"); servletContext.addInitParameter("contextConfigLocation","classpath:/META-INF/spring/root-context.xml"); //AnnotationConfigWebApplicationContext wac = new AnnotationConfigWebApplicationContext(); XmlWebApplicationContext wac = new XmlWebApplicationContext(); //ClassPathXmlApplicationContext wac = new ClassPathXmlApplicationContext(); wac.setServletContext(servletContext); wac.setServletConfig(servletConfig); wac.setConfigLocation("classpath:/servlet-context.xml"); //wac.register(WebConfig.class); wac.refresh(); this.dispatcherServlet = new DispatcherServlet(wac); this.dispatcherServlet.init(servletConfig); }
getServletConfig().addInitParameter("config-location", m_cxfContextPath); CXFServlet servlet = new CXFServlet(); setDispatcher(servlet);