Skip to content

Commit 8267e7b

Browse files
committed
Replaced deprecated JUnit3 Asserts with their JUnit4 equivalents.
1 parent 8192609 commit 8267e7b

20 files changed

+3467
-3854
lines changed

src/main/antlr3/org/culturegraph/mf/flux/parser/FlowBuilder.java

Lines changed: 744 additions & 862 deletions
Large diffs are not rendered by default.

src/main/antlr3/org/culturegraph/mf/flux/parser/FluxLexer.java

Lines changed: 1094 additions & 1179 deletions
Large diffs are not rendered by default.

src/main/antlr3/org/culturegraph/mf/flux/parser/FluxParser.java

Lines changed: 1385 additions & 1565 deletions
Large diffs are not rendered by default.

src/test/java/org/culturegraph/mf/morph/functions/ISBNTest.java

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
*/
1616
package org.culturegraph.mf.morph.functions;
1717

18-
import junit.framework.Assert;
19-
18+
import static org.junit.Assert.assertEquals;
19+
import static org.junit.Assert.assertFalse;
20+
import static org.junit.Assert.assertTrue;
21+
2022
import org.culturegraph.mf.morph.functions.ISBN;
2123
import org.junit.Test;
22-
23-
24-
24+
2525

2626
/**
2727
* tests {@link ISBN}
@@ -53,27 +53,27 @@ public final class ISBNTest {
5353
public void testProcess(){
5454
final ISBN isbn = new ISBN();
5555
isbn.setTo("isbn13");
56-
Assert.assertEquals(ISBN13A, isbn.process(ISBN10A));
56+
assertEquals(ISBN13A, isbn.process(ISBN10A));
5757
isbn.setTo("isbn10");
58-
Assert.assertEquals(ISBN10A, isbn.process(ISBN13A));
58+
assertEquals(ISBN10A, isbn.process(ISBN13A));
5959
isbn.setTo("cleanse");
60-
Assert.assertEquals(ISBN10A, isbn.process(ISBN10A_DIRTY));
60+
assertEquals(ISBN10A, isbn.process(ISBN10A_DIRTY));
6161

6262
}
6363

6464
@Test
6565
public void testTo13() {
66-
Assert.assertEquals(ISBN13A, ISBN.isbn10to13(ISBN10A));
66+
assertEquals(ISBN13A, ISBN.isbn10to13(ISBN10A));
6767
}
6868

6969
@Test
7070
public void testTo10() {
71-
Assert.assertEquals(ISBN10A,ISBN.isbn13to10(ISBN13A));
71+
assertEquals(ISBN10A,ISBN.isbn13to10(ISBN13A));
7272
}
7373

7474
@Test
7575
public void testCleanse() {
76-
Assert.assertEquals(ISBN10A,ISBN.cleanse(ISBN10A_DIRTY));
76+
assertEquals(ISBN10A,ISBN.cleanse(ISBN10A_DIRTY));
7777
}
7878

7979
@Test(expected = IllegalArgumentException.class)
@@ -88,18 +88,18 @@ public void testInvalidInputTo10() {
8888

8989
@Test
9090
public void testIsValid() {
91-
Assert.assertFalse(ISBN.isValid(ISBN_INCORRECT_CHECK13));
92-
Assert.assertFalse(ISBN.isValid(ISBN_INCORRECT_CHECK10));
93-
Assert.assertFalse(ISBN.isValid(ISBN_INCORRECT_SIZE1));
94-
Assert.assertFalse(ISBN.isValid(ISBN_INCORRECT_SIZE2));
95-
Assert.assertFalse(ISBN.isValid(ISBN_INCORRECT_SIZE3));
91+
assertFalse(ISBN.isValid(ISBN_INCORRECT_CHECK13));
92+
assertFalse(ISBN.isValid(ISBN_INCORRECT_CHECK10));
93+
assertFalse(ISBN.isValid(ISBN_INCORRECT_SIZE1));
94+
assertFalse(ISBN.isValid(ISBN_INCORRECT_SIZE2));
95+
assertFalse(ISBN.isValid(ISBN_INCORRECT_SIZE3));
9696

97-
Assert.assertTrue(ISBN.isValid(ISBN10B));
98-
Assert.assertTrue(ISBN.isValid(ISBN10A));
99-
Assert.assertTrue(ISBN.isValid(ISBN13A ));
100-
Assert.assertTrue(ISBN.isValid(ISBN.cleanse(ISBN10C_DIRTY)));
101-
Assert.assertTrue(ISBN.isValid(ISBN.cleanse(ISBN13D_DIRTY)));
102-
Assert.assertTrue(ISBN.isValid(ISBN.cleanse(ISBN10F_DIRTY)));
97+
assertTrue(ISBN.isValid(ISBN10B));
98+
assertTrue(ISBN.isValid(ISBN10A));
99+
assertTrue(ISBN.isValid(ISBN13A ));
100+
assertTrue(ISBN.isValid(ISBN.cleanse(ISBN10C_DIRTY)));
101+
assertTrue(ISBN.isValid(ISBN.cleanse(ISBN13D_DIRTY)));
102+
assertTrue(ISBN.isValid(ISBN.cleanse(ISBN10F_DIRTY)));
103103
}
104104

105105
@Test(expected = ISBN.InvalidISBNLengthException.class)

src/test/java/org/culturegraph/mf/morph/functions/LookupTest.java

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,16 @@
1515
*/
1616
package org.culturegraph.mf.morph.functions;
1717

