@Override protected void configure() { bind(ImposterConfig.class).in(Singleton.class); } }
@Override protected void configure(ImposterConfig imposterConfig) throws Exception { super.configure(imposterConfig); }
/** * Main entry point. * * @param args the user command line arguments. */ public static void main(String[] args) { LogUtil.configureLogging(System.getProperty(LogUtil.PROPERTY_LOG_LEVEL, "DEBUG")); new ImposterLauncher().dispatch(args); }
@Before public void setUp(TestContext testContext) throws Exception { final Async async = testContext.async(); listenPort = findFreePort(); // simulate ImposterLauncher injector bootstrap final ImposterConfig imposterConfig = InjectorUtil.create(new BootstrapModule()).getInstance(ImposterConfig.class); configure(imposterConfig); rule.vertx().deployVerticle(ImposterVerticle.class.getCanonicalName(), completion -> { if (completion.succeeded()) { async.complete(); } else { testContext.fail(completion.cause()); } }); }
@Before public void setUp(TestContext testContext) throws Exception { super.setUp(testContext); RestAssured.baseURI = "http://" + HOST + ":" + getListenPort(); }
@Before public void setUp(TestContext testContext) throws Exception { super.setUp(testContext); // set up trust store for TLS RestAssured.trustStore(CryptoUtil.getDefaultKeystore(ImposterVerticleTest.class).toFile(), CryptoUtil.DEFAULT_KEYSTORE_PASSWORD); RestAssured.baseURI = "https://" + HOST + ":" + getListenPort(); }
@Override public void dispatch(String[] originalArgs) { final CmdLineParser parser = new CmdLineParser(this); try { parser.parseArgument(originalArgs); if (displayHelp) { printUsage(parser, 0); } else if (displayVersion) { printVersion(); } else { startServer(originalArgs); } } catch (CmdLineException e) { // handling of wrong arguments if (LOGGER.isDebugEnabled()) { LOGGER.debug(e); } else { LOGGER.error(e.getMessage()); } printUsage(parser, 255); } catch (Exception e) { LOGGER.error("Error starting server", e); } }
private void startServer(String[] originalArgs) { InjectorUtil.create(new BootstrapModule()).injectMembers(this); if (isNull(pluginClassNames) || 0 == pluginClassNames.length) { LOGGER.debug("No plugins specified - attempting to load defaults"); // check for list of comma-separated plugin classes to load if none specified pluginClassNames = ofNullable(MetaUtil.readMetaProperties().getProperty("plugins")) .map(plugin -> plugin.split(",")) .orElse(new String[0]); } final Map<String, String> splitArgs = Arrays.stream(ofNullable(pluginArgs).orElse(new String[0])) .map(arg -> arg.split("=")) .collect(Collectors.toMap(splitArg -> splitArg[0], splitArg -> splitArg[1])); imposterConfig.setConfigDirs(configDirs); imposterConfig.setPluginClassNames(pluginClassNames); imposterConfig.setListenPort(listenPort); imposterConfig.setHost(host); imposterConfig.setServerUrl(serverUrl); imposterConfig.setTlsEnabled(tlsEnabled); imposterConfig.setKeystorePath(keystorePath); imposterConfig.setKeystorePassword(keystorePassword); imposterConfig.setPluginArgs(splitArgs); final List<String> args = Lists.newArrayList(originalArgs); args.add(0, "run"); args.add(1, ImposterVerticle.class.getCanonicalName()); super.dispatch(args.toArray(new String[args.size()])); }
private void startServer(Future<Void> startFuture) { final Router router = configureRoutes(); .listen(imposterConfig.getListenPort(), imposterConfig.getHost(), resolveFutureOnCompletion(startFuture));
@Override public void stop(Future<Void> stopFuture) { LOGGER.info("Stopping mock server on {}:{}", imposterConfig.getHost(), imposterConfig.getListenPort()); ofNullable(httpServer).ifPresent(server -> server.close(resolveFutureOnCompletion(stopFuture))); }
@Override public void start(Future<Void> startFuture) throws Exception { LOGGER.debug("Initialising mock server"); new Imposter().start(); InjectorUtil.getInjector().injectMembers(this); startServer(startFuture); }
protected void configure(ImposterConfig imposterConfig) throws Exception { imposterConfig.setConfigDirs(new String[]{Paths.get(getClass().getResource("/config").toURI()).toString()}); imposterConfig.setPluginClassNames(new String[]{getPluginClass().getCanonicalName()}); imposterConfig.setHost(HOST); imposterConfig.setListenPort(listenPort); imposterConfig.setPluginArgs(emptyMap()); }
@Override protected void configure(ImposterConfig imposterConfig) throws Exception { super.configure(imposterConfig); // enable TLS imposterConfig.setTlsEnabled(true); imposterConfig.setKeystorePath(CLASSPATH_PREFIX + DEFAULT_KEYSTORE_PATH); imposterConfig.setKeystorePassword(DEFAULT_KEYSTORE_PASSWORD); }
@Before public void setUp(TestContext testContext) throws Exception { super.setUp(testContext); RestAssured.baseURI = "http://" + HOST + ":" + getListenPort(); }
@Override protected void configure(ImposterConfig imposterConfig) throws Exception { super.configure(imposterConfig); // enable TLS imposterConfig.setTlsEnabled(true); imposterConfig.setKeystorePath(CLASSPATH_PREFIX + DEFAULT_KEYSTORE_PATH); imposterConfig.setKeystorePassword(DEFAULT_KEYSTORE_PASSWORD); }
@Before public void setUp(TestContext testContext) throws Exception { super.setUp(testContext); // set up trust store for TLS System.setProperty("javax.net.ssl.trustStore", CryptoUtil.getDefaultKeystore(SfdcPluginImplTest.class).toString()); System.setProperty("javax.net.ssl.trustStorePassword", CryptoUtil.DEFAULT_KEYSTORE_PASSWORD); System.setProperty("javax.net.ssl.trustStoreType", "JKS"); // for localhost testing only javax.net.ssl.HttpsURLConnection.setDefaultHostnameVerifier( (hostname, sslSession) -> hostname.equals("localhost")); }