You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by Vamsee Lakamsani <va...@yahoo.com.INVALID> on 2014/06/04 17:46:47 UTC

Using custom data source connection factory in JUnit


I have a resource defined like this in tomee.xml and it works fine from TomEE
<Resource id=“myDS" type="javax.sql.DataSource"
       factory-name="createJDBCDataSource" class-name=“my.CustomDataSourceFactory" >
        auth=Application
        singleton = true
</Resource>

Now, I want to test this in JUnit using javax.ejb.embeddable.EJBContainer


This example shows how to use Properties to initialize the data source.  But is there any way I can just pass a javax.sql.DataSource object (created by calling createJDBCDataSource on my factory above directly) to the embeddable EJB container? 
http://tomee.apache.org/examples-trunk/injection-of-datasource/README.html

Re: Using custom data source connection factory in JUnit

Posted by Vamsee Lakamsani <va...@yahoo.com.INVALID>.
The extra properties for the data source is working. It was a typo on my part.

The MyBatis CDI problem went away after I added an empty beans.xml to src/main/resource/META-INF! I had it under src/main/webapp/WEB-INF but understandably the embedded container runs from a Junit test does not look there. 

I added simple MyBatis CDI setup and pushed it that sample repo I created earlier (https://github.com/lakamsani/cdi-nested) 

All good now. Thanks for the prompt responses. 


________________________________
 From: Romain Manni-Bucau <rm...@gmail.com>
To: "users@tomee.apache.org" <us...@tomee.apache.org>; Vamsee Lakamsani <va...@yahoo.com> 
Sent: Wednesday, June 4, 2014 9:51 AM
Subject: Re: Using custom data source connection factory in JUnit
 

can you reproduce it in a sample you can share?


Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau



2014-06-04 18:39 GMT+02:00 Vamsee Lakamsani <va...@yahoo.com.invalid>:
> Getting close. It is calling my factory when I use the syntax you suggested but the .auth (and a few more properties I have) are not getting through. When I look in the debugger when running the unit test,  I just see the two standard ones (ServiceId and transactionManager). I see all of them when debugging via TomEE.
>
> Here's is the line of code where I added the extra properties. Is there another way to pass them in?
>
>  p.put("myDs.auth", "Application");
>
> FYI I use this line to create the embedded container:
> EJBContainer.createEJBContainer(p).getContext().bind("inject", this);
>
>
> On a related topic I have another issue that only shows up in them embedded container via JUnit. To get there I skip the factory for now and specify all the properties to the data source directly in the unit test code. It then gets to a point where it needs a MyBatis  SqlSessionFactory setup using MyBatis CDI like this:
> http://mybatis.github.io/cdi/injection.html
>
>
> All of this works via TomEE but in the embedded container I get this exception. All of the MyBatis CDI unit tests (in their git repo) use Weld/Weld JUnit runner. But given that this works in TomEE I 'm hoping there is someway to get it to work in the embedded OpenEJB container as well.
>
>
> SEVERE - The bean instance PolicyManager threw a system exception:org.mybatis.cdi.MybatisCdiConfigurationException: There are no SqlSessionFactory producers properly configured.
> org.mybatis.cdi.MybatisCdiConfigurationException: There are no SqlSessionFactory producers properly configured.
> at org.mybatis.cdi.CDIUtils.findSqlSessionFactory(CDIUtils.java:47)
> at org.mybatis.cdi.MyBatisBean.findSqlSessionManager(MyBatisBean.java:113)
> at org.mybatis.cdi.MyBatisBean.create(MyBatisBean.java:104)
> at org.apache.webbeans.component.third.ThirdpartyBeanImpl.create(ThirdpartyBeanImpl.java:86)
> at org.apache.webbeans.context.DependentContext.getInstance(DependentContext.java:68)
> at org.apache.webbeans.context.AbstractContext.get(AbstractContext.java:125)
> at org.apache.webbeans.container.BeanManagerImpl.getReference(BeanManagerImpl.java:749)
> at org.apache.webbeans.container.BeanManagerImpl.getInjectableReference(BeanManagerImpl.java:628)
> at org.apache.webbeans.inject.AbstractInjectable.inject(AbstractInjectable.java:95)
> at org.apache.webbeans.inject.InjectableField.doInjection(InjectableField.java:65)
> at org.apache.webbeans.portable.InjectionTargetImpl.injectFields(InjectionTargetImpl.java:208)
> at org.apache.webbeans.portable.InjectionTargetImpl.inject(InjectionTargetImpl.java:194)
> at org.apache.webbeans.portable.InjectionTargetImpl.inject(InjectionTargetImpl.java:184)
> at org.apache.openejb.cdi.CdiEjbBean$EjbInjectionTargetImpl.inject(CdiEjbBean.java:389)
> at org.apache.openejb.BeanContext.inject(BeanContext.java:1662)
> at org.apache.openejb.BeanContext.newInstance(BeanContext.java:1491)
> at org.apache.openejb.core.singleton.SingletonInstanceManager.createInstance(SingletonInstanceManager.java:179)
> at org.apache.openejb.core.singleton.SingletonInstanceManager.access$100(SingletonInstanceManager.java:69)
> at org.apache.openejb.core.singleton.SingletonInstanceManager$1.call(SingletonInstanceManager.java:120)
> at org.apache.openejb.core.singleton.SingletonInstanceManager$1.call(SingletonInstanceManager.java:118)
> at java.util.concurrent.FutureTask.run(FutureTask.java:262)
> at org.apache.openejb.core.singleton.SingletonInstanceManager.getInstance(SingletonInstanceManager.java:129)
> at org.apache.openejb.core.singleton.SingletonInstanceManager.initialize(SingletonInstanceManager.java:93)
> at org.apache.openejb.core.singleton.SingletonInstanceManager.start(SingletonInstanceManager.java:84)
> at org.apache.openejb.core.singleton.SingletonContainer.start(SingletonContainer.java:125)
> at org.apache.openejb.assembler.classic.Assembler.startEjbs(Assembler.java:1160)
> at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:816)
> at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:623)
> at org.apache.openejb.OpenEjbContainer$Provider.createEJBContainer(OpenEjbContainer.java:335)
> at javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:56)
> at com.ca.mdo.policy.PolicyManagerTest.setUp(PolicyManagerTest.java:41)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:606)
> at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
> at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
> at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
> at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
> at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
> at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
> at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
> at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
> at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
> at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
> at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
> at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
> at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
> at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
> at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
>
>
>
> ________________________________
>  From: Romain Manni-Bucau <rm...@gmail.com>
> To: "users@tomee.apache.org" <us...@tomee.apache.org>; Vamsee Lakamsani <va...@yahoo.com>
> Sent: Wednesday, June 4, 2014 9:04 AM
> Subject: Re: Using custom data source connection factory in JUnit
>
>
> myDs = new://Resource?type=DataSource&class-name=....&factory-name=...
> myDs.auth=Application
> ....
>
>
> as properties should work
>
>
> Romain Manni-Bucau
> Twitter: @rmannibucau
> Blog: http://rmannibucau.wordpress.com/
> LinkedIn: http://fr.linkedin.com/in/rmannibucau
> Github: https://github.com/rmannibucau
>
>
>
> 2014-06-04 17:46 GMT+02:00 Vamsee Lakamsani <va...@yahoo.com.invalid>:
>>
>>
>> I have a resource defined like this in tomee.xml and it works fine from TomEE
>> <Resource id=“myDS" type="javax.sql.DataSource"
>>        factory-name="createJDBCDataSource" class-name=“my.CustomDataSourceFactory" >
>>         auth=Application
>>         singleton = true
>> </Resource>
>>
>> Now, I want to test this in JUnit using javax.ejb.embeddable.EJBContainer
>>
>>
>> This example shows how to use Properties to initialize the data source.  But is there any way I can just pass a javax.sql.DataSource object (created by calling createJDBCDataSource on my factory above directly) to the embeddable EJB container?
>> http://tomee.apache.org/examples-trunk/injection-of-datasource/README.html

