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
39b1c0fe
Unverified
Commit
39b1c0fe
authored
Sep 29, 2017
by
Spencer Gibb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update routes endpoint to new endpoint infrastructure.
fixes gh-2318
parent
6f2fc1de
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
40 deletions
+25
-40
spring-cloud-netflix.adoc
docs/src/main/asciidoc/spring-cloud-netflix.adoc
+1
-1
RoutesEndpoint.java
...rg/springframework/cloud/netflix/zuul/RoutesEndpoint.java
+7
-8
RoutesEndpointDetailsTests.java
...mework/cloud/netflix/zuul/RoutesEndpointDetailsTests.java
+15
-12
RoutesEndpointIntegrationTests.java
...rk/cloud/netflix/zuul/RoutesEndpointIntegrationTests.java
+1
-5
RoutesEndpointTests.java
...ringframework/cloud/netflix/zuul/RoutesEndpointTests.java
+1
-14
No files found.
docs/src/main/asciidoc/spring-cloud-netflix.adoc
View file @
39b1c0fe
...
...
@@ -1715,7 +1715,7 @@ routes:
Additional route details can be requested by adding the `?format=details` query
string to `/routes`. This will produce the following output:
.GET /routes
?format=
details
.GET /routes
/
details
[source,json]
----
{
...
...
spring-cloud-netflix-zuul/src/main/java/org/springframework/cloud/netflix/zuul/RoutesEndpoint.java
View file @
39b1c0fe
...
...
@@ -23,6 +23,7 @@ import java.util.Set;
import
org.springframework.boot.actuate.endpoint.annotation.Endpoint
;
import
org.springframework.boot.actuate.endpoint.annotation.ReadOperation
;
import
org.springframework.boot.actuate.endpoint.annotation.Selector
;
import
org.springframework.boot.actuate.endpoint.annotation.WriteOperation
;
import
org.springframework.cloud.netflix.zuul.filters.Route
;
import
org.springframework.cloud.netflix.zuul.filters.RouteLocator
;
...
...
@@ -44,6 +45,7 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder;
public
class
RoutesEndpoint
implements
ApplicationEventPublisherAware
{
static
final
String
ID
=
"routes"
;
static
final
String
FORMAT_DETAILS
=
"details"
;
private
RouteLocator
routes
;
...
...
@@ -84,17 +86,14 @@ public class RoutesEndpoint implements ApplicationEventPublisherAware {
/**
* Expose Zuul {@link Route} information with details.
*/
//FIXME 2.0.x
/*@GetMapping(params = "format", produces = { ActuatorMediaTypes.APPLICATION_ACTUATOR_V1_JSON_VALUE,
MediaType.APPLICATION_JSON_VALUE })
@ResponseBody
public Object invokeRouteDetails(@RequestParam String format) {
@ReadOperation
public
Object
invokeRouteDetails
(
@Selector
String
format
)
{
if
(
FORMAT_DETAILS
.
equalsIgnoreCase
(
format
))
{
return
endpoint.
invokeRouteDetails();
return
invokeRouteDetails
();
}
else
{
return super.invoke();
return
invoke
();
}
}
}*/
/**
* Container for exposing Zuul {@link Route} details as JSON.
...
...
spring-cloud-netflix-zuul/src/test/java/org/springframework/cloud/netflix/zuul/Routes
MvcEndpoint
Tests.java
→
spring-cloud-netflix-zuul/src/test/java/org/springframework/cloud/netflix/zuul/Routes
EndpointDetails
Tests.java
View file @
39b1c0fe
...
...
@@ -21,19 +21,25 @@ package org.springframework.cloud.netflix.zuul;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.mockito.Mock
;
import
org.mockito.
runners
.MockitoJUnitRunner
;
import
org.mockito.
junit
.MockitoJUnitRunner
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.cloud.netflix.zuul.filters.Route
;
import
org.springframework.cloud.netflix.zuul.filters.RouteLocator
;
import
org.springframework.context.ApplicationEventPublisher
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
mockito
.
ArgumentMatchers
.
isA
;
import
static
org
.
mockito
.
Mockito
.
spy
;
import
static
org
.
mockito
.
Mockito
.
times
;
import
static
org
.
mockito
.
Mockito
.
verify
;
/**
* @author Ryan Baxter
...
...
@@ -41,7 +47,7 @@ import static org.mockito.Mockito.spy;
*/
@SpringBootTest
@RunWith
(
MockitoJUnitRunner
.
class
)
public
class
Routes
MvcEndpoint
Tests
{
public
class
Routes
EndpointDetails
Tests
{
private
RouteLocator
locator
;
private
RoutesEndpoint
endpoint
;
@Mock
...
...
@@ -73,28 +79,24 @@ public class RoutesMvcEndpointTests {
@Test
public
void
reset
()
throws
Exception
{
//FIXME: 2.0.x
/*RoutesMvcEndpoint mvcEndpoint = new RoutesMvcEndpoint(endpoint, locator);
mvcEndpoint.setApplicationEventPublisher(publisher);
Map<String, String> result = new HashMap<String, String>();
this
.
endpoint
.
setApplicationEventPublisher
(
publisher
);
Map
<
String
,
String
>
result
=
new
HashMap
<>();
for
(
Route
r
:
locator
.
getRoutes
())
{
result
.
put
(
r
.
getFullPath
(),
r
.
getLocation
());
}
assertEquals(result ,
mvcE
ndpoint.reset());
assertEquals
(
result
,
e
ndpoint
.
reset
());
verify
(
endpoint
,
times
(
1
)).
invoke
();
verify(publisher, times(1)).publishEvent(isA(RoutesRefreshedEvent.class));
*/
verify
(
publisher
,
times
(
1
)).
publishEvent
(
isA
(
RoutesRefreshedEvent
.
class
));
}
@Test
public
void
routeDetails
()
throws
Exception
{
//FIXME: 2.0.x
/*RoutesMvcEndpoint mvcEndpoint = new RoutesMvcEndpoint(endpoint, locator);
Map
<
String
,
RoutesEndpoint
.
RouteDetails
>
results
=
new
HashMap
<>();
for
(
Route
route
:
locator
.
getRoutes
())
{
results
.
put
(
route
.
getFullPath
(),
new
RoutesEndpoint
.
RouteDetails
(
route
));
}
assertEquals(results,
mvcEndpoint.invokeRouteDetails(RoutesMvc
Endpoint.FORMAT_DETAILS));
verify(endpoint, times(1)).invokeRouteDetails();
*/
assertEquals
(
results
,
this
.
endpoint
.
invokeRouteDetails
(
Routes
Endpoint
.
FORMAT_DETAILS
));
verify
(
endpoint
,
times
(
1
)).
invokeRouteDetails
();
}
}
\ No newline at end of file
spring-cloud-netflix-zuul/src/test/java/org/springframework/cloud/netflix/zuul/RoutesEndpointIntegrationTests.java
View file @
39b1c0fe
...
...
@@ -19,7 +19,6 @@ package org.springframework.cloud.netflix.zuul;
import
java.util.Map
;
import
org.junit.Ignore
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -60,14 +59,12 @@ public class RoutesEndpointIntegrationTests {
private
SimpleZuulProxyApplication
.
RoutesRefreshListener
refreshListener
;
@Test
@Ignore
// FIXME: 2.0.x
public
void
getRoutesTest
()
{
Map
<
String
,
String
>
routes
=
restTemplate
.
getForObject
(
"/admin/routes"
,
Map
.
class
);
assertEquals
(
"https://localhost:8443"
,
routes
.
get
(
"/sslservice/**"
));
}
@Test
@Ignore
// FIXME: 2.0.x
public
void
postRoutesTest
()
{
Map
<
String
,
String
>
routes
=
restTemplate
.
postForObject
(
"/admin/routes"
,
null
,
Map
.
class
);
assertEquals
(
"https://localhost:8443"
,
routes
.
get
(
"/sslservice/**"
));
...
...
@@ -75,10 +72,9 @@ public class RoutesEndpointIntegrationTests {
}
@Test
@Ignore
// FIXME: 2.0.x
public
void
getRouteDetailsTest
()
{
ResponseEntity
<
Map
<
String
,
RoutesEndpoint
.
RouteDetails
>>
responseEntity
=
restTemplate
.
exchange
(
"/admin/routes
?format=
details"
,
HttpMethod
.
GET
,
null
,
new
ParameterizedTypeReference
<
Map
<
String
,
RoutesEndpoint
.
RouteDetails
>>()
{
"/admin/routes
/
details"
,
HttpMethod
.
GET
,
null
,
new
ParameterizedTypeReference
<
Map
<
String
,
RoutesEndpoint
.
RouteDetails
>>()
{
});
assertThat
(
responseEntity
.
getStatusCode
(),
is
(
HttpStatus
.
OK
));
...
...
spring-cloud-netflix-zuul/src/test/java/org/springframework/cloud/netflix/zuul/RoutesEndpointTests.java
View file @
39b1c0fe
...
...
@@ -24,13 +24,13 @@ import java.util.Collections;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.springframework.cloud.netflix.zuul.filters.Route
;
import
org.springframework.cloud.netflix.zuul.filters.RouteLocator
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
/**
* @author Ryan Baxter
...
...
@@ -83,16 +83,4 @@ public class RoutesEndpointTests {
assertEquals
(
results
,
endpoint
.
invokeRouteDetails
());
}
//FIXME 2.0.x
/*@Test
public void testId() {
RoutesEndpoint endpoint = new RoutesEndpoint(locator);
assertEquals("routes", endpoint.getId());
}
@Test
public void testIsSensitive() {
RoutesEndpoint endpoint = new RoutesEndpoint(locator);
assertTrue(endpoint.isSensitive());
}*/
}
\ No newline at end of file
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