File tree Expand file tree Collapse file tree 4 files changed +56
-0
lines changed
src/test/java/jp/azisaba/lgw/kdstatus Expand file tree Collapse file tree 4 files changed +56
-0
lines changed Original file line number Diff line number Diff line change 9292 <version >3.5.1</version >
9393 </dependency >
9494 </dependencies >
95+ <configuration >
96+ <groups >small</groups >
97+ </configuration >
9598 </plugin >
9699 </plugins >
97100 </build >
Original file line number Diff line number Diff line change 1+ package jp .azisaba .lgw .kdstatus ;
2+
3+ public class TestSize {
4+ public static final String SMALL = "small" ;
5+ public static final String MEDIUM = "medium" ;
6+ public static final String LARGE = "large" ;
7+ }
Original file line number Diff line number Diff line change 1+ package jp .azisaba .lgw .kdstatus .sql ;
2+
3+ import jp .azisaba .lgw .kdstatus .TestSize ;
4+ import org .junit .jupiter .api .Tag ;
5+ import org .junit .jupiter .api .Test ;
6+
7+ import java .sql .Connection ;
8+ import java .sql .PreparedStatement ;
9+ import java .sql .SQLException ;
10+ import java .util .Random ;
11+ import java .util .logging .Logger ;
12+
13+ import static org .junit .jupiter .api .Assertions .assertTrue ;
14+
15+ @ Tag (TestSize .LARGE )
16+ public class ConnectionTest {
17+ @ Test
18+ public void ConnectToDatabase () throws InterruptedException {
19+ Random rnd = new Random ();
20+ HikariMySQLDatabase db = new HikariMySQLDatabase (
21+ Logger .getLogger ("DBConnectionTest" ),
22+ 10 ,
23+ "localhost" ,
24+ "3306" ,
25+ "db" ,
26+ "root" ,
27+ "mariadb"
28+ );
29+ db .connect ();
30+ for (int i =0 ;i <20 ;i ++) {
31+ assertTrue (db .isConnectionAlive ());
32+ System .out .println ("Connection is alive! " + i );
33+ try (Connection conn = db .getConnection ();
34+ PreparedStatement pstmt = conn .prepareStatement ("SELECT 1" )) {
35+ assertTrue (pstmt .executeQuery ().next ());
36+ } catch (SQLException e ) {
37+ e .printStackTrace ();
38+ }
39+ Thread .sleep (rnd .nextInt (2000 ));
40+ }
41+ db .close ();
42+ }
43+ }
Original file line number Diff line number Diff line change 11package jp .azisaba .lgw .kdstatus .utils ;
22
3+ import jp .azisaba .lgw .kdstatus .TestSize ;
4+ import org .junit .jupiter .api .Tag ;
35import org .junit .jupiter .api .Test ;
46
57import java .util .UUID ;
810
911public class UUIDConverterTest {
1012 @ Test
13+ @ Tag (TestSize .SMALL )
1114 public void UUIDToString () {
1215 UUID uuid = UUID .randomUUID ();
1316 assertEquals (uuid .toString (), UUIDConverter .insertDashUUID (uuid .toString ().replace ("-" , "" )));
You can’t perform that action at this time.
0 commit comments