[jboss-cvs] JBossAS SVN: r78036 - in projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory: test and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Sep 4 20:43:45 EDT 2008


Author: scott.stark at jboss.org
Date: 2008-09-04 20:43:45 -0400 (Thu, 04 Sep 2008)
New Revision: 78036

Added:
   projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/JmsDestinationICF.java
   projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/SecDomainICF.java
   projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/SecDomainMD.java
   projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/SecurityDeploymentType.java
   projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/SecurityDomain.java
   projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/SecurityDomainApplicationManagedMetaData.java
Modified:
   projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/JmsDestination.java
   projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/JmsDestinations.java
   projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/test/AbstractManagedObjectFactoryUnitTestCase.java
Log:
Add a test of writing a GenericValue/ManagedObject 

Modified: projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/JmsDestination.java
===================================================================
--- projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/JmsDestination.java	2008-09-05 00:42:36 UTC (rev 78035)
+++ projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/JmsDestination.java	2008-09-05 00:43:45 UTC (rev 78036)
@@ -36,15 +36,31 @@
    implements Serializable
 {
    private static final long serialVersionUID = 1;
+   private String jndiName;
+   private SecDomainMD domain;
 
-   @ManagementProperty(description="JNDI binding location of destination")
+   @ManagementProperty(description="JNDI binding location of destination", includeInTemplate=true)
    public String getJndiName()
    {
-      return null;
+      return jndiName;
    }
-   @ManagementProperty(use={ViewUse.STATISTIC})
+   public void setJndiName(String jndiName)
+   {
+      this.jndiName = jndiName;
+   }
+
+   @ManagementProperty(use={ViewUse.STATISTIC}, includeInTemplate=false)
    public int getMsgCount()
    {
       return 0;
    }
+   @ManagementProperty(description="Security domain information", managed=true)
+   public SecDomainMD getDomain()
+   {
+      return domain;
+   }
+   public void setDomain(SecDomainMD domain)
+   {
+      this.domain = domain;
+   }
 }

Added: projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/JmsDestinationICF.java
===================================================================
--- projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/JmsDestinationICF.java	                        (rev 0)
+++ projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/JmsDestinationICF.java	2008-09-05 00:43:45 UTC (rev 78036)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * 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.managed.factory.support.deployment;
+
+import org.jboss.beans.info.spi.BeanInfo;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.plugins.factory.AbstractInstanceClassFactory;
+import org.jboss.metatype.api.values.EnumValue;
+import org.jboss.metatype.api.values.GenericValue;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValue;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class JmsDestinationICF extends AbstractInstanceClassFactory<JmsDestination>
+{
+
+   @Override
+   public void setValue(BeanInfo beanInfo, ManagedProperty property,
+         JmsDestination object, MetaValue value)
+   {
+      if(property.getName().equals("domain"))
+      {
+         GenericValue gv = (GenericValue) value;
+         ManagedObject mo = (ManagedObject) gv.getValue();
+         // Create the correct type of 
+         ManagedProperty type = mo.getProperty("securityDeploymentType");
+         ManagedProperty domain = mo.getProperty("domain");
+         String domainName = ((SimpleValue) domain.getValue()).getValue().toString();
+         EnumValue typeValue = (EnumValue) type.getValue();
+         String typeString = typeValue.getValue();
+         SecurityDeploymentType stype = SecurityDeploymentType.valueOf(typeString);
+         SecDomainMD domainMD = null;
+         switch(stype)
+         {
+         case APPLICATION:
+            domainMD = new SecurityDomainApplicationManagedMetaData();
+            break;
+         case DOMAIN:
+            domainMD = new SecurityDomain();
+            break;
+         default:
+         case NONE:
+            break;
+         }
+         domainMD.setDomain(domainName);
+         object.setDomain(domainMD);
+      }
+      else
+      {
+         super.setValue(beanInfo, property, object, value);
+      }
+   }
+
+}

