Re: How do you unit test services with dependent services

2014-01-22 Thread Lance Java
You can use IOCUtilities.addDefaultModules(RegistryBuilder) To scan the classpath for META-INF entries. On 21 Jan 2014 19:47, "George Christman" wrote: > and that is the easiest way to do it ugh lol > > > On Tue, Jan 21, 2014 at 2:30 PM, Dragan Sahpaski > wrote: > > > You have to manually add A

Re: How do you unit test services with dependent services

2014-01-22 Thread Lance Java
I think it would be easy enough to create a TapestryJUnit4ClassRunner which is similar to SpringJUnit4ClassRunner. eg: @RunWith(TapestryJUnit4ClassRunner.class) @Modules({SecurityModule.class, HibernateModule.class, MyTestModule.class}) @ModuleDefs({SpringModuleDef.class}) public class MyIOCTest

Re: How do you unit test services with dependent services

2014-01-21 Thread Dragan Sahpaski
Alternatively use the @SubModule in your AppModule which is not needed for a webapp because when starting the tapestry filter, tapestry autoloads the ioc modules for all jars on the classpath. This is very well documented here http://tapestry.apache.org/autoloading-modules.html You can see the cod

Re: How do you unit test services with dependent services

2014-01-21 Thread Dmitry Gusev
As Dragan said, you have to add all modules manually. In the thread I've posted a link to above you can find some references, like here: https://gist.github.com/dmitrygusev/6672859#file-baseintegrationtest-java-L11-L18 Notice, the class also extends AbstractShiroTest, because some additional setu

Re: How do you unit test services with dependent services

2014-01-21 Thread George Christman
Am I going about this all the wrong way? Am I using the services correctly? I never see in any example test code where you guys are having to add all the modules. Any suggestions? On Tue, Jan 21, 2014 at 2:47 PM, George Christman wrote: > and that is the easiest way to do it ugh lol > > > On Tue

Re: How do you unit test services with dependent services

2014-01-21 Thread George Christman
and that is the easiest way to do it ugh lol On Tue, Jan 21, 2014 at 2:30 PM, Dragan Sahpaski wrote: > You have to manually add ALL the tapestry IOC modules you're using (in this > case the tapestry-security module > org.tynamo.security.services.SecurityModule), because you're starting only > th

Re: How do you unit test services with dependent services

2014-01-21 Thread Dragan Sahpaski
You have to manually add ALL the tapestry IOC modules you're using (in this case the tapestry-security module org.tynamo.security.services.SecurityModule), because you're starting only the Registry and not the entire webapp. Cheers, Dragan Sahpaski On Tue, Jan 21, 2014 at 8:22 PM, George Christm

Re: How do you unit test services with dependent services

2014-01-21 Thread George Christman
Dmitry, I'm very confused. I use constructor injection in my services which I always thought was the correct way to do it based on the tap docs. I have the following test class where I'm trying to use a service. public class TimeSheetServiceTest { protected static TimeSheetService timeSheetS

Re: How do you unit test services with dependent services

2014-01-21 Thread Dmitry Gusev
Right, this is for integration testing. I use mocking too, but rarely -- my tests are 80% integration ones and involve DB (the same as in production). For mocks I have to use constructor injection also, and this is the only reason why I use constructor injections. The code looks ugly in this cases,

Re: How do you unit test services with dependent services

2014-01-21 Thread Dmitry Gusev
Here's one recent thread that on the same subject: http://apache-tapestry-mailing-list-archives.1045711.n5.nabble.com/Testing-Tapestry-td5723590.html On Tue, Jan 21, 2014 at 9:41 PM, Dragan Sahpaski wrote: > I agree with Dimitry but thats more for integration like testing. > For basic unit testi

Re: How do you unit test services with dependent services

2014-01-21 Thread Dragan Sahpaski
I agree with Dimitry but thats more for integration like testing. For basic unit testing of services methods (usually we unit test a single method per test) we mock the dependencies (the injected services) and pass the mocks through the constructor of the service implementation class under test. Th

Re: How do you unit test services with dependent services

2014-01-21 Thread Dmitry Gusev
I usually create base class where I construct registry instance, then I use registry.getService(Intf.class) when I need an instance of a service. Like here: https://github.com/anjlab/anjlab-tapestry-commons/blob/master/anjlab-tapestry-quartz/src/test/java/com/anjlab/tapestry5/services/quartz/Sched

Re: How do you unit test services with dependent services

2014-01-21 Thread Nourredine K.
Hi, Just use the PageTester#getServicemethod in your unit tests. 2014/1/21 George Christman > Hello, we are trying to unit test our services, but our services contain > othe