Fórumok

Junit to test services build using service builder.

Kailas Lokhande, módosítva 11 év-val korábban

Junit to test services build using service builder.

New Member Bejegyzések: 10 Csatlakozás dátuma: 2012.11.07. Legújabb bejegyzések
Hi,

I have services developed using Liferay service builder . I want to write JUNIT test case for the same.

I am using tomcat 7 + liferay 6.1 ce.

Please let me know, how should I proceed with it?
Did anyone wrote junits before?

Thanks,
Kailas
thumbnail
Bart Simpson, módosítva 11 év-val korábban

RE: Junit to test services build using service builder.

Liferay Master Bejegyzések: 522 Csatlakozás dátuma: 2011.08.29. Legújabb bejegyzések
May be this helps
http://www.liferay.com/community/wiki/-/wiki/Main/How+to+use+JUnit+to+test+service+in+portlets
http://www.liferay.com/community/wiki/-/wiki/Main/JUnit
Kailas Lokhande, módosítva 11 év-val korábban

RE: Junit to test services build using service builder.

New Member Bejegyzések: 10 Csatlakozás dátuma: 2012.11.07. Legújabb bejegyzések
I followed "http://www.liferay.com/community/wiki/-/wiki/Main/How+to+use+JUnit+to+test+service+in+portlets".

But stucked with exception

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.liferay.portal.kernel.spring.util.SpringFactoryUtil#0' defined in class path resource [META-INF/base-spring.xml]: Cannot resolve reference to bean 'serviceAdvice' while setting constructor argument with key [TypedStringValue: value [methodInterceptor], target type [null]]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serviceAdvice' defined in class path resource [META-INF/base-spring.xml]: Cannot resolve reference to bean 'serviceMonitorAdvice' while setting constructor argument with key [TypedStringValue: value [nextMethodInterceptor], target type [null]]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serviceMonitorAdvice' defined in class path resource [META-INF/base-spring.xml]: Cannot resolve reference to bean 'asyncAdvice' while setting constructor argument with key [TypedStringValue: value [nextMethodInterceptor], target type [null]]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'asyncAdvice' defined in class path resource [META-INF/base-spring.xml]: Cannot resolve reference to bean 'threadLocalCacheAdvice' while setting constructor argument with key [TypedStringValue: value [nextMethodInterceptor], target type [null]]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'threadLocalCacheAdvice' defined in class path resource [META-INF/base-spring.xml]: Cannot resolve reference to bean 'bufferedIncrementAdvice' while setting constructor argument with key [TypedStringValue: value [nextMethodInterceptor], target type [null]]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bufferedIncrementAdvice' defined in class path resource [META-INF/base-spring.xml]: Cannot resolve reference to bean 'indexableAdvice' while setting constructor argument with key [TypedStringValue: value [nextMethodInterceptor], target type [null]]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'indexableAdvice' defined in class path resource [META-INF/base-spring.xml]: Cannot resolve reference to bean 'transactionAdvice' while setting constructor argument with key [TypedStringValue: value [nextMethodInterceptor], target type [null]]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionAdvice' defined in class path resource [META-INF/base-spring.xml]: Cannot resolve reference to bean 'transactionAttributeSource' while setting constructor argument with key [TypedStringValue: value [transactionAttributeSource], target type [null]]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionAttributeSource' defined in class path resource [META-INF/base-spring.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public static java.lang.Object com.liferay.portal.kernel.spring.util.SpringFactoryUtil.newBean(java.lang.String) throws com.liferay.portal.kernel.spring.util.SpringFactoryException] threw exception; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedMap(BeanDefinitionValueResolver.java:378)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:161)
at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:630)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:441)



Any Idea??
Gogi SH, módosítva 11 év-val korábban

RE: Junit to test services build using service builder.

New Member Bejegyzések: 3 Csatlakozás dátuma: 2012.11.03. Legújabb bejegyzések
I have the same problem. Is there any idea?
Siby Mathew, módosítva 11 év-val korábban

RE: Junit to test services build using service builder.

Expert Bejegyzések: 268 Csatlakozás dátuma: 2011.03.04. Legújabb bejegyzések
In the service.properties, keep only reference to ext-spring.xml
In portal-test.properties, keep hibernate.config to point to portal-hbm.xml and portlet-hbm.xml.
Finally make sure in the compiled classes/META-INF folder, only ext-spring.xml and portlet-hbm.xml is present. All other XMLs should be deleted. (Make sure its not recopied)
Re-run the test case.

Thanks,
Siby Mathew
Kailas Lokhande, módosítva 11 év-val korábban

RE: Junit to test services build using service builder. (Válasz)

New Member Bejegyzések: 10 Csatlakozás dátuma: 2012.11.07. Legújabb bejegyzések
Hi everyone,

I solved it using following steps, please let me know if I am doing something wrong.

Steps:
1. Create "test" folder in your plugin project , at the same level where "docroot" is present. (not under docroot)
2. Create "unit" folder under "test" folder.
3. Now you can start writing your test classes under this "test/unit" folder.
4. In your test class, write setup method, which will invoke "InitUtil.initWithSpring()" method.
5. Start writing your Test method with @Test annotations.
6. you can use Mockito for mocking services and persistent layer as per your requirement
7. Now run "ant test" . This will start running your test cases.

Thanks,
Kailas Lokhande
Oussama Denden, módosítva 11 év-val korábban

RE: Junit to test services build using service builder.

New Member Bejegyzések: 9 Csatlakozás dátuma: 2012.12.10. Legújabb bejegyzések
Hi Kailas Lokhande could u give an exemple please i am facing the same problem and didn't find a solution yet thanks