org.springframework.http.MediaType.TEXT_PLAIN

Here are the examples of the java api org.springframework.http.MediaType.TEXT_PLAIN taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

600 Examples 7

19 View Source File : RestTemplateTests.java
License : MIT License
Project Creator : Vip-Augus

private void mockTextPlainHttpMessageConverter() {
    mockHttpMessageConverter(MediaType.TEXT_PLAIN, String.clreplaced);
}

19 View Source File : RestTemplateTests.java
License : MIT License
Project Creator : Vip-Augus

private void mockTextResponseBody(String expectedBody) throws Exception {
    mockResponseBody(expectedBody, MediaType.TEXT_PLAIN);
}

19 View Source File : BookRouter.java
License : Apache License 2.0
Project Creator : springdoc

@Bean
RouterFunction<?> routes4(BookRepository br) {
    return nest(path("/test"), nest(path("/greeter").and(path("/greeter2")), route(GET("/books").and(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll())).withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClreplaced(BookRepository.clreplaced).beanMethod("findAll")).and(route(GET("/books").and(accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll())).withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClreplaced(BookRepository.clreplaced).beanMethod("findAll"))).and(route(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")))).withAttribute(OPERATION_ATTRIBUTE, operationBuilder().operationId("findByAuthor").parameter(parameterBuilder().name("author").in(ParameterIn.PATH)).beanClreplaced(BookRepository.clreplaced).beanMethod("findByAuthor")))));
}

19 View Source File : BookRouter.java
License : Apache License 2.0
Project Creator : springdoc

@Bean
RouterFunction<?> routes(BookRepository br) {
    return nest(path("/greeter").and(path("/greeter2")), route(GET("/books").and(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll())).withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClreplaced(BookRepository.clreplaced).beanMethod("findAll")).and(route(GET("/books").and(accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll())).withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClreplaced(BookRepository.clreplaced).beanMethod("findAll"))).and(route(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")))).withAttribute(OPERATION_ATTRIBUTE, operationBuilder().operationId("findByAuthor").parameter(parameterBuilder().name("author").in(ParameterIn.PATH)).beanClreplaced(BookRepository.clreplaced).beanMethod("findByAuthor"))));
}

19 View Source File : BookRouter.java
License : Apache License 2.0
Project Creator : springdoc

@Bean
RouterFunction<?> routes3(BookRepository br) {
    return nest(path("/greeter").or(path("/greeter2")), route(GET("/books").and(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll())).withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClreplaced(BookRepository.clreplaced).beanMethod("findAll")).and(route(GET("/books").and(accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll())).withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClreplaced(BookRepository.clreplaced).beanMethod("findAll"))).and(route(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")))).withAttribute(OPERATION_ATTRIBUTE, operationBuilder().operationId("findByAuthor").parameter(parameterBuilder().name("author").in(ParameterIn.PATH)).beanClreplaced(BookRepository.clreplaced).beanMethod("findByAuthor"))));
}

19 View Source File : BookRouter.java
License : Apache License 2.0
Project Creator : springdoc

@Bean
@RouterOperations({ @RouterOperation(path = "/greeter/books", produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }, beanClreplaced = BookRepository.clreplaced, beanMethod = "findAll"), @RouterOperation(path = "/greeter/books", produces = { MediaType.TEXT_PLAIN_VALUE, MediaType.APPLICATION_XML_VALUE }, beanClreplaced = BookRepository.clreplaced, beanMethod = "findAll"), @RouterOperation(path = "/greeter/books/{author}", beanClreplaced = BookRepository.clreplaced, beanMethod = "findByAuthor", operation = @Operation(operationId = "findByAuthor", parameters = { @Parameter(in = ParameterIn.PATH, name = "author") })), @RouterOperation(path = "/greeter2/books", produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }, beanClreplaced = BookRepository.clreplaced, beanMethod = "findAll"), @RouterOperation(path = "/greeter2/books", produces = { MediaType.TEXT_PLAIN_VALUE, MediaType.APPLICATION_XML_VALUE }, beanClreplaced = BookRepository.clreplaced, beanMethod = "findAll"), @RouterOperation(path = "/greeter2/books/{author}", beanClreplaced = BookRepository.clreplaced, beanMethod = "findByAuthor", operation = @Operation(operationId = "findByAuthor", parameters = { @Parameter(in = ParameterIn.PATH, name = "author") })) })
RouterFunction<?> routes3(BookRepository br) {
    return nest(RequestPredicates.path("/greeter").or(RequestPredicates.path("/greeter2")), route(RequestPredicates.GET("/books").and(RequestPredicates.accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll())).and(route(RequestPredicates.GET("/books").and(RequestPredicates.accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll()))).andRoute(RequestPredicates.GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")))));
}

19 View Source File : BookRouter.java
License : Apache License 2.0
Project Creator : springdoc

@Bean
RouterFunction<?> bookRoute(BookRepository br) {
    return route().GET("/books", accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML), HANDLER_FUNCTION, ops -> ops.operationId("findAll").tag("book").beanClreplaced(BookRepository.clreplaced).beanMethod("findAll")).build().and(route().GET("/books", accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN), HANDLER_FUNCTION, ops -> ops.operationId("findAll").tag("book").beanClreplaced(BookRepository.clreplaced).beanMethod("findAll")).build()).and(route().GET("/books/{author}", HANDLER_FUNCTION, ops -> ops.tag("book").beanClreplaced(BookRepository.clreplaced).beanMethod("findByAuthor").operationId("findByAuthor").tag("book").parameter(parameterBuilder().in(ParameterIn.PATH).name("author"))).build());
}

19 View Source File : BookRouter.java
License : Apache License 2.0
Project Creator : springdoc

@Bean
RouterFunction<?> routes2() {
    return nest(path("/greeter").and(path("/greeter2")), route().GET("/books", accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML), HANDLER_FUNCTION, getOperation1()).build()).and(route().GET("/books/nest", accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN), HANDLER_FUNCTION, getOperation1()).build()).and(route().GET("/books/nest/{author}", HANDLER_FUNCTION, getOperation2()).build());
}

