|
15 | 15 | */
|
16 | 16 | package org.culturegraph.mf.stream.pipe;
|
17 | 17 |
|
18 |
| -import static org.junit.Assert.assertEquals; |
| 18 | +import static org.mockito.Mockito.verify; |
19 | 19 |
|
20 |
| -import org.culturegraph.mf.framework.DefaultObjectReceiver; |
| 20 | +import org.culturegraph.mf.framework.ObjectReceiver; |
| 21 | +import org.junit.After; |
| 22 | +import org.junit.Before; |
21 | 23 | import org.junit.Test;
|
| 24 | +import org.mockito.Mock; |
| 25 | +import org.mockito.MockitoAnnotations; |
22 | 26 |
|
23 | 27 | /**
|
24 | 28 | * Tests {@link Utf8Normalizer}.
|
|
28 | 32 | */
|
29 | 33 | public final class Utf8NormalizerTest {
|
30 | 34 |
|
31 |
| - // The umlauts in this string are composed of two characters (u and ", e.g.): |
32 |
| - private static final String INPUT_STR = |
| 35 | + private static final String STRING_WITH_DIACRITICS = |
33 | 36 | "Bauer, Sigmund: Über den Einfluß der Ackergeräthe auf den Reinertrag.";
|
34 | 37 |
|
35 |
| - // The umlauts in this string are individual characters: |
36 |
| - private static final String OUTPUT_STR = |
| 38 | + private static final String STRING_WITH_PRECOMPOSED_CHARS = |
37 | 39 | "Bauer, Sigmund: Über den Einfluß der Ackergeräthe auf den Reinertrag.";
|
38 | 40 |
|
39 |
| - @Test |
40 |
| - public void testNormalization() { |
41 |
| - final Utf8Normalizer normalizer = new Utf8Normalizer(); |
| 41 | + private Utf8Normalizer normalizer; |
| 42 | + |
| 43 | + @Mock |
| 44 | + private ObjectReceiver<String> receiver; |
| 45 | + |
| 46 | + @Before |
| 47 | + public void setup() { |
| 48 | + MockitoAnnotations.initMocks(this); |
42 | 49 |
|
43 |
| - normalizer.setReceiver(new DefaultObjectReceiver<String>() { |
44 |
| - @Override |
45 |
| - public void process(final String obj) { |
46 |
| - assertEquals(OUTPUT_STR, obj); |
47 |
| - } |
48 |
| - }); |
| 50 | + normalizer = new Utf8Normalizer(); |
| 51 | + normalizer.setReceiver(receiver); |
| 52 | + } |
| 53 | + |
| 54 | + @After |
| 55 | + public void cleanup() { |
| 56 | + normalizer.closeStream(); |
| 57 | + } |
| 58 | + |
| 59 | + @Test |
| 60 | + public void testShouldReplaceDiacriticsWithPrecomposedChars() { |
| 61 | + normalizer.process(STRING_WITH_DIACRITICS); |
49 | 62 |
|
50 |
| - normalizer.process(INPUT_STR); |
| 63 | + verify(receiver).process(STRING_WITH_PRECOMPOSED_CHARS); |
51 | 64 | }
|
52 | 65 |
|
53 | 66 | }
|
0 commit comments