Foros de discusión

Liferay Portlet With Junit

thumbnail
Vikash Kumar, modificado hace 8 años.

Liferay Portlet With Junit

Junior Member Mensajes: 30 Fecha de incorporación: 18/04/13 Mensajes recientes
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, modificado hace 8 años.

RE: Liferay Portlet With Junit

Liferay Master Mensajes: 735 Fecha de incorporación: 5/07/11 Mensajes recientes
Hi Vikash.
This has been covered like a 1000 times here in the forum.
Try this Link:
thumbnail
Vikash Kumar, modificado hace 8 años.

RE: Liferay Portlet With Junit

Junior Member Mensajes: 30 Fecha de incorporación: 18/04/13 Mensajes recientes
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);




}