@Test public void testReconfigureMessaging_noAgentConfigurationFile() throws IOException { File karafEtc = this.folder.newFolder(); final File msgConf = new File( karafEtc, "net.roboconf.messaging.rabbitmq.cfg" ); final File agentConf = new File( karafEtc, Constants.KARAF_CFG_FILE_AGENT ); Map<String,String> msgData = new HashMap<> (); msgData.put( MessagingConstants.MESSAGING_TYPE_PROPERTY, "rabbitmq" ); msgData.put("net.roboconf.messaging.rabbitmq.server.ip", "rabbit-server"); msgData.put("net.roboconf.messaging.rabbitmq.server.username", "user1"); msgData.put("net.roboconf.messaging.rabbitmq.server.password", "password1"); Assert.assertFalse( msgConf.exists()); Assert.assertFalse( agentConf.exists()); this.userDataHelper.reconfigureMessaging(karafEtc.getAbsolutePath(), msgData); Assert.assertTrue( msgConf.exists()); Assert.assertTrue( agentConf.exists()); Properties p = Utils.readPropertiesFile(msgConf); String val = p.getProperty("net.roboconf.messaging.rabbitmq.server.ip"); Assert.assertEquals(val, "rabbit-server"); val = p.getProperty("net.roboconf.messaging.rabbitmq.server.username"); Assert.assertEquals(val, "user1"); val = p.getProperty("net.roboconf.messaging.rabbitmq.server.password"); Assert.assertEquals(val, "password1"); p = Utils.readPropertiesFile( agentConf ); Assert.assertEquals( "rabbitmq", p.get( Constants.MESSAGING_TYPE )); Assert.assertEquals( 1, p.size()); }
public void reconfigureMessaging( String etcDir, Map<String,String> msgData ) throws IOException { String messagingType = msgData.get( MessagingConstants.MESSAGING_TYPE_PROPERTY ); Logger.getLogger( getClass().getName()).fine( "Messaging type for reconfiguration: " + messagingType ); if( ! Utils.isEmptyOrWhitespaces( etcDir ) && ! Utils.isEmptyOrWhitespaces( messagingType )) { File f = new File( etcDir, "net.roboconf.messaging." + messagingType + ".cfg" ); Logger logger = Logger.getLogger( getClass().getName()); Properties props = Utils.readPropertiesFileQuietly( f, logger ); props.putAll( msgData ); props.remove( MessagingConstants.MESSAGING_TYPE_PROPERTY ); Utils.writePropertiesFile( props, f ); f = new File( etcDir, Constants.KARAF_CFG_FILE_AGENT ); props = Utils.readPropertiesFileQuietly( f, Logger.getLogger( getClass().getName())); if( messagingType != null ) { props.put( Constants.MESSAGING_TYPE, messagingType ); Utils.writePropertiesFile( props, f ); } } }
UserDataHelper { public void reconfigureMessaging( String etcDir, Map<String,String> msgData ) throws IOException { String messagingType = msgData.get( MessagingConstants.MESSAGING_TYPE_PROPERTY ); Logger.getLogger( getClass().getName()).fine( "Messaging type for reconfiguration: " + messagingType ); if( ! Utils.isEmptyOrWhitespaces( etcDir ) && ! Utils.isEmptyOrWhitespaces( messagingType )) { File f = new File( etcDir, "net.roboconf.messaging." + messagingType + ".cfg" ); Logger logger = Logger.getLogger( getClass().getName()); Properties props = Utils.readPropertiesFileQuietly( f, logger ); props.putAll( msgData ); props.remove( MessagingConstants.MESSAGING_TYPE_PROPERTY ); Utils.writePropertiesFile( props, f ); f = new File( etcDir, Constants.KARAF_CFG_FILE_AGENT ); props = Utils.readPropertiesFileQuietly( f, Logger.getLogger( getClass().getName())); if( messagingType != null ) { props.put( Constants.MESSAGING_TYPE, messagingType ); Utils.writePropertiesFile( props, f ); } } } }
UserDataHelper { public void reconfigureMessaging( String etcDir, Map<String,String> msgData ) throws IOException { String messagingType = msgData.get( MessagingConstants.MESSAGING_TYPE_PROPERTY ); Logger.getLogger( getClass().getName()).fine( "Messaging type for reconfiguration: " + messagingType ); if( ! Utils.isEmptyOrWhitespaces( etcDir ) && ! Utils.isEmptyOrWhitespaces( messagingType )) { File f = new File( etcDir, "net.roboconf.messaging." + messagingType + ".cfg" ); Logger logger = Logger.getLogger( getClass().getName()); Properties props = Utils.readPropertiesFileQuietly( f, logger ); props.putAll( msgData ); props.remove( MessagingConstants.MESSAGING_TYPE_PROPERTY ); Utils.writePropertiesFile( props, f ); f = new File( etcDir, Constants.KARAF_CFG_FILE_AGENT ); props = Utils.readPropertiesFileQuietly( f, Logger.getLogger( getClass().getName())); if( messagingType != null ) { props.put( Constants.MESSAGING_TYPE, messagingType ); Utils.writePropertiesFile( props, f ); } } }  }
UserDataHelper { public void reconfigureMessaging( String etcDir, Map<String,String> msgData ) throws IOException { String messagingType = msgData.get( MessagingConstants.MESSAGING_TYPE_PROPERTY ); Logger.getLogger( getClass().getName()).fine( "Messaging type for reconfiguration: " + messagingType ); if( ! Utils.isEmptyOrWhitespaces( etcDir ) && ! Utils.isEmptyOrWhitespaces( messagingType )) { File f = new File( etcDir, "net.roboconf.messaging." + messagingType + ".cfg" ); Logger logger = Logger.getLogger( getClass().getName()); Properties props = Utils.readPropertiesFileQuietly( f, logger ); props.putAll( msgData ); props.remove( MessagingConstants.MESSAGING_TYPE_PROPERTY ); Utils.writePropertiesFile( props, f ); f = new File( etcDir, Constants.KARAF_CFG_FILE_AGENT ); props = Utils.readPropertiesFileQuietly( f, Logger.getLogger( getClass().getName())); if( messagingType != null ) { props.put( Constants.MESSAGING_TYPE, messagingType ); Utils.writePropertiesFile( props, f ); } } }  AgentProperties findParametersForAmazonOrOpenStack( Logger logger ); AgentProperties findParametersForAzure( Logger logger ); AgentProperties findParametersForVmware( Logger logger ); AgentProperties findParametersFromUrl( String url, Logger logger ); void reconfigureMessaging( String etcDir, Map<String,String> msgData ); }
UserDataHelper { public void reconfigureMessaging( String etcDir, Map<String,String> msgData ) throws IOException { String messagingType = msgData.get( MessagingConstants.MESSAGING_TYPE_PROPERTY ); Logger.getLogger( getClass().getName()).fine( "Messaging type for reconfiguration: " + messagingType ); if( ! Utils.isEmptyOrWhitespaces( etcDir ) && ! Utils.isEmptyOrWhitespaces( messagingType )) { File f = new File( etcDir, "net.roboconf.messaging." + messagingType + ".cfg" ); Logger logger = Logger.getLogger( getClass().getName()); Properties props = Utils.readPropertiesFileQuietly( f, logger ); props.putAll( msgData ); props.remove( MessagingConstants.MESSAGING_TYPE_PROPERTY ); Utils.writePropertiesFile( props, f ); f = new File( etcDir, Constants.KARAF_CFG_FILE_AGENT ); props = Utils.readPropertiesFileQuietly( f, Logger.getLogger( getClass().getName())); if( messagingType != null ) { props.put( Constants.MESSAGING_TYPE, messagingType ); Utils.writePropertiesFile( props, f ); } } }  AgentProperties findParametersForAmazonOrOpenStack( Logger logger ); AgentProperties findParametersForAzure( Logger logger ); AgentProperties findParametersForVmware( Logger logger ); AgentProperties findParametersFromUrl( String url, Logger logger ); void reconfigureMessaging( String etcDir, Map<String,String> msgData );  }