mil.dod.th.ose.remote.integration/src/mil/dod/th/ose/remote/integration/namespace/TestConfigAdminNamespace.java
@Test
    public void testGetSetMultipleConfigProperties() throws UnknownHostException, IOException, InterruptedException
    {   
        MessageListener listener = new MessageListener(socket);
        
        //Delete configuration to insure properties are set to default values.
        ConfigNamespaceUtils.deleteConfig(ExampleClass.CONFIG_PID, socket, listener);
        
        SetPropertyRequestData.Builder requestSet = SetPropertyRequestData.newBuilder().setPid(
                ExampleClass.CONFIG_PID);
        //Set thread pool size for the event admin.
        Multitype value1 = Multitype.newBuilder().setType(Type.INT32).setInt32Value(25).build();
        SimpleTypesMapEntry prop1 = SimpleTypesMapEntry.newBuilder()
                .setKey(ExampleClassConfig.CONFIG_PROP_EXAMPLE_CONFIG_VALUE).setValue(value1).build();
        requestSet.addProperties(prop1);
        //Set timeout
        Multitype value2 = Multitype.newBuilder().setType(Type.STRING).setStringValue("something").build();
        SimpleTypesMapEntry prop2 = 
                SimpleTypesMapEntry.newBuilder()
                .setKey(ExampleClassConfig.CONFIG_PROP_EXAMPLE_CONFIG_VALUE_STRING).setValue(value2).build();
        requestSet.addProperties(prop2);
        //Set require topic
        Multitype value3 = Multitype.newBuilder().setType(Type.STRING).setStringValue("somewhere").build();
        SimpleTypesMapEntry prop3 = 
                SimpleTypesMapEntry.newBuilder()
                .setKey(ExampleClassConfig.CONFIG_PROP_EXAMPLE_CONFIG_STRING_VALUE_AGAIN).setValue(value3).build();
        requestSet.addProperties(prop3);
        
        //create terra harvest message   
        TerraHarvestMessage thMessage = createConfigAdminMessage(ConfigAdminMessageType.SetPropertyRequest, 
                requestSet.build());
        
        //send out message
        thMessage.writeDelimitedTo(socket.getOutputStream());
        
        //Verify a set property response is received.
        Message messageRcvd = 
            listener.waitForMessage(Namespace.ConfigAdmin, ConfigAdminMessageType.SetPropertyResponse, 2000);
        
        //Create message to retrieve configuration and associated properties.
        GetConfigurationInfoRequestData request = GetConfigurationInfoRequestData.newBuilder().
                setFilter("(service.pid=" + ExampleClass.CONFIG_PID +")").setIncludeProperties(true).build();
        
        //create terra harvest message   
        TerraHarvestMessage message = createConfigAdminMessage(ConfigAdminMessageType.GetConfigurationInfoRequest, 
            request);
                
        // send out message
        message.writeDelimitedTo(socket.getOutputStream());

        messageRcvd = listener.waitForMessage(Namespace.ConfigAdmin, 
                ConfigAdminMessageType.GetConfigurationInfoResponse, 1000);

        //parse specific message type
        ConfigAdminNamespace namespaceResponse = (ConfigAdminNamespace) messageRcvd;
        assertThat(namespaceResponse.getType(), is(ConfigAdminMessageType.GetConfigurationInfoResponse));
        //verify
        GetConfigurationInfoResponseData responseData = GetConfigurationInfoResponseData.
            parseFrom(namespaceResponse.getData());
        List<ConfigurationInfoType> data = responseData.getConfigurationsList();
        assertThat(data.size(), is(1));
        assertThat(data.get(0).getPid(), is(ExampleClass.CONFIG_PID));
        assertThat(data.get(0).hasFactoryPid(), is(false));
        assertThat(data.get(0).getBundleLocation(), is(notNullValue()));
        assertThat(data.get(0).getPropertiesCount(), is(4));
        Map<String, SimpleTypesMapEntry> properties = Maps.uniqueIndex(data.get(0).getPropertiesList(), 
            new Function<SimpleTypesMapEntry, String>()
            {
                @Override
                public String apply(SimpleTypesMapEntry item)
                {
                    return item.getKey();
                }
            });
        assertThat(properties.get("service.pid").getValue().getStringValue(), is(ExampleClass.CONFIG_PID));
        assertThat(properties.get(ExampleClassConfig.CONFIG_PROP_EXAMPLE_CONFIG_STRING_VALUE_AGAIN)
                .getValue().getStringValue(), is("somewhere"));
        assertThat(properties.get(ExampleClassConfig.CONFIG_PROP_EXAMPLE_CONFIG_VALUE)
                .getValue().getInt32Value(), is(25));
        assertThat(properties.get(ExampleClassConfig.CONFIG_PROP_EXAMPLE_CONFIG_VALUE_STRING)
                .getValue().getStringValue(), is("something"));
        
        ConfigNamespaceUtils.deleteConfig(ExampleClass.CONFIG_PID, socket, listener);
    }
/**
     * Test setting multiple configuration properties with one message and receiving multiple configuration properties
     * with one message.
     */
