Skip to content

Commit 90fd52e

Browse files
author
mgeipel
committed
imports reorganized, warnings removed, autoboxing removed
1 parent 7d42461 commit 90fd52e

File tree

5 files changed

+285
-289
lines changed

5 files changed

+285
-289
lines changed
Lines changed: 71 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
/**
2-
*
3-
*/
1+
/**
2+
*
3+
*/
44
/*
55
* Copyright 2013 Deutsche Nationalbibliothek
66
*
@@ -16,71 +16,71 @@
1616
* See the License for the specific language governing permissions and
1717
* limitations under the License.
1818
*/
19-
package org.culturegraph.mf.stream.pipe;
20-
21-
import junit.framework.Assert;
22-
23-
import org.culturegraph.mf.framework.DefaultObjectReceiver;
24-
import org.culturegraph.mf.stream.pipe.ObjectExceptionCatcher;
25-
import org.junit.Test;
26-
27-
28-
/**
29-
* Tests {@link ObjectExceptionCatcher}.
30-
*
31-
* @author Christoph Böhme
32-
*/
33-
public final class ObjectExceptionCatcherTest {
34-
35-
private static final String OBJECT = "Test Object";
36-
37-
/**
38-
* A special exception to make sure the test
39-
* is not passed accidentally on a different
40-
* exception.
41-
*/
42-
private static final class ModuleException
43-
extends RuntimeException {
44-
45-
private static final long serialVersionUID = 1L;
46-
}
47-
48-
/**
49-
* A module whose {@code process()} method always throws
50-
* an exception.
51-
*
52-
* @param <T> object type
53-
*/
54-
private static final class FailingModule<T>
55-
extends DefaultObjectReceiver<T> {
56-
57-
@Override
58-
public void process(final T obj) {
59-
throw new ModuleException();
60-
}
61-
}
62-
63-
@Test(expected=ModuleException.class)
64-
public void testSetup() {
65-
final FailingModule<String> failingModule = new FailingModule<String>();
66-
67-
failingModule.process(OBJECT);
68-
failingModule.closeStream();
69-
}
70-
71-
@Test
72-
public void testCatcher() {
73-
final ObjectExceptionCatcher<String> catcher = new ObjectExceptionCatcher<String>();
74-
final FailingModule<String> failingModule = new FailingModule<String>();
75-
76-
catcher.setReceiver(failingModule);
77-
78-
try {
79-
catcher.process(OBJECT);
80-
catcher.closeStream();
81-
} catch (final ModuleException e) {
82-
Assert.fail(e.toString());
83-
}
84-
}
85-
86-
}
19+
package org.culturegraph.mf.stream.pipe;
20+
21+
22+
23+
import org.culturegraph.mf.framework.DefaultObjectReceiver;
24+
import org.junit.Assert;
25+
import org.junit.Test;
26+
27+
28+
/**
29+
* Tests {@link ObjectExceptionCatcher}.
30+
*
31+
* @author Christoph Böhme
32+
*/
33+
public final class ObjectExceptionCatcherTest {
34+
35+
private static final String OBJECT = "Test Object";
36+
37+
/**
38+
* A special exception to make sure the test
39+
* is not passed accidentally on a different
40+
* exception.
41+
*/
42+
protected static final class ModuleException
43+
extends RuntimeException {
44+
45+
private static final long serialVersionUID = 1L;
46+
}
47+
48+
/**
49+
* A module whose {@code process()} method always throws
50+
* an exception.
51+
*
52+
* @param <T> object type
53+
*/
54+
protected static final class FailingModule<T>
55+
extends DefaultObjectReceiver<T> {
56+
57+
@Override
58+
public void process(final T obj) {
59+
throw new ModuleException();
60+
}
61+
}
62+
63+
@Test(expected=ModuleException.class)
64+
public void testSetup() {
65+
final FailingModule<String> failingModule = new FailingModule<String>();
66+
67+
failingModule.process(OBJECT);
68+
failingModule.closeStream();
69+
}
70+
71+
@Test
72+
public void testCatcher() {
73+
final ObjectExceptionCatcher<String> catcher = new ObjectExceptionCatcher<String>();
74+
final FailingModule<String> failingModule = new FailingModule<String>();
75+
76+
catcher.setReceiver(failingModule);
77+
78+
try {
79+
catcher.process(OBJECT);
80+
catcher.closeStream();
81+
} catch (final ModuleException e) {
82+
Assert.fail(e.toString());
83+
}
84+
}
85+
86+
}

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

