forked from pinpoint-apm/pinpoint
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[pinpoint-apm#8965] Apply SharedTestLifeCycle to PostSql
- Loading branch information
Showing
6 changed files
with
65 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...jdbc-it/src/test/java/com/navercorp/pinpoint/plugin/jdbc/postgresql/PostgreSqlServer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.navercorp.pinpoint.plugin.jdbc.postgresql; | ||
|
||
import com.navercorp.pinpoint.test.plugin.shared.SharedTestLifeCycle; | ||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.junit.Assume; | ||
import org.testcontainers.DockerClientFactory; | ||
import org.testcontainers.containers.PostgreSQLContainer; | ||
|
||
import java.util.Properties; | ||
|
||
public class PostgreSqlServer implements SharedTestLifeCycle { | ||
private final Logger logger = LogManager.getLogger(getClass()); | ||
|
||
private PostgreSQLContainer postgreSql; | ||
|
||
@Override | ||
public Properties beforeAll() { | ||
Assume.assumeTrue("Docker not enabled", DockerClientFactory.instance().isDockerAvailable()); | ||
|
||
postgreSql = PostgreSQLContainerFactory.newContainer(logger.getName()); | ||
|
||
postgreSql.start(); | ||
|
||
Properties properties = new Properties(); | ||
properties.setProperty("JDBC_URL", postgreSql.getJdbcUrl()); | ||
properties.setProperty("USERNAME", postgreSql.getUsername()); | ||
properties.setProperty("PASSWORD", postgreSql.getPassword()); | ||
return properties; | ||
} | ||
|
||
@Override | ||
public void afterAll() { | ||
if (postgreSql != null) { | ||
postgreSql.stop(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters