1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.commons.compress.utils;
20
21 import static org.junit.jupiter.api.Assertions.assertFalse;
22 import static org.junit.jupiter.api.Assertions.assertThrows;
23
24 import java.util.NoSuchElementException;
25
26 import org.junit.jupiter.api.Test;
27
28
29
30
31
32
33 public class ServiceLoaderIteratorTest {
34
35 @Test
36 public void testHasNextReturnsFalse() {
37 final Class<Object> clasz = Object.class;
38 final ServiceLoaderIterator<Object> serviceLoaderIterator = new ServiceLoaderIterator<>(clasz);
39 final boolean result = serviceLoaderIterator.hasNext();
40 assertFalse(result);
41 }
42
43 @Test
44 public void testNextThrowsNoSuchElementException() {
45 final Class<String> clasz = String.class;
46 final ServiceLoaderIterator<String> serviceLoaderIterator = new ServiceLoaderIterator<>(clasz);
47 assertThrows(NoSuchElementException.class, () -> serviceLoaderIterator.next());
48 }
49
50 @Test
51 public void testRemoveThrowsUnsupportedOperationException() {
52 final Class<Integer> clasz = Integer.class;
53 final ServiceLoaderIterator<Integer> serviceLoaderIterator = new ServiceLoaderIterator<>(clasz);
54 assertThrows(UnsupportedOperationException.class, () -> serviceLoaderIterator.remove());
55 }
56
57 }