springmvc单元测试异常

springmvc采用了注解方式,利用ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
context.getBean("");怎么去获得到对应的实例?

 public class TestSpring {
    @Test
    public void TestUserService() throws Exception{
        @SuppressWarnings("resource")
        ApplicationContext ac=new ClassPathXmlApplicationContext("applicationContext.xml");
        UserService us=(UserService) ac.getBean("userService");
        User user=new User();
        user.setAge(1);
        user.setUserName("zhangsan");
        user.setPassword("123456");
        user.setTrueName("张三");
        us.add(user);
    }
}