Skip to content

Commit 06ca8db

Browse files
author
mgeipel
committed
Merge branch 'master' of ssh://github.com/culturegraph/metafacture-core into HEAD
2 parents d9c3550 + 5564d89 commit 06ca8db

File tree

7 files changed

+86
-64
lines changed

7 files changed

+86
-64
lines changed

pom.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,11 @@
157157
<plugin>
158158
<groupId>org.apache.maven.plugins</groupId>
159159
<artifactId>maven-release-plugin</artifactId>
160-
<version>2.4</version>
160+
<version>2.4</version><!--$NO-MVN-MAN-VER$-->
161+
<!-- m2e complains about a different plugin version
162+
being specified in the parent pom. However,
163+
this is not actually problem for maven. So,
164+
we can ignore the warning. -->
161165
</plugin>
162166

163167
</plugins>

quality_assurance/checkstyle_rules.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@
111111
<module name="Regexp"/>
112112
<module name="JavadocType"/>
113113
</module>
114-
<module name="StrictDuplicateCode"/>
114+
<module name="StrictDuplicateCode">
115+
<property name="fileExtensions" value="java"/>
116+
</module>
115117
<module name="Header">
116118
<property name="headerFile" value="${basedir}/quality_assurance/java-header.txt"/>
117119
<property name="fileExtensions" value="java"/>

