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 org.eclipse.jetty.server.Server;
18  import org.htmlunit.WebDriverTestCase;
19  import org.htmlunit.WebServerTestCase;
20  import org.htmlunit.junit.BrowserRunner;
21  import org.htmlunit.junit.annotation.HtmlUnitNYI;
22  import org.junit.AfterClass;
23  import org.junit.BeforeClass;
24  import org.junit.Test;
25  import org.junit.runner.RunWith;
26  
27  /**
28   * Tests for Apache MyFaces.
29   *
30   * @author Ronald Brill
31   */
32  @RunWith(BrowserRunner.class)
33  public class MyFacesTest extends WebDriverTestCase {
34  
35      /** The server. */
36      protected static Server SERVER_;
37  
38      /**
39       * @throws Exception if an error occurs
40       */
41      @BeforeClass
42      public static void startSesrver() throws Exception {
43          SERVER_ = WebServerTestCase.createWebServer("src/test/resources/libraries/myfaces/4_0_2", null);
44      }
45  
46      /**
47       * @throws Exception if an error occurs
48       */
49      @AfterClass
50      public static void stopServer() throws Exception {
51          if (SERVER_ != null) {
52              SERVER_.stop();
53              SERVER_.destroy();
54              SERVER_ = null;
55          }
56      }
57  
58      /**
59       * @throws Exception if the test fails
60       */
61      @Test
62      @HtmlUnitNYI(CHROME = "org.htmlunit.ScriptException: syntax error",
63              EDGE = "org.htmlunit.ScriptException: syntax error",
64              FF = "org.htmlunit.ScriptException: syntax error",
65              FF_ESR = "org.htmlunit.ScriptException: syntax error")
66      public void checkForJsCompileErrors_4_0_2() throws Exception {
67          try {
68              getWebDriver().get(URL_FIRST + "index.html");
69          }
70          catch (final Exception e) {
71              if (getExpectedAlerts().length > 0) {
72                  assertTrue(e.getMessage(), e.getMessage().startsWith(getExpectedAlerts()[0]));
73                  return;
74              }
75  
76              throw e;
77          }
78      }
79  }