Search in sources :

Example 11 with StringHttpMessageConverter

use of org.springframework.http.converter.StringHttpMessageConverter in project tutorials by eugenp.

the class ApplicationConfiguration method configureMessageConverters.

@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
    converters.add(new StringHttpMessageConverter());
    converters.add(new RssChannelHttpMessageConverter());
    converters.add(new JsonChannelHttpMessageConverter());
    super.configureMessageConverters(converters);
}
Also used : JsonChannelHttpMessageConverter(com.baeldung.spring.controller.rss.JsonChannelHttpMessageConverter) RssChannelHttpMessageConverter(org.springframework.http.converter.feed.RssChannelHttpMessageConverter) StringHttpMessageConverter(org.springframework.http.converter.StringHttpMessageConverter)

Example 12 with StringHttpMessageConverter

use of org.springframework.http.converter.StringHttpMessageConverter in project nakadi by zalando.

the class StoragesControllerTest method before.

@Before
public void before() {
    final StoragesController controller = new StoragesController(securitySettings, storageService, adminService);
    final FeatureToggleService featureToggleService = mock(FeatureToggleService.class);
    doReturn("nakadi").when(securitySettings).getAdminClientId();
    mockMvc = standaloneSetup(controller).setMessageConverters(new StringHttpMessageConverter(), TestUtils.JACKSON_2_HTTP_MESSAGE_CONVERTER).setCustomArgumentResolvers(new ClientResolver(securitySettings, featureToggleService)).build();
}
Also used : FeatureToggleService(org.zalando.nakadi.service.FeatureToggleService) ClientResolver(org.zalando.nakadi.security.ClientResolver) StringHttpMessageConverter(org.springframework.http.converter.StringHttpMessageConverter) Before(org.junit.Before)

Example 13 with StringHttpMessageConverter

use of org.springframework.http.converter.StringHttpMessageConverter in project nakadi by zalando.

the class EventTypeControllerTestCase method init.

@Before
public void init() throws Exception {
    final NakadiSettings nakadiSettings = new NakadiSettings(0, 0, 0, TOPIC_RETENTION_TIME_MS, 0, 60, NAKADI_POLL_TIMEOUT, NAKADI_SEND_TIMEOUT, 0, NAKADI_EVENT_MAX_BYTES, NAKADI_SUBSCRIPTION_MAX_PARTITIONS, "service", "nakadi", "I am warning you");
    final PartitionsCalculator partitionsCalculator = new KafkaConfig().createPartitionsCalculator("t2.large", TestUtils.OBJECT_MAPPER, nakadiSettings);
    when(timelineService.getTopicRepository((Timeline) any())).thenReturn(topicRepository);
    when(timelineService.getTopicRepository((EventTypeBase) any())).thenReturn(topicRepository);
    when(transactionTemplate.execute(any())).thenAnswer(invocation -> {
        final TransactionCallback callback = (TransactionCallback) invocation.getArguments()[0];
        return callback.doInTransaction(null);
    });
    final EventTypeService eventTypeService = new EventTypeService(eventTypeRepository, timelineService, partitionResolver, enrichment, subscriptionRepository, schemaEvolutionService, partitionsCalculator, featureToggleService, authorizationValidator, timelineSync, transactionTemplate, nakadiSettings, nakadiKpiPublisher, "et-log-event-type");
    final EventTypeOptionsValidator eventTypeOptionsValidator = new EventTypeOptionsValidator(TOPIC_RETENTION_MIN_MS, TOPIC_RETENTION_MAX_MS);
    final EventTypeController controller = new EventTypeController(eventTypeService, featureToggleService, eventTypeOptionsValidator, applicationService, adminService, nakadiSettings);
    doReturn(randomUUID).when(uuid).randomUUID();
    doReturn(true).when(applicationService).exists(any());
    doReturn(true).when(featureToggleService).isFeatureEnabled(CHECK_PARTITIONS_KEYS);
    mockMvc = standaloneSetup(controller).setMessageConverters(new StringHttpMessageConverter(), TestUtils.JACKSON_2_HTTP_MESSAGE_CONVERTER).setCustomArgumentResolvers(new ClientResolver(settings, featureToggleService)).setControllerAdvice(new ExceptionHandling()).build();
}
Also used : TransactionCallback(org.springframework.transaction.support.TransactionCallback) PartitionsCalculator(org.zalando.nakadi.repository.kafka.PartitionsCalculator) EventTypeService(org.zalando.nakadi.service.EventTypeService) EventTypeOptionsValidator(org.zalando.nakadi.validation.EventTypeOptionsValidator) ClientResolver(org.zalando.nakadi.security.ClientResolver) NakadiSettings(org.zalando.nakadi.config.NakadiSettings) StringHttpMessageConverter(org.springframework.http.converter.StringHttpMessageConverter) KafkaConfig(org.zalando.nakadi.repository.kafka.KafkaConfig) Before(org.junit.Before)

