2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Copyright (C) 2017 Amdocs
8 * =============================================================================
9 * Modifications Copyright (C) 2018 IBM.
10 * =============================================================================
11 * Licensed under the Apache License, Version 2.0 (the "License");
12 * you may not use this file except in compliance with the License.
13 * You may obtain a copy of the License at
15 * http://www.apache.org/licenses/LICENSE-2.0
17 * Unless required by applicable law or agreed to in writing, software
18 * distributed under the License is distributed on an "AS IS" BASIS,
19 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 * See the License for the specific language governing permissions and
21 * limitations under the License.
23 * ============LICENSE_END=========================================================
26 package org.onap.appc.cache.impl;
30 import org.junit.Assert;
31 import org.junit.Before;
32 import org.junit.Test;
33 import org.powermock.reflect.Whitebox;
35 public class LRUCacheTest {
37 private LRUCache cache;
41 cache = new LRUCache(20);
45 public void testConstructor() throws Exception {
46 Map internalMap = Whitebox.getInternalState(cache, "map");
47 Assert.assertTrue(internalMap != null);
48 Assert.assertTrue(internalMap.size() == 0);
52 public void testGetAndPutObject() throws Exception {
53 String key = "testing key";
54 Assert.assertTrue(cache.getObject(key) == null);
56 String value = "testing value";
57 cache.putObject(key, value);
58 Map internalMap = Whitebox.getInternalState(cache, "map");
59 Assert.assertTrue(internalMap.containsKey(key));
60 Assert.assertTrue(internalMap.containsValue(value));
61 Assert.assertTrue(internalMap.size() == 1);
63 Assert.assertEquals(value, cache.getObject(key));