Updated all Junit tests to 5.x

resolves TASK-675
This commit is contained in:
Glenn Renfro
2020-06-17 16:38:20 -04:00
committed by Michael Minella
parent f3bbc37293
commit 59c9adf047
74 changed files with 617 additions and 534 deletions

View File

@@ -22,13 +22,15 @@ import java.util.Map;
import javax.sql.DataSource;
import org.h2.tools.Server;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.test.system.OutputCaptureRule;
import org.springframework.boot.test.system.CapturedOutput;
import org.springframework.boot.test.system.OutputCaptureExtension;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
@@ -41,6 +43,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Glenn Renfro
*/
@ExtendWith(OutputCaptureExtension.class)
public class JpaApplicationTests {
private final static String DATASOURCE_URL;
@@ -59,13 +62,11 @@ public class JpaApplicationTests {
+ "DB_CLOSE_ON_EXIT=FALSE";
}
@Rule
public OutputCaptureRule outputCapture = new OutputCaptureRule();
private ConfigurableApplicationContext context;
private DataSource dataSource;
private Server server;
@Before
@BeforeEach
public void setup() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName(DATASOURCE_DRIVER_CLASS_NAME);
@@ -84,7 +85,7 @@ public class JpaApplicationTests {
}
}
@After
@AfterEach
public void tearDown() {
if (this.context != null && this.context.isActive()) {
this.context.close();
@@ -93,14 +94,14 @@ public class JpaApplicationTests {
}
@Test
public void testBatchJobApp() {
public void testBatchJobApp(CapturedOutput capturedOutput) {
final String INSERT_MESSAGE = "Hibernate: insert into task_run_output (";
this.context = SpringApplication
.run(JpaApplication.class, "--spring.datasource.url=" + DATASOURCE_URL,
"--spring.datasource.username=" + DATASOURCE_USER_NAME,
"--spring.datasource.driverClassName=" + DATASOURCE_DRIVER_CLASS_NAME,
"--spring.jpa.database-platform=org.hibernate.dialect.H2Dialect");
String output = this.outputCapture.toString();
String output = capturedOutput.toString();
assertThat(output
.contains(INSERT_MESSAGE)).as("Unable to find the insert message: " + output)
.isTrue();