[jboss-cvs] JBossAS SVN: r86792 - in branches/Branch_5_x: testsuite/src/main/org/jboss/test/profileservice/test and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sat Apr 4 14:52:25 EDT 2009
Author: emuckenhuber
Date: 2009-04-04 14:52:25 -0400 (Sat, 04 Apr 2009)
New Revision: 86792
Modified:
branches/Branch_5_x/messaging/src/main/org/jboss/jms/server/destination/SecurityConfigMapper.java
branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/JmsDestinationUnitTestCase.java
Log:
[JBAS-6716] test securityConfig, make Mapper result comparable
Modified: branches/Branch_5_x/messaging/src/main/org/jboss/jms/server/destination/SecurityConfigMapper.java
===================================================================
--- branches/Branch_5_x/messaging/src/main/org/jboss/jms/server/destination/SecurityConfigMapper.java 2009-04-04 18:51:34 UTC (rev 86791)
+++ branches/Branch_5_x/messaging/src/main/org/jboss/jms/server/destination/SecurityConfigMapper.java 2009-04-04 18:52:25 UTC (rev 86792)
@@ -86,7 +86,7 @@
if(object == null)
return null;
- Map<String, CompositeValue> entries = new HashMap<String, CompositeValue>();
+ Map<String, MetaValue> entries = new HashMap<String, MetaValue>();
// Parse
NodeList list = object.getElementsByTagName("role");
int l = list.getLength();
@@ -103,7 +103,7 @@
// Put
entries.put(name, new CompositeValueSupport(composite, values));
}
- return new MapCompositeValueSupport(metaType);
+ return new MapCompositeValueSupport(entries, metaType);
}
@Override
@@ -163,20 +163,19 @@
Map<String, MetaValue> map = new HashMap<String, MetaValue>();
for(String attribute : attributeNames)
{
- SimpleValue v = parseAttribute(attribute, element);
- if(v != null) map.put(attribute, v);
+ map.put(attribute, parseAttribute(attribute, element));
}
return map;
}
protected static SimpleValue parseAttribute(String attributeName, Element element)
{
+ Boolean value = null;
if(element.getAttributeNode(attributeName) != null)
{
- Boolean value = Boolean.valueOf(element.getAttribute(attributeName));
- return new SimpleValueSupport(SimpleMetaType.BOOLEAN, value);
+ value = Boolean.valueOf(element.getAttribute(attributeName));
}
- return null;
+ return new SimpleValueSupport(SimpleMetaType.BOOLEAN, value);
}
}
Modified: branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/JmsDestinationUnitTestCase.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/JmsDestinationUnitTestCase.java 2009-04-04 18:51:34 UTC (rev 86791)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/JmsDestinationUnitTestCase.java 2009-04-04 18:52:25 UTC (rev 86792)
@@ -35,10 +35,15 @@
import org.jboss.managed.api.DeploymentTemplateInfo;
import org.jboss.managed.api.ManagedComponent;
import org.jboss.managed.api.ManagedProperty;
+import org.jboss.metatype.api.types.MapCompositeMetaType;
import org.jboss.metatype.api.types.MetaType;
import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.CompositeValue;
+import org.jboss.metatype.api.values.CompositeValueSupport;
+import org.jboss.metatype.api.values.MapCompositeValueSupport;
import org.jboss.metatype.api.values.MetaValue;
import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.plugins.types.MutableCompositeMetaType;
/**
* @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
@@ -47,6 +52,24 @@
*/
public class JmsDestinationUnitTestCase extends AbstractProfileServiceTest
{
+
+ /** The meta type. */
+ protected static final MapCompositeMetaType securityConfType;
+
+ /** The composite meta type. */
+ public static MutableCompositeMetaType composite;
+
+ static
+ {
+ // Create the meta type
+ composite = new MutableCompositeMetaType("SecurityConfig", "The security config");
+ composite.addItem("read", "read permission", SimpleMetaType.BOOLEAN);
+ composite.addItem("write", "write permission", SimpleMetaType.BOOLEAN);
+ composite.addItem("create", "create permission", SimpleMetaType.BOOLEAN);
+ composite.freeze();
+ securityConfType = new MapCompositeMetaType(composite);
+ }
+
public JmsDestinationUnitTestCase(String s)
{
super(s);
@@ -61,6 +84,8 @@
suite.addTest(new JmsDestinationUnitTestCase("testDLQ"));
suite.addTest(new JmsDestinationUnitTestCase("testCreateQueue"));
suite.addTest(new JmsDestinationUnitTestCase("testRemoveQueue"));
+ suite.addTest(new JmsDestinationUnitTestCase("testCreateSecureQueue"));
+ suite.addTest(new JmsDestinationUnitTestCase("testRemoveSecureQueue"));
suite.addTest(new JmsDestinationUnitTestCase("testCreateTopic"));
suite.addTest(new JmsDestinationUnitTestCase("testRemoveTopic"));
@@ -238,4 +263,48 @@
ManagedComponent topic = getManagementView().getComponent("testCreateTopic", type);
assertNull("topic should be removed " + topic, topic);
}
+
+ public void testCreateSecureQueue() throws Exception
+ {
+ Map<String, MetaValue> propValues = new HashMap<String, MetaValue>();
+ String jndiName = getName();
+ propValues.put("name", SimpleValueSupport.wrap(jndiName));
+ propValues.put("JNDIName", SimpleValueSupport.wrap(jndiName));
+ // Security config
+ Map<String, MetaValue> values = new HashMap<String, MetaValue>();
+ values.put("admin", createCompositeValue(true, true, true));
+ values.put("publisher", createCompositeValue(true, true, false));
+ values.put("user", createCompositeValue(true, null, null));
+ CompositeValue map = new MapCompositeValueSupport(values, securityConfType);
+ propValues.put("securityConfig", map);
+
+ ComponentType type = KnownComponentTypes.JMSDestination.Queue.getType();
+ createComponentTest("QueueTemplate", propValues, getName(), type, jndiName);
+ ManagedComponent queue = activeView.getComponent("testCreateSecureQueue", type);
+ assertNotNull(queue);
+ assertEquals("testCreateSecureQueue", queue.getName());
+ log.info(queue.getProperties().keySet());
+ assertNotNull(queue.getProperty("securityConfig").getValue());
+
+ }
+
+ public void testRemoveSecureQueue() throws Exception
+ {
+ removeDeployment("testCreateSecureQueue-service.xml");
+ ComponentType type = KnownComponentTypes.JMSDestination.Queue.getType();
+ ManagedComponent queue = getManagementView().getComponent("testCreateSecureQueue", type);
+ assertNull("queue should be removed" + queue, queue);
+ }
+
+
+ protected CompositeValue createCompositeValue(Boolean read, Boolean write, Boolean create)
+ {
+ Map<String, MetaValue> map = new HashMap<String, MetaValue>();
+
+ map.put("read", new SimpleValueSupport(SimpleMetaType.BOOLEAN, read));
+ map.put("write", new SimpleValueSupport(SimpleMetaType.BOOLEAN, write));
+ map.put("create", new SimpleValueSupport(SimpleMetaType.BOOLEAN, create));
+
+ return new CompositeValueSupport(composite, map);
+ }
}
More information about the jboss-cvs-commits
mailing list