-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
53 additions
and
1 deletion.
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
52 changes: 52 additions & 0 deletions
52
src/test/java/liquibase/ext/percona/VerifyLiquibaseCoreTest.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,52 @@ | ||
package liquibase.ext.percona; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertAll; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import java.io.IOException; | ||
import java.net.URI; | ||
import java.net.URISyntaxException; | ||
import java.net.URL; | ||
import java.nio.charset.StandardCharsets; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import org.apache.commons.io.IOUtils; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import liquibase.util.LiquibaseUtil; | ||
|
||
class VerifyLiquibaseCoreTest { | ||
|
||
@Test | ||
void liquibaseUtilVersion() { | ||
assertEquals("4.29.2", LiquibaseUtil.getBuildVersion()); | ||
assertEquals("3683", LiquibaseUtil.getBuildNumber()); | ||
assertEquals("2024-08-29 16:45+0000", LiquibaseUtil.getBuildTime()); | ||
assertEquals("4.29.2", LiquibaseUtil.getBuildVersionInfo()); | ||
} | ||
|
||
@Test | ||
void liquibaseCoreJar() throws URISyntaxException, IOException, InterruptedException { | ||
URL liquibaseCoreLocation = LiquibaseUtil.class.getProtectionDomain().getCodeSource().getLocation(); | ||
assertTrue(liquibaseCoreLocation.toString().endsWith("liquibase-core-4.29.2.jar"), "Unexpected file path: " + liquibaseCoreLocation); | ||
Path liquibaseCore = Paths.get(liquibaseCoreLocation.toURI()); | ||
assertTrue(Files.exists(liquibaseCore), "File doesn't exist: " + liquibaseCore); | ||
|
||
Process process = new ProcessBuilder("md5sum", liquibaseCore.toString()).start(); | ||
String md5sum = IOUtils.toString(process.getInputStream(), StandardCharsets.UTF_8).substring(0, 32); | ||
process.waitFor(10, TimeUnit.SECONDS); | ||
|
||
String md5sumCentral = IOUtils.toString(URI.create("https://repo.maven.apache.org/maven2/org/liquibase/liquibase-core/4.29.2/liquibase-core-4.29.2.jar.md5"), | ||
StandardCharsets.UTF_8); | ||
|
||
assertAll( | ||
() -> assertEquals(2884238L, Files.size(liquibaseCore), "Unexpected file size"), | ||
() -> assertEquals("82d2385a0349310b2c6c994b6d5add13", md5sum, "Unexpected checksum"), | ||
() -> assertEquals(md5sumCentral, md5sum) | ||
); | ||
} | ||
} |