forked from Zephery/newblog
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
101 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
import org.junit.runner.RunWith; | ||
import org.springframework.test.context.ActiveProfiles; | ||
import org.springframework.test.context.ContextConfiguration; | ||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | ||
|
||
/** | ||
* Created with IntelliJ IDEA. | ||
* User: Zephery | ||
* Time: 2018/4/14 0:13 | ||
* Description: | ||
*/ | ||
@ContextConfiguration(locations = {"classpath:testContext.xml"}) | ||
@ActiveProfiles("develop") | ||
@RunWith(SpringJUnit4ClassRunner.class) | ||
public abstract class BaseTest { | ||
} | ||
//import org.junit.runner.RunWith; | ||
//import org.springframework.test.context.ActiveProfiles; | ||
//import org.springframework.test.context.ContextConfiguration; | ||
//import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | ||
// | ||
///** | ||
// * Created with IntelliJ IDEA. | ||
// * User: Zephery | ||
// * Time: 2018/4/14 0:13 | ||
// * Description: | ||
// */ | ||
//@ContextConfiguration(locations = {"classpath:testContext.xml"}) | ||
//@ActiveProfiles("develop") | ||
//@RunWith(SpringJUnit4ClassRunner.class) | ||
//public abstract class BaseTest { | ||
//} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
import com.myblog.service.IBlogService; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.junit.Test; | ||
|
||
import javax.annotation.Resource; | ||
|
||
/** | ||
* Created with IntelliJ IDEA. | ||
* User: Zephery | ||
* Time: 2018/4/8 23:36 | ||
* Description: | ||
*/ | ||
|
||
@Slf4j | ||
public class CacheTest extends BaseTest{ | ||
@Resource | ||
private IBlogService blogService; | ||
|
||
@Test | ||
public void test() { | ||
blogService.getBlogDetail(615); | ||
} | ||
} | ||
//import com.myblog.service.IBlogService; | ||
//import lombok.extern.slf4j.Slf4j; | ||
//import org.junit.Test; | ||
// | ||
//import javax.annotation.Resource; | ||
// | ||
///** | ||
// * Created with IntelliJ IDEA. | ||
// * User: Zephery | ||
// * Time: 2018/4/8 23:36 | ||
// * Description: | ||
// */ | ||
// | ||
//@Slf4j | ||
//public class CacheTest extends BaseTest{ | ||
// @Resource | ||
// private IBlogService blogService; | ||
// | ||
// @Test | ||
// public void test() { | ||
// blogService.getBlogDetail(615); | ||
// } | ||
//} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
import org.apache.ibatis.io.Resources; | ||
import org.apache.ibatis.session.SqlSession; | ||
import org.apache.ibatis.session.SqlSessionFactory; | ||
import org.apache.ibatis.session.SqlSessionFactoryBuilder; | ||
import org.junit.Test; | ||
|
||
/** | ||
* @author Zephery | ||
* @since 2018/1/20 15:41 | ||
*/ | ||
public class MyBatisTest { | ||
@Test | ||
public void oneCache() throws Exception { | ||
SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(Resources.getResourceAsReader("mybatis-config.xml")); | ||
SqlSession session = sqlSessionFactory.openSession(); | ||
} | ||
} | ||
//import org.apache.ibatis.io.Resources; | ||
//import org.apache.ibatis.session.SqlSession; | ||
//import org.apache.ibatis.session.SqlSessionFactory; | ||
//import org.apache.ibatis.session.SqlSessionFactoryBuilder; | ||
//import org.junit.Test; | ||
// | ||
///** | ||
// * @author Zephery | ||
// * @since 2018/1/20 15:41 | ||
// */ | ||
//public class MyBatisTest { | ||
// @Test | ||
// public void oneCache() throws Exception { | ||
// SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(Resources.getResourceAsReader("mybatis-config.xml")); | ||
// SqlSession session = sqlSessionFactory.openSession(); | ||
// } | ||
//} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,45 @@ | ||
import com.myblog.service.IBlogService; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.context.ApplicationContext; | ||
import org.springframework.context.support.FileSystemXmlApplicationContext; | ||
|
||
/** | ||
* @author Zephery | ||
* @since 2018/1/17 15:12 | ||
*/ | ||
public class SpringTest { | ||
//logger | ||
private static final Logger logger = LoggerFactory.getLogger(SpringTest.class); | ||
private ApplicationContext ctx; | ||
|
||
@Before | ||
public void before() { | ||
ctx = new FileSystemXmlApplicationContext("classpath:spring-test.xml"); | ||
} | ||
|
||
@Test | ||
public void cacheTest() { | ||
IBlogService blogService = (IBlogService) ctx.getBean("blogService"); | ||
|
||
long startTime = System.currentTimeMillis(); | ||
try { | ||
Thread.sleep(5 * 1000); | ||
} catch (InterruptedException e) { | ||
e.printStackTrace(); | ||
} | ||
for (int i = 0; i < 100; i++) { | ||
blogService.getBlogDetail(615); | ||
} | ||
System.out.print("========使用了缓存======="); | ||
System.out.println(System.currentTimeMillis() - startTime); | ||
} | ||
|
||
@Test | ||
public void aop() { | ||
IBlogService blogService = (IBlogService) ctx.getBean("blogService"); | ||
blogService.getBlogDetail(615); | ||
} | ||
} | ||
//import com.myblog.service.IBlogService; | ||
//import org.junit.Before; | ||
//import org.junit.Test; | ||
//import org.slf4j.Logger; | ||
//import org.slf4j.LoggerFactory; | ||
//import org.springframework.context.ApplicationContext; | ||
//import org.springframework.context.support.FileSystemXmlApplicationContext; | ||
// | ||
///** | ||
// * @author Zephery | ||
// * @since 2018/1/17 15:12 | ||
// */ | ||
//public class SpringTest { | ||
// //logger | ||
// private static final Logger logger = LoggerFactory.getLogger(SpringTest.class); | ||
// private ApplicationContext ctx; | ||
// | ||
// @Before | ||
// public void before() { | ||
// ctx = new FileSystemXmlApplicationContext("classpath:spring-test.xml"); | ||
// } | ||
// | ||
// @Test | ||
// public void cacheTest() { | ||
// IBlogService blogService = (IBlogService) ctx.getBean("blogService"); | ||
// | ||
// long startTime = System.currentTimeMillis(); | ||
// try { | ||
// Thread.sleep(5 * 1000); | ||
// } catch (InterruptedException e) { | ||
// e.printStackTrace(); | ||
// } | ||
// for (int i = 0; i < 100; i++) { | ||
// blogService.getBlogDetail(615); | ||
// } | ||
// System.out.print("========使用了缓存======="); | ||
// System.out.println(System.currentTimeMillis() - startTime); | ||
// } | ||
// | ||
// @Test | ||
// public void aop() { | ||
// IBlogService blogService = (IBlogService) ctx.getBean("blogService"); | ||
// blogService.getBlogDetail(615); | ||
// } | ||
//} |