Package org.jacorb.notification

Examples of org.jacorb.notification.TypedEventMessage


    public Message newMessage(String interfaceName, String operationName, NVList args,
            IProxyConsumer consumer)
    {
        try
        {
            TypedEventMessage _mesg = (TypedEventMessage) typedEventMessagePool_.lendObject();

            _mesg.initReceiveTimestamp();

            Property[] _props = new Property[args.count()];

            for (int x = 0; x < _props.length; ++x)
            {
                NamedValue _nv = args.item(x);

                _props[x] = new Property(_nv.name(), _nv.value());
            }

            _mesg.setTypedEvent(interfaceName, operationName, _props);

            _mesg.setFilterStage(consumer.getFirstStage());

           return _mesg.getHandle();
        } catch (Bounds e)
        {
            // this should never happen as NamedValue bounds are checked always.
            throw new RuntimeException(e.toString());
        }
View Full Code Here


    /**
     * create a message wrapping a typed event.
     */
    public Message newMessage(Property[] props)
    {
        TypedEventMessage _mesg = (TypedEventMessage) typedEventMessagePool_.lendObject();

        _mesg.setTypedEvent(props);

        return _mesg.getHandle();
    }
View Full Code Here

        assertTrue(filter_.match_typed(_props));
    }

    public void testFilterTypedMessageEvent() throws Exception
    {
        TypedEventMessage _mesg = new TypedEventMessage();

        String _domainName = "IDL:org.jacorb/org/jacorb/test/filter/Bla:1.0";
        String _operationName = "blaOperation";

        _mesg.setTypedEvent(_domainName, _operationName, new Property[] {
                new Property("param1", toAny("value1")), new Property("param2", toAny(100)) });

        assertFalse(_mesg.match(filter_));

        ConstraintExp[] _constraintExp = new ConstraintExp[1];

        EventType[] _eventType = new EventType[1];
        _eventType[0] = new EventType("", "%TYPED");

        String _expression = "$event_type.domain_name == '" + _domainName
                + "' and $event_type.type_name == '" + _operationName + "' and $param2 > 50";

        _constraintExp[0] = new ConstraintExp(_eventType, _expression);

        filter_.add_constraints(_constraintExp);

        assertTrue(_mesg.match(filter_));
    }
View Full Code Here

    }

    public void testPushPulledEvent() throws Exception
    {
        // setup test data
        TypedEventMessage _event = new TypedEventMessage();

        _event.setTypedEvent(PullCoffeeHelper.id(), DRINKING_COFFEE_ID, new Property[] {
                new Property("name", toAny("alphonse")), new Property("minutes", toAny(10)) });

        // setup mock
        MockCoffee _mockCoffee = new MockCoffee()
        {
            public void drinking_coffee(String name, int minutes)
            {
                super.drinking_coffee(name, minutes);

                assertEquals("alphonse", name);
                assertEquals(10, minutes);
            }
        };

        _mockCoffee.drinking_coffee_expect = 1;

        // setup and connect consumer
        final Coffee _coffee = _mockCoffee._this(getClientORB());

        MockTypedPushConsumer _mockConsumer = new MockTypedPushConsumer()
        {
            public org.omg.CORBA.Object get_typed_consumer()
            {
                return _coffee;
            }
        };

        TypedPushConsumer _consumer = _mockConsumer._this(getClientORB());

        proxyPushSupplier_.connect_typed_push_consumer(_consumer);

        // run test
        objectUnderTest_.getMessageConsumer().queueMessage(_event.getHandle());

        // verify results
        _mockCoffee.verify();
    }
View Full Code Here

    }

    public void testPushTyped() throws Exception
    {
        // setup test data
        TypedEventMessage _event = new TypedEventMessage();

        _event.setTypedEvent(CoffeeHelper.id(), DRINKING_COFFEE_ID, new Property[] {
                new Property("name", toAny("alphonse")), new Property("minutes", toAny(10)) });

        // setup mock
        MockCoffee _mockCoffee = new MockCoffee()
        {
            public void drinking_coffee(String name, int minutes)
            {
                super.drinking_coffee(name, minutes);

                assertEquals("alphonse", name);
                assertEquals(10, minutes);
            }
        };

        _mockCoffee.drinking_coffee_expect = 1;

        // setup and connect consumer
        final Coffee _coffee = _mockCoffee._this(getClientORB());

        MockTypedPushConsumer _mockConsumer = new MockTypedPushConsumer()
        {
            public org.omg.CORBA.Object get_typed_consumer()
            {
                return _coffee;
            }
        };

        TypedPushConsumer _consumer = _mockConsumer._this(getClientORB());

        proxyPushSupplier_.connect_typed_push_consumer(_consumer);

        // run test
        objectUnderTest_.getMessageConsumer().queueMessage(_event.getHandle());

        // verify results
        _mockCoffee.verify();
    }
