Skip to content

Commit

Permalink
Migrate to JUnit 5
Browse files Browse the repository at this point in the history
Fixes #118
  • Loading branch information
albfernandez committed Jan 19, 2024
1 parent 5e87fdb commit 5d7c742
Show file tree
Hide file tree
Showing 64 changed files with 876 additions and 787 deletions.
19 changes: 15 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,11 @@
</properties>



<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.10.1</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand All @@ -61,6 +60,18 @@
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.5</version>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.9.1</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/com/linuxense/javadbf/AnyNumericTypeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import java.math.BigDecimal;
import java.math.BigInteger;

import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class AnyNumericTypeTest {
@Test
Expand Down Expand Up @@ -86,7 +86,7 @@ public void testNumericInteger() throws DBFException, IOException {
}

byte[] data = out.toByteArray();
Assert.assertEquals(259, data.length);
Assertions.assertEquals(259, data.length);
}

@Test
Expand Down Expand Up @@ -152,6 +152,6 @@ public void testNumericBigDecimal() throws DBFException, IOException {
}

byte[] data = out.toByteArray();
Assert.assertEquals(259, data.length);
Assertions.assertEquals(259, data.length);
}
}
18 changes: 9 additions & 9 deletions src/test/java/com/linuxense/javadbf/BinaryImageTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import java.io.File;
import java.io.FileInputStream;

