JavaFx extends Application implements UserAgent, Runnable, RunnableFactory<JavaFx> { @Override public AuthorizationResponse requestAuthorizationCode(final URI authorizationEndpoint, final URI redirectUri) throws AuthorizationException { interceptingBrowser.sendRequest(authorizationEndpoint, redirectUri); return interceptingBrowser.waitForResponse(); } JavaFx(); static void main(final String[] args); @Override AuthorizationResponse requestAuthorizationCode(final URI authorizationEndpoint, final URI redirectUri); @Override void start(final Stage primaryStage); @Override void stop(); @Override void run(); @Override Runnable create(final JavaFx javaFx);  }
@Category(IntegrationTests.class) @Ignore("JavaFX fails if Application.launch() is called more than once; the other test is more important.") @Test public void nullPointerException() { expectedExceptionRef.set(new NullPointerException()); final String[] args = {UserAgentImpl.REQUEST_AUTHORIZATION_CODE}; JavaFx.RUNNABLE_FACTORY_OVERRIDE = new RunnableFactory<JavaFx>() { public Runnable create(final JavaFx javaFx) { return new Runnable() { public void run() { try { javaFx.requestAuthorizationCode(null, null); } catch (final Exception e) { actualExceptionRef.set(e); } finally { Platform.exit(); } } }; } }; LauncherImpl.launchApplication(JavaFx.class, args); }
@Category(IntegrationTests.class) @Test public void insecureWiremock() throws URISyntaxException, AuthorizationException { expectedExceptionRef.set(new AuthorizationException("load_error", "java.lang.Throwable: SSL handshake failed", null, null)); final int insecurePort = wireMockRule.httpsPort(); final URI authorizationEndpoint = new URI(INSECURE_PROTOCOL, null, HOST, insecurePort, "/oauth2/authorize", "response_type=code&client_id=insecureWiremock&state=chicken", null); final URI redirectUri = new URI(INSECURE_PROTOCOL, null, HOST, insecurePort, "/finished", null, null); stubFor(get(urlEqualTo(authorizationEndpoint.getPath() + "?" + authorizationEndpoint.getQuery())) .willReturn(aResponse() .withStatus(200) .withHeader("Content-Type", "text/html"))); JavaFx.RUNNABLE_FACTORY_OVERRIDE = new RunnableFactory<JavaFx>() { public Runnable create(final JavaFx javaFx) { return new Runnable() { public void run() { try { javaFx.requestAuthorizationCode(authorizationEndpoint, redirectUri); } catch (final Exception e) { actualExceptionRef.set(e); } finally { Platform.exit(); } } }; } }; LauncherImpl.launchApplication(JavaFx.class, null); }