AzureDataStoreFactory implements BlobStoreFactory { static AzureDataStore createDS(String directory, Properties props) { Properties strippedProperties = new Properties(); Map<String, String> map = Maps.newHashMap(); if(StringUtils.isEmpty(directory) && !map.containsKey("path")) { directory = System.getProperty("java.io.tmpdir"); } for (Object key : new HashSet<>(props.keySet())) { String strippedValue = stripValue(props.getProperty((String) key)); strippedProperties.put(key, strippedValue); map.put((String) key, strippedValue); } AzureDataStore ds = new AzureDataStore(); ds.setProperties(strippedProperties); ds.setPath(directory); PropertiesUtil.populate(ds, map, false); return ds; } AzureDataStoreFactory(String configuration, String directory, boolean ignoreMissingBlobs); @Override BlobStore create(Closer closer); @Override String toString();  }
@Test public void testPopulateProperties() throws NoSuchFieldException, IllegalAccessException { Properties props = new Properties(); props.setProperty("cacheSize", "123"); AzureDataStore ds = AzureDataStoreFactory.createDS("/tmp", props); assertEquals(123, readLong("cacheSize", AbstractSharedCachingDataStore.class, ds)); assertEquals("/tmp", readString("path", AbstractSharedCachingDataStore.class, ds)); }
@Test public void testPopulatePropertiesNoPath() throws NoSuchFieldException, IllegalAccessException { Properties props = new Properties(); props.setProperty("cacheSize", "123"); String tempDir = System.getProperty("java.io.tmpdir"); AzureDataStore ds = AzureDataStoreFactory.createDS(null, props); assertEquals(123, readLong("cacheSize", AbstractSharedCachingDataStore.class, ds)); assertEquals(tempDir, readString("path", AbstractSharedCachingDataStore.class, ds)); }
@Test public void testPopulatePropertiesPathFromConfig() throws NoSuchFieldException, IllegalAccessException { Properties props = new Properties(); props.setProperty("cacheSize", "123"); props.setProperty("path", "/tmp"); AzureDataStore ds = AzureDataStoreFactory.createDS(null, props); assertEquals(123, readLong("cacheSize", AbstractSharedCachingDataStore.class, ds)); assertEquals("/tmp", readString("path", AbstractSharedCachingDataStore.class, ds)); }
@Test public void testStripOsgiPrefix() throws NoSuchFieldException, IllegalAccessException { Properties props = new Properties(); props.setProperty("cacheSize", "I\"123\""); AzureDataStore ds = AzureDataStoreFactory.createDS("xyz", props); assertEquals(123, readLong("cacheSize", AbstractSharedCachingDataStore.class, ds)); }