use of com.netflix.exhibitor.core.config.none.NoneConfigProvider in project exhibitor by soabase.
the class TestZooCfgOrdering method testZooCfgOrdering.
@Test
public void testZooCfgOrdering() throws Exception {
final String CFG_EXTRA = "initLimit=30\n" + "syncLimit=30\n" + "tickTime=2000\n" + "aaa=test";
File tempDirectory = Files.createTempDir();
ConfigProvider config = new NoneConfigProvider(tempDirectory.getPath());
Properties properties = new Properties();
properties.setProperty(PropertyBasedInstanceConfig.toName(StringConfigs.ZOO_CFG_EXTRA, PropertyBasedInstanceConfig.ROOT_PROPERTY_PREFIX), CFG_EXTRA);
LoadedInstanceConfig instanceConfig = config.storeConfig(new PropertyBasedInstanceConfig(properties, new Properties()), 0);
String string = instanceConfig.getConfig().getRootConfig().getString(StringConfigs.ZOO_CFG_EXTRA);
Assert.assertEquals(CFG_EXTRA, string);
EncodedConfigParser parser = new EncodedConfigParser("s=10&d=dee&a=hey");
Assert.assertEquals(parser.getFieldValues().size(), 3);
Assert.assertEquals(parser.getFieldValues().get(0), new EncodedConfigParser.FieldValue("s", "10"));
Assert.assertEquals(parser.getFieldValues().get(1), new EncodedConfigParser.FieldValue("d", "dee"));
Assert.assertEquals(parser.getFieldValues().get(2), new EncodedConfigParser.FieldValue("a", "hey"));
Map<String, String> sortedMap = parser.getSortedMap();
Iterator<Map.Entry<String, String>> iterator = sortedMap.entrySet().iterator();
Assert.assertEquals(sortedMap.size(), 3);
Assert.assertEquals(iterator.next(), new HashMap.SimpleEntry<String, String>("a", "hey"));
Assert.assertEquals(iterator.next(), new HashMap.SimpleEntry<String, String>("d", "dee"));
Assert.assertEquals(iterator.next(), new HashMap.SimpleEntry<String, String>("s", "10"));
}
Aggregations