[jboss-cvs] JBossAS SVN: r69618 - in trunk: messaging/src/etc/deploy/common and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Feb 5 09:17:20 EST 2008
Author: alex.loubyansky at jboss.com
Date: 2008-02-05 09:17:20 -0500 (Tue, 05 Feb 2008)
New Revision: 69618
Added:
trunk/messaging/src/etc/deploy/common/messaging-beans.xml
trunk/profileservice/src/main/org/jboss/profileservice/management/templates/JmsDestinationTemplate.java
trunk/profileservice/src/main/org/jboss/profileservice/management/templates/JmsDestinationTemplateInfo.java
trunk/testsuite/src/main/org/jboss/test/profileservice/test/AbstractProfileServiceTest.java
trunk/testsuite/src/main/org/jboss/test/profileservice/test/JmsDestinationUnitTestCase.java
Modified:
trunk/build/build-distr.xml
trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java
Log:
JBAS-4396 not complete yet (there is still the issue with MO name incosistency between the template MO and the deployed one mentioned in the forums)
Modified: trunk/build/build-distr.xml
===================================================================
--- trunk/build/build-distr.xml 2008-02-05 13:25:38 UTC (rev 69617)
+++ trunk/build/build-distr.xml 2008-02-05 14:17:20 UTC (rev 69618)
@@ -771,6 +771,7 @@
<copy todir="${install.all.deploy}/messaging">
<fileset dir="${_module.output}/etc/deploy/common">
<include name="*-service.xml"/>
+ <include name="*-beans.xml"/>
</fileset>
<fileset dir="${_module.output}/etc/deploy/clustered">
<include name="*-service.xml"/>
@@ -787,6 +788,7 @@
<copy todir="${install.all.deploy}/messaging">
<fileset dir="${_module.output}/etc/deploy/common">
<include name="*-service.xml"/>
+ <include name="*-beans.xml"/>
</fileset>
<fileset dir="${_module.output}/etc/deploy/clustered">
<include name="*-service.xml"/>
@@ -801,6 +803,7 @@
<copy todir="${install.default.deploy}/messaging">
<fileset dir="${_module.output}/etc/deploy/common">
<include name="*-service.xml"/>
+ <include name="*-beans.xml"/>
</fileset>
<fileset dir="${_module.output}/etc/deploy/non-clustered">
<include name="*-service.xml"/>
Added: trunk/messaging/src/etc/deploy/common/messaging-beans.xml
===================================================================
--- trunk/messaging/src/etc/deploy/common/messaging-beans.xml (rev 0)
+++ trunk/messaging/src/etc/deploy/common/messaging-beans.xml 2008-02-05 14:17:20 UTC (rev 69618)
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Messaging beans
+ $Id: messaging-beans.xml 68282 2007-12-14 13:43:52Z alex.loubyansky at jboss.com $
+-->
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="QueueTemplate" class="org.jboss.profileservice.management.templates.JmsDestinationTemplate">
+ <property name="info"><inject bean="QueueTemplateInfo"/></property>
+ </bean>
+ <bean name="QueueTemplateInfo"
+ class="org.jboss.profileservice.management.templates.JmsDestinationTemplateInfo">
+ <constructor>
+ <parameter>QueueTemplate</parameter>
+ <parameter>A template for JMS queue *-service.xml deployments</parameter>
+ <parameter>queue</parameter>
+ </constructor>
+ </bean>
+
+ <bean name="TopicTemplate" class="org.jboss.profileservice.management.templates.JmsDestinationTemplate">
+ <property name="info"><inject bean="TopicTemplateInfo"/></property>
+ </bean>
+ <bean name="TopicTemplateInfo"
+ class="org.jboss.profileservice.management.templates.JmsDestinationTemplateInfo">
+ <constructor>
+ <parameter>TopicTemplate</parameter>
+ <parameter>A template for JMS topic *-service.xml deployments</parameter>
+ <parameter>topic</parameter>
+ </constructor>
+ </bean>
+
+</deployment>
Added: trunk/profileservice/src/main/org/jboss/profileservice/management/templates/JmsDestinationTemplate.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/templates/JmsDestinationTemplate.java (rev 0)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/templates/JmsDestinationTemplate.java 2008-02-05 14:17:20 UTC (rev 69618)
@@ -0,0 +1,228 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.profileservice.management.templates;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlValue;
+import org.jboss.deployers.spi.management.DeploymentTemplate;
+import org.jboss.deployers.spi.management.DeploymentTemplateInfo;
+import org.jboss.deployers.vfs.spi.client.VFSDeployment;
+import org.jboss.logging.Logger;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: $</tt>
+ */
+public class JmsDestinationTemplate
+ implements DeploymentTemplate
+{
+ private static final Logger log = Logger.getLogger(JmsDestinationTemplate.class);
+
+ private DeploymentTemplateInfo info;
+
+ public DeploymentTemplateInfo getInfo()
+ {
+ return info;
+ }
+
+ public void setInfo(DeploymentTemplateInfo info)
+ {
+ this.info = info;
+ }
+
+ public VirtualFile applyTemplate(VirtualFile root, String deploymentBaseName, DeploymentTemplateInfo values)
+ throws Exception
+ {
+ String dsName = deploymentBaseName + "-service.xml";
+ URI dsXmlURI = new URI(root.toURI() + dsName);
+ File dsXml = new File(dsXmlURI.getPath());
+ writeTemplate(dsXml, values);
+ return root.findChild(dsName);
+ }
+
+ public void updateTemplateDeployment(VFSDeployment ctx, DeploymentTemplateInfo values) throws Exception
+ {
+ }
+
+ private void writeTemplate(File dsXml, DeploymentTemplateInfo info)
+ throws Exception
+ {
+ JmsDestinationTemplateInfo destinationInfo = (JmsDestinationTemplateInfo)info;
+ String destinationType = destinationInfo.getDestinationType();
+
+ JmsDestinationMetaData destination = new JmsDestinationMetaData();
+
+ if("queue".equals(destinationType))
+ {
+ destination.className = "org.jboss.jms.server.destination.QueueService";
+ destination.annotation =
+ "@org.jboss.system.deployers.managed.ManagementObjectClass(code=org.jboss.jms.server.destination.QueueServiceMO)";
+ destination.xmbeanDd = "xmdesc/Queue-xmbean.xml";
+ destination.jmxName = "jboss.messaging.destination:service=Queue,name=" + getProperty(info, "Name");
+ }
+ else if("topic".equals(destinationType))
+ {
+ destination.className = "org.jboss.jms.server.destination.TopicService";
+ destination.annotation =
+ "@org.jboss.system.deployers.managed.ManagementObjectClass(code=org.jboss.jms.server.destination.TopicServiceMO)";
+ destination.xmbeanDd = "xmdesc/Topic-xmbean.xml";
+ destination.jmxName = "jboss.messaging.destination:service=Topic,name=" + getProperty(info, "Name");
+ }
+ else
+ {
+ throw new IllegalStateException("Unsupported destination type: " + destinationType);
+ }
+
+/*
+ ServiceMetaData destination = new ServiceMetaData();
+ destination.setCode("org.jboss.jms.server.destination.QueueService");
+
+ java.util.Properties keyValues = new java.util.Properties();
+ keyValues.put("service", "Queue");
+ keyValues.put("name", destinationInfo.getName());
+ ObjectName name = new ObjectName("jboss.messaging.destination", keyValues);
+ destination.setObjectName(name);
+
+ ServiceDependencyMetaData depends = new ServiceDependencyMetaData();
+ depends.setIDependOn("jboss.messaging:service=PostOffice");
+ List<ServiceDependencyMetaData> dependsList = new ArrayList<ServiceDependencyMetaData>();
+ dependsList.add(depends);
+ destination.setDependencies(dependsList);
+
+ ServiceDeployment deployment = new ServiceDeployment();
+ List<ServiceMetaData> services = new ArrayList<ServiceMetaData>();
+ services.add(destination);
+ deployment.setServices(services);
+*/
+
+ List<JmsDependencyMetaData> depends = new ArrayList<JmsDependencyMetaData>();
+ destination.depends = depends;
+ depends.add(new JmsDependencyMetaData("ServerPeer", "jboss.messaging:service=ServerPeer"));
+ depends.add(new JmsDependencyMetaData("jboss.messaging:service=PostOffice"));
+
+ JmsDestinationDeployment deployment = new JmsDestinationDeployment();
+ deployment.destination = destination;
+
+ Class[] classes = {JmsDestinationDeployment.class};
+ JAXBContext context = JAXBContext.newInstance(classes);
+ Marshaller marshaller = context.createMarshaller();
+ marshaller.setProperty("jaxb.formatted.output", Boolean.TRUE);
+
+ JAXBElement<JmsDestinationDeployment> root =
+ new JAXBElement<JmsDestinationDeployment>(
+ new javax.xml.namespace.QName("server"),
+ JmsDestinationDeployment.class,
+ null, deployment
+ );
+
+ FileWriter fw = null;
+ try
+ {
+ fw = new FileWriter(dsXml);
+ marshaller.marshal(root, fw);
+ }
+ finally
+ {
+ if(fw != null)
+ {
+ fw.close();
+ }
+ }
+ }
+
+ private Object getProperty(DeploymentTemplateInfo info, String propName)
+ {
+ Map<String, ManagedProperty> propsInfo = info.getProperties();
+ ManagedProperty prop = propsInfo.get(propName);
+ if(prop == null)
+ {
+ throw new IllegalStateException("Property " + propName + " not found.");
+ }
+ return prop.getValue();
+ }
+
+ // the classes below should go away and ServiceDeployment and MetaData
+ // API should be used instead once their bound with JAXB
+
+ @XmlRootElement(name = "server")
+ public static class JmsDestinationDeployment
+ {
+ @XmlElement(name = "mbean")
+ public JmsDestinationMetaData destination;
+ }
+
+ public static class JmsDestinationMetaData
+ {
+ @XmlAttribute(name = "code")
+ String className;
+
+ @XmlAttribute(name = "name")
+ String jmxName;
+
+ @XmlAttribute(name = "xmbean-dd")
+ String xmbeanDd;
+
+ @XmlElement
+ String annotation;
+
+ public List<JmsDependencyMetaData> depends;
+ }
+
+ public static class JmsDependencyMetaData
+ {
+ @XmlAttribute(name = "optional-attribute-name")
+ String attribute;
+
+ @XmlValue
+ String value;
+
+ public JmsDependencyMetaData()
+ {
+ }
+
+
+ public JmsDependencyMetaData(String value)
+ {
+ this.value = value;
+ }
+
+
+ public JmsDependencyMetaData(String attribute, String value)
+ {
+ this.attribute = attribute;
+ this.value = value;
+ }
+ }
+}
Added: trunk/profileservice/src/main/org/jboss/profileservice/management/templates/JmsDestinationTemplateInfo.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/templates/JmsDestinationTemplateInfo.java (rev 0)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/templates/JmsDestinationTemplateInfo.java 2008-02-05 14:17:20 UTC (rev 69618)
@@ -0,0 +1,105 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.profileservice.management.templates;
+
+import org.jboss.profileservice.management.plugins.BasicDeploymentTemplateInfo;
+import org.jboss.managed.api.Fields;
+import org.jboss.managed.plugins.ManagedObjectImpl;
+import org.jboss.managed.plugins.DefaultFieldsImpl;
+import org.jboss.managed.plugins.ManagedPropertyImpl;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: $</tt>
+ */
+public class JmsDestinationTemplateInfo extends BasicDeploymentTemplateInfo
+{
+ private String destinationType = "queue";
+
+ public JmsDestinationTemplateInfo(String name, String description, String destinationType)
+ {
+ super(name, description);
+ this.destinationType = destinationType;
+ }
+
+
+ public String getDestinationType()
+ {
+ return destinationType;
+ }
+
+ public void start()
+ {
+ ManagedObjectImpl mo = null;
+ if("queue".equals(destinationType))
+ mo = new ManagedObjectImpl("org.jboss.jms.server.destination.QueueServiceMO");
+ else if("topic".equals(destinationType))
+ mo = new ManagedObjectImpl("org.jboss.jms.server.destination.TopicServiceMO");
+ else
+ throw new IllegalStateException("Unexpected destination type: " + destinationType);
+
+ addManagedProperty("Name", "The destination name", true, SimpleMetaType.STRING, mo);
+ addManagedProperty("JNDIName", "The destination's JNDI name", false, SimpleMetaType.STRING, mo);
+ }
+
+ private void addManagedProperty(String fieldName,
+ String fieldDescr,
+ boolean mandatory,
+ MetaType metaType,
+ ManagedObjectImpl mo)
+ {
+ addManagedProperty(fieldName, fieldDescr, mandatory, metaType, null, mo);
+ }
+
+ private void addManagedProperty(String fieldName,
+ String fieldDescr,
+ boolean mandatory,
+ MetaType metaType,
+ java.io.Serializable value,
+ ManagedObjectImpl mo)
+ {
+ DefaultFieldsImpl fields = new DefaultFieldsImpl();
+ setFieldName(fieldName, fields);
+ fields.setDescription(fieldDescr);
+ fields.setMandatory(mandatory);
+ fields.setMetaType(metaType);
+ ManagedPropertyImpl mp = new ManagedPropertyImpl(mo, fields);
+ super.addProperty(mp);
+ if(value != null)
+ mp.setValue(value);
+ }
+
+ protected void setFieldName(String name, Fields f)
+ {
+ f.setField(Fields.NAME, name);
+/*
+ if( propertyNameMappings != null )
+ {
+ String mappedName = propertyNameMappings.get(name);
+ if( mappedName != null )
+ f.setField(Fields.MAPPED_NAME, mappedName);
+ }
+*/
+ }
+}
Added: trunk/testsuite/src/main/org/jboss/test/profileservice/test/AbstractProfileServiceTest.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/test/AbstractProfileServiceTest.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/test/AbstractProfileServiceTest.java 2008-02-05 14:17:20 UTC (rev 69618)
@@ -0,0 +1,179 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.profileservice.test;
+
+import java.util.Set;
+import java.util.Map;
+import java.util.HashSet;
+import java.io.Serializable;
+import java.lang.reflect.Type;
+import javax.naming.InitialContext;
+import org.jboss.test.JBossTestCase;
+import org.jboss.deployers.spi.management.ManagementView;
+import org.jboss.deployers.spi.management.DeploymentTemplateInfo;
+import org.jboss.managed.api.ManagedDeployment;
+import org.jboss.managed.api.ManagedComponent;
+import org.jboss.managed.api.ComponentType;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.profileservice.spi.ProfileService;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.virtual.VFS;
+import org.jboss.metatype.api.values.MetaValueFactory;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValue;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: $</tt>
+ */
+public class AbstractProfileServiceTest
+ extends JBossTestCase
+{
+ protected ManagementView activeView;
+ private MetaValueFactory metaValueFactory;
+
+ public AbstractProfileServiceTest(String name)
+ {
+ super(name);
+ }
+
+ protected void removeDeployment(String deployment)
+ throws Exception
+ {
+ ManagementView mgtView = getManagementView();
+ Set<String> names = mgtView.getMatchingDeploymentName(".*" + deployment);
+ assertEquals("1 matching name", 1, names.size());
+ String deploymentName = names.iterator().next();
+ mgtView.removeDeployment(deploymentName, ManagedDeployment.DeploymentPhase.APPLICATION);
+ mgtView.process();
+ }
+
+ protected void createComponentTest(String templateName,
+ Map<String, Serializable> propValues,
+ String deploymentName,
+ ComponentType componentType, String componentName)
+ throws Exception
+ {
+ ManagementView mgtView = getManagementView();
+ DeploymentTemplateInfo info = mgtView.getTemplate(templateName);
+ assertNotNull("template " + templateName + " found", info);
+ Map<String, ManagedProperty> props = info.getProperties();
+
+ for(String propName : propValues.keySet())
+ {
+ ManagedProperty prop = props.get(propName);
+ assertNotNull("property " + propName + " found in template " + templateName, prop);
+ prop.setValue(propValues.get(propName));
+ }
+
+ mgtView.applyTemplate(ManagedDeployment.DeploymentPhase.APPLICATION, deploymentName, info);
+ mgtView.process();
+
+ // reload the view
+ activeView = null;
+ mgtView = getManagementView();
+ ManagedComponent dsMC = getManagedComponent(mgtView, componentType, componentName);
+ assertNotNull(dsMC);
+
+ Set<String> mcPropNames = new HashSet<String>(dsMC.getPropertyNames());
+ for(String propName : propValues.keySet())
+ {
+ ManagedProperty prop = dsMC.getProperty(propName);
+ assertNotNull(prop);
+ Object propValue = prop.getValue();
+ Object expectedValue = propValues.get(propName);
+ if(propValue instanceof MetaValue)
+ {
+ if(prop.getMetaType().isSimple())
+ assertEquals(prop.getName(), expectedValue, ((SimpleValue)propValue).getValue());
+ else
+ {
+ Type valueType = expectedValue.getClass();
+ propValue = getMetaValueFactory().unwrap((MetaValue)propValue, valueType);
+ expectedValue = getMetaValueFactory().unwrap((MetaValue)expectedValue, valueType);
+ assertEquals(prop.getName(), expectedValue, propValue);
+ }
+ }
+ else
+ assertEquals(prop.getName(), expectedValue, propValue);
+
+ mcPropNames.remove(propName);
+ }
+
+ if(!mcPropNames.isEmpty())
+ {
+ log.warn(getName() + "> untested properties: " + mcPropNames);
+ }
+ }
+
+ /**
+ * Obtain the ProfileService.ManagementView
+ * @return
+ * @throws Exception
+ */
+ protected ManagementView getManagementView()
+ throws Exception
+ {
+ if( activeView == null )
+ {
+ InitialContext ctx = getInitialContext();
+ ProfileService ps = (ProfileService) ctx.lookup("ProfileService");
+ activeView = ps.getViewManager();
+ ProfileKey defaultKey = new ProfileKey("default");
+ activeView.loadProfile(defaultKey);
+ // Init the VFS to setup the vfs* protocol handlers
+ VFS.init();
+ }
+ return activeView;
+ }
+
+ /**
+ * Locate the given ComponentType with the given component name.
+ *
+ * @param mgtView -
+ * @return the matching ManagedComponent if found, null otherwise
+ * @throws Exception
+ */
+ protected ManagedComponent getManagedComponent(ManagementView mgtView, ComponentType type, String name)
+ throws Exception
+ {
+ Set<ManagedComponent> comps = mgtView.getComponentsForType(type);
+ ManagedComponent mc = null;
+ for (ManagedComponent comp : comps)
+ {
+ String cname = comp.getName();
+ if( cname.endsWith(name) )
+ {
+ mc = comp;
+ break;
+ }
+ }
+ return mc;
+ }
+
+ protected MetaValueFactory getMetaValueFactory()
+ {
+ if(metaValueFactory == null)
+ metaValueFactory = MetaValueFactory.getInstance();
+ return metaValueFactory;
+ }
+}
Added: trunk/testsuite/src/main/org/jboss/test/profileservice/test/JmsDestinationUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/test/JmsDestinationUnitTestCase.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/test/JmsDestinationUnitTestCase.java 2008-02-05 14:17:20 UTC (rev 69618)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.profileservice.test;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.io.Serializable;
+import org.jboss.deployers.spi.management.KnownComponentTypes;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: $</tt>
+ */
+public class JmsDestinationUnitTestCase
+ extends AbstractProfileServiceTest
+{
+ public JmsDestinationUnitTestCase(String s)
+ {
+ super(s);
+ }
+
+ public void testCreateQueue() throws Exception
+ {
+ String jndiName = getName();
+ Map<String, Serializable> propValues = new HashMap<String, Serializable>();
+ propValues.put("Name", jndiName);
+ createComponentTest("QueueTemplate", propValues, getName(),
+ KnownComponentTypes.JMSDestination.Queue.getType(), jndiName);
+ }
+
+ public void testRemoveQueue()
+ throws Exception
+ {
+ removeDeployment("testCreateQueue-service.xml");
+ }
+
+ public void testCreateTopic() throws Exception
+ {
+ String jndiName = getName();
+ Map<String, Serializable> propValues = new HashMap<String, Serializable>();
+ propValues.put("Name", jndiName);
+ createComponentTest("TopicTemplate", propValues, getName(),
+ KnownComponentTypes.JMSDestination.Topic.getType(), jndiName);
+ }
+
+ public void testRemoveTopic()
+ throws Exception
+ {
+ removeDeployment("testCreateTopic-service.xml");
+ }
+}
Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java 2008-02-05 13:25:38 UTC (rev 69617)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java 2008-02-05 14:17:20 UTC (rev 69618)
@@ -25,9 +25,7 @@
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-import java.util.ArrayList;
import java.util.HashMap;
-import java.util.List;
import java.io.Serializable;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
@@ -43,8 +41,8 @@
import org.jboss.managed.api.ManagedComponent;
import org.jboss.managed.api.ManagedDeployment;
import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
-import org.jboss.managed.api.annotation.ManagementProperty;
import org.jboss.managed.api.annotation.ViewUse;
+import org.jboss.managed.api.annotation.ManagementProperty;
import org.jboss.managed.api.ManagedObject;
import org.jboss.managed.api.ManagedOperation;
import org.jboss.managed.api.ManagedProperty;
@@ -56,22 +54,16 @@
import org.jboss.profileservice.spi.NoSuchProfileException;
import org.jboss.profileservice.spi.ProfileKey;
import org.jboss.profileservice.spi.ProfileService;
-import org.jboss.test.JBossTestCase;
-import org.jboss.virtual.VFS;
-import org.jboss.resource.metadata.mcf.XAConnectionPropertyMetaData;
-import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryPropertyMetaData;
/** Test of using ProfileService
@author Scott.Stark at jboss.org
@version $Revision: 58115 $
*/
-public class ProfileServiceUnitTestCase extends JBossTestCase
+public class ProfileServiceUnitTestCase extends AbstractProfileServiceTest
{
- ManagementView activeView;
private Type mapType;
private Type mapOfMapsType;
- private MetaValueFactory metaValueFactory;
/**
* We need to define the order in which tests runs
@@ -122,7 +114,6 @@
InitialContext ctx = super.getInitialContext();
ProfileService ps = (ProfileService) ctx.lookup("ProfileService");
Collection<ProfileKey> keys = ps.getProfileKeys();
- log.info("getProfileKeys: "+keys);
ProfileKey defaultKey = new ProfileKey("default");
assertTrue("keys contains default", keys.contains(defaultKey));
}
@@ -132,7 +123,6 @@
{
ManagementView mgtView = getManagementView();
Set<String> names = mgtView.getDeploymentNames();
- log.info("getDeploymentNames, "+names);
// Build a set of the simple deployment names
HashSet<String> simpleNames = new HashSet<String>();
for (String name : names)
@@ -145,7 +135,6 @@
String sname = name.substring(index+1);
simpleNames.add(sname);
}
- log.info("Deployment simple names: "+simpleNames);
// Validate some well known deployments
String[] expectedNames = {
"jboss-service.xml",
@@ -180,7 +169,6 @@
{
ManagementView mgtView = getManagementView();
Set<String> names = mgtView.getTemplateNames();
- log.info("getTemplateNames, "+names);
assertTrue("LocalTxDataSourceTemplate exists", names.contains("LocalTxDataSourceTemplate"));
}
@@ -214,7 +202,6 @@
{
ManagementView mgtView = getManagementView();
Set<String> names = mgtView.getDeploymentNamesForType("jca-ds");
- log.info("jca-ds names: "+names);
assertTrue("names.size > 0 ", names.size() > 0);
boolean sawHsqldbDS = false;
for (String name : names)
@@ -267,7 +254,6 @@
ManagedComponent ds = getManagedComponent(mgtView, type, "DefaultDS");
assertNotNull("hsqldb-ds.xml ManagedComponent", ds);
Map<String,ManagedProperty> props = ds.getProperties();
- log.info("hsqldb-ds.props: "+props);
// Validate the property names
ManagedProperty p = props.get("jndi-name");
assertEquals("jndi-name", SimpleValueSupport.wrap("DefaultDS"), p.getValue());
@@ -299,7 +285,6 @@
ManagedObject secDomain = (ManagedObject) sdGV.getValue();
// TODO, this should be non-null:
// assertNotNull("security-domain.MO", secDomain);
- log.info("security-domain.MO: "+secDomain);
}
/**
@@ -312,13 +297,12 @@
ManagementView mgtView = getManagementView();
ComponentType queueType = new ComponentType("JMSDestination", "Queue");
Set<ManagedComponent> queues = mgtView.getComponentsForType(queueType);
- log.info("queues: "+queues);
assertNotNull("Null JMS queues", queues);
assertTrue("queues.size", queues.size() > 0);
+
ComponentType topicType = new ComponentType("JMSDestination", "Topic");
Set<ManagedComponent> topics = mgtView.getComponentsForType(topicType);
- log.info("topics: "+topics);
assertNotNull(topics);
assertTrue("topics.size", topics.size() > 0);
}
@@ -337,7 +321,6 @@
ComponentType type = new ComponentType("DataSource", "LocalTx");
ManagedComponent hsqldb = getManagedComponent(mgtView, type, "DefaultDS");
Map<String,ManagedProperty> props = hsqldb.getProperties();
- log.info("hsqldb.props: "+props);
// Update properties
ManagedProperty minSize = props.get("min-pool-size");
minSize.setValue(new Integer(13));
@@ -373,7 +356,6 @@
if(use == ViewUse.STATISTIC)
{
sawStats = true;
- log.info("STATISTIC: "+prop);
}
}
}
@@ -387,12 +369,10 @@
public void testDefaultDSOps()
throws Exception
{
- log.info("+++ testDefaultDSOps");
ManagementView mgtView = getManagementView();
ComponentType type = new ComponentType("DataSource", "LocalTx");
ManagedComponent hsqldb = getManagedComponent(mgtView, type, "DefaultDS");
Set<ManagedOperation> ops = hsqldb.getOperations();
- log.info("DefaultDS ops: "+ops);
assertNotNull("Set<ManagedOperation>", ops);
assertTrue("Set<ManagedOperation> > 0", ops.size() > 0);
ManagedOperation listFormattedSubPoolStatistics = null;
@@ -408,7 +388,6 @@
MetaValue[] params = {};
Object result = listFormattedSubPoolStatistics.invoke(params);
assertNotNull("Expecting non null result", result);
- log.info("listFormattedSubPoolStatistics.invoke: "+result);
}
/**
@@ -690,10 +669,10 @@
// todo: local-transaction
}
- private void createComponentTest(String templateName,
- Map<String, Serializable> propValues,
- String deploymentName,
- ComponentType componentType, String componentName)
+ protected void createComponentTest(String templateName,
+ Map<String, Serializable> propValues,
+ String deploymentName,
+ ComponentType componentType, String componentName)
throws Exception
{
ManagementView mgtView = getManagementView();
@@ -753,70 +732,6 @@
}
}
- protected void removeDeployment(String deployment)
- throws Exception
- {
- ManagementView mgtView = getManagementView();
- Set<String> names = mgtView.getMatchingDeploymentName(".*" + deployment);
- assertEquals("1 matching name", 1, names.size());
- String deploymentName = names.iterator().next();
- mgtView.removeDeployment(deploymentName, DeploymentPhase.APPLICATION);
- mgtView.process();
- }
-
- /**
- * Obtain the ProfileService.ManagementView
- * @return
- * @throws Exception
- */
- protected ManagementView getManagementView()
- throws Exception
- {
- if( activeView == null )
- {
- InitialContext ctx = getInitialContext();
- ProfileService ps = (ProfileService) ctx.lookup("ProfileService");
- activeView = ps.getViewManager();
- ProfileKey defaultKey = new ProfileKey("default");
- activeView.loadProfile(defaultKey);
- log.info("Loaded profile: "+defaultKey);
- // Init the VFS to setup the vfs* protocol handlers
- VFS.init();
- }
- return activeView;
- }
-
- /**
- * Locate the given ComponentType with the given component name.
- *
- * @param mgtView -
- * @return the matching ManagedComponent if found, null otherwise
- * @throws Exception
- */
- protected ManagedComponent getManagedComponent(ManagementView mgtView, ComponentType type, String name)
- throws Exception
- {
- Set<ManagedComponent> comps = mgtView.getComponentsForType(type);
- ManagedComponent mc = null;
- for (ManagedComponent comp : comps)
- {
- String cname = comp.getName();
- if( cname.endsWith(name) )
- {
- mc = comp;
- break;
- }
- }
- return mc;
- }
-
- private MetaValueFactory getMetaValueFactory()
- {
- if(metaValueFactory == null)
- metaValueFactory = MetaValueFactory.getInstance();
- return metaValueFactory;
- }
-
private Type getMapType()
{
if(mapType == null)
More information about the jboss-cvs-commits
mailing list