View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.juneau.commons.collections;
18  
19  import static org.junit.jupiter.api.Assertions.*;
20  
21  import org.apache.juneau.*;
22  import org.junit.jupiter.api.*;
23  
24  class CacheMode_Test extends TestBase {
25  
26  	//====================================================================================================
27  	// parse(String)
28  	//====================================================================================================
29  
30  	@Test
31  	void a01_parse_none_lowercase() {
32  		assertEquals(CacheMode.NONE, CacheMode.parse("none"));
33  	}
34  
35  	@Test
36  	void a02_parse_none_uppercase() {
37  		assertEquals(CacheMode.NONE, CacheMode.parse("NONE"));
38  	}
39  
40  	@Test
41  	void a03_parse_none_mixedCase() {
42  		assertEquals(CacheMode.NONE, CacheMode.parse("None"));
43  	}
44  
45  	@Test
46  	void a04_parse_weak_lowercase() {
47  		assertEquals(CacheMode.WEAK, CacheMode.parse("weak"));
48  	}
49  
50  	@Test
51  	void a05_parse_weak_uppercase() {
52  		assertEquals(CacheMode.WEAK, CacheMode.parse("WEAK"));
53  	}
54  
55  	@Test
56  	void a06_parse_weak_mixedCase() {
57  		assertEquals(CacheMode.WEAK, CacheMode.parse("Weak"));
58  	}
59  
60  	@Test
61  	void a07_parse_full_lowercase() {
62  		assertEquals(CacheMode.FULL, CacheMode.parse("full"));
63  	}
64  
65  	@Test
66  	void a08_parse_full_uppercase() {
67  		assertEquals(CacheMode.FULL, CacheMode.parse("FULL"));
68  	}
69  
70  	@Test
71  	void a09_parse_full_mixedCase() {
72  		assertEquals(CacheMode.FULL, CacheMode.parse("Full"));
73  	}
74  
75  	@Test
76  	void a10_parse_null_returnsFull() {
77  		assertEquals(CacheMode.FULL, CacheMode.parse(null));
78  	}
79  
80  	@Test
81  	void a11_parse_invalid_returnsFull() {
82  		assertEquals(CacheMode.FULL, CacheMode.parse("invalid"));
83  		assertEquals(CacheMode.FULL, CacheMode.parse(""));
84  		assertEquals(CacheMode.FULL, CacheMode.parse("NON"));
85  		assertEquals(CacheMode.FULL, CacheMode.parse("WEA"));
86  	}
87  }
88