Skip to content

Commit

Permalink
HtmlUnitTest.java readability
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Fuchs committed Feb 13, 2010
1 parent cf8d50f commit ee75f15
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions test/java/HtmlUnitTest.java
Expand Up @@ -4,6 +4,7 @@
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.regex.Pattern;

import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.MockWebConnection;
Expand All @@ -12,6 +13,12 @@
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import org.apache.commons.io.FileUtils;

/*
org.junit.ComparisonFailure:
Expected :<div id="drop_2" class="drop ui-droppable"></div>
Actual :<div id="drop_1" class="drop ui-droppable"></div>
*/

public class HtmlUnitTest {
protected WebClient client;
protected MockWebConnection connection;
Expand All @@ -31,15 +38,15 @@ public void testDragAndDrop () throws Exception {

HtmlPage page = client.getPage("http://localhost/index.html");
HtmlElement drag = (HtmlElement) page.getByXPath("//div[contains(@class, 'drag')]").get(0);
HtmlElement drop = (HtmlElement) page.getByXPath("//div[@id='drop_4']").get(0);
HtmlElement drop = (HtmlElement) page.getByXPath("//div[@id='drop_2']").get(0);

drag.mouseDown();
drop.mouseMove();
page = (HtmlPage) drop.mouseUp();
client.waitForBackgroundJavaScript(1000);

String log = page.executeJavaScript("$('#log').text()").getJavaScriptResult().toString();
assertEquals("<div class=\"drop ui-droppable\" id=\"drop_2\">", log);
assertEquals("<div id=\"drop_2\" class=\"drop ui-droppable\"></div>", log);
}

public void mockResponse(String path, String contentType) throws Exception {
Expand All @@ -50,4 +57,5 @@ public void mockResponse(String path, String contentType) throws Exception {
public String readFile(String name) throws IOException {
return FileUtils.readFileToString(new File(name));
}

}

0 comments on commit ee75f15

Please sign in to comment.