Package org.jacorb.test.notification

Source Code of org.jacorb.test.notification.TypedEventMessageTest

package org.jacorb.test.notification;

/*
*        JacORB - a free Java ORB
*
*   Copyright (C) 1997-2003  Gerald Brose.
*
*   This library is free software; you can redistribute it and/or
*   modify it under the terms of the GNU Library General Public
*   License as published by the Free Software Foundation; either
*   version 2 of the License, or (at your option) any later version.
*
*   This library is distributed in the hope that it will be useful,
*   but WITHOUT ANY WARRANTY; without even the implied warranty of
*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
*   Library General Public License for more details.
*
*   You should have received a copy of the GNU Library General Public
*   License along with this library; if not, write to the Free
*   Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

import junit.framework.Test;

import org.jacorb.notification.TypedEventMessage;
import org.jacorb.test.notification.common.NotificationTestCase;
import org.jacorb.test.notification.common.NotificationTestCaseSetup;
import org.jacorb.test.notification.typed.CoffeeHelper;
import org.omg.CORBA.Any;
import org.omg.CosNotification.EventType;
import org.omg.CosNotification.EventTypeHelper;
import org.omg.CosNotification.Property;
import org.omg.CosNotification.PropertySeqHelper;
import org.omg.CosNotification.StructuredEvent;

/**
* @author Alphonse Bendt
* @version $Id: TypedEventMessageTest.java,v 1.7 2005/12/04 22:19:27 alphonse.bendt Exp $
*/
public class TypedEventMessageTest extends NotificationTestCase
{
    private static final Property[] EMPTY_PROPS = new Property[0];

    private TypedEventMessage objectUnderTest_;

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

    public void setUpTest() throws Exception
    {
        objectUnderTest_ = new TypedEventMessage();
    }

    public TypedEventMessageTest(String name, NotificationTestCaseSetup setup)
    {
        super(name, setup);
    }

    public void testToProperty()
    {
        objectUnderTest_.setTypedEvent(CoffeeHelper.id(), "drinking_coffee", EMPTY_PROPS);

        Property[] _props = objectUnderTest_.toTypedEvent();

        assertEquals(1, _props.length);
        assertEquals("event_type", _props[0].name);

        EventType et = EventTypeHelper.extract(_props[0].value);
        assertEquals(CoffeeHelper.id(), et.domain_name);
        assertEquals("drinking_coffee", et.type_name);
    }

    public void testToAny()
    {
        objectUnderTest_.setTypedEvent(CoffeeHelper.id(), DRINKING_COFFEE_ID, EMPTY_PROPS);

        Any _any = objectUnderTest_.toAny();

        assertEquals(PropertySeqHelper.type(), _any.type());

        Property[] _props = PropertySeqHelper.extract(_any);

        assertEquals(1, _props.length);

        assertEquals("operation", _props[0].name);

        assertEquals(DRINKING_COFFEE_ID, _props[0].value.extract_string());
    }

    public void testToStructured()
    {
        objectUnderTest_.setTypedEvent(CoffeeHelper.id(), DRINKING_COFFEE_ID, EMPTY_PROPS);

        StructuredEvent _structEvent = objectUnderTest_.toStructuredEvent();

        assertEquals(1, _structEvent.filterable_data.length);

        assertEquals("operation", _structEvent.filterable_data[0].name);

        assertEquals(DRINKING_COFFEE_ID, _structEvent.filterable_data[0].value.extract_string());

        assertEquals("%TYPED", _structEvent.header.fixed_header.event_type.type_name);
    }

    public static Test suite() throws Exception
    {
        return NotificationTestCase.suite(TypedEventMessageTest.class);
    }
}
TOP

Related Classes of org.jacorb.test.notification.TypedEventMessageTest

TOP
Copyright © 2018 www.massapi.com. 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.