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.javascript.configuration;
16  
17  import org.htmlunit.javascript.HtmlUnitScriptable;
18  import org.junit.jupiter.api.Assertions;
19  import org.junit.jupiter.api.Test;
20  
21  /**
22   * Tests for {@link ClassConfiguration}.
23   *
24   * @author Chris Erskine
25   * @author Ahmed Ashour
26   * @author Ronald Brill
27   */
28  public class ClassConfigurationTest {
29  
30      /**
31       * @throws Exception on error
32       */
33      @Test
34      public void forJSFlagTrue() throws Exception {
35          final ClassConfiguration config1 = new ClassConfiguration(ConfigTestClass.class, null, true, null, "");
36          Assertions.assertTrue(config1.isJsObject(), "JSObject Flag should have been set");
37      }
38  
39      /**
40       * @throws Exception on error
41       */
42      @Test
43      public void forJSFlagFalse() throws Exception {
44          final ClassConfiguration config1 = new ClassConfiguration(ConfigTestClass.class, null, false, null, "");
45          Assertions.assertFalse(config1.isJsObject(), "JSObject Flag should not have been set");
46      }
47  
48      /**
49       * Test class.
50       */
51      protected class ConfigTestClass extends HtmlUnitScriptable {
52          private boolean test_ = false;
53  
54          /**
55           * Dummy function.
56           */
57          public void function() {
58          }
59  
60          /**
61           * @return boolean
62           */
63          public boolean jsxGet_test() {
64              return test_;
65          }
66  
67          /**
68           * @return boolean
69           */
70          public boolean jsxGet_getterOnly() {
71              return test_;
72          }
73  
74          /**
75           * @param testFlag - test value
76           */
77          public void jsxSet_test(final Boolean testFlag) {
78              test_ = testFlag;
79          }
80      }
81  }