All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.dthoffman.tomcatmock.junit.spring.JokeAppSpringConfig Maven / Gradle / Ivy

Go to download

Helper code to spin up a tomcat app during tests and mocking downstream http calls

The newest version!
package com.dthoffman.tomcatmock.junit.spring;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.annotation.PropertySources;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;

@Configuration
@PropertySources({@PropertySource("classpath:/config/${environment:prod}.properties")})
public class JokeAppSpringConfig {
    @Bean
    static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
        return new PropertySourcesPlaceholderConfigurer();
    }

    @Bean
    HttpClient httpClient() {
        return HttpClientBuilder.create().build();
    }

    @Bean
    ObjectMapper objectMapper() {
        return new ObjectMapper();
    }

    @Bean
    JokeAppController jokeAppController() {
        return new JokeAppController();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy