- Mockito for Spring
- Sujoy Acharya
- 393字
- 2021-07-23 20:37:57
What this book covers
Chapter 1, Getting Familiar with the Spring Framework, covers the basics of Spring, Spring projects, and especially the Spring Framework. It explores the Spring container, the life cycle of beans, dependency injection, AOP, Spring MVC, and Spring transaction management.
Chapter 2, Working with JUnit and Mockito, covers both basic and advanced JUnit usages. It covers annotation-based JUnit testing, assertion, the @RunWith
annotation, exception handling, and the Eclipse setup to run JUnit tests, matchers, and assertThat
, as well as the custom lessThanOrEqual()
matcher. The Working with Mockito section explores the Mockito framework and provides technical examples to demonstrate the capability of Mockito.
Chapter 3, Working with Spring Tests, illustrates every aspect of unit testing your Spring applications. It starts with TestContext
and explores the JUnit 4 enabled SpringJUnit4ClassRunner
. Then, it explores Spring profiles that can be used to work with the different sets of configuration files as well as the Spring environment and how to mock the environment with MockEnvironment
and MockPropertySource
. We use the ReflectionTestUtils
method to access the private fields of the Spring beans. The chapter provides usage examples of Spring annotations for testing, unit tests the MVC application with MockHttpServletRequest
, MockHttpSession
, and ModelAndViewAssert
, and mocks the servlet container with MockMvc
to handle actual requests and responses, as they will be at runtime. You will also perform real Spring integration and transaction management with annotations such as @Transactional
, @TransactionConfiguration
, and @Rollback
.
Chapter 4, Resolving Out-of-container Dependencies with Mockito, deals with unit testing the service layer in isolation from the data access layer with Mockito, unit testing the Spring data access layer with Mockito, and unit testing the Spring presentation layer (MVC) with Mockito.
Chapter 5, Time Travelling with Spring, starts by covering the features of the new major Spring release 4.0, such as Java 8 support and so on. Then, we pick the four Spring 4 topics and explore them one by one. The Working with asynchronous tasks section showcases the execution of long running methods asynchronously and provides examples to handle asynchronous processing. The Exploring @RestController section eases RESTful web service development with the advent of the @RestController
annotation. The Learning AsyncRestTemplate section explains the RESTful client code to invoke RESTful web services asynchronously. Caching is inevitable for high performant, scalable web applications. This section explains EhCache and Spring integration to achieve a high availability caching solution.
- Python數據分析基礎
- Visual C++數字圖像處理技術詳解
- AutoCAD VBA參數化繪圖程序開發與實戰編碼
- QGIS:Becoming a GIS Power User
- 可解釋機器學習:模型、方法與實踐
- Getting Started with React Native
- OpenGL Data Visualization Cookbook
- INSTANT Yii 1.1 Application Development Starter
- Java Web從入門到精通(第2版)
- Node.js區塊鏈開發
- Visual C++開發寶典
- Bitcoin Essentials
- Python趣味創意編程
- 算法訓練營:海量圖解+競賽刷題(入門篇)
- JavaScript編程精解(原書第3版)