Ejemplo n.º 1
0
  //    @Test
  public void testJoin() throws Exception {
    assertEquals(ConnectionState.NULL, connection.getState());
    connection.bind();
    Thread.sleep(500);

    connection.join();

    Thread.sleep(1000);
    assertEquals(ConnectionState.OPEN, connection.getState());
    assertTrue("Listener did not receive event", openState);
  }
Ejemplo n.º 2
0
  //    @Test
  public void testTimeout() throws Exception {
    //        assertEquals(ConnectionState.NULL, connection.getState());
    //        connection.bind();

    Thread.sleep(10000);
    assertEquals(ConnectionState.NULL, connection.getState());
  }
Ejemplo n.º 3
0
  public void process(ConnectionEvent event) {
    if (event.getId() == ConnectionEvent.STATE_CHANGE) {
      BaseConnection conn = (BaseConnection) event.getSource();

      if (conn.getState() == ConnectionState.HALF_OPEN) {
        halfOpenState = true;
      }

      if (conn.getState() == ConnectionState.OPEN) {
        openState = true;
      }

      if (conn.getState() == ConnectionState.NULL) {
        nullState = true;
      }
    }
  }
Ejemplo n.º 4
0
  //    @Test
  public void testBind() throws Exception {
    //        assertEquals(ConnectionState.NULL, connection.getState());
    //        connection.bind();

    Thread.sleep(1000);
    assertEquals(ConnectionState.HALF_OPEN, connection.getState());
    assertTrue("Listener did not receive event", halfOpenState);
  }
Ejemplo n.º 5
0
  @Before
  public void setUp()
      throws ResourceUnavailableException, IOException, TooManyConnectionsException {
    // use default clock
    clock = new WallClock();

    // create single thread scheduler
    scheduler = new PriorityQueueScheduler();
    scheduler.setClock(clock);
    scheduler.start();

    channelsManager = new ChannelsManager(new UdpManager(new ServiceScheduler()));
    channelsManager.setScheduler(scheduler);

    resourcesPool = new ResourcesPool(scheduler, channelsManager, dspFactory);
    // assign scheduler to the endpoint
    endpoint = new MyTestEndpoint("test");
    endpoint.setScheduler(scheduler);
    endpoint.setResourcesPool(resourcesPool);
    endpoint.start();

    connection = (BaseConnection) endpoint.createConnection(ConnectionType.LOCAL, false);
    connection.addListener(this);
  }
Ejemplo n.º 6
0
 //    @Test
 public void testGetEndpoint() {
   assertEquals(endpoint, connection.getEndpoint());
 }
Ejemplo n.º 7
0
 //    @Test
 public void testGetState() {
   assertEquals(ConnectionState.NULL, connection.getState());
 }