@Test(expected = UnsupportedOperationException.class) public void testAddAll2() throws Exception { Set<Integer> hashSet = CollectionFactory.makeSet(1, 4); IntSet sis = new SingletonIntSet(3); sis.addAll(hashSet); }
@Test public void testContainsAll1() throws Exception { IntSet sis = new SingletonIntSet(3); Set<Integer> hashSet = CollectionFactory.makeSet(new Integer[]{3}); assertTrue(sis.containsAll(hashSet)); assertTrue(hashSet.containsAll(sis)); hashSet.add(0); assertTrue(hashSet.containsAll(sis)); assertFalse(sis.containsAll(hashSet)); }
@Test public void testContainsAll1() throws Exception { intSet.add(1); intSet.add(4); Set<Integer> set = CollectionFactory.makeSet(1, 4, 7); assertFalse(intSet.containsAll(set)); assertTrue(set.containsAll(intSet)); }
@Test public void testAddAll2() throws Exception { intSet.addAll(CollectionFactory.makeSet(1, 4)); assertEquals(2, intSet.size()); }
@Test public void testForEachObject() { intSet.add(0); intSet.add(4); intSet.add(7); Set<Integer> results = new HashSet<>(); intSet.forEach((Consumer<? super Integer>) results::add); assertEquals(CollectionFactory.makeSet(0, 4, 7), results); }
@Test public void testForEachPrimitive() { intSet.add(0); intSet.add(4); intSet.add(7); Set<Integer> results = new HashSet<>(); intSet.forEach((IntConsumer) results::add); assertEquals(CollectionFactory.makeSet(0, 4, 7), results); }
@Test public void testIntSpliteratorForEachRemaining() { intSet.add(1); intSet.add(4); intSet.add(7); Set<Integer> results = new HashSet<>(); intSet.intSpliterator().forEachRemaining((IntConsumer) results::add); assertEquals(CollectionFactory.makeSet(1, 4, 7), results); }
@Test public void testEquals2() throws Exception { intSet.add(1); intSet.add(4); intSet.add(7); Set<Integer> hashSet = CollectionFactory.makeSet(1, 4); // Verify equals both ways assertNotEquals(intSet, hashSet); assertNotEquals(hashSet, intSet); hashSet.add(7); assertEquals(intSet, hashSet); assertEquals(hashSet, intSet); }
@Test public void testIntSpliteratorSplitTryAdvance() { intSet.add(1); intSet.add(4); intSet.add(7); Set<Integer> results = new HashSet<>(); Spliterator.OfInt spliterator = intSet.intSpliterator(); Spliterator.OfInt split = spliterator.trySplit(); assertNotNull(split); IntConsumer consumer = results::add; while (spliterator.tryAdvance(consumer)) { } while (split.tryAdvance(consumer)) { } assertEquals(CollectionFactory.makeSet(1, 4, 7), results); } }
@Test public void testRetainAll1() throws Exception { intSet.add(1); intSet.add(4); intSet.add(7); assertEquals(3, intSet.size()); // (0 - 4) IntSet rs = new RangeSet(5); assertTrue(intSet.retainAll(rs)); assertEquals(CollectionFactory.makeSet(1, 4), intSet); }
@Test public void testRemoveAll1() throws Exception { intSet.add(1); intSet.add(4); intSet.add(7); assertEquals(3, intSet.size()); // (1 - 4) IntSet rs = new RangeSet(5); assertTrue(intSet.removeAll(rs)); assertEquals(CollectionFactory.makeSet((Object) 7), intSet); }
@Test public void testRemoveIfObject() { intSet.add(1); intSet.add(4); intSet.add(7); assertFalse(intSet.removeIf((Integer i) -> i / 10 > 0)); assertEquals(3, intSet.size()); assertTrue(intSet.removeIf((Integer i) -> i > 3)); assertEquals(CollectionFactory.makeSet((Object) 1), intSet); }
@Test public void testRetainAll() throws Exception { intSet.add(1); intSet.add(4); intSet.add(7); assertEquals(3, intSet.size()); IntSet intSet2 = new SmallIntSet(); intSet2.add(4); intSet2.add(5); intSet2.add(7); intSet.retainAll(intSet2); assertEquals(CollectionFactory.makeSet(4, 7), intSet); }
@Override public void call() { JCacheManager jCacheManager = createJCacheManager(cm, this); InMemoryJCacheLoader<Integer, String> cacheLoader = new InMemoryJCacheLoader<Integer, String>(); cacheLoader.store(1, "v1").store(2, "v2"); MutableConfiguration<Integer, String> cfg = new MutableConfiguration<Integer, String>(); // JDK6 fails to compile when calling FactoryBuilder.factoryOf() :( cfg.setCacheLoaderFactory(new FactoryBuilder.SingletonFactory(cacheLoader)); Cache<Integer, String> cache = jCacheManager.createCache(cacheName, cfg); assertEquals(0, cacheLoader.getLoadCount()); CompletionListenerFuture future = new CompletionListenerFuture(); cache.loadAll(CollectionFactory.makeSet(1, 2), true, future); futureGet(future); assertEquals(2, cacheLoader.getLoadCount()); } });