Example 14 with StringHttpMessageConverter

use of org.springframework.http.converter.StringHttpMessageConverter in project spring-cloud-netflix by spring-cloud.

the class RestClientRibbonCommandIntegrationTests method javascriptEncodedFormParams.

@Override
@SuppressWarnings("deprecation")
@Test
public void javascriptEncodedFormParams() {
    TestRestTemplate testRestTemplate = new TestRestTemplate();
    ArrayList<HttpMessageConverter<?>> converters = new ArrayList<>();
    converters.addAll(Arrays.asList(new StringHttpMessageConverter(), new NoEncodingFormHttpMessageConverter()));
    testRestTemplate.getRestTemplate().setMessageConverters(converters);
    MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
    map.add("foo", "(bar)");
    ResponseEntity<String> result = testRestTemplate.postForEntity("http://localhost:" + this.port + "/simple/local", map, String.class);
    assertEquals(HttpStatus.OK, result.getStatusCode());
    assertEquals("Posted [(bar)] and Content-Length was: -1!", result.getBody());
}
Also used : TestRestTemplate(org.springframework.boot.test.web.client.TestRestTemplate) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) StringHttpMessageConverter(org.springframework.http.converter.StringHttpMessageConverter) HttpMessageConverter(org.springframework.http.converter.HttpMessageConverter) NoEncodingFormHttpMessageConverter(org.springframework.cloud.netflix.zuul.filters.route.support.NoEncodingFormHttpMessageConverter) ArrayList(java.util.ArrayList) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) StringHttpMessageConverter(org.springframework.http.converter.StringHttpMessageConverter) NoEncodingFormHttpMessageConverter(org.springframework.cloud.netflix.zuul.filters.route.support.NoEncodingFormHttpMessageConverter) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Example 15 with StringHttpMessageConverter

use of org.springframework.http.converter.StringHttpMessageConverter in project spring-cloud-netflix by spring-cloud.

the class ZuulProxyTestBase method javascriptEncodedFormParams.

@SuppressWarnings("deprecation")
@Test
public void javascriptEncodedFormParams() {
    TestRestTemplate testRestTemplate = new TestRestTemplate();
    ArrayList<HttpMessageConverter<?>> converters = new ArrayList<>();
    converters.addAll(Arrays.asList(new StringHttpMessageConverter(), new NoEncodingFormHttpMessageConverter()));
    testRestTemplate.getRestTemplate().setMessageConverters(converters);
    MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
    map.add("foo", "(bar)");
    ResponseEntity<String> result = testRestTemplate.postForEntity("http://localhost:" + this.port + "/simple/local", map, String.class);
    assertEquals(HttpStatus.OK, result.getStatusCode());
    assertEquals("Posted [(bar)] and Content-Length was: 13!", result.getBody());
}
Also used : TestRestTemplate(org.springframework.boot.test.web.client.TestRestTemplate) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) FormHttpMessageConverter(org.springframework.http.converter.FormHttpMessageConverter) StringHttpMessageConverter(org.springframework.http.converter.StringHttpMessageConverter) HttpMessageConverter(org.springframework.http.converter.HttpMessageConverter) ArrayList(java.util.ArrayList) StringHttpMessageConverter(org.springframework.http.converter.StringHttpMessageConverter) Test(org.junit.Test)

Aggregations

StringHttpMessageConverter (org.springframework.http.converter.StringHttpMessageConverter)91 HttpMessageConverter (org.springframework.http.converter.HttpMessageConverter)46 ArrayList (java.util.ArrayList)38 MappingJackson2HttpMessageConverter (org.springframework.http.converter.json.MappingJackson2HttpMessageConverter)25 ByteArrayHttpMessageConverter (org.springframework.http.converter.ByteArrayHttpMessageConverter)24 RestTemplate (org.springframework.web.client.RestTemplate)23 Test (org.junit.jupiter.api.Test)21 ResourceHttpMessageConverter (org.springframework.http.converter.ResourceHttpMessageConverter)18 Test (org.junit.Test)16 AllEncompassingFormHttpMessageConverter (org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter)16 MappingJackson2XmlHttpMessageConverter (org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter)11 MediaType (org.springframework.http.MediaType)9 MockHttpServletRequest (org.springframework.web.testfixture.servlet.MockHttpServletRequest)9 MockHttpServletResponse (org.springframework.web.testfixture.servlet.MockHttpServletResponse)9 SerDeHttpMessageConverter (com.kixeye.chassis.transport.http.SerDeHttpMessageConverter)7 MessageSerDe (com.kixeye.chassis.transport.serde.MessageSerDe)7 URI (java.net.URI)7 HashMap (java.util.HashMap)7 Before (org.junit.Before)7 MethodParameter (org.springframework.core.MethodParameter)7