package com.didispace; import com.didispace.service.BlogProperties; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.SpringApplicationConfiguration; import org.springframework.mock.web.MockServletContext; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; /** * * @author 程序猿DD * @version 1.0.0 * @blog http://blog.didispace.com * */ @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(Application.class) public class ApplicationTests { private static final Log log = LogFactory.getLog(ApplicationTests.class); @Autowired private BlogProperties blogProperties; @Test public void test1() throws Exception { Assert.assertEquals("程序猿DD", blogProperties.getName()); Assert.assertEquals("Spring Boot教程", blogProperties.getTitle()); Assert.assertEquals("程序猿DD正在努力写《Spring Boot教程》", blogProperties.getDesc()); log.info("随机数测试输出:"); log.info("随机字符串 : " + blogProperties.getValue()); log.info("随机int : " + blogProperties.getNumber()); log.info("随机long : " + blogProperties.getBignumber()); log.info("随机10以下 : " + blogProperties.getTest1()); log.info("随机10-20 : " + blogProperties.getTest2()); } }