<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                我開發環境springMVC版本3.0.4 樣例代碼: ~~~ package com.redhorse.agent.action.junit; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.mock.web.MockServletContext; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.XmlWebApplicationContext; import org.springframework.web.servlet.HandlerAdapter; import org.springframework.web.servlet.HandlerExecutionChain; import org.springframework.web.servlet.HandlerMapping; import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter; import org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping; import com.redhorse.bean.AgentEmployeeBean; public class EmployeeManagerActionTest { private static HandlerMapping handlerMapping; private static HandlerAdapter handlerAdapter; /** * 讀取spring3 MVC配置文件 */ @BeforeClass public static void setUp() { if (handlerMapping == null) { String[] configs = { "file:src/spring/*.xml","file:src/spring/servlet/*.xml" }; XmlWebApplicationContext context = new XmlWebApplicationContext(); context.setConfigLocations(configs); MockServletContext msc = new MockServletContext(); context.setServletContext(msc); context.refresh(); msc.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, context); handlerMapping = (HandlerMapping) context.getBean(DefaultAnnotationHandlerMapping.class); handlerAdapter = (HandlerAdapter) context .getBean(context.getBeanNamesForType(AnnotationMethodHandlerAdapter.class)[0]); } } /** * 執行request對象請求的action * * @param request * @param response * @return * @throws Exception */ public ModelAndView excuteAction(HttpServletRequest request, HttpServletResponse response) throws Exception { HandlerExecutionChain chain = handlerMapping.getHandler(request); final ModelAndView model = handlerAdapter.handle(request, response, chain.getHandler()); return model; } @Test public void save() throws Exception { MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletResponse response = new MockHttpServletResponse(); AgentEmployeeBean ae = new AgentEmployeeBean(); ae.setId(12); request.getSession().setAttribute("curUser", ae); request.setRequestURI("/employee/addEmployee"); request.addParameter("email", "gpqhl0071@126.com"); request.addParameter("mobile", "15652377458"); request.addParameter("realName", "gao"); request.addParameter("subRegionIds", "1"); request.addParameter("end", "1000"); request.addParameter("point", "10"); request.setMethod("POST"); // 執行URI對應的action final ModelAndView mav = this.excuteAction(request, response); // Assert logic Assert.assertEquals("/employee/addEmployee", mav.getViewName()); String msg = (String) request.getAttribute("msg"); System.out.println(msg); } } ~~~ 需要改動的代碼: 33行,按照自己要讀取的spring配置進行修改。 61到81行,寫自己的單元測試方法。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看