1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.htmlunit.libraries;
16
17 import java.net.URL;
18
19 import org.eclipse.jetty.server.Server;
20 import org.htmlunit.WebClient;
21 import org.htmlunit.WebDriverTestCase;
22 import org.htmlunit.WebServerTestCase;
23 import org.htmlunit.junit.BrowserRunner;
24 import org.htmlunit.junit.annotation.Alerts;
25 import org.htmlunit.junit.annotation.HtmlUnitNYI;
26 import org.junit.AfterClass;
27 import org.junit.BeforeClass;
28 import org.junit.Test;
29 import org.junit.runner.RunWith;
30 import org.openqa.selenium.By;
31 import org.openqa.selenium.WebDriver;
32 import org.openqa.selenium.htmlunit.HtmlUnitDriver;
33
34
35
36
37
38
39 @RunWith(BrowserRunner.class)
40 public class QuillTest extends WebDriverTestCase {
41
42
43 protected static Server SERVER_;
44
45
46
47
48 @BeforeClass
49 public static void startSesrver() throws Exception {
50 SERVER_ = WebServerTestCase.createWebServer("src/test/resources/libraries/quill/", null);
51 }
52
53
54
55
56 @AfterClass
57 public static void stopServer() throws Exception {
58 if (SERVER_ != null) {
59 SERVER_.stop();
60 SERVER_.destroy();
61 SERVER_ = null;
62 }
63 }
64
65
66
67
68 protected URL getBaseUrl() {
69 return URL_FIRST;
70 }
71
72
73
74
75 @Test
76 @Alerts("Bold Italic\\nHello World!\\nSome initial bold text")
77 @HtmlUnitNYI
78 public void basic() throws Exception {
79
80 doTest("QuillTest.html");
81 }
82
83 private void doTest(final String filename) throws Exception {
84 final WebDriver driver = getWebDriver();
85 if (driver instanceof HtmlUnitDriver) {
86 final WebClient webClient = ((HtmlUnitDriver) driver).getWebClient();
87 webClient.getOptions().setThrowExceptionOnScriptError(false);
88 }
89
90 driver.get(getBaseUrl() + filename);
91
92 String content = driver.findElement(By.tagName("body")).getText();
93 content = content.replace("\r", "").replace("\n", "\\n");
94 assertEquals(getExpectedAlerts()[0], content);
95 }
96 }