Re: Using custom data source connection factory in JUnit

Posted by Romain Manni-Bucau <rm...@gmail.com>.
can you reproduce it in a sample you can share?


Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau


2014-06-04 18:39 GMT+02:00 Vamsee Lakamsani <va...@yahoo.com.invalid>:
> Getting close. It is calling my factory when I use the syntax you suggested but the .auth (and a few more properties I have) are not getting through. When I look in the debugger when running the unit test,  I just see the two standard ones (ServiceId and transactionManager). I see all of them when debugging via TomEE.
>
> Here's is the line of code where I added the extra properties. Is there another way to pass them in?
>
>  p.put("myDs.auth", "Application");
>
> FYI I use this line to create the embedded container:
> EJBContainer.createEJBContainer(p).getContext().bind("inject", this);
>
>
> On a related topic I have another issue that only shows up in them embedded container via JUnit. To get there I skip the factory for now and specify all the properties to the data source directly in the unit test code. It then gets to a point where it needs a MyBatis  SqlSessionFactory setup using MyBatis CDI like this:
> http://mybatis.github.io/cdi/injection.html
>
>
> All of this works via TomEE but in the embedded container I get this exception. All of the MyBatis CDI unit tests (in their git repo) use Weld/Weld JUnit runner. But given that this works in TomEE I 'm hoping there is someway to get it to work in the embedded OpenEJB container as well.
>
>
> SEVERE - The bean instance PolicyManager threw a system exception:org.mybatis.cdi.MybatisCdiConfigurationException: There are no SqlSessionFactory producers properly configured.
> org.mybatis.cdi.MybatisCdiConfigurationException: There are no SqlSessionFactory producers properly configured.
> at org.mybatis.cdi.CDIUtils.findSqlSessionFactory(CDIUtils.java:47)
> at org.mybatis.cdi.MyBatisBean.findSqlSessionManager(MyBatisBean.java:113)
> at org.mybatis.cdi.MyBatisBean.create(MyBatisBean.java:104)
> at org.apache.webbeans.component.third.ThirdpartyBeanImpl.create(ThirdpartyBeanImpl.java:86)
> at org.apache.webbeans.context.DependentContext.getInstance(DependentContext.java:68)
> at org.apache.webbeans.context.AbstractContext.get(AbstractContext.java:125)
> at org.apache.webbeans.container.BeanManagerImpl.getReference(BeanManagerImpl.java:749)
> at org.apache.webbeans.container.BeanManagerImpl.getInjectableReference(BeanManagerImpl.java:628)
> at org.apache.webbeans.inject.AbstractInjectable.inject(AbstractInjectable.java:95)
> at org.apache.webbeans.inject.InjectableField.doInjection(InjectableField.java:65)
> at org.apache.webbeans.portable.InjectionTargetImpl.injectFields(InjectionTargetImpl.java:208)
> at org.apache.webbeans.portable.InjectionTargetImpl.inject(InjectionTargetImpl.java:194)
> at org.apache.webbeans.portable.InjectionTargetImpl.inject(InjectionTargetImpl.java:184)
> at org.apache.openejb.cdi.CdiEjbBean$EjbInjectionTargetImpl.inject(CdiEjbBean.java:389)
> at org.apache.openejb.BeanContext.inject(BeanContext.java:1662)
> at org.apache.openejb.BeanContext.newInstance(BeanContext.java:1491)
> at org.apache.openejb.core.singleton.SingletonInstanceManager.createInstance(SingletonInstanceManager.java:179)
> at org.apache.openejb.core.singleton.SingletonInstanceManager.access$100(SingletonInstanceManager.java:69)
> at org.apache.openejb.core.singleton.SingletonInstanceManager$1.call(SingletonInstanceManager.java:120)
> at org.apache.openejb.core.singleton.SingletonInstanceManager$1.call(SingletonInstanceManager.java:118)
> at java.util.concurrent.FutureTask.run(FutureTask.java:262)
> at org.apache.openejb.core.singleton.SingletonInstanceManager.getInstance(SingletonInstanceManager.java:129)
> at org.apache.openejb.core.singleton.SingletonInstanceManager.initialize(SingletonInstanceManager.java:93)
> at org.apache.openejb.core.singleton.SingletonInstanceManager.start(SingletonInstanceManager.java:84)
> at org.apache.openejb.core.singleton.SingletonContainer.start(SingletonContainer.java:125)
> at org.apache.openejb.assembler.classic.Assembler.startEjbs(Assembler.java:1160)
> at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:816)
> at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:623)
> at org.apache.openejb.OpenEjbContainer$Provider.createEJBContainer(OpenEjbContainer.java:335)
> at javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:56)
> at com.ca.mdo.policy.PolicyManagerTest.setUp(PolicyManagerTest.java:41)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:606)
> at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
> at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
> at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
> at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
> at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
> at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
> at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
> at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
> at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
> at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
> at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
> at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
> at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
> at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
> at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
>
>
>
> ________________________________
>  From: Romain Manni-Bucau <rm...@gmail.com>
> To: "users@tomee.apache.org" <us...@tomee.apache.org>; Vamsee Lakamsani <va...@yahoo.com>
> Sent: Wednesday, June 4, 2014 9:04 AM
> Subject: Re: Using custom data source connection factory in JUnit
>
>
> myDs = new://Resource?type=DataSource&class-name=....&factory-name=...
> myDs.auth=Application
> ....
>
>
> as properties should work
>
>
> Romain Manni-Bucau
> Twitter: @rmannibucau
> Blog: http://rmannibucau.wordpress.com/
> LinkedIn: http://fr.linkedin.com/in/rmannibucau
> Github: https://github.com/rmannibucau
>
>
>
> 2014-06-04 17:46 GMT+02:00 Vamsee Lakamsani <va...@yahoo.com.invalid>:
>>
>>
>> I have a resource defined like this in tomee.xml and it works fine from TomEE
>> <Resource id=“myDS" type="javax.sql.DataSource"
>>        factory-name="createJDBCDataSource" class-name=“my.CustomDataSourceFactory" >
>>         auth=Application
>>         singleton = true
>> </Resource>
>>
>> Now, I want to test this in JUnit using javax.ejb.embeddable.EJBContainer
>>
>>
>> This example shows how to use Properties to initialize the data source.  But is there any way I can just pass a javax.sql.DataSource object (created by calling createJDBCDataSource on my factory above directly) to the embeddable EJB container?
>> http://tomee.apache.org/examples-trunk/injection-of-datasource/README.html

