Package org.apache.ace.agent

Examples of org.apache.ace.agent.ConnectionHandler


     */
    @Test
    public void testReadPartialContentByteForByteOk() throws Exception {
        String content = m_content;

        ConnectionHandler handler = new TestConnectionHandler(new PartialContentConnection(content, false));
        ContentRangeInputStream is = new ContentRangeInputStream(handler, m_testURL);

        assertEquals(slurpAsStringByteForByte(is), content);
    }
View Full Code Here


    /**
     * Tests that we cannot read partial content if the content is not available.
     */
    @Test(expectedExceptions = IOException.class)
    public void testReadPartialContentNotFoundFail() throws Exception {
        ConnectionHandler handler = new TestConnectionHandler(new FailingContentConnection(m_content, Failure.CONTENT_NOT_FOUND));
        ContentRangeInputStream is = null;

        try {
            is = new ContentRangeInputStream(handler, m_testURL);
            is.read(); // should fail!
View Full Code Here

     */
    @Test
    public void testReadPartialContentOk() throws Exception {
        String content = m_content;

        ConnectionHandler handler = new TestConnectionHandler(new PartialContentConnection(content, false));
        ContentRangeInputStream is = new ContentRangeInputStream(handler, m_testURL);

        assertEquals(slurpAsStringWithBuffer(is), content);
    }
View Full Code Here

     */
    @Test
    public void testReadPartialContentWithUnknownChunkSizeOk() throws Exception {
        String content = m_content;

        ConnectionHandler handler = new TestConnectionHandler(new FailingContentConnection(content, Failure.PARTIAL_UNKNOWN_CHUNK_SIZE));
        ContentRangeInputStream is = new ContentRangeInputStream(handler, m_testURL);

        assertEquals(slurpAsStringWithBuffer(is), content.substring(48));
    }
View Full Code Here

    /**
     * Tests that we cannot read partial content if the server is not available.
     */
    @Test(expectedExceptions = RetryAfterException.class)
    public void testReadPartialContentServerUnavailableFail() throws Exception {
        ConnectionHandler handler = new TestConnectionHandler(new FailingContentConnection(m_content, Failure.SERVER_UNAVAILABLE));
        ContentRangeInputStream is = null;

        try {
            is = new ContentRangeInputStream(handler, m_testURL);
            is.read(); // should fail!
View Full Code Here

    /**
     * Tests that we cannot read partial content if the server returns a complete body.
     */
    @Test(expectedExceptions = IOException.class)
    public void testReadPartialContentWithChangingContentLengthFail() throws Exception {
        ConnectionHandler handler = new TestConnectionHandler(new FailingContentConnection(m_content, Failure.PARTIAL_CHANGING_CONTENT_LENGTH));
        ContentRangeInputStream is = null;

        try {
            is = new ContentRangeInputStream(handler, m_testURL);
            is.read(new byte[1024]); // should succeed.
View Full Code Here

    @Test
    public void testReadPartialContentWithChunkSizeOk() throws Exception {
        String content = m_content;

        PartialContentConnection conn = new PartialContentConnection(content, false);
        ConnectionHandler handler = new TestConnectionHandler(conn);
        // should cause chunks of 1024 bytes to be used, which means 4 complete chunks and one chunk of 704 bytes...
        ContentRangeInputStream is = new ContentRangeInputStream(handler, m_testURL, 0, 1024);

        assertEquals(slurpAsStringWithBuffer(is), content);
View Full Code Here

    /**
     * Tests that we cannot read partial content if the server returns a complete body.
     */
    @Test(expectedExceptions = IOException.class)
    public void testReadPartialContentWithCompleteBodyFail() throws Exception {
        ConnectionHandler handler = new TestConnectionHandler(new FailingContentConnection(m_content, Failure.PARTIAL_COMPLETE_BODY));
        ContentRangeInputStream is = null;

        try {
            is = new ContentRangeInputStream(handler, m_testURL);
            is.read(new byte[1024]); // should succeed.
View Full Code Here

     */
    @Test
    public void testReadPartialContentWithDeferredTotalLengthOk() throws Exception {
        String content = m_content;

        ConnectionHandler handler = new TestConnectionHandler(new PartialContentConnection(content, true));
        ContentRangeInputStream is = new ContentRangeInputStream(handler, m_testURL);

        assertEquals(slurpAsStringWithBuffer(is), content);
    }
View Full Code Here

    @Test
    public void testReadPartialContentWithOffsetAndChunkSizeOk() throws Exception {
        String content = m_content;

        PartialContentConnection conn = new PartialContentConnection(content, false);
        ConnectionHandler handler = new TestConnectionHandler(conn);
        // 4752 + 48 = 4800, causing only one chunk to be returned...
        ContentRangeInputStream is = new ContentRangeInputStream(handler, m_testURL, 48, 4752);

        assertEquals(slurpAsStringWithBuffer(is), content.substring(48));
    }
View Full Code Here

TOP

Related Classes of org.apache.ace.agent.ConnectionHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.