RE: Override annotations in ejb-jar.xml for a test case

2008-10-09 Thread Marcin Kwapisz
Hi,

 We don't have any functionality for supplying an alternate ejb-jar.xml
 for testing purposes.  It's not a bad idea and is something we might
 be able to add after we get the 3.1 release out the door.

[Marcin Kwapisz] 
My Maven2 profile is as follows. resource directs to folder 
src/test/resources/Toplink (METAINF) where modified ejb-jar.xml and 
persistence.xml exist.
profile
idTestEJB_Toplink/id
activation
property
nameenv/name
valuetesttoplink/value
/property
/activation
dependencies
dependency
groupIdtoplink.essentials/groupId
artifactIdtoplink-essentials-agent/artifactId
version2.1-53/version
scopetest/scope
/dependency
dependency
groupIdtoplink.essentials/groupId
artifactIdtoplink-essentials/artifactId
version2.1-53/version
scopetest/scope
/dependency
dependency
groupIdzsk.samples/groupId
artifactIdToplinkExternalContainer/artifactId
version1.0/version
scopetest/scope
/dependency
/dependencies
build
resources
resource
directorysrc/test/resources/Toplink/directory
/resource
/resources
/build
/profile

 This might be because the ejb-jar.xml is with the ejbs that are
 annotated.
[Marcin Kwapisz] 
Correct me if I am wrong: when ejb-jar is empty OpenEJB process all class files 
(in classes and test-classes) and looks for annotated EJBs. When ejb-jar is 
modified, OpenEJB process that file and looks for annotated EJBs in 
test-classes only.

Regards
-- 
Marcin Kwapisz
Division of Computer Networks
Technical Univeristy of Lodz, Poland





Re: Override annotations in ejb-jar.xml for a test case

2008-10-09 Thread David Blevins


On Oct 9, 2008, at 3:16 AM, Marcin Kwapisz wrote:

Correct me if I am wrong: when ejb-jar is empty OpenEJB process all  
class files (in classes and test-classes) and looks for annotated  
EJBs. When ejb-jar is modified, OpenEJB process that file and looks  
for annotated EJBs in test-classes only.


We look for annotated ejbs in classes/ if we find a classes/META-INF/ 
ejb-jar.xml file and the ejb-jar.xml file does not have 'metadata- 
complete' attribute set to 'true'.  Aside from the metadata-complete  
attribute, the contents of the ejb-jar.xml do not prevent searching  
for annotations or annotated ejbs.  The classes/ directory is treated  
as a single ejb jar and the contents of the classes/META-INF/ejb- 
jar.xml apply only to the beans in classes/.


The same rule applies for test-classes/.  Specifically, we look for  
annotated ejbs in test-classes/ if we find a test-classes/META-INF/ejb- 
jar.xml file and the ejb-jar.xml file does not have 'metadata- 
complete' attribute set to 'true' and the test-classes/ directory is  
treated as a single ejb jar, separate from classes/, and the contents  
of the test-classes/META-INF/ejb-jar.xml apply only to the beans in  
test-classes/.


Hope that helps.

-David



Re: Override annotations in ejb-jar.xml for a test case

2008-10-08 Thread David Blevins


On Sep 22, 2008, at 5:33 AM, Marcin Kwapisz wrote:


Hi,

I would like to add an interceptor to my EJB but only in a test. I  
have separate ejb-jar.xml for tests and all my EJBs are annotated.


We don't have any functionality for supplying an alternate ejb-jar.xml  
for testing purposes.  It's not a bad idea and is something we might  
be able to add after we get the 3.1 release out the door.



When ejb-jar.xml is empty everything works fine. When I change ejb- 
jar and add for example:


assembly-descriptor
   interceptor-binding
   ejb-nameStudentEndpointBean/ejb-name
   interceptor- 
classpl.zsk.sos.interceptor.TestInterceptor/interceptor-class

   /interceptor-binding
   /assembly-descriptor

automatic configuration does not find my EJBs and I get  
javax.naming.NameNotFoundException


This might be because the ejb-jar.xml is with the ejbs that are  
annotated.


A small workaround might be to add an interceptor to your main app and  
have it look for a special system property of your creation in its  
constructor.  The system property can be the name of an interceptor  
class that it should delegate to.  If the system property is not  
specified then it does nothing.  The test case could set the special  
system property to point to pl.zsk.sos.interceptor.TestInterceptor or  
any other interceptor you wish to write for a given test case.  You  
could potentially then have an interceptor dedicated to each test case  
to help with testing yet still only have one active at a time.



-David