/** Get connection factory should try to instantiate one if none found. */
  public void testGetConnectionFactory() {
    /* First try with an existing factory */
    ConnectionFactory connectionFactory = new MockConnectionFactory();
    HostEndpoint endpoint = new HostEndpointImpl(connectionFactory);
    assertEquals(connectionFactory, endpoint.getHostConnectionfactory());

    /* A class name is needed. */
    endpoint.setHostConnectionfactory(null);
    try {
      endpoint.getHostConnectionfactory();
    } catch (IllegalStateException e) {
      assertEquals("Host endpoint has no connection factory class name", e.getMessage());
    }

    /* The class name must be on the classpath. */
    endpoint.setHostConnectionfactoryClass("complement.bidon");
    try {
      endpoint.getHostConnectionfactory();
    } catch (IllegalStateException e) {
      assertEquals("java.lang.ClassNotFoundException: complement.bidon", e.getMessage());
    }

    /* Now force the endpoint to create a new one. */
    endpoint.setHostConnectionfactory(null);
    endpoint.setHostConnectionfactoryClass("com.legstar.messaging.MockConnectionFactory");
    ConnectionFactory connectionFactory2 = endpoint.getHostConnectionfactory();
    assertTrue(connectionFactory2 != connectionFactory);
  }
 /** Test the toString method. */
 public void testToString() {
   HostEndpoint endpoint = new HostEndpointImpl();
   endpoint.setName("TheMainframe");
   endpoint.setHostConnectionfactoryClass("com.legstar.mock.client.MockConnectionFactory");
   endpoint.setHostCharset("IBM01147");
   endpoint.setHostUserID("MYUSER");
   endpoint.setHostPassword("MYPASS");
   endpoint.setHostTraceMode(true);
   endpoint.setConnectTimeout(45);
   endpoint.setReceiveTimeout(789);
   endpoint.setHostConnectionPoolSize(18);
   endpoint.setPooledInvokeTimeout(456);
   endpoint.setPooledMaxIdleTime(74);
   endpoint.setPooledMaxIdleTimeCheckPeriod(13);
   assertEquals(
       "[hostEndpoint=TheMainframe,"
           + "hostCharset=IBM01147,"
           + "hostUserID=MYUSER,"
           + "hostPassword=********,"
           + "hostTraceMode=true,"
           + "connectTimeout=45,"
           + "receiveTimeout=789,"
           + "hostConnectionfactoryClass=com.legstar.mock.client.MockConnectionFactory,"
           + "hostAccessStrategy=direct,"
           + "hostConnectionPoolSize=18,"
           + "pooledInvokeTimeout=456,"
           + "pooledMaxIdleTime=74,"
           + "pooledMaxIdleTimeCheckPeriod=13]",
       endpoint.toString());
 }