Spring Boot 属性配置文件

This commit is contained in:
JeffLi1993
2017-04-17 15:07:15 +08:00
committed by liqiangqiang
parent ed91d430c4
commit f32f86c9db
7 changed files with 197 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
package org.spring.springboot.property;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
/**
* 自定义配置文件测试类
*
* Created by bysocket on 17/04/2017.
*/
@RunWith(SpringRunner.class)
@SpringBootTest
public class HomePropertiesTest {
private static final Logger LOGGER = LoggerFactory.getLogger(HomePropertiesTest.class);
@Autowired
private HomeProperties homeProperties;
@Test
public void getHomeProperties() {
LOGGER.info(homeProperties.getProvince());
Assert.assertEquals("浙江省",homeProperties.getProvince());
LOGGER.info(homeProperties.getCity());
Assert.assertEquals("温岭松门",homeProperties.getCity());
LOGGER.info(homeProperties.getDesc());
}
}

View File

@@ -0,0 +1,18 @@
package org.spring.springboot.web;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
/**
* Spring Boot HelloWorldController 测试 - {@link HelloWorldController}
*
* Created by bysocket on 16/4/26.
*/
public class HelloWorldControllerTest {
@Test
public void testSayHello() {
assertEquals("Hello,World!",new HelloWorldController().sayHello());
}
}