留言板
Liferay Portlet With Junit
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());
}
}
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());
}
}
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);
}
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);
}