Lines changed: 45 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -13,49 +13,48 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.culturegraph.mf.stream.pipe;
17-
18-
import org.culturegraph.mf.framework.DefaultObjectReceiver;
19-
import org.culturegraph.mf.stream.pipe.ObjectTimer;
20-
import org.junit.Test;
21-
22-
23-
/**
24-
* Tests {@link ObjectTimer}.
25-
*
26-
* @author Christoph Böhme
27-
*/
28-
public final class ObjectTimerTest {
29-
30-
private static final long[] DURATIONS = { 150L, 20L, 30L, 202L };
31-
32-
/**
33-
* A module with a slow process method.
34-
*/
35-
private static final class BenchmarkedModule extends DefaultObjectReceiver<Long> {
36-
37-
@Override
38-
public void process(final Long duration) {
39-
try {
40-
Thread.sleep(duration);
41-
} catch (InterruptedException e) {
42-
return;
43-
}
44-
}
45-
}
46-
47-
@Test
48-
public void testObjectTimer() {
49-
final ObjectTimer<Long> timer = new ObjectTimer<Long>();
50-
final BenchmarkedModule benchmarkedModule = new BenchmarkedModule();
51-
52-
timer.setReceiver(benchmarkedModule);
53-
54-
for (int i=0; i < DURATIONS.length; ++i) {
55-
timer.process(DURATIONS[i]);
56-
}
57-
58-
timer.closeStream();
59-
}
60-
61-
}
16+
package org.culturegraph.mf.stream.pipe;
17+
18+
import org.culturegraph.mf.framework.DefaultObjectReceiver;
19+
import org.junit.Test;
20+
21+
22+
/**
23+
* Tests {@link ObjectTimer}.
24+
*
25+
* @author Christoph Böhme
26+
*/
27+
public final class ObjectTimerTest {
28+
29+
private static final long[] DURATIONS = { 150L, 20L, 30L, 202L };
30+
31+
/**
32+
* A module with a slow process method.
33+
*/
34+
private static final class BenchmarkedModule extends DefaultObjectReceiver<Long> {
35+
36+
@Override
37+
public void process(final Long duration) {
38+
try {
39+
Thread.sleep(duration.longValue());
40+
} catch (InterruptedException e) {
41+
return;
42+
}
43+
}
44+
}
45+
46+
@Test
47+
public void testObjectTimer() {
48+
final ObjectTimer<Long> timer = new ObjectTimer<Long>();
49+
final BenchmarkedModule benchmarkedModule = new BenchmarkedModule();
50+
51+
timer.setReceiver(benchmarkedModule);
52+
53+
for (int i=0; i < DURATIONS.length; ++i) {
54+
timer.process(Long.valueOf(DURATIONS[i]));
55+
}
56+
57+
timer.closeStream();
58+
}
59+
60+
}

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

Lines changed: 44 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -13,48 +13,47 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.culturegraph.mf.stream.pipe;
17-
18-
import java.io.FileReader;
19-
import java.io.IOException;
20-
21-
import junit.framework.Assert;
22-
23-
import org.culturegraph.mf.morph.DataFilePath;
24-
import org.culturegraph.mf.stream.pipe.Splitter;
25-
import org.culturegraph.mf.stream.reader.PicaReader;
26-
import org.culturegraph.mf.stream.reader.Reader;
27-
import org.culturegraph.mf.stream.sink.Counter;
28-
import org.junit.Test;
29-
30-
31-
/**
32-
* Tests {@link Splitter}.
33-
*
34-
* @author Markus Michael Geipel
35-
*
36-
*/
37-
public final class SplitterTest {
38-
39-
private static final int NUM_TP_RECORDS = 3;
40-
private static final int NUM_TN_RECORDS = 7;
41-
42-
@Test
43-
public void testCorrectTeeFunction() throws IOException {
44-
final Reader picaReader = new PicaReader();
45-
46-
final Splitter splitter = new Splitter("morph/typeSplitter.xml");
47-
48-
final Counter countingWriterTp = new Counter();
49-
final Counter countingWriterTn = new Counter();
50-
51-
picaReader.setReceiver(splitter).setReceiver("Tn", countingWriterTn);
52-
53-
splitter.setReceiver("Tp", countingWriterTp);
54-
55-
picaReader.process(new FileReader(DataFilePath.PND_PICA));
56-
57-
Assert.assertEquals(NUM_TN_RECORDS, countingWriterTn.getNumRecords());
58-
Assert.assertEquals(NUM_TP_RECORDS, countingWriterTp.getNumRecords());
59-
}
60-
}
16+
package org.culturegraph.mf.stream.pipe;
17+
18+
import java.io.FileReader;
19+
import java.io.IOException;
20+
21+
import junit.framework.Assert;
22+
23+
import org.culturegraph.mf.morph.DataFilePath;
24+
import org.culturegraph.mf.stream.reader.PicaReader;
25+
import org.culturegraph.mf.stream.reader.Reader;
26+
import org.culturegraph.mf.stream.sink.Counter;
27+
import org.junit.Test;
28+
29+
30+
/**
31+
* Tests {@link Splitter}.
32+
*
33+
* @author Markus Michael Geipel
34+
*
35+
*/
36+
public final class SplitterTest {
37+
38+
private static final int NUM_TP_RECORDS = 3;
39+
private static final int NUM_TN_RECORDS = 7;
40+
41+
@Test
42+
public void testCorrectTeeFunction() throws IOException {
43+
final Reader picaReader = new PicaReader();
44+
45+
final Splitter splitter = new Splitter("morph/typeSplitter.xml");
46+
47+
final Counter countingWriterTp = new Counter();
48+
final Counter countingWriterTn = new Counter();
49+
50+
picaReader.setReceiver(splitter).setReceiver("Tn", countingWriterTn);
51+
52+
splitter.setReceiver("Tp", countingWriterTp);
53+
54+
picaReader.process(new FileReader(DataFilePath.PND_PICA));
55+
56+
Assert.assertEquals(NUM_TN_RECORDS, countingWriterTn.getNumRecords());
57+
Assert.assertEquals(NUM_TP_RECORDS, countingWriterTp.getNumRecords());
58+
}
59+
}

0 commit comments

Comments
 (0)