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.spi;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertFalse;
12 import static org.junit.Assert.assertNull;
13 import static org.junit.Assert.assertSame;
14 import static org.junit.Assert.assertTrue;
16 import org.junit.After;
17 import org.junit.Before;
18 import org.junit.Test;
19 import org.opendaylight.yangtools.objcache.spi.AbstractObjectCache.SoftKey;
21 import com.google.common.base.FinalizableReferenceQueue;
23 public class SoftKeyTest {
24 private FinalizableReferenceQueue queue;
29 queue = new FinalizableReferenceQueue();
33 public void tearDown() {
38 public void testEquals() {
39 final String str = "foo";
41 final SoftKey<?> key = new SoftKey<String>(str, queue) {
43 public void finalizeReferent() {
48 assertSame(str, key.get());
49 assertEquals(str.hashCode(), key.hashCode());
50 assertTrue(key.equals(str));
52 assertNull(key.get());
53 assertEquals(str.hashCode(), key.hashCode());
54 assertFalse(key.equals(str));