@ContextConfiguration(locations = { "classpath:abframe-context-security.xml", "classpath:abframe-context.xml", "classpath:abframe-servlet.xml" }) public abstract class BaseControllerTestCase extends AbstractTransactionalJUnit4SpringContextTests { /** * Convenience methods to make tests simpler * * @param url the URL to post to * @return a MockHttpServletRequest with a POST to the specified URL */ public MockHttpServletRequest newPost(String url) { return new MockHttpServletRequest("POST", url); } public MockHttpServletRequest newGet(String url) { return new MockHttpServletRequest("GET", url); } } @RunWith(SpringJUnit4ClassRunner.class) public class DockWidgetControllerTest extends BaseControllerTestCase{ private MockHttpServletRequest request; private MockHttpServletResponse response; @Autowired private IDockWidgetService dockWidgetService=null; @Autowired private DockWidgetController dockWidgetController=null; @Rollback(false)//不回滚,否则回滚 @Test public void testDockList() throws Exception{ request=newPost("/abframe/dockWidget/findDockList"); Operator op=new Operator(); op.setId(1L); Integer b[]=new Integer[2]; b[0]=1; request.getSession().setAttribute(Constants.OPERATOR_KEY,op); //request.getSession().setAttribute("dockList",b); //List<Long> menuIdList=dockWidgetService.findDockMenuIdList(1); //System.out.println(menuIdList.toString()); List ls=new LinkedList(); //1460478#1460514#1631980 ls.add("1460478"); ls.add("1460514"); ls.add("1631980"); ls.add("111111"); //dockWidgetController.findDockList(request); dockWidgetController.updateDockList(ls,"5309177",request); } }