Esempio n. 1
0
  @Test
  public void testStructuredEventWithStartTimeProperty() throws Exception {
    structuredEvent_.header.variable_header = new Property[1];

    Date _now = new Date();

    Any _startTimeAny = getORB().create_any();
    UtcT _startTime = Time.corbaTime(_now);
    UtcTHelper.insert(_startTimeAny, _startTime);

    structuredEvent_.header.variable_header[0] = new Property(StartTime.value, _startTimeAny);

    Message _event = messageFactory_.newMessage(structuredEvent_, proxyConsumerMock_);

    assertTrue(_event.hasStartTime());
    assertEquals(_now.getTime(), _event.getStartTime());
  }
Esempio n. 2
0
  public void processEventWithStartTime(long offset) throws Exception {
    final AtomicBoolean failed = new AtomicBoolean(true);

    structuredEvent_.header.variable_header = new Property[1];

    final Date _startTime = new Date(System.currentTimeMillis() + offset);

    Any _startTimeAny = getORB().create_any();
    UtcTHelper.insert(_startTimeAny, Time.corbaTime(_startTime));

    structuredEvent_.header.variable_header[0] = new Property(StartTime.value, _startTimeAny);

    final Message _event = messageFactory_.newMessage(structuredEvent_, proxyConsumerMock_);

    final CountDownLatch _latch = new CountDownLatch(1);

    // TODO check if MockTaskProcessor can be used here
    final DefaultTaskFactory _defaultTaskFactory = new DefaultTaskFactory(getConfiguration());
    addDisposable(_defaultTaskFactory);
    DefaultTaskProcessor _taskProcessor =
        new DefaultTaskProcessor(getConfiguration(), _defaultTaskFactory) {
          public void processMessageInternal(Message event) {
            try {
              long _recvTime = System.currentTimeMillis();
              assertEquals(event, _event);
              assertTrue(_recvTime >= _startTime.getTime());

              failed.set(false);
            } finally {
              _latch.countDown();
            }
          }
        };

    _taskProcessor.processMessage(_event);

    _latch.await();

    assertFalse(failed.get());

    _taskProcessor.dispose();
  }
Esempio n. 3
0
  @Test
  public void testAnyEventHasNoStartTime() throws Exception {
    Message _event = messageFactory_.newMessage(getORB().create_any());

    assertTrue(!_event.hasStartTime());
  }
Esempio n. 4
0
  @Test
  public void testStructuredEventWithoutStartTimeProperty() throws Exception {
    Message _event = messageFactory_.newMessage(structuredEvent_);

    assertTrue(!_event.hasStartTime());
  }