ConfigurationEntryStore store = _storeCreator.createStore(_userStoreLocation.getAbsolutePath(), "json", _initialStoreFile.getAbsolutePath(), false, Collections.<String,String>emptyMap());
assertNotNull("Store was not created", store);
assertTrue("File should exists", _userStoreLocation.exists());
assertTrue("File size should be greater than 0", _userStoreLocation.length() > 0);
JsonConfigurationEntryStore jsonStore = new JsonConfigurationEntryStore(_userStoreLocation.getAbsolutePath(), null, false, Collections.<String,String>emptyMap());
ConfigurationEntry entry = jsonStore.getRootEntry();
assertEquals("Unexpected root id", testBrokerId, entry.getId());
Map<String, Object> attributes = entry.getAttributes();
assertNotNull("Unexpected attributes: " + attributes, attributes);
assertEquals("Unexpected attributes size: " + attributes.size(), 3, attributes.size());
assertEquals("Unexpected attribute name: " + attributes.get("name"), testBrokerName, attributes.get(Broker.NAME));
Set<UUID> childrenIds = entry.getChildrenIds();
assertTrue("Unexpected children: " + childrenIds, childrenIds.isEmpty());
if(overwrite)
{
ConfigurationEntryStore overwrittenStore = _storeCreator.createStore(_userStoreLocation.getAbsolutePath(), "json", BrokerOptions.DEFAULT_INITIAL_CONFIG_LOCATION, true, new BrokerOptions().getConfigProperties());
assertNotNull("Store was not created", overwrittenStore);
assertTrue("File should exists", _userStoreLocation.exists());
assertTrue("File size should be greater than 0", _userStoreLocation.length() > 0);
//check the contents reflect the test store content having been overwritten with the default store
JsonConfigurationEntryStore reopenedOverwrittenStore = new JsonConfigurationEntryStore(_userStoreLocation.getAbsolutePath(), null, false, Collections.<String,String>emptyMap());
entry = reopenedOverwrittenStore.getRootEntry();
assertFalse("Root id did not change, store content was not overwritten", testBrokerId.equals(entry.getId()));
attributes = entry.getAttributes();
assertNotNull("No attributes found", attributes);
assertFalse("Test name should not equal default broker name", testBrokerName.equals(defaultBrokerName));
assertEquals("Unexpected broker name value" , defaultBrokerName, attributes.get(Broker.NAME));