Codota Logo
ServiceUnavailableHandler
Code IndexAdd Codota to your IDE (free)

How to use
ServiceUnavailableHandler
in
ro.polak.http

Best Java code snippets using ro.polak.http.ServiceUnavailableHandler (Showing top 4 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
List l =
  • Codota Iconnew LinkedList()
  • Codota IconCollections.emptyList()
  • Codota Iconnew ArrayList()
  • Smart code suggestions by Codota
}
origin: piotrpolak/android-http-server

@Before
public void setUp() throws Exception {
  outputStream = new ByteArrayOutputStream();
  factory = mock(HttpServletResponseImplFactory.class);
  HttpServletResponseImpl response = mock(HttpServletResponseImpl.class);
  printWriter = new PrintWriter(outputStream);
  when(response.getWriter()).thenReturn(printWriter);
  when(factory.createFromSocket(any(Socket.class))).thenReturn(response);
  serviceUnavailableHandler = new ServiceUnavailableHandler(factory);
}
origin: piotrpolak/android-http-server

  @Test
  public void shouldHandleServerRunnable() throws Exception {
    serviceUnavailableHandler.rejectedExecution(mock(ServerRunnable.class), null);
    verify(factory, times(1)).createFromSocket(any(Socket.class));
    printWriter.flush();
    assertThat(outputStream.toString(), containsString("503"));
  }
}
origin: piotrpolak/android-http-server

public ServiceContainer(final ServerConfig serverConfig) {
  HeadersParser headersParser = new HeadersParser();
  requestWrapperFactory = new HttpServletRequestImplFactory(headersParser,
      new QueryStringParser(),
      new RequestStatusParser(),
      new CookieParser(),
      new MultipartHeadersPartParser(headersParser),
      serverConfig.getTempPath()
  );
  responseFactory = new HttpServletResponseImplFactory(
      new HeadersSerializer(),
      new CookieHeaderSerializer(new DateProvider()),
      new StreamHelper(
          new RangeHelper(),
          new RangePartHeaderSerializer()
      )
  );
  threadPoolExecutor = new ThreadPoolExecutor(1, serverConfig.getMaxServerThreads(),
      DEFAULT_TIME_UNITS, TimeUnit.SECONDS,
      new ArrayBlockingQueue<Runnable>(serverConfig.getMaxServerThreads() * MAX_THREADS_MULTIPLIER),
      Executors.defaultThreadFactory(),
      new ServiceUnavailableHandler(responseFactory)
  );
  httpErrorHandlerResolver = new HttpErrorHandlerResolverImpl(serverConfig);
  pathHelper = new PathHelper();
}
origin: piotrpolak/android-http-server

@Test
public void shouldIgnoreRunnableThatIsNotServerRunnable() throws Exception {
  serviceUnavailableHandler.rejectedExecution(mock(Runnable.class), null);
  verify(factory, never()).createFromSocket(any(Socket.class));
}
ro.polak.httpServiceUnavailableHandler

Javadoc

ServiceUnavailableHandler is responsible for sending 503 error pages when there is more space in the runnable queue. To test this class you have to limit the number of available threads and queue size to 1 and then to try open multiple connections at the same time.

Most used methods

  • <init>
    Default constructor.
  • rejectedExecution

Popular in Java

  • Finding current android device location
  • notifyDataSetChanged (ArrayAdapter)
  • setRequestProperty (URLConnection)
  • getContentResolver (Context)
  • Menu (java.awt)
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • JButton (javax.swing)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now