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