@Before public void checkMysqlOrPostgresqlProfile() { Assume.assumeTrue( Arrays.asList(webApplicationContext.getEnvironment().getActiveProfiles()).contains("mysql") || Arrays.asList(webApplicationContext.getEnvironment().getActiveProfiles()).contains("postgresql") ); }
/** * Loads the bean definitions via an XmlBeanDefinitionReader. * @see org.springframework.beans.factory.xml.XmlBeanDefinitionReader * @see #initBeanDefinitionReader * @see #loadBeanDefinitions */ @Override protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) throws BeansException, IOException { // Create a new XmlBeanDefinitionReader for the given BeanFactory. XmlBeanDefinitionReader beanDefinitionReader = new XmlBeanDefinitionReader(beanFactory); // Configure the bean definition reader with this context's // resource loading environment. beanDefinitionReader.setEnvironment(getEnvironment()); beanDefinitionReader.setResourceLoader(this); beanDefinitionReader.setEntityResolver(new ResourceEntityResolver(this)); // Allow a subclass to provide custom initialization of the reader, // then proceed with actually loading the bean definitions. initBeanDefinitionReader(beanDefinitionReader); loadBeanDefinitions(beanDefinitionReader); }
/** * Loads the bean definitions via an XmlBeanDefinitionReader. * @see org.springframework.beans.factory.xml.XmlBeanDefinitionReader * @see #initBeanDefinitionReader * @see #loadBeanDefinitions */ @Override protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) throws BeansException, IOException { // Create a new XmlBeanDefinitionReader for the given BeanFactory. XmlBeanDefinitionReader beanDefinitionReader = new XmlBeanDefinitionReader(beanFactory); // Configure the bean definition reader with this context's // resource loading environment. beanDefinitionReader.setEnvironment(getEnvironment()); beanDefinitionReader.setResourceLoader(this); beanDefinitionReader.setEntityResolver(new ResourceEntityResolver(this)); // Allow a subclass to provide custom initialization of the reader, // then proceed with actually loading the bean definitions. initBeanDefinitionReader(beanDefinitionReader); loadBeanDefinitions(beanDefinitionReader); }
identityClientToken = testClient.getClientCredentialsOAuthAccessToken("identity", "identitysecret", ""); groupMaxCount = Integer.parseInt(getWebApplicationContext().getEnvironment().getProperty("groupMaxCount"));
root.refresh(); XmlWebApplicationContext wac = new XmlWebApplicationContext(); wac.getEnvironment().addActiveProfile("wacProfile1"); wac.setParent(root); wac.setServletContext(sc);
@Override protected XmlWebApplicationContext initAppContext(MockConfig config, ApplicationContext parent) { XmlWebApplicationContext ctx = super.initAppContext(config, parent); if (parent == null) { ConfigurableEnvironment env = ctx.getEnvironment(); env.getPropertySources().addFirst(new LabelPropertySource()); env.getPropertySources().addLast(new DomainPropertySource(ctx)); MockAppContextFinder.setRootContext(ctx); } else { MockAppContextFinder.initPage(getSession().getPage(), ctx); } return ctx; }
@Override public void initialize(XmlWebApplicationContext ctx) { ctx.setAllowBeanDefinitionOverriding(true); ConfigurableEnvironment env = ctx.getEnvironment(); Set<String> aps = new LinkedHashSet<>(); Collections.addAll(aps, env.getActiveProfiles());
/** * Loads the bean definitions via an XmlBeanDefinitionReader. * @see org.springframework.beans.factory.xml.XmlBeanDefinitionReader * @see #initBeanDefinitionReader * @see #loadBeanDefinitions */ @Override protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) throws BeansException, IOException { // Create a new XmlBeanDefinitionReader for the given BeanFactory. XmlBeanDefinitionReader beanDefinitionReader = new XmlBeanDefinitionReader(beanFactory); // Configure the bean definition reader with this context's // resource loading environment. beanDefinitionReader.setEnvironment(getEnvironment()); beanDefinitionReader.setResourceLoader(this); beanDefinitionReader.setEntityResolver(new ResourceEntityResolver(this)); // Allow a subclass to provide custom initialization of the reader, // then proceed with actually loading the bean definitions. initBeanDefinitionReader(beanDefinitionReader); loadBeanDefinitions(beanDefinitionReader); }
/** * Loads the bean definitions via an XmlBeanDefinitionReader. * @see org.springframework.beans.factory.xml.XmlBeanDefinitionReader * @see #initBeanDefinitionReader * @see #loadBeanDefinitions */ @Override protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) throws BeansException, IOException { // Create a new XmlBeanDefinitionReader for the given BeanFactory. XmlBeanDefinitionReader beanDefinitionReader = new XmlBeanDefinitionReader(beanFactory); // Configure the bean definition reader with this context's // resource loading environment. beanDefinitionReader.setEnvironment(getEnvironment()); beanDefinitionReader.setResourceLoader(this); beanDefinitionReader.setEntityResolver(new ResourceEntityResolver(this)); // Allow a subclass to provide custom initialization of the reader, // then proceed with actually loading the bean definitions. initBeanDefinitionReader(beanDefinitionReader); loadBeanDefinitions(beanDefinitionReader); }
/** * Initialize the app context. * * @param config Configuration data. * @param parent If creating a child context, this will be its parent. Otherwise, will be null. * @return The initialized app context. */ protected XmlWebApplicationContext initAppContext(MockConfig config, ApplicationContext parent) { XmlWebApplicationContext appContext = createApplicationContext(); appContext.setServletContext(servletContext); if (parent == null) { ClasspathMessageSource.getInstance().setResourceLoader(appContext); } else { appContext.setParent(parent); } if (config.configLocations != null) { appContext.setConfigLocations(config.configLocations); } if (config.profiles != null && config.profiles.length > 0) { ConfigurableEnvironment env = appContext.getEnvironment(); env.setDefaultProfiles(parent == null ? config.profiles[0] : "dummy"); env.setActiveProfiles(config.profiles); } return appContext; }