| 1 | /* |
|---|
| 2 | * To change this license header, choose License Headers in Project Properties. |
|---|
| 3 | * To change this template file, choose Tools | Templates |
|---|
| 4 | * and open the template in the editor. |
|---|
| 5 | */ |
|---|
| 6 | package tmcsim.client.cadclientgui.screens; |
|---|
| 7 | |
|---|
| 8 | import java.util.Vector; |
|---|
| 9 | import junit.framework.TestCase; |
|---|
| 10 | import java.io.File; |
|---|
| 11 | import java.io.FileWriter; |
|---|
| 12 | import java.io.IOException; |
|---|
| 13 | import java.io.PrintWriter; |
|---|
| 14 | |
|---|
| 15 | /** |
|---|
| 16 | * |
|---|
| 17 | * @author jdalbey |
|---|
| 18 | */ |
|---|
| 19 | public class LoginTest extends TestCase { |
|---|
| 20 | |
|---|
| 21 | public LoginTest(String testName) { |
|---|
| 22 | super(testName); |
|---|
| 23 | } |
|---|
| 24 | |
|---|
| 25 | @Override |
|---|
| 26 | protected void setUp() throws Exception { |
|---|
| 27 | super.setUp(); |
|---|
| 28 | } |
|---|
| 29 | |
|---|
| 30 | @Override |
|---|
| 31 | protected void tearDown() throws Exception { |
|---|
| 32 | super.tearDown(); |
|---|
| 33 | } |
|---|
| 34 | |
|---|
| 35 | /** |
|---|
| 36 | * Test of readNamesFile method, of class Login. |
|---|
| 37 | */ |
|---|
| 38 | public void testReadNamesFile() throws IOException { |
|---|
| 39 | System.out.println("readNamesFile"); |
|---|
| 40 | File file = File.createTempFile("temp", null); |
|---|
| 41 | PrintWriter writer = null; |
|---|
| 42 | try { |
|---|
| 43 | writer = new PrintWriter(file); |
|---|
| 44 | writer.println(" "); |
|---|
| 45 | writer.println(" Trainee, Jose "); |
|---|
| 46 | writer.close(); |
|---|
| 47 | } catch(Exception e) |
|---|
| 48 | {e.printStackTrace();} |
|---|
| 49 | |
|---|
| 50 | String studentNamesFile = file.getAbsolutePath(); |
|---|
| 51 | Vector<String> expResult = new Vector<String>(); |
|---|
| 52 | expResult.add("Trainee, Jose"); |
|---|
| 53 | Vector<String> result = Login.readNamesFile(studentNamesFile); |
|---|
| 54 | assertEquals(expResult, result); |
|---|
| 55 | } |
|---|
| 56 | |
|---|
| 57 | /** |
|---|
| 58 | * Test of reverseLastFirst method, of class Login. |
|---|
| 59 | */ |
|---|
| 60 | public void testReverseLastFirst() { |
|---|
| 61 | System.out.println("reverseLastFirst"); |
|---|
| 62 | String result = Login.reverseLastFirst("Trainee, Jose"); |
|---|
| 63 | assertEquals("Jose Trainee", result); |
|---|
| 64 | result = Login.reverseLastFirst(" Trainee, Jose "); |
|---|
| 65 | assertEquals("Jose Trainee", result); |
|---|
| 66 | result = Login.reverseLastFirst(" Smith , Bob "); |
|---|
| 67 | assertEquals("Bob Smith", result); |
|---|
| 68 | result = Login.reverseLastFirst("Nocomma Case"); |
|---|
| 69 | assertEquals("Nocomma Case", result); |
|---|
| 70 | result = Login.reverseLastFirst(" "); |
|---|
| 71 | assertEquals(" ", result); |
|---|
| 72 | } |
|---|
| 73 | |
|---|
| 74 | } |
|---|