Skip to content

Commit

Permalink
Adjust native image test to combine container start and executing tes…
Browse files Browse the repository at this point in the history
…t-native-image executable
  • Loading branch information
rbygrave committed Oct 30, 2023
1 parent c38fc9b commit 3cd5d57
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 26 deletions.
37 changes: 18 additions & 19 deletions test-native-image/src/main/java/org/example/Main.java
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
package org.example;

import io.ebean.migration.*;
import io.ebean.migration.MigrationConfig;
import io.ebean.migration.MigrationRunner;

import java.io.InputStream;
import java.util.List;
import java.util.Properties;
import java.net.URL;

public class Main {

public static void main(String[] args) {
// InputStream is = Main.class.getResourceAsStream("/dbmigration/postgres/idx_postgres.migrations");
// System.out.println("GOT is: " + is);
public static void main(String[] args) {
URL url = Main.class.getResource("/dbmigration/postgres/idx_postgres.migrations");
System.out.println("Found idx_postgres.migrations: " + url);

MigrationConfig config = new MigrationConfig();
config.setDbUsername("mig");
config.setDbPassword("test");
config.setDbUrl("jdbc:postgresql://localhost:6432/mig");
config.setBasePlatform("postgres");
config.setPlatform("postgres");
config.setMigrationPath("dbmigration");
MigrationConfig config = new MigrationConfig();
config.setDbUsername("mig");
config.setDbPassword("test");
config.setDbUrl("jdbc:postgresql://localhost:6432/mig");
config.setBasePlatform("postgres");
config.setPlatform("postgres");
config.setMigrationPath("dbmigration");

MigrationRunner runner = new MigrationRunner(config);
runner.run();
MigrationRunner runner = new MigrationRunner(config);
runner.run();

//System.out.println("state: " + runner.checkState());
System.out.println("DONE");
}
//System.out.println("state: " + runner.checkState());
System.out.println("DONE");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,16 @@
class StartPostgresContainerTest {

@Test
void test() {
PostgresContainer.builder("15")
void test() throws Exception {
PostgresContainer container = PostgresContainer.builder("15")
.port(6432)
.dbName("mig")
.build()
.start();
}

@Test
void run() throws Exception {
File out = new File("out");
System.out.println("Postgres container running " + container.isRunning());

var out = new File("out");

Process process = new ProcessBuilder()
.command("./target/test-native-image")
Expand All @@ -31,7 +30,7 @@ void run() throws Exception {
.start();

int code = process.waitFor();
System.out.println("exit " + code);
System.out.println("exit code: " + code);

Files.lines(out.toPath()).forEach(System.out::println);
}
Expand Down

0 comments on commit 3cd5d57

Please sign in to comment.