Reference no: EM133673732
Task: Turn 8.1P into a STEM game for grade 46 kids
Overview
In 8.1P you have created a login.html page and connected it to a HTTP endpoint for authentication service. In this task, you will need to transform this application to a STEM game application consisting of several math questions for students of grade 46 which you would like to show during Deakin's Open day. After successful login, the next page shows a math problem to be answered by the user and click on submit. If the answer is correct, the next page shows another question, otherwise, the current page shows an error message asking the user to try it again. A new Java web project is created for this project to allow the page navigation to happen compared to the previous one where HTML files were outside of the Java HTTP endpoints which could only receive GET or POST requests but could not navigate through pages. Two sample math problems of addition and subtraction are created, and, in this task, you will need to do unit testing of the math operations and create the third math problem HTML page. You will need to create unit test cases for the math operations and do functional testing of the pages using Selenium. In addition, you need to create a third question in the pool which appears once the second question is answered correctly and ensure to do unit test and functional tests properly. Reflect on difficulties testing a path or sequence of pages - how to organise your functional test cases.
Submission details
Use the instructions on the following page to carry out this task's steps. Like 8.1P submission, you will need to submit below items
A PDF file listing unit test cases from developer pointofview and functional test cases from testteam pointofview. You can use a table to describe each test case name, description, intended result and test results.
A selfreflection on testing an integrated web application compared to what has been done in 8.1P.
Your reflection on functional testing sequence of pages using JUnit and following best test practices to organise your test cases.
Your program's source code. You can copy/paste your source code and test codes in PDF.
A screenshot of your GitHub page where your latest project folder is pushed.
You want to focus on the following key ideas, and make sure you can explain them in relation to your program.
Web application structure of separate HTML and Java endpoints within a single web project and its testability aspects.
Instructions
For this task you will need to
Download task9_1P.zip Java project and unzip it in a common folder (say, java_projects) which you will be using to store all the weekly projects.
Import the project (as a maven project) in Eclipse IDE.
Observe the project folder structure as below
Directory structure MyServer.java
src/main/webapp Folder containing HTML files within the project. JSP files contain
HTML codes. You will need to create functional test cases for these HTML files using Selenium.
MyServer.java
Package: web Web application entry point, you have to run this file to start the
web server.
RoutingServlet.java
Package: web.handler Handles mapping between URL and endpoints, for example,
what Java function to call when URL contains /login.
LoginService.java
Package: web.service Authentication logic for /login URL routing. The login function
within this Java file is called to authenticate a user.
MathQuestionService.java
Package: web.service Contains math functions for STEM tests. These functions are
used to evaluate users when a math question is answered and a
submit button is pressed on the page. You will need to unit test
these functions.
Line 920 Web application starting point. Inside main() function, an application using a thirdparty Java library called Spring Framework is utilised. You can run this file to start the web
server.
The RoutingServlet.java file contains code to bind GET/POST requests to functions for each URL.
RoutingServlet.java
JSP file from src/main/webapp/WEBINF/jsp folder. The URL part / indicates a
root URL without any subURL. https://127.0.0.1:8080/ is a root URL.
Line 2630 Mapping of a GET URL part /login to a Java function loginView() which returns viewlogin.jsp HTML page. This page allows input elements and submitting a HTML form in terms of POST method which is handled in login() function
below.
Line 3357 Mapping of a POST URL part /login to a Java function login() which contains logic to inspect login page data and call LoginService.login() function to authenticate a user. Upon successful login, a redirectview request is issued to display page for URL part /q1 (line 46), otherwise the same /login view is
rendered with an error message which is generated in line 53.
As can be seen for each HTML page a GET mapping function is required to deliver the corresponding URL part specific page. If the page contains an HTML form, then a POST mapping function is required to serve the submitted form and both the GET and POST mapping functions have the same URL part (such
as /login shown above).
The GET method handling in RoutingServlet.java shows how to deliver the view view q1.jsp and the POST method handling shows how to retrieve two numbers and the user's response for mathematical addition question. HTML form input values are passed to MathQuestionService.java functions to get a response.
RoutingServlet.java
Line 75 Calls MathQuestionService.q1Addition() function with 2 numbers as received from the HTML POST submission.
MathQuestionService.java
Line 1113 Q1Addition() function takes String format numbers, converts to double,
adds them and returns the result.
The Q1 math question page is shown below.
viewq1.jsp HTML rendered view
As you can see, if the numbers in Q1 form are submitted with empty values, they are passed as it is to MathQuestionService.q1Addition() function. This results an error page as below
Your job is to unit test MathQuestionService.java functions so the errors can be eliminated, if not, reduce the number of errors. You will need to set proper message in each questions POST mapping function (shown in step 4 above) so you can perform functional tests using Selenium for success and failure cases.
Your Task
Your task is to:
Study the project source and test codes and HTML code in JSP files to understand the project better.
Write unit test cases to improve functions in MathQuestionService.java. This requires you to ensure the error page is not displayed for the question pages (viewq1.jsp and viewq2.jsp) which results from mainly value error.
Write functional test cases to validate if the application meets minimum level of functionality to be a STEM math testing application.
Your goal should be to critically write test cases from both developer and testteam member's point of view to find flaws in the system.
Follow submission instructions on the first page and submit your work.