11
11
import com .eternalcode .parcellockers .parcel .repository .ParcelRepository ;
12
12
import com .eternalcode .parcellockers .parcel .repository .ParcelRepositoryOrmLite ;
13
13
import com .eternalcode .parcellockers .shared .Page ;
14
+ import org .junit .jupiter .api .AfterEach ;
14
15
import org .junit .jupiter .api .Test ;
16
+ import org .junit .jupiter .api .io .TempDir ;
15
17
import org .testcontainers .containers .MySQLContainer ;
16
18
import org .testcontainers .junit .jupiter .Container ;
17
19
import org .testcontainers .junit .jupiter .Testcontainers ;
18
20
import org .testcontainers .utility .DockerImageName ;
19
21
20
22
import java .io .File ;
23
+ import java .nio .file .Path ;
21
24
import java .util .Collections ;
22
25
import java .util .List ;
23
26
import java .util .Optional ;
28
31
import static org .junit .jupiter .api .Assertions .assertTrue ;
29
32
30
33
@ Testcontainers
31
- class ParcelDatabaseServiceIntegrationTest extends ParcelLockerIntegrationSpec {
34
+ class ParcelRepositoryIntegrationTest extends IntegrationTestSpec {
32
35
33
36
@ Container
34
37
private static final MySQLContainer mySQLContainer = new MySQLContainer (DockerImageName .parse ("mysql:latest" ));
35
38
39
+ @ TempDir
40
+ private Path tempDir ;
41
+
42
+ private DatabaseManager databaseManager ;
43
+
36
44
@ Test
37
45
void test () {
38
- File dataFolder = new File ( "run/plugins/ ParcelLockers" );
46
+ File dataFolder = tempDir . resolve ( " ParcelLockers"). toFile ( );
39
47
PluginConfiguration config = new ConfigurationManager (dataFolder ).load (new PluginConfiguration ());
40
48
DatabaseManager databaseManager = new DatabaseManager (config , Logger .getLogger ("ParcelLockers" ), dataFolder );
49
+ this .databaseManager = databaseManager ;
41
50
ParcelCache cache = new ParcelCache ();
42
51
43
52
ParcelRepository parcelRepository = new ParcelRepositoryOrmLite (databaseManager , new TestScheduler (), cache );
@@ -70,4 +79,11 @@ void test() {
70
79
Optional <Parcel > removedParcel = this .await (parcelRepository .findByUUID (uuid ));
71
80
assertTrue (removedParcel .isEmpty ());
72
81
}
82
+
83
+ @ AfterEach
84
+ void tearDown () {
85
+ if (this .databaseManager != null ) {
86
+ this .databaseManager .disconnect ();
87
+ }
88
+ }
73
89
}
0 commit comments