View Full Code Here

    private static String DRINKING_COFFEE_ID = "::org::jacorb::test::notification::typed::Coffee::drinking_coffee";

    public void setUpTest() throws Exception
    {
        objectUnderTest_ = new TypedEventMessage();
    }
View Full Code Here

        assertFalse(_pullCoffee.try_drinking_coffee(_name, _minutes));
    }

    public void testTryPullDrinkingCoffee() throws Exception
    {
        TypedEventMessage _mesg = new TypedEventMessage();

        _mesg.setTypedEvent(PullCoffeeHelper.id(), DRINKING_COFFEE_ID, new Property[] {
                new Property("name", toAny("jacorb")), new Property("minutes", toAny(10)) });

        NullPullConsumer _pullConsumer = new NullPullConsumer();

        proxyPullSupplier_.connect_typed_pull_consumer(_pullConsumer._this(getClientORB()));

        org.omg.CORBA.Object _object = proxyPullSupplier_.get_typed_supplier();

        String _objectAsString = _object.toString();

        PullCoffee _pullCoffee = PullCoffeeHelper.narrow(getClientORB().string_to_object(
                _objectAsString));

        StringHolder _name = new StringHolder();
        IntHolder _minutes = new IntHolder();

        objectUnderTest_.getMessageConsumer().queueMessage(_mesg.getHandle());

        assertTrue(_pullCoffee.try_drinking_coffee(_name, _minutes));

        assertEquals("jacorb", _name.value);
        assertEquals(10, _minutes.value);
View Full Code Here

        assertEquals(10, _minutes.value);
    }

    public void testPullDrinkingCoffee() throws Exception
    {
        TypedEventMessage _mesg = new TypedEventMessage();

        _mesg.setTypedEvent(PullCoffeeHelper.id(), DRINKING_COFFEE_ID, new Property[] {
                new Property("name", toAny("jacorb")), new Property("minutes", toAny(10)) });

        NullPullConsumer _pullConsumer = new NullPullConsumer();

        proxyPullSupplier_.connect_typed_pull_consumer(_pullConsumer._this(getClientORB()));

        org.omg.CORBA.Object _object = proxyPullSupplier_.get_typed_supplier();

        String _objectAsString = _object.toString();

        final PullCoffee _pullCoffee = PullCoffeeHelper.narrow(getClientORB().string_to_object(
                _objectAsString));

        final StringHolder _name = new StringHolder();
        final IntHolder _minutes = new IntHolder();

        final CountDownLatch _latch = new CountDownLatch(1);

        new Thread()
        {
            public void run()
            {
                _pullCoffee.drinking_coffee(_name, _minutes);
                _latch.countDown();
            }
        }.start();

        objectUnderTest_.getMessageConsumer().queueMessage(_mesg.getHandle());

        assertTrue(_latch.await(1000, TimeUnit.MICROSECONDS));

        assertEquals("jacorb", _name.value);
        assertEquals(10, _minutes.value);
View Full Code Here

    public void testInvokeDrinkingCoffee() throws Exception
    {
        MockControl controlTaskProcessor = MockControl.createControl(TaskProcessor.class);
        TaskProcessor mockTaskProcessor = (TaskProcessor) controlTaskProcessor.getMock();

        TypedEventMessage message = new TypedEventMessage();
        Message handle = message.getHandle();

        mockTaskProcessor.processMessage(handle);
        controlTaskProcessor.setMatcher(new AbstractMatcher()
        {
            protected boolean argumentMatches(Object exp, Object act)
View Full Code Here

        assertFalse(_pullCoffee.try_drinking_coffee(_name, _minutes));
    }

    public void testTryPullDrinkingCoffee() throws Exception
    {
        TypedEventMessage _mesg = new TypedEventMessage();

        _mesg.setTypedEvent(PullCoffeeHelper.id(), DRINKING_COFFEE_ID, new Property[] {
                new Property("name", toAny("jacorb")), new Property("minutes", toAny(10)) });

        NullPullConsumer _pullConsumer = new NullPullConsumer();

        proxyPullSupplier_.connect_typed_pull_consumer(_pullConsumer._this(getClientORB()));

        org.omg.CORBA.Object _object = proxyPullSupplier_.get_typed_supplier();

        String _objectAsString = _object.toString();

        PullCoffee _pullCoffee = PullCoffeeHelper.narrow(getClientORB().string_to_object(
                _objectAsString));

        StringHolder _name = new StringHolder();
        IntHolder _minutes = new IntHolder();

        objectUnderTest_.getMessageConsumer().queueMessage(_mesg.getHandle());

        assertTrue(_pullCoffee.try_drinking_coffee(_name, _minutes));

        assertEquals("jacorb", _name.value);
        assertEquals(10, _minutes.value);
View Full Code Here

TOP

Related Classes of org.jacorb.notification.TypedEventMessage

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.