2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.objcache.guava;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotSame;
12 import static org.junit.Assert.assertSame;
14 import org.junit.Before;
15 import org.junit.Test;
16 import org.opendaylight.yangtools.objcache.ObjectCache;
17 import org.opendaylight.yangtools.objcache.ObjectCacheFactory;
19 public class GuavaObjectCacheTest {
20 private ObjectCache cache;
24 cache = ObjectCacheFactory.getObjectCache(String.class);
28 public void testCorrectWiring() {
29 assertEquals(GuavaObjectCache.class, cache.getClass());
33 public void testInitialReference() {
34 final String s1 = "abcd";
35 final String s2 = cache.getReference(s1);
40 // This test is based on using different references
41 @SuppressWarnings("RedundantStringConstructorCall")
42 public void testMultipleReferences() {
43 final String s1 = "abcd";
44 final String s2 = new String(s1);
48 assertNotSame(s1, s2);
50 assertSame(s1, cache.getReference(s1));
51 assertSame(s1, cache.getReference(s2));
52 assertNotSame(s2, cache.getReference(s2));