/** * {@inheritDoc} */ @Override public ClassLoader getDefaultClassLoader() { return ClassLoading.getDefaultClassLoader(); }
@Override public Iterable<? extends Map.Entry<? extends K, ? extends V>> apply(final Iterable<? extends K> keys) { int size = CollectionUtil.findBestCollectionSize(keys, 1); // in our current implementation, we have one entry all the time List<Map.Entry<K, V>> computeResult = new ArrayList<>(size); for (K key : keys) { computeResult.add(new AbstractMap.SimpleImmutableEntry<>(key, null)); } return computeResult; } }
public static <V> Matcher<Supplier<V>> holding(final V value) { return holding(equalTo(value)); }
@Test public void testNullReadArray() { ByteBufferInputStream stream = createStream(); try { stream.read(null, 0, 0); fail("Expected NullPointerException"); } catch (NullPointerException e) { //expected } }
/** * Constructs an instance of XmlConfiguration from the given XML DOM. * <p> * The default ClassLoader will first try to use the thread context class loader, followed by the ClassLoader that * loaded the Ehcache classes. * * @param xml XML Document Object Model * * @throws XmlConfigurationException if anything went wrong parsing the XML */ public XmlConfiguration(Document xml) throws XmlConfigurationException { this(xml, ClassLoading.getDefaultClassLoader()); }
@Test public void findBestCollectionSize_notSizeable() { int size = CollectionUtil.findBestCollectionSize(() -> null, 100); assertThat(size).isEqualTo(100); } }
@Test public void testNegativeOffsetAndLength() { ByteBufferInputStream stream = createStream(); try { stream.read(new byte[32], -1, -1); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { //expected } }
/** * Constructs an instance of XmlConfiguration mapping to the XML file located at {@code url}. * <p> * The default ClassLoader will first try to use the thread context class loader, followed by the ClassLoader that * loaded the Ehcache classes. * * @param url URL pointing to the XML file's location * * @throws XmlConfigurationException if anything went wrong parsing the XML */ public XmlConfiguration(URL url) throws XmlConfigurationException { this(url, ClassLoading.getDefaultClassLoader()); }
@Test public void testMaxOffsetAndMaxLength() { ByteBufferInputStream stream = createStream(); try { stream.read(new byte[32], Integer.MAX_VALUE, Integer.MAX_VALUE); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { //expected } }
@Override public final ClassLoader getClassLoader() { ClassLoader classLoader = cacheBinding.getCache().getRuntimeConfiguration().getClassLoader(); return classLoader == null ? ClassLoading.getDefaultClassLoader() : classLoader; }
@Test public void testMinOffsetAndUnitLength() { ByteBufferInputStream stream = createStream(); try { stream.read(new byte[32], Integer.MIN_VALUE, 1); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { //expected } }
@Test public void testUnitOffsetAndMinLength() { ByteBufferInputStream stream = createStream(); try { stream.read(new byte[32], 1, Integer.MIN_VALUE); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { //expected } }
@Test public void testZeroOffsetAndExcessiveLength() { ByteBufferInputStream stream = createStream(); try { stream.read(new byte[32], 0, 33); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { //expected } }
@Test public void testExcessiveOffsetAndLegalLength() { ByteBufferInputStream stream = createStream(); try { stream.read(new byte[32], 33, 4); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { //expected } }
@Test public void testNegativeOffsetAndZeroLength() { ByteBufferInputStream stream = createStream(); try { stream.read(new byte[32], -1, 0); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { //expected } }
@Test public void testMaximalOffsetAndFiniteLength() { ByteBufferInputStream stream = createStream(); try { stream.read(new byte[32], 32, 4); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { //expected } }
@Test public void testNegativeOffsetAndMaxLength() { ByteBufferInputStream stream = createStream(); try { stream.read(new byte[32], -1, Integer.MAX_VALUE); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { //expected } }
@Test public void testZeroOffsetAndNegativeLength() { ByteBufferInputStream stream = createStream(); try { stream.read(new byte[32], 0, -1); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { //expected } }
@Test public void testExcessiveOffsetAndZeroLength() { ByteBufferInputStream stream = createStream(); try { stream.read(new byte[32], 33, 0); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { //expected } }
@Test public void testUnitOffsetAndMaxLength() { ByteBufferInputStream stream = createStream(); try { stream.read(new byte[32], 1, Integer.MAX_VALUE); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { //expected } }