18-
import java.util.HashMap;
19-
import java.util.Map;
20-
21-
import junit.framework.Assert;
22-
23-
import org.culturegraph.mf.morph.functions.Lookup;
24-
import org.culturegraph.mf.types.MultiHashMap;
25-
import org.culturegraph.mf.types.MultiMap;
26-
import org.junit.Test;
27-
28-
29-
18+
import static org.junit.Assert.assertEquals;
19+
import static org.junit.Assert.assertNull;
20+
21+
import java.util.HashMap;
22+
import java.util.Map;
23+
24+
import org.culturegraph.mf.types.MultiHashMap;
25+
import org.culturegraph.mf.types.MultiMap;
26+
import org.junit.Test;
27+
3028

3129
/**
3230
* tests {@link Lookup}
@@ -53,16 +51,15 @@ public void testLookup() {
5351

5452
lookup.setMultiMap(multiMapProvider);
5553
lookup.setIn(MAP_NAME_WRONG);
56-
Assert.assertNull(lookup.process(KEY));
57-
Assert.assertNull(lookup.process(KEY_WRONG));
54+
assertNull(lookup.process(KEY));
55+
assertNull(lookup.process(KEY_WRONG));
5856

5957
lookup.setIn(MAP_NAME);
60-
Assert.assertEquals(VALUE, lookup.process(KEY));
61-
Assert.assertNull(lookup.process(KEY_WRONG));
58+
assertEquals(VALUE, lookup.process(KEY));
59+
assertNull(lookup.process(KEY_WRONG));
6260

6361
map.put(MultiMap.DEFAULT_MAP_KEY, VALUE);
64-
Assert.assertEquals(VALUE, lookup.process(KEY_WRONG));
62+
assertEquals(VALUE, lookup.process(KEY_WRONG));
6563
}
66-
67-
64+
6865
}

src/test/java/org/culturegraph/mf/morph/functions/StringOperationsTest.java

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,10 @@
1515
*/
1616
package org.culturegraph.mf.morph.functions;
1717

18-
import junit.framework.Assert;
19-
20-
import org.culturegraph.mf.morph.functions.Compose;
21-
import org.culturegraph.mf.morph.functions.Regexp;
22-
import org.culturegraph.mf.morph.functions.Replace;
23-
import org.culturegraph.mf.morph.functions.Substring;
24-
import org.junit.Test;
25-
26-
18+
import static org.junit.Assert.assertEquals;
19+
import static org.junit.Assert.assertNull;
20+
21+
import org.junit.Test;
2722

2823

2924
/**
@@ -44,32 +39,33 @@ public final class StringOperationsTest {
4439
public void testRegexp() {
4540
final Regexp regexp = new Regexp();
4641
regexp.setMatch(VALUE2);
47-
Assert.assertEquals(VALUE2, regexp.process(VALUE1+VALUE2));
48-
Assert.assertNull(regexp.process(VALUE3+VALUE1));
42+
assertEquals(VALUE2, regexp.process(VALUE1+VALUE2));
43+
assertNull(regexp.process(VALUE3+VALUE1));
4944
regexp.setFormat(VALUE3 + " ${1}.");
5045
regexp.setMatch("((K)).*$");
51-
Assert.assertEquals(VALUE3 + " K.", regexp.process(VALUE1 + VALUE2));
46+
assertEquals(VALUE3 + " K.", regexp.process(VALUE1 + VALUE2));
5247
}
5348

5449
@Test
5550
public void testSubstring() {
5651
final Substring substring = new Substring();
57-
Assert.assertEquals(VALUE1,substring.process(VALUE1));
52+
assertEquals(VALUE1,substring.process(VALUE1));
5853

5954
final int position = 2;
6055
substring.setStart(String.valueOf(position));
61-
Assert.assertEquals(VALUE1.substring(position),substring.process(VALUE1));
56+
assertEquals(VALUE1.substring(position),substring.process(VALUE1));
6257

6358
substring.setStart("0");
6459
substring.setEnd(String.valueOf(VALUE1.length()+1));
65-
Assert.assertEquals(VALUE1, substring.process(VALUE1));
60+
assertEquals(VALUE1, substring.process(VALUE1));
6661

6762
substring.setStart(String.valueOf(VALUE1.length()+1));
6863
substring.setEnd(String.valueOf(position));
69-
Assert.assertNull(substring.process(VALUE1));
64+
assertNull(substring.process(VALUE1));
7065

7166
}
72-
67+
68+
// TODO: Can we remove this test?
7369
// @Test(expected=Regexp.PatternNotFoundException.class)
7470
// public void testRegexpExceptionOnFail() {
7571
// final Regexp regexp = new Regexp();
@@ -82,10 +78,10 @@ public void testSubstring() {
8278
public void testCompose() {
8379
final Compose compose = new Compose();
8480
compose.setPrefix(VALUE1);
85-
Assert.assertEquals(VALUE1+VALUE2, compose.process(VALUE2));
81+
assertEquals(VALUE1+VALUE2, compose.process(VALUE2));
8682
compose.setPrefix("");
8783
compose.setPostfix(VALUE1);
88-
Assert.assertEquals(VALUE2+VALUE1, compose.process(VALUE2));
84+
assertEquals(VALUE2+VALUE1, compose.process(VALUE2));
8985

9086
}
9187

@@ -94,6 +90,7 @@ public void testReplace() {
9490
final Replace replace = new Replace();
9591
replace.setPattern(VALUE2);
9692
replace.setWith(VALUE3);
97-
Assert.assertEquals(VALUE1+VALUE3, replace.process(VALUE1+VALUE2));
98-
}
93+
assertEquals(VALUE1+VALUE3, replace.process(VALUE1+VALUE2));
94+
}
95+
9996
}

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@
1515
*/
1616
package org.culturegraph.mf.morph.maps;
1717

