[jboss-cvs] JBossAS SVN: r85151 - in projects/ejb3/trunk: testsuite and 6 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Mar 3 04:13:09 EST 2009
Author: jaikiran
Date: 2009-03-03 04:13:09 -0500 (Tue, 03 Mar 2009)
New Revision: 85151
Added:
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1629/
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1629/Ejb3DescriptorHandlerTestBean.java
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1629/Ejb3DescriptorHandlerTestRemote.java
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1629/unit/
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1629/unit/Ejb3DescriptorHandlerPrimitiveHandlingTestCase.java
projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree1629/
projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree1629/META-INF/
projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree1629/META-INF/ejb-jar.xml
Modified:
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/Ejb3DescriptorHandler.java
projects/ejb3/trunk/testsuite/build-test.xml
Log:
EJBTHREE-1629 Fixed the Ejb3DescriptorHandler which was not handling the entire set of primitive types
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/Ejb3DescriptorHandler.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/Ejb3DescriptorHandler.java 2009-03-03 07:18:28 UTC (rev 85150)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/Ejb3DescriptorHandler.java 2009-03-03 09:13:09 UTC (rev 85151)
@@ -132,6 +132,7 @@
import org.jboss.ejb3.annotation.impl.TransactionAttributeImpl;
import org.jboss.ejb3.annotation.impl.TransactionManagementImpl;
import org.jboss.ejb3.annotation.impl.TransactionTimeoutImpl;
+import org.jboss.ejb3.common.classloader.PrimitiveAwareClassLoader;
import org.jboss.ejb3.common.lang.ClassHelper;
import org.jboss.ejb3.interceptor.InterceptorInfoRepository;
import org.jboss.ejb3.mdb.ConsumerContainer;
@@ -2187,21 +2188,7 @@
int paramIndex = 0;
for(String param : params)
{
- Class<?> paramClass = null;
- if (param.equals("boolean"))
- paramClass = boolean.class;
- else if (param.equals("int"))
- paramClass = int.class;
- else if (param.equals("long"))
- paramClass = long.class;
- else if (param.equals("short"))
- paramClass = short.class;
- else if (param.equals("byte"))
- paramClass = byte.class;
- else if (param.equals("char"))
- paramClass = char.class;
- else
- paramClass = di.getClassLoader().loadClass(param);
+ Class<?> paramClass = new PrimitiveAwareClassLoader(di.getClassLoader()).loadClass(param);
methodSignature[paramIndex++] = paramClass;
}
if(log.isTraceEnabled())
Modified: projects/ejb3/trunk/testsuite/build-test.xml
===================================================================
--- projects/ejb3/trunk/testsuite/build-test.xml 2009-03-03 07:18:28 UTC (rev 85150)
+++ projects/ejb3/trunk/testsuite/build-test.xml 2009-03-03 09:13:09 UTC (rev 85151)
@@ -282,6 +282,12 @@
<jvmarg value="${ejb3.jboss.jvmargs}" />
</server>
+ <!-- ejbthree1629 -->
+ <server name="ejbthree1629" host="${node0}">
+ <jvmarg value="${ejb3.jboss.jvmargs}" />
+ </server>
+
+
</server:config>
<!-- =================== -->
@@ -4244,6 +4250,24 @@
</fileset>
</jar>
</target>
+
+ <target name="ejbthree1629"
+ description="Builds the jar file(s) needed for testing EJBTHREE-1629."
+ >
+
+ <delete file="${build.lib}/ejbthree1629.jar"/>
+ <mkdir dir="${build.lib}"/>
+
+ <jar jarfile="${build.lib}/ejbthree1629.jar">
+ <fileset dir="${build.classes}">
+ <include name="org/jboss/ejb3/test/ejbthree1629/*.class"/>
+ </fileset>
+ <fileset dir="${resources}/test/ejbthree1629">
+ <include name="META-INF/*.xml"/>
+ </fileset>
+ </jar>
+ </target>
+
<target name="jars" depends="statefulproxyfactoryoverride, removedislocal, statelesscreation, defaultremotebindings, localfromremote, clusteredjms, entityoptimisticlocking, concurrentnaming, propertyreplacement, persistenceunits, appclient, tck5sec, invalidtxmdb, descriptortypo, libdeployment, homeinterface, arjuna, mdbtransactions, unauthenticatedprincipal, clusteredservice, invoker, classloader,
concurrent,
@@ -4273,7 +4297,7 @@
timer, benchmark, entity, joininheritance, singletable, tableperclass, dependent, mdb, manytomany, regression,
composite, composite2, entitycallback, relationships, ssl, ssladvanced, clusteredsession, strictpool, jacc,
localcall, interceptors, interceptors2, interceptors3, iiop, clientinterceptor,
- statelesscreation, changexml, externalrefscoped, singleton, ejbthree1671, ejbthree1677"/>
+ statelesscreation, changexml, externalrefscoped, singleton, ejbthree1671, ejbthree1677, ejbthree1629"/>
<target name="test" depends="init" if="test"
description="Execute all tests in the given test directory.">
Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1629/Ejb3DescriptorHandlerTestBean.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1629/Ejb3DescriptorHandlerTestBean.java (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1629/Ejb3DescriptorHandlerTestBean.java 2009-03-03 09:13:09 UTC (rev 85151)
@@ -0,0 +1,86 @@
+/*
+ * 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.ejb3.test.ejbthree1629;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+
+import org.jboss.ejb3.annotation.RemoteBinding;
+
+/**
+ * Ejb3DescriptorHandlerTestBean
+ *
+ * Will be used for testing EJBTHREE-1629 issue. The issue happens
+ * only when the methods have a annotaiton present like @TransactionAttribute
+ * and accept primitive type parameters (especially double or float). To reproduce
+ * the issue, there needs to be a entry for this bean in the ejb-jar.xml too, minimally
+ * just the ejb-name and ejb-class.
+ *
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+ at Stateless
+ at Remote(Ejb3DescriptorHandlerTestRemote.class)
+ at RemoteBinding(jndiBinding = Ejb3DescriptorHandlerTestBean.JNDI_NAME)
+public class Ejb3DescriptorHandlerTestBean implements Ejb3DescriptorHandlerTestRemote
+{
+
+ /**
+ * Not appropriate to expose the JNDI_NAME through this class, since
+ * the client will have to be aware of the bean implementation class.
+ * But since this is just being used by a testcase, we are OK.
+ */
+ public static final String JNDI_NAME = "PrimitiveTesterWithTransactionBean at SomeJNDIName";
+
+ @TransactionAttribute (TransactionAttributeType.REQUIRED)
+ public double doOpAndReturnDouble(double someDouble)
+ {
+ return someDouble;
+ }
+
+ @TransactionAttribute (TransactionAttributeType.REQUIRED)
+ public float doOpAndReturnFloat(float someFloat)
+ {
+ return someFloat;
+ }
+
+ @TransactionAttribute (TransactionAttributeType.REQUIRED)
+ public double[] doOpAndReturnDouble(double[] someDouble)
+ {
+ return someDouble;
+ }
+
+ @TransactionAttribute (TransactionAttributeType.REQUIRED)
+ public float[] doOpAndReturnFloat(float[] someFloat)
+ {
+ return someFloat;
+ }
+
+ public String sayHi(String name)
+ {
+ return "Hi " + name;
+ }
+
+}
Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1629/Ejb3DescriptorHandlerTestRemote.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1629/Ejb3DescriptorHandlerTestRemote.java (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1629/Ejb3DescriptorHandlerTestRemote.java 2009-03-03 09:13:09 UTC (rev 85151)
@@ -0,0 +1,44 @@
+/*
+ * 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.ejb3.test.ejbthree1629;
+
+import javax.ejb.Remote;
+
+/**
+ * PrimitiveTesterRemote
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+ at Remote
+public interface Ejb3DescriptorHandlerTestRemote
+{
+ double doOpAndReturnDouble(double someDouble);
+
+ double[] doOpAndReturnDouble(double[] someDouble);
+
+ float[] doOpAndReturnFloat(float[] someFloat);
+
+ float doOpAndReturnFloat(float someFloat);
+
+ String sayHi(String name);
+}
Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1629/unit/Ejb3DescriptorHandlerPrimitiveHandlingTestCase.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1629/unit/Ejb3DescriptorHandlerPrimitiveHandlingTestCase.java (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1629/unit/Ejb3DescriptorHandlerPrimitiveHandlingTestCase.java 2009-03-03 09:13:09 UTC (rev 85151)
@@ -0,0 +1,116 @@
+/*
+ * 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.ejb3.test.ejbthree1629.unit;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import junit.framework.Test;
+
+import org.jboss.ejb3.test.ejbthree1629.Ejb3DescriptorHandlerTestBean;
+import org.jboss.ejb3.test.ejbthree1629.Ejb3DescriptorHandlerTestRemote;
+import org.jboss.logging.Logger;
+import org.jboss.test.JBossTestCase;
+
+/**
+ * Ejb3DescriptorHandlerPrimitiveHandlingTestCase
+ *
+ * Test case for EJBTHREE-1629 issue.
+ * Incorrect handling of primitives. The issue arises when there's a bean method
+ * accepting a primitive type (double or float) and also has an annotation on the
+ * method (ex: @TransactionAttribute). Furthermore, the bean needs to have a
+ * corresponding entry (minimally ejb-name and ejb-class) in ejb-jar.xml, for this
+ * issue to manifest.
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class Ejb3DescriptorHandlerPrimitiveHandlingTestCase extends JBossTestCase
+{
+
+ /**
+ * Logger
+ */
+ private static final Logger logger = Logger.getLogger(Ejb3DescriptorHandlerPrimitiveHandlingTestCase.class);
+
+ /**
+ * Constructor
+ *
+ * @param name
+ */
+ public Ejb3DescriptorHandlerPrimitiveHandlingTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite() throws Exception
+ {
+ return getDeploySetup(Ejb3DescriptorHandlerPrimitiveHandlingTestCase.class, "ejbthree1629.jar");
+ }
+
+ /**
+ * Test that the bean has been deployed and available for
+ * method invocations.
+ *
+ * @throws Throwable
+ */
+ public void testBeanInvocation() throws Throwable
+ {
+ Context ctx = new InitialContext();
+ String jndiName = Ejb3DescriptorHandlerTestBean.JNDI_NAME;
+ Object bean = ctx.lookup(jndiName);
+ logger.info("Successfully looked up the bean at " + jndiName);
+
+ assertNotNull("Object returned from JNDI lookup for " + jndiName + " is null", bean);
+ assertTrue("Object returned from JNDI lookup for " + jndiName + " is not an instance of "
+ + Ejb3DescriptorHandlerTestRemote.class, (bean instanceof Ejb3DescriptorHandlerTestRemote));
+
+ // Call the method on the bean
+ Ejb3DescriptorHandlerTestRemote primitiveTesterBean = (Ejb3DescriptorHandlerTestRemote) bean;
+ double someDouble = 2.0;
+ double returnedDouble = primitiveTesterBean.doOpAndReturnDouble(someDouble);
+ assertEquals("Bean returned unexpected value for primitive double",returnedDouble, someDouble);
+
+ // test on float
+ float someFloat = 2.5F;
+ float returnedFloat = primitiveTesterBean.doOpAndReturnFloat(someFloat);
+ assertEquals("Bean returned unexpected value for primitive float",returnedFloat, someFloat);
+
+ // test on arrays
+ float[] floatArray = new float[]{someFloat};
+ float[] returnedFloatArray = primitiveTesterBean.doOpAndReturnFloat(floatArray);
+ assertEquals("Bean returned unexpected value for primitive float array",returnedFloatArray.length, floatArray.length);
+ assertEquals("Bean returned unexpected value for primitive float array contents",returnedFloatArray[0], floatArray[0]);
+
+ double[] doubleArray = new double[]{someDouble};
+ double[] returnedDoubleArray = primitiveTesterBean.doOpAndReturnDouble(doubleArray);
+ assertEquals("Bean returned unexpected value for primitive double array",returnedDoubleArray.length, doubleArray.length);
+ assertEquals("Bean returned unexpected value for primitive double array contents",returnedDoubleArray[0], doubleArray[0]);
+
+ // now some simple method which says hi
+ String name = "jai";
+ String returnedMessage = primitiveTesterBean.sayHi(name);
+ assertEquals("Bean returned unexpected message", returnedMessage, "Hi " + name);
+
+ }
+
+}
Added: projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree1629/META-INF/ejb-jar.xml
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree1629/META-INF/ejb-jar.xml (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree1629/META-INF/ejb-jar.xml 2009-03-03 09:13:09 UTC (rev 85151)
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ejb-jar
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
+ version="3.0">
+
+ <enterprise-beans>
+
+ <session>
+ <ejb-name>Ejb3DescriptorHandlerTestBean</ejb-name>
+ <ejb-class>org.jboss.ejb3.test.ejbthree1629.Ejb3DescriptorHandlerTestBean</ejb-class>
+ </session>
+
+
+ </enterprise-beans>
+
+
+
+</ejb-jar>
More information about the jboss-cvs-commits
mailing list