View Javadoc
1   /*
2    * Licensed under the GPL License. You may not use this file except in compliance with the License.
3    * You may obtain a copy of the License at
4    *
5    *   https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
6    *
7    * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
8    * WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
9    * PURPOSE.
10   */
11  package psiprobe.jsp;
12  
13  import static org.junit.jupiter.api.Assertions.assertEquals;
14  
15  import com.codebox.bean.JavaBeanTester;
16  
17  import org.junit.jupiter.api.Test;
18  
19  /**
20   * Tests for {@link Functions}.
21   */
22  class FunctionsTest {
23  
24    @Test
25    void testPrivateConstructor() {
26      JavaBeanTester.builder(Functions.class).testPrivateConstructor();
27    }
28  
29    @Test
30    void testSafeCookieNameNoQuotes() {
31      assertEquals("simpleName", Functions.safeCookieName("simpleName"));
32    }
33  
34    @Test
35    void testSafeCookieNameWithDoubleQuotes() {
36      assertEquals("name", Functions.safeCookieName("\"name\""));
37    }
38  
39    @Test
40    void testSafeCookieNameMultipleQuotes() {
41      assertEquals("name value", Functions.safeCookieName("\"name\" \"value\""));
42    }
43  
44    @Test
45    void testSafeCookieNameEmpty() {
46      assertEquals("", Functions.safeCookieName(""));
47    }
48  
49    @Test
50    void testSafeCookieNameOnlyQuotes() {
51      assertEquals("", Functions.safeCookieName("\"\""));
52    }
53  }