留言板

Liferay Portlet With Junit

thumbnail
Vikash Kumar,修改在8 年前。

Liferay Portlet With Junit

Junior Member 帖子: 30 加入日期: 13-4-18 最近的帖子
Hi,
i am getting some bean locator exception while i am accessing user object in my junit custom class
and my problem is we should not use any mock object...

public class JunitTableLocalServiceImplTest extends TestCase {

private UserLocalService userService;
@Override
@Before
protected void setUp() {
try {

// Test LR services
userService = UserLocalServiceUtil.getService();

super.setUp();
} catch (Exception ex) {
ex.printStackTrace();
fail("Init failed...");
}
}

@Override
@After
protected void tearDown() throws Exception {
System.out.println(">>>TEAR DOWN");

userService = null;
super.tearDown();
}
@Test
public void testLiferayAllUsers() throws PortalException, SystemException {
System.out.println("User Fetch Size:"+UserLocalServiceUtil.getUsers(0,-1).size());
}


}
thumbnail
Jan Geißler,修改在8 年前。

RE: Liferay Portlet With Junit

Liferay Master 帖子: 735 加入日期: 11-7-5 最近的帖子
Hi Vikash.
This has been covered like a 1000 times here in the forum.
Try this Link:
thumbnail
Vikash Kumar,修改在8 年前。

RE: Liferay Portlet With Junit

Junior Member 帖子: 30 加入日期: 13-4-18 最近的帖子
Thanks for your reply.
Last 1 weak i am searching like this only and i am not getting any solution.The main problem is i dont want to use powermock or mockito.
And in my impl having user object for this scenario how can i write my junit test case.

Impl Method Prototype
public void CustomImpl(User user){
//implementation
}
Test Class Prototype
@Test
public void testFindById() throws PortalException, SystemException,
RemoteException {

User user=UserLocalServiceUtil.getUser(10198);
String screenName=user.getScreenName();

Assert.assertTrue(screenName);




}