| | Test suite for Java homework
Automated testing for the Java homework
A small
automated test suite for the Java homework is
available. (during or after downloading, change the file extension from .zip
to .jar)
To run the test suite, type the following at a command
prompt:
java -jar homework-test.jar
Options
By default, the test suite interacts with Don's
reference implementation of the homework, as deployed in GlassFish
on the gf server, using a test student named "Waldo" and an invalid
grade of "bogus". You can change these parameters by changing the
following JVM properties on the command line:
-Dhost |
the value should be the service's base URL,
NOT including the context root. For example, -Dhost=http://localhost:8080
[default: http://glassfish.students.franklin.edu:4301] |
-DcontextRoot |
the value should be the service's context
root. For example, -DcontextRoot=joe
[default: don] |
-Dstudent |
the value should be the student name to be
used in testing. For example, -Dstudent=Barney
[default: Waldo] |
-Dbogus |
the value should be the invalid grade string
used in the bogus-grade test. For example, -Dgrade=whatever
[default: bogus] |
More information
- The test suite uses Jersey's
"Uniform Interface" to web resources, which is a very promising
library for calling web services.
- The Client and WebResource classes should be easily
adaptable to other situations in which you need to call RESTful web
services.
- As always, you are free to re-use any of the source
code that is included in the test suite jar file.
Example - running the test with default parameters
C:\testing>java -jar homework-test.jar
no-waldo: GET http://glassfish.students.franklin.edu:4301/don/student/Waldo
succeeded
waldo-posts-b: POST
http://glassfish.students.franklin.edu:4301/don/student/Waldo/grade/B
succeeded
waldo-included: GET http://glassfish.students.franklin.edu:4301/don/student
succeeded
waldo-gets-b: GET
http://glassfish.students.franklin.edu:4301/don/student/Waldo
succeeded
waldo-puts-c-: PUT
http://glassfish.students.franklin.edu:4301/don/student/Waldo/grade/C-
succeeded
waldo-gets-c-: GET
http://glassfish.students.franklin.edu:4301/don/student/Waldo
succeeded
bogus-grade: POST
http://glassfish.students.franklin.edu:4301/don/student/Waldo/grade/bogus
succeeded
goodbye-waldo: DELETE
http://glassfish.students.franklin.edu:4301/don/student/Waldo
succeeded
no-waldo: GET http://glassfish.students.franklin.edu:4301/don/student/Waldo
succeeded
0 of 9 tests failed
Example - running the test with several custom parameters
java -Dhost=http://localhost:8080 -DcontextRoot=don -Dstudent=Barney -jar
homework-test.jar
no-waldo: GET http://localhost:8080/don/student/Barney
succeeded
waldo-posts-b: POST http://localhost:8080/don/student/Barney/grade/B
succeeded
waldo-included: GET http://localhost:8080/don/student
succeeded
waldo-gets-b: GET http://localhost:8080/don/student/Barney
succeeded
waldo-puts-c-: PUT http://localhost:8080/don/student/Barney/grade/C-
succeeded
waldo-gets-c-: GET http://localhost:8080/don/student/Barney
succeeded
bogus-grade: POST http://localhost:8080/don/student/Barney/grade/bogus
succeeded
goodbye-waldo: DELETE http://localhost:8080/don/student/Barney
succeeded
no-waldo: GET http://localhost:8080/don/student/Barney
succeeded
0 of 9 tests failed
|