O'Reilly logo

Spring MVC Beginner’s Guide by Amuthan G

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – testing REST controllers

Similarly, we can test the REST-based controllers as well. Just perform the following steps:

  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 com.jayway.jsonpath, Artifact Id as json-path-assert, and Version as 0.8.1. Select Scope as test, click on the OK button, and save pom.xml.
  4. Now create a class called CartRestControllerTest under the com.packt.webstore.controller package in the source folder, src/test/java. Now add the following code to it:
    package com.packt.webstore.controller; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required