Example usage for org.apache.commons.collections4.queue CircularFifoQueue toString

List of usage examples for org.apache.commons.collections4.queue CircularFifoQueue toString

Introduction

In this page you can find the example usage for org.apache.commons.collections4.queue CircularFifoQueue toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:com.thoughtworks.go.publishers.GoArtifactsManipulatorTest.java

@Test
public void shouldBombWithErrorWhenStatusCodeReturnedIsRequestEntityTooLarge()
        throws IOException, InterruptedException {
    when(httpService.upload(any(String.class), eq(tempFile.length()), any(File.class), any(Properties.class)))
            .thenReturn(HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE);

    CircularFifoQueue buffer = (CircularFifoQueue) ReflectionUtil
            .getField(ReflectionUtil.getField(goPublisher, "consoleOutputTransmitter"), "buffer");
    synchronized (buffer) {
        try {/*  www  .  j av a  2  s  .c o  m*/
            goArtifactsManipulatorStub.publish(goPublisher, "some_dest", tempFile, jobIdentifier);
            fail("should have thrown request entity too large error");
        } catch (RuntimeException e) {
            String expectedMessage = "Artifact upload for file " + tempFile.getAbsolutePath() + " (Size: "
                    + tempFile.length()
                    + ") was denied by the server. This usually happens when server runs out of disk space.";
            assertThat(e.getMessage(),
                    is("java.lang.RuntimeException: " + expectedMessage + ".  HTTP return code is 413"));
            assertThat(buffer.toString().contains(expectedMessage), is(true));
        }
    }
}