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

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sun Jul 20 17:03:55 EDT 2008


Author: ALRubinger
Date: 2008-07-20 17:03:54 -0400 (Sun, 20 Jul 2008)
New Revision: 76028

Added:
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta77/
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta77/unit/
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta77/unit/SerializableDefaultJndiBindingPolicyUnitTestCase.java
Modified:
   projects/metadata/trunk/src/main/java/org/jboss/metadata/ejb/jboss/jndipolicy/spi/DefaultJndiBindingPolicy.java
Log:
[JBMETA-77] Ensure DefaultJndiBindingPolicy is Serializale (and tests)

Modified: projects/metadata/trunk/src/main/java/org/jboss/metadata/ejb/jboss/jndipolicy/spi/DefaultJndiBindingPolicy.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/ejb/jboss/jndipolicy/spi/DefaultJndiBindingPolicy.java	2008-07-20 13:50:28 UTC (rev 76027)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/ejb/jboss/jndipolicy/spi/DefaultJndiBindingPolicy.java	2008-07-20 21:03:54 UTC (rev 76028)
@@ -21,16 +21,18 @@
  */
 package org.jboss.metadata.ejb.jboss.jndipolicy.spi;
 
+import java.io.Serializable;
+
 import org.jboss.metadata.ejb.jboss.jndipolicy.spi.KnownInterfaces.KnownInterfaceType;
 
 /**
  * A jndi name policy spi for obtaining jndi names not specified in metadata.
  * 
- * @author <a href="mailto:andrew.rubinger at redhat.com">ALR</a>
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
  * @author Scott.Stark at jboss.org
  * @version $Revision$
  */
-public interface DefaultJndiBindingPolicy
+public interface DefaultJndiBindingPolicy extends Serializable
 {
    /**
     * Returns the JNDI name that should be assigned to this deployment

Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta77/unit/SerializableDefaultJndiBindingPolicyUnitTestCase.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta77/unit/SerializableDefaultJndiBindingPolicyUnitTestCase.java	                        (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta77/unit/SerializableDefaultJndiBindingPolicyUnitTestCase.java	2008-07-20 21:03:54 UTC (rev 76028)
@@ -0,0 +1,94 @@
+/*
+ * 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.jbmeta77.unit;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+
+import junit.framework.TestCase;
+
+import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+import org.jboss.metadata.ejb.jboss.jndipolicy.plugins.BasicJndiBindingPolicy;
+import org.jboss.metadata.ejb.jboss.jndipolicy.plugins.JBossSessionPolicyDecorator;
+import org.jboss.metadata.ejb.jboss.jndipolicy.spi.DefaultJndiBindingPolicy;
+
+/**
+ * SerializableDefaultJndiBindingPolicyUnitTestCase
+ * 
+ * Ensures that a JBossSessionBeanMetaData
+ * instance decorated with a DefaultJndiBindingPolicy is
+ * Serializable
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class SerializableDefaultJndiBindingPolicyUnitTestCase extends TestCase
+{
+   // ------------------------------------------------------------------------------||
+   // Class Members ----------------------------------------------------------------||
+   // ------------------------------------------------------------------------------||
+
+   private static final Logger log = Logger.getLogger(SerializableDefaultJndiBindingPolicyUnitTestCase.class);
+
+   // ------------------------------------------------------------------------------||
+   // Tests ------------------------------------------------------------------------||
+   // ------------------------------------------------------------------------------||
+
+   /**
+    * Tests that a JBossSessionBeanMetaData
+    * instance decorated with a BasicJndiBindingPolicy is
+    * Serializable
+    * 
+    * @throws Throwable
+    */
+   public void test() throws Throwable
+   {
+
+      // Create a BasicJndiBindingPolicy
+      DefaultJndiBindingPolicy policy = new BasicJndiBindingPolicy();
+
+      // Ensure Serializable
+      assertTrue(BasicJndiBindingPolicy.class.getSimpleName() + " is not " + Serializable.class.getSimpleName(),
+            policy instanceof Serializable);
+
+      // Create MD
+      JBossSessionBeanMetaData smd = new JBossSessionBeanMetaData();
+
+      // Decorate with Policy
+      smd = new JBossSessionPolicyDecorator(smd, policy);
+
+      // Serialize Roundtrip Copy
+      ByteArrayOutputStream out = new ByteArrayOutputStream();
+      ObjectOutputStream objOut = new ObjectOutputStream(out);
+      objOut.writeObject(smd);
+      ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
+      ObjectInputStream objIn = new ObjectInputStream(in);
+      objIn.readObject();
+
+      // Log
+      log.info(smd + " Successfully Serialized");
+   }
+}




More information about the jboss-cvs-commits mailing list