EventStoreCertificateMojo extends AbstractMojo { @Override public final void execute() throws MojoExecutionException { StaticLoggerBinder.getSingleton().setMavenLog(getLog()); LOG.info("certificateFile={}", certificateFile); if (certificateFile == null || certificateFile.trim().length() == 0) { LOG.info("Skipped generation: No certificate file given"); return; } try { Security.addProvider(new BouncyCastleProvider()); final File file = new File(certificateFile); createSelfSignedCertificate("test.com", file); LOG.info("Certificate successfully created"); } catch (final RuntimeException ex) { throw new MojoExecutionException( "Error generating a self-signed X509 certificate: " + certificateFile, ex); } }  @Override final void execute(); final String getCertificateFile(); final void setCertificateFile(final String certificateFile);  }
@Test public void testExecute() throws MojoExecutionException, IOException { final EventStoreCertificateMojo testee = new EventStoreCertificateMojo(); final File p12File = File.createTempFile("EventStoreCertificateMojoTest-", ".p12"); testee.setCertificateFile(p12File.toString()); testee.execute(); assertThat(p12File).exists(); assertThat(p12File.length()).isGreaterThan(0); }