org.littleshoot.proxy.impl.ThreadPoolConfiguration Java Examples
The following examples show how to use
org.littleshoot.proxy.impl.ThreadPoolConfiguration.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProxyServerFactory.java From vividus with Apache License 2.0 | 6 votes |
@Override public BrowserUpProxy createProxyServer() { BrowserUpProxyServer proxyServer = new BrowserUpProxyServer(); proxyServer.setHostNameResolver(advancedHostResolver); proxyServer.setTrustAllServers(trustAllServers); proxyServer.enableHarCaptureTypes(captureTypes); if (mitmEnabled) { proxyServer.setMitmManager(mitmManagerFactory.createMitmManager(mitmManagerOptions)); } ThreadPoolConfiguration config = new ThreadPoolConfiguration(); config.withClientToProxyWorkerThreads(PROXY_WORKER_THREADS); config.withProxyToServerWorkerThreads(PROXY_WORKER_THREADS); proxyServer.setThreadPoolConfiguration(config); return proxyServer; }
Example #2
Source File: ProxyServerFactoryTests.java From vividus with Apache License 2.0 | 6 votes |
@Test @PrepareForTest({BrowserUpProxyServer.class, ThreadPoolConfiguration.class, ProxyServerFactory.class}) public void testCreateProxyServerConfigDisableMitm() throws Exception { MitmManagerOptions mitmManagerOptions = mock(MitmManagerOptions.class); IMitmManagerFactory mitmManagerFactory = mock(IMitmManagerFactory.class); MitmManager mitmManager = mock(MitmManager.class); when(mitmManagerFactory.createMitmManager(mitmManagerOptions)).thenReturn(mitmManager); BrowserUpProxyServer mockedServer = mock(BrowserUpProxyServer.class); PowerMockito.whenNew(BrowserUpProxyServer.class).withNoArguments().thenReturn(mockedServer); proxyServerFactory.setMitmManagerOptions(mitmManagerOptions); proxyServerFactory.setMitmManagerFactory(mitmManagerFactory); proxyServerFactory.setMitmEnabled(true); proxyServerFactory.createProxyServer(); verify(mockedServer).setMitmManager(mitmManager); }
Example #3
Source File: TestHttpClient.java From localization_nifi with Apache License 2.0 | 6 votes |
private static void startProxyServerWithAuth() throws IOException { int proxyServerPort; try (final ServerSocket serverSocket = new ServerSocket(0)) { proxyServerPort = serverSocket.getLocalPort(); } proxyServerWithAuth = DefaultHttpProxyServer.bootstrap() .withPort(proxyServerPort) .withAllowLocalOnly(true) .withProxyAuthenticator(new ProxyAuthenticator() { @Override public boolean authenticate(String userName, String password) { return PROXY_USER.equals(userName) && PROXY_PASSWORD.equals(password); } @Override public String getRealm() { return "NiFi Unit Test"; } }) // Use less threads to mitigate Gateway Timeout (504) with proxy test .withThreadPoolConfiguration(new ThreadPoolConfiguration() .withAcceptorThreads(2) .withClientToProxyWorkerThreads(4) .withProxyToServerWorkerThreads(4)) .start(); }
Example #4
Source File: TestHttpClient.java From nifi with Apache License 2.0 | 6 votes |
private static void startProxyServerWithAuth() throws IOException { int proxyServerPort; try (final ServerSocket serverSocket = new ServerSocket(0)) { proxyServerPort = serverSocket.getLocalPort(); } proxyServerWithAuth = DefaultHttpProxyServer.bootstrap() .withPort(proxyServerPort) .withAllowLocalOnly(true) .withProxyAuthenticator(new ProxyAuthenticator() { @Override public boolean authenticate(String userName, String password) { return PROXY_USER.equals(userName) && PROXY_PASSWORD.equals(password); } @Override public String getRealm() { return "NiFi Unit Test"; } }) // Use less threads to mitigate Gateway Timeout (504) with proxy test .withThreadPoolConfiguration(new ThreadPoolConfiguration() .withAcceptorThreads(2) .withClientToProxyWorkerThreads(4) .withProxyToServerWorkerThreads(4)) .start(); }
Example #5
Source File: ProxyServerFactoryTests.java From vividus with Apache License 2.0 | 5 votes |
@Test @PrepareForTest({BrowserUpProxyServer.class, ThreadPoolConfiguration.class, ProxyServerFactory.class}) public void testCreateProxyServerConfig() throws Exception { MitmManagerOptions mitmManagerOptions = mock(MitmManagerOptions.class); IMitmManagerFactory mitmManagerFactory = mock(IMitmManagerFactory.class); MitmManager mitmManager = mock(MitmManager.class); when(mitmManagerFactory.createMitmManager(mitmManagerOptions)).thenReturn(mitmManager); BrowserUpProxyServer mockedServer = mock(BrowserUpProxyServer.class); PowerMockito.whenNew(BrowserUpProxyServer.class).withNoArguments().thenReturn(mockedServer); ThreadPoolConfiguration mockedConfig = mock(ThreadPoolConfiguration.class); PowerMockito.whenNew(ThreadPoolConfiguration.class).withNoArguments().thenReturn(mockedConfig); AdvancedHostResolver hostNameResolver = mock(AdvancedHostResolver.class); boolean trustAllServers = true; proxyServerFactory.setMitmManagerOptions(mitmManagerOptions); proxyServerFactory.setMitmManagerFactory(mitmManagerFactory); proxyServerFactory.setTrustAllServers(trustAllServers); proxyServerFactory.setMitmEnabled(true); proxyServerFactory.setAdvancedHostResolver(hostNameResolver); proxyServerFactory.setCaptureTypes(CaptureType.getAllContentCaptureTypes()); proxyServerFactory.createProxyServer(); int expectedThreadsCount = 16; verify(mockedConfig).withClientToProxyWorkerThreads(expectedThreadsCount); verify(mockedConfig).withProxyToServerWorkerThreads(expectedThreadsCount); verify(mockedServer).setTrustAllServers(trustAllServers); verify(mockedServer).setMitmManager(mitmManager); verify(mockedServer).setThreadPoolConfiguration(mockedConfig); verify(mockedServer).setHostNameResolver(hostNameResolver); verify(mockedServer).enableHarCaptureTypes(CaptureType.getAllContentCaptureTypes()); }
Example #6
Source File: BrowserUpProxyServer.java From browserup-proxy with Apache License 2.0 | 5 votes |
/** * Configures the Netty thread pool used by the LittleProxy back-end. See {@link ThreadPoolConfiguration} for details. * * @param threadPoolConfiguration thread pool configuration to use */ public void setThreadPoolConfiguration(ThreadPoolConfiguration threadPoolConfiguration) { if (isStarted()) { throw new IllegalStateException("Cannot configure thread pool after proxy has started."); } this.threadPoolConfiguration = threadPoolConfiguration; }
Example #7
Source File: BrowserMobProxyServer.java From CapturePacket with MIT License | 5 votes |
/** * Configures the Netty thread pool used by the LittleProxy back-end. See {@link ThreadPoolConfiguration} for details. * * @param threadPoolConfiguration thread pool configuration to use */ public void setThreadPoolConfiguration(ThreadPoolConfiguration threadPoolConfiguration) { if (isStarted()) { throw new IllegalStateException("Cannot configure thread pool after proxy has started."); } this.threadPoolConfiguration = threadPoolConfiguration; }
Example #8
Source File: TestHttpClient.java From localization_nifi with Apache License 2.0 | 5 votes |
private static void startProxyServer() throws IOException { int proxyServerPort; try (final ServerSocket serverSocket = new ServerSocket(0)) { proxyServerPort = serverSocket.getLocalPort(); } proxyServer = DefaultHttpProxyServer.bootstrap() .withPort(proxyServerPort) .withAllowLocalOnly(true) // Use less threads to mitigate Gateway Timeout (504) with proxy test .withThreadPoolConfiguration(new ThreadPoolConfiguration() .withAcceptorThreads(2) .withClientToProxyWorkerThreads(4) .withProxyToServerWorkerThreads(4)) .start(); }
Example #9
Source File: BrowserMobProxyServer.java From Dream-Catcher with MIT License | 5 votes |
/** * Configures the Netty thread pool used by the LittleProxy back-end. See {@link ThreadPoolConfiguration} for details. * * @param threadPoolConfiguration thread pool configuration to use */ public void setThreadPoolConfiguration(ThreadPoolConfiguration threadPoolConfiguration) { if (isStarted()) { throw new IllegalStateException("Cannot configure thread pool after proxy has started."); } this.threadPoolConfiguration = threadPoolConfiguration; }
Example #10
Source File: BrowserMobProxyServer.java From AndroidHttpCapture with MIT License | 5 votes |
/** * Configures the Netty thread pool used by the LittleProxy back-end. See {@link ThreadPoolConfiguration} for details. * * @param threadPoolConfiguration thread pool configuration to use */ public void setThreadPoolConfiguration(ThreadPoolConfiguration threadPoolConfiguration) { if (isStarted()) { throw new IllegalStateException("Cannot configure thread pool after proxy has started."); } this.threadPoolConfiguration = threadPoolConfiguration; }
Example #11
Source File: TestHttpClient.java From nifi with Apache License 2.0 | 5 votes |
private static void startProxyServer() throws IOException { int proxyServerPort; try (final ServerSocket serverSocket = new ServerSocket(0)) { proxyServerPort = serverSocket.getLocalPort(); } proxyServer = DefaultHttpProxyServer.bootstrap() .withPort(proxyServerPort) .withAllowLocalOnly(true) // Use less threads to mitigate Gateway Timeout (504) with proxy test .withThreadPoolConfiguration(new ThreadPoolConfiguration() .withAcceptorThreads(2) .withClientToProxyWorkerThreads(4) .withProxyToServerWorkerThreads(4)) .start(); }
Example #12
Source File: HttpProxyServerBootstrap.java From g4proxy with Apache License 2.0 | 2 votes |
/** * Set the configuration parameters for the proxy's thread pools. * * @param configuration thread pool configuration * @return proxy server bootstrap for chaining */ HttpProxyServerBootstrap withThreadPoolConfiguration(ThreadPoolConfiguration configuration);