Updates to boot 2.0.0 endpoint and properties.

parent ef508b42
...@@ -105,7 +105,10 @@ public class EurekaClientAutoConfigurationTests { ...@@ -105,7 +105,10 @@ public class EurekaClientAutoConfigurationTests {
@Test @Test
public void securePortUnderscores() { public void securePortUnderscores() {
testSecurePort("SERVER_PORT"); TestPropertyValues.of("eureka.instance.secure-port-enabled=true").applyTo(this.context);
addSystemEnvironment(this.context.getEnvironment(), "SERVER_PORT:8443");
setupContext();
assertEquals(8443, getInstanceConfig().getSecurePort());
} }
@Test @Test
...@@ -396,8 +399,7 @@ public class EurekaClientAutoConfigurationTests { ...@@ -396,8 +399,7 @@ public class EurekaClientAutoConfigurationTests {
} }
private void testSecurePort(String propName) { private void testSecurePort(String propName) {
EnvironmentTestUtils.addEnvironment(this.context, "eureka.instance.securePortEnabled=true"); TestPropertyValues.of("eureka.instance.secure-port-enabled=true", propName+":8443").applyTo(this.context);
addEnvironment(this.context, propName + ":8443");
setupContext(); setupContext();
assertEquals(8443, getInstanceConfig().getSecurePort()); assertEquals(8443, getInstanceConfig().getSecurePort());
} }
......
package org.springframework.cloud.netflix.zuul; package org.springframework.cloud.netflix.zuul;
import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.filters.FilterRegistry;
import org.springframework.boot.actuate.endpoint.AbstractEndpoint;
import org.springframework.jmx.export.annotation.ManagedAttribute;
import org.springframework.jmx.export.annotation.ManagedResource;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.TreeMap; import java.util.TreeMap;
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.filters.FilterRegistry;
/** /**
* Endpoint for listing Zuul filters. * Endpoint for listing Zuul filters.
* *
* @author Daryl Robbins * @author Daryl Robbins
* @author Gregor Zurowski * @author Gregor Zurowski
*/ */
@ManagedResource(description = "List Zuul filters") @Endpoint(id = "filters")
public class FiltersEndpoint extends AbstractEndpoint<Map<String, List<Map<String, Object>>>> { public class FiltersEndpoint {
private static final String ID = "filters";
private final FilterRegistry filterRegistry; private final FilterRegistry filterRegistry;
public FiltersEndpoint(FilterRegistry filterRegistry) { public FiltersEndpoint(FilterRegistry filterRegistry) {
super(ID, true);
this.filterRegistry = filterRegistry; this.filterRegistry = filterRegistry;
} }
@ManagedAttribute @ReadOperation
@Override
public Map<String, List<Map<String, Object>>> invoke() { public Map<String, List<Map<String, Object>>> invoke() {
// Map of filters by type // Map of filters by type
final Map<String, List<Map<String, Object>>> filterMap = new TreeMap<>(); final Map<String, List<Map<String, Object>>> filterMap = new TreeMap<>();
...@@ -39,7 +35,7 @@ public class FiltersEndpoint extends AbstractEndpoint<Map<String, List<Map<Strin ...@@ -39,7 +35,7 @@ public class FiltersEndpoint extends AbstractEndpoint<Map<String, List<Map<Strin
for (ZuulFilter filter : this.filterRegistry.getAllFilters()) { for (ZuulFilter filter : this.filterRegistry.getAllFilters()) {
// Ensure that we have a list to store filters of each type // Ensure that we have a list to store filters of each type
if (!filterMap.containsKey(filter.filterType())) { if (!filterMap.containsKey(filter.filterType())) {
filterMap.put(filter.filterType(), new ArrayList<Map<String, Object>>()); filterMap.put(filter.filterType(), new ArrayList<>());
} }
final Map<String, Object> filterInfo = new LinkedHashMap<>(); final Map<String, Object> filterInfo = new LinkedHashMap<>();
......
/*
* Copyright 2013-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud.netflix.zuul; package org.springframework.cloud.netflix.zuul;
import com.netflix.zuul.ZuulFilter; import java.util.List;
import java.util.Map;
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.boot.SpringBootConfiguration;
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.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.web.bind.annotation.RestController;
import java.util.List; import com.netflix.zuul.ZuulFilter;
import java.util.Map;
import static org.hibernate.validator.internal.util.Contracts.assertTrue; import static org.hibernate.validator.internal.util.Contracts.assertTrue;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
/** /**
* Tests for Filters endpoint * Tests for Filters endpoint
*/ */
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = FiltersEndpointApplication.class, @SpringBootTest(webEnvironment = RANDOM_PORT)
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
value = { "server.contextPath: /app" })
public class FiltersEndpointTests { public class FiltersEndpointTests {
@Autowired @Autowired
...@@ -53,9 +68,8 @@ public class FiltersEndpointTests { ...@@ -53,9 +68,8 @@ public class FiltersEndpointTests {
} }
@Configuration @SpringBootConfiguration
@EnableAutoConfiguration @EnableAutoConfiguration
@RestController
@EnableZuulProxy @EnableZuulProxy
class FiltersEndpointApplication { class FiltersEndpointApplication {
......
...@@ -31,9 +31,6 @@ import org.junit.runner.RunWith; ...@@ -31,9 +31,6 @@ import org.junit.runner.RunWith;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner; import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cloud.netflix.zuul.RoutesEndpoint;
import org.springframework.cloud.netflix.zuul.RoutesRefreshedEvent;
import org.springframework.cloud.netflix.zuul.RoutesMvcEndpoint;
import org.springframework.cloud.netflix.zuul.filters.Route; import org.springframework.cloud.netflix.zuul.filters.Route;
import org.springframework.cloud.netflix.zuul.filters.RouteLocator; import org.springframework.cloud.netflix.zuul.filters.RouteLocator;
import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.ApplicationEventPublisher;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment