|
| 1 | +/* |
| 2 | + * Copyright 2015 Ben Manes. All Rights Reserved. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | +package com.github.benmanes.caffeine.guava; |
| 17 | + |
| 18 | +import static org.junit.Assert.assertEquals; |
| 19 | +import static org.ops4j.pax.exam.CoreOptions.bundle; |
| 20 | +import static org.ops4j.pax.exam.CoreOptions.junitBundles; |
| 21 | +import static org.ops4j.pax.exam.CoreOptions.mavenBundle; |
| 22 | +import static org.ops4j.pax.exam.CoreOptions.options; |
| 23 | + |
| 24 | +import org.junit.Test; |
| 25 | +import org.junit.runner.RunWith; |
| 26 | +import org.ops4j.pax.exam.Configuration; |
| 27 | +import org.ops4j.pax.exam.Option; |
| 28 | +import org.ops4j.pax.exam.junit.PaxExam; |
| 29 | +import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy; |
| 30 | +import org.ops4j.pax.exam.spi.reactors.PerMethod; |
| 31 | + |
| 32 | +import com.github.benmanes.caffeine.cache.Caffeine; |
| 33 | +import com.google.common.cache.CacheLoader; |
| 34 | +import com.google.common.cache.LoadingCache; |
| 35 | + |
| 36 | +/** |
| 37 | + * @author [email protected] (Ben Manes) |
| 38 | + */ |
| 39 | +@RunWith(PaxExam.class) |
| 40 | +@ExamReactorStrategy(PerMethod.class) |
| 41 | +public final class OSGiTest { |
| 42 | + |
| 43 | + @Configuration |
| 44 | + public Option[] config() { |
| 45 | + return options( |
| 46 | + junitBundles(), |
| 47 | + bundle("file:" + System.getProperty("caffeine.osgi.jar")), |
| 48 | + bundle("file:" + System.getProperty("caffeine-guava.osgi.jar")), |
| 49 | + mavenBundle("com.google.guava", "guava", System.getProperty("guava.osgi.version"))); |
| 50 | + } |
| 51 | + |
| 52 | + @Test |
| 53 | + public void sanity() { |
| 54 | + CacheLoader<Integer, Integer> loader = new CacheLoader<Integer, Integer>() { |
| 55 | + @Override public Integer load(Integer key) { |
| 56 | + return -key; |
| 57 | + } |
| 58 | + }; |
| 59 | + LoadingCache<Integer, Integer> cache = CaffeinatedGuava.build(Caffeine.newBuilder(), loader); |
| 60 | + assertEquals(-1, cache.getUnchecked(1).intValue()); |
| 61 | + } |
| 62 | +} |
0 commit comments