Test setting multiple configuration properties with one message and receiving multiple configuration properties
with one message.
Test setting multiple configuration properties with one message and receiving multiple configuration properties with one message .
@Test
    public void testGetSetMultipleConfigProperties() throws UnknownHostException, IOException, InterruptedException
    {   
        MessageListener listener = new MessageListener(socket);
        ConfigNamespaceUtils.deleteConfig(ExampleClass.CONFIG_PID, socket, listener);
        SetPropertyRequestData.Builder requestSet = SetPropertyRequestData.newBuilder().setPid(
                ExampleClass.CONFIG_PID);
        Multitype value1 = Multitype.newBuilder().setType(Type.INT32).setInt32Value(25).build();
        SimpleTypesMapEntry prop1 = SimpleTypesMapEntry.newBuilder()
                .setKey(ExampleClassConfig.CONFIG_PROP_EXAMPLE_CONFIG_VALUE).setValue(value1).build();
        requestSet.addProperties(prop1);
        Multitype value2 = Multitype.newBuilder().setType(Type.STRING).setStringValue("something").build();
        SimpleTypesMapEntry prop2 = 
                SimpleTypesMapEntry.newBuilder()
                .setKey(ExampleClassConfig.CONFIG_PROP_EXAMPLE_CONFIG_VALUE_STRING).setValue(value2).build();
        requestSet.addProperties(prop2);
        Multitype value3 = Multitype.newBuilder().setType(Type.STRING).setStringValue("somewhere").build();
        SimpleTypesMapEntry prop3 = 
                SimpleTypesMapEntry.newBuilder()
                .setKey(ExampleClassConfig.CONFIG_PROP_EXAMPLE_CONFIG_STRING_VALUE_AGAIN).setValue(value3).build();
        requestSet.addProperties(prop3);
        TerraHarvestMessage thMessage = createConfigAdminMessage(ConfigAdminMessageType.SetPropertyRequest, 
                requestSet.build());
        thMessage.writeDelimitedTo(socket.getOutputStream());
        Message messageRcvd = 
            listener.waitForMessage(Namespace.ConfigAdmin, ConfigAdminMessageType.SetPropertyResponse, 2000);
        GetConfigurationInfoRequestData request = GetConfigurationInfoRequestData.newBuilder().
                setFilter("(service.pid=" + ExampleClass.CONFIG_PID +")").setIncludeProperties(true).build();
        TerraHarvestMessage message = createConfigAdminMessage(ConfigAdminMessageType.GetConfigurationInfoRequest, 
            request);
        message.writeDelimitedTo(socket.getOutputStream());
        messageRcvd = listener.waitForMessage(Namespace.ConfigAdmin, 
                ConfigAdminMessageType.GetConfigurationInfoResponse, 1000);
        ConfigAdminNamespace namespaceResponse = (ConfigAdminNamespace) messageRcvd;
        assertThat(namespaceResponse.getType(), is(ConfigAdminMessageType.GetConfigurationInfoResponse));
        GetConfigurationInfoResponseData responseData = GetConfigurationInfoResponseData.
            parseFrom(namespaceResponse.getData());
        List<ConfigurationInfoType> data = responseData.getConfigurationsList();
        assertThat(data.size(), is(1));
        assertThat(data.get(0).getPid(), is(ExampleClass.CONFIG_PID));
        assertThat(data.get(0).hasFactoryPid(), is(false));
        assertThat(data.get(0).getBundleLocation(), is(notNullValue()));
        assertThat(data.get(0).getPropertiesCount(), is(4));
        Map<String, SimpleTypesMapEntry> properties = Maps.uniqueIndex(data.get(0).getPropertiesList(), 
            new Function<SimpleTypesMapEntry, String>()
            {
                @Override
                public String apply(SimpleTypesMapEntry item)
                {
                    return item.getKey();
                }
            });
        assertThat(properties.get("service.pid").getValue().getStringValue(), is(ExampleClass.CONFIG_PID));
        assertThat(properties.get(ExampleClassConfig.CONFIG_PROP_EXAMPLE_CONFIG_STRING_VALUE_AGAIN)
                .getValue().getStringValue(), is("somewhere"));
        assertThat(properties.get(ExampleClassConfig.CONFIG_PROP_EXAMPLE_CONFIG_VALUE)
                .getValue().getInt32Value(), is(25));
        assertThat(properties.get(ExampleClassConfig.CONFIG_PROP_EXAMPLE_CONFIG_VALUE_STRING)
                .getValue().getStringValue(), is("something"));
        ConfigNamespaceUtils.deleteConfig(ExampleClass.CONFIG_PID, socket, listener);
    }
