View Javadoc
1   /*
2    * Copyright (c) 2002-2025 Gargoyle Software Inc.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * https://www.apache.org/licenses/LICENSE-2.0
8    *
9    * Unless required by applicable law or agreed to in writing, software
10   * distributed under the License is distributed on an "AS IS" BASIS,
11   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12   * See the License for the specific language governing permissions and
13   * limitations under the License.
14   */
15  package org.htmlunit.libraries;
16  
17  import java.net.URL;
18  
19  import org.eclipse.jetty.server.Server;
20  import org.htmlunit.WebDriverTestCase;
21  import org.htmlunit.WebServerTestCase;
22  import org.htmlunit.junit.BrowserRunner;
23  import org.junit.AfterClass;
24  import org.junit.BeforeClass;
25  import org.junit.Test;
26  import org.junit.runner.RunWith;
27  import org.openqa.selenium.WebDriver;
28  
29  /**
30   * Tests for compatibility with <a href="http://www.curvycorners.net">curvyCorners</a>.
31   *
32   * @author Gareth Davis
33   * @author Ronald Brill
34   */
35  @RunWith(BrowserRunner.class)
36  public class CurvyCornersTest extends WebDriverTestCase {
37  
38      /** The server. */
39      protected static Server SERVER_;
40  
41      /**
42       * @throws Exception if an error occurs
43       */
44      @BeforeClass
45      public static void startSesrver() throws Exception {
46          SERVER_ = WebServerTestCase.createWebServer("src/test/resources/libraries/curvyCorners/1.2.9-beta/", null);
47      }
48  
49      /**
50       * @throws Exception if an error occurs
51       */
52      @AfterClass
53      public static void stopServer() throws Exception {
54          if (SERVER_ != null) {
55              SERVER_.stop();
56              SERVER_.destroy();
57              SERVER_ = null;
58          }
59      }
60  
61      /**
62       * @return the resource base URL
63       */
64      protected URL getBaseUrl() {
65          return URL_FIRST;
66      }
67  
68      /**
69       * @throws Exception if the test fails
70       */
71      @Test
72      public void demo() throws Exception {
73          doTest("demo.html");
74      }
75  
76      /**
77       * @throws Exception if the test fails
78       */
79      @Test
80      public void demo2() throws Exception {
81          doTest("demo2.html");
82      }
83  
84      private void doTest(final String filename) throws Exception {
85          final WebDriver driver = getWebDriver();
86          driver.get(getBaseUrl() + filename);
87      }
88  }