public static void doJoinGame(WebConversation client) throws Exception { System.out.println("Joining game..."); WebResponse response = client.getResponse("http://127.0.0.1:8080/games/euchre?action=joinGame"); for (String name : response.getHeaderFieldNames()) { System.out.println( "header: name=" + name + ", value=" + Arrays.toString(response.getHeaderFields(name))); } System.out.println("response code=" + response.getResponseCode()); for (String name : response.getNewCookieNames()) { System.out.println( "new cookie: name=" + name + ", value=" + response.getNewCookieValue(name)); } System.out.println("text=" + response.getText()); }
public static void doAnonymousLogin(WebConversation client, String nickname) throws Exception { System.out.println("Logging in anonymously..."); PostMethodWebRequest request = new PostMethodWebRequest("http://127.0.0.1:8080/games/anonLogin"); request.setParameter("nickname", nickname); WebResponse response = client.getResponse(request); for (String name : response.getHeaderFieldNames()) { System.out.println( "header: name=" + name + ", value=" + Arrays.toString(response.getHeaderFields(name))); } System.out.println("response code=" + response.getResponseCode()); for (String name : response.getNewCookieNames()) { System.out.println( "new cookie: name=" + name + ", value=" + response.getNewCookieValue(name)); } System.out.println("text=" + response.getText()); }