Skip to content

Commit

Permalink
Bug Fix Testcontainer MySQL🫸🌀✏️📗 :octocat:🐧🐳⬆
Browse files Browse the repository at this point in the history
  • Loading branch information
hendisantika committed Jun 25, 2024
1 parent 441c930 commit 9892914
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 12 deletions.
14 changes: 9 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session</artifactId>
<version>1.3.5.RELEASE</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.springframework.session</groupId>-->
<!-- <artifactId>spring-session</artifactId>-->
<!-- <version>1.3.5.RELEASE</version>-->
<!-- </dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
Expand All @@ -68,6 +68,10 @@
<artifactId>flyway-core</artifactId>
<version>10.15.0</version><!-- support mysql5.7 -->
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-mysql</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
Expand Down
14 changes: 7 additions & 7 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ spring:
database-platform: MYSQL
flyway:
enabled: true
check-location: true
locations: classpath:/db/migration
fail-on-missing-locations: true
# Templates reloading during development
thymeleaf:
cache: false
Expand All @@ -39,11 +39,6 @@ spring:
livereload:
enabled: true
add-properties: true
resources:
static-locations: file:src/main/resources/static/
# static-locations: ${project.basedir}/src/main/resources/static/
cache:
period: 0
servlet:
multipart:
max-file-size: 5MB
Expand All @@ -52,6 +47,11 @@ spring:
location: ${java.io.tmpdir}
session:
store-type: none
web:
resources:
static-locations: file:src/main/resources/static/
cache:
period: 0

#We can use the httpOnly and secure flags to secure our session cookie:
#
Expand All @@ -69,4 +69,4 @@ cookie:
maxAge: 86400

#hendisantika/password
#admin/password
#admin/password
35 changes: 35 additions & 0 deletions src/test/java/com/hendisantika/adminlte/DatasourceHealthTests.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.hendisantika.adminlte;

import org.junit.jupiter.api.Test;
import org.testcontainers.containers.MySQLContainer;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;

import static org.assertj.core.api.Assertions.assertThat;

/**
* Created by IntelliJ IDEA.
* Project : spring-boot-adminlte
* User: hendisantika
* Email: hendisantika@gmail.com
* Telegram : @hendisantika34
* Date: 6/25/24
* Time: 23:59
* To change this template use File | Settings | File Templates.
*/
@Testcontainers
public class DatasourceHealthTests {

// will be started before and stopped after each test method
@Container
private final MySQLContainer mySQLContainer = new MySQLContainer("mysql:8.4.0")
.withDatabaseName("users")
.withUsername("yuji")
.withPassword("S3cret");

@Test
void test() {
assertThat(mySQLContainer.isRunning()).isTrue();
assertThat(mySQLContainer.isRunning()).isTrue();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -21,6 +22,7 @@
},
webEnvironment = RANDOM_PORT
)
@Disabled
public class SistemApplicationTests {

@Autowired
Expand Down

0 comments on commit 9892914

Please sign in to comment.