@RunWith(SpringJUnit4ClassRunner.class)
//@ContextConfiguration(locations={"file:web/WEB-INF/application-
context.xml","file:web/WEB-INF/dispatcher-servlet.xml"})
@ContextConfiguration(locations={"file:D:/ABC/src/main/webapp/WEB-INF/
xyz-servlet.xml",
"file:D:/ABC/src/main/webapp/WEB-INF/xyzrest-servlet.xml"})
public class TestNGXController {
@Inject
private ApplicationContext applicationContext;
private MockHttpServletRequest request;
private MockHttpServletResponse response;
private HandlerAdapter handlerAdapter;
private XController controller;
@Test
public void setUp() {
request = new MockHttpServletRequest();
response = new MockHttpServletResponse();
handlerAdapter =
applicationContext.getBean(HandlerAdapter.class);
// I could get the controller from the context here
controller = new XController();
}
@Test
public void testgoLoginPage() throws Exception {
request.setAttribute("login", "0");
final org.springframework.web.servlet.ModelAndView mav =
handlerAdapter.handle(request, response, controller);
assertViewName(mav, null);
assertAndReturnModelAttributeOfType(mav, "login", null);
}
@Test
public void testgoHomePage(){
org.springframework.web.servlet.ModelAndView mav =null;
request.setAttribute("success1", "1");
request.setAttribute("success", "1");
try {
mav = handlerAdapter.handle(request, response, controller);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
assertViewName(mav, null);
assertAndReturnModelAttributeOfType(mav, "home",null);
}
Thanks &Regards,
Venu Gopala Reddy.
On May 16, 1:38 pm, Antony Siagian <
antonysiag...@gmail.com> wrote:
> Could you list all method in your class?
> As i know, you require a method inside your class which prefix name is
> begin with test.
> Sou you need to make a method like testController()
>
>
>
>
>
> On Wed, May 16, 2012 at 3:13 PM, venu gopal <
venuinfo.j...@gmail.com> wrote:
> > Hi,
>
> > When i m running the Spring ControllerTest
>
> > getting fallowing error :
>
> > java.lang.NoSuchMethodError:
> > org.junit.runner.notification.RunNotifier.testAborted(Lorg/junit/
> > runner/Description;Ljava/lang/Throwable;)V
> > at
>
> > org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invokeTestMethod(SpringJUnit4ClassRunner.java:
> > 155)
>
> > How to resolve ....
> > org.junit.runner.notification.RunNotifier.
>
> --
> Regard's
>
> Antony Siagian
> -e
antonysiag...@gmail.com
> -m +628 13 11 14 3200
> Jakarta, Indonesia
> "Man's mind is like a store of idolatry and superstition; so much so that
> if a man believes his own mind it is certain that he will forsake God and
> forge some idol in his own brain"- Hide quoted text -
>
> - Show quoted text -