1. Project Clover database Mon Dec 22 2025 14:59:38 CST
  2. Package org.europa.together

File JUnit5Preperator.java

 

Coverage histogram

../../../img/srcFileCovDistChart8.png
89% of files have more coverage

Code metrics

0
11
3
1
52
36
4
0.36
3.67
3
1.33

Classes

Class Line # Actions
JUnit5Preperator 18 11 0% 4 3
0.7857142778.6%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    package org.europa.together;
2   
3    import java.sql.SQLException;
4    import org.europa.together.application.JdbcActions;
5    import org.europa.together.application.LogbackLogger;
6    import org.europa.together.business.DatabaseActions;
7    import org.europa.together.business.Logger;
8    import org.europa.together.domain.LogLevel;
9    import org.junit.jupiter.api.extension.BeforeAllCallback;
10    import org.junit.jupiter.api.extension.ExtensionContext;
11    import static org.junit.jupiter.api.extension.ExtensionContext.Namespace.GLOBAL;
12   
13    /**
14    * JUnit5 Extension to run code beforr all test, like setup test suite and
15    * shutdown after all the testenvironment.<br>
16    * <b>USAGE: </b> @ExtendWith({JUnit5DbPreperator.class})
17    */
 
18    public class JUnit5Preperator
19    implements BeforeAllCallback {
20   
21    private static final Logger LOGGER = new LogbackLogger(JUnit5Preperator.class);
22   
23    public static DatabaseActions JDBC_CONNECTION;
24    private static boolean isConnected = false;
25   
 
26  34 toggle @Override
27    public void beforeAll(ExtensionContext context) {
28  34 LOGGER.log("TEST ENVIRONMENT will be prepared.", LogLevel.DEBUG);
29   
30    // check if the JDBC Connection is well established
31  34 JDBC_CONNECTION = new JdbcActions();
32  34 try {
33  34 JDBC_CONNECTION.connect("test");
34  34 LOGGER.log("JDBC: " + JDBC_CONNECTION.getJdbcMetaData().toString(), LogLevel.DEBUG);
35   
36  34 JUnit5Preperator.isConnected = true;
37  34 context.getRoot().getStore(GLOBAL).put("TogetherPlatform", this);
38   
39    } catch (SQLException ex) {
40  0 LOGGER.catchException(ex);
41    }
42  34 LOGGER.log("TEST ENVIRONMENT prepared...", LogLevel.DEBUG);
43    }
44   
 
45  0 toggle public void close() {
46  0 LOGGER.log("TEST ENVIRONMENT will be shut down.", LogLevel.DEBUG);
47    }
48   
 
49  7 toggle public static boolean isConnected() {
50  7 return JUnit5Preperator.isConnected;
51    }
52    }