src/test/java/org/culturegraph/mf/morph/maps/JndiSqlMapTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
*/
3030
public final class JndiSqlMapTest {
3131
@Test
32-
public void name() throws IOException {
32+
public void testGetDatasource() throws IOException {
3333
final JndiSqlMap map = new JndiSqlMap();
3434
map.setDatasource("testDataSource");
3535

src/test/java/org/culturegraph/mf/stream/pipe/StreamBufferTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import org.culturegraph.mf.framework.StreamReceiver;
2222
import org.culturegraph.mf.stream.sink.EventList;
2323
import org.culturegraph.mf.stream.sink.StreamValidator;
24-
import org.junit.Ignore;
2524
import org.junit.Test;
2625

2726

src/test/java/org/culturegraph/mf/stream/pipe/StreamLoggerTest.java

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,42 +15,52 @@
1515
*/
1616
package org.culturegraph.mf.stream.pipe;
1717

18-
import org.culturegraph.mf.stream.pipe.StreamLogger;
19-
import org.junit.Ignore;
20-
import org.junit.Test;
18+
import static org.junit.Assert.fail;
19+
20+
import org.culturegraph.mf.exceptions.FormatException;
21+
import org.culturegraph.mf.framework.StreamReceiver;
22+
import org.culturegraph.mf.stream.sink.EventList;
23+
import org.culturegraph.mf.stream.sink.StreamValidator;
24+
import org.junit.Test;
2125

2226

2327
/**
2428
* Tests if {@link StreamLogger} is correctly piping all events.
2529
*
26-
* @author Markus Michael Geipel
30+
* @author Markus Michael Geipel, Christoph Böhme
2731
*/
2832

2933
public final class StreamLoggerTest {
3034

3135
@Test
32-
@Ignore
3336
public void testCorrectPipeFunction() {
34-
// final ResourceOpener opener = new ResourceOpener();
35-
// final PicaDecoder picaDecoder = new PicaDecoder();
36-
// final StringWriter referenceWriter = new StringWriter();
37-
//
38-
// opener.setReceiver(new LineReader())
39-
// .setReceiver(picaDecoder)
40-
// .setReceiver(new StreamWriter(referenceWriter));
41-
//
42-
// opener.process(DataFilePath.PND_PICA);
43-
// opener.closeStream();
44-
//
45-
// final StringWriter finalWriter = new StringWriter();
46-
//
47-
// picaDecoder.setReceiver(new StreamLogger("test-logger"))
48-
// .setReceiver(new StreamWriter(finalWriter));
49-
//
50-
// opener.process(DataFilePath.PND_PICA);
51-
// opener.closeStream();
52-
//
53-
// Assert.assertEquals(referenceWriter.toString(), finalWriter.toString());
54-
//
55-
}
37+
final EventList list = new EventList();
38+
execTestEvents(list);
39+
40+
final StreamValidator validator = new StreamValidator(list.getEvents());
41+
final StreamLogger logger = new StreamLogger("test-logger");
42+
logger.setReceiver(validator);
43+
44+
try {
45+
execTestEvents(logger);
46+
logger.closeStream();
47+
} catch (FormatException e) {
48+
fail("Logger did not forward data as expected: " + e);
49+
}
50+
51+
}
52+
53+
private void execTestEvents(final StreamReceiver receiver) {
54+
receiver.startRecord("1");
55+
receiver.literal("l1", "value1");
56+
receiver.literal("l1", "value2");
57+
receiver.startEntity("e1");
58+
receiver.literal("l2", "value3");
59+
receiver.endEntity();
60+
receiver.endRecord();
61+
receiver.startRecord("2");
62+
receiver.literal("l3", "value4");
63+
receiver.endRecord();
64+
}
65+
5666
}

src/test/java/org/culturegraph/mf/stream/pipe/StreamTeeTest.java

Lines changed: 39 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -15,44 +15,53 @@
1515
*/
1616
package org.culturegraph.mf.stream.pipe;
1717

18-
import org.culturegraph.mf.framework.Tee;
19-
import org.junit.Ignore;
20-
import org.junit.Test;
18+
import static org.junit.Assert.fail;
19+
20+
import org.culturegraph.mf.exceptions.FormatException;
21+
import org.culturegraph.mf.framework.StreamReceiver;
22+
import org.culturegraph.mf.stream.sink.EventList;
23+
import org.culturegraph.mf.stream.sink.StreamValidator;
24+
import org.junit.Test;
2125

2226

2327
/**
24-
* Tests if {@link Tee} is correctly piping all events.
28+
* Tests if {@link StreamTee} is correctly piping all events.
2529
*
2630
* @author Markus Michael Geipel
2731
*
2832
*/
2933
public final class StreamTeeTest {
3034

3135
@Test
32-
@Ignore
33-
public void testCorrectTeeFunction() {
34-
// final ResourceOpener opener = new ResourceOpener();
35-
// final PicaDecoder picaDecoder = new PicaDecoder();
36-
//
37-
// final StringWriter referenceWriter = new StringWriter();
38-
//
39-
// opener.setReceiver(new LineReader())
40-
// .setReceiver(picaDecoder)
41-
// .setReceiver(new StreamWriter(referenceWriter));
42-
//
43-
// opener.process(DataFilePath.PND_PICA);
44-
// opener.closeStream();
45-
//
46-
// final StringWriter finalWriter1 = new StringWriter();
47-
// final StringWriter finalWriter2 = new StringWriter();
48-
//
49-
// picaDecoder.setReceiver(new StreamTee())
50-
// .setReceivers(new StreamWriter(finalWriter1), new StreamWriter(finalWriter2));
51-
//
52-
// opener.process(DataFilePath.PND_PICA);
53-
// opener.closeStream();
54-
//
55-
// Assert.assertEquals(referenceWriter.toString(), finalWriter1.toString());
56-
// Assert.assertEquals(referenceWriter.toString(), finalWriter2.toString());
57-
}
36+
public void testCorrectTeeFunction() {
37+
final EventList list = new EventList();
38+
execTestEvents(list);
39+
40+
final StreamValidator validator1 = new StreamValidator(list.getEvents());
41+
final StreamValidator validator2 = new StreamValidator(list.getEvents());
42+
final StreamTee tee = new StreamTee();
43+
tee.addReceiver(validator1)
44+
.addReceiver(validator2);
45+
46+
try {
47+
execTestEvents(tee);
48+
tee.closeStream();
49+
} catch (FormatException e) {
50+
fail("Tee did not forward data as expected: " + e);
51+
}
52+
}
53+
54+
private void execTestEvents(final StreamReceiver receiver) {
55+
receiver.startRecord("1");
56+
receiver.literal("l1", "value1");
57+
receiver.literal("l1", "value2");
58+
receiver.startEntity("e1");
59+
receiver.literal("l2", "value3");
60+
receiver.endEntity();
61+
receiver.endRecord();
62+
receiver.startRecord("2");
63+
receiver.literal("l3", "value4");
64+
receiver.endRecord();
65+
}
66+
5867
}

src/test/java/org/culturegraph/mf/util/tries/SetReplaceTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@
2828
*/
2929
public final class SetReplaceTest {
3030

31-
32-
3331
@Test
34-
public void testReplece() {
32+
public void testReplace() {
3533

3634
final SetReplacer setReplace = new SetReplacer();
3735
final String text = "auf sylt mit super krabben entsafter und apfel";

0 commit comments

Comments
 (0)