Author: orudyy
Date: Fri Dec 21 18:23:16 2012
New Revision: 1425070
URL: http://svn.apache.org/viewvc?rev=1425070&view=rev
Log:
QPID-4390: Add JSON broker configuration store
Added:
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStore.java
- copied, changed from r1423438,
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStore.j
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/store/ConfigurationEntryStoreTestCase.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStoreTest.java
Removed:
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStore.j
Modified:
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfigurationEntry.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfigurationEntryStore.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/AttributeMap.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/XMLConfigurationEntryStore.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/UUIDGenerator.java
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/model/BrokerShutdownTest.java
Modified:
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfigurationEntry.java
URL:
http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfigurationEntry.java?rev=1425070&r1=1425069&r2=1425070&view=diff
==============================================================================
---
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfigurationEntry.java
(original)
+++
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfigurationEntry.java
Fri Dec 21 18:23:16 2012
@@ -28,8 +28,6 @@ import java.util.Map;
import java.util.Set;
import java.util.UUID;
-import org.apache.qpid.server.configuration.startup.AttributeMap;
-
public class ConfigurationEntry
{
private final UUID _id;
@@ -103,6 +101,11 @@ public class ConfigurationEntry
return Collections.unmodifiableMap(children);
}
+ public boolean hasChild(UUID id)
+ {
+ return _childrenIds.contains(id);
+ }
+
@Override
public int hashCode()
{
Modified:
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfigurationEntryStore.java
URL:
http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfigurationEntryStore.java?rev=1425070&r1=1425069&r2=1425070&view=diff
==============================================================================
---
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfigurationEntryStore.java
(original)
+++
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfigurationEntryStore.java
Fri Dec 21 18:23:16 2012
@@ -30,6 +30,6 @@ public interface ConfigurationEntryStore
void save(ConfigurationEntry... entries);
- void remove(UUID... entryIds);
+ UUID[] remove(UUID... entryIds);
}
Modified:
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/AttributeMap.java
URL:
http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/AttributeMap.java?rev=1425070&r1=1425069&r2=1425070&view=diff
==============================================================================
---
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/AttributeMap.java
(original)
+++
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/AttributeMap.java
Fri Dec 21 18:23:16 2012
@@ -24,7 +24,7 @@ import java.util.Map;
import java.util.Set;
import org.apache.qpid.server.util.MapValueConverter;
-
+//TODO: delete me
public class AttributeMap
{
private Map<String, Object> _source;
Copied:
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStore.java
(from r1423438,
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStore.j)
URL:
http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStore.java?p2=qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStore.java&p1=qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStore.j&r1=1423438&r2=1425070&rev=1425070&view=diff
==============================================================================
---
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStore.j
(original)
+++
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStore.java
Fri Dec 21 18:23:16 2012
@@ -2,10 +2,11 @@ package org.apache.qpid.server.configura
import java.io.File;
import java.io.IOException;
-import java.util.Collection;
-import java.util.Collections;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
@@ -16,17 +17,21 @@ import org.apache.qpid.server.configurat
import org.apache.qpid.server.configuration.ConfigurationEntryStore;
import org.apache.qpid.server.configuration.IllegalConfigurationException;
import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.UUIDGenerator;
import org.codehaus.jackson.JsonGenerationException;
import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.JsonProcessingException;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.SerializationConfig;
+import org.codehaus.jackson.node.ArrayNode;
public class JsonConfigurationEntryStore implements ConfigurationEntryStore
{
+ static final String ATTRIBUTES = "attributes";
private static final String ID = "id";
private static final String TYPE = "type";
+ private static final String NAME = "name";
private ObjectMapper _objectMapper;
private Map<UUID, ConfigurationEntry> _entries;
@@ -38,15 +43,19 @@ public class JsonConfigurationEntryStore
_storeFile = new File(filePath);
_objectMapper = new ObjectMapper();
_objectMapper.configure(SerializationConfig.Feature.INDENT_OUTPUT,
true);
- _entries = new HashMap<UUID, ConfigurationEntry>();
+
if (_storeFile.exists())
{
JsonNode node = load(_storeFile, _objectMapper);
- _rootId = getId(node);
- _entries.putAll(flattenTree(_rootId, node));
+
+ Map<UUID, ConfigurationEntry> entries = new HashMap<UUID,
ConfigurationEntry>();
+ ConfigurationEntry brokerEntry = toEntry(node, true, entries);
+ _rootId = brokerEntry.getId();
+ _entries = entries;
}
else
{
+ _entries = new HashMap<UUID, ConfigurationEntry>();
File parent = _storeFile.getParentFile();
if (!parent.exists())
{
@@ -66,87 +75,74 @@ public class JsonConfigurationEntryStore
{
throw new IllegalConfigurationException("Cannot write into
file at " + _storeFile, e);
}
- ConfigurationEntry brokerEntry = new
ConfigurationEntry(UUID.randomUUID(), Broker.class.getSimpleName(), null,
- null, null);
+ ConfigurationEntry brokerEntry = new
ConfigurationEntry(UUID.randomUUID(), Broker.class.getSimpleName(), null, null,
null);
_rootId = brokerEntry.getId();
save(brokerEntry);
}
}
@Override
- public synchronized Collection<ConfigurationEntry> list()
- {
- return Collections.unmodifiableCollection(_entries.values());
- }
-
- @Override
- public synchronized void save(ConfigurationEntry entry)
+ public synchronized UUID[] remove(UUID... entryIds)
{
- ConfigurationEntry parent = null;
- ConfigurationEntry oldEntry = _entries.put(entry.getId(), entry);
- if (!entry.equals(oldEntry))
+ List<UUID> removedIds = new ArrayList<UUID>();
+ boolean anyRemoved = false;
+ for (UUID uuid : entryIds)
{
- if (oldEntry == null && parent != null)
+ if (removeInternal(uuid))
{
- Set<UUID> parentChildren = parent.getChildrenIds();
- parentChildren.add(entry.getId());
- _entries.put(parentId, new ConfigurationEntry(parent.getId(),
parent.getType(), parent.getAttributes(), parent.getParentId(),
parentChildren));
+ anyRemoved = true;
+
+ // remove references to the entry from parent entries
+ for (ConfigurationEntry entry : _entries.values())
+ {
+ if (entry.hasChild(uuid))
+ {
+ Set<UUID> children = new
HashSet<UUID>(entry.getChildrenIds());
+ children.remove(uuid);
+ ConfigurationEntry referal = new
ConfigurationEntry(entry.getId(), entry.getType(), entry.getAttributes(),
children, this);
+ _entries.put(entry.getId(), referal);
+ }
+ }
+ removedIds.add(uuid);
}
- saveAsTree();
}
- }
-
- @Override
- public synchronized void remove(UUID entryId)
- {
- if (removeInternal(entryId))
+ if (anyRemoved)
{
saveAsTree();
}
+ return removedIds.toArray(new UUID[removedIds.size()]);
}
@Override
- public synchronized void save(ConfigurationEntry[] entries)
+ public synchronized void save(ConfigurationEntry... entries)
{
- boolean theSame = true;
- for (int i = 0; i < entries.length; i++)
- {
- ConfigurationEntry entry = entries[i];
- UUID parentId = entry.getParentId();
- if (parentId != null)
- {
- ConfigurationEntry parent = _entries.get(parentId);
- if (parent == null)
- {
- throw new IllegalConfigurationException("Unknown parentId
" + entry.getParentId());
- }
- }
- }
- for (int i = 0; i < entries.length; i++)
+ boolean anySaved = false;
+ for (ConfigurationEntry entry : entries)
{
- ConfigurationEntry entry = entries[i];
ConfigurationEntry oldEntry = _entries.put(entry.getId(), entry);
if (!entry.equals(oldEntry))
{
- theSame = false;
- if (oldEntry == null)
- {
- ConfigurationEntry parent =
_entries.get(entry.getParentId());
- if (parent != null)
- {
- Set<UUID> parentChildren = parent.getChildrenIds();
- parentChildren.add(entry.getId());
- _entries.put(parent.getId(), new
ConfigurationEntry(parent.getId(), parent.getType(), parent.getAttributes(),
parent.getParentId(), parentChildren));
- }
- }
+ anySaved = true;
}
}
- if (!theSame)
+ if (anySaved)
{
saveAsTree();
}
}
+ @Override
+ public ConfigurationEntry getRootEntry()
+ {
+ return getEntry(_rootId);
+ }
+
+ @Override
+ public synchronized ConfigurationEntry getEntry(UUID id)
+ {
+ return _entries.get(id);
+ }
+
private boolean removeInternal(UUID entryId)
{
ConfigurationEntry oldEntry = _entries.remove(entryId);
@@ -160,17 +156,6 @@ public class JsonConfigurationEntryStore
removeInternal(childId);
}
}
- UUID parentId = oldEntry.getParentId();
- if (parentId != null)
- {
- ConfigurationEntry parent = _entries.get(parentId);
- if (parent != null)
- {
- Set<UUID> parentChildren = parent.getChildrenIds();
- parentChildren.remove(oldEntry.getId());
- _entries.put(parentId, new
ConfigurationEntry(parent.getId(), parent.getType(), parent.getAttributes(),
parent.getParentId(), parentChildren));
- }
- }
return true;
}
return false;
@@ -213,7 +198,7 @@ public class JsonConfigurationEntryStore
Map<String, Object> attributes = entry.getAttributes();
if (attributes != null)
{
- tree.putAll(attributes);
+ tree.put(ATTRIBUTES, attributes);
}
tree.put(ID, entry.getId());
tree.put(TYPE, entry.getType());
@@ -259,130 +244,169 @@ public class JsonConfigurationEntryStore
return root;
}
- private Map<UUID, ConfigurationEntry> flattenTree(UUID id, JsonNode root)
+ private ConfigurationEntry toEntry(JsonNode parent, boolean isRoot,
Map<UUID, ConfigurationEntry> entries)
{
- String type = getType(root);
- UUID parentId = getParentId(root);
-
Map<String, Object> attributes = new HashMap<String, Object>();
Set<UUID> childrenIds = new TreeSet<UUID>();
-
- ConfigurationEntry entry = new ConfigurationEntry(id, type,
attributes, childrenIds, this);
- Map<UUID, ConfigurationEntry> entries = new HashMap<UUID,
ConfigurationEntry>();
- entries.put(id, entry);
- Iterator<String> fieldNames = root.getFieldNames();
+ Iterator<String> fieldNames = parent.getFieldNames();
+ String type = null;
+ String idAsString = null;
while (fieldNames.hasNext())
{
- String name = fieldNames.next();
- JsonNode node = root.get(name);
- if (node.isValueNode())
+ String fieldName = fieldNames.next();
+ JsonNode fieldNode = parent.get(fieldName);
+ if (fieldName.equals(ATTRIBUTES))
{
- if (node.isBoolean())
+ if (fieldNode != null)
{
- attributes.put(name, node.asBoolean());
- }
- else if (node.isDouble())
- {
- attributes.put(name, node.asDouble());
- }
- else if (node.isInt())
- {
- attributes.put(name, node.asInt());
- }
- else if (node.isLong())
- {
- attributes.put(name, node.asLong());
- }
- else if (node.isNull())
- {
- attributes.put(name, null);
- }
- else
- {
- String text = node.asText();
- try
+ if (!fieldNode.isObject())
{
- UUID referedId = UUID.fromString(text);
- attributes.put(name, referedId);
+ throw new IllegalConfigurationException("Object
attributes are set incorrectly for " + parent);
}
- catch (Exception e)
+ Iterator<String> attributeNamesNames =
fieldNode.getFieldNames();
+ while (attributeNamesNames.hasNext())
{
- attributes.put(name, text);
+ String name = attributeNamesNames.next();
+ JsonNode node = fieldNode.get(name);
+ attributes.put(name, toObject(node));
}
}
}
- else if (node.isArray())
+ else if (fieldName.equals(ID))
+ {
+ idAsString = fieldNode.asText();
+ }
+ else if (fieldName.equals(TYPE))
+ {
+ type = fieldNode.asText();
+ }
+ else if (fieldNode.isArray())
{
- Iterator<JsonNode> elements = node.getElements();
+ Iterator<JsonNode> elements = fieldNode.getElements();
while (elements.hasNext())
{
JsonNode element = elements.next();
- UUID elementId = getId(element);
- childrenIds.add(elementId);
- Map<UUID, ConfigurationEntry> subEntries =
flattenTree(elementId, element);
- entries.putAll(subEntries);
+ ConfigurationEntry entry = toEntry(element, false,
entries);
+ childrenIds.add(entry.getId());
}
}
else
{
- throw new IllegalConfigurationException("Unexpected node " +
root + "!");
+ throw new IllegalConfigurationException("Cannot parse
configuration for node " + fieldName + "=" + fieldNode);
}
}
- return entries;
- }
+ if (type == null)
+ {
+ if (isRoot)
+ {
+ type = Broker.class.getName();
+ }
+ else
+ {
+ throw new IllegalConfigurationException("Type attribute is not
provided for configuration entry " + parent);
+ }
+ }
+ String name = (String) attributes.get(NAME);
+ if ((name == null || "".equals(name)))
+ {
+ if (isRoot)
+ {
+ name = "Broker";
+ }
+ else
+ {
+ throw new IllegalConfigurationException("Name attribute is not
provided for configuration entry " + parent);
+ }
+ }
+ UUID id = null;
- private String getType(JsonNode root)
- {
- JsonNode typeNode = root.get(TYPE);
- if (typeNode != null)
+ if (idAsString == null)
+ {
+ id = UUIDGenerator.generateBrokerChildUUID(type, name);
+ }
+ else
+ {
+ try
+ {
+ id = UUID.fromString(idAsString);
+ }
+ catch (Exception e)
+ {
+ throw new IllegalConfigurationException("ID attribute value
does not conform to UUID format for configuration entry " + parent);
+ }
+ }
+ ConfigurationEntry entry = new ConfigurationEntry(id, type,
attributes, childrenIds, this);
+ if (entries.containsKey(id))
{
- return typeNode.asText();
+ throw new IllegalConfigurationException("Duplicate id is found: "
+ id + "! The following configuration entries have the same id: "
+ + entries.get(id) + ", " + entry);
}
- return null;
+ entries.put(id, entry);
+ return entry;
}
- private UUID getId(JsonNode node)
+ private Object toObject(JsonNode node)
{
- JsonNode idNode = node.get(ID);
- if (idNode == null)
+ if (node.isValueNode())
{
- return UUID.randomUUID();
+ if (node.isBoolean())
+ {
+ return node.asBoolean();
+ }
+ else if (node.isDouble())
+ {
+ return node.asDouble();
+ }
+ else if (node.isInt())
+ {
+ return node.asInt();
+ }
+ else if (node.isLong())
+ {
+ return node.asLong();
+ }
+ else if (node.isNull())
+ {
+ return null;
+ }
+ else
+ {
+ return node.asText();
+ }
}
- String id = idNode.asText();
- if (id == null)
+ else if (node.isArray())
{
- return UUID.randomUUID();
+ return toArray(node);
}
- try
+ else if (node.isObject())
{
- return UUID.fromString(id);
+ Map<String, Object> object = new HashMap<String, Object>();
+ Iterator<String> fieldNames = node.getFieldNames();
+ while (fieldNames.hasNext())
+ {
+ String name = fieldNames.next();
+ Object value = toObject(node.get(name));
+ object.put(name, value);
+ }
+ return object;
}
- catch (Exception e)
+ else
{
- return UUID.nameUUIDFromBytes(id.getBytes());
+ throw new IllegalConfigurationException("Unexpected node: " +
node);
}
}
- @Override
- public ConfigurationEntry getRootEntry()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public ConfigurationEntry getEntry(UUID id)
+ private Object toArray(JsonNode node)
{
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public void remove(UUID... entryIds)
- {
- // TODO Auto-generated method stub
-
+ ArrayNode arrayNode = (ArrayNode) node;
+ Object[] array = new Object[arrayNode.size()];
+ Iterator<JsonNode> elements = arrayNode.getElements();
+ for (int i = 0; i < array.length; i++)
+ {
+ array[i] = toObject(elements.next());
+ }
+ return array;
}
}
Modified:
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/XMLConfigurationEntryStore.java
URL:
http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/XMLConfigurationEntryStore.java?rev=1425070&r1=1425069&r2=1425070&view=diff
==============================================================================
---
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/XMLConfigurationEntryStore.java
(original)
+++
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/XMLConfigurationEntryStore.java
Fri Dec 21 18:23:16 2012
@@ -460,15 +460,13 @@ public class XMLConfigurationEntryStore
@Override
public void save(ConfigurationEntry... entries)
{
- // TODO Auto-generated method stub
-
+ throw new RuntimeException("Unsupported operation");
}
@Override
- public void remove(UUID... entryIds)
+ public UUID[] remove(UUID... entryIds)
{
- // TODO Auto-generated method stub
-
+ throw new RuntimeException("Unsupported operation");
}
public ServerConfiguration getConfiguration()
Modified:
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/UUIDGenerator.java
URL:
http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/UUIDGenerator.java?rev=1425070&r1=1425069&r2=1425070&view=diff
==============================================================================
---
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/UUIDGenerator.java
(original)
+++
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/UUIDGenerator.java
Fri Dec 21 18:23:16 2012
@@ -87,4 +87,9 @@ public class UUIDGenerator
{
return createUUID(GroupMember.class.getName(), groupProviderName,
groupName, groupMemberName);
}
+
+ public static UUID generateBrokerChildUUID(String type, String childName)
+ {
+ return createUUID(type, childName);
+ }
}
Added:
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/store/ConfigurationEntryStoreTestCase.java
URL:
http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/store/ConfigurationEntryStoreTestCase.java?rev=1425070&view=auto
==============================================================================
---
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/store/ConfigurationEntryStoreTestCase.java
(added)
+++
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/store/ConfigurationEntryStoreTestCase.java
Fri Dec 21 18:23:16 2012
@@ -0,0 +1,393 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.server.configuration.store;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+
+import org.apache.qpid.server.configuration.ConfigurationEntry;
+import org.apache.qpid.server.configuration.ConfigurationEntryStore;
+import org.apache.qpid.server.configuration.IllegalConfigurationException;
+import org.apache.qpid.server.model.AuthenticationProvider;
+import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.GroupProvider;
+import org.apache.qpid.server.model.KeyStore;
+import org.apache.qpid.server.model.Port;
+import org.apache.qpid.server.model.Transport;
+import org.apache.qpid.server.model.TrustStore;
+import org.apache.qpid.server.model.VirtualHost;
+import org.apache.qpid.server.plugin.AuthenticationManagerFactory;
+import
org.apache.qpid.server.security.auth.manager.AnonymousAuthenticationManager;
+import
org.apache.qpid.server.security.auth.manager.ExternalAuthenticationManager;
+import org.apache.qpid.test.utils.QpidTestCase;
+
+public abstract class ConfigurationEntryStoreTestCase extends QpidTestCase
+{
+ private ConfigurationEntryStore _store;
+
+ private UUID _brokerId;
+ private UUID _virtualHostId;
+ private UUID _authenticationProviderId;
+
+ private Map<String, Object> _brokerAttributes;
+ private Map<String, Object> _virtualHostAttributes;
+ private Map<String, Object> _authenticationProviderAttributes;
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+
+ _brokerId = UUID.randomUUID();
+ _brokerAttributes = new HashMap<String, Object>();
+ _brokerAttributes.put(Broker.DEFAULT_VIRTUAL_HOST, "test");
+ _brokerAttributes.put(Broker.DEFAULT_AUTHENTICATION_PROVIDER,
"authenticationProvider1");
+ _brokerAttributes.put(Broker.ALERT_THRESHOLD_MESSAGE_AGE, 9);
+ _brokerAttributes.put(Broker.ALERT_THRESHOLD_MESSAGE_COUNT, 8);
+ _brokerAttributes.put(Broker.ALERT_THRESHOLD_QUEUE_DEPTH, 7);
+ _brokerAttributes.put(Broker.ALERT_THRESHOLD_MESSAGE_SIZE, 6);
+ _brokerAttributes.put(Broker.ALERT_REPEAT_GAP, 5);
+ _brokerAttributes.put(Broker.FLOW_CONTROL_SIZE_BYTES, 5);
+ _brokerAttributes.put(Broker.FLOW_CONTROL_RESUME_SIZE_BYTES, 3);
+ _brokerAttributes.put(Broker.MAXIMUM_DELIVERY_ATTEMPTS, 2);
+ _brokerAttributes.put(Broker.DEAD_LETTER_QUEUE_ENABLED, true);
+ _brokerAttributes.put(Broker.HOUSEKEEPING_CHECK_PERIOD, 1);
+ _brokerAttributes.put(Broker.ACL_FILE, "/path/to/acl");
+ _brokerAttributes.put(Broker.SESSION_COUNT_LIMIT, 1000);
+ _brokerAttributes.put(Broker.HEART_BEAT_DELAY, 2000);
+ _brokerAttributes.put(Broker.STATISTICS_REPORTING_PERIOD, 4000);
+ _brokerAttributes.put(Broker.STATISTICS_REPORTING_RESET_ENABLED, true);
+
+ _virtualHostId = UUID.randomUUID();
+ _virtualHostAttributes = new HashMap<String, Object>();
+ _virtualHostAttributes.put(VirtualHost.NAME, "test");
+ _virtualHostAttributes.put(VirtualHost.CONFIGURATION,
"/path/to/phantom/test");
+
+ _authenticationProviderId = UUID.randomUUID();
+ _authenticationProviderAttributes = new HashMap<String, Object>();
+ _authenticationProviderAttributes.put(AuthenticationProvider.NAME,
"authenticationProvider1");
+
_authenticationProviderAttributes.put(AuthenticationManagerFactory.ATTRIBUTE_TYPE,
AnonymousAuthenticationManager.class.getSimpleName());
+
+ _store = createStore(_brokerId, _brokerAttributes);
+ addConfiguration(_virtualHostId, VirtualHost.class.getName(),
_virtualHostAttributes);
+ addConfiguration(_authenticationProviderId,
AuthenticationProvider.class.getName(), _authenticationProviderAttributes);
+ }
+
+ // ??? perhaps it should not be abstract
+ protected abstract ConfigurationEntryStore createStore(UUID brokerId,
Map<String, Object> brokerAttributes) throws Exception;
+
+ protected abstract void addConfiguration(UUID id, String type, Map<String,
Object> attributes);
+
+ protected ConfigurationEntryStore getStore()
+ {
+ return _store;
+ }
+
+ public void testGetRootEntry()
+ {
+ ConfigurationEntry brokerConfigEntry = _store.getRootEntry();
+ assertNotNull("Root entry does not exist", brokerConfigEntry);
+ assertEquals("Unexpected id", _brokerId, brokerConfigEntry.getId());
+ assertEquals("Unexpected type ", Broker.class.getName(),
brokerConfigEntry.getType());
+ Map<String, Object> attributes = brokerConfigEntry.getAttributes();
+ assertNotNull("Attributes cannot be null", attributes);
+ assertEquals("Unexpected attributes", _brokerAttributes, attributes);
+ }
+
+ public void testGetEntry()
+ {
+ ConfigurationEntry authenticationProviderConfigEntry =
_store.getEntry(_authenticationProviderId);
+ assertNotNull("Provider with id " + _authenticationProviderId + "
should exist", authenticationProviderConfigEntry);
+ assertEquals("Unexpected id", _authenticationProviderId,
authenticationProviderConfigEntry.getId());
+ assertEquals("Unexpected type ",
AuthenticationProvider.class.getName(),
authenticationProviderConfigEntry.getType());
+ Map<String, Object> attributes =
authenticationProviderConfigEntry.getAttributes();
+ assertNotNull("Attributes cannot be null", attributes);
+ assertEquals("Unexpected attributes",
_authenticationProviderAttributes, attributes);
+ }
+
+ public void testRemove()
+ {
+ Map<String, Object> virtualHostAttributes = new HashMap<String,
Object>();
+ virtualHostAttributes.put(VirtualHost.NAME, getName());
+ virtualHostAttributes.put(VirtualHost.CONFIGURATION,
"/path/to/phantom/virtualhost/config");
+ UUID virtualHostId = UUID.randomUUID();
+ addConfiguration(virtualHostId, VirtualHost.class.getName(),
virtualHostAttributes);
+
+ assertNotNull("Virtual host with id " + virtualHostId + " should
exist", _store.getEntry(virtualHostId));
+
+ _store.remove(virtualHostId);
+ assertNull("Authentication provider configuration should be removed",
_store.getEntry(virtualHostId));
+ }
+
+ public void testRemoveMultipleEntries()
+ {
+ Map<String, Object> virtualHost1Attributes = new HashMap<String,
Object>();
+ virtualHost1Attributes.put(VirtualHost.NAME, "test1");
+ virtualHost1Attributes.put(VirtualHost.CONFIGURATION,
"/path/to/phantom/virtualhost/config1");
+ UUID virtualHost1Id = UUID.randomUUID();
+ addConfiguration(virtualHost1Id, VirtualHost.class.getName(),
virtualHost1Attributes);
+
+ Map<String, Object> virtualHost2Attributes = new HashMap<String,
Object>();
+ virtualHost2Attributes.put(VirtualHost.NAME, "test1");
+ virtualHost2Attributes.put(VirtualHost.CONFIGURATION,
"/path/to/phantom/virtualhost/config2");
+ UUID virtualHost2Id = UUID.randomUUID();
+ addConfiguration(virtualHost2Id, VirtualHost.class.getName(),
virtualHost2Attributes);
+
+ assertNotNull("Virtual host with id " + virtualHost1Id + " should
exist", _store.getEntry(virtualHost1Id));
+ assertNotNull("Virtual host with id " + virtualHost2Id + " should
exist", _store.getEntry(virtualHost2Id));
+
+ UUID[] deletedIds = _store.remove(virtualHost1Id, virtualHost2Id);
+ assertNotNull("Unexpected deleted ids", deletedIds);
+ assertEquals("Unexpected id of first deleted virtual host",
virtualHost1Id , deletedIds[0]);
+ assertEquals("Unexpected id of second deleted virtual host",
virtualHost2Id , deletedIds[1]);
+ assertNull("First virtual host configuration should be removed",
_store.getEntry(virtualHost1Id));
+ assertNull("Second virtual host configuration should be removed",
_store.getEntry(virtualHost2Id));
+ }
+
+ public void testSaveBroker()
+ {
+ ConfigurationEntry brokerConfigEntry = _store.getRootEntry();
+ Map<String, Object> attributes = new HashMap<String, Object>();
+ attributes.put(Broker.DEFAULT_VIRTUAL_HOST, "test");
+ attributes.put(Broker.DEFAULT_AUTHENTICATION_PROVIDER,
"authenticationProvider1");
+ attributes.put(Broker.ALERT_THRESHOLD_MESSAGE_AGE, 19);
+ attributes.put(Broker.ALERT_THRESHOLD_MESSAGE_COUNT, 18);
+ attributes.put(Broker.ALERT_THRESHOLD_QUEUE_DEPTH, 17);
+ attributes.put(Broker.ALERT_THRESHOLD_MESSAGE_SIZE, 16);
+ attributes.put(Broker.ALERT_REPEAT_GAP, 15);
+ attributes.put(Broker.FLOW_CONTROL_SIZE_BYTES, 15);
+ attributes.put(Broker.FLOW_CONTROL_RESUME_SIZE_BYTES, 13);
+ attributes.put(Broker.MAXIMUM_DELIVERY_ATTEMPTS, 12);
+ attributes.put(Broker.DEAD_LETTER_QUEUE_ENABLED, false);
+ attributes.put(Broker.HOUSEKEEPING_CHECK_PERIOD, 11);
+ attributes.put(Broker.ACL_FILE, "/path/to/acl1");
+ attributes.put(Broker.SESSION_COUNT_LIMIT, 11000);
+ attributes.put(Broker.HEART_BEAT_DELAY, 12000);
+ attributes.put(Broker.STATISTICS_REPORTING_PERIOD, 14000);
+ attributes.put(Broker.STATISTICS_REPORTING_RESET_ENABLED, false);
+ ConfigurationEntry updatedBrokerEntry = new
ConfigurationEntry(_brokerId, Broker.class.getName(), attributes,
+ brokerConfigEntry.getChildrenIds(), _store);
+
+ _store.save(updatedBrokerEntry);
+
+ ConfigurationEntry newBrokerConfigEntry = _store.getRootEntry();
+ assertNotNull("Root entry does not exist", newBrokerConfigEntry);
+ assertEquals("Unexpected id", _brokerId, newBrokerConfigEntry.getId());
+ assertEquals("Unexpected type ", Broker.class.getName(),
newBrokerConfigEntry.getType());
+ Map<String, Object> newBrokerattributes =
newBrokerConfigEntry.getAttributes();
+ assertNotNull("Attributes cannot be null", newBrokerattributes);
+ assertEquals("Unexpected attributes", attributes, newBrokerattributes);
+ }
+
+ public void testSaveNewVirtualHost()
+ {
+ Map<String, Object> virtualHostAttributes = new HashMap<String,
Object>();
+ virtualHostAttributes.put(VirtualHost.NAME, "test1");
+ virtualHostAttributes.put(VirtualHost.CONFIGURATION,
"/path/to/phantom/virtualhost/config1");
+ UUID virtualHostId = UUID.randomUUID();
+ ConfigurationEntry hostEntry = new ConfigurationEntry(virtualHostId,
VirtualHost.class.getName(), virtualHostAttributes,
+ Collections.<UUID> emptySet(), _store);
+
+ _store.save(hostEntry);
+
+ ConfigurationEntry configurationEntry = _store.getEntry(virtualHostId);
+ assertEquals("Unexpected virtual host configuration", hostEntry,
configurationEntry);
+ assertEquals("Unexpected type", VirtualHost.class.getName(),
configurationEntry.getType());
+ assertEquals("Unexpected virtual host attributes",
hostEntry.getAttributes(), configurationEntry.getAttributes());
+ assertTrue("Unexpected virtual host children found",
hostEntry.getChildrenIds().isEmpty());
+ }
+
+ public void testSaveExistingVirtualHost()
+ {
+ ConfigurationEntry hostEntry = _store.getEntry(_virtualHostId);
+ assertNotNull("Host configuration is not found", hostEntry);
+
+ Map<String, Object> virtualHostAttributes = new HashMap<String,
Object>();
+ virtualHostAttributes.put(VirtualHost.NAME, "test");
+ virtualHostAttributes.put(VirtualHost.CONFIGURATION,
"/path/to/new/phantom/test/configuration");
+
+ ConfigurationEntry updatedEntry = new
ConfigurationEntry(_virtualHostId, VirtualHost.class.getName(),
virtualHostAttributes,
+ hostEntry.getChildrenIds(), _store);
+ _store.save(updatedEntry);
+
+ ConfigurationEntry newHostEntry = _store.getEntry(_virtualHostId);
+ assertEquals("Unexpected virtual host configuration", updatedEntry,
newHostEntry);
+ assertEquals("Unexpected type", VirtualHost.class.getName(),
newHostEntry.getType());
+ assertEquals("Unexpected virtual host attributes",
updatedEntry.getAttributes(), newHostEntry.getAttributes());
+ assertEquals("Unexpected virtual host children found",
updatedEntry.getChildrenIds(), newHostEntry.getChildrenIds());
+ }
+
+ public void testSaveNewAuthenticationProvider()
+ {
+ UUID authenticationProviderId = UUID.randomUUID();
+ Map<String, Object> authenticationProviderAttributes = new
HashMap<String, Object>();
+ authenticationProviderAttributes.put(AuthenticationProvider.NAME,
"authenticationProvider1");
+
authenticationProviderAttributes.put(AuthenticationManagerFactory.ATTRIBUTE_TYPE,
ExternalAuthenticationManager.class.getSimpleName());
+ ConfigurationEntry providerEntry = new
ConfigurationEntry(authenticationProviderId,
AuthenticationProvider.class.getName(),
+ authenticationProviderAttributes, Collections.<UUID>
emptySet(), _store);
+
+ _store.save(providerEntry);
+
+ ConfigurationEntry storeEntry =
_store.getEntry(authenticationProviderId);
+ assertEquals("Unexpected provider configuration", providerEntry,
storeEntry);
+ assertEquals("Unexpected type",
AuthenticationProvider.class.getName(), storeEntry.getType());
+ assertEquals("Unexpected provider attributes",
providerEntry.getAttributes(), storeEntry.getAttributes());
+ assertTrue("Unexpected provider children found",
storeEntry.getChildrenIds().isEmpty());
+ }
+
+ public void testSaveExistingAuthenticationProvider()
+ {
+ ConfigurationEntry providerEntry =
_store.getEntry(_authenticationProviderId);
+ assertNotNull("provider configuration is not found", providerEntry);
+
+ Map<String, Object> authenticationProviderAttributes = new
HashMap<String, Object>();
+ authenticationProviderAttributes.put(AuthenticationProvider.NAME,
"authenticationProvider1");
+
authenticationProviderAttributes.put(AuthenticationManagerFactory.ATTRIBUTE_TYPE,
ExternalAuthenticationManager.class.getSimpleName());
+ ConfigurationEntry updatedEntry = new
ConfigurationEntry(_authenticationProviderId,
AuthenticationProvider.class.getName(),
+ authenticationProviderAttributes, Collections.<UUID>
emptySet(), _store);
+ _store.save(updatedEntry);
+
+ ConfigurationEntry storeEntry =
_store.getEntry(_authenticationProviderId);
+ assertEquals("Unexpected provider configuration", updatedEntry,
storeEntry);
+ assertEquals("Unexpected type",
AuthenticationProvider.class.getName(), storeEntry.getType());
+ assertEquals("Unexpected provider attributes",
updatedEntry.getAttributes(), storeEntry.getAttributes());
+ assertTrue("Unexpected provider children found",
storeEntry.getChildrenIds().isEmpty());
+ }
+
+ public void testSaveTrustStore()
+ {
+ UUID trustStoreId = UUID.randomUUID();
+ Map<String, Object> attributes = new HashMap<String, Object>();
+ attributes.put(TrustStore.NAME, getName());
+ attributes.put(TrustStore.PATH, "/path/to/truststore");
+ attributes.put(TrustStore.PASSWORD, "my-secret-password");
+ attributes.put(TrustStore.TYPE, "NON-JKS");
+ attributes.put(TrustStore.KEY_MANAGER_FACTORY_ALGORITHM,
"NON-STANDARD");
+ attributes.put(TrustStore.DESCRIPTION, "Description");
+
+ ConfigurationEntry trustStoreEntry = new
ConfigurationEntry(trustStoreId, TrustStore.class.getName(), attributes,
+ Collections.<UUID> emptySet(), _store);
+
+ _store.save(trustStoreEntry);
+
+ ConfigurationEntry storeEntry = _store.getEntry(trustStoreId);
+ assertEquals("Unexpected trust store configuration", trustStoreEntry,
storeEntry);
+ assertEquals("Unexpected type", TrustStore.class.getName(),
storeEntry.getType());
+ assertEquals("Unexpected provider attributes",
trustStoreEntry.getAttributes(), storeEntry.getAttributes());
+ assertTrue("Unexpected provider children found",
storeEntry.getChildrenIds().isEmpty());
+ }
+
+ public void testSaveKeyStore()
+ {
+ UUID keyStoreId = UUID.randomUUID();
+ Map<String, Object> attributes = new HashMap<String, Object>();
+ attributes.put(KeyStore.NAME, getName());
+ attributes.put(KeyStore.PATH, "/path/to/truststore");
+ attributes.put(KeyStore.PASSWORD, "my-secret-password");
+ attributes.put(KeyStore.TYPE, "NON-JKS");
+ attributes.put(KeyStore.KEY_MANAGER_FACTORY_ALGORITHM, "NON-STANDARD");
+ attributes.put(KeyStore.DESCRIPTION, "Description");
+ attributes.put(KeyStore.CERTIFICATE_ALIAS, "Alias");
+
+ ConfigurationEntry keyStoreEntry = new ConfigurationEntry(keyStoreId,
KeyStore.class.getName(), attributes, Collections.<UUID> emptySet(),
+ _store);
+
+ _store.save(keyStoreEntry);
+
+ ConfigurationEntry storeEntry = _store.getEntry(keyStoreId);
+ assertEquals("Unexpected key store configuration", keyStoreEntry,
storeEntry);
+ assertEquals("Unexpected type", KeyStore.class.getName(),
storeEntry.getType());
+ assertEquals("Unexpected provider attributes",
keyStoreEntry.getAttributes(), storeEntry.getAttributes());
+ assertTrue("Unexpected provider children found",
storeEntry.getChildrenIds().isEmpty());
+ }
+
+ public void testSaveGroupProvider()
+ {
+ UUID groupProviderId = UUID.randomUUID();
+ Map<String, Object> attributes = new HashMap<String, Object>();
+ attributes.put(GroupProvider.NAME, getName());
+
+ ConfigurationEntry groupProviderEntry = new
ConfigurationEntry(groupProviderId, GroupProvider.class.getName(), attributes,
+ Collections.<UUID> emptySet(), _store);
+
+ _store.save(groupProviderEntry);
+
+ ConfigurationEntry storeEntry = _store.getEntry(groupProviderId);
+ assertEquals("Unexpected group provider configuration",
groupProviderEntry, storeEntry);
+ assertEquals("Unexpected type", GroupProvider.class.getName(),
storeEntry.getType());
+ assertEquals("Unexpected group provider attributes",
groupProviderEntry.getAttributes(), storeEntry.getAttributes());
+ assertTrue("Unexpected provider children found",
storeEntry.getChildrenIds().isEmpty());
+ }
+
+ public void testSavePort()
+ {
+ UUID portId = UUID.randomUUID();
+ Map<String, Object> attributes = new HashMap<String, Object>();
+ Set<String> tcpTransportSet =
Collections.singleton(Transport.TCP.name());
+ attributes.put(Port.PORT, 9999);
+ attributes.put(Port.TRANSPORTS, tcpTransportSet);
+ attributes.put(Port.TCP_NO_DELAY, true);
+ attributes.put(Port.RECEIVE_BUFFER_SIZE, 1);
+ attributes.put(Port.SEND_BUFFER_SIZE, 2);
+ attributes.put(Port.NEED_CLIENT_AUTH, true);
+ attributes.put(Port.WANT_CLIENT_AUTH, true);
+
+ ConfigurationEntry portEntry = new ConfigurationEntry(portId,
Port.class.getName(), attributes, Collections.<UUID> emptySet(), _store);
+
+ _store.save(portEntry);
+
+ ConfigurationEntry storeEntry = _store.getEntry(portId);
+ assertEquals("Unexpected port configuration", portEntry, storeEntry);
+ assertEquals("Unexpected type", Port.class.getName(),
storeEntry.getType());
+ assertEquals("Unexpected port attributes", portEntry.getAttributes(),
storeEntry.getAttributes());
+ assertTrue("Unexpected port children found",
storeEntry.getChildrenIds().isEmpty());
+ }
+
+ public void testMultipleSave()
+ {
+ UUID virtualHostId = UUID.randomUUID();
+ Map<String, Object> virtualHostAttributes = new HashMap<String,
Object>();
+ virtualHostAttributes.put(VirtualHost.NAME, "test1");
+ virtualHostAttributes.put(VirtualHost.CONFIGURATION,
"/path/to/phantom/virtualhost/config1");
+ ConfigurationEntry hostEntry = new ConfigurationEntry(virtualHostId,
VirtualHost.class.getName(), virtualHostAttributes,
+ Collections.<UUID> emptySet(), _store);
+
+ UUID keyStoreId = UUID.randomUUID();
+ Map<String, Object> attributes = new HashMap<String, Object>();
+ attributes.put(KeyStore.NAME, getName());
+ attributes.put(KeyStore.PATH, "/path/to/truststore");
+ attributes.put(KeyStore.PASSWORD, "my-secret-password");
+ attributes.put(KeyStore.TYPE, "NON-JKS");
+ attributes.put(KeyStore.KEY_MANAGER_FACTORY_ALGORITHM, "NON-STANDARD");
+ attributes.put(KeyStore.DESCRIPTION, "Description");
+ attributes.put(KeyStore.CERTIFICATE_ALIAS, "Alias");
+
+ ConfigurationEntry keyStoreEntry = new ConfigurationEntry(keyStoreId,
KeyStore.class.getName(), attributes, Collections.<UUID> emptySet(),
+ _store);
+
+ _store.save(hostEntry, keyStoreEntry);
+
+ assertNotNull("Virtual host is not found",
_store.getEntry(virtualHostId));
+ assertNotNull("Key store is not found", _store.getEntry(keyStoreId));
+ }
+}
Added:
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStoreTest.java
URL:
http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStoreTest.java?rev=1425070&view=auto
==============================================================================
---
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStoreTest.java
(added)
+++
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStoreTest.java
Fri Dec 21 18:23:16 2012
@@ -0,0 +1,57 @@
+package org.apache.qpid.server.configuration.store;
+
+import java.io.File;
+import java.io.StringWriter;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import org.apache.qpid.server.configuration.ConfigurationEntry;
+import org.apache.qpid.server.configuration.ConfigurationEntryStore;
+import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.test.utils.TestFileUtils;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+
+public class JsonConfigurationEntryStoreTest extends
ConfigurationEntryStoreTestCase
+{
+ private File _storeFile;
+ private ObjectMapper _objectMapper;
+
+ public void tearDown() throws Exception
+ {
+ _storeFile.delete();
+ super.tearDown();
+ }
+
+ @Override
+ protected ConfigurationEntryStore createStore(UUID brokerId, Map<String,
Object> brokerAttributes) throws Exception
+ {
+ _objectMapper = new ObjectMapper();
+ _objectMapper.configure(SerializationConfig.Feature.INDENT_OUTPUT,
true);
+
+ Map<String, Object> brokerObjectMap = new HashMap<String, Object>();
+ brokerObjectMap.put(Broker.ID, brokerId);
+ brokerObjectMap.put("type", Broker.class.getName());
+ brokerObjectMap.put(JsonConfigurationEntryStore.ATTRIBUTES,
brokerAttributes);
+
+ StringWriter sw = new StringWriter();
+ _objectMapper.writeValue(sw, brokerObjectMap);
+
+ String brokerJson = sw.toString();
+
+ _storeFile = TestFileUtils.createTempFile(this, ".json", brokerJson);
+
+ JsonConfigurationEntryStore store = new
JsonConfigurationEntryStore(_storeFile.getAbsolutePath());
+ return store;
+ }
+
+ @Override
+ protected void addConfiguration(UUID id, String type, Map<String, Object>
attributes)
+ {
+ ConfigurationEntryStore store = getStore();
+ store.save(new ConfigurationEntry(id, type, attributes,
Collections.<UUID>emptySet(), store));
+ }
+
+}
Modified:
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/model/BrokerShutdownTest.java
URL:
http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/model/BrokerShutdownTest.java?rev=1425070&r1=1425069&r2=1425070&view=diff
==============================================================================
---
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/model/BrokerShutdownTest.java
(original)
+++
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/model/BrokerShutdownTest.java
Fri Dec 21 18:23:16 2012
@@ -103,8 +103,9 @@ public class BrokerShutdownTest extends
}
@Override
- public void remove(UUID... entryIds)
+ public UUID[] remove(UUID... entryIds)
{
+ return null;
}
};
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]