package net.ttddyy.evernote.rest;

import org.springframework.boot.test.EnvironmentTestUtils;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;

/**
 * ApplicationContextInitializer to set required system properties.
 *
 * @author Tadaya Tsuyukubo
 */
public class IntegrationTestInitializer implements ApplicationContextInitializer<ConfigurableApplicationContext> {
	@Override
	public void initialize(ConfigurableApplicationContext applicationContext) {
		ConfigurableEnvironment environment = applicationContext.getEnvironment();
		EnvironmentTestUtils.addEnviroment(environment, "evernote.consumerKey:test_consumer_key");
		EnvironmentTestUtils.addEnviroment(environment, "evernote.consumerSecret:test_consumer_secret");

		// disable jmx export for test to avoid InstanceAlreadyExistsException for multiple SpringBoot app contexts
		EnvironmentTestUtils.addEnviroment(environment, "spring.jmx.enabled:false");
	}

}

@@ -598,132 +598,28 @@
 %7B%0A%09%09
-ConfigurableEnvironment environment = applicationContext.getEnvironment();%0A%09%09EnvironmentTestUtils.addEnviroment(environment,
+String consumerKey =
  %22ev
@@ -659,60 +659,35 @@
 key%22
-)
 ;%0A%09%09
-EnvironmentTestUtils.addEnviroment(environment,
+String consumerSecret =
  %22ev
@@ -729,19 +729,17 @@
 _secret%22
-);%0A
+;
 %0A%09%09// di
@@ -841,16 +841,67 @@
 ontexts%0A
+%09%09String disableJmx = %22spring.jmx.enabled:false%22;%0A%0A
 %09%09Enviro
@@ -928,52 +928,73 @@
 viro
+n
 ment(
-environment, %22spring.jmx.enabled:false%22
+applicationContext, consumerKey, consumerSecret, disableJmx
 );%0A%09

fix usage of EnvironmentTestUtils.addEnvironment()