VertxGenerator extends JavaExecGenerator { @Override protected List<String> getExtraJavaOptions() { List<String> opts = super.getExtraJavaOptions(); opts.add("-Dvertx.cacheDirBase=/tmp"); if (! contains("-Dvertx.disableDnsResolver=", opts)) { opts.add("-Dvertx.disableDnsResolver=true"); } if (MavenUtil.hasDependency(getProject(), VERTX_GROUPID, VERTX_DROPWIZARD)) { opts.add("-Dvertx.metrics.options.enabled=true"); opts.add("-Dvertx.metrics.options.jmxEnabled=true"); opts.add("-Dvertx.metrics.options.jmxDomain=vertx"); } if (! contains("-Djava.net.preferIPv4Stack", opts) && MavenUtil.hasDependency(getProject(), VERTX_GROUPID, VERTX_INFINIPAN)) { opts.add("-Djava.net.preferIPv4Stack=true"); } return opts; } VertxGenerator(GeneratorContext context); @Override boolean isApplicable(List<ImageConfiguration> configs);  }
@Test public void testDefaultOptions(@Mocked final MavenProject project) { new Expectations() {{ project.getBuild().getDirectory(); result = new File("target/tmp").getAbsolutePath(); project.getBuild().getOutputDirectory(); result = new File("target/tmp/target").getAbsolutePath(); }}; GeneratorContext context = new GeneratorContext.Builder() .logger(logger) .project(project) .build(); VertxGenerator generator = new VertxGenerator(context); List<String> list = generator.getExtraJavaOptions(); assertThat(list).containsOnly("-Dvertx.cacheDirBase=/tmp", "-Dvertx.disableDnsResolver=true"); }
@Test public void testWithMetrics(@Mocked final MavenProject project) { new Expectations() {{ project.getBuild().getDirectory(); result = new File("target/tmp").getAbsolutePath(); project.getBuild().getOutputDirectory(); result = new File("target/tmp/target").getAbsolutePath(); project.getArtifacts(); result = ImmutableSet.of(dropwizard, core); }}; GeneratorContext context = new GeneratorContext.Builder() .logger(logger) .project(project) .build(); VertxGenerator generator = new VertxGenerator(context); List<String> list = generator.getExtraJavaOptions(); assertThat(list).containsOnly( "-Dvertx.cacheDirBase=/tmp", "-Dvertx.disableDnsResolver=true", "-Dvertx.metrics.options.enabled=true", "-Dvertx.metrics.options.jmxEnabled=true", "-Dvertx.metrics.options.jmxDomain=vertx"); }