Package org.serviceconnector.net.connection

Examples of org.serviceconnector.net.connection.IConnection


    message.setHeader(SCMPHeaderAttributeKey.LOCAL_DATE_TIME, ldt);

    for (int i = 0; i < 10000; i++) {
      ConnectionPool cp = new ConnectionPool(TestConstants.HOST, this.port, this.connectionType.getValue(),
          this.keepAliveSeconds, this.keepAliveOTIMillis);
      IConnection connection = cp.getConnection();
      TestCallback cbk = new TestCallback();
      connection.send(message, cbk);
      cbk.getMessageSync(1000);
      cp.freeConnection(connection);
      cp.destroy();
      if ((i + 1) % 5000 == 0) {
        testLogger.info("connection nr " + (i + 1) + "...");
View Full Code Here


   * Expectation: passes
   */
  @Test
  public void t01_Send50000() throws Exception {
    ConnectionFactory connectionFactory = AppContext.getConnectionFactory();
    IConnection connection = connectionFactory.createConnection(ConnectionType.NETTY_HTTP.getValue());
    connection.setHost(TestConstants.HOST);
    connection.setPort(TestConstants.PORT_SC0_HTTP);
    connection.setIdleTimeoutSeconds(0); // idle timeout inactive
    IIdleConnectionCallback idleCallback = new IdleCallback();
    ConnectionContext connectionContext = new ConnectionContext(connection, idleCallback, 0);
    connection.setContext(connectionContext);
    String ldt = DateTimeUtility.getCurrentTimeZoneMillis();

    SCMPMessage message = new SCMPMessage(SCMPVersion.CURRENT);
    message.setMessageType(SCMPMsgType.ATTACH);
    message.setHeader(SCMPHeaderAttributeKey.SC_VERSION, SCVersion.CURRENT.toString());
    message.setHeader(SCMPHeaderAttributeKey.LOCAL_DATE_TIME, ldt);
    connection.connect();

    for (int i = 0; i < 50000; i++) {
      TestCallback cbk = new TestCallback();
      connection.send(message, cbk);
      TestUtil.checkReply(cbk.getMessageSync(3000));
      if ((i + 1) % 10000 == 0) {
        testLogger.info("message nr " + (i + 1) + "...");
      }
    }
    connection.disconnect();
  }
View Full Code Here

   * Expectation: passes
   */
  @Test
  public void t01_ConnectSendAndDisconnect50000() throws Exception {
    ConnectionFactory connectionFactory = AppContext.getConnectionFactory();
    IConnection connection = connectionFactory.createConnection(ConnectionType.NETTY_HTTP.getValue());
    connection.setHost(TestConstants.HOST);
    connection.setPort(TestConstants.PORT_SC0_HTTP);
    connection.setIdleTimeoutSeconds(0); // idle timeout inactive
    IIdleConnectionCallback idleCallback = new IdleCallback();
    ConnectionContext connectionContext = new ConnectionContext(connection, idleCallback, 0);
    connection.setContext(connectionContext);
    String ldt = DateTimeUtility.getCurrentTimeZoneMillis();

    SCMPMessage message = new SCMPMessage(SCMPVersion.CURRENT);
    message.setMessageType(SCMPMsgType.ATTACH);
    message.setHeader(SCMPHeaderAttributeKey.SC_VERSION, SCVersion.CURRENT.toString());
    message.setHeader(SCMPHeaderAttributeKey.LOCAL_DATE_TIME, ldt);

    for (int i = 0; i < 50000; i++) {
      connection.connect();
      TestCallback cbk = new TestCallback();
      connection.send(message, cbk);
      TestUtil.checkReply(cbk.getMessageSync(3000));
      connection.disconnect();
      if ((i + 1) % 1000 == 0) {
        testLogger.info("connection nr " + (i + 1) + "...");
      }
    }
  }
View Full Code Here

            this.writeBean(writer, connectionContext);
            writer.writeEndElement();
            continue;
          }
          if (value instanceof IConnection) {
            IConnection connection = (IConnection) value;
            writer.writeStartElement("connection");
            this.writeBean(writer, connection);
            writer.writeEndElement();
            continue;
          }
View Full Code Here

    message.setHeader(SCMPHeaderAttributeKey.SC_VERSION, SCVersion.CURRENT.toString());
    message.setHeader(SCMPHeaderAttributeKey.LOCAL_DATE_TIME, ldt);

    for (int i = 0; i < numberOfConnections; i++) {
      ConnectionFactory connectionFactory = AppContext.getConnectionFactory();
      IConnection connection = connectionFactory.createConnection(ConnectionType.NETTY_HTTP.getValue());
      connections[i] = connection;
      connection.setHost(TestConstants.HOST);
      connection.setPort(TestConstants.PORT_SC0_HTTP);
      connection.setIdleTimeoutSeconds(0);
      IIdleConnectionCallback idleCallback = new IdleCallback();
      ConnectionContext connectionContext = new ConnectionContext(connection, idleCallback, 0);
      connection.setContext(connectionContext);
      connection.connect();
      TestCallback cbk = new TestCallback();
      connection.send(message, cbk);
      TestUtil.checkReply(cbk.getMessageSync(3000));
      if ((i + 1) % 100 == 0) {
        testLogger.info("connection nr " + (i + 1) + "...");
      }
    }
View Full Code Here

   * Description: Gets one connection and frees it<br>
   * Expectation: passes
   */
  @Test
  public void t01_GetAndFreeConnection() throws Exception {
    IConnection connection = connectionPool.getConnection();
    connectionPool.freeConnection(connection);
  }
View Full Code Here

  public void t20_KeepAliveActive() throws Exception {
    connectionPool.setMaxConnections(1);
    connectionPool.setMinConnections(1);
    connectionPool.initMinConnections();
    Thread.sleep((long) ((this.keepAliveSeconds * 1.4) * Constants.SEC_TO_MILLISEC_FACTOR));
    IConnection connection = connectionPool.getConnection();
    Assert.assertTrue(connection.getNrOfIdlesInSequence() > 0);
    connectionPool.freeConnection(connection);
  }
View Full Code Here

   * Expectation: passes
   */
  @Test
  public void t21_NoKeepAliveForUsedConnection() throws Exception {
    connectionPool.setMaxConnections(1);
    IConnection connection = connectionPool.getConnection();
    Thread.sleep((long) ((this.keepAliveSeconds * 1.4) * Constants.SEC_TO_MILLISEC_FACTOR));
    Assert.assertTrue(connection.getNrOfIdlesInSequence() == 0);
    Assert.assertTrue(connection.isConnected());
  }
View Full Code Here

   * Expectation: passes
   */
  @Test
  public void t30_CloseAfterFreeConnection() throws Exception {
    connectionPool.setCloseOnFree(true);
    IConnection connection = connectionPool.getConnection();
    IConnection connection2 = connectionPool.getConnection();
    connectionPool.freeConnection(connection);
    Assert.assertFalse(connection.isConnected());
    connectionPool.freeConnection(connection2);
    Assert.assertTrue(connection2.isConnected());
  }
View Full Code Here

    connectionPool.setMinConnections(2);
    connectionPool.setCloseAfterKeepAlive(false);
    connectionPool.initMinConnections();
    Thread.sleep((long) ((this.keepAliveSeconds * 1.5) * Constants.SEC_TO_MILLISEC_FACTOR)
        * Constants.DEFAULT_NR_OF_KEEP_ALIVES_TO_CLOSE);
    IConnection connection = connectionPool.getConnection();
    Assert.assertTrue(connection.getNrOfIdlesInSequence() > Constants.DEFAULT_NR_OF_KEEP_ALIVES_TO_CLOSE);
    Assert.assertTrue(connection.isConnected());
    connectionPool.freeConnection(connection);
    connectionPool.setCloseAfterKeepAlive(true);
  }
View Full Code Here

TOP

Related Classes of org.serviceconnector.net.connection.IConnection

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.