Package org.jacorb.notification

Examples of org.jacorb.notification.AnyMessage


            // received a StructuredEvent wrapped inside an Any
            // see Spec. 2-11
            return newMessage(StructuredEventHelper.extract(any), consumer);
        }

        AnyMessage _mesg = newAnyMessage(any);

        _mesg.initReceiveTimestamp();

        _mesg.setFilterStage(consumer.getFirstStage());

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


        if (StructuredEventHelper.type().equals(any.type()))
        {
            return newMessage(StructuredEventHelper.extract(any));
        }

        AnyMessage _mesg = newAnyMessage(any);

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

        return _mesg.getHandle();
    }

    private AnyMessage newAnyMessage(Any any)
    {
        AnyMessage _mesg = (AnyMessage) anyMessagePool_.lendObject();

        _mesg.setAny(any);

        return _mesg;
    }
View Full Code Here

    }

    public void testPushAny() throws Exception
    {
        // setup test data
        AnyMessage _event = new AnyMessage();

        Any _any = getORB().create_any();

        PropertySeqHelper.insert(_any, new Property[] {
                new Property("operation", toAny(DRINKING_COFFEE_ID)),
                new Property("name", toAny("alphonse")), new Property("minutes", toAny(10)) });

        _event.setAny(_any);

        final CountDownLatch _hasReceived = new CountDownLatch(1);
       
        // 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);
               
                _hasReceived.countDown();
            }
        };

        _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());

        assertTrue(_hasReceived.await(5000, TimeUnit.MILLISECONDS));
       
        // verify results
        _mockCoffee.verify();
View Full Code Here

        super(name, setup);
    }

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

     * enqueue a message into the queue which then should be returned to the first thread.
     * wrong synchronization led to a deadlock.
     */
    public void testDeadlock() throws Exception
    {
        final AnyMessage mesg = new AnyMessage();

        final AtomicBoolean received = new AtomicBoolean(false);
        final AtomicBoolean delivered = new AtomicBoolean(false);
        final CountDownLatch threadsDone = new CountDownLatch(1);
        final CountDownLatch getPutOrder = new CountDownLatch(1);

        final CyclicBarrier barrier = new CyclicBarrier(2, new Runnable()
        {
            public void run()
            {
                threadsDone.countDown();
            }
        });

        Runnable getCommand = new Runnable()
        {
            public void run()
            {
                try
                {
                    synchronized (lock_)
                    {
                        getPutOrder.countDown();
                        objectUnderTest_.getMessageBlocking();
                    }

                    received.set(true);

                    barrier.await();
                } catch (Exception e)
                {
                    fail();
                }
            }
        };

        Runnable putCommand = new Runnable()
        {
            public void run()
            {
                try
                {
                    getPutOrder.await();

                    objectUnderTest_.enqeue(mesg.getHandle());

                    delivered.set(true);

                    barrier.await();
                } catch (Exception e)
View Full Code Here

        final AbstractPoolablePool pool =
            new AbstractPoolablePool("test")
            {
                public Object newInstance()
                {
                    return new AnyMessage();
                }
            };

            pool.configure(null);
View Full Code Here

        {
            long now = System.currentTimeMillis();

            for (int i = 0; i < 1000; ++i)
            {
                AnyMessage m = createMessage();
                try
                {
                    Thread.sleep(10);
                } catch (InterruptedException e)
                {
                    // ignored
                }
                m.reset();
            }

            synchronized (this)
            {
                time = System.currentTimeMillis() - now;
View Full Code Here

            }
        }

        public AnyMessage createMessage()
        {
            return new AnyMessage();
        }
View Full Code Here

    }

    public void testPushAny() throws Exception
    {
        // setup test data
        AnyMessage _event = new AnyMessage();

        Any _any = getORB().create_any();

        PropertySeqHelper.insert(_any, new Property[] {
                new Property("operation", toAny(DRINKING_COFFEE_ID)),
                new Property("name", toAny("alphonse")), new Property("minutes", toAny(10)) });

        _event.setAny(_any);

        final CountDownLatch _hasReceived = new CountDownLatch(1);

        // 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);

                _hasReceived.countDown();
            }
        };

        _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());

        assertTrue(_hasReceived.await(5000, TimeUnit.MILLISECONDS));

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

TOP

Related Classes of org.jacorb.notification.AnyMessage

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.