19 View Source File : BookRouter.java
License : Apache License 2.0
Project Creator : springdoc

@Bean
RouterFunction<?> routes4() {
    return nest(path("/test"), nest(path("/greeter").and(path("/greeter2")), route().GET("/books", accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML), HANDLER_FUNCTION, getOperation1()).build().and(route().GET("/books", accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN), HANDLER_FUNCTION, getOperation1()).build()).and(route().GET("/books/{author}", HANDLER_FUNCTION, getOperation2()).build())));
}

19 View Source File : BookRouter.java
License : Apache License 2.0
Project Creator : springdoc

@Bean
RouterFunction<?> routes4(BookRepository br) {
    return nest(path("/test"), nest(path("/greeter").and(path("/greeter2")), route(GET("/books").and(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll(), Book.clreplaced)).withAttribute(OPERATION_ATTRIBUTE, getFindAll()).and(route(GET("/books").and(accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll(), Book.clreplaced)).withAttribute(OPERATION_ATTRIBUTE, getFindAll())).and(route(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")), Book.clreplaced)).withAttribute(OPERATION_ATTRIBUTE, getRouterAttribute()))));
}

19 View Source File : BookRouter.java
License : Apache License 2.0
Project Creator : springdoc

@Bean
RouterFunction<?> routes3(BookRepository br) {
    return nest(path("/greeter").or(path("/greeter2")), route(GET("/books").and(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll(), Book.clreplaced)).withAttribute(OPERATION_ATTRIBUTE, getFindAll()).and(route(GET("/books").and(accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll(), Book.clreplaced)).withAttribute(OPERATION_ATTRIBUTE, getFindAll())).and(route(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")), Book.clreplaced)).withAttribute(OPERATION_ATTRIBUTE, getRouterAttribute())));
}

19 View Source File : BookRouter.java
License : Apache License 2.0
Project Creator : springdoc

@Bean
RouterFunction<?> routes(BookRepository br) {
    return nest(path("/greeter").and(path("/greeter2")), route(GET("/books").and(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll(), Book.clreplaced)).withAttribute(OPERATION_ATTRIBUTE, getFindAll()).and(route(GET("/books").and(accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll(), Book.clreplaced)).withAttribute(OPERATION_ATTRIBUTE, getFindAll())).and(route(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")), Book.clreplaced)).withAttribute(OPERATION_ATTRIBUTE, getRouterAttribute())));
}

19 View Source File : BookRouter.java
License : Apache License 2.0
Project Creator : springdoc

@Bean
RouterFunction<?> routes(BookRepository br) {
    return route(GET("/books").and(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll(), Book.clreplaced)).withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClreplaced(BookRepository.clreplaced).beanMethod("findAll")).and(route(GET("/books").and(accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll(), Book.clreplaced)).withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClreplaced(BookRepository.clreplaced).beanMethod("findAll"))).and(route(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")), Book.clreplaced)).withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClreplaced(BookRepository.clreplaced).beanMethod("findByAuthor").operationId("findByAuthor").parameter(parameterBuilder().in(ParameterIn.PATH).name("author"))));
}

19 View Source File : BookRouter.java
License : Apache License 2.0
Project Creator : springdoc

@Bean
@RouterOperations({ @RouterOperation(path = "/greeter/books", produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }, beanClreplaced = BookRepository.clreplaced, beanMethod = "findAll"), @RouterOperation(path = "/greeter/books", produces = { MediaType.TEXT_PLAIN_VALUE, MediaType.APPLICATION_XML_VALUE }, beanClreplaced = BookRepository.clreplaced, beanMethod = "findAll"), @RouterOperation(path = "/greeter/books/{author}", beanClreplaced = BookRepository.clreplaced, beanMethod = "findByAuthor", operation = @Operation(operationId = "findByAuthor", parameters = { @Parameter(in = ParameterIn.PATH, name = "author") })), @RouterOperation(path = "/greeter2/books", produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }, beanClreplaced = BookRepository.clreplaced, beanMethod = "findAll"), @RouterOperation(path = "/greeter2/books", produces = { MediaType.TEXT_PLAIN_VALUE, MediaType.APPLICATION_XML_VALUE }, beanClreplaced = BookRepository.clreplaced, beanMethod = "findAll"), @RouterOperation(path = "/greeter2/books/{author}", beanClreplaced = BookRepository.clreplaced, beanMethod = "findByAuthor", operation = @Operation(operationId = "findByAuthor", parameters = { @Parameter(in = ParameterIn.PATH, name = "author") })) })
RouterFunction<?> routes3(BookRepository br) {
    return nest(path("/greeter").or(path("/greeter2")), route(GET("/books").and(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll(), Book.clreplaced)).and(route(GET("/books").and(accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll(), Book.clreplaced))).andRoute(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")), Book.clreplaced)));
}

19 View Source File : HttpGetIntegrationTests.java
License : Apache License 2.0
Project Creator : spring-cloud

@Test
public void compose() throws Exception {
    ResponseEnreplacedy<String> result = this.rest.exchange(RequestEnreplacedy.get(new URI("/concat,reverse/foo")).accept(MediaType.TEXT_PLAIN).build(), String.clreplaced);
    replacedertThat(result.getBody()).isEqualTo("oofoof");
}

19 View Source File : FluxRestApplicationTests.java
License : Apache License 2.0
Project Creator : spring-cloud

@Test
public void convertGet() throws Exception {
    replacedertThat(this.rest.exchange(RequestEnreplacedy.get(new URI("/wrap/123")).accept(MediaType.TEXT_PLAIN).build(), String.clreplaced).getBody()).isEqualTo("..123..");
}

19 View Source File : FluxRestApplicationTests.java
License : Apache License 2.0
Project Creator : spring-cloud

@Test
public void uppercaseGet() throws Exception {
    replacedertThat(this.rest.exchange(RequestEnreplacedy.get(new URI("/uppercase/foo")).accept(MediaType.TEXT_PLAIN).build(), String.clreplaced).getBody()).isEqualTo("[FOO]");
}

19 View Source File : StringHttpMessageConverterTests.java
License : Apache License 2.0
Project Creator : SourceHot

@Test
public void canWrite() {
    replacedertThat(this.converter.canWrite(String.clreplaced, MediaType.TEXT_PLAIN)).isTrue();
    replacedertThat(this.converter.canWrite(String.clreplaced, MediaType.ALL)).isTrue();
}

19 View Source File : StringHttpMessageConverterTests.java
License : Apache License 2.0
Project Creator : SourceHot

@Test
public void canRead() {
    replacedertThat(this.converter.canRead(String.clreplaced, MediaType.TEXT_PLAIN)).isTrue();
}

19 View Source File : BaseClient.java
License : Apache License 2.0
Project Creator : onap

public HttpHeaders setDefaultHttpHeaders(String auth) {
    httpHeader = new HttpHeaders();
    httpHeader.set("Authorization", auth);
    httpHeader.setContentType(MediaType.APPLICATION_JSON);
    List<MediaType> acceptMediaTypes = new ArrayList<MediaType>();
    acceptMediaTypes.add(MediaType.APPLICATION_JSON);
    acceptMediaTypes.add(MediaType.TEXT_PLAIN);
    httpHeader.setAccept(acceptMediaTypes);
    return httpHeader;
}

19 View Source File : HelloRouter.java
License : MIT License
Project Creator : jonashackt

@Bean
public RouterFunction<ServerResponse> route(HelloHandler helloHandler) {
    return RouterFunctions.route(RequestPredicates.GET("/hello").and(RequestPredicates.accept(MediaType.TEXT_PLAIN)), serverRequest -> helloHandler.hello(serverRequest));
}

19 View Source File : CommonFilterMethodTest.java
License : Apache License 2.0
Project Creator : eacdy

private void testCommonBlockAndRedirectBlockPage(String url, ClusterNode cnGet, ClusterNode cnPost) throws Exception {
    configureRulesFor(GET + ":" + url, 0);
    // The request will be blocked and response is default block message.
    this.mvc.perform(get(url).accept(MediaType.TEXT_PLAIN)).andExpect(status().isOk()).andExpect(content().string(FilterUtil.DEFAULT_BLOCK_MSG));
    replacedertEquals(1, cnGet.blockQps(), 0.01);
    // Test for post preplaced
    this.mvc.perform(post(url)).andExpect(status().isOk()).andExpect(content().string(HELLO_POST_STR));
    replacedertEquals(2, cnPost.preplacedQps(), 0.01);
    FlowRuleManager.loadRules(null);
    WebServletConfig.setBlockPage("");
}

19 View Source File : CommonFilterTest.java
License : Apache License 2.0
Project Creator : eacdy

private void testUrlCleaner() throws Exception {
    final String fooPrefix = "/foo/";
    String url1 = fooPrefix + 1;
    String url2 = fooPrefix + 2;
    WebCallbackManager.setUrlCleaner(new UrlCleaner() {

        @Override
        public String clean(String originUrl) {
            if (originUrl.startsWith(fooPrefix)) {
                return "/foo/*";
            }
            return originUrl;
        }
    });
    this.mvc.perform(get(url1).accept(MediaType.TEXT_PLAIN)).andExpect(status().isOk()).andExpect(content().string("Hello 1"));
    this.mvc.perform(get(url2).accept(MediaType.TEXT_PLAIN)).andExpect(status().isOk()).andExpect(content().string("Hello 2"));
    ClusterNode cn = ClusterBuilderSlot.getClusterNode(fooPrefix + "*");
    replacedertEquals(2, cn.preplacedQps(), 0.01);
    replacedertNull(ClusterBuilderSlot.getClusterNode(url1));
    replacedertNull(ClusterBuilderSlot.getClusterNode(url2));
    WebCallbackManager.setUrlCleaner(new DefaultUrlCleaner());
}

19 View Source File : CommonFilterTest.java
License : Apache License 2.0
Project Creator : eacdy

private void testCommonBlockAndRedirectBlockPage(String url, ClusterNode cn) throws Exception {
    configureRulesFor(url, 0);
    // The request will be blocked and response is default block message.
    this.mvc.perform(get(url).accept(MediaType.TEXT_PLAIN)).andExpect(status().isOk()).andExpect(content().string(FilterUtil.DEFAULT_BLOCK_MSG));
    replacedertEquals(1, cn.blockQps(), 0.01);
    // Test for redirect.
    String redirectUrl = "http://some-location.com";
    WebServletConfig.setBlockPage(redirectUrl);
    this.mvc.perform(get(url).accept(MediaType.TEXT_PLAIN)).andExpect(status().is3xxRedirection()).andExpect(header().string("Location", redirectUrl + "?http_referer=http://localhost/hello"));
    FlowRuleManager.loadRules(null);
    WebServletConfig.setBlockPage("");
}

19 View Source File : CommonFilterTest.java
License : Apache License 2.0
Project Creator : eacdy

private void testCustomOriginParser() throws Exception {
    String url = "/hello";
    String limitOrigin = "userA";
    final String headerName = "S-User";
    configureRulesFor(url, 0, limitOrigin);
    WebCallbackManager.setRequestOriginParser(new RequestOriginParser() {

        @Override
        public String parseOrigin(HttpServletRequest request) {
            String origin = request.getHeader(headerName);
            return origin != null ? origin : "";
        }
    });
    this.mvc.perform(get(url).accept(MediaType.TEXT_PLAIN).header(headerName, "userB")).andExpect(status().isOk()).andExpect(content().string(HELLO_STR));
    // This will be blocked.
    this.mvc.perform(get(url).accept(MediaType.TEXT_PLAIN).header(headerName, limitOrigin)).andExpect(status().isOk()).andExpect(content().string(FilterUtil.DEFAULT_BLOCK_MSG));
    this.mvc.perform(get(url).accept(MediaType.TEXT_PLAIN)).andExpect(status().isOk()).andExpect(content().string(HELLO_STR));
    WebCallbackManager.setRequestOriginParser(null);
    FlowRuleManager.loadRules(null);
}

19 View Source File : HttpServletFilterIntegrationTests.java
License : Apache License 2.0
Project Creator : census-instrumentation

private MvcResult sendRequest() throws Exception {
    MvcResult result = this.mockMvc.perform(MockMvcRequestBuilders.get("/foo").accept(MediaType.TEXT_PLAIN)).andReturn();
    return result;
}

19 View Source File : CommonFilterMethodTest.java
License : Apache License 2.0
Project Creator : alibaba

private void testCommonBlockAndRedirectBlockPage(String url, ClusterNode cnGet, ClusterNode cnPost) throws Exception {
    configureRulesFor(GET + ":" + url, 0);
    // The request will be blocked and response is default block message.
    this.mvc.perform(get(url).accept(MediaType.TEXT_PLAIN)).andExpect(status().isTooManyRequests()).andExpect(content().string(FilterUtil.DEFAULT_BLOCK_MSG));
    replacedertEquals(1, cnGet.blockQps(), 0.01);
    // Test for post preplaced
    this.mvc.perform(post(url)).andExpect(status().isOk()).andExpect(content().string(HELLO_POST_STR));
    replacedertEquals(2, cnPost.preplacedQps(), 0.01);
    FlowRuleManager.loadRules(null);
    WebServletConfig.setBlockPage("");
}

19 View Source File : CommonFilterTest.java
License : Apache License 2.0
Project Creator : alibaba

private void testCustomOriginParser() throws Exception {
    String url = "/hello";
    String limitOrigin = "userA";
    final String headerName = "S-User";
    configureRulesFor(url, 0, limitOrigin);
    WebCallbackManager.setRequestOriginParser(new RequestOriginParser() {

        @Override
        public String parseOrigin(HttpServletRequest request) {
            String origin = request.getHeader(headerName);
            return origin != null ? origin : "";
        }
    });
    this.mvc.perform(get(url).accept(MediaType.TEXT_PLAIN).header(headerName, "userB")).andExpect(status().isOk()).andExpect(content().string(HELLO_STR));
    // This will be blocked.
    this.mvc.perform(get(url).accept(MediaType.TEXT_PLAIN).header(headerName, limitOrigin)).andExpect(status().isTooManyRequests()).andExpect(content().string(FilterUtil.DEFAULT_BLOCK_MSG));
    this.mvc.perform(get(url).accept(MediaType.TEXT_PLAIN)).andExpect(status().isOk()).andExpect(content().string(HELLO_STR));
    WebCallbackManager.setRequestOriginParser(null);
    FlowRuleManager.loadRules(null);
}

19 View Source File : CommonFilterTest.java
License : Apache License 2.0
Project Creator : alibaba

private void testUrlExclusion() throws Exception {
    final String excludePrefix = "/exclude/";
    String url = excludePrefix + 1;
    WebCallbackManager.setUrlCleaner(new UrlCleaner() {

        @Override
        public String clean(String originUrl) {
            if (originUrl.startsWith(excludePrefix)) {
                return "";
            }
            return originUrl;
        }
    });
    this.mvc.perform(get(url).accept(MediaType.TEXT_PLAIN)).andExpect(status().isOk()).andExpect(content().string("Exclude 1"));
    replacedertNull(ClusterBuilderSlot.getClusterNode(url));
    WebCallbackManager.setUrlCleaner(new DefaultUrlCleaner());
}

18 View Source File : ExampleHandler.java
License : MIT License
Project Creator : ZhongyangMA

public Mono<ServerResponse> funcTest2(ServerRequest request) {
    return ServerResponse.ok().contentType(MediaType.TEXT_PLAIN).body(BodyInserters.fromObject("funcTest2: WebFlux functional router."));
}

18 View Source File : ExampleHandler.java
License : MIT License
Project Creator : ZhongyangMA

/**
 * below for functional routers
 */
public Mono<ServerResponse> funcTest1(ServerRequest request) {
    return ServerResponse.ok().contentType(MediaType.TEXT_PLAIN).body(BodyInserters.fromObject("funcTest1: WebFlux functional router."));
}

18 View Source File : SampleWebFluxApplicationTests.java
License : Apache License 2.0
Project Creator : yuanmabiji

@Test
public void testWelcome() {
    this.webClient.get().uri("/").accept(MediaType.TEXT_PLAIN).exchange().expectBody(String.clreplaced).isEqualTo("Hello World");
}

18 View Source File : UserVehicleControllerTests.java
License : Apache License 2.0
Project Creator : yuanmabiji

@Test
public void getVehicleWhenRequestingTextShouldReturnMakeAndModel() throws Exception {
    given(this.userVehicleService.getVehicleDetails("sboot")).willReturn(new VehicleDetails("Honda", "Civic"));
    this.mvc.perform(get("/sboot/vehicle").accept(MediaType.TEXT_PLAIN)).andExpect(status().isOk()).andExpect(content().string("Honda Civic"));
}

@Test
public void get() {
    this.contextRunner.run(withWebTestClient((webTestClient) -> webTestClient.get().uri("/actuator/example/one").accept(MediaType.TEXT_PLAIN).exchange().expectStatus().isOk().expectHeader().contentTypeCompatibleWith(MediaType.TEXT_PLAIN).expectBody(String.clreplaced).isEqualTo("One")));
}

18 View Source File : HelloHandler.java
License : Apache License 2.0
Project Creator : xuwujing

public Mono<ServerResponse> hello(ServerRequest request) {
    String hello = "Hello, world!";
    Mono<ServerResponse> mono = ServerResponse.ok().contentType(MediaType.TEXT_PLAIN).body(BodyInserters.fromObject(hello));
    return mono;
}

18 View Source File : ConfigurationAdminResourceIntTest.java
License : Apache License 2.0
Project Creator : xm-online

private void verifyDoreplacedent(String s) throws Exception {
    mockMvc.perform(get(API_PREFIX + FULL_PATH_PREFIX + "/test/folder/subfolder/doreplacedentname" + s).contentType(MediaType.TEXT_PLAIN)).andExpect(content().string(s)).andExpect(status().is2xxSuccessful());
}

18 View Source File : ConfigurationAdminResourceIntTest.java
License : Apache License 2.0
Project Creator : xm-online

private void createDoreplacedent(String placeholder) throws Exception {
    mockMvc.perform(put(API_PREFIX + INMEMORY + FULL_PATH_PREFIX + "/test/folder/subfolder/doreplacedentname" + placeholder).content(placeholder).contentType(MediaType.TEXT_PLAIN)).andExpect(status().is2xxSuccessful());
}

public static void configureMessageConverters(List<HttpMessageConverter<?>> converters, Gson gson) {
    // Rend possible la production de texte (getFile)
    StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter(StandardCharsets.UTF_8);
    stringHttpMessageConverter.setSupportedMediaTypes(Collections.singletonList(MediaType.TEXT_PLAIN));
    converters.add(stringHttpMessageConverter);
    // Rend possible l'utilisation de Gson pour la sérialisation/désérialisation
    GsonHttpMessageConverter gsonHttpMessageConverter = new GsonHttpMessageConverter();
    gsonHttpMessageConverter.setGson(gson);
    converters.add(gsonHttpMessageConverter);
}

18 View Source File : ResponseBodyEmitterTests.java
License : MIT License
Project Creator : Vip-Augus

@Test
public void sendWithError() throws Exception {
    this.emitter.initialize(this.handler);
    verify(this.handler).onTimeout(any());
    verify(this.handler).onError(any());
    verify(this.handler).onCompletion(any());
    verifyNoMoreInteractions(this.handler);
    IOException failure = new IOException();
    willThrow(failure).given(this.handler).send("foo", MediaType.TEXT_PLAIN);
    try {
        this.emitter.send("foo", MediaType.TEXT_PLAIN);
        fail("Expected exception");
    } catch (IOException ex) {
    // expected
    }
    verify(this.handler).send("foo", MediaType.TEXT_PLAIN);
    verifyNoMoreInteractions(this.handler);
}

18 View Source File : ResponseBodyEmitterTests.java
License : MIT License
Project Creator : Vip-Augus

@Test
public void sendDuplicateBeforeHandlerInitialized() throws Exception {
    this.emitter.send("foo", MediaType.TEXT_PLAIN);
    this.emitter.send("foo", MediaType.TEXT_PLAIN);
    this.emitter.complete();
    verifyNoMoreInteractions(this.handler);
    this.emitter.initialize(this.handler);
    verify(this.handler, times(2)).send("foo", MediaType.TEXT_PLAIN);
    verify(this.handler).complete();
    verifyNoMoreInteractions(this.handler);
}

18 View Source File : ResponseBodyEmitterTests.java
License : MIT License
Project Creator : Vip-Augus

@Test
public void sendBeforeHandlerInitialized() throws Exception {
    this.emitter.send("foo", MediaType.TEXT_PLAIN);
    this.emitter.send("bar", MediaType.TEXT_PLAIN);
    this.emitter.complete();
    verifyNoMoreInteractions(this.handler);
    this.emitter.initialize(this.handler);
    verify(this.handler).send("foo", MediaType.TEXT_PLAIN);
    verify(this.handler).send("bar", MediaType.TEXT_PLAIN);
    verify(this.handler).complete();
    verifyNoMoreInteractions(this.handler);
}

18 View Source File : ResponseBodyEmitterTests.java
License : MIT License
Project Creator : Vip-Augus

@Test
public void sendAfterHandlerInitialized() throws Exception {
    this.emitter.initialize(this.handler);
    verify(this.handler).onTimeout(any());
    verify(this.handler).onError(any());
    verify(this.handler).onCompletion(any());
    verifyNoMoreInteractions(this.handler);
    this.emitter.send("foo", MediaType.TEXT_PLAIN);
    this.emitter.send("bar", MediaType.TEXT_PLAIN);
    this.emitter.complete();
    verify(this.handler).send("foo", MediaType.TEXT_PLAIN);
    verify(this.handler).send("bar", MediaType.TEXT_PLAIN);
    verify(this.handler).complete();
    verifyNoMoreInteractions(this.handler);
}

18 View Source File : ResponseBodyEmitterTests.java
License : MIT License
Project Creator : Vip-Augus

@Test
public void sendAfterHandlerInitializedWithError() throws Exception {
    this.emitter.initialize(this.handler);
    verify(this.handler).onTimeout(any());
    verify(this.handler).onError(any());
    verify(this.handler).onCompletion(any());
    verifyNoMoreInteractions(this.handler);
    IllegalStateException ex = new IllegalStateException();
    this.emitter.send("foo", MediaType.TEXT_PLAIN);
    this.emitter.send("bar", MediaType.TEXT_PLAIN);
    this.emitter.completeWithError(ex);
    verify(this.handler).send("foo", MediaType.TEXT_PLAIN);
    verify(this.handler).send("bar", MediaType.TEXT_PLAIN);
    verify(this.handler).completeWithError(ex);
    verifyNoMoreInteractions(this.handler);
}

18 View Source File : ResponseBodyEmitterTests.java
License : MIT License
Project Creator : Vip-Augus

@Test
public void sendBeforeHandlerInitializedWithError() throws Exception {
    IllegalStateException ex = new IllegalStateException();
    this.emitter.send("foo", MediaType.TEXT_PLAIN);
    this.emitter.send("bar", MediaType.TEXT_PLAIN);
    this.emitter.completeWithError(ex);
    verifyNoMoreInteractions(this.handler);
    this.emitter.initialize(this.handler);
    verify(this.handler).send("foo", MediaType.TEXT_PLAIN);
    verify(this.handler).send("bar", MediaType.TEXT_PLAIN);
    verify(this.handler).completeWithError(ex);
    verifyNoMoreInteractions(this.handler);
}

18 View Source File : DefaultResponseErrorHandlerTests.java
License : MIT License
Project Creator : Vip-Augus

// SPR-17461
@Test
public void hasErrorForCustomClientError() throws Exception {
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.TEXT_PLAIN);
    given(response.getRawStatusCode()).willReturn(499);
    given(response.getStatusText()).willReturn("Custom status code");
    given(response.getHeaders()).willReturn(headers);
    replacedertTrue(handler.hasError(response));
}

18 View Source File : DefaultResponseErrorHandlerTests.java
License : MIT License
Project Creator : Vip-Augus

@Test(expected = UnknownHttpStatusCodeException.clreplaced)
public void handleErrorForCustomClientError() throws Exception {
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.TEXT_PLAIN);
    given(response.getRawStatusCode()).willReturn(499);
    given(response.getStatusText()).willReturn("Custom status code");
    given(response.getHeaders()).willReturn(headers);
    handler.handleError(response);
}

18 View Source File : DefaultResponseErrorHandlerTests.java
License : MIT License
Project Creator : Vip-Augus

@Test(expected = UnknownHttpStatusCodeException.clreplaced)
public void handleErrorForCustomServerError() throws Exception {
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.TEXT_PLAIN);
    given(response.getRawStatusCode()).willReturn(599);
    given(response.getStatusText()).willReturn("Custom status code");
    given(response.getHeaders()).willReturn(headers);
    handler.handleError(response);
}

18 View Source File : DefaultResponseErrorHandlerTests.java
License : MIT License
Project Creator : Vip-Augus

// SPR-17461
@Test
public void hasErrorForCustomServerError() throws Exception {
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.TEXT_PLAIN);
    given(response.getRawStatusCode()).willReturn(599);
    given(response.getStatusText()).willReturn("Custom status code");
    given(response.getHeaders()).willReturn(headers);
    replacedertTrue(handler.hasError(response));
}

18 View Source File : DefaultResponseErrorHandlerTests.java
License : MIT License
Project Creator : Vip-Augus

// SPR-9406
@Test(expected = UnknownHttpStatusCodeException.clreplaced)
public void handleErrorUnknownStatusCode() throws Exception {
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.TEXT_PLAIN);
    given(response.getRawStatusCode()).willReturn(999);
    given(response.getStatusText()).willReturn("Custom status code");
    given(response.getHeaders()).willReturn(headers);
    handler.handleError(response);
}

18 View Source File : DefaultResponseErrorHandlerTests.java
License : MIT License
Project Creator : Vip-Augus

// SPR-16108
@Test
public void hasErrorForUnknownStatusCode() throws Exception {
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.TEXT_PLAIN);
    given(response.getRawStatusCode()).willReturn(999);
    given(response.getStatusText()).willReturn("Custom status code");
    given(response.getHeaders()).willReturn(headers);
    replacedertFalse(handler.hasError(response));
}

See More Examples