Modified: projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/JmsDestinations.java
===================================================================
--- projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/JmsDestinations.java	2008-09-05 00:42:36 UTC (rev 78035)
+++ projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/JmsDestinations.java	2008-09-05 00:43:45 UTC (rev 78036)
@@ -27,6 +27,7 @@
 import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
 import org.jboss.managed.api.annotation.ManagementDeployment;
 import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ManagementProperty;
 
 /**
  * test jms pojo deployment
@@ -43,11 +44,11 @@
 
    private List<JmsDestination> destinations;
 
+   @ManagementProperty(managed=true)
    public List<JmsDestination> getDestinations()
    {
       return destinations;
    }
-
    public void setDestinations(List<JmsDestination> destinations)
    {
       this.destinations = destinations;

Added: projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/SecDomainICF.java
===================================================================
--- projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/SecDomainICF.java	                        (rev 0)
+++ projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/SecDomainICF.java	2008-09-05 00:43:45 UTC (rev 78036)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * 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.managed.factory.support.deployment;
+
+import org.jboss.managed.plugins.factory.AbstractInstanceClassFactory;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class SecDomainICF extends AbstractInstanceClassFactory<SecDomainMD>
+{
+
+}

Added: projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/SecDomainMD.java
===================================================================
--- projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/SecDomainMD.java	                        (rev 0)
+++ projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/SecDomainMD.java	2008-09-05 00:43:45 UTC (rev 78036)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * 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.managed.factory.support.deployment;
+
+import java.io.Serializable;
+
+import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ManagementProperty;
+
+/**
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+ at ManagementObject(description="The security domain, type information")
+public class SecDomainMD implements Serializable
+{
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 1;
+   private String domain;
+   private SecurityDeploymentType type;
+   
+   
+   public SecDomainMD()
+   {
+      this(SecurityDeploymentType.NONE);
+   }
+   protected SecDomainMD(SecurityDeploymentType type)
+   {
+      this.type = type;
+   }
+   
+   public boolean requiresDomain()
+   {
+      return (getSecurityDeploymentType().equals(SecurityDeploymentType.DOMAIN) 
+            || getSecurityDeploymentType().equals(SecurityDeploymentType.DOMAIN_AND_APPLICATION));
+   }   
+
+   @ManagementProperty
+   public String getDomain()
+   {
+      return domain;
+   }
+   public void setDomain(String domain)
+   {
+      this.domain = domain;
+   }
+
+   @ManagementProperty
+   public SecurityDeploymentType getSecurityDeploymentType()
+   {
+      return type;
+   }
+}
+

Added: projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/SecurityDeploymentType.java
===================================================================
--- projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/SecurityDeploymentType.java	                        (rev 0)
+++ projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/SecurityDeploymentType.java	2008-09-05 00:43:45 UTC (rev 78036)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * 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.managed.factory.support.deployment;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public enum SecurityDeploymentType
+{
+   NONE, APPLICATION, DOMAIN, DOMAIN_AND_APPLICATION;
+}

Added: projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/SecurityDomain.java
===================================================================
--- projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/SecurityDomain.java	                        (rev 0)
+++ projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/SecurityDomain.java	2008-09-05 00:43:45 UTC (rev 78036)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * 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.managed.factory.support.deployment;
+
+import org.jboss.managed.api.annotation.ManagementObject;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+ at ManagementObject
+public class SecurityDomain
+   extends SecDomainMD
+{
+   private static final long serialVersionUID = 1;
+   public SecurityDomain()
+   {
+      super(SecurityDeploymentType.DOMAIN);
+   }
+   public SecurityDomain(String domain)
+   {
+      super(SecurityDeploymentType.DOMAIN);
+      super.setDomain(domain);
+   }
+}

Added: projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/SecurityDomainApplicationManagedMetaData.java
===================================================================
--- projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/SecurityDomainApplicationManagedMetaData.java	                        (rev 0)
+++ projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/support/deployment/SecurityDomainApplicationManagedMetaData.java	2008-09-05 00:43:45 UTC (rev 78036)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * 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.managed.factory.support.deployment;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class SecurityDomainApplicationManagedMetaData
+   extends SecDomainMD
+{
+   private static final long serialVersionUID = 1;
+
+   public SecurityDomainApplicationManagedMetaData()
+   {
+      super(SecurityDeploymentType.APPLICATION);
+   }
+}

Modified: projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/test/AbstractManagedObjectFactoryUnitTestCase.java
===================================================================
--- projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/test/AbstractManagedObjectFactoryUnitTestCase.java	2008-09-05 00:42:36 UTC (rev 78035)
+++ projects/jboss-man/trunk/managed/src/test/java/org/jboss/test/managed/factory/test/AbstractManagedObjectFactoryUnitTestCase.java	2008-09-05 00:43:45 UTC (rev 78036)
@@ -21,21 +21,36 @@
  */
 package org.jboss.test.managed.factory.test;
 
