spring - @TestPropertySource is not loading properties -


i'm writing integration test spring boot application when try override properties using @testpropertysource, it's loading property file defined in context xml it's not overriding properties defined in annotation.

@runwith(springjunit4classrunner.class) @springapplicationconfiguration(classes = {defaultapp.class, messageitcase.config.class}) @webappconfiguration @testpropertysource(properties = {"spring.profiles.active=hornetq", "test.url=http://www.test.com/",                     "test.api.key=343krqmekrfdaskfnajk"}) public class messageitcase {     @value("${test.url}")     private string testurl;      @value("${test.api.key}")     private string testapikey;      @test     public void testurl() throws exception {         system.out.println("loaded test url:" + testurl);     }        @configuration     @importresource("classpath:/meta-inf/spring/test-context.xml")     public static class config {      } } 

i tested feature spring boot 1.4 line below works pretty well

@testpropertysource(properties = { "key=value", "eureka.client.enabled=false" }) 

nevertheless new @springboottest annotation working well

@runwith(springrunner.class) @springboottest(     webenvironment = springboottest.webenvironment.random_port,     properties = { "key=value", "eureka.client.enabled=false" } ) public class newboottest {      @value("${key}")     public string key;      @test     public void test() {         system.out.println("great " + key);     } } 

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -