use of com.github.tomakehurst.wiremock.extension.responsetemplating.ResponseTemplateTransformer in project irontest by zheng-wang.
the class IronTestApplication method run.
@Override
public void run(IronTestConfiguration configuration, Environment environment) throws IOException {
final JdbiFactory jdbiFactory = new JdbiFactory();
final Jdbi systemDBJdbi = jdbiFactory.build(environment, configuration.getSystemDatabase(), "systemDatabase");
// compare system database version with uber jar version to see whether an upgrade is needed
Integer versionTableCount = systemDBJdbi.withHandle(handle -> handle.createQuery("select count(*) from information_schema.tables where table_name = 'VERSION'").mapTo(Integer.class).findOnly());
if (versionTableCount == 1) {
// VERSION table exists in the system database (i.e. we are not starting a brand new Iron Test build)
if (!checkVersion(systemDBJdbi)) {
System.out.println("Press Enter to exit.");
System.in.read();
System.exit(0);
}
}
// by 'new SSLContextBuilder().loadTrustMaterial').
if (new File(configuration.getSslTrustStorePath()).exists()) {
System.setProperty("javax.net.ssl.trustStore", configuration.getSslTrustStorePath());
System.setProperty("javax.net.ssl.trustStorePassword", configuration.getSslTrustStorePassword());
}
// start WireMock server (in the same JVM)
WireMockServer wireMockServer = new WireMockServer(options().extensions(new ResponseTemplateTransformer(true)).port(Integer.parseInt(configuration.getWireMock().get("port"))).maxRequestJournalEntries(Integer.parseInt(configuration.getWireMock().get("maxRequestJournalEntries"))).notifier(new WireMockFileNotifier()));
wireMockServer.start();
createSystemResources(configuration, environment, systemDBJdbi, wireMockServer);
createSampleResources(configuration, environment);
environment.lifecycle().addServerLifecycleListener(new ServerLifecycleListener() {
@Override
public void serverStarted(Server server) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("Iron Test started with UI address http://localhost:" + +getLocalPort(server) + "/ui");
System.out.println();
}
});
}
Aggregations