掲示板

Junit to test services build using service builder.

11年前 に Kailas Lokhande によって更新されました。

Junit to test services build using service builder.

New Member 投稿: 10 参加年月日: 12/11/07 最新の投稿
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
11年前 に Bart Simpson によって更新されました。

RE: Junit to test services build using service builder.

Liferay Master 投稿: 522 参加年月日: 11/08/29 最新の投稿
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
11年前 に Kailas Lokhande によって更新されました。

RE: Junit to test services build using service builder.

New Member 投稿: 10 参加年月日: 12/11/07 最新の投稿
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??
11年前 に Gogi SH によって更新されました。

RE: Junit to test services build using service builder.

New Member 投稿: 3 参加年月日: 12/11/03 最新の投稿
I have the same problem. Is there any idea?
11年前 に Siby Mathew によって更新されました。

RE: Junit to test services build using service builder.

Expert 投稿: 268 参加年月日: 11/03/04 最新の投稿
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
11年前 に Kailas Lokhande によって更新されました。

RE: Junit to test services build using service builder. (回答)

New Member 投稿: 10 参加年月日: 12/11/07 最新の投稿
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
11年前 に Oussama Denden によって更新されました。

RE: Junit to test services build using service builder.

New Member 投稿: 9 参加年月日: 12/12/10 最新の投稿
Hi Kailas Lokhande could u give an exemple please i am facing the same problem and didn't find a solution yet thanks