Re: Using custom data source connection factory in JUnit

Posted by Vamsee Lakamsani <va...@yahoo.com.INVALID>.
Getting close. It is calling my factory when I use the syntax you suggested but the .auth (and a few more properties I have) are not getting through. When I look in the debugger when running the unit test,  I just see the two standard ones (ServiceId and transactionManager). I see all of them when debugging via TomEE. 

Here's is the line of code where I added the extra properties. Is there another way to pass them in?

 p.put("myDs.auth", "Application");

FYI I use this line to create the embedded container:
EJBContainer.createEJBContainer(p).getContext().bind("inject", this);


On a related topic I have another issue that only shows up in them embedded container via JUnit. To get there I skip the factory for now and specify all the properties to the data source directly in the unit test code. It then gets to a point where it needs a MyBatis  SqlSessionFactory setup using MyBatis CDI like this:
http://mybatis.github.io/cdi/injection.html


All of this works via TomEE but in the embedded container I get this exception. All of the MyBatis CDI unit tests (in their git repo) use Weld/Weld JUnit runner. But given that this works in TomEE I 'm hoping there is someway to get it to work in the embedded OpenEJB container as well. 


SEVERE - The bean instance PolicyManager threw a system exception:org.mybatis.cdi.MybatisCdiConfigurationException: There are no SqlSessionFactory producers properly configured.
org.mybatis.cdi.MybatisCdiConfigurationException: There are no SqlSessionFactory producers properly configured.
at org.mybatis.cdi.CDIUtils.findSqlSessionFactory(CDIUtils.java:47)
at org.mybatis.cdi.MyBatisBean.findSqlSessionManager(MyBatisBean.java:113)
at org.mybatis.cdi.MyBatisBean.create(MyBatisBean.java:104)
at org.apache.webbeans.component.third.ThirdpartyBeanImpl.create(ThirdpartyBeanImpl.java:86)
at org.apache.webbeans.context.DependentContext.getInstance(DependentContext.java:68)
at org.apache.webbeans.context.AbstractContext.get(AbstractContext.java:125)
at org.apache.webbeans.container.BeanManagerImpl.getReference(BeanManagerImpl.java:749)
at org.apache.webbeans.container.BeanManagerImpl.getInjectableReference(BeanManagerImpl.java:628)
at org.apache.webbeans.inject.AbstractInjectable.inject(AbstractInjectable.java:95)
at org.apache.webbeans.inject.InjectableField.doInjection(InjectableField.java:65)
at org.apache.webbeans.portable.InjectionTargetImpl.injectFields(InjectionTargetImpl.java:208)
at org.apache.webbeans.portable.InjectionTargetImpl.inject(InjectionTargetImpl.java:194)
at org.apache.webbeans.portable.InjectionTargetImpl.inject(InjectionTargetImpl.java:184)
at org.apache.openejb.cdi.CdiEjbBean$EjbInjectionTargetImpl.inject(CdiEjbBean.java:389)
at org.apache.openejb.BeanContext.inject(BeanContext.java:1662)
at org.apache.openejb.BeanContext.newInstance(BeanContext.java:1491)
at org.apache.openejb.core.singleton.SingletonInstanceManager.createInstance(SingletonInstanceManager.java:179)
at org.apache.openejb.core.singleton.SingletonInstanceManager.access$100(SingletonInstanceManager.java:69)
at org.apache.openejb.core.singleton.SingletonInstanceManager$1.call(SingletonInstanceManager.java:120)
at org.apache.openejb.core.singleton.SingletonInstanceManager$1.call(SingletonInstanceManager.java:118)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at org.apache.openejb.core.singleton.SingletonInstanceManager.getInstance(SingletonInstanceManager.java:129)
at org.apache.openejb.core.singleton.SingletonInstanceManager.initialize(SingletonInstanceManager.java:93)
at org.apache.openejb.core.singleton.SingletonInstanceManager.start(SingletonInstanceManager.java:84)
at org.apache.openejb.core.singleton.SingletonContainer.start(SingletonContainer.java:125)
at org.apache.openejb.assembler.classic.Assembler.startEjbs(Assembler.java:1160)
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:816)
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:623)
at org.apache.openejb.OpenEjbContainer$Provider.createEJBContainer(OpenEjbContainer.java:335)
at javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:56)
at com.ca.mdo.policy.PolicyManagerTest.setUp(PolicyManagerTest.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)



