[jboss-cvs] JBossAS SVN: r82754 - in projects/metadata/trunk/src/test/java/org/jboss/test/metadata: jbmeta152/unit and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sun Jan 11 04:57:51 EST 2009


Author: ALRubinger
Date: 2009-01-11 04:57:51 -0500 (Sun, 11 Jan 2009)
New Revision: 82754

Added:
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta165/
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta165/ServiceWithFullMetadataBean.java
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta165/unit/
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta165/unit/ServiceBeanWrappedInPolicyDecoratorTestCase.java
Modified:
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta152/unit/OverriddenNotAdditiveRolesAllowedTestCase.java
Log:
[JBMETA-165] Add Unit Tests

Modified: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta152/unit/OverriddenNotAdditiveRolesAllowedTestCase.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta152/unit/OverriddenNotAdditiveRolesAllowedTestCase.java	2009-01-11 08:34:17 UTC (rev 82753)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta152/unit/OverriddenNotAdditiveRolesAllowedTestCase.java	2009-01-11 09:57:51 UTC (rev 82754)
@@ -41,7 +41,7 @@
 import org.jboss.test.metadata.jbmeta152.SecureServiceBean;
 
 /**
- * LeakingRolesAllowedTestCase
+ * OverriddenNotAdditiveRolesAllowedTestCase
  * 
  * Tests EJBs that have @RolesAllowed defined on a method
  * are overridden by inheritence, not applied in an additive model

Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta165/ServiceWithFullMetadataBean.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta165/ServiceWithFullMetadataBean.java	                        (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta165/ServiceWithFullMetadataBean.java	2009-01-11 09:57:51 UTC (rev 82754)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.metadata.jbmeta165;
+
+import org.jboss.ejb3.annotation.Management;
+import org.jboss.ejb3.annotation.Service;
+
+/**
+ * ServiceWithManagementInterfaceBean
+ * 
+ * A dummy @Service bean which defines metadata
+ * specific to JBossServiceBeanMetadata
+ * 
+ * JBMETA-165
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+ at Service(xmbean = ServiceWithFullMetadataBean.XM_BEAN, objectName = ServiceWithFullMetadataBean.OBJECT_NAME)
+ at Management(Cloneable.class)
+public class ServiceWithFullMetadataBean
+{
+   // -------------------------------------------------------------------||
+   // Constants ---------------------------------------------------------||
+   // -------------------------------------------------------------------||
+
+   public static final String XM_BEAN = "XMBEAN_DEFINITION";
+
+   public static final String OBJECT_NAME = "DUMMY_OBJECT_NAME";
+}

Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta165/unit/ServiceBeanWrappedInPolicyDecoratorTestCase.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta165/unit/ServiceBeanWrappedInPolicyDecoratorTestCase.java	                        (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta165/unit/ServiceBeanWrappedInPolicyDecoratorTestCase.java	2009-01-11 09:57:51 UTC (rev 82754)
@@ -0,0 +1,223 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.metadata.jbmeta165.unit;
+
+import java.lang.reflect.AnnotatedElement;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import junit.framework.TestCase;
+
+import org.jboss.logging.Logger;
+import org.jboss.metadata.annotation.creator.ejb.jboss.JBoss50Creator;
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.annotation.finder.DefaultAnnotationFinder;
+import org.jboss.metadata.ejb.jboss.JBoss50MetaData;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossServiceBeanMetaData;
+import org.jboss.metadata.ejb.jboss.jndipolicy.plugins.BasicJndiBindingPolicy;
+import org.jboss.metadata.ejb.jboss.jndipolicy.plugins.JBossSessionPolicyDecorator;
+import org.jboss.test.metadata.jbmeta165.ServiceWithFullMetadataBean;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * ServiceBeanWrappedInPolicyDecoratorTestCase
+ * 
+ * Tests that JBossServiceBeanMetadata operations, when
+ * executed upon a metadata wrapped in JNDI Policy, 
+ * continue to work as expected
+ * 
+ * JBMETA-165
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class ServiceBeanWrappedInPolicyDecoratorTestCase
+{
+   // -------------------------------------------------------------------||
+   // Class Members -----------------------------------------------------||
+   // -------------------------------------------------------------------||
+
+   private static final Logger log = Logger.getLogger(ServiceBeanWrappedInPolicyDecoratorTestCase.class);
+
+   // -------------------------------------------------------------------||
+   // Instance Members --------------------------------------------------||
+   // -------------------------------------------------------------------||
+
+   private static JBossServiceBeanMetaData serviceBean;
+
+   // -------------------------------------------------------------------||
+   // Tests -------------------------------------------------------------||
+   // -------------------------------------------------------------------||
+
+   /**
+    * Ensures that XM Bean operations work as expected
+    */
+   @Test
+   public void testXmBeanOperations() throws Throwable
+   {
+      // Get the existing value
+      String existing = serviceBean.getXmbean();
+
+      // Ensure expected
+      TestCase.assertEquals("xmbean value as read from metadata not as expected", ServiceWithFullMetadataBean.XM_BEAN,
+            existing);
+
+      // Set a new value
+      String newValue = "new Value";
+      serviceBean.setXmbean(newValue);
+
+      // Ensure expected as we've just set
+      String roundtrip = serviceBean.getXmbean();
+      TestCase.assertEquals("xmbean value not set properly", newValue, roundtrip);
+
+      // Reset to original
+      serviceBean.setXmbean(existing);
+
+      // Ensure reset
+      String reset = serviceBean.getXmbean();
+      TestCase.assertEquals("xmbean value not reset properly", existing, reset);
+   }
+
+   /**
+    * Ensures that ObjectName operations work as expected
+    */
+   @Test
+   public void testObjectNameOperations() throws Throwable
+   {
+      // Get the existing value
+      String existing = serviceBean.getObjectName();
+
+      // Ensure expected
+      TestCase.assertEquals("objectName value as read from metadata not as expected",
+            ServiceWithFullMetadataBean.OBJECT_NAME, existing);
+
+      // Set a new value
+      String newValue = "new Value";
+      serviceBean.setObjectName(newValue);
+
+      // Ensure expected as we've just set
+      String roundtrip = serviceBean.getObjectName();
+      TestCase.assertEquals("objectName value not set properly", newValue, roundtrip);
+
+      // Reset to original
+      serviceBean.setObjectName(existing);
+
+      // Ensure reset
+      String reset = serviceBean.getObjectName();
+      TestCase.assertEquals("objectName value not reset properly", existing, reset);
+   }
+
+   /**
+    * Ensures that @Management operations work as expected
+    */
+   @Test
+   public void testManagementOperations() throws Throwable
+   {
+      // Get the existing value
+      String existing = serviceBean.getManagement();
+
+      // Ensure expected
+      TestCase.assertEquals("@Management value as read from metadata not as expected", Cloneable.class.getName(),
+            existing);
+
+      // Set a new value
+      String newValue = "new Value";
+      serviceBean.setManagement(newValue);
+
+      // Ensure expected as we've just set
+      String roundtrip = serviceBean.getManagement();
+      TestCase.assertEquals("@Management value not set properly", newValue, roundtrip);
+
+      // Reset to original
+      serviceBean.setManagement(existing);
+
+      // Ensure reset
+      String reset = serviceBean.getManagement();
+      TestCase.assertEquals("@Management value not reset properly", existing, reset);
+   }
+
+   // -------------------------------------------------------------------||
+   // Lifecycle Methods -------------------------------------------------||
+   // -------------------------------------------------------------------||
+
+   @BeforeClass
+   public static void beforeAll() throws Throwable
+   {
+      /*
+       * Make the metadata
+       */
+
+      // Define the implementation class
+      Class<?> implClass = ServiceWithFullMetadataBean.class;
+
+      // Make an annotation finder
+      AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>();
+
+      // Configure to scan the test EJB
+      Collection<Class<?>> classes = new ArrayList<Class<?>>();
+      classes.add(implClass);
+      JBoss50Creator creator = new JBoss50Creator(finder);
+
+      // Make the metadata
+      JBoss50MetaData md = creator.create(classes);
+
+      // Sanity Checks
+      String ejbName = implClass.getSimpleName();
+      JBossEnterpriseBeanMetaData bean = md.getEnterpriseBean(ejbName);
+      assert bean != null : "Bean of name " + ejbName + " should not be null";
+      assert (bean instanceof JBossServiceBeanMetaData) : "Expected " + JBossServiceBeanMetaData.class.getSimpleName()
+            + ", was " + bean.getClass().getName();
+
+      // Wrap and set
+      JBossServiceBeanMetaData service = (JBossServiceBeanMetaData) bean;
+      JBossServiceBeanMetaData policyWrapped = new JBossSessionPolicyDecorator(service, new BasicJndiBindingPolicy());
+
+      //TODO this line above
+
+      /*
+       * 
+       * 
+       * 
+       * 
+       * 
+       * 
+       * 
+       * 
+       */
+
+      serviceBean = policyWrapped;
+
+      // Log
+      log.info("Set " + policyWrapped + " with delegate " + service);
+   }
+
+   @AfterClass
+   public static void afterAll() throws Throwable
+   {
+      // We're done, null out
+      serviceBean = null;
+   }
+
+}




More information about the jboss-cvs-commits mailing list