/** * test if events are reorderd respecting their priority. a supplier pushes some events with * ascending priority into a channel that was setup with OrderPolicy=PriorityOrder. A Consumer * receives and checks if the Events are delivered in descending Priority order. */ public void testPriorityOrder() throws Exception { // create and setup channel IntHolder channelId = new IntHolder(); Property[] qosProps; qosProps = new Property[] {new Property(OrderPolicy.value, priorityOrder)}; EventChannel channel = getEventChannelFactory().create_channel(qosProps, new Property[0], channelId); // testdata StructuredEvent[] events = new StructuredEvent[10]; for (int x = 0; x < events.length; ++x) { events[x] = new NotificationTestUtils(getClientORB()).getStructuredEvent(); Any priority = getClientORB().create_any(); priority.insert_short((short) x); events[x].header.variable_header = new Property[] {new Property(Priority.value, priority)}; } final List received = new ArrayList(); // setup clients StructuredPushReceiver receiver = new StructuredPushReceiver(this.getClientORB(), events.length) { public void push_structured_event(StructuredEvent event) throws Disconnected { super.push_structured_event(event); received.add(event); } }; receiver.connect(channel, false); receiver.pushSupplier_.suspend_connection(); StructuredPushSender sender = new StructuredPushSender(this.getClientORB()); sender.setStructuredEvent(events); sender.setInterval(100); sender.connect(channel, false); // push events sender.run(); assertFalse(receiver.isEventHandled()); Thread.sleep(2000); receiver.pushSupplier_.resume_connection(); receiver.setTimeOut(events.length * 1000); receiver.run(); assertTrue(receiver.isEventHandled()); Thread.sleep(2000); while (!received.isEmpty()) { StructuredEvent event = (StructuredEvent) received.remove(0); Iterator i = received.iterator(); while (i.hasNext()) { short p1 = event.header.variable_header[0].value.extract_short(); short p2 = ((StructuredEvent) i.next()).header.variable_header[0].value.extract_short(); assertTrue(p1 + " > " + p2, p1 > p2); } } }