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
0a689b50
Unverified
Commit
0a689b50
authored
Dec 20, 2017
by
Spencer Gibb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
polish
parent
ac1ac4d5
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
22 deletions
+22
-22
PatternServiceRouteMapperIntegrationTests.java
.../discovery/PatternServiceRouteMapperIntegrationTests.java
+15
-22
LocationRewriteFilterTests.java
...netflix/zuul/filters/post/LocationRewriteFilterTests.java
+7
-0
No files found.
spring-cloud-netflix-zuul/src/test/java/org/springframework/cloud/netflix/zuul/filters/discovery/PatternServiceRouteMapperIntegrationTests.java
View file @
0a689b50
...
@@ -8,19 +8,17 @@ import org.junit.Before;
...
@@ -8,19 +8,17 @@ import org.junit.Before;
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.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.SpringBootConfiguration
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.boot.test.context.SpringBootTest.WebEnvironment
;
import
org.springframework.boot.test.web.client.TestRestTemplate
;
import
org.springframework.boot.test.web.client.TestRestTemplate
;
import
org.springframework.boot.web.server.LocalServerPort
;
import
org.springframework.cloud.client.discovery.DiscoveryClient
;
import
org.springframework.cloud.client.discovery.DiscoveryClient
;
import
org.springframework.cloud.netflix.ribbon.RibbonClient
;
import
org.springframework.cloud.netflix.ribbon.RibbonClient
;
import
org.springframework.cloud.netflix.ribbon.StaticServerList
;
import
org.springframework.cloud.netflix.ribbon.StaticServerList
;
import
org.springframework.cloud.netflix.zuul.EnableZuulProxy
;
import
org.springframework.cloud.netflix.zuul.EnableZuulProxy
;
import
org.springframework.cloud.netflix.zuul.RoutesEndpoint
;
import
org.springframework.cloud.netflix.zuul.RoutesEndpoint
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpMethod
;
import
org.springframework.http.HttpMethod
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
...
@@ -39,21 +37,21 @@ import com.netflix.zuul.context.RequestContext;
...
@@ -39,21 +37,21 @@ import com.netflix.zuul.context.RequestContext;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
static
org
.
springframework
.
cloud
.
netflix
.
zuul
.
filters
.
discovery
.
PatternServiceRouteMapperIntegrationTests
.
SERVICE_ID
;
import
static
org
.
springframework
.
boot
.
test
.
context
.
SpringBootTest
.
WebEnvironment
.
RANDOM_PORT
;
/**
/**
* @author Stéphane Leroy
* @author Stéphane Leroy
*/
*/
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringBootTest
(
classes
=
SampleCustomZuulProxyApplication
.
class
,
webEnvironment
=
WebEnvironment
.
RANDOM_PORT
,
value
=
{
@SpringBootTest
(
webEnvironment
=
RANDOM_PORT
,
"spring.application.name=regex-test-application"
,
"spring.jmx.enabled=false"
,
properties
=
{
"spring.application.name=regex-test-application"
,
"spring.jmx.enabled=false"
,
"eureka.client.enabled=false"
})
"eureka.client.enabled=false"
})
@DirtiesContext
@DirtiesContext
public
class
PatternServiceRouteMapperIntegrationTests
{
public
class
PatternServiceRouteMapperIntegrationTests
{
protected
static
final
String
SERVICE_ID
=
"domain-service-v1"
;
protected
static
final
String
SERVICE_ID
=
"domain-service-v1"
;
@
Value
(
"${local.server.port}"
)
@
LocalServerPort
private
int
port
;
private
int
port
;
@Autowired
@Autowired
...
@@ -94,14 +92,12 @@ public class PatternServiceRouteMapperIntegrationTests {
...
@@ -94,14 +92,12 @@ public class PatternServiceRouteMapperIntegrationTests {
assertEquals
(
"Get 1"
,
result
.
getBody
());
assertEquals
(
"Get 1"
,
result
.
getBody
());
}
}
}
@SpringBootConfiguration
@EnableAutoConfiguration
@Configuration
@RestController
@EnableAutoConfiguration
@EnableZuulProxy
@RestController
@RibbonClient
(
value
=
SERVICE_ID
,
configuration
=
SimpleRibbonClientConfiguration
.
class
)
@EnableZuulProxy
protected
static
class
SampleCustomZuulProxyApplication
{
@RibbonClient
(
value
=
SERVICE_ID
,
configuration
=
SimpleRibbonClientConfiguration
.
class
)
class
SampleCustomZuulProxyApplication
{
@Bean
@Bean
public
DiscoveryClient
discoveryClient
()
{
public
DiscoveryClient
discoveryClient
()
{
...
@@ -124,19 +120,16 @@ class SampleCustomZuulProxyApplication {
...
@@ -124,19 +120,16 @@ class SampleCustomZuulProxyApplication {
"${version}/${domain}/${name}"
);
"${version}/${domain}/${name}"
);
}
}
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
SampleCustomZuulProxyApplication
.
class
,
args
);
}
}
}
@Configuration
protected
static
class
SimpleRibbonClientConfiguration
{
class
SimpleRibbonClientConfiguration
{
@Value
(
"${local.server.port}"
)
@LocalServerPort
private
int
port
=
0
;
private
int
port
=
0
;
@Bean
@Bean
public
ServerList
<
Server
>
ribbonServerList
()
{
public
ServerList
<
Server
>
ribbonServerList
()
{
return
new
StaticServerList
<>(
new
Server
(
"localhost"
,
this
.
port
));
return
new
StaticServerList
<>(
new
Server
(
"localhost"
,
this
.
port
));
}
}
}
}
}
spring-cloud-netflix-zuul/src/test/java/org/springframework/cloud/netflix/zuul/filters/post/LocationRewriteFilterTests.java
View file @
0a689b50
...
@@ -19,6 +19,7 @@ package org.springframework.cloud.netflix.zuul.filters.post;
...
@@ -19,6 +19,7 @@ package org.springframework.cloud.netflix.zuul.filters.post;
import
com.netflix.util.Pair
;
import
com.netflix.util.Pair
;
import
com.netflix.zuul.context.RequestContext
;
import
com.netflix.zuul.context.RequestContext
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.springframework.cloud.netflix.zuul.filters.Route
;
import
org.springframework.cloud.netflix.zuul.filters.Route
;
...
@@ -57,6 +58,12 @@ public class LocationRewriteFilterTests {
...
@@ -57,6 +58,12 @@ public class LocationRewriteFilterTests {
RequestContext
.
testSetCurrentContext
(
context
);
RequestContext
.
testSetCurrentContext
(
context
);
}
}
@After
public
void
reset
()
{
RequestContext
.
getCurrentContext
().
clear
();
}
@Test
@Test
public
void
shouldRewriteLocationHeadersWithRoutePrefix
()
{
public
void
shouldRewriteLocationHeadersWithRoutePrefix
()
{
RequestContext
context
=
RequestContext
.
getCurrentContext
();
RequestContext
context
=
RequestContext
.
getCurrentContext
();
...
...
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