Mockito for Spring
eBook - ePub

Mockito for Spring

Sujoy Acharya

Share book
  1. 178 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Mockito for Spring

Sujoy Acharya

Book details
Book preview
Table of contents
Citations

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Mockito for Spring an online PDF/ePUB?
Yes, you can access Mockito for Spring by Sujoy Acharya in PDF and/or ePUB format, as well as other popular books in Informatique & Développement de logiciels. We have over one million books available in our catalogue for you to explore.

Information

Year
2015
ISBN
9781783983780

Mockito for Spring


Table of Contents

Mockito for Spring
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Getting Familiar with the Spring Framework
Getting started with Spring
Exploring the Spring architecture
The core container
The AOP module
The instrumentation module
The messaging module
The data access module
The web layer
The test module
Learning the Inversion of Control
Printing Hello World
Examining life cycle messages
Working with autowiring and annotations
Working with aspects
Exploring Spring JDBC
Handling a transaction with Spring
Working with declarative Spring transaction
Exploring transaction attributes
Using the @Transactional annotation
Working with a programmatic Spring transaction
Using TransactionTemplate
Using PlatformTransactionManager
Building an MVC application with Spring
Summary
2. Working with JUnit and Mockito
Learning unit testing
Working with the JUnit framework
Configuring Eclipse
Examining annotations
Verifying an expectation with an assertion
Examining exception handling
Working with the @RunWith annotation
Working with test suites
Working with assertThat
Exploring equalTo, is, and not
Exploring compound matchers – either, both, anyOf, and allOf
Exploring collection matchers – hasItem and hasItems
Working with string matchers – startsWith, endsWith, and containsString
Exploring custom matchers
Working with Mockito
Learning the significance of Mockito
Exploring Mockito
Configuring Mockito
Mocking in action
Mocking objects
Stubbing methods
Verifying in depth
Verifying zero and no more interactions
Throwing exceptions
Summary
3. Working with Spring Tests
Exploring the TestContext framework
Writing a custom TestExecutionListener interface
Configuring Spring profiles
Mocking an environment
Mocking the JNDI lookup
Using ReflectionTestUtils
Working with annotations
Testing Spring MVC
Mocking the servlet container with MockMvc
Handling transactions in Spring tests
Summary
4. Resolving Out-of-container Dependencies with Mockito
Unit testing the web layer
Unit testing the service layer
Unit testing the data access layer
Summary
5. Time Travelling with Spring
Discovering the new Spring release
Working with asynchronous tasks
Exploring @RestController
Learning AsyncRestTemplate
Caching objects
Summary
Index

Mockito for Spring

Copyright © 2015 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: February 2015
Production reference: 1200215
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78398-378-0
www.packtpub.com

Credits

Author
Sujoy Acharya
Reviewers
Carlo Micieli
Gualtiero Testa
Commissioning Editor
Amarabha Banerjee
Acquisition Editor
Llewellyn Rozario
Content Development Editor
Parita Khedekar
Technical Editors
Manal Pednekar
Chinmay S. Puranik
Copy Editors
Dipti Kapadia
Deepa Nambiar
Vikrant Phadke
Project Coordinator
Milton Dsouza
Proofreaders
Martin Diver
Maria Gould
Paul Hindle
Indexer
Monica Ajmera Mehta
Production Coordinator
Aparna Bhagat
Cover Work
Aparna Bhagat

About the Author

Sujoy Acharya works as a software architect with Siemens Technology and Services Pvt. Ltd. (STS). He grew up in a joint family and pursued his graduation in the fields of computer science and engineering. His hobbies are watching movies and sitcoms, playing outdoor sports, and reading books.
Sujoy likes to research upcoming technologies. His major contributions are in the fields of Java, J2EE, SOA, Ajax, GWT, and the Spring Framework.
He has authored three books for Packt Publishing, namely Test-Driven Development with Mockito, Mastering Unit Testing using Mockito and JUnit, and Mockito Essentials.
He designs and develops healthcare software products. He has over 11 years of experience in the industry and has architected and implemented large-scale enterprise solutions.

About the Reviewers

Carlo Micieli has been a software developer since 2001, developing applications for computer-aided manufacturing with C#.
His main area of interest is application life cycle management, with a strong focus on topics such as software design and testing.
He is a programming languages enthusiast, and he's currently trying to learn Scala and Haskell. He shares his experiments on GitHub (http://github.com/CarloMicieli).
Gualtiero Testa is a software analyst, architect, and developer involved in Java enterprise-level web applications, mainly in the domains of banking, health, and government agencies. He lives in Pavia, Italy.
His main interests are test-driven development (TDD), testing tools and methodologies, and everything related to code quality.
You can reach him through his blog at http://www.gualtierotesta.it/.

www.PacktPub.com

Support files, eBooks, discount offers, and more

For support files and downloads related to your book,...

Table of contents