Package org.apache.ace.agent

Examples of org.apache.ace.agent.ConnectionHandler


        props.put(AgentConstants.CONFIG_CONNECTION_AUTHTYPE, Types.NONE.name());

        ConfigurationHandler configurationHandler = m_agentContext.getHandler(ConfigurationHandler.class);
        configurationHandler.putAll(props);

        ConnectionHandler connectionHandler = m_agentContext.getHandler(ConnectionHandler.class);
        HttpURLConnection connection = (HttpURLConnection) connectionHandler.getConnection(m_basicAuthURL);

        assertEquals(connection.getResponseCode(), HttpServletResponse.SC_FORBIDDEN);
    }
View Full Code Here


        props.put(AgentConstants.CONFIG_CONNECTION_PASSWORD, PASSWORD);

        ConfigurationHandler configurationHandler = m_agentContext.getHandler(ConfigurationHandler.class);
        configurationHandler.putAll(props);

        ConnectionHandler connectionHandler = m_agentContext.getHandler(ConnectionHandler.class);

        HttpURLConnection connection = (HttpURLConnection) connectionHandler.getConnection(m_basicAuthURL);
        assertEquals(connection.getResponseCode(), HttpServletResponse.SC_OK);
    }
View Full Code Here

    /**
     * Tests that we call {@link InputStream#close()} multiple times.
     */
    @Test
    public void testDoubleClosedStreamOk() throws Exception {
        ConnectionHandler handler = new TestConnectionHandler(new CompleteContentConnection(m_content, true));

        ContentRangeInputStream is = new ContentRangeInputStream(handler, m_testURL);
        is.close(); // simulate an early close...
        is.close(); // not a problem...
    }
View Full Code Here

    /**
     * Tests that we can read non-partial content and return the expected contents.
     */
    @Test(expectedExceptions = IOException.class)
    public void testReadClosedStreamFail() throws Exception {
        ConnectionHandler handler = new TestConnectionHandler(new CompleteContentConnection(m_content, true));

        ContentRangeInputStream is = new ContentRangeInputStream(handler, m_testURL);
        is.close(); // simulate an early close...

        is.read(); // should fail!
View Full Code Here

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

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

        assertEquals(slurpAsStringByteForByte(is), content);

        // try several additional reads, which should all return -1 (= EOF)...
View Full Code Here

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

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

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

     */
    @Test
    public void testReadNonPartialEmptyContentOk() throws Exception {
        String content = "";

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

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

        FileOutputStream fos = new FileOutputStream(file);
        fos.write(m_content.getBytes());
        fos.close();

        ConnectionHandler handler = new TestConnectionHandler(file.toURI().toURL().openConnection());
        ContentRangeInputStream is = new ContentRangeInputStream(handler, m_testURL);

        assertEquals(slurpAsStringByteForByte(is), m_content);

        // try several additional reads, which should all return -1 (= EOF)...
View Full Code Here

        FileOutputStream fos = new FileOutputStream(file);
        fos.write(m_content.getBytes());
        fos.close();

        ConnectionHandler handler = new TestConnectionHandler(file.toURI().toURL().openConnection());
        ContentRangeInputStream is = new ContentRangeInputStream(handler, m_testURL, 48);

        assertEquals(slurpAsStringByteForByte(is), m_content.substring(48));

        // try several additional reads, which should all return -1 (= EOF)...
View Full Code Here

     */
    @Test
    public void testReadNonPartialWithoutContentLengthOk() throws Exception {
        String content = "";

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

        assertEquals(slurpAsStringWithBuffer(is), content);
    }
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.