Lab lecture exercises – 9 October 2015 1. JUnit Test (a) Log-in, open a Terminal. (b) Add to your file .cshrc at the end the two lines: setenv CLASSPATH .:/usr/share/java/junit4.jar alias junit ’java org.junit.runner.JUnitCore’ (c) Close the terminal by inputting exit. Open a Terminal. (d) Copy the file http://www.cs.bham.ac.uk/internal/courses/java/msc/handouts/ 1-02/JUnitExample.java to a suitable directory. On the School machines you can also do the following in the directory of your choice: cp /bham/htdocs/www/internal/courses/java/msc/handouts/1-02/ JUnitExample.java . (e) Compile the file by javac JUnitExample.java. (f) Run the tests by junit JUnitExample. 2. Eclipse (a) Open Eclipse by entering in a terminal the command eclipse &. (b) Enter a file space where you want Eclipse write all your Java files. (c) Close the Welcome window (by clicking the x). (d) Start a new Project by clicking Java Project following the File and then the New. Name the new project Week2, and press the Finish button. (e) Cancel the SVN Connectors. (f) Create a Class following File and New again. (g) Give the class the Name HelloWorld and press the Finish button. (h) Enter in the HellowWorld.java window the HelloWorld program. (i) Run it by clicking the white arrow in the green circle. (You have to click again okay in a pop-up window.) (j) Likewise, create a JUnit Test Case with JUnitExample (following the File and New again). (k) Copy the text from the link above into the new window. (l) Run the tests by clicking the white arrow in the green circle. (You have to click again okay in a pop-up window.) 3. Write a class Patient with the field variables name, id, address, phoneNumber all of type String. Generate a constructor, getters, setters, and a toString method following the Source tab in Eclipse. Add an equals methods. c© 2015, Manfred Kerber, School of Computer Science, University of Birmingham