import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import com.linuxense.javadbf.testutils.AssertUtils;
import com.linuxense.javadbf.testutils.DbfToTxtTest;
Expand All @@ -37,9 +37,9 @@ public void testBinaryImage() throws Exception {
reader.setMemoFile(new File("src/test/resources/inventory.dbt"));

DBFHeader header = reader.getHeader();
Assert.assertNotNull(header);
Assert.assertEquals(6, header.fieldArray.length);
Assert.assertEquals(12, header.numberOfRecords);
Assertions.assertNotNull(header);
Assertions.assertEquals(6, header.fieldArray.length);
Assertions.assertEquals(12, header.numberOfRecords);

DBFField[] fieldArray = header.fieldArray;
int i = 0;
Expand All @@ -54,10 +54,10 @@ public void testBinaryImage() throws Exception {
Object[] row = null;

row = reader.nextRecord();
Assert.assertEquals(16777344, ((Number) row[0]).intValue());
Assert.assertEquals(16777344, ((Number) row[1]).intValue());
Assert.assertEquals("Dartboard", row[2]);
Assert.assertEquals(889192576, ((Number) row[3]).intValue());
Assertions.assertEquals(16777344, ((Number) row[0]).intValue());
Assertions.assertEquals(16777344, ((Number) row[1]).intValue());
Assertions.assertEquals("Dartboard", row[2]);
Assertions.assertEquals(889192576, ((Number) row[3]).intValue());


DbfToTxtTest.export(reader, File.createTempFile("javadbf-test", ".txt"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import java.io.IOException;
import java.io.InputStream;

import org.junit.Test;
import org.junit.jupiter.api.Test;

public class BufferedInputStreamTest {

Expand All @@ -40,9 +40,7 @@ public void testBuffered() throws IOException {
ReadDBFAssert.testReadDBFFile(is, 11, 10);
}
finally {
if (is != null) {
is.close();
}
DBFUtils.close(is);
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/test/java/com/linuxense/javadbf/CopyExampleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import java.io.FileInputStream;
import java.nio.charset.StandardCharsets;

import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;



Expand Down Expand Up @@ -58,7 +58,7 @@ public void test() throws Exception {
finally {
DBFUtils.close(check);
}
Assert.assertEquals(recordCount, recordCountResultFile);
Assertions.assertEquals(recordCount, recordCountResultFile);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import java.io.IOException;
import java.io.OutputStream;

import org.junit.Test;
import org.junit.jupiter.api.Test;

public class CreateEmptyFileFromTemplateTest {

Expand Down
16 changes: 8 additions & 8 deletions src/test/java/com/linuxense/javadbf/CurrencyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import java.io.IOException;
import java.math.BigDecimal;

import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class CurrencyTest {

Expand Down Expand Up @@ -52,20 +52,20 @@ public void testCurrency () throws IOException {
reader = new DBFReader(new FileInputStream("src/test/resources/books.dbf"));

int numberOfFields = reader.getFieldCount();
Assert.assertEquals(11, numberOfFields);
Assertions.assertEquals(11, numberOfFields);
for (int i = 0; i < numberOfFields; i++) {
DBFField field = reader.getField(i);
Assert.assertNotNull(field.getName());
Assertions.assertNotNull(field.getName());
}
Object[] rowObject;
int countedRows = 0;
while ((rowObject = reader.nextRecord()) != null) {
Assert.assertEquals(numberOfFields, rowObject.length);
Assert.assertTrue(rowObject[6] instanceof BigDecimal);
Assert.assertEquals(values[countedRows], rowObject[6]);
Assertions.assertEquals(numberOfFields, rowObject.length);
Assertions.assertTrue(rowObject[6] instanceof BigDecimal);
Assertions.assertEquals(values[countedRows], rowObject[6]);
countedRows++;
}
Assert.assertEquals(10, countedRows);
Assertions.assertEquals(10, countedRows);
}
finally {
DBFUtils.close(reader);
Expand Down
28 changes: 14 additions & 14 deletions src/test/java/com/linuxense/javadbf/DB7CreationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import java.util.Date;
import java.util.GregorianCalendar;

import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

public class DB7CreationTest {

Expand All @@ -19,7 +19,7 @@ public DB7CreationTest() {
}

@Test
@Ignore
@Disabled
public void simpleTest() throws Exception {
File tmp = File.createTempFile("test", ".dbf");
DBFWriter writer = null;
Expand All @@ -40,7 +40,7 @@ public void simpleTest() throws Exception {
}

@Test
@Ignore
@Disabled
public void testLongNames() throws Exception{

File tmp = File.createTempFile("test", ".dbf");
Expand All @@ -62,7 +62,7 @@ public void testLongNames() throws Exception{

}
@Test
@Ignore
@Disabled
public void testLongChar() throws Exception{
File tmp = File.createTempFile("test", ".dbf");
DBFWriter writer = null;
Expand All @@ -88,30 +88,30 @@ private void read(File f) throws IOException {
reader = new DBFReader(new FileInputStream(f));

int numberOfFields = reader.getFieldCount();
Assert.assertEquals(3, numberOfFields);
Assertions.assertEquals(3, numberOfFields);

for (int i = 0; i < numberOfFields; i++) {
DBFField field = reader.getField(i);
Assert.assertNotNull(field.getName());
Assertions.assertNotNull(field.getName());
}

Object[] rowObject;
int countedRows = 0;
while ((rowObject = reader.nextRecord()) != null) {
Assert.assertEquals(numberOfFields, rowObject.length);
Assert.assertTrue(rowObject[1] instanceof java.util.Date);
Assertions.assertEquals(numberOfFields, rowObject.length);
Assertions.assertTrue(rowObject[1] instanceof java.util.Date);

Calendar calendar = new GregorianCalendar();
calendar.set(1942,Calendar.NOVEMBER,27,10,15,0);
calendar.clear(Calendar.MILLISECOND);

Assert.assertTrue(rowObject[0].toString().trim().equals("jimi"));
Assert.assertEquals(calendar.getTime(),(Date)rowObject[1]);
Assert.assertTrue(rowObject[2].toString().trim().equals("hendrix"));
Assertions.assertTrue(rowObject[0].toString().trim().equals("jimi"));
Assertions.assertEquals(calendar.getTime(),(Date)rowObject[1]);
Assertions.assertTrue(rowObject[2].toString().trim().equals("hendrix"));

countedRows++;
}
Assert.assertEquals(1, countedRows);
Assertions.assertEquals(1, countedRows);
}
finally {
DBFUtils.close(reader);
Expand Down
34 changes: 17 additions & 17 deletions src/test/java/com/linuxense/javadbf/DBCDATASUSTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import java.io.InputStream;
import java.nio.file.Files;

import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class DBCDATASUSTest {

Expand All @@ -26,8 +26,8 @@ public void testSidsBDF() throws FileNotFoundException {
try {
reader = new DBFReader(new BufferedInputStream(new FileInputStream(file)));
DBFHeader header = reader.getHeader();
Assert.assertEquals("PERIMETER", header.fieldArray[1].getName());
Assert.assertEquals(DBFDataType.NUMERIC, header.fieldArray[1].getType());
Assertions.assertEquals("PERIMETER", header.fieldArray[1].getName());
Assertions.assertEquals(DBFDataType.NUMERIC, header.fieldArray[1].getType());

DBFRow row = null;

Expand All @@ -36,7 +36,7 @@ public void testSidsBDF() throws FileNotFoundException {
System.out.println(row.getString(0));
count++;
}
Assert.assertEquals(100, count);
Assertions.assertEquals(100, count);


}
Expand All @@ -55,8 +55,8 @@ public void testSidsDBCDATASUSReader() throws FileNotFoundException {
System.out.println("---- DBC ---");;
reader = new DBCDATASUSReader(new BufferedInputStream(new FileInputStream(file)));
DBFHeader header = reader.getHeader();
Assert.assertEquals("PERIMETER", header.fieldArray[1].getName());
Assert.assertEquals(DBFDataType.NUMERIC, header.fieldArray[1].getType());
Assertions.assertEquals("PERIMETER", header.fieldArray[1].getName());
Assertions.assertEquals(DBFDataType.NUMERIC, header.fieldArray[1].getType());

DBFRow row = null;

Expand All @@ -65,7 +65,7 @@ public void testSidsDBCDATASUSReader() throws FileNotFoundException {
System.out.println(row.getString(0));
count++;
}
Assert.assertEquals(100, count);
Assertions.assertEquals(100, count);


}
Expand All @@ -82,8 +82,8 @@ public void testsStormDBF() throws FileNotFoundException {
try {
reader = new DBFReader(new BufferedInputStream(new FileInputStream(file)));
DBFHeader header = reader.getHeader();
Assert.assertEquals("COUNTYNAME", header.fieldArray[1].getName());
Assert.assertEquals(DBFDataType.CHARACTER, header.fieldArray[1].getType());
Assertions.assertEquals("COUNTYNAME", header.fieldArray[1].getName());
Assertions.assertEquals(DBFDataType.CHARACTER, header.fieldArray[1].getType());

DBFRow row = null;

Expand All @@ -92,7 +92,7 @@ public void testsStormDBF() throws FileNotFoundException {
System.out.println(row.getString(1));
count++;
}
Assert.assertEquals(100, count);
Assertions.assertEquals(100, count);


}
Expand All @@ -108,8 +108,8 @@ public void testStormDBCDATASUSReader() throws FileNotFoundException {
System.out.println("---- DBC ---");;
reader = new DBCDATASUSReader(new BufferedInputStream(new FileInputStream(file)));
DBFHeader header = reader.getHeader();
Assert.assertEquals("COUNTYNAME", header.fieldArray[1].getName());
Assert.assertEquals(DBFDataType.CHARACTER, header.fieldArray[1].getType());
Assertions.assertEquals("COUNTYNAME", header.fieldArray[1].getName());
Assertions.assertEquals(DBFDataType.CHARACTER, header.fieldArray[1].getType());

DBFRow row = null;

Expand All @@ -118,7 +118,7 @@ public void testStormDBCDATASUSReader() throws FileNotFoundException {
System.out.println(row.getString(1));
count++;
}
Assert.assertEquals(100, count);
Assertions.assertEquals(100, count);


}
Expand All @@ -137,7 +137,7 @@ public void testExploderMemory() throws IOException {
byte[] result = new byte[size];
System.arraycopy(outputDatae, 0, result, 0, size);
String s = new String(result);
Assert.assertEquals("AIAIAIAIAIAIA", s);
Assertions.assertEquals("AIAIAIAIAIAIA", s);

}

Expand All @@ -151,7 +151,7 @@ public void testExploderOutputStream() throws IOException {
byte[] outputDatae = baos.toByteArray();
System.arraycopy(outputDatae, 0, result, 0, size);
String s = new String(result);
Assert.assertEquals("AIAIAIAIAIAIA", s);
Assertions.assertEquals("AIAIAIAIAIAIA", s);

}

Expand All @@ -165,7 +165,7 @@ public void testExploderInputStream() throws IOException {
in = new DBFExploderInputStream(new FileInputStream(file));
int readed = in.read(data);
String s = new String(data,0, readed);
Assert.assertEquals("AIAIAIAIAIAIA", s);
Assertions.assertEquals("AIAIAIAIAIAIA", s);
}
finally {
DBFUtils.close(in);;
Expand Down
Loading

0 comments on commit 5d7c742

Please sign in to comment.