org.jcoderz.commons.connector.http.transport
Class HttpClientConnectionTest

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.jcoderz.commons.TestCase
              extended by org.jcoderz.commons.connector.http.transport.HttpClientConnectionTest
All Implemented Interfaces:
Test

public class HttpClientConnectionTest
extends TestCase

This class test the implementation of the HttpConnectionInterface provided via the Jakarta commons-httpclient project.

Author:
anonymous

Constructor Summary
HttpClientConnectionTest()
           
 
Method Summary
static void main(String[] args)
          Main.
protected  void setUp()
          Setup creates a new interface implementation object.
static Test suite()
          Creates the testsuite.
protected  void tearDown()
          TearDown of the TestCase.
 void testCloseConnectionFailed()
          Multiple closing fails.
 void testCloseConnectionSuccessAfterSending()
          Closes the connection after successful sending.
 void testEstablishConnection()
          Tests establishing a connection.
 void testExecuteFailed()
          Executes connection without establishing before.
 void testReleaseConnectionFailed()
          Tests error case with a missing "releaseConnection" call before reusing an already opened connection.
 void testReleaseConnectionSuccessMultipleUse()
          Releases a connection multiple times.
 void testReleaseConnectionSuccessWithOneSendMessage()
          Tests releasing the connection and sending a second message without sending the first message.
 void testReleaseConnectionSuccessWithTwoSendMessages()
          Tests the release of connection after sending a message and a sending anew after releasing.
 void testReleaseConnectionWithInvalidState()
          Release a not established connection.
 void testSendMultiplePostRequestAfterServerClose()
          Sends a request with Connection=close and receives the response.
 void testSendSimplePostRequest()
          Performs establishing a connection, creating a request, sending that request, receiving the response and closing the connection.
 void testSendSimplePostRequestToNotExistingTarget()
          Sends post request without a waiting server.
 void testSendSimplePostRequestWithEmptyResponseBody()
          Tests if the correct exception is thrown if the http response body received is empty.
 void testSendSimplePostRequestWithExpectedResponseHeaderFailed()
          Tests if the correct exception is thrown if evaluating a response header key value pair set for the connection has been failed.
 void testSendSimplePostRequestWithExpectedResponseHeaderSuccess()
          Tests if a response header key value pair set for the connection has been evaluated correctly.
 void testSendSimplePostRequestWithImmediateClose()
          Sends a request and expects a immediate close on server side.
 void testSendSimplePostRequestWithoutResponse()
          Sends a request and expects no response.
 void testSendSimplePostRequestWithSSL()
          Performs establishing a connection (to SubwayCA) , creating a request, sending that request, receiving the response and closing the connection USING SSL.
 
Methods inherited from class org.jcoderz.commons.TestCase
getBaseDir, getHostName, getSuite, hasTestCases
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HttpClientConnectionTest

public HttpClientConnectionTest()
Method Detail

main

public static void main(String[] args)
Main.

Parameters:
args - main arguments

suite

public static Test suite()
Creates the testsuite.

Returns:
Test the testsuite

setUp

protected void setUp()
              throws Exception
Setup creates a new interface implementation object.

Overrides:
setUp in class TestCase
Throws:
Exception
See Also:
TestCase.setUp()

tearDown

protected void tearDown()
                 throws Exception
TearDown of the TestCase.

Overrides:
tearDown in class TestCase
Throws:
Exception
See Also:
TestCase.tearDown()

testSendSimplePostRequest

public void testSendSimplePostRequest()
                               throws Exception
Performs establishing a connection, creating a request, sending that request, receiving the response and closing the connection.

Throws:
Exception - for any unexpected error

testSendSimplePostRequestToNotExistingTarget

public void testSendSimplePostRequestToNotExistingTarget()
                                                  throws Exception
Sends post request without a waiting server.

Throws:
Exception - if the test case fails with an exception.

testSendSimplePostRequestWithExpectedResponseHeaderSuccess

public void testSendSimplePostRequestWithExpectedResponseHeaderSuccess()
                                                                throws Exception
Tests if a response header key value pair set for the connection has been evaluated correctly.

Throws:
Exception - in case of any unexpected error

testSendSimplePostRequestWithExpectedResponseHeaderFailed

public void testSendSimplePostRequestWithExpectedResponseHeaderFailed()
                                                               throws Exception
Tests if the correct exception is thrown if evaluating a response header key value pair set for the connection has been failed.

Throws:
Exception - in case of any unexpected error

testSendSimplePostRequestWithEmptyResponseBody

public void testSendSimplePostRequestWithEmptyResponseBody()
                                                    throws Exception
Tests if the correct exception is thrown if the http response body received is empty.

Throws:
Exception - in case of any unexpected error

testSendSimplePostRequestWithoutResponse

public void testSendSimplePostRequestWithoutResponse()
                                              throws Exception
Sends a request and expects no response.

Throws:
Exception - for any unexpected error

testSendSimplePostRequestWithImmediateClose

public void testSendSimplePostRequestWithImmediateClose()
                                                 throws Exception
Sends a request and expects a immediate close on server side.

Throws:
Exception - for any unexpected errors

testSendMultiplePostRequestAfterServerClose

public void testSendMultiplePostRequestAfterServerClose()
                                                 throws Exception
Sends a request with Connection=close and receives the response.

Throws:
Exception - for any unexpected error

testEstablishConnection

public void testEstablishConnection()
Tests establishing a connection. Checks one simple good case and several cases that leads to an ArgumentMalformedException caused by an unsufficient URL parameter.


testReleaseConnectionSuccessMultipleUse

public void testReleaseConnectionSuccessMultipleUse()
Releases a connection multiple times.


testReleaseConnectionSuccessWithTwoSendMessages

public void testReleaseConnectionSuccessWithTwoSendMessages()
                                                     throws Exception
Tests the release of connection after sending a message and a sending anew after releasing.

Throws:
Exception - if the test case fails with an exception.

testReleaseConnectionSuccessWithOneSendMessage

public void testReleaseConnectionSuccessWithOneSendMessage()
                                                    throws Exception
Tests releasing the connection and sending a second message without sending the first message.

Throws:
Exception - if the test case fails with an exception.

testReleaseConnectionFailed

public void testReleaseConnectionFailed()
                                 throws Exception
Tests error case with a missing "releaseConnection" call before reusing an already opened connection.

Throws:
Exception - if the test case fails with an exception.

testReleaseConnectionWithInvalidState

public void testReleaseConnectionWithInvalidState()
Release a not established connection.


testCloseConnectionSuccessAfterSending

public void testCloseConnectionSuccessAfterSending()
                                            throws Exception
Closes the connection after successful sending.

Throws:
Exception - if the test case fails with an exception.

testCloseConnectionFailed

public void testCloseConnectionFailed()
Multiple closing fails.


testExecuteFailed

public void testExecuteFailed()
                       throws Exception
Executes connection without establishing before.

Throws:
Exception - if the test case fails with an exception.

testSendSimplePostRequestWithSSL

public void testSendSimplePostRequestWithSSL()
                                      throws Exception
Performs establishing a connection (to SubwayCA) , creating a request, sending that request, receiving the response and closing the connection USING SSL.

Throws:
Exception - in case of missing keystore


Copyright 2007 The jCoderZ Project.