aboutsummaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java1
-rw-r--r--src/test/java/com/healthmarketscience/jackcess/PropertiesTest.java1
-rw-r--r--src/test/java/com/healthmarketscience/jackcess/TestUtil.java37
-rw-r--r--src/test/java/com/healthmarketscience/jackcess/impl/BigIntTest.java1
-rw-r--r--src/test/java/com/healthmarketscience/jackcess/impl/CodecHandlerTest.java33
-rw-r--r--src/test/java/com/healthmarketscience/jackcess/impl/LongValueTest.java2
-rw-r--r--src/test/java/com/healthmarketscience/jackcess/util/ColumnFormatterTest.java3
-rw-r--r--src/test/java/com/healthmarketscience/jackcess/util/RowFilterTest.java1
8 files changed, 26 insertions, 53 deletions
diff --git a/src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java b/src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java
index 2ea9e29..8452dc9 100644
--- a/src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java
+++ b/src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java
@@ -199,7 +199,6 @@ public class DatabaseTest extends TestCase
Map<String,Object> row2 = createTestRowMap("Tim2");
Map<String,Object> row3 = createTestRowMap("Tim3");
Table table = db.getTable("Test");
- @SuppressWarnings("unchecked")
List<Map<String,Object>> rows = Arrays.asList(row1, row2, row3);
table.addRowsFromMaps(rows);
assertRowCount(3, table);
diff --git a/src/test/java/com/healthmarketscience/jackcess/PropertiesTest.java b/src/test/java/com/healthmarketscience/jackcess/PropertiesTest.java
index f5cb304..92f7b51 100644
--- a/src/test/java/com/healthmarketscience/jackcess/PropertiesTest.java
+++ b/src/test/java/com/healthmarketscience/jackcess/PropertiesTest.java
@@ -25,7 +25,6 @@ import java.util.Map;
import java.util.UUID;
import static com.healthmarketscience.jackcess.Database.*;
-import com.healthmarketscience.jackcess.InvalidValueException;
import com.healthmarketscience.jackcess.impl.DatabaseImpl;
import static com.healthmarketscience.jackcess.impl.JetFormatTest.*;
import com.healthmarketscience.jackcess.impl.PropertyMapImpl;
diff --git a/src/test/java/com/healthmarketscience/jackcess/TestUtil.java b/src/test/java/com/healthmarketscience/jackcess/TestUtil.java
index 97139b8..fae1fa0 100644
--- a/src/test/java/com/healthmarketscience/jackcess/TestUtil.java
+++ b/src/test/java/com/healthmarketscience/jackcess/TestUtil.java
@@ -16,14 +16,7 @@ limitations under the License.
package com.healthmarketscience.jackcess;
-import java.io.DataInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.PrintWriter;
+import java.io.*;
import java.lang.reflect.Field;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
@@ -31,24 +24,13 @@ import java.nio.charset.Charset;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.TimeZone;
-
-import static com.healthmarketscience.jackcess.Database.*;
+import java.util.*;
+import java.util.stream.StreamSupport;
+
+import com.healthmarketscience.jackcess.Database.FileFormat;
import com.healthmarketscience.jackcess.complex.ComplexValueForeignKey;
-import com.healthmarketscience.jackcess.impl.ByteUtil;
-import com.healthmarketscience.jackcess.impl.DatabaseImpl;
-import com.healthmarketscience.jackcess.impl.IndexData;
-import com.healthmarketscience.jackcess.impl.IndexImpl;
-import com.healthmarketscience.jackcess.impl.JetFormatTest;
+import com.healthmarketscience.jackcess.impl.*;
import com.healthmarketscience.jackcess.impl.JetFormatTest.TestDB;
-import com.healthmarketscience.jackcess.impl.RowIdImpl;
-import com.healthmarketscience.jackcess.impl.RowImpl;
import com.healthmarketscience.jackcess.util.MemFileChannel;
import org.junit.Assert;
@@ -264,11 +246,8 @@ public class TestUtil
}
public static int countRows(Table table) throws Exception {
- int rtn = 0;
- for(Map<String, Object> row : CursorBuilder.createCursor(table)) {
- rtn++;
- }
- return rtn;
+ Cursor cursor = CursorBuilder.createCursor(table);
+ return (int) StreamSupport.stream(cursor.spliterator(), false).count();
}
public static void assertTable(
diff --git a/src/test/java/com/healthmarketscience/jackcess/impl/BigIntTest.java b/src/test/java/com/healthmarketscience/jackcess/impl/BigIntTest.java
index 98689d6..6ef97ae 100644
--- a/src/test/java/com/healthmarketscience/jackcess/impl/BigIntTest.java
+++ b/src/test/java/com/healthmarketscience/jackcess/impl/BigIntTest.java
@@ -18,7 +18,6 @@ package com.healthmarketscience.jackcess.impl;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Comparator;
import java.util.List;
import java.util.Map;
diff --git a/src/test/java/com/healthmarketscience/jackcess/impl/CodecHandlerTest.java b/src/test/java/com/healthmarketscience/jackcess/impl/CodecHandlerTest.java
index 51e9f3c..7c5f59f 100644
--- a/src/test/java/com/healthmarketscience/jackcess/impl/CodecHandlerTest.java
+++ b/src/test/java/com/healthmarketscience/jackcess/impl/CodecHandlerTest.java
@@ -167,25 +167,26 @@ public class CodecHandlerTest extends TestCase
throws Exception
{
long dbLen = dbFile.length();
- FileChannel fileChannel = new RandomAccessFile(dbFile, "rw").getChannel();
- ByteBuffer bb = ByteBuffer.allocate(pageSize)
- .order(PageChannel.DEFAULT_BYTE_ORDER);
- for(long offset = pageSize; offset < dbLen; offset += pageSize) {
-
- bb.clear();
- fileChannel.read(bb, offset);
+ try (RandomAccessFile randomAccessFile = new RandomAccessFile(dbFile, "rw");
+ FileChannel fileChannel = randomAccessFile.getChannel()) {
+ ByteBuffer bb = ByteBuffer.allocate(pageSize)
+ .order(PageChannel.DEFAULT_BYTE_ORDER);
+ for(long offset = pageSize; offset < dbLen; offset += pageSize) {
+
+ bb.clear();
+ fileChannel.read(bb, offset);
+
+ int pageNumber = (int)(offset / pageSize);
+ if(simple) {
+ simpleEncode(bb.array(), bb.array(), pageNumber, 0, pageSize);
+ } else {
+ fullEncode(bb.array(), bb.array(), pageNumber);
+ }
- int pageNumber = (int)(offset / pageSize);
- if(simple) {
- simpleEncode(bb.array(), bb.array(), pageNumber, 0, pageSize);
- } else {
- fullEncode(bb.array(), bb.array(), pageNumber);
+ bb.rewind();
+ fileChannel.write(bb, offset);
}
-
- bb.rewind();
- fileChannel.write(bb, offset);
}
- fileChannel.close();
}
private static void simpleEncode(byte[] inBuffer, byte[] outBuffer,
diff --git a/src/test/java/com/healthmarketscience/jackcess/impl/LongValueTest.java b/src/test/java/com/healthmarketscience/jackcess/impl/LongValueTest.java
index 96418e6..2a21bbc 100644
--- a/src/test/java/com/healthmarketscience/jackcess/impl/LongValueTest.java
+++ b/src/test/java/com/healthmarketscience/jackcess/impl/LongValueTest.java
@@ -214,7 +214,7 @@ public class LongValueTest extends TestCase
public void testUnicodeCompression() throws Exception
{
File dbFile = new File("src/test/data/V2003/testUnicodeCompV2003.mdb");
- Database db = open(Database.FileFormat.V2003, new File("src/test/data/V2003/testUnicodeCompV2003.mdb"), true);
+ Database db = open(Database.FileFormat.V2003, dbFile, true);
StringBuilder sb = new StringBuilder(127);
for(int i = 1; i <= 0xFF; ++i) {
diff --git a/src/test/java/com/healthmarketscience/jackcess/util/ColumnFormatterTest.java b/src/test/java/com/healthmarketscience/jackcess/util/ColumnFormatterTest.java
index d9aecb7..edf4a79 100644
--- a/src/test/java/com/healthmarketscience/jackcess/util/ColumnFormatterTest.java
+++ b/src/test/java/com/healthmarketscience/jackcess/util/ColumnFormatterTest.java
@@ -19,15 +19,12 @@ package com.healthmarketscience.jackcess.util;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import java.util.Map;
import com.healthmarketscience.jackcess.Column;
import com.healthmarketscience.jackcess.ColumnBuilder;
-import com.healthmarketscience.jackcess.CursorBuilder;
import com.healthmarketscience.jackcess.DataType;
import com.healthmarketscience.jackcess.Database;
import com.healthmarketscience.jackcess.Database.FileFormat;
-import com.healthmarketscience.jackcess.IndexCursor;
import com.healthmarketscience.jackcess.PropertyMap;
import com.healthmarketscience.jackcess.Row;
import com.healthmarketscience.jackcess.Table;
diff --git a/src/test/java/com/healthmarketscience/jackcess/util/RowFilterTest.java b/src/test/java/com/healthmarketscience/jackcess/util/RowFilterTest.java
index 4a247d9..1117521 100644
--- a/src/test/java/com/healthmarketscience/jackcess/util/RowFilterTest.java
+++ b/src/test/java/com/healthmarketscience/jackcess/util/RowFilterTest.java
@@ -41,7 +41,6 @@ public class RowFilterTest extends TestCase
super(name);
}
- @SuppressWarnings("unchecked")
public void testFilter() throws Exception
{
Row row0 = createExpectedRow(ID_COL, 0, COL1, "foo", COL2, 13, COL3, "bar");