http client configuration work
This commit is contained in:
parent
a830caca39
commit
1e7f8dc2b0
@ -1,294 +1,318 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<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">
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<groupId>org.baeldung</groupId>
|
||||||
<groupId>org.baeldung</groupId>
|
<artifactId>spring-security-rest-template</artifactId>
|
||||||
<artifactId>spring-security-rest-template</artifactId>
|
<version>0.1-SNAPSHOT</version>
|
||||||
<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>
|
||||||
<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>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-context</artifactId>
|
<artifactId>spring-context</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-jdbc</artifactId>
|
<artifactId>spring-jdbc</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-beans</artifactId>
|
<artifactId>spring-beans</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-aop</artifactId>
|
<artifactId>spring-aop</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-tx</artifactId>
|
<artifactId>spring-tx</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-expression</artifactId>
|
<artifactId>spring-expression</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-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>httpclient</artifactId>
|
<!-- <artifactId>fluent-hc</artifactId> -->
|
||||||
<version>${httpclient.version}</version>
|
<!-- <version>4.2.5</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> -->
|
||||||
|
|
||||||
<!-- web -->
|
<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>javax.servlet</groupId>
|
<groupId>org.apache.httpcomponents</groupId>
|
||||||
<artifactId>javax.servlet-api</artifactId>
|
<artifactId>httpclient</artifactId>
|
||||||
<version>3.0.1</version>
|
<version>${httpclient.version}</version>
|
||||||
<scope>provided</scope>
|
<exclusions>
|
||||||
</dependency>
|
<exclusion>
|
||||||
|
<artifactId>commons-logging</artifactId>
|
||||||
|
<groupId>commons-logging</groupId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<!-- web -->
|
||||||
<groupId>javax.servlet</groupId>
|
|
||||||
<artifactId>jstl</artifactId>
|
|
||||||
<version>1.2</version>
|
|
||||||
<scope>runtime</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- util -->
|
<dependency>
|
||||||
|
<groupId>javax.servlet</groupId>
|
||||||
|
<artifactId>javax.servlet-api</artifactId>
|
||||||
|
<version>3.0.1</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.guava</groupId>
|
<groupId>javax.servlet</groupId>
|
||||||
<artifactId>guava</artifactId>
|
<artifactId>jstl</artifactId>
|
||||||
<version>${guava.version}</version>
|
<version>1.2</version>
|
||||||
</dependency>
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- test scoped -->
|
<!-- util -->
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>com.google.guava</groupId>
|
||||||
<artifactId>spring-test</artifactId>
|
<artifactId>guava</artifactId>
|
||||||
<version>${org.springframework.version}</version>
|
<version>${guava.version}</version>
|
||||||
<scope>test</scope>
|
</dependency>
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<!-- logging -->
|
||||||
<groupId>junit</groupId>
|
|
||||||
<artifactId>junit-dep</artifactId>
|
|
||||||
<version>${junit.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.hamcrest</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>hamcrest-core</artifactId>
|
<artifactId>slf4j-api</artifactId>
|
||||||
<version>${org.hamcrest.version}</version>
|
<version>${org.slf4j.version}</version>
|
||||||
<scope>test</scope>
|
</dependency>
|
||||||
</dependency>
|
<dependency>
|
||||||
<dependency>
|
<groupId>ch.qos.logback</groupId>
|
||||||
<groupId>org.hamcrest</groupId>
|
<artifactId>logback-classic</artifactId>
|
||||||
<artifactId>hamcrest-library</artifactId>
|
<version>${logback.version}</version>
|
||||||
<version>${org.hamcrest.version}</version>
|
<!-- <scope>runtime</scope> -->
|
||||||
<scope>test</scope>
|
</dependency>
|
||||||
</dependency>
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>jcl-over-slf4j</artifactId>
|
||||||
|
<version>${org.slf4j.version}</version>
|
||||||
|
<!-- <scope>runtime</scope> --> <!-- some spring dependencies need to compile against jcl -->
|
||||||
|
</dependency>
|
||||||
|
<dependency> <!-- needed to bridge to slf4j for projects that use the log4j APIs directly -->
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>log4j-over-slf4j</artifactId>
|
||||||
|
<version>${org.slf4j.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<!-- test scoped -->
|
||||||
<groupId>org.mockito</groupId>
|
|
||||||
<artifactId>mockito-core</artifactId>
|
|
||||||
<version>${mockito.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-test</artifactId>
|
||||||
|
<version>${org.springframework.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<build>
|
<dependency>
|
||||||
<finalName>spring-security-rest-template</finalName>
|
<groupId>junit</groupId>
|
||||||
<resources>
|
<artifactId>junit-dep</artifactId>
|
||||||
<resource>
|
<version>${junit.version}</version>
|
||||||
<directory>src/main/resources</directory>
|
<scope>test</scope>
|
||||||
<filtering>true</filtering>
|
</dependency>
|
||||||
</resource>
|
|
||||||
</resources>
|
|
||||||
|
|
||||||
<plugins>
|
<dependency>
|
||||||
|
<groupId>org.hamcrest</groupId>
|
||||||
|
<artifactId>hamcrest-core</artifactId>
|
||||||
|
<version>${org.hamcrest.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.hamcrest</groupId>
|
||||||
|
<artifactId>hamcrest-library</artifactId>
|
||||||
|
<version>${org.hamcrest.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<plugin>
|
<dependency>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.mockito</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>mockito-core</artifactId>
|
||||||
<version>3.1</version>
|
<version>${mockito.version}</version>
|
||||||
<configuration>
|
<scope>test</scope>
|
||||||
<source>1.7</source>
|
</dependency>
|
||||||
<target>1.7</target>
|
|
||||||
<debug>true</debug>
|
|
||||||
<debuglevel>source</debuglevel>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
<plugin>
|
</dependencies>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
|
||||||
<version>${maven-surefire-plugin.version}</version>
|
|
||||||
<configuration>
|
|
||||||
<excludes>
|
|
||||||
<exclude>**/*LiveTest.java</exclude>
|
|
||||||
</excludes>
|
|
||||||
<systemPropertyVariables>
|
|
||||||
<!-- <provPersistenceTarget>h2</provPersistenceTarget> -->
|
|
||||||
</systemPropertyVariables>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
<plugin>
|
<build>
|
||||||
<groupId>org.codehaus.cargo</groupId>
|
<finalName>spring-security-rest-template</finalName>
|
||||||
<artifactId>cargo-maven2-plugin</artifactId>
|
<resources>
|
||||||
<version>${cargo-maven2-plugin.version}</version>
|
<resource>
|
||||||
<configuration>
|
<directory>src/main/resources</directory>
|
||||||
<wait>true</wait>
|
<filtering>true</filtering>
|
||||||
<container>
|
</resource>
|
||||||
<containerId>jetty8x</containerId>
|
</resources>
|
||||||
<type>embedded</type>
|
|
||||||
<systemProperties>
|
|
||||||
<!-- <provPersistenceTarget>cargo</provPersistenceTarget> -->
|
|
||||||
</systemProperties>
|
|
||||||
</container>
|
|
||||||
<configuration>
|
|
||||||
<properties>
|
|
||||||
<cargo.servlet.port>8082</cargo.servlet.port>
|
|
||||||
</properties>
|
|
||||||
</configuration>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
</plugins>
|
<plugins>
|
||||||
|
|
||||||
</build>
|
<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>
|
||||||
|
|
||||||
<properties>
|
<plugin>
|
||||||
<!-- Spring -->
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<org.springframework.version>3.2.3.RELEASE</org.springframework.version>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<org.springframework.security.version>3.1.4.RELEASE</org.springframework.security.version>
|
<version>${maven-surefire-plugin.version}</version>
|
||||||
|
<configuration>
|
||||||
|
<excludes>
|
||||||
|
<exclude>**/*LiveTest.java</exclude>
|
||||||
|
</excludes>
|
||||||
|
<systemPropertyVariables>
|
||||||
|
<!-- <provPersistenceTarget>h2</provPersistenceTarget> -->
|
||||||
|
</systemPropertyVariables>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
<!-- persistence -->
|
<plugin>
|
||||||
<hibernate.version>4.2.3.Final</hibernate.version>
|
<groupId>org.codehaus.cargo</groupId>
|
||||||
<mysql-connector-java.version>5.1.25</mysql-connector-java.version>
|
<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>
|
||||||
|
|
||||||
<!-- http -->
|
</plugins>
|
||||||
<httpcore.version>4.2.4</httpcore.version>
|
|
||||||
<httpclient.version>4.2.5</httpclient.version>
|
|
||||||
|
|
||||||
<!-- logging -->
|
</build>
|
||||||
<org.slf4j.version>1.7.5</org.slf4j.version>
|
|
||||||
<logback.version>1.0.11</logback.version>
|
|
||||||
|
|
||||||
<!-- various -->
|
<properties>
|
||||||
<hibernate-validator.version>5.0.1.Final</hibernate-validator.version>
|
<!-- Spring -->
|
||||||
|
<org.springframework.version>3.2.3.RELEASE</org.springframework.version>
|
||||||
|
<org.springframework.security.version>3.1.4.RELEASE</org.springframework.security.version>
|
||||||
|
|
||||||
<!-- util -->
|
<!-- persistence -->
|
||||||
<guava.version>14.0.1</guava.version>
|
<hibernate.version>4.2.3.Final</hibernate.version>
|
||||||
<commons-lang3.version>3.1</commons-lang3.version>
|
<mysql-connector-java.version>5.1.25</mysql-connector-java.version>
|
||||||
|
|
||||||
<!-- testing -->
|
<!-- http -->
|
||||||
<org.hamcrest.version>1.3</org.hamcrest.version>
|
<httpcore.version>4.2.4</httpcore.version>
|
||||||
<junit.version>4.11</junit.version>
|
<httpclient.version>4.2.5</httpclient.version>
|
||||||
<mockito.version>1.9.5</mockito.version>
|
|
||||||
|
|
||||||
<rest-assured.version>1.8.1</rest-assured.version>
|
<!-- logging -->
|
||||||
<groovy.version>1.8.9</groovy.version>
|
<org.slf4j.version>1.7.5</org.slf4j.version>
|
||||||
|
<logback.version>1.0.11</logback.version> <!-- do not upgrade - see http://jira.qos.ch/browse/LOGBACK-851 -->
|
||||||
|
|
||||||
<!-- Maven plugins -->
|
<!-- various -->
|
||||||
<cargo-maven2-plugin.version>1.4.3</cargo-maven2-plugin.version>
|
<hibernate-validator.version>5.0.1.Final</hibernate-validator.version>
|
||||||
<maven-surefire-plugin.version>2.15</maven-surefire-plugin.version>
|
|
||||||
</properties>
|
<!-- util -->
|
||||||
|
<guava.version>14.0.1</guava.version>
|
||||||
|
<commons-lang3.version>3.1</commons-lang3.version>
|
||||||
|
|
||||||
|
<!-- testing -->
|
||||||
|
<org.hamcrest.version>1.3</org.hamcrest.version>
|
||||||
|
<junit.version>4.11</junit.version>
|
||||||
|
<mockito.version>1.9.5</mockito.version>
|
||||||
|
|
||||||
|
<rest-assured.version>1.8.1</rest-assured.version>
|
||||||
|
<groovy.version>1.8.9</groovy.version>
|
||||||
|
|
||||||
|
<!-- Maven plugins -->
|
||||||
|
<cargo-maven2-plugin.version>1.4.3</cargo-maven2-plugin.version>
|
||||||
|
<maven-surefire-plugin.version>2.15</maven-surefire-plugin.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
@ -0,0 +1,31 @@
|
|||||||
|
package org.baeldung.web.controller;
|
||||||
|
|
||||||
|
import org.baeldung.web.dto.Bar;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.ApplicationEventPublisher;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequestMapping(value = "/bars")
|
||||||
|
public class BarController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ApplicationEventPublisher eventPublisher;
|
||||||
|
|
||||||
|
public BarController() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
// API
|
||||||
|
|
||||||
|
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
|
||||||
|
@ResponseBody
|
||||||
|
public Bar findOne(@PathVariable("id") final Long id) {
|
||||||
|
return new Bar();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -30,10 +30,4 @@ 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();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
package org.baeldung.web.dto;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
@XmlRootElement
|
||||||
|
public class Bar implements Serializable {
|
||||||
|
|
||||||
|
public Bar() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -7,7 +7,6 @@
|
|||||||
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd">
|
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd">
|
||||||
|
|
||||||
<http use-expressions="true">
|
<http use-expressions="true">
|
||||||
<intercept-url pattern="/**" access="isAuthenticated()" />
|
|
||||||
|
|
||||||
<http-basic />
|
<http-basic />
|
||||||
|
|
||||||
@ -21,4 +20,6 @@
|
|||||||
</authentication-provider>
|
</authentication-provider>
|
||||||
</authentication-manager>
|
</authentication-manager>
|
||||||
|
|
||||||
|
<global-method-security pre-post-annotations="enabled" />
|
||||||
|
|
||||||
</beans:beans>
|
</beans:beans>
|
@ -1,11 +1,15 @@
|
|||||||
package org.baeldung.client;
|
package org.baeldung.client;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Timer;
|
||||||
|
import java.util.TimerTask;
|
||||||
|
|
||||||
import org.apache.http.HttpResponse;
|
import org.apache.http.HttpResponse;
|
||||||
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.client.params.ClientPNames;
|
||||||
import org.apache.http.impl.client.DefaultHttpClient;
|
import org.apache.http.impl.client.DefaultHttpClient;
|
||||||
|
import org.apache.http.params.CoreConnectionPNames;
|
||||||
import org.apache.http.params.HttpConnectionParams;
|
import org.apache.http.params.HttpConnectionParams;
|
||||||
import org.apache.http.params.HttpParams;
|
import org.apache.http.params.HttpParams;
|
||||||
import org.baeldung.client.spring.ClientConfig;
|
import org.baeldung.client.spring.ClientConfig;
|
||||||
@ -25,21 +29,39 @@ public class RawClientLiveTest {
|
|||||||
public final void whenSecuredRestApiIsConsumed_then200OK() throws ClientProtocolException, IOException {
|
public final void whenSecuredRestApiIsConsumed_then200OK() throws ClientProtocolException, IOException {
|
||||||
final DefaultHttpClient httpClient = new DefaultHttpClient();
|
final DefaultHttpClient httpClient = new DefaultHttpClient();
|
||||||
|
|
||||||
final int timeout = 5; // seconds
|
final int timeout = 20; // seconds
|
||||||
final HttpParams httpParams = httpClient.getParams();
|
final HttpParams httpParams = httpClient.getParams();
|
||||||
// - note: timeout via raw String parameters
|
configureViaRawApi(timeout, httpParams);
|
||||||
// httpParams.setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, timeout * 1000);
|
// configureViaHighLevelApi(timeout, httpParams);
|
||||||
// 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
|
final HttpGet getMethod = new HttpGet("http://localhost:8080/spring-security-rest-template/api/bars/1");
|
||||||
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 hardTimeout = 5; // seconds
|
||||||
final int statusCode = response.getStatusLine().getStatusCode();
|
final TimerTask task = new TimerTask() {
|
||||||
System.out.println(statusCode);
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (getMethod != null) {
|
||||||
|
getMethod.abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
new Timer(true).schedule(task, hardTimeout * 1000);
|
||||||
|
|
||||||
|
final HttpResponse response = httpClient.execute(getMethod);
|
||||||
|
System.out.println("HTTP Status of response: " + response.getStatusLine().getStatusCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// util
|
||||||
|
|
||||||
|
final void configureViaHighLevelApi(final int timeout, final HttpParams httpParams) {
|
||||||
|
HttpConnectionParams.setConnectionTimeout(httpParams, timeout * 1000); // http.connection.timeout
|
||||||
|
HttpConnectionParams.setSoTimeout(httpParams, timeout * 1000); // http.socket.timeout
|
||||||
|
httpParams.setParameter(ClientPNames.CONN_MANAGER_TIMEOUT, new Long(timeout * 1000));
|
||||||
|
}
|
||||||
|
|
||||||
|
final void configureViaRawApi(final int timeout, final HttpParams httpParams) {
|
||||||
|
httpParams.setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, timeout * 1000);
|
||||||
|
httpParams.setParameter(CoreConnectionPNames.SO_TIMEOUT, timeout * 1000);
|
||||||
|
httpParams.setParameter(ClientPNames.CONN_MANAGER_TIMEOUT, new Long(timeout * 1000));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user