Java Code Examples for org.springframework.test.web.servlet.setup.MockMvcBuilders#standaloneSetup()
The following examples show how to use
org.springframework.test.web.servlet.setup.MockMvcBuilders#standaloneSetup() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestServlet.java From tds with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Before public void setup() throws Exception { super.bindstd(); Nc4wrapper.TRACE = false; // if(DEBUGDATA) DapController.DUMPDATA = true; /* * USESPRING * this.mockMvc = MockMvcBuilders.webAppContextSetup(wac).build(); * else */ { StandaloneMockMvcBuilder mvcbuilder = MockMvcBuilders.standaloneSetup(new Dap4Controller()); mvcbuilder.setValidator(new TestServlet.NullValidator()); this.mockMvc = mvcbuilder.build(); } testSetup(); if (prop_ascii) Generator.setASCII(true); TestCase.setRoots(canonjoin(getResourceRoot(), TESTINPUTDIR), canonjoin(getResourceRoot(), BASELINEDIR), canonjoin(getResourceRoot(), GENERATEDIR)); defineAllTestcases(); chooseTestcases(); }
Example 2
Source File: TestFrontPage.java From tds with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Before public void setup() throws Exception { StandaloneMockMvcBuilder mvcbuilder = MockMvcBuilders.standaloneSetup(new D4TSController()); mvcbuilder.setValidator(new TestServlet.NullValidator()); this.mockMvc = mvcbuilder.build(); testSetup(); DapCache.dspregistry.register(FileDSP.class, DSPRegistry.FIRST); DapCache.dspregistry.register(SynDSP.class, DSPRegistry.FIRST); if (prop_ascii) Generator.setASCII(true); this.resourceroot = getResourceRoot(); }
Example 3
Source File: GenerateRaw.java From tds with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Before public void setup() throws Exception { StandaloneMockMvcBuilder mvcbuilder = USED4TS ? MockMvcBuilders.standaloneSetup(new D4TSController()) : MockMvcBuilders.standaloneSetup(new Dap4Controller()); mvcbuilder.setValidator(new TestServlet.NullValidator()); this.mockMvc = mvcbuilder.build(); testSetup(); if (prop_ascii) Generator.setASCII(true); TestCase.setRoots(getResourceRoot()); defineAlltestcases(); choosetests(); if (USEDAPDMR) { String dapdir = canonjoin(TestCase.resourcepath(), DAPDIR); String dmrdir = canonjoin(TestCase.resourcepath(), DMRDIR); File dapfile = new File(dapdir); if (!dapfile.exists()) dapfile.mkdirs(); File dmrfile = new File(dmrdir); if (!dmrfile.exists()) dmrfile.mkdirs(); } else { String rawdir = canonjoin(TestCase.resourcepath(), RAWDIR); File rawfile = new File(rawdir); if (!rawfile.exists()) rawfile.mkdirs(); } }
Example 4
Source File: TestServletConstraints.java From tds with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Before public void setup() throws Exception { super.bindstd(); StandaloneMockMvcBuilder mvcbuilder = MockMvcBuilders.standaloneSetup(new Dap4Controller()); mvcbuilder.setValidator(new TestServlet.NullValidator()); this.mockMvc = mvcbuilder.build(); testSetup(); if (prop_ascii) Generator.setASCII(true); TestCase.setRoots(canonjoin(getResourceRoot(), TESTINPUTDIR), canonjoin(getResourceRoot(), BASELINEDIR), canonjoin(getResourceRoot(), GENERATEDIR)); defineAllTestcases(); chooseTestcases(); }
Example 5
Source File: TestDSR.java From tds with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Before public void setup() throws Exception { StandaloneMockMvcBuilder mvcbuilder = MockMvcBuilders.standaloneSetup(new D4TSController()); mvcbuilder.setValidator(new TestServlet.NullValidator()); this.mockMvc = mvcbuilder.build(); testSetup(); DapCache.dspregistry.register(FileDSP.class, DSPRegistry.FIRST); DapCache.dspregistry.register(SynDSP.class, DSPRegistry.FIRST); if (prop_ascii) Generator.setASCII(true); this.resourceroot = getResourceRoot(); // this.datasetpath = getResourceRoot(); }
Example 6
Source File: DapTestCommon.java From tds with BSD 3-Clause "New" or "Revised" License | 4 votes |
public HttpResponse execute(HttpRequestBase rq) throws IOException { URI uri = rq.getURI(); DapController controller = getController(uri); StandaloneMockMvcBuilder mvcbuilder = MockMvcBuilders.standaloneSetup(controller); mvcbuilder.setValidator(new TestServlet.NullValidator()); MockMvc mockMvc = mvcbuilder.build(); MockHttpServletRequestBuilder mockrb = MockMvcRequestBuilders.get(uri); // We need to use only the path part mockrb.servletPath(uri.getPath()); // Move any headers from rq to mockrb Header[] headers = rq.getAllHeaders(); for (int i = 0; i < headers.length; i++) { Header h = headers[i]; mockrb.header(h.getName(), h.getValue()); } // Since the url has the query parameters, // they will automatically be parsed and added // to the rb parameters. // Finally set the resource dir mockrb.requestAttr("RESOURCEDIR", this.resourcepath); // Now invoke the servlet MvcResult result; try { result = mockMvc.perform(mockrb).andReturn(); } catch (Exception e) { throw new IOException(e); } // Collect the output MockHttpServletResponse res = result.getResponse(); byte[] byteresult = res.getContentAsByteArray(); // Convert to HttpResponse HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, res.getStatus(), ""); if (response == null) throw new IOException("HTTPMethod.executeMock: Response was null"); Collection<String> keys = res.getHeaderNames(); // Move headers to the response for (String key : keys) { List<String> values = res.getHeaders(key); for (String v : values) { response.addHeader(key, v); } } ByteArrayEntity entity = new ByteArrayEntity(byteresult); String sct = res.getContentType(); entity.setContentType(sct); response.setEntity(entity); return response; }
Example 7
Source File: RestControllerTestSupport.java From fullstop with Apache License 2.0 | 4 votes |
@Before public void setUpMockMvc() throws Exception { final StandaloneMockMvcBuilder mockMvcBuilder = MockMvcBuilders.standaloneSetup(mockMvcControllers()); configure(mockMvcBuilder); mockMvc = mockMvcBuilder.build(); }
Example 8
Source File: BaseTestClass.java From tutorials with MIT License | 4 votes |
@Before public void setup() { StandaloneMockMvcBuilder standaloneMockMvcBuilder = MockMvcBuilders.standaloneSetup(evenOddController); RestAssuredMockMvc.standaloneSetup(standaloneMockMvcBuilder); }