mil.dod.th.ose.remote.integration/src/mil/dod/th/ose/remote/integration/namespace/TestEventAdminNamespace.java
@Test
    public void testDuplicateEventRegs() throws IOException
    {
        MessageListener listener = new MessageListener(m_Socket);

        // Register event
        EventRegistrationRequestData.Builder requestMessage = EventRegistrationRequestData.newBuilder()
                .addTopic("test-topic1");
        // add required fields
        requestMessage = RemoteUtils.appendRequiredFields(requestMessage, false);
        TerraHarvestMessage message = createEventAdminMessage(EventAdminMessageType.EventRegistrationRequest, 
                requestMessage.build());
        // send out message
        message.writeDelimitedTo(m_Socket.getOutputStream());
        
        // listen for messages for a specific time interval
        List<MessageDetails> details = listener.waitForMessages(1000,
                new BasicMessageMatcher(Namespace.EventAdmin, 
                        EventAdminMessageType.EventRegistrationResponse));
        
        EventAdminNamespace response = null;
        for (MessageDetails detail : details)
        {
            if (detail.getNamespaceMessage() instanceof EventAdminNamespace)
            {
                response = (EventAdminNamespace)detail.getNamespaceMessage();
                break;
            }
        }
        
        assertThat(response, notNullValue());
        
        EventRegistrationResponseData regResponse = EventRegistrationResponseData.parseFrom(response.getData());
        int origRegId = regResponse.getId();

        // Register event again
        requestMessage = EventRegistrationRequestData.newBuilder().addTopic("test-topic1");
        // add required fields
        requestMessage = RemoteUtils.appendRequiredFields(requestMessage, false);
        message = createEventAdminMessage(EventAdminMessageType.EventRegistrationRequest, requestMessage.build());
        // send out message
        message.writeDelimitedTo(m_Socket.getOutputStream());
        
        // listen for messages for a specific time interval
        details = listener.waitForMessages(1000,
                new BasicMessageMatcher(Namespace.EventAdmin, 
                        EventAdminMessageType.EventRegistrationResponse));
        
        response = null;
        for (MessageDetails detail : details)
        {
            if (detail.getNamespaceMessage() instanceof EventAdminNamespace)
            {
                response = (EventAdminNamespace)detail.getNamespaceMessage();
                break;
            }
        }
        
        assertThat(response, notNullValue());
        
        regResponse = EventRegistrationResponseData.parseFrom(response.getData());
        assertThat(regResponse.getId(), equalTo(origRegId));
    }
/**
     * Verify that duplicate event registrations are not created.
     */
Verify that duplicate event registrations are not created.
Verify that duplicate event registrations are not created .
@Test
    public void testDuplicateEventRegs() throws IOException
    {
        MessageListener listener = new MessageListener(m_Socket);
        EventRegistrationRequestData.Builder requestMessage = EventRegistrationRequestData.newBuilder()
                .addTopic("test-topic1");
        requestMessage = RemoteUtils.appendRequiredFields(requestMessage, false);
        TerraHarvestMessage message = createEventAdminMessage(EventAdminMessageType.EventRegistrationRequest, 
                requestMessage.build());
        message.writeDelimitedTo(m_Socket.getOutputStream());
        List<MessageDetails> details = listener.waitForMessages(1000,
                new BasicMessageMatcher(Namespace.EventAdmin, 
                        EventAdminMessageType.EventRegistrationResponse));
        EventAdminNamespace response = null;
        for (MessageDetails detail : details)
        {
            if (detail.getNamespaceMessage() instanceof EventAdminNamespace)
            {
                response = (EventAdminNamespace)detail.getNamespaceMessage();
                break;
            }
        }
        assertThat(response, notNullValue());
        EventRegistrationResponseData regResponse = EventRegistrationResponseData.parseFrom(response.getData());
        int origRegId = regResponse.getId();
         again
        requestMessage = EventRegistrationRequestData.newBuilder().addTopic("test-topic1");
        requestMessage = RemoteUtils.appendRequiredFields(requestMessage, false);
        message = createEventAdminMessage(EventAdminMessageType.EventRegistrationRequest, requestMessage.build());
        message.writeDelimitedTo(m_Socket.getOutputStream());
        details = listener.waitForMessages(1000,
                new BasicMessageMatcher(Namespace.EventAdmin, 
                        EventAdminMessageType.EventRegistrationResponse));
        response = null;
        for (MessageDetails detail : details)
        {
            if (detail.getNamespaceMessage() instanceof EventAdminNamespace)
            {
                response = (EventAdminNamespace)detail.getNamespaceMessage();
                break;
            }
        }
        assertThat(response, notNullValue());
        regResponse = EventRegistrationResponseData.parseFrom(response.getData());
        assertThat(regResponse.getId(), equalTo(origRegId));
    }
@ Test public void testDuplicateEventRegs ( ) throws IOException { MessageListener listener = new MessageListener ( m_Socket ) ; EventRegistrationRequestData . Builder requestMessage = EventRegistrationRequestData . newBuilder ( ) . addTopic ( "test-topic1" ) ; requestMessage = RemoteUtils . appendRequiredFields ( requestMessage , false ) ; TerraHarvestMessage message = createEventAdminMessage ( EventAdminMessageType . EventRegistrationRequest , requestMessage . build ( ) ) ; message . writeDelimitedTo ( m_Socket . getOutputStream ( ) ) ; List < MessageDetails > details = listener . waitForMessages ( 1000 , new BasicMessageMatcher ( Namespace . EventAdmin , EventAdminMessageType . EventRegistrationResponse ) ) ; EventAdminNamespace response = null ; for ( MessageDetails detail : details ) { if ( detail . getNamespaceMessage ( ) instanceof EventAdminNamespace ) { response = ( EventAdminNamespace ) detail . getNamespaceMessage ( ) ; break ; } } assertThat ( response , notNullValue ( ) ) ; EventRegistrationResponseData regResponse = EventRegistrationResponseData . parseFrom ( response . getData ( ) ) ; int origRegId = regResponse . getId ( ) ; requestMessage = EventRegistrationRequestData . newBuilder ( ) . addTopic ( "test-topic1" ) ; requestMessage = RemoteUtils . appendRequiredFields ( requestMessage , false ) ; message = createEventAdminMessage ( EventAdminMessageType . EventRegistrationRequest , requestMessage . build ( ) ) ; message . writeDelimitedTo ( m_Socket . getOutputStream ( ) ) ; details = listener . waitForMessages ( 1000 , new BasicMessageMatcher ( Namespace . EventAdmin , EventAdminMessageType . EventRegistrationResponse ) ) ; response = null ; for ( MessageDetails detail : details ) { if ( detail . getNamespaceMessage ( ) instanceof EventAdminNamespace ) { response = ( EventAdminNamespace ) detail . getNamespaceMessage ( ) ; break ; } } assertThat ( response , notNullValue ( ) ) ; regResponse = EventRegistrationResponseData . parseFrom ( response . getData ( ) ) ; assertThat ( regResponse . getId ( ) , equalTo ( origRegId ) ) ; }
Verify that duplicate event registrations are not created.
Verify that duplicate event registrations are not created .
// Register event // add required fields // send out message // listen for messages for a specific time interval // Register event again // add required fields // send out message // listen for messages for a specific time interval