@ Test public void testGetSetMultipleConfigProperties ( ) throws UnknownHostException , IOException , InterruptedException { MessageListener listener = new MessageListener ( socket ) ; ConfigNamespaceUtils . deleteConfig ( ExampleClass . CONFIG_PID , socket , listener ) ; SetPropertyRequestData . Builder requestSet = SetPropertyRequestData . newBuilder ( ) . setPid ( ExampleClass . CONFIG_PID ) ; Multitype value1 = Multitype . newBuilder ( ) . setType ( Type . INT32 ) . setInt32Value ( 25 ) . build ( ) ; SimpleTypesMapEntry prop1 = SimpleTypesMapEntry . newBuilder ( ) . setKey ( ExampleClassConfig . CONFIG_PROP_EXAMPLE_CONFIG_VALUE ) . setValue ( value1 ) . build ( ) ; requestSet . addProperties ( prop1 ) ; Multitype value2 = Multitype . newBuilder ( ) . setType ( Type . STRING ) . setStringValue ( "something" ) . build ( ) ; SimpleTypesMapEntry prop2 = SimpleTypesMapEntry . newBuilder ( ) . setKey ( ExampleClassConfig . CONFIG_PROP_EXAMPLE_CONFIG_VALUE_STRING ) . setValue ( value2 ) . build ( ) ; requestSet . addProperties ( prop2 ) ; Multitype value3 = Multitype . newBuilder ( ) . setType ( Type . STRING ) . setStringValue ( "somewhere" ) . build ( ) ; SimpleTypesMapEntry prop3 = SimpleTypesMapEntry . newBuilder ( ) . setKey ( ExampleClassConfig . CONFIG_PROP_EXAMPLE_CONFIG_STRING_VALUE_AGAIN ) . setValue ( value3 ) . build ( ) ; requestSet . addProperties ( prop3 ) ; TerraHarvestMessage thMessage = createConfigAdminMessage ( ConfigAdminMessageType . SetPropertyRequest , requestSet . build ( ) ) ; thMessage . writeDelimitedTo ( socket . getOutputStream ( ) ) ; Message messageRcvd = listener . waitForMessage ( Namespace . ConfigAdmin , ConfigAdminMessageType . SetPropertyResponse , 2000 ) ; GetConfigurationInfoRequestData request = GetConfigurationInfoRequestData . newBuilder ( ) . setFilter ( "(service.pid=" + ExampleClass . CONFIG_PID + ")" ) . setIncludeProperties ( true ) . build ( ) ; TerraHarvestMessage message = createConfigAdminMessage ( ConfigAdminMessageType . GetConfigurationInfoRequest , request ) ; message . writeDelimitedTo ( socket . getOutputStream ( ) ) ; messageRcvd = listener . waitForMessage ( Namespace . ConfigAdmin , ConfigAdminMessageType . GetConfigurationInfoResponse , 1000 ) ; ConfigAdminNamespace namespaceResponse = ( ConfigAdminNamespace ) messageRcvd ; assertThat ( namespaceResponse . getType ( ) , is ( ConfigAdminMessageType . GetConfigurationInfoResponse ) ) ; GetConfigurationInfoResponseData responseData = GetConfigurationInfoResponseData . parseFrom ( namespaceResponse . getData ( ) ) ; List < ConfigurationInfoType > data = responseData . getConfigurationsList ( ) ; assertThat ( data . size ( ) , is ( 1 ) ) ; assertThat ( data . get ( 0 ) . getPid ( ) , is ( ExampleClass . CONFIG_PID ) ) ; assertThat ( data . get ( 0 ) . hasFactoryPid ( ) , is ( false ) ) ; assertThat ( data . get ( 0 ) . getBundleLocation ( ) , is ( notNullValue ( ) ) ) ; assertThat ( data . get ( 0 ) . getPropertiesCount ( ) , is ( 4 ) ) ; Map < String , SimpleTypesMapEntry > properties = Maps . uniqueIndex ( data . get ( 0 ) . getPropertiesList ( ) , new Function < SimpleTypesMapEntry , String > ( ) { @ Override public String apply ( SimpleTypesMapEntry item ) { return item . getKey ( ) ; } } ) ; assertThat ( properties . get ( "service.pid" ) . getValue ( ) . getStringValue ( ) , is ( ExampleClass . CONFIG_PID ) ) ; assertThat ( properties . get ( ExampleClassConfig . CONFIG_PROP_EXAMPLE_CONFIG_STRING_VALUE_AGAIN ) . getValue ( ) . getStringValue ( ) , is ( "somewhere" ) ) ; assertThat ( properties . get ( ExampleClassConfig . CONFIG_PROP_EXAMPLE_CONFIG_VALUE ) . getValue ( ) . getInt32Value ( ) , is ( 25 ) ) ; assertThat ( properties . get ( ExampleClassConfig . CONFIG_PROP_EXAMPLE_CONFIG_VALUE_STRING ) . getValue ( ) . getStringValue ( ) , is ( "something" ) ) ; ConfigNamespaceUtils . deleteConfig ( ExampleClass . CONFIG_PID , socket , listener ) ; }
Test setting multiple configuration properties with one message and receiving multiple configuration properties
 with one message.
Test setting multiple configuration properties with one message and receiving multiple configuration properties with one message .
//Delete configuration to insure properties are set to default values. //Set thread pool size for the event admin. //Set timeout //Set require topic //create terra harvest message    //send out message //Verify a set property response is received. //Create message to retrieve configuration and associated properties. //create terra harvest message    // send out message //parse specific message type //verify