________________________________
 From: Romain Manni-Bucau <rm...@gmail.com>
To: "users@tomee.apache.org" <us...@tomee.apache.org>; Vamsee Lakamsani <va...@yahoo.com> 
Sent: Wednesday, June 4, 2014 9:04 AM
Subject: Re: Using custom data source connection factory in JUnit
 

myDs = new://Resource?type=DataSource&class-name=....&factory-name=...
myDs.auth=Application
....


as properties should work


Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau



2014-06-04 17:46 GMT+02:00 Vamsee Lakamsani <va...@yahoo.com.invalid>:
>
>
> I have a resource defined like this in tomee.xml and it works fine from TomEE
> <Resource id=“myDS" type="javax.sql.DataSource"
>        factory-name="createJDBCDataSource" class-name=“my.CustomDataSourceFactory" >
>         auth=Application
>         singleton = true
> </Resource>
>
> Now, I want to test this in JUnit using javax.ejb.embeddable.EJBContainer
>
>
> This example shows how to use Properties to initialize the data source.  But is there any way I can just pass a javax.sql.DataSource object (created by calling createJDBCDataSource on my factory above directly) to the embeddable EJB container?
> http://tomee.apache.org/examples-trunk/injection-of-datasource/README.html

Re: Using custom data source connection factory in JUnit

Posted by Romain Manni-Bucau <rm...@gmail.com>.
myDs = new://Resource?type=DataSource&class-name=....&factory-name=...
myDs.auth=Application
....


as properties should work


Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau


2014-06-04 17:46 GMT+02:00 Vamsee Lakamsani <va...@yahoo.com.invalid>:
>
>
> I have a resource defined like this in tomee.xml and it works fine from TomEE
> <Resource id=“myDS" type="javax.sql.DataSource"
>        factory-name="createJDBCDataSource" class-name=“my.CustomDataSourceFactory" >
>         auth=Application
>         singleton = true
> </Resource>
>
> Now, I want to test this in JUnit using javax.ejb.embeddable.EJBContainer
>
>
> This example shows how to use Properties to initialize the data source.  But is there any way I can just pass a javax.sql.DataSource object (created by calling createJDBCDataSource on my factory above directly) to the embeddable EJB container?
> http://tomee.apache.org/examples-trunk/injection-of-datasource/README.html