Test made using Mockito and JUnit

This commit is contained in:
Shubham Aggarwal 2016-11-28 11:03:13 +05:30
parent 782e169f46
commit 3c0d504fe5
1 changed files with 4 additions and 7 deletions

View File

@ -7,6 +7,7 @@ import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
@WebServlet(name = "FormServlet", urlPatterns = "/calculateServlet")
public class FormServlet extends HttpServlet {
@ -25,6 +26,9 @@ public class FormServlet extends HttpServlet {
response.setHeader("Test", "Success");
response.setHeader("BMI", String.valueOf(bmi));
PrintWriter out= response.getWriter();
out.write(String.valueOf(bmi));
RequestDispatcher dispatcher = request.getRequestDispatcher("index.jsp");
dispatcher.forward(request, response);
} catch (Exception e) {
@ -33,13 +37,6 @@ public class FormServlet extends HttpServlet {
}
}
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// do something else here
}
private Double calculateBMI(Double weight, Double height) {
return weight / (height * height);