18-
import java.io.IOException;
19-
20-
import junit.framework.Assert;
21-
22-
import org.culturegraph.mf.morph.maps.JndiSqlMap;
23-
import org.junit.Test;
18+
import static org.junit.Assert.assertNotNull;
19+
20+
import java.io.IOException;
21+
22+
import org.junit.Test;
2423

2524

2625
/**
@@ -34,7 +33,8 @@ public void name() throws IOException {
3433
final JndiSqlMap map = new JndiSqlMap();
3534
map.setDatasource("testDataSource");
3635

37-
Assert.assertNotNull(map.getDatasource());
36+
assertNotNull(map.getDatasource());
3837
map.close();
39-
}
38+
}
39+
4040
}

src/test/java/org/culturegraph/mf/stream/converter/xml/GenericXMLHandlerTest.java

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,15 @@
1515
*/
1616
package org.culturegraph.mf.stream.converter.xml;
1717

18-
import junit.framework.Assert;
19-
20-
import org.culturegraph.mf.exceptions.FormatException;
21-
import org.culturegraph.mf.stream.DataFilePath;
22-
import org.culturegraph.mf.stream.converter.CGTextDecoder;
23-
import org.culturegraph.mf.stream.converter.xml.GenericXmlHandler;
24-
import org.culturegraph.mf.stream.converter.xml.XmlDecoder;
25-
import org.culturegraph.mf.stream.sink.EventList;
26-
import org.culturegraph.mf.stream.sink.StreamValidator;
27-
import org.culturegraph.mf.stream.source.ResourceOpener;
28-
import org.junit.Test;
18+
import static org.junit.Assert.fail;
19+
20+
import org.culturegraph.mf.exceptions.FormatException;
21+
import org.culturegraph.mf.stream.DataFilePath;
22+
import org.culturegraph.mf.stream.converter.CGTextDecoder;
23+
import org.culturegraph.mf.stream.sink.EventList;
24+
import org.culturegraph.mf.stream.sink.StreamValidator;
25+
import org.culturegraph.mf.stream.source.ResourceOpener;
26+
import org.junit.Test;
2927

3028

3129
/**
@@ -61,7 +59,7 @@ public void ignoreCharDataNotInRecord() {
6159
opener.process(DataFilePath.GENERIC_XML);
6260
opener.closeStream();
6361
} catch(FormatException e) {
64-
Assert.fail(e.toString());
62+
fail(e.toString());
6563
}
6664
}
6765
}

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

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

18+
import static org.junit.Assert.assertEquals;
19+
1820
import java.io.FileReader;
1921
import java.io.IOException;
2022

21-
import junit.framework.Assert;
22-
2323
import org.culturegraph.mf.morph.DataFilePath;
2424
import org.culturegraph.mf.stream.reader.PicaReader;
2525
import org.culturegraph.mf.stream.reader.Reader;
@@ -53,7 +53,8 @@ public void testCorrectTeeFunction() throws IOException {
5353

5454
picaReader.process(new FileReader(DataFilePath.PND_PICA));
5555

56-
Assert.assertEquals(NUM_TN_RECORDS, countingWriterTn.getNumRecords());
57-
Assert.assertEquals(NUM_TP_RECORDS, countingWriterTp.getNumRecords());
56+
assertEquals(NUM_TN_RECORDS, countingWriterTn.getNumRecords());
57+
assertEquals(NUM_TP_RECORDS, countingWriterTp.getNumRecords());
5858
}
59+
5960
}

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
*/
1616
package org.culturegraph.mf.stream.pipe;
1717

18-
19-
2018
import org.junit.Assert;
2119
import org.junit.Test;
2220

0 commit comments

Comments
 (0)