List of usage examples for org.springframework.http MediaType TEXT_HTML
MediaType TEXT_HTML
To view the source code for org.springframework.http MediaType TEXT_HTML.
Click Source Link
From source file:com.hp.autonomy.frontend.find.core.view.AbstractViewControllerIT.java
@Test public void viewDocument() throws Exception { final String reference = mvcIntegrationTestUtils.getValidReference(mockMvc); final MockHttpServletRequestBuilder requestBuilder = get( ViewController.VIEW_PATH + ViewController.VIEW_DOCUMENT_PATH) .param(ViewController.REFERENCE_PARAM, reference) .param(ViewController.DATABASE_PARAM, mvcIntegrationTestUtils.getDatabases()[0]) .with(authentication(userAuth())); mockMvc.perform(requestBuilder).andExpect(status().isOk()) .andExpect(content().contentType(MediaType.TEXT_HTML)); }
From source file:spring.travel.site.AppConfigurer.java
@Override public void configureContentNegotiation(ContentNegotiationConfigurer configurer) { configurer.favorPathExtension(false).useJaf(false).defaultContentType(MediaType.TEXT_HTML).mediaType("json", MediaType.APPLICATION_JSON); }
From source file:org.cloudfoundry.identity.uaa.integration.LoginInfoEndpointIntegrationTests.java
/** * tests a happy-day flow of the <code>/login</code> endpoint *///from w ww.jav a2s.com @Test public void testHappyDayHtml() throws Exception { HttpHeaders headers = new HttpHeaders(); headers.setAccept(Arrays.asList(MediaType.TEXT_HTML)); HttpStatus status = HttpStatus.FOUND; String location = "/login"; ResponseEntity<Void> response = null; while (status == HttpStatus.FOUND) { response = serverRunning.getForResponse(location, headers); status = response.getStatusCode(); if (status == HttpStatus.FOUND) { location = response.getHeaders().getLocation().toString(); System.err.println("Redirected to " + location); } } ResponseEntity<String> finalResponse = serverRunning.getForString(location, headers); String body = finalResponse.getBody().toString(); // System.err.println(body); assertNotNull(body); assertTrue("Wrong body: " + body, body.contains("<form id=")); }
From source file:guru.nidi.ramltester.UriTest.java
@RequestMapping(value = { "/raml/v1/{def}/{type}", "/v1/{def}/{type}", "/{def}/{type}", "/sub-raml/{a}/{b}/{c}/{d}" }) @ResponseBody// ww w . j a v a 2 s . com public HttpEntity<String> test() { final HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.TEXT_HTML); return new HttpEntity<>(headers); }
From source file:fi.helsinki.opintoni.server.WebPageServer.java
public void expectMetaDataRequest() { server.expect(requestTo(OpenGraphSampleData.URL)).andExpect(method(HttpMethod.GET)) .andRespond(withSuccess(SampleDataFiles.toText("pagemetadata/document.html"), MediaType.TEXT_HTML)); }
From source file:org.cloudfoundry.identity.app.integration.AuthenticationIntegrationTests.java
@Test public void formLoginSucceeds() throws Exception { ResponseEntity<Void> result; String location;//from ww w .ja va 2 s. c o m String cookie; HttpHeaders uaaHeaders = new HttpHeaders(); HttpHeaders appHeaders = new HttpHeaders(); uaaHeaders.setAccept(Arrays.asList(MediaType.TEXT_HTML)); appHeaders.setAccept(Arrays.asList(MediaType.TEXT_HTML)); // *** GET /app/id result = serverRunning.getForResponse("/id", appHeaders); assertEquals(HttpStatus.FOUND, result.getStatusCode()); location = result.getHeaders().getLocation().toString(); cookie = result.getHeaders().getFirst("Set-Cookie"); assertNotNull("Expected cookie in " + result.getHeaders(), cookie); appHeaders.set("Cookie", cookie); assertTrue("Wrong location: " + location, location.contains("/oauth/authorize")); // *** GET /uaa/oauth/authorize result = serverRunning.getForResponse(location, uaaHeaders); assertEquals(HttpStatus.FOUND, result.getStatusCode()); location = result.getHeaders().getLocation().toString(); cookie = result.getHeaders().getFirst("Set-Cookie"); assertNotNull("Expected cookie in " + result.getHeaders(), cookie); uaaHeaders.set("Cookie", cookie); assertTrue("Wrong location: " + location, location.contains("/login")); location = serverRunning.getAuthServerUrl("/login.do"); MultiValueMap<String, String> formData; formData = new LinkedMultiValueMap<String, String>(); formData.add("username", testAccounts.getUserName()); formData.add("password", testAccounts.getPassword()); // *** POST /uaa/login.do result = serverRunning.postForResponse(location, uaaHeaders, formData); cookie = result.getHeaders().getFirst("Set-Cookie"); assertNotNull("Expected cookie in " + result.getHeaders(), cookie); uaaHeaders.set("Cookie", cookie); assertEquals(HttpStatus.FOUND, result.getStatusCode()); location = result.getHeaders().getLocation().toString(); assertTrue("Wrong location: " + location, location.contains("/oauth/authorize")); // *** GET /uaa/oauth/authorize result = serverRunning.getForResponse(location, uaaHeaders); // If there is no token in place already for this client we get the approval page. // TODO: revoke the token so we always get the approval page if (result.getStatusCode() == HttpStatus.OK) { location = serverRunning.getAuthServerUrl("/oauth/authorize"); formData = new LinkedMultiValueMap<String, String>(); formData.add("user_oauth_approval", "true"); // *** POST /uaa/oauth/authorize result = serverRunning.postForResponse(location, uaaHeaders, formData); } location = result.getHeaders().getLocation().toString(); // SUCCESS assertTrue("Wrong location: " + location, location.contains("/id")); // *** GET /app/id result = serverRunning.getForResponse(location, appHeaders); // System.err.println(result.getHeaders()); assertEquals(HttpStatus.OK, result.getStatusCode()); }
From source file:edu.infsci2560.AboutIT.java
@Test public void testAboutPage() throws Exception { HttpHeaders headers = new HttpHeaders(); headers.setAccept(Arrays.asList(MediaType.TEXT_HTML)); ResponseEntity<String> entity = this.restTemplate.exchange("/about.html", HttpMethod.GET, new HttpEntity<>(headers), String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); }
From source file:com.borabora.ui.secure.SampleSecureApplicationTests.java
@Test public void testHome() throws Exception { HttpHeaders headers = new HttpHeaders(); headers.setAccept(Arrays.asList(MediaType.TEXT_HTML)); ResponseEntity<String> entity = new TestRestTemplate().exchange("http://localhost:" + this.port, HttpMethod.GET, new HttpEntity<Void>(headers), String.class); assertEquals(HttpStatus.OK, entity.getStatusCode()); assertTrue("Wrong body (title doesn't match):\n" + entity.getBody(), entity.getBody().contains("<title>Login")); }
From source file:edu.infsci2560.LoginIT.java
@Test public void testLoginPage() throws Exception { HttpHeaders headers = new HttpHeaders(); headers.setAccept(Arrays.asList(MediaType.TEXT_HTML)); ResponseEntity<String> entity = this.restTemplate.exchange("/login", HttpMethod.GET, new HttpEntity<>(headers), String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getBody()).contains("_csrf"); }
From source file:sample.session.SmartHttpSessionStrategy.java
@Autowired public SmartHttpSessionStrategy(ContentNegotiationStrategy contentNegotiationStrategy) { this(new CookieHttpSessionStrategy(), new HeaderHttpSessionStrategy()); MediaTypeRequestMatcher matcher = new MediaTypeRequestMatcher(contentNegotiationStrategy, Arrays.asList(MediaType.TEXT_HTML)); matcher.setIgnoredMediaTypes(Collections.singleton(MediaType.ALL)); RequestHeaderRequestMatcher javascript = new RequestHeaderRequestMatcher("X-Requested-With"); this.browserMatcher = new OrRequestMatcher(Arrays.asList(matcher, javascript)); }