Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
6cfbcafc
Commit
6cfbcafc
authored
Nov 29, 2013
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switch to httpcomponents for better error handling in tests
parent
5661f8fc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
26 deletions
+34
-26
pom.xml
spring-boot-dependencies/pom.xml
+12
-6
pom.xml
spring-boot/pom.xml
+7
-2
AbstractEmbeddedServletContainerFactoryTests.java
...mbedded/AbstractEmbeddedServletContainerFactoryTests.java
+15
-18
No files found.
spring-boot-dependencies/pom.xml
View file @
6cfbcafc
...
...
@@ -10,7 +10,6 @@
<activemq.version>
5.4.0
</activemq.version>
<aspectj.version>
1.7.3
</aspectj.version>
<commons-dbcp.version>
1.4
</commons-dbcp.version>
<commons-httpclient.version>
3.1
</commons-httpclient.version>
<gradle.version>
1.6
</gradle.version>
<groovy.version>
2.1.6
</groovy.version>
<h2.version>
1.3.172
</h2.version>
...
...
@@ -18,6 +17,8 @@
<hibernate-entitymanager.version>
4.2.1.Final
</hibernate-entitymanager.version>
<hibernate-jpa-api.version>
1.0.1.Final
</hibernate-jpa-api.version>
<hibernate-validator.version>
4.3.1.Final
</hibernate-validator.version>
<httpclient.version>
4.3.1
</httpclient.version>
<httpasyncclient.version>
4.0
</httpasyncclient.version>
<hsqldb.version>
2.2.9
</hsqldb.version>
<jackson.version>
2.2.2
</jackson.version>
<jetty.version>
8.1.9.v20130131
</jetty.version>
...
...
@@ -79,11 +80,6 @@
<artifactId>
commons-dbcp
</artifactId>
<version>
${commons-dbcp.version}
</version>
</dependency>
<dependency>
<groupId>
commons-httpclient
</groupId>
<artifactId>
commons-httpclient
</artifactId>
<version>
${commons-httpclient.version}
</version>
</dependency>
<dependency>
<groupId>
com.lambdaworks
</groupId>
<artifactId>
lettuce
</artifactId>
...
...
@@ -134,6 +130,16 @@
<artifactId>
activemq-pool
</artifactId>
<version>
${activemq.version}
</version>
</dependency>
<dependency>
<groupId>
org.apache.httpcomponents
</groupId>
<artifactId>
httpclient
</artifactId>
<version>
${httpclient.version}
</version>
</dependency>
<dependency>
<groupId>
org.apache.httpcomponents
</groupId>
<artifactId>
httpasyncclient
</artifactId>
<version>
${httpasyncclient.version}
</version>
</dependency>
<dependency>
<groupId>
org.apache.tomcat.embed
</groupId>
<artifactId>
tomcat-embed-core
</artifactId>
...
...
spring-boot/pom.xml
View file @
6cfbcafc
...
...
@@ -91,8 +91,13 @@
</dependency>
<!-- Test -->
<dependency>
<groupId>
commons-httpclient
</groupId>
<artifactId>
commons-httpclient
</artifactId>
<groupId>
org.apache.httpcomponents
</groupId>
<artifactId>
httpclient
</artifactId>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.apache.httpcomponents
</groupId>
<artifactId>
httpasyncclient
</artifactId>
<scope>
test
</scope>
</dependency>
<dependency>
...
...
spring-boot/src/test/java/org/springframework/boot/context/embedded/AbstractEmbeddedServletContainerFactoryTests.java
View file @
6cfbcafc
...
...
@@ -24,17 +24,14 @@ import java.net.URISyntaxException;
import
java.nio.charset.Charset
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.concurrent.TimeUnit
;
import
javax.servlet.ServletContext
;
import
javax.servlet.ServletException
;
import
javax.servlet.ServletRequest
;
import
javax.servlet.ServletResponse
;
import
org.apache.commons.httpclient.HttpClient
;
import
org.apache.commons.httpclient.MultiThreadedHttpConnectionManager
;
import
org.apache.commons.httpclient.methods.GetMethod
;
import
org.junit.After
;
import
org.junit.Ignore
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.rules.ExpectedException
;
...
...
@@ -44,9 +41,11 @@ import org.springframework.http.HttpMethod;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.client.ClientHttpRequest
;
import
org.springframework.http.client.ClientHttpResponse
;
import
org.springframework.http.client.SimpleClientHttpRequestFactory
;
import
org.springframework.http.client.HttpComponentsAsyncClientHttpRequestFactory
;
import
org.springframework.http.client.HttpComponentsClientHttpRequestFactory
;
import
org.springframework.util.FileCopyUtils
;
import
org.springframework.util.StreamUtils
;
import
org.springframework.util.concurrent.ListenableFuture
;
import
static
org
.
hamcrest
.
Matchers
.
equalTo
;
import
static
org
.
hamcrest
.
Matchers
.
notNullValue
;
...
...
@@ -115,25 +114,26 @@ public abstract class AbstractEmbeddedServletContainerFactoryTests {
}
@Test
@Ignore
public
void
restartWithKeepAlive
()
throws
Exception
{
ConfigurableEmbeddedServletContainerFactory
factory
=
getFactory
();
this
.
container
=
factory
.
getEmbeddedServletContainer
(
exampleServletRegistration
());
this
.
container
.
start
();
MultiThreadedHttpConnectionManager
connectionManager
=
new
MultiThreadedHttpConnectionManager
();
HttpClient
client
=
new
HttpClient
(
connectionManager
);
GetMethod
get1
=
new
GetMethod
(
"http://localhost:8080/hello"
);
assertThat
(
client
.
executeMethod
(
get1
),
equalTo
(
200
)
);
get1
.
releaseConnection
(
);
HttpComponentsAsyncClientHttpRequestFactory
clientHttpRequestFactory
=
new
HttpComponentsAsyncClientHttpRequestFactory
();
ListenableFuture
<
ClientHttpResponse
>
response1
=
clientHttpRequestFactory
.
createAsyncRequest
(
new
URI
(
"http://localhost:8080/hello"
),
HttpMethod
.
GET
).
executeAsync
(
);
assertThat
(
response1
.
get
(
10
,
TimeUnit
.
SECONDS
).
getRawStatusCode
(),
equalTo
(
200
)
);
this
.
container
.
stop
();
this
.
container
=
factory
.
getEmbeddedServletContainer
(
exampleServletRegistration
());
this
.
container
.
start
();
GetMethod
get2
=
new
GetMethod
(
"http://localhost:8080/hello"
);
assertThat
(
client
.
executeMethod
(
get2
),
equalTo
(
200
));
get2
.
releaseConnection
();
ListenableFuture
<
ClientHttpResponse
>
response2
=
clientHttpRequestFactory
.
createAsyncRequest
(
new
URI
(
"http://localhost:8080/hello"
),
HttpMethod
.
GET
).
executeAsync
();
assertThat
(
response2
.
get
(
10
,
TimeUnit
.
SECONDS
).
getRawStatusCode
(),
equalTo
(
200
));
}
@Test
...
...
@@ -267,9 +267,6 @@ public abstract class AbstractEmbeddedServletContainerFactoryTests {
}
@Test
@Ignore
// FIXME: how to test an error response (maybe java.net.HttpUrlConnection isn't going
// to cut it)
public
void
errorPage
()
throws
Exception
{
ConfigurableEmbeddedServletContainerFactory
factory
=
getFactory
();
factory
.
addErrorPages
(
new
ErrorPage
(
HttpStatus
.
INTERNAL_SERVER_ERROR
,
"/hello"
));
...
...
@@ -292,7 +289,7 @@ public abstract class AbstractEmbeddedServletContainerFactoryTests {
protected
ClientHttpResponse
getClientResponse
(
String
url
)
throws
IOException
,
URISyntaxException
{
SimpleClientHttpRequestFactory
clientHttpRequestFactory
=
new
Simple
ClientHttpRequestFactory
();
HttpComponentsClientHttpRequestFactory
clientHttpRequestFactory
=
new
HttpComponents
ClientHttpRequestFactory
();
ClientHttpRequest
request
=
clientHttpRequestFactory
.
createRequest
(
new
URI
(
url
),
HttpMethod
.
GET
);
ClientHttpResponse
response
=
request
.
execute
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment