start
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.auction;
|
||||
|
||||
import org.junit.jupiter.api.*;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.sql.SQLException;
|
||||
@@ -282,7 +283,7 @@ class DatabaseServiceTest {
|
||||
|
||||
@Test
|
||||
@DisplayName("Should handle empty database gracefully")
|
||||
void testEmptyDatabase() throws SQLException {
|
||||
void testEmptyDatabase() throws SQLException, IOException {
|
||||
DatabaseService emptyDb = new DatabaseService("empty_test_" + System.currentTimeMillis() + ".db");
|
||||
emptyDb.ensureSchema();
|
||||
|
||||
@@ -340,7 +341,7 @@ class DatabaseServiceTest {
|
||||
|
||||
@Test
|
||||
@DisplayName("Should handle concurrent upserts")
|
||||
void testConcurrentUpserts() throws InterruptedException {
|
||||
void testConcurrentUpserts() throws InterruptedException, SQLException {
|
||||
Thread t1 = new Thread(() -> {
|
||||
try {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
|
||||
@@ -361,7 +361,7 @@ class IntegrationTest {
|
||||
@Test
|
||||
@Order(9)
|
||||
@DisplayName("Integration: Handle rapid concurrent updates")
|
||||
void testConcurrentOperations() throws InterruptedException {
|
||||
void testConcurrentOperations() throws InterruptedException, SQLException {
|
||||
Thread auctionThread = new Thread(() -> {
|
||||
try {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
|
||||
@@ -283,7 +283,7 @@ class TroostwijkMonitorTest {
|
||||
|
||||
@Test
|
||||
@DisplayName("Should handle multiple concurrent lot updates")
|
||||
void testConcurrentLotUpdates() throws InterruptedException {
|
||||
void testConcurrentLotUpdates() throws InterruptedException, SQLException {
|
||||
Thread t1 = new Thread(() -> {
|
||||
try {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
package com.auction;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.opencv.core.Core;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
/**
|
||||
* Test case for TroostwijkScraper that verifies auction discovery and data persistence.
|
||||
* Uses a temporary test database to verify that:
|
||||
* 1. Dutch auctions are correctly discovered from the live page
|
||||
* 2. Auction properties (sale IDs, titles, etc.) are valid
|
||||
* 3. Data is correctly persisted to the database
|
||||
*/
|
||||
public class TroostwijkScraperTest {
|
||||
|
||||
private TroostwijkScraper scraper;
|
||||
private String testDatabasePath;
|
||||
|
||||
@BeforeAll
|
||||
public static void loadOpenCV() {
|
||||
// Load native OpenCV library before any tests run
|
||||
try {
|
||||
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
|
||||
IO.println("✓ OpenCV native library loaded successfully");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("⚠️ Warning: Could not load OpenCV native library");
|
||||
System.err.println(" Tests will run without object detection support");
|
||||
}
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() throws SQLException, java.io.IOException {
|
||||
// Create temporary test database
|
||||
testDatabasePath = "test_auctions_" + System.currentTimeMillis() + ".db";
|
||||
|
||||
// Initialize scraper with test database (no YOLO models needed for this test)
|
||||
// Using non-existent paths for YOLO files will disable object detection
|
||||
scraper = new TroostwijkScraper(
|
||||
testDatabasePath,
|
||||
"desktop",
|
||||
"",
|
||||
"nonexistent/yolov4.cfg",
|
||||
"nonexistent/yolov4.weights",
|
||||
"nonexistent/coco.names"
|
||||
);
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
// Clean up browser and cache
|
||||
if (scraper != null) {
|
||||
scraper.close();
|
||||
}
|
||||
|
||||
// Clean up test database
|
||||
var dbFile = new File(testDatabasePath);
|
||||
if (dbFile.exists()) {
|
||||
dbFile.delete();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user