package com.zlikun.spring;

import com.zlikun.spring.service.HelloService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;

import static org.junit.Assert.assertEquals;

/**
 * 本例中激活了配置：dev ,windows
 * @author zlikun <zlikun-dev@hotmail.com>
 * @date 2017-11-03 11:03
 */
@RunWith(SpringRunner.class)
@ContextConfiguration(classes = AppConfigure.class)
// 指定激活的配置，对应@Profile("dev")标注的Bean
@ActiveProfiles({ "dev" })
// 可以直接配置键值对
@TestPropertySource(properties = { "host = 192.168.9.205"  ,"port: 6379"})
// 可以注入外部资源文件
// @TestPropertySource("classpath:config.properties")
public class ActiveProfilesTest {

    @Autowired
    HelloService helloService ;

    @Test
    public void say() {
        String message = helloService.say("zlikun") ;
        assertEquals("zlikun : Hello !" ,message) ;
    }

}
