Book Image

Spring MVC Beginner's Guide

By : Amuthan Ganeshan
Book Image

Spring MVC Beginner's Guide

By: Amuthan Ganeshan

Overview of this book

Table of Contents (19 chapters)
Spring MVC Beginner's Guide
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Time for action – testing the product validator


Let's see how we can boot up our test context using the Spring Test Context framework to test our ProductValidator class:

  1. Open pom.xml and you will find pom.xml under the root directory of the project itself.

  2. You will be able to see some tabs at the bottom of the pom.xml file; select the Dependencies tab and click on the Add button of the Dependencies section.

  3. A Select Dependency window will appear; enter Group Id as org.springframework, Artifact Id as spring-test, and Version as 4.0.3.RELEASE; then select Scope as test, click on the OK button, and save pom.xml.

  4. Now create an XML file called test-DispatcherServlet-context.xml under the com.packt.webstore.validator package in the source folder, src/test/resources. Add the following code into it and save it:

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:context="http://www.springframework...