Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
spring-cloud-netflix
Project
Overview
Details
Activity
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
openSource
spring-cloud-netflix
Commits
29e691a4
Commit
29e691a4
authored
Jan 27, 2016
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix some zuul tests (clear request context before test)
parent
22b08f1a
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
38 deletions
+45
-38
AdhocTestSuite.java
...ava/org/springframework/cloud/netflix/AdhocTestSuite.java
+5
-2
CustomHostRoutingFilterTests.java
...ud/netflix/zuul/filters/CustomHostRoutingFilterTests.java
+0
-0
ProxyRequestHelperTests.java
...k/cloud/netflix/zuul/filters/ProxyRequestHelperTests.java
+8
-8
DiscoveryClientRouteLocatorTests.java
...l/filters/discovery/DiscoveryClientRouteLocatorTests.java
+32
-28
No files found.
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/AdhocTestSuite.java
View file @
29e691a4
...
...
@@ -20,7 +20,9 @@ import org.junit.Ignore;
import
org.junit.runner.RunWith
;
import
org.junit.runners.Suite
;
import
org.junit.runners.Suite.SuiteClasses
;
import
org.springframework.cloud.netflix.feign.valid.FeignHttpClientTests
;
import
org.springframework.cloud.netflix.zuul.filters.CustomHostRoutingFilterTests
;
import
org.springframework.cloud.netflix.zuul.filters.ProxyRequestHelperTests
;
import
org.springframework.cloud.netflix.zuul.filters.discovery.DiscoveryClientRouteLocatorTests
;
/**
* A test suite for probing weird ordering problems in the tests.
...
...
@@ -28,7 +30,8 @@ import org.springframework.cloud.netflix.feign.valid.FeignHttpClientTests;
* @author Dave Syer
*/
@RunWith
(
Suite
.
class
)
@SuiteClasses
({
FeignHttpClientTests
.
class
})
@SuiteClasses
({
DiscoveryClientRouteLocatorTests
.
class
,
CustomHostRoutingFilterTests
.
class
,
ProxyRequestHelperTests
.
class
})
@Ignore
public
class
AdhocTestSuite
{
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/zuul/filters/CustomHostRoutingFilterTests.java
View file @
29e691a4
This diff is collapsed.
Click to expand it.
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/zuul/filters/ProxyRequestHelperTests.java
View file @
29e691a4
...
...
@@ -56,6 +56,12 @@ public class ProxyRequestHelperTests {
initMocks
(
this
);
}
@Before
public
void
setTestRequestcontext
()
{
RequestContext
context
=
new
RequestContext
();
RequestContext
.
testSetCurrentContext
(
context
);
}
@Test
public
void
debug
()
throws
Exception
{
MockHttpServletRequest
request
=
new
MockHttpServletRequest
(
"POST"
,
"/"
);
...
...
@@ -130,10 +136,7 @@ public class ProxyRequestHelperTests {
MultiValueMap
<
String
,
String
>
headers
=
new
HttpHeaders
();
headers
.
add
(
HttpHeaders
.
CONTENT_ENCODING
.
toLowerCase
(),
"gzip"
);
helper
.
setResponse
(
200
,
request
.
getInputStream
(),
headers
);
helper
.
setResponse
(
200
,
request
.
getInputStream
(),
headers
);
assertTrue
(
context
.
getResponseGZipped
());
}
...
...
@@ -151,10 +154,7 @@ public class ProxyRequestHelperTests {
MultiValueMap
<
String
,
String
>
headers
=
new
HttpHeaders
();
headers
.
add
(
HttpHeaders
.
CONTENT_ENCODING
,
"gzip"
);
helper
.
setResponse
(
200
,
request
.
getInputStream
(),
headers
);
helper
.
setResponse
(
200
,
request
.
getInputStream
(),
headers
);
assertTrue
(
context
.
getResponseGZipped
());
}
}
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/zuul/filters/discovery/DiscoveryClientRouteLocatorTests.java
View file @
29e691a4
...
...
@@ -66,7 +66,7 @@ public class DiscoveryClientRouteLocatorTests {
@Before
public
void
init
()
{
initMocks
(
this
);
setTestRequestcontext
();
//re-initialize Zuul context for each test
setTestRequestcontext
();
//
re-initialize Zuul context for each test
}
@Test
...
...
@@ -96,8 +96,9 @@ public class DiscoveryClientRouteLocatorTests {
@Test
public
void
testGetMatchingPathWithServletPath
()
throws
Exception
{
setTestRequestcontext
();
RequestContext
.
getCurrentContext
().
set
(
RequestUtils
.
IS_DISPATCHERSERVLETREQUEST
,
true
);
setTestRequestcontext
();
RequestContext
.
getCurrentContext
().
set
(
RequestUtils
.
IS_DISPATCHERSERVLETREQUEST
,
true
);
DiscoveryClientRouteLocator
routeLocator
=
new
DiscoveryClientRouteLocator
(
"/app"
,
this
.
discovery
,
this
.
properties
);
this
.
properties
.
getRoutes
().
put
(
"foo"
,
new
ZuulRoute
(
"/foo/**"
));
...
...
@@ -107,20 +108,20 @@ public class DiscoveryClientRouteLocatorTests {
assertEquals
(
"foo"
,
route
.
getLocation
());
assertEquals
(
"/1"
,
route
.
getPath
());
}
@Test
public
void
testGetMatchingPathWithZuulServletPath
()
throws
Exception
{
RequestContext
.
getCurrentContext
().
setZuulEngineRan
();
DiscoveryClientRouteLocator
routeLocator
=
new
DiscoveryClientRouteLocator
(
"/app"
,
this
.
discovery
,
this
.
properties
);
this
.
properties
.
getRoutes
().
put
(
"foo"
,
new
ZuulRoute
(
"/foo/**"
));
this
.
properties
.
init
();
routeLocator
.
getRoutes
();
// force refresh
Route
route
=
routeLocator
.
getMatchingRoute
(
"/zuul/foo/1"
);
assertEquals
(
"foo"
,
route
.
getLocation
());
assertEquals
(
"/1"
,
route
.
getPath
());
}
@Test
public
void
testGetMatchingPathWithZuulServletPath
()
throws
Exception
{
RequestContext
.
getCurrentContext
().
setZuulEngineRan
();
DiscoveryClientRouteLocator
routeLocator
=
new
DiscoveryClientRouteLocator
(
"/app"
,
this
.
discovery
,
this
.
properties
);
this
.
properties
.
getRoutes
().
put
(
"foo"
,
new
ZuulRoute
(
"/foo/**"
));
this
.
properties
.
init
();
routeLocator
.
getRoutes
();
// force refresh
Route
route
=
routeLocator
.
getMatchingRoute
(
"/zuul/foo/1"
);
assertEquals
(
"foo"
,
route
.
getLocation
());
assertEquals
(
"/1"
,
route
.
getPath
());
}
@Test
public
void
testGetMatchingPathWithNoPrefixStripping
()
throws
Exception
{
...
...
@@ -161,10 +162,12 @@ public class DiscoveryClientRouteLocatorTests {
assertEquals
(
"foo"
,
route
.
getLocation
());
assertEquals
(
"/foo/1"
,
route
.
getPath
());
}
@Test
public
void
testGetMatchingPathWithGlobalPrefixStrippingAndServletPath
()
throws
Exception
{
RequestContext
.
getCurrentContext
().
set
(
RequestUtils
.
IS_DISPATCHERSERVLETREQUEST
,
true
);
public
void
testGetMatchingPathWithGlobalPrefixStrippingAndServletPath
()
throws
Exception
{
RequestContext
.
getCurrentContext
().
set
(
RequestUtils
.
IS_DISPATCHERSERVLETREQUEST
,
true
);
DiscoveryClientRouteLocator
routeLocator
=
new
DiscoveryClientRouteLocator
(
"/app"
,
this
.
discovery
,
this
.
properties
);
this
.
properties
.
getRoutes
().
put
(
"foo"
,
...
...
@@ -174,10 +177,11 @@ public class DiscoveryClientRouteLocatorTests {
Route
route
=
routeLocator
.
getMatchingRoute
(
"/app/proxy/foo/1"
);
assertEquals
(
"foo"
,
route
.
getLocation
());
assertEquals
(
"/foo/1"
,
route
.
getPath
());
}
}
@Test
public
void
testGetMatchingPathWithGlobalPrefixStrippingAndZuulServletPath
()
throws
Exception
{
public
void
testGetMatchingPathWithGlobalPrefixStrippingAndZuulServletPath
()
throws
Exception
{
RequestContext
.
getCurrentContext
().
setZuulEngineRan
();
DiscoveryClientRouteLocator
routeLocator
=
new
DiscoveryClientRouteLocator
(
"/"
,
this
.
discovery
,
this
.
properties
);
...
...
@@ -188,7 +192,7 @@ public class DiscoveryClientRouteLocatorTests {
Route
route
=
routeLocator
.
getMatchingRoute
(
"/zuul/proxy/foo/1"
);
assertEquals
(
"foo"
,
route
.
getLocation
());
assertEquals
(
"/foo/1"
,
route
.
getPath
());
}
}
@Test
public
void
testGetMatchingPathWithRoutePrefixStripping
()
throws
Exception
{
...
...
@@ -644,10 +648,10 @@ public class DiscoveryClientRouteLocatorTests {
}
return
null
;
}
private
void
setTestRequestcontext
()
{
RequestContext
context
=
new
RequestContext
();
RequestContext
.
testSetCurrentContext
(
context
);
RequestContext
context
=
new
RequestContext
();
RequestContext
.
testSetCurrentContext
(
context
);
}
}
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