1 36 package org.columba.ristretto.testserver; 37 38 import java.util.Hashtable ; 39 import java.util.LinkedList ; 40 import java.util.List ; 41 import java.util.Map ; 42 43 public class SimpleTestServerSession implements TestServerSession { 44 45 protected Map dialogMap; 46 protected List log; 47 protected String helloResponse; 48 protected String quitCommand; 49 protected boolean close; 50 51 52 public SimpleTestServerSession(String helloResponse, String quitCommand) { 53 dialogMap = new Hashtable (); 54 log = new LinkedList (); 55 56 this.helloResponse = helloResponse; 57 this.quitCommand = quitCommand; 58 59 close = false; 60 } 61 62 public void addDialog(String client, String server) { 63 dialogMap.put(client, server); 64 } 65 66 69 public String next(String clientCommand) { 70 String response = (String ) dialogMap.get(clientCommand); 71 log.add(clientCommand); 72 log.add(response); 73 74 close = clientCommand.indexOf(quitCommand) != -1; 75 76 return response; 77 } 78 79 public List getLog() { 80 return log; 81 } 82 83 86 public String serverHelloResponse() { 87 return helloResponse; 88 } 89 90 93 public boolean closeConnection() { 94 return close; 95 } 96 97 } 98 | Popular Tags |