@SuppressWarnings( { "unchecked", "rawtypes" } ) @Test public void testInitProperties() throws IOException { String sampleKey = "sampleKey"; String sampleValue = "sampleValue"; Dictionary<String, Object> dictionary = new Hashtable<>(); dictionary.put( sampleKey, sampleValue ); Configuration configuration = mock( Configuration.class ); when( configuration.getProperties() ).thenReturn( dictionary ); ConfigurationAdmin confAdmin = mock( ConfigurationAdmin.class ); when( confAdmin.getConfiguration( anyString() ) ).thenReturn( configuration ); ServiceReference reference = mock( ServiceReference.class ); BundleContext context = mock( BundleContext.class ); when( context.getServiceReference( anyString() ) ).thenReturn( reference ); when( context.getService( any( ServiceReference.class ) ) ).thenReturn( confAdmin ); namedClusterManager.setBundleContext( context ); namedClusterManager.initProperties(); Map<String, Object> prop = namedClusterManager.getProperties(); assertEquals( dictionary.size(), prop.keySet().size() ); Enumeration<String> keys = dictionary.keys(); while ( keys.hasMoreElements() ) { String key = keys.nextElement(); assertTrue( prop.keySet().contains( key ) ); assertTrue( prop.values().contains( dictionary.get( key ) ) ); } }
protected void initProperties() { final ServiceReference<?> serviceReference = getBundleContext().getServiceReference( ConfigurationAdmin.class.getName() ); if ( serviceReference != null ) { try { final ConfigurationAdmin admin = (ConfigurationAdmin) getBundleContext().getService( serviceReference ); final Configuration configuration = admin.getConfiguration( "pentaho.big.data.impl.cluster" ); Dictionary<String, Object> rawProperties = configuration.getProperties(); for ( Enumeration<String> keys = rawProperties.keys(); keys.hasMoreElements(); ) { String key = keys.nextElement(); properties.put( key, rawProperties.get( key ) ); } } catch ( Exception e ) { properties = new HashMap<>(); } } }
NamedClusterManager implements NamedClusterService { protected void initProperties() { final ServiceReference<?> serviceReference = getBundleContext().getServiceReference( ConfigurationAdmin.class.getName() ); if ( serviceReference != null ) { try { final ConfigurationAdmin admin = (ConfigurationAdmin) getBundleContext().getService( serviceReference ); final Configuration configuration = admin.getConfiguration( "pentaho.big.data.impl.cluster" ); Dictionary<String, Object> rawProperties = configuration.getProperties(); for ( Enumeration<String> keys = rawProperties.keys(); keys.hasMoreElements(); ) { String key = keys.nextElement(); properties.put( key, rawProperties.get( key ) ); } } catch ( Exception e ) { properties = new HashMap<>(); } } } }
NamedClusterManager implements NamedClusterService { protected void initProperties() { final ServiceReference<?> serviceReference = getBundleContext().getServiceReference( ConfigurationAdmin.class.getName() ); if ( serviceReference != null ) { try { final ConfigurationAdmin admin = (ConfigurationAdmin) getBundleContext().getService( serviceReference ); final Configuration configuration = admin.getConfiguration( "pentaho.big.data.impl.cluster" ); Dictionary<String, Object> rawProperties = configuration.getProperties(); for ( Enumeration<String> keys = rawProperties.keys(); keys.hasMoreElements(); ) { String key = keys.nextElement(); properties.put( key, rawProperties.get( key ) ); } } catch ( Exception e ) { properties = new HashMap<>(); } } }  }
NamedClusterManager implements NamedClusterService { protected void initProperties() { final ServiceReference<?> serviceReference = getBundleContext().getServiceReference( ConfigurationAdmin.class.getName() ); if ( serviceReference != null ) { try { final ConfigurationAdmin admin = (ConfigurationAdmin) getBundleContext().getService( serviceReference ); final Configuration configuration = admin.getConfiguration( "pentaho.big.data.impl.cluster" ); Dictionary<String, Object> rawProperties = configuration.getProperties(); for ( Enumeration<String> keys = rawProperties.keys(); keys.hasMoreElements(); ) { String key = keys.nextElement(); properties.put( key, rawProperties.get( key ) ); } } catch ( Exception e ) { properties = new HashMap<>(); } } }  BundleContext getBundleContext(); void setBundleContext( BundleContext bundleContext ); @Override void close( IMetaStore metastore ); @Override NamedCluster getClusterTemplate(); @Override void setClusterTemplate( NamedCluster clusterTemplate ); @Override void create( NamedCluster namedCluster, IMetaStore metastore ); @Override NamedCluster read( String clusterName, IMetaStore metastore ); @Override void update( NamedCluster namedCluster, IMetaStore metastore ); @Override void delete( String clusterName, IMetaStore metastore ); @Override List<NamedCluster> list( IMetaStore metastore ); @Override List<NamedCluster> list( IMetaStore metastore, List<MetaStoreException> exceptionList ); @Override List<String> listNames( IMetaStore metastore ); @Override boolean contains( String clusterName, IMetaStore metastore ); @Override NamedCluster getNamedClusterByName( String namedClusterName, IMetaStore metastore ); Map<String, Object> getProperties(); @Override NamedCluster getNamedClusterByHost( String hostName, IMetaStore metastore ); @Override void updateNamedClusterTemplate( String hostName, int port, boolean isMapr ); }
NamedClusterManager implements NamedClusterService { protected void initProperties() { final ServiceReference<?> serviceReference = getBundleContext().getServiceReference( ConfigurationAdmin.class.getName() ); if ( serviceReference != null ) { try { final ConfigurationAdmin admin = (ConfigurationAdmin) getBundleContext().getService( serviceReference ); final Configuration configuration = admin.getConfiguration( "pentaho.big.data.impl.cluster" ); Dictionary<String, Object> rawProperties = configuration.getProperties(); for ( Enumeration<String> keys = rawProperties.keys(); keys.hasMoreElements(); ) { String key = keys.nextElement(); properties.put( key, rawProperties.get( key ) ); } } catch ( Exception e ) { properties = new HashMap<>(); } } }  BundleContext getBundleContext(); void setBundleContext( BundleContext bundleContext ); @Override void close( IMetaStore metastore ); @Override NamedCluster getClusterTemplate(); @Override void setClusterTemplate( NamedCluster clusterTemplate ); @Override void create( NamedCluster namedCluster, IMetaStore metastore ); @Override NamedCluster read( String clusterName, IMetaStore metastore ); @Override void update( NamedCluster namedCluster, IMetaStore metastore ); @Override void delete( String clusterName, IMetaStore metastore ); @Override List<NamedCluster> list( IMetaStore metastore ); @Override List<NamedCluster> list( IMetaStore metastore, List<MetaStoreException> exceptionList ); @Override List<String> listNames( IMetaStore metastore ); @Override boolean contains( String clusterName, IMetaStore metastore ); @Override NamedCluster getNamedClusterByName( String namedClusterName, IMetaStore metastore ); Map<String, Object> getProperties(); @Override NamedCluster getNamedClusterByHost( String hostName, IMetaStore metastore ); @Override void updateNamedClusterTemplate( String hostName, int port, boolean isMapr ); static final String BIG_DATA_SLAVE_METASTORE_DIR; }