<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>Unit Test only possible for portal, not for portlets with services? {Solve</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=3827879" />
  <subtitle>Unit Test only possible for portal, not for portlets with services? {Solve</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=3827879</id>
  <updated>2026-06-14T18:13:49Z</updated>
  <dc:date>2026-06-14T18:13:49Z</dc:date>
  <entry>
    <title>RE: Unit Testing only possible for portal, not for portlets with services?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=5059566" />
    <author>
      <name>Laurent Gauthier</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=5059566</id>
    <updated>2010-06-08T17:00:37Z</updated>
    <published>2010-06-08T17:00:37Z</published>
    <summary type="html">For the benefits of those, who, like me, stumbled across the problem of unit testing Liferay portlets, I published a Blog article on the subject at: &lt;a href="http://agile-reflections.opnworks.com/2010/06/portlet-unit-testing-with-liferay-6.html"&gt;Liferay Portlet Unit testing&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;It outlines a simple and effective solution to this problem. Feedback and comments are welcome.&lt;br /&gt;&lt;br /&gt;Laurent</summary>
    <dc:creator>Laurent Gauthier</dc:creator>
    <dc:date>2010-06-08T17:00:37Z</dc:date>
  </entry>
  <entry>
    <title>RE: Unit Testing only possible for portal, not for portlets with services?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=4323971" />
    <author>
      <name>Chandrasekhar Kothuri</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=4323971</id>
    <updated>2009-11-27T06:10:00Z</updated>
    <published>2009-11-27T06:10:00Z</published>
    <summary type="html">Hi,&lt;br /&gt;&lt;br /&gt;Can you please explain in detail what you have followed the approach.&lt;br /&gt;Actually I want to increment the liferay counter value by using the myeclipse.&lt;br /&gt;&lt;br /&gt;Thanks in advance &lt;br /&gt;&lt;br /&gt;Regards,&lt;br /&gt;K.chandra sekhar</summary>
    <dc:creator>Chandrasekhar Kothuri</dc:creator>
    <dc:date>2009-11-27T06:10:00Z</dc:date>
  </entry>
  <entry>
    <title>RE: Unit Testing only possible for portal, not for portlets with services?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=3839573" />
    <author>
      <name>Stef Heyenrath</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=3839573</id>
    <updated>2009-08-20T09:09:28Z</updated>
    <published>2009-08-20T09:09:28Z</published>
    <summary type="html">&lt;strong&gt;I found a solution!.&lt;/strong&gt;&lt;br /&gt;(It took a lot of searching + developing time to solve this issue, and as far as I know, this is the only solution present in the whole Liferay community!)&lt;br /&gt;&lt;br /&gt;I did the following:&lt;br /&gt;&lt;br /&gt;1. Create an own test project based on the portal-src from Liferay.&lt;br /&gt;2. Remove all java files but keep all jar files.&lt;br /&gt;3. Add portal-impl.jar, portal-kernel.jar, portal-service.jar and util-java.jar to this project.&lt;br /&gt;4. Create an own version of initWithSpring() which initializes my portlet.&lt;br /&gt;5. Update the build file from the services-portlet project to create a jar file which includes all classes + configuation files. (xml + properties)&lt;br /&gt;&lt;br /&gt;See &lt;a href="http://tencompetence.cvs.sourceforge.net/viewvc/tencompetence/portal/org.tencompetence.services-portlet/"&gt;Services-Portlet project&lt;/a&gt; and the &lt;a href="http://tencompetence.cvs.sourceforge.net/viewvc/tencompetence/portal/org.tencompetence.services-portlet.test/"&gt;Test Services-Portlet project&lt;/a&gt; for more details.</summary>
    <dc:creator>Stef Heyenrath</dc:creator>
    <dc:date>2009-08-20T09:09:28Z</dc:date>
  </entry>
  <entry>
    <title>Unit Test only possible for portal, not for portlets with services? {Solve</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=3827878" />
    <author>
      <name>Stef Heyenrath</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=3827878</id>
    <updated>2009-08-19T07:38:01Z</updated>
    <published>2009-08-19T07:38:01Z</published>
    <summary type="html">In the portal source code, there are several test classes. (&lt;em&gt;portal-impl/test/com/liferay/counter/service/CounterServiceTest.java&lt;/em&gt;)&lt;br /&gt;&lt;br /&gt;The most interesting class is : &lt;strong&gt;BaseTestCase&lt;/strong&gt;.&lt;br /&gt;&lt;br /&gt;In this class the environment is setup to make unit testing possible. (Spring beans are initialized and Jetty is started up.)&lt;br /&gt;The method which does all the work is : &lt;strong&gt;InitUtil.initWithSpring()&lt;/strong&gt;.&lt;br /&gt;&lt;br /&gt;I want to unit test the business logic from the services (classes created by the service-builder) from my portlet so that I don&amp;#39;t need a fully working Liferay environment to test some small functionality.&lt;br /&gt;&lt;br /&gt;The question is : How can I correctly initialize the spring beans from my &lt;u&gt;own &lt;/u&gt;portlet ?&lt;br /&gt;Because this is needed to solve the &amp;#34;BeanLocator is null&amp;#34; exception.</summary>
    <dc:creator>Stef Heyenrath</dc:creator>
    <dc:date>2009-08-19T07:38:01Z</dc:date>
  </entry>
</feed>
