package com.aemreunal.config;

/*
 * *********************** *
 * Copyright (c) 2015      *
 *                         *
 * This code belongs to:   *
 *                         *
 * @author Ahmet Emre Ünal *
 * S001974                 *
 *                         *
 * aemreunal@gmail.com     *
 * emre.unal@ozu.edu.tr    *
 *                         *
 * aemreunal.com           *
 * *********************** *
 */

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.ByteArrayHttpMessageConverter;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.hibernate4.Hibernate4Module;

/*
 * http://www.petrikainulainen.net/programming/spring-framework/unit-testing-of-spring-mvc-controllers-configuration/
 */

@Configuration
@EnableWebMvc
@ComponentScan(GlobalSettings.BASE_PACKAGE_NAME)
public class MVCConfig extends WebMvcConfigurerAdapter {
    @Autowired
    public MappingJackson2HttpMessageConverter jacksonMessageConverter;

    @Autowired
    public ByteArrayHttpMessageConverter byteArrayHttpMessageConverter;

//    @Autowired
//    private SessionFactory sessionFactory;

    @Bean
    public MappingJackson2HttpMessageConverter jacksonMessageConverter() {
        MappingJackson2HttpMessageConverter messageConverter = new MappingJackson2HttpMessageConverter();
        ObjectMapper mapper = new ObjectMapper();
        //Registering Hibernate4Module to support lazy objects
        mapper.registerModule(new Hibernate4Module());
        messageConverter.setObjectMapper(mapper);
        return messageConverter;
    }

    @Bean
    public ByteArrayHttpMessageConverter byteArrayHttpMessageConverter() {
        return new ByteArrayHttpMessageConverter();
    }

    @Override
    public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
        // Add our custom-configured HttpMessageConverters
        converters.add(jacksonMessageConverter);
        converters.add(byteArrayHttpMessageConverter);
        super.configureMessageConverters(converters);
    }

//    @Override
//    public void addInterceptors(InterceptorRegistry registry) {
//        super.addInterceptors(registry);
//        OpenSessionInViewInterceptor osiv = new OpenSessionInViewInterceptor();
//        osiv.setSessionFactory(sessionFactory);
//        registry.addWebRequestInterceptor(osiv);
//    }
}

@@ -798,32 +798,102 @@
 ssageConverter;%0A
+import org.springframework.http.converter.StringHttpMessageConverter;%0A
 import org.sprin
@@ -952,32 +952,32 @@
 ssageConverter;%0A
-
 import org.sprin
@@ -1670,16 +1670,98 @@
 erter;%0A%0A
+    @Autowired%0A    public StringHttpMessageConverter stringHttpMessageConverter;%0A%0A
 //    @A
@@ -2404,24 +2404,159 @@
 r();%0A    %7D%0A%0A
+    @Bean%0A    public StringHttpMessageConverter stringHttpMessageConverter() %7B%0A        return new StringHttpMessageConverter();%0A    %7D%0A%0A
     @Overrid
@@ -2744,32 +2744,32 @@
 sageConverter);%0A
-
         converte
@@ -2799,32 +2799,84 @@
 sageConverter);%0A
+        converters.add(stringHttpMessageConverter);%0A
         super.co

Add String message converter for returning HTML