[jboss-cvs] JBossAS SVN: r69651 - in trunk: messaging/src/etc/deploy/common and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Feb 6 08:45:51 EST 2008
Author: alex.loubyansky at jboss.com
Date: 2008-02-06 08:45:51 -0500 (Wed, 06 Feb 2008)
New Revision: 69651
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/profileservice/build.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-06 13:42:05 UTC (rev 69650)
+++ trunk/build/build-distr.xml 2008-02-06 13:45:51 UTC (rev 69651)
@@ -774,6 +774,7 @@
</fileset>
<fileset dir="${_module.output}/etc/deploy/clustered">
<include name="*-service.xml"/>
+ <include name="*-beans.xml"/>
<include name="mysql-ds.xml"/>
</fileset>
</copy>
@@ -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-06 13:45:51 UTC (rev 69651)
@@ -0,0 +1,32 @@
+<?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>
Modified: trunk/profileservice/build.xml
===================================================================
--- trunk/profileservice/build.xml 2008-02-06 13:42:05 UTC (rev 69650)
+++ trunk/profileservice/build.xml 2008-02-06 13:45:51 UTC (rev 69651)
@@ -78,6 +78,8 @@
<path refid="jboss.remoting.classpath"/>
<path refid="jboss.system.classpath"/>
<path refid="jboss.systemjmx.classpath"/>
+ <path refid="sun.jaxb.classpath"/>
+ <path refid="stax.api.classpath"/>
</path>
<!-- The combined dependant module classpath -->
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-06 13:45:51 UTC (rev 69651)
@@ -0,0 +1,226 @@
+/*
+ * 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 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-06 13:45:51 UTC (rev 69651)
@@ -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;
+ 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-06 13:45:51 UTC (rev 69651)
@@ -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-06 13:45:51 UTC (rev 69651)
@@ -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-06 13:42:05 UTC (rev 69650)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java 2008-02-06 13:45:51 UTC (rev 69651)
@@ -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;
@@ -52,26 +50,19 @@
import org.jboss.metatype.api.values.MetaValue;
import org.jboss.metatype.api.values.SimpleValueSupport;
import org.jboss.metatype.api.values.SimpleValue;
-import org.jboss.metatype.api.values.MetaValueFactory;
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
@@ -444,22 +435,6 @@
propValues.put("xa-datasource-class", "org.hsqldb.jdbcDriver");
propValues.put("xa-resource-timeout", new Integer(256));
-/*
- ArrayList<XAConnectionPropertyMetaData> xaPropsValue = new ArrayList<XAConnectionPropertyMetaData>();
- XAConnectionPropertyMetaData xaPropMD = new XAConnectionPropertyMetaData();
- xaPropMD.setName("URL");
- xaPropMD.setValue("jdbc:hsqldb:.");
- xaPropsValue.add(xaPropMD);
- xaPropMD = new XAConnectionPropertyMetaData();
- xaPropMD.setName("User");
- xaPropMD.setValue("sa");
- xaPropsValue.add(xaPropMD);
- xaPropMD = new XAConnectionPropertyMetaData();
- xaPropMD.setName("Password");
- xaPropMD.setValue("");
- xaPropsValue.add(xaPropMD);
- propValues.put("xa-datasource-properties", xaPropsValue);
-*/
HashMap<String, String> xaPropValues = new HashMap<String, String>();
xaPropValues.put("URL", "jdbc:hsqldb");
xaPropValues.put("User", "sa");
@@ -493,21 +468,6 @@
addCommonCfProperties(propValues, jndiName, "jms-ra.rar", "org.jboss.resource.adapter.jms.JmsConnectionFactory");
-/*
- ArrayList<ManagedConnectionFactoryPropertyMetaData> configPropsValue = new ArrayList<ManagedConnectionFactoryPropertyMetaData>();
- ManagedConnectionFactoryPropertyMetaData configPropMD = new ManagedConnectionFactoryPropertyMetaData();
- configPropMD.setName("SessionDefaultType");
- configPropMD.setType("java.lang.String");
- configPropMD.setValue("javax.jms.Topic");
- configPropsValue.add(configPropMD);
- configPropMD = new ManagedConnectionFactoryPropertyMetaData();
- configPropMD.setName("JmsProviderAdapterJNDI");
- configPropMD.setType("java.lang.String");
- configPropMD.setValue("java:/DefaultJMSProvider");
- configPropsValue.add(configPropMD);
- propValues.put("config-property", configPropsValue);
-*/
-
Map<String, Map<String, String>> xaProps = new HashMap<String, Map<String, String>>();
Map<String, String> value = new HashMap<String, String>();
value.put("name", "SessionDefaultType");
@@ -573,21 +533,6 @@
addCommonCfProperties(propValues, jndiName, "jms-ra.rar", "org.jboss.resource.adapter.jms.JmsConnectionFactory");
-/*
- ArrayList<ManagedConnectionFactoryPropertyMetaData> configPropsValue = new ArrayList<ManagedConnectionFactoryPropertyMetaData>();
- ManagedConnectionFactoryPropertyMetaData configPropMD = new ManagedConnectionFactoryPropertyMetaData();
- configPropMD.setName("SessionDefaultType");
- configPropMD.setType("java.lang.String");
- configPropMD.setValue("javax.jms.Topic");
- configPropsValue.add(configPropMD);
- configPropMD = new ManagedConnectionFactoryPropertyMetaData();
- configPropMD.setName("JmsProviderAdapterJNDI");
- configPropMD.setType("java.lang.String");
- configPropMD.setValue("java:/DefaultJMSProvider");
- configPropsValue.add(configPropMD);
- propValues.put("config-property", configPropsValue);
-*/
-
Map<String, Map<String, String>> xaProps = new HashMap<String, Map<String, String>>();
Map<String, String> value = new HashMap<String, String>();
value.put("name", "SessionDefaultType");
@@ -690,7 +635,7 @@
// todo: local-transaction
}
- private void createComponentTest(String templateName,
+ protected void createComponentTest(String templateName,
Map<String, Serializable> propValues,
String deploymentName,
ComponentType componentType, String componentName)
@@ -753,70 +698,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