[jboss-cvs] JBossAS SVN: r76120 - in projects/metadata/trunk/src/test/java/org/jboss/test/metadata: jbmeta80 and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jul 23 01:22:26 EDT 2008
Author: ALRubinger
Date: 2008-07-23 01:22:26 -0400 (Wed, 23 Jul 2008)
New Revision: 76120
Added:
projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta80/
projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta80/BusinessInterface.java
projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta80/SessionContextAnnotatedResourceBean.java
projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta80/unit/
projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta80/unit/SessionContextAddedToMetadataUnitTestCase.java
Log:
[JBMETA-80] Added Unit Test to show the problem
Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta80/BusinessInterface.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta80/BusinessInterface.java (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta80/BusinessInterface.java 2008-07-23 05:22:26 UTC (rev 76120)
@@ -0,0 +1,35 @@
+/*
+ * 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.jbmeta80;
+
+/**
+ * BusinessInterface
+ *
+ * A Simple Business interface
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface BusinessInterface
+{
+ boolean isSessionContextInjected();
+}
Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta80/SessionContextAnnotatedResourceBean.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta80/SessionContextAnnotatedResourceBean.java (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta80/SessionContextAnnotatedResourceBean.java 2008-07-23 05:22:26 UTC (rev 76120)
@@ -0,0 +1,72 @@
+/*
+ * 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.jbmeta80;
+
+import javax.annotation.Resource;
+import javax.ejb.Local;
+import javax.ejb.SessionContext;
+import javax.ejb.Stateless;
+
+import org.jboss.logging.Logger;
+
+/**
+ * SessionContextAnnotatedResourceBean
+ *
+ * A Simple EJB used to determine whether a SessionContext was
+ * picked up as @Resource by JBoss50Creator
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+ at Stateless
+ at Local(BusinessInterface.class)
+public class SessionContextAnnotatedResourceBean implements BusinessInterface
+{
+
+ // --------------------------------------------------------------------------------||
+ // Class Members ------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ private static final Logger log = Logger.getLogger(SessionContextAnnotatedResourceBean.class);
+
+ // --------------------------------------------------------------------------------||
+ // Instance Members ---------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ @Resource
+ public SessionContext context;
+
+ // --------------------------------------------------------------------------------||
+ // Required Implementations -------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Returns whether the SessionContext was injected
+ *
+ * @return
+ */
+ public boolean isSessionContextInjected()
+ {
+ return this.context!=null;
+ }
+
+}
Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta80/unit/SessionContextAddedToMetadataUnitTestCase.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta80/unit/SessionContextAddedToMetadataUnitTestCase.java (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta80/unit/SessionContextAddedToMetadataUnitTestCase.java 2008-07-23 05:22:26 UTC (rev 76120)
@@ -0,0 +1,110 @@
+/*
+ * 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.jbmeta80.unit;
+
+import java.lang.reflect.AnnotatedElement;
+import java.util.Collection;
+import java.util.HashSet;
+
+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.JBossMetaData;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+import org.jboss.metadata.javaee.spec.Environment;
+import org.jboss.metadata.javaee.spec.ResourceEnvironmentReferenceMetaData;
+import org.jboss.metadata.javaee.spec.ResourceEnvironmentReferencesMetaData;
+import org.jboss.metadata.javaee.spec.ResourceReferenceMetaData;
+import org.jboss.metadata.javaee.spec.ResourceReferencesMetaData;
+import org.jboss.test.metadata.jbmeta80.SessionContextAnnotatedResourceBean;
+
+/**
+ * SessionContextAddedToMetadataUnitTestCase
+ *
+ * Ensures that a SessionContext is added to metadata when
+ * using the JBoss50Creator
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class SessionContextAddedToMetadataUnitTestCase extends TestCase
+{
+ // ------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------||
+ // ------------------------------------------------------------------------------||
+
+ private static final Logger log = Logger.getLogger(SessionContextAddedToMetadataUnitTestCase.class);
+
+ // ------------------------------------------------------------------------------||
+ // Tests ------------------------------------------------------------------------||
+ // ------------------------------------------------------------------------------||
+
+ /**
+ * Tests that a field-level SessionContext instance is
+ * injected
+ *
+ * @throws Throwable
+ */
+ public void testFieldLevelSessionContextInjected() throws Throwable
+ {
+ // Define the Bean Implementation Class
+ Class<?> beanImplClass = SessionContextAnnotatedResourceBean.class;
+
+ // Use JBoss50Creator to generate metadata
+ AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>();
+ Collection<Class<?>> classes = new HashSet<Class<?>>();
+ classes.add(beanImplClass);
+ JBossMetaData metadata = new JBoss50Creator(finder).create(classes);
+
+ // Get SLSB
+ String ejbName = beanImplClass.getSimpleName();
+ JBossSessionBeanMetaData slsb = (JBossSessionBeanMetaData) metadata.getEnterpriseBean(ejbName);
+ assert slsb != null : "Bean metadata for " + ejbName + " could not be found";
+
+ // Get Environment
+ Environment env = slsb.getJndiEnvironmentRefsGroup();
+
+ // Look in Resource References
+ ResourceReferencesMetaData refs = env.getResourceReferences();
+ if (refs != null)
+ {
+ for (ResourceReferenceMetaData ref : refs)
+ {
+ log.info(ref);
+ }
+ }
+
+ // Look in Resource Env References
+ ResourceEnvironmentReferencesMetaData envRefs = env.getResourceEnvironmentReferences();
+ if (envRefs != null)
+ {
+ for (ResourceEnvironmentReferenceMetaData envRef : envRefs)
+ {
+ log.info(envRef);
+ }
+ }
+
+ }
+}
More information about the jboss-cvs-commits
mailing list