[jboss-cvs] JBossAS SVN: r97729 - in projects/metadata/ejb/trunk/src: main/java/org/jboss/metadata/ejb/jboss/jndipolicy/spi and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Dec 11 08:23:29 EST 2009
Author: wolfc
Date: 2009-12-11 08:23:28 -0500 (Fri, 11 Dec 2009)
New Revision: 97729
Added:
projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/jndipolicy/plugins/JavaEE6JndiBindingPolicy.java
projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jndipolicy/
projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jndipolicy/JavaEE6JndiBindingPolicyTest.java
Modified:
projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/jndipolicy/spi/DeploymentSummary.java
projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/jndipolicy/spi/EjbDeploymentSummary.java
Log:
JBMETA-231: created JavaEE 6 JNDI binding policy
Added: projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/jndipolicy/plugins/JavaEE6JndiBindingPolicy.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/jndipolicy/plugins/JavaEE6JndiBindingPolicy.java (rev 0)
+++ projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/jndipolicy/plugins/JavaEE6JndiBindingPolicy.java 2009-12-11 13:23:28 UTC (rev 97729)
@@ -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.metadata.ejb.jboss.jndipolicy.plugins;
+
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossEntityBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+import org.jboss.metadata.ejb.jboss.jndipolicy.spi.DefaultJndiBindingPolicy;
+import org.jboss.metadata.ejb.jboss.jndipolicy.spi.EjbDeploymentSummary;
+import org.jboss.metadata.ejb.jboss.jndipolicy.spi.KnownInterfaces;
+import org.jboss.metadata.ejb.jboss.jndipolicy.spi.KnownInterfaces.KnownInterfaceType;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class JavaEE6JndiBindingPolicy implements DefaultJndiBindingPolicy
+{
+ private static final long serialVersionUID = 1L;
+
+ protected String getBaseJndiName(EjbDeploymentSummary summary)
+ {
+ String appName = summary.getAppName();
+ String modulePath = summary.getDeploymentPath();
+ String moduleName = summary.getDeploymentName();
+ String beanName = summary.getBeanMD().getEjbName();
+ return (appName != null ? appName + "/" : "") + (modulePath != null ? modulePath + "/" : "") + moduleName + "/" + beanName;
+ }
+
+ @Override
+ public String getDefaultLocalHomeJndiName(EjbDeploymentSummary summary)
+ {
+ return getBaseJndiName(summary) + "!" + KnownInterfaces.LOCAL_HOME;
+ }
+
+ @Override
+ public String getDefaultLocalJndiName(EjbDeploymentSummary summary)
+ {
+ return getBaseJndiName(summary) + "!" + KnownInterfaces.LOCAL;
+ }
+
+ @Override
+ public String getDefaultRemoteHomeJndiName(EjbDeploymentSummary summary)
+ {
+ return getBaseJndiName(summary) + "!" + KnownInterfaces.HOME;
+ }
+
+ @Override
+ public String getDefaultRemoteJndiName(EjbDeploymentSummary summary)
+ {
+ return getBaseJndiName(summary) + "!" + KnownInterfaces.REMOTE;
+ }
+
+ @Override
+ public String getJndiName(EjbDeploymentSummary summary)
+ {
+ return getBaseJndiName(summary);
+ }
+
+ @Override
+ public String getJndiName(EjbDeploymentSummary summary, String iface, KnownInterfaceType ifaceType)
+ {
+ String jndiName = null;
+ if (KnownInterfaces.isKnownInterface(iface))
+ iface = null;
+
+ String baseJndiName = getBaseJndiName(summary);
+
+ if (ifaceType == KnownInterfaceType.UNKNOWN)
+ {
+ if (iface == null)
+ jndiName = baseJndiName;
+ else
+ jndiName = baseJndiName + "!" + iface;
+ }
+ else
+ {
+ boolean is3x = summary.getBeanMD().getJBossMetaData().isEJB3x();
+ if (is3x)
+ {
+ // EJB 3
+ switch (ifaceType)
+ {
+ // base-name/local(-iface)
+ case BUSINESS_LOCAL :
+
+ if (iface == null)
+ jndiName = baseJndiName + "!" + ifaceType.toSuffix();
+ else
+ jndiName = baseJndiName + "!" + iface;
+
+ break;
+
+ // base-name/remote(-iface) || mappedName
+ case BUSINESS_REMOTE :
+ case UNKNOWN :
+
+ JBossEnterpriseBeanMetaData md = summary.getBeanMD();
+ String mappedName = null;
+ if (md.isSession())
+ {
+ mappedName = ((JBossSessionBeanMetaData) md).getJndiName();
+ }
+ String setMappedName = md.getMappedName();
+ if (setMappedName != null && setMappedName.trim().length() > 0)
+ {
+ mappedName = md.getMappedName();
+ }
+
+ // JBMETA-75
+ // Use mappedName if it's specified
+ if (mappedName != null && iface == null)
+ {
+ jndiName = mappedName;
+ }
+ // JBMETA-75
+ // Fall back on base JNDI Name + type suffix
+ else if (iface == null)
+ jndiName = baseJndiName + "!" + ifaceType.toSuffix();
+ else
+ jndiName = baseJndiName + "!" + iface;
+ break;
+ case LOCAL_HOME :
+ // base-name / (local|remote)Home
+ jndiName = baseJndiName + "!" + ifaceType.toSuffix();
+ break;
+ case REMOTE_HOME :
+
+ /*
+ * First ensure that the Home binding has not been explicitly-defined
+ * (JBMETA-82)
+ */
+
+ // Obtain the MD
+ JBossEnterpriseBeanMetaData beanMd = summary.getBeanMD();
+
+ // If a Session Bean
+ if (beanMd.isSession())
+ {
+ JBossSessionBeanMetaData smd = (JBossSessionBeanMetaData) beanMd;
+ String explicitHomeJndiName = smd.getHomeJndiName();
+ // If explicitly-defined
+ if (explicitHomeJndiName != null && explicitHomeJndiName.length() > 0)
+ {
+ jndiName = explicitHomeJndiName;
+ break;
+ }
+ }
+
+ // base-name / (local|remote)Home
+ jndiName = baseJndiName + "!" + ifaceType.toSuffix();
+ break;
+ }
+ }
+ else
+ {
+ // EJB 2.x
+ switch (ifaceType)
+ {
+ // The local home jndi name (same for getLocalJndiName and getLocalHomeJndiName)
+ case BUSINESS_LOCAL :
+ case LOCAL_HOME :
+ // Use the bean local jndi name or a generated name for ejb2.x local homes
+ jndiName = summary.getBeanMD().getLocalJndiName();
+ if (jndiName != null && jndiName.trim().length() > 0)
+ {
+ return jndiName;
+ }
+ String ejbName = summary.getBeanMD().getEjbName();
+ jndiName = "local/" + ejbName + '@' + System.identityHashCode(ejbName);
+ break;
+
+ // The home jndi name (same for getJndiName and getHomeJndiName)
+ case BUSINESS_REMOTE :
+ case REMOTE_HOME :
+ // Don't append the iface suffix for ejb2.x homes
+ // JBMETA-79, use any explicit jndi-name/mapped-name
+ JBossEnterpriseBeanMetaData md = summary.getBeanMD();
+ String mappedName = md.getMappedName();
+ if (mappedName == null || mappedName.length() == 0)
+ {
+ if (md.isSession())
+ {
+ mappedName = ((JBossSessionBeanMetaData) md).getJndiName();
+ }
+ else if (md.isEntity())
+ {
+ mappedName = ((JBossEntityBeanMetaData) md).getJndiName();
+ }
+ }
+ jndiName = mappedName;
+ if (jndiName != null && jndiName.trim().length() > 0)
+ {
+ return jndiName;
+ }
+ // Fallback to the deployment summary base name
+ jndiName = baseJndiName;
+ break;
+ }
+ }
+ }
+ return jndiName;
+ }
+}
Modified: projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/jndipolicy/spi/DeploymentSummary.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/jndipolicy/spi/DeploymentSummary.java 2009-12-11 13:14:30 UTC (rev 97728)
+++ projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/jndipolicy/spi/DeploymentSummary.java 2009-12-11 13:23:28 UTC (rev 97729)
@@ -44,6 +44,10 @@
private String deploymentName;
/** The parent deployment base name without a suffix */
private String deploymentScopeBaseName;
+
+ /** The relative path within an EAR */
+ private String deploymentPath;
+
/**
* The packaging structure used
*/
@@ -57,8 +61,20 @@
setDeploymentName(summary.getDeploymentName());
setDeploymentScopeBaseName(summary.getDeploymentScopeBaseName());
this.setPackagingType(summary.getPackagingType());
+ // set deployment path after packaging type to maintain invariants
+ setDeploymentPath(summary.getDeploymentPath());
}
+ /**
+ * @return the name of the ear or null if not packaged within an ear
+ */
+ public String getAppName()
+ {
+ if(packagingType == PackagingType.EAR)
+ return getDeploymentScopeBaseName();
+ return null;
+ }
+
public String getDeploymentName()
{
return deploymentName;
@@ -68,6 +84,35 @@
this.deploymentName = deploymentName;
}
+ /**
+ * Returns the relative path of this deployment within an EAR.
+ * If the deployment is in the root of the EAR it'll return an empty String.
+ * If the deployment is stand-alone it'll return null.
+ *
+ * @return the relative path of this deployment within an ear or null
+ */
+ public String getDeploymentPath()
+ {
+ return deploymentPath;
+ }
+
+ public void setDeploymentPath(String deploymentPath)
+ {
+ /* invariant doesn't hold against deprecated usage
+ if(packagingType == PackagingType.EAR)
+ {
+ if(deploymentPath == null)
+ throw new IllegalArgumentException("deploymentPath must not be null for deployments within an EAR");
+ }
+ else
+ {
+ if(deploymentPath != null)
+ throw new IllegalArgumentException("deploymentPath must be null for stand-alone deployments");
+ }
+ */
+ this.deploymentPath = deploymentPath;
+ }
+
public String getDeploymentScopeBaseName()
{
return deploymentScopeBaseName;
Modified: projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/jndipolicy/spi/EjbDeploymentSummary.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/jndipolicy/spi/EjbDeploymentSummary.java 2009-12-11 13:14:30 UTC (rev 97728)
+++ projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/jndipolicy/spi/EjbDeploymentSummary.java 2009-12-11 13:23:28 UTC (rev 97729)
@@ -104,6 +104,7 @@
@Deprecated
public void setEjbName(String ejbName)
{
+ assert ejbName != null : "ejbName is null";
this.ejbName = ejbName;
}
Added: projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jndipolicy/JavaEE6JndiBindingPolicyTest.java
===================================================================
--- projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jndipolicy/JavaEE6JndiBindingPolicyTest.java (rev 0)
+++ projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jndipolicy/JavaEE6JndiBindingPolicyTest.java 2009-12-11 13:23:28 UTC (rev 97729)
@@ -0,0 +1,301 @@
+/*
+ * 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.metadata.ejb.test.jndipolicy;
+
+import static org.junit.Assert.assertEquals;
+
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeansMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+import org.jboss.metadata.ejb.jboss.jndipolicy.plugins.JavaEE6JndiBindingPolicy;
+import org.jboss.metadata.ejb.jboss.jndipolicy.spi.DeploymentSummary;
+import org.jboss.metadata.ejb.jboss.jndipolicy.spi.EjbDeploymentSummary;
+import org.jboss.metadata.ejb.jboss.jndipolicy.spi.PackagingType;
+import org.jboss.metadata.ejb.jboss.jndipolicy.spi.KnownInterfaces.KnownInterfaceType;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class JavaEE6JndiBindingPolicyTest
+{
+ private static JavaEE6JndiBindingPolicy policy = new JavaEE6JndiBindingPolicy();
+ private static EjbDeploymentSummary singleJarDeploymentSummary;
+
+ @BeforeClass
+ public static void beforeClass()
+ {
+ JBossSessionBeanMetaData beanMetaData = createBeanMetaData();
+
+ singleJarDeploymentSummary = createDeploymentSummary(beanMetaData);
+ }
+
+ private static JBossSessionBeanMetaData createBeanMetaData()
+ {
+ JBossMetaData metaData = new JBossMetaData();
+ metaData.setEjbVersion("3.1");
+ JBossEnterpriseBeansMetaData enterpriseBeans = new JBossEnterpriseBeansMetaData();
+ metaData.setEnterpriseBeans(enterpriseBeans);
+ JBossSessionBeanMetaData beanMetaData = new JBossSessionBeanMetaData();
+ beanMetaData.setEjbName("TestBean");
+ enterpriseBeans.add(beanMetaData);
+
+ return beanMetaData;
+ }
+
+ private static EjbDeploymentSummary createDeploymentSummary(JBossSessionBeanMetaData beanMetaData)
+ {
+ DeploymentSummary dsummary = new DeploymentSummary();
+ dsummary.setDeploymentName("test-ejb-jar");
+ return new EjbDeploymentSummary(beanMetaData, dsummary);
+ }
+
+ @Test
+ public void testBusinessLocal()
+ {
+ KnownInterfaceType ifaceType = KnownInterfaceType.BUSINESS_LOCAL;
+ String iface = JavaEE6JndiBindingPolicyTest.class.getPackage().getName() + ".Test";
+ String jndiName = policy.getJndiName(singleJarDeploymentSummary, iface, ifaceType);
+ assertEquals("test-ejb-jar/TestBean!" + iface, jndiName);
+ }
+
+ @Test
+ public void testBusinessRemote()
+ {
+ KnownInterfaceType ifaceType = KnownInterfaceType.BUSINESS_REMOTE;
+ String iface = JavaEE6JndiBindingPolicyTest.class.getPackage().getName() + ".Test";
+ String jndiName = policy.getJndiName(singleJarDeploymentSummary, iface, ifaceType);
+ assertEquals("test-ejb-jar/TestBean!" + iface, jndiName);
+ }
+
+ @Test
+ public void testBusinessRemoteInEAR()
+ {
+ JBossSessionBeanMetaData beanMetaData = createBeanMetaData();
+ EjbDeploymentSummary deploymentSummary = createDeploymentSummary(beanMetaData);
+ deploymentSummary.setPackagingType(PackagingType.EAR);
+ deploymentSummary.setDeploymentScopeBaseName("test-ear");
+
+ KnownInterfaceType ifaceType = KnownInterfaceType.BUSINESS_REMOTE;
+ String iface = JavaEE6JndiBindingPolicyTest.class.getPackage().getName() + ".Test";
+ String jndiName = policy.getJndiName(deploymentSummary, iface, ifaceType);
+ assertEquals("test-ear/test-ejb-jar/TestBean!" + iface, jndiName);
+ }
+
+ @Test
+ public void testBusinessRemoteInEARWithRelativePath()
+ {
+ JBossSessionBeanMetaData beanMetaData = createBeanMetaData();
+ EjbDeploymentSummary deploymentSummary = createDeploymentSummary(beanMetaData);
+ deploymentSummary.setPackagingType(PackagingType.EAR);
+ deploymentSummary.setDeploymentScopeBaseName("test-ear");
+ deploymentSummary.setDeploymentPath("a/b");
+
+ KnownInterfaceType ifaceType = KnownInterfaceType.BUSINESS_REMOTE;
+ String iface = JavaEE6JndiBindingPolicyTest.class.getPackage().getName() + ".Test";
+ String jndiName = policy.getJndiName(deploymentSummary, iface, ifaceType);
+ assertEquals("test-ear/a/b/test-ejb-jar/TestBean!" + iface, jndiName);
+ }
+
+ @Test
+ public void testBusinessRemoteWithMappedName()
+ {
+ JBossSessionBeanMetaData beanMetaData = createBeanMetaData();
+ beanMetaData.setMappedName("test-mapped-name");
+ EjbDeploymentSummary deploymentSummary = createDeploymentSummary(beanMetaData);
+
+ KnownInterfaceType ifaceType = KnownInterfaceType.BUSINESS_REMOTE;
+ String iface = JavaEE6JndiBindingPolicyTest.class.getPackage().getName() + ".Test";
+ String jndiName = policy.getJndiName(deploymentSummary, iface, ifaceType);
+ assertEquals("test-ejb-jar/TestBean!" + iface, jndiName);
+ }
+
+ @Test
+ public void testDefaultLocalHomeJndiName()
+ {
+ String jndiName = policy.getDefaultLocalHomeJndiName(singleJarDeploymentSummary);
+ assertEquals("test-ejb-jar/TestBean!localHome", jndiName);
+ }
+
+ @Test
+ public void testDefaultLocalJndiName()
+ {
+ String jndiName = policy.getDefaultLocalJndiName(singleJarDeploymentSummary);
+ assertEquals("test-ejb-jar/TestBean!local", jndiName);
+ }
+
+ @Test
+ public void testDefaultRemoteHomeJndiName()
+ {
+ String jndiName = policy.getDefaultRemoteHomeJndiName(singleJarDeploymentSummary);
+ assertEquals("test-ejb-jar/TestBean!home", jndiName);
+ }
+
+ @Test
+ public void testDefaultRemoteJndiName()
+ {
+ String jndiName = policy.getDefaultRemoteJndiName(singleJarDeploymentSummary);
+ assertEquals("test-ejb-jar/TestBean!remote", jndiName);
+ }
+
+ @Test
+ public void testEjb2LocalHome()
+ {
+ JBossSessionBeanMetaData beanMetaData = createBeanMetaData();
+ beanMetaData.getEjbJarMetaData().setEjbVersion("2.1");
+ EjbDeploymentSummary deploymentSummary = createDeploymentSummary(beanMetaData);
+
+ KnownInterfaceType ifaceType = KnownInterfaceType.LOCAL_HOME;
+ String iface = null;
+ String jndiName = policy.getJndiName(deploymentSummary, iface, ifaceType);
+ assertEquals("local/TestBean@" + System.identityHashCode("TestBean"), jndiName);
+ }
+
+ @Test
+ public void testEjb2LocalHomeWithLocalJndiName()
+ {
+ JBossSessionBeanMetaData beanMetaData = createBeanMetaData();
+ beanMetaData.getEjbJarMetaData().setEjbVersion("2.1");
+ beanMetaData.setLocalJndiName("local-jndi-name");
+ EjbDeploymentSummary deploymentSummary = createDeploymentSummary(beanMetaData);
+
+ KnownInterfaceType ifaceType = KnownInterfaceType.LOCAL_HOME;
+ String iface = null;
+ String jndiName = policy.getJndiName(deploymentSummary, iface, ifaceType);
+ assertEquals("local-jndi-name", jndiName);
+ }
+
+ @Test
+ public void testEjb2RemoteHome()
+ {
+ JBossSessionBeanMetaData beanMetaData = createBeanMetaData();
+ beanMetaData.getEjbJarMetaData().setEjbVersion("2.1");
+ EjbDeploymentSummary deploymentSummary = createDeploymentSummary(beanMetaData);
+
+ KnownInterfaceType ifaceType = KnownInterfaceType.REMOTE_HOME;
+ String iface = null;
+ String jndiName = policy.getJndiName(deploymentSummary, iface, ifaceType);
+ assertEquals("test-ejb-jar/TestBean", jndiName);
+ }
+
+ @Test
+ public void testEjb2RemoteHomeWithMappedName()
+ {
+ JBossSessionBeanMetaData beanMetaData = createBeanMetaData();
+ beanMetaData.getEjbJarMetaData().setEjbVersion("2.1");
+ beanMetaData.setMappedName("mapped-name");
+ EjbDeploymentSummary deploymentSummary = createDeploymentSummary(beanMetaData);
+
+ KnownInterfaceType ifaceType = KnownInterfaceType.REMOTE_HOME;
+ String iface = null;
+ String jndiName = policy.getJndiName(deploymentSummary, iface, ifaceType);
+ assertEquals("mapped-name", jndiName);
+ }
+
+ @Test
+ public void testJndiName()
+ {
+ String jndiName = policy.getJndiName(singleJarDeploymentSummary);
+ assertEquals("test-ejb-jar/TestBean", jndiName);
+ }
+
+ @Test
+ public void testKnownInterface()
+ {
+ KnownInterfaceType ifaceType = KnownInterfaceType.BUSINESS_LOCAL;
+ String iface = "local";
+ String jndiName = policy.getJndiName(singleJarDeploymentSummary, iface, ifaceType);
+ assertEquals("test-ejb-jar/TestBean!" + iface, jndiName);
+ }
+
+ // TODO: as can be seen in the coverage report, this is wicked
+ // I would expect TestBean!local, but that path can't be executed.
+ @Test
+ public void testUnknownInterfaceType()
+ {
+ KnownInterfaceType ifaceType = KnownInterfaceType.UNKNOWN;
+ String iface = "local";
+ String jndiName = policy.getJndiName(singleJarDeploymentSummary, iface, ifaceType);
+ assertEquals("test-ejb-jar/TestBean", jndiName);
+ }
+
+ // TODO: real use-case is unknown to me
+ @Test
+ public void testUnknownLocalHomeInterface()
+ {
+ KnownInterfaceType ifaceType = KnownInterfaceType.LOCAL_HOME;
+ String iface = null;
+ String jndiName = policy.getJndiName(singleJarDeploymentSummary, iface, ifaceType);
+ assertEquals("test-ejb-jar/TestBean!localHome", jndiName);
+ }
+
+ // TODO: real use-case is unknown to me
+ @Test
+ public void testUnknownRemoteBusinessInterface()
+ {
+ KnownInterfaceType ifaceType = KnownInterfaceType.BUSINESS_REMOTE;
+ String iface = null;
+ String jndiName = policy.getJndiName(singleJarDeploymentSummary, iface, ifaceType);
+ assertEquals("test-ejb-jar/TestBean!remote", jndiName);
+ }
+
+ // TODO: real use-case is unknown to me
+ @Test
+ public void testUnknownRemoteBusinessInterfaceWithMappedName()
+ {
+ JBossSessionBeanMetaData beanMetaData = createBeanMetaData();
+ beanMetaData.setMappedName("test-mapped-name");
+ EjbDeploymentSummary deploymentSummary = createDeploymentSummary(beanMetaData);
+
+ KnownInterfaceType ifaceType = KnownInterfaceType.BUSINESS_REMOTE;
+ String iface = null;
+ String jndiName = policy.getJndiName(deploymentSummary, iface, ifaceType);
+ assertEquals("test-mapped-name", jndiName);
+ }
+
+ // TODO: real use-case is unknown to me
+ @Test
+ public void testUnknownRemoteHomeInterface()
+ {
+ KnownInterfaceType ifaceType = KnownInterfaceType.REMOTE_HOME;
+ String iface = null;
+ String jndiName = policy.getJndiName(singleJarDeploymentSummary, iface, ifaceType);
+ assertEquals("test-ejb-jar/TestBean!home", jndiName);
+ }
+
+ // TODO: real use-case is unknown to me
+ @Test
+ public void testUnknownRemoteHomeInterfaceWithHomeJndiName()
+ {
+ JBossSessionBeanMetaData beanMetaData = createBeanMetaData();
+ beanMetaData.setHomeJndiName("home-jndi-name");
+ EjbDeploymentSummary deploymentSummary = createDeploymentSummary(beanMetaData);
+
+ KnownInterfaceType ifaceType = KnownInterfaceType.REMOTE_HOME;
+ String iface = null;
+ String jndiName = policy.getJndiName(deploymentSummary, iface, ifaceType);
+ assertEquals("home-jndi-name", jndiName);
+ }
+
+}
More information about the jboss-cvs-commits
mailing list