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.annotation.Alerts;
24 import org.htmlunit.junit.annotation.HtmlUnitNYI;
25 import org.junit.jupiter.api.AfterAll;
26 import org.junit.jupiter.api.BeforeAll;
27 import org.junit.jupiter.api.Test;
28 import org.openqa.selenium.By;
29 import org.openqa.selenium.WebDriver;
30 import org.openqa.selenium.htmlunit.HtmlUnitDriver;
31
32
33
34
35
36
37 public class QuillTest extends WebDriverTestCase {
38
39
40 protected static Server SERVER_;
41
42
43
44
45 @BeforeAll
46 public static void startSesrver() throws Exception {
47 SERVER_ = WebServerTestCase.createWebServer("src/test/resources/libraries/quill/", null);
48 }
49
50
51
52
53 @AfterAll
54 public static void stopServer() throws Exception {
55 if (SERVER_ != null) {
56 SERVER_.stop();
57 SERVER_.destroy();
58 SERVER_ = null;
59 }
60 }
61
62
63
64
65 protected URL getBaseUrl() {
66 return URL_FIRST;
67 }
68
69
70
71
72 @Test
73 @Alerts("Bold Italic\\nHello World!\\nSome initial bold text")
74 @HtmlUnitNYI
75 public void basic() throws Exception {
76
77 doTest("QuillTest.html");
78 }
79
80 private void doTest(final String filename) throws Exception {
81 final WebDriver driver = getWebDriver();
82 if (driver instanceof HtmlUnitDriver) {
83 final WebClient webClient = ((HtmlUnitDriver) driver).getWebClient();
84 webClient.getOptions().setThrowExceptionOnScriptError(false);
85 }
86
87 driver.get(getBaseUrl() + filename);
88
89 String content = driver.findElement(By.tagName("body")).getText();
90 content = content.replace("\r", "").replace("\n", "\\n");
91 assertEquals(getExpectedAlerts()[0], content);
92 }
93 }