package com.thoughtworks.selenium;

import junit.framework.*;

import org.openqa.selenium.server.*;
import org.openqa.selenium.server.browserlaunchers.*;

/**
 * A test of the Apache MyFaces JSF AJAX auto-suggest sandbox application at www.irian.at.
 *  
 * 
 *  @author danielf
 *
 */
public class ApacheMyFacesSuggestTest extends TestCase {

    DefaultSelenium selenium;
    
    protected void setUp() throws Exception {
    }
    
    public void testAJAXFirefox() throws Throwable {
        selenium = new DefaultSelenium("localhost", SeleniumServer.DEFAULT_PORT, "*firefox", "http://www.irian.at");
        selenium.start();
        ajaxTester();
    }
    
    public void testAJAXIExplore() throws Throwable {
        if (!WindowsUtils.thisIsWindows()) return;
        selenium = new DefaultSelenium("localhost", SeleniumServer.DEFAULT_PORT, "*iexplore", "http://www.irian.at");
        selenium.start();
        ajaxTester();
    }
    
    public void ajaxTester() throws Throwable {
		String inputId = "ac4";
		String updateId = "ac4update";

        selenium.open("http://www.irian.at/selenium-server/tests/html/ajax/ajax_autocompleter2_test.html");
		selenium.keyPress(inputId, "\\74");
		Thread.sleep(500);
		selenium.keyPress(inputId, "\\97");
		selenium.keyPress(inputId, "\\110");
		Thread.sleep(500);
		assertEquals("Jane Agnews", selenium.getText(updateId));
		selenium.keyPress(inputId, "\\9");
		Thread.sleep(500);
		assertEquals("Jane Agnews", selenium.getValue(inputId));
    }

	public void tearDown() {
        if (selenium == null) return;
        selenium.stop();
    }
}

@@ -649,35 +649,528 @@
 art();%0D%0A
-        ajaxTester(
+%0D%0A%09%09String inputId = %22ac4%22;%0D%0A%09%09String updateId = %22ac4update%22;%0D%0A%0D%0A        selenium.open(%22http://www.irian.at/selenium-server/tests/html/ajax/ajax_autocompleter2_test.html%22);%0D%0A%09%09selenium.keyPress(inputId, %22%5C%5C74%22);%0D%0A%09%09Thread.sleep(500);%0D%0A%09%09selenium.keyPress(inputId, %22%5C%5C97%22);%0D%0A%09%09selenium.keyPress(inputId, %22%5C%5C110%22);%0D%0A%09%09Thread.sleep(500);%0D%0A%09%09assertEquals(%22Jane Agnews%22, selenium.getText(updateId));%0D%0A%09%09selenium.keyPress(inputId, %22%5C%5C9%22);%0D%0A%09%09Thread.sleep(500);%0D%0A%09%09assertEquals(%22Jane Agnews%22, selenium.getValue(inputId)
 );%0D%0A    
@@ -1435,91 +1435,8 @@
 );%0D%0A
-        ajaxTester();%0D%0A    %7D%0D%0A    %0D%0A    public void ajaxTester() throws Throwable %7B
 %0D%0A%09%09
@@ -1612,32 +1612,63 @@
 %0A%09%09selenium.
-keyPress
+type(inputId, %22J%22);%0D%0A%09%09selenium.keyDown
 (inputId, %22%5C
@@ -1704,32 +1704,28 @@
 %0A%09%09selenium.
-keyPress
+type
 (inputId, %22%5C
@@ -1715,36 +1715,35 @@
 .type(inputId, %22
-%5C%5C97
+Jan
 %22);%0D%0A%09%09selenium.
@@ -1737,37 +1737,36 @@
 %0D%0A%09%09selenium.key
-Press
+Down
 (inputId, %22%5C%5C110
@@ -1858,37 +1858,36 @@
 %0D%0A%09%09selenium.key
-Press
+Down
 (inputId, %22%5C%5C9%22)
@@ -1875,33 +1875,34 @@
 own(inputId, %22%5C%5C
-9
+13
 %22);%0D%0A%09%09Thread.sl
@@ -1979,16 +1979,20 @@
 %0A    %7D%0D%0A
+    
 %0D%0A%09publi

change ajax test case of Java client driver, in order to make build faster. NOTE: you may need update local maven repository with latest version of Selenium-Core, otherwise the new test case may fail.