Unit test cases for Java Controller based Webscripts in Alfresco

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
sarakahn
Member II

Unit test cases for Java Controller based Webscripts in Alfresco

I plan to unit test the webscripts that had Java as controllers. I have found two approaches.

1) Go along the lines of bootstrap code HelloWorldWebScriptControllerTest.java

2) Follow https://github.com/Alfresco/alfresco-remote-api. Here, the test classes extend org.alfresco.repo.web.scripts.BaseWebScriptTest.

For the second approach, I tried adding the following dependency, but cannot find this BaseWebScriptTest.

<!-- https://mvnrepository.com/artifact/org.alfresco/alfresco-remote-api --> <dependency>     <groupId>org.alfresco</groupId>     <artifactId>alfresco-remote-api</artifactId>     <version>5.2.b-EA</version> </dependency>

I tried adding <classifier>tests</classifier> to the above dependency as well. But, cannot find this class.

How can this issue be resolved? Also, which approach is suggested?

2 Replies
krutik_jayswal
Senior Member II

Re: Unit test cases for Java Controller based Webscripts in Alfresco

In the second approach you are trying to add EA version,which does not exist in the specified url.

You can use another version.

Check by your self on below URL.

Maven Repository: org.alfresco » alfresco-remote-api 

sarakahn
Member II

Re: Unit test cases for Java Controller based Webscripts in Alfresco

I have taken the latest one as well. But, the BaseWebScriptTest is missing. I was wondering if my approach to alfresco-remote-api is correct. 

Also, if I follow the first method, I need to mock lot of services as well. How should I mock ServiceRegistry or NodeService?