timeout work
This commit is contained in:
parent
7d17c4dd9d
commit
a830caca39
@ -1,275 +1,294 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
<modelVersion>4.0.0</modelVersion>
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<groupId>org.baeldung</groupId>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>spring-security-rest-template</artifactId>
|
<groupId>org.baeldung</groupId>
|
||||||
<version>0.1-SNAPSHOT</version>
|
<artifactId>spring-security-rest-template</artifactId>
|
||||||
|
<version>0.1-SNAPSHOT</version>
|
||||||
|
|
||||||
<name>spring-security-rest-template</name>
|
<name>spring-security-rest-template</name>
|
||||||
<packaging>war</packaging>
|
<packaging>war</packaging>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<!-- Spring Security -->
|
<!-- Spring Security -->
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.security</groupId>
|
<groupId>org.springframework.security</groupId>
|
||||||
<artifactId>spring-security-web</artifactId>
|
<artifactId>spring-security-web</artifactId>
|
||||||
<version>${org.springframework.security.version}</version>
|
<version>${org.springframework.security.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.security</groupId>
|
<groupId>org.springframework.security</groupId>
|
||||||
<artifactId>spring-security-config</artifactId>
|
<artifactId>spring-security-config</artifactId>
|
||||||
<version>${org.springframework.security.version}</version>
|
<version>${org.springframework.security.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Spring -->
|
<!-- Spring -->
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-core</artifactId>
|
<artifactId>spring-core</artifactId>
|
||||||
<version>${org.springframework.version}</version>
|
<version>${org.springframework.version}</version>
|
||||||
</dependency>
|
<exclusions>
|
||||||
<dependency>
|
<exclusion>
|
||||||
<groupId>org.springframework</groupId>
|
<artifactId>commons-logging</artifactId>
|
||||||
<artifactId>spring-context</artifactId>
|
<groupId>commons-logging</groupId>
|
||||||
<version>${org.springframework.version}</version>
|
</exclusion>
|
||||||
</dependency>
|
</exclusions>
|
||||||
<dependency>
|
</dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<dependency>
|
||||||
<artifactId>spring-jdbc</artifactId>
|
<groupId>org.springframework</groupId>
|
||||||
<version>${org.springframework.version}</version>
|
<artifactId>spring-context</artifactId>
|
||||||
</dependency>
|
<version>${org.springframework.version}</version>
|
||||||
<dependency>
|
</dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<dependency>
|
||||||
<artifactId>spring-beans</artifactId>
|
<groupId>org.springframework</groupId>
|
||||||
<version>${org.springframework.version}</version>
|
<artifactId>spring-jdbc</artifactId>
|
||||||
</dependency>
|
<version>${org.springframework.version}</version>
|
||||||
<dependency>
|
</dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<dependency>
|
||||||
<artifactId>spring-aop</artifactId>
|
<groupId>org.springframework</groupId>
|
||||||
<version>${org.springframework.version}</version>
|
<artifactId>spring-beans</artifactId>
|
||||||
</dependency>
|
<version>${org.springframework.version}</version>
|
||||||
<dependency>
|
</dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<dependency>
|
||||||
<artifactId>spring-tx</artifactId>
|
<groupId>org.springframework</groupId>
|
||||||
<version>${org.springframework.version}</version>
|
<artifactId>spring-aop</artifactId>
|
||||||
</dependency>
|
<version>${org.springframework.version}</version>
|
||||||
<dependency>
|
</dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<dependency>
|
||||||
<artifactId>spring-expression</artifactId>
|
<groupId>org.springframework</groupId>
|
||||||
<version>${org.springframework.version}</version>
|
<artifactId>spring-tx</artifactId>
|
||||||
</dependency>
|
<version>${org.springframework.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-expression</artifactId>
|
||||||
|
<version>${org.springframework.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-web</artifactId>
|
<artifactId>spring-web</artifactId>
|
||||||
<version>${org.springframework.version}</version>
|
<version>${org.springframework.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-webmvc</artifactId>
|
<artifactId>spring-webmvc</artifactId>
|
||||||
<version>${org.springframework.version}</version>
|
<version>${org.springframework.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-oxm</artifactId>
|
<artifactId>spring-oxm</artifactId>
|
||||||
<version>${org.springframework.version}</version>
|
<version>${org.springframework.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- marshalling -->
|
<!-- marshalling -->
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
<version>2.2.2</version>
|
<version>2.2.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- http -->
|
<!-- http -->
|
||||||
|
|
||||||
|
<!-- <dependency> -->
|
||||||
|
<!-- <groupId>org.apache.httpcomponents</groupId> -->
|
||||||
|
<!-- <artifactId>fluent-hc</artifactId> -->
|
||||||
|
<!-- <version>4.2.5</version> -->
|
||||||
|
<!-- <exclusions> -->
|
||||||
|
<!-- <exclusion> -->
|
||||||
|
<!-- <artifactId>commons-logging</artifactId> -->
|
||||||
|
<!-- <groupId>commons-logging</groupId> -->
|
||||||
|
<!-- </exclusion> -->
|
||||||
|
<!-- </exclusions> -->
|
||||||
|
<!-- </dependency> -->
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.httpcomponents</groupId>
|
||||||
|
<artifactId>httpcore</artifactId>
|
||||||
|
<version>${httpcore.version}</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>commons-logging</artifactId>
|
||||||
|
<groupId>commons-logging</groupId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.httpcomponents</groupId>
|
<groupId>org.apache.httpcomponents</groupId>
|
||||||
<artifactId>httpcore</artifactId>
|
<artifactId>httpclient</artifactId>
|
||||||
<version>${httpcore.version}</version>
|
<version>${httpclient.version}</version>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<artifactId>commons-logging</artifactId>
|
<artifactId>commons-logging</artifactId>
|
||||||
<groupId>commons-logging</groupId>
|
<groupId>commons-logging</groupId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<!-- web -->
|
||||||
<groupId>org.apache.httpcomponents</groupId>
|
|
||||||
<artifactId>httpclient</artifactId>
|
|
||||||
<version>${httpclient.version}</version>
|
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<artifactId>commons-logging</artifactId>
|
|
||||||
<groupId>commons-logging</groupId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- web -->
|
<dependency>
|
||||||
|
<groupId>javax.servlet</groupId>
|
||||||
|
<artifactId>javax.servlet-api</artifactId>
|
||||||
|
<version>3.0.1</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.servlet</groupId>
|
<groupId>javax.servlet</groupId>
|
||||||
<artifactId>javax.servlet-api</artifactId>
|
<artifactId>jstl</artifactId>
|
||||||
<version>3.0.1</version>
|
<version>1.2</version>
|
||||||
<scope>provided</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<!-- util -->
|
||||||
<groupId>javax.servlet</groupId>
|
|
||||||
<artifactId>jstl</artifactId>
|
|
||||||
<version>1.2</version>
|
|
||||||
<scope>runtime</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- util -->
|
<dependency>
|
||||||
|
<groupId>com.google.guava</groupId>
|
||||||
|
<artifactId>guava</artifactId>
|
||||||
|
<version>${guava.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<!-- test scoped -->
|
||||||
<groupId>com.google.guava</groupId>
|
|
||||||
<artifactId>guava</artifactId>
|
|
||||||
<version>${guava.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- test scoped -->
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-test</artifactId>
|
||||||
|
<version>${org.springframework.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>spring-test</artifactId>
|
<artifactId>junit-dep</artifactId>
|
||||||
<version>${org.springframework.version}</version>
|
<version>${junit.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>org.hamcrest</groupId>
|
||||||
<artifactId>junit-dep</artifactId>
|
<artifactId>hamcrest-core</artifactId>
|
||||||
<version>${junit.version}</version>
|
<version>${org.hamcrest.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.hamcrest</groupId>
|
||||||
|
<artifactId>hamcrest-library</artifactId>
|
||||||
|
<version>${org.hamcrest.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.hamcrest</groupId>
|
<groupId>org.mockito</groupId>
|
||||||
<artifactId>hamcrest-core</artifactId>
|
<artifactId>mockito-core</artifactId>
|
||||||
<version>${org.hamcrest.version}</version>
|
<version>${mockito.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.hamcrest</groupId>
|
|
||||||
<artifactId>hamcrest-library</artifactId>
|
|
||||||
<version>${org.hamcrest.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
</dependencies>
|
||||||
<groupId>org.mockito</groupId>
|
|
||||||
<artifactId>mockito-core</artifactId>
|
|
||||||
<version>${mockito.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
<build>
|
||||||
|
<finalName>spring-security-rest-template</finalName>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
|
||||||
<build>
|
<plugins>
|
||||||
<finalName>spring-security-rest-template</finalName>
|
|
||||||
<resources>
|
|
||||||
<resource>
|
|
||||||
<directory>src/main/resources</directory>
|
|
||||||
<filtering>true</filtering>
|
|
||||||
</resource>
|
|
||||||
</resources>
|
|
||||||
|
|
||||||
<plugins>
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.1</version>
|
||||||
|
<configuration>
|
||||||
|
<source>1.7</source>
|
||||||
|
<target>1.7</target>
|
||||||
|
<debug>true</debug>
|
||||||
|
<debuglevel>source</debuglevel>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<version>3.1</version>
|
<version>${maven-surefire-plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.7</source>
|
<excludes>
|
||||||
<target>1.7</target>
|
<exclude>**/*LiveTest.java</exclude>
|
||||||
<debug>true</debug>
|
</excludes>
|
||||||
<debuglevel>source</debuglevel>
|
<systemPropertyVariables>
|
||||||
</configuration>
|
<!-- <provPersistenceTarget>h2</provPersistenceTarget> -->
|
||||||
</plugin>
|
</systemPropertyVariables>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.codehaus.cargo</groupId>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>cargo-maven2-plugin</artifactId>
|
||||||
<version>${maven-surefire-plugin.version}</version>
|
<version>${cargo-maven2-plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<excludes>
|
<wait>true</wait>
|
||||||
<exclude>**/*LiveTest.java</exclude>
|
<container>
|
||||||
</excludes>
|
<containerId>jetty8x</containerId>
|
||||||
<systemPropertyVariables>
|
<type>embedded</type>
|
||||||
<!-- <provPersistenceTarget>h2</provPersistenceTarget> -->
|
<systemProperties>
|
||||||
</systemPropertyVariables>
|
<!-- <provPersistenceTarget>cargo</provPersistenceTarget> -->
|
||||||
</configuration>
|
</systemProperties>
|
||||||
</plugin>
|
</container>
|
||||||
|
<configuration>
|
||||||
|
<properties>
|
||||||
|
<cargo.servlet.port>8082</cargo.servlet.port>
|
||||||
|
</properties>
|
||||||
|
</configuration>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
<plugin>
|
</plugins>
|
||||||
<groupId>org.codehaus.cargo</groupId>
|
|
||||||
<artifactId>cargo-maven2-plugin</artifactId>
|
|
||||||
<version>${cargo-maven2-plugin.version}</version>
|
|
||||||
<configuration>
|
|
||||||
<wait>true</wait>
|
|
||||||
<container>
|
|
||||||
<containerId>jetty8x</containerId>
|
|
||||||
<type>embedded</type>
|
|
||||||
<systemProperties>
|
|
||||||
<!-- <provPersistenceTarget>cargo</provPersistenceTarget> -->
|
|
||||||
</systemProperties>
|
|
||||||
</container>
|
|
||||||
<configuration>
|
|
||||||
<properties>
|
|
||||||
<cargo.servlet.port>8082</cargo.servlet.port>
|
|
||||||
</properties>
|
|
||||||
</configuration>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
</plugins>
|
</build>
|
||||||
|
|
||||||
</build>
|
<properties>
|
||||||
|
<!-- Spring -->
|
||||||
|
<org.springframework.version>3.2.3.RELEASE</org.springframework.version>
|
||||||
|
<org.springframework.security.version>3.1.4.RELEASE</org.springframework.security.version>
|
||||||
|
|
||||||
<properties>
|
<!-- persistence -->
|
||||||
<!-- Spring -->
|
<hibernate.version>4.2.3.Final</hibernate.version>
|
||||||
<org.springframework.version>3.2.3.RELEASE</org.springframework.version>
|
<mysql-connector-java.version>5.1.25</mysql-connector-java.version>
|
||||||
<org.springframework.security.version>3.1.4.RELEASE</org.springframework.security.version>
|
|
||||||
|
|
||||||
<!-- persistence -->
|
<!-- http -->
|
||||||
<hibernate.version>4.2.3.Final</hibernate.version>
|
<httpcore.version>4.2.4</httpcore.version>
|
||||||
<mysql-connector-java.version>5.1.25</mysql-connector-java.version>
|
<httpclient.version>4.2.5</httpclient.version>
|
||||||
|
|
||||||
<!-- http -->
|
<!-- logging -->
|
||||||
<httpcore.version>4.2.4</httpcore.version>
|
<org.slf4j.version>1.7.5</org.slf4j.version>
|
||||||
<httpclient.version>4.2.5</httpclient.version>
|
<logback.version>1.0.11</logback.version>
|
||||||
|
|
||||||
<!-- logging -->
|
<!-- various -->
|
||||||
<org.slf4j.version>1.7.5</org.slf4j.version>
|
<hibernate-validator.version>5.0.1.Final</hibernate-validator.version>
|
||||||
<logback.version>1.0.11</logback.version>
|
|
||||||
|
|
||||||
<!-- various -->
|
<!-- util -->
|
||||||
<hibernate-validator.version>5.0.1.Final</hibernate-validator.version>
|
<guava.version>14.0.1</guava.version>
|
||||||
|
<commons-lang3.version>3.1</commons-lang3.version>
|
||||||
|
|
||||||
<!-- util -->
|
<!-- testing -->
|
||||||
<guava.version>14.0.1</guava.version>
|
<org.hamcrest.version>1.3</org.hamcrest.version>
|
||||||
<commons-lang3.version>3.1</commons-lang3.version>
|
<junit.version>4.11</junit.version>
|
||||||
|
<mockito.version>1.9.5</mockito.version>
|
||||||
|
|
||||||
<!-- testing -->
|
<rest-assured.version>1.8.1</rest-assured.version>
|
||||||
<org.hamcrest.version>1.3</org.hamcrest.version>
|
<groovy.version>1.8.9</groovy.version>
|
||||||
<junit.version>4.11</junit.version>
|
|
||||||
<mockito.version>1.9.5</mockito.version>
|
|
||||||
|
|
||||||
<rest-assured.version>1.8.1</rest-assured.version>
|
<!-- Maven plugins -->
|
||||||
<groovy.version>1.8.9</groovy.version>
|
<cargo-maven2-plugin.version>1.4.3</cargo-maven2-plugin.version>
|
||||||
|
<maven-surefire-plugin.version>2.15</maven-surefire-plugin.version>
|
||||||
<!-- Maven plugins -->
|
</properties>
|
||||||
<cargo-maven2-plugin.version>1.4.3</cargo-maven2-plugin.version>
|
|
||||||
<maven-surefire-plugin.version>2.15</maven-surefire-plugin.version>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
@ -30,4 +30,10 @@ public class FooController {
|
|||||||
return new Foo();
|
return new Foo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "/{id}/unsecured", method = RequestMethod.GET)
|
||||||
|
@ResponseBody
|
||||||
|
public Foo findOneUnsecured(@PathVariable("id") final Long id) {
|
||||||
|
return new Foo();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,8 @@
|
|||||||
</encoder>
|
</encoder>
|
||||||
</appender>
|
</appender>
|
||||||
|
|
||||||
|
<logger name="org.apache.http" level="TRACE" />
|
||||||
|
|
||||||
<logger name="org.springframework" level="WARN" />
|
<logger name="org.springframework" level="WARN" />
|
||||||
<logger name="org.springframework.transaction" level="WARN" />
|
<logger name="org.springframework.transaction" level="WARN" />
|
||||||
|
|
||||||
|
|||||||
@ -3,38 +3,43 @@ package org.baeldung.client;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.apache.http.HttpResponse;
|
import org.apache.http.HttpResponse;
|
||||||
import org.apache.http.auth.AuthScope;
|
|
||||||
import org.apache.http.auth.UsernamePasswordCredentials;
|
|
||||||
import org.apache.http.client.ClientProtocolException;
|
import org.apache.http.client.ClientProtocolException;
|
||||||
import org.apache.http.client.methods.HttpGet;
|
import org.apache.http.client.methods.HttpGet;
|
||||||
import org.apache.http.impl.client.DefaultHttpClient;
|
import org.apache.http.impl.client.DefaultHttpClient;
|
||||||
|
import org.apache.http.params.HttpConnectionParams;
|
||||||
|
import org.apache.http.params.HttpParams;
|
||||||
import org.baeldung.client.spring.ClientConfig;
|
import org.baeldung.client.spring.ClientConfig;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
|
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
||||||
import org.springframework.web.client.RestTemplate;
|
|
||||||
|
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@ContextConfiguration(classes = { ClientConfig.class }, loader = AnnotationConfigContextLoader.class)
|
@ContextConfiguration(classes = { ClientConfig.class }, loader = AnnotationConfigContextLoader.class)
|
||||||
public class RawClientLiveTest {
|
public class RawClientLiveTest {
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RestTemplate restTemplate;
|
|
||||||
|
|
||||||
// tests
|
// tests
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public final void whenSecuredRestApiIsConsumed_then200OK() throws ClientProtocolException, IOException {
|
public final void whenSecuredRestApiIsConsumed_then200OK() throws ClientProtocolException, IOException {
|
||||||
final HttpComponentsClientHttpRequestFactory requestFactory = (HttpComponentsClientHttpRequestFactory) restTemplate.getRequestFactory();
|
final DefaultHttpClient httpClient = new DefaultHttpClient();
|
||||||
final DefaultHttpClient httpClient = (DefaultHttpClient) requestFactory.getHttpClient();
|
|
||||||
httpClient.getCredentialsProvider().setCredentials(new AuthScope("localhost", 8080, AuthScope.ANY_REALM), new UsernamePasswordCredentials("user", "userPass"));
|
|
||||||
|
|
||||||
final HttpResponse response = httpClient.execute(new HttpGet("http://localhost:8080/spring-security-rest-template/api/foos/1"));
|
final int timeout = 5; // seconds
|
||||||
|
final HttpParams httpParams = httpClient.getParams();
|
||||||
|
// - note: timeout via raw String parameters
|
||||||
|
// httpParams.setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, timeout * 1000);
|
||||||
|
// httpParams.setParameter(CoreConnectionPNames.SO_TIMEOUT, timeout * 1000);
|
||||||
|
// httpParams.setParameter("http.connection-manager.timeout", new Long(timeout * 1000));
|
||||||
|
// httpParams.setParameter("http.protocol.head-body-timeout", timeout * 1000);
|
||||||
|
|
||||||
|
// - note: timeout via the API
|
||||||
|
HttpConnectionParams.setConnectionTimeout(httpParams, timeout * 1000); // http.connection.timeout
|
||||||
|
HttpConnectionParams.setSoTimeout(httpParams, timeout * 1000); // http.socket.timeout
|
||||||
|
|
||||||
|
final HttpResponse response = httpClient.execute(new HttpGet("http://localhost:8080/spring-security-rest-template/api/foos/1/unsecured"));
|
||||||
final int statusCode = response.getStatusLine().getStatusCode();
|
final int statusCode = response.getStatusLine().getStatusCode();
|
||||||
System.out.println(statusCode);
|
System.out.println(statusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user