package net.ttddyy.evernote.rest;

import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.MapPropertySource;
import org.springframework.core.env.MutablePropertySources;

import java.util.HashMap;
import java.util.Map;

/**
 * ApplicationContextInitializer to set required system properties.
 *
 * @author Tadaya Tsuyukubo
 */
public class IntegrationTestInitializer implements ApplicationContextInitializer<ConfigurableApplicationContext> {
	@Override
	public void initialize(ConfigurableApplicationContext applicationContext) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("evernote.consumerKey", "test_consumer_key");
		map.put("evernote.consumerSecret", "test_consumer_secret");

		ConfigurableEnvironment environment = applicationContext.getEnvironment();
		MutablePropertySources propertySources = environment.getPropertySources();
		propertySources.addFirst(new MapPropertySource("override", map));
	}

}

@@ -875,16 +875,172 @@
 ret%22);%0A%0A
+%09%09// disable jmx export for test to avoid InstanceAlreadyExistsException for multiple SpringBoot app contexts%0A%09%09map.put(%22endpoints.jmx.enabled%22, %22false%22);%0A%0A
 %09%09Config

disable mbean export for test