JAVA-4277: Fix tests in spring-resttemplate module (#10447)
* JAVA-4277: Fix tests in spring-resttemplate module * JAVA-4277: Moved article from spring-resttemplate to spring-resttemplate-2
This commit is contained in:
parent
e07bcb5315
commit
7d78e63edf
|
@ -10,3 +10,4 @@ This module contains articles about Spring RestTemplate
|
|||
- [RestTemplate Post Request with JSON](https://www.baeldung.com/spring-resttemplate-post-json)
|
||||
- [How to Compress Requests Using the Spring RestTemplate](https://www.baeldung.com/spring-resttemplate-compressing-requests)
|
||||
- [Get list of JSON objects with Spring RestTemplate](https://www.baeldung.com/spring-resttemplate-json-list)
|
||||
- [A Guide To Spring Redirects](https://www.baeldung.com/spring-redirect-and-forward)
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-boot-2</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>parent-boot-2/pom.xml</relativePath>
|
||||
<relativePath>../../parent-boot-2/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
|
||||
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd"
|
||||
>
|
||||
|
||||
<context:component-scan base-package="com.baeldung.sampleapp.web" />
|
||||
|
||||
<mvc:annotation-driven content-negotiation-manager="contentNegotiationManager" >
|
||||
<mvc:message-converters register-defaults="true">
|
||||
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"/>
|
||||
<!-- <bean class="org.springframework.http.converter.protobuf.ProtobufHttpMessageConverter"/> -->
|
||||
</mvc:message-converters>
|
||||
</mvc:annotation-driven>
|
||||
|
||||
|
||||
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" />
|
||||
<bean class="org.springframework.web.servlet.view.XmlViewResolver">
|
||||
<property name="location">
|
||||
<value>/WEB-INF/spring-views.xml</value>
|
||||
</property>
|
||||
<property name="order" value="0" />
|
||||
</bean>
|
||||
|
||||
|
||||
<bean id="contentNegotiationManager"
|
||||
class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
|
||||
<property name="defaultContentType" value="application/json" />
|
||||
</bean>
|
||||
|
||||
|
||||
</beans>
|
||||
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"
|
||||
>
|
||||
|
||||
<bean id="RedirectedUrl" class="org.springframework.web.servlet.view.RedirectView">
|
||||
<property name="url" value="redirectedUrl" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
|
@ -188,7 +188,7 @@
|
|||
<artifactId>cargo-maven2-plugin</artifactId>
|
||||
<version>${cargo-maven2-plugin.version}</version>
|
||||
<configuration>
|
||||
<!--<wait>true</wait> caused errors on commit -->
|
||||
<wait>true</wait>
|
||||
<container>
|
||||
<containerId>tomcat8x</containerId>
|
||||
<type>embedded</type>
|
||||
|
@ -297,7 +297,7 @@
|
|||
<guava.version>20.0</guava.version>
|
||||
|
||||
<!-- Maven plugins -->
|
||||
<cargo-maven2-plugin.version>1.6.0</cargo-maven2-plugin.version>
|
||||
<cargo-maven2-plugin.version>1.6.1</cargo-maven2-plugin.version>
|
||||
<findbugs-maven-plugin.version>3.0.4</findbugs-maven-plugin.version>
|
||||
|
||||
<!-- okhttp -->
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.resttemplate.web.service;
|
||||
package com.baeldung.mock;
|
||||
|
||||
import com.baeldung.resttemplate.web.model.Employee;
|
||||
import org.slf4j.Logger;
|
|
@ -18,6 +18,7 @@ import org.springframework.web.client.RestTemplate;
|
|||
import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
|
||||
// This test needs RestTemplateConfigurationApplication to be up and running
|
||||
public class TestRestTemplateBasicLiveTest {
|
||||
|
||||
private RestTemplate restTemplate;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package com.baeldung.web.service;
|
||||
package com.baeldung.mock;
|
||||
|
||||
import static org.springframework.test.web.client.match.MockRestRequestMatchers.method;
|
||||
import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
|
||||
|
@ -7,8 +7,9 @@ import static org.springframework.test.web.client.response.MockRestResponseCreat
|
|||
import java.net.URI;
|
||||
|
||||
import com.baeldung.SpringTestConfig;
|
||||
import com.baeldung.mock.EmployeeService;
|
||||
import com.baeldung.resttemplate.web.model.Employee;
|
||||
import com.baeldung.resttemplate.web.service.EmployeeService;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
|
@ -1,7 +1,8 @@
|
|||
package com.baeldung.web.service;
|
||||
package com.baeldung.mock;
|
||||
|
||||
import com.baeldung.mock.EmployeeService;
|
||||
import com.baeldung.resttemplate.web.model.Employee;
|
||||
import com.baeldung.resttemplate.web.service.EmployeeService;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
|
@ -38,6 +38,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
|
||||
import com.google.common.base.Charsets;
|
||||
|
||||
// This test needs RestTemplateConfigurationApplication to be up and running
|
||||
public class RestTemplateBasicLiveTest {
|
||||
|
||||
private RestTemplate restTemplate;
|
||||
|
|
Loading…
Reference in New Issue