+import java.io.Serializable;
 import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
 
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
 
 import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.ManagedProperty;
 import org.jboss.managed.api.factory.ManagedObjectFactory;
+import org.jboss.managed.plugins.factory.AbstractInstanceClassFactory;
 import org.jboss.managed.plugins.factory.AbstractManagedObjectFactory;
+import org.jboss.managed.spi.factory.InstanceClassFactory;
+import org.jboss.metatype.api.values.ArrayValue;
+import org.jboss.metatype.api.values.CollectionValue;
+import org.jboss.metatype.api.values.GenericValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
 import org.jboss.test.managed.factory.AbstractManagedObjectFactoryTest;
 import org.jboss.test.managed.factory.support.ManagementPropertySimpleManaged;
 import org.jboss.test.managed.factory.support.Simple;
 import org.jboss.test.managed.factory.support.amof.TestICF;
 import org.jboss.test.managed.factory.support.amof.TestMOP;
 import org.jboss.test.managed.factory.support.amof.TestSimpleICF;
+import org.jboss.test.managed.factory.support.deployment.JmsDestination;
+import org.jboss.test.managed.factory.support.deployment.JmsDestinationICF;
+import org.jboss.test.managed.factory.support.deployment.JmsDestinations;
+import org.jboss.test.managed.factory.support.deployment.QueueDestination;
+import org.jboss.test.managed.factory.support.deployment.SecurityDomain;
 
 /**
  * Test of behavior of the AbstractManagedObjectFactory
@@ -109,6 +124,52 @@
  
    }
 
+   public void testGenericValueUpdate()
+   {
+      AbstractManagedObjectFactory mof = new AbstractManagedObjectFactory();
+      mof.setInstanceClassFactory(JmsDestination.class, new JmsDestinationICF());
+      testMOF = mof;
+
+      JmsDestinations destinations = new JmsDestinations();
+      List<JmsDestination> queues = new ArrayList<JmsDestination>();
+      QueueDestination q1 = new QueueDestination();
+      q1.setJndiName("queues/Q1");
+      q1.setDomain(new SecurityDomain("java:/jaas/JMS"));
+      queues.add(q1);
+      destinations.setDestinations(queues);
+
+      ManagedObject managedObject = initManagedObject(destinations);
+      checkManagedObjectDefaults(JmsDestinations.class, managedObject);
+
+      ManagedProperty destinationsMP = managedObject.getProperty("destinations");
+      assertNotNull(destinationsMP);
+      CollectionValue destinationsValue = (CollectionValue) destinationsMP.getValue();
+      assertNotNull(destinationsValue);
+      assertEquals(1, destinationsValue.getSize());
+      GenericValue q1GV = (GenericValue) destinationsValue.getElements()[0];
+      assertNotNull(q1GV);
+
+      ManagedObject q1MO = (ManagedObject) q1GV.getValue();
+      assertNotNull(q1MO);
+      ManagedProperty domain = q1MO.getProperty("domain");
+      getLog().info(domain);
+      GenericValue domainGV = (GenericValue) domain.getValue();
+      assertNotNull(domainGV);
+      ManagedObject domainMO = (ManagedObject) domainGV.getValue();
+      assertNotNull(domainMO);
+
+      ManagedProperty domainName = domainMO.getProperty("domain");
+      assertEquals(SimpleValueSupport.wrap("java:/jaas/JMS"), domainName.getValue());
+
+      ManagedObject domainUpdateMO = initManagedObject(new SecurityDomain("java:/jaas/JMS2"));
+      AbstractInstanceClassFactory icf = new AbstractInstanceClassFactory(mof);
+      GenericValue domainUpdateGV = icf.getManagedObjectValue(domain, domainUpdateMO);
+      assertNotNull(domainUpdateGV.getValue());
+      domain.setValue(domainUpdateGV);
+      // Validate this has been written through
+      assertEquals("java:/jaas/JMS2", q1.getDomain().getDomain());
+   }
+
    /**
     * Override to allow test specific ManagedObjectFactory
     */




More information about the jboss-cvs-commits mailing list