diff --git a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/EurekaClientAutoConfigurationTests.java b/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/EurekaClientAutoConfigurationTests.java index 92456a61..fc5d7aeb 100644 --- a/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/EurekaClientAutoConfigurationTests.java +++ b/spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/EurekaClientAutoConfigurationTests.java @@ -105,7 +105,10 @@ public class EurekaClientAutoConfigurationTests { @Test 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 @@ -396,8 +399,7 @@ public class EurekaClientAutoConfigurationTests { } private void testSecurePort(String propName) { - EnvironmentTestUtils.addEnvironment(this.context, "eureka.instance.securePortEnabled=true"); - addEnvironment(this.context, propName + ":8443"); + TestPropertyValues.of("eureka.instance.secure-port-enabled=true", propName+":8443").applyTo(this.context); setupContext(); assertEquals(8443, getInstanceConfig().getSecurePort()); } diff --git a/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/FiltersEndpoint.java b/spring-cloud-netflix-zuul/src/main/java/org/springframework/cloud/netflix/zuul/FiltersEndpoint.java similarity index 70% rename from spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/FiltersEndpoint.java rename to spring-cloud-netflix-zuul/src/main/java/org/springframework/cloud/netflix/zuul/FiltersEndpoint.java index a57d98d0..3cf22ffa 100644 --- a/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/FiltersEndpoint.java +++ b/spring-cloud-netflix-zuul/src/main/java/org/springframework/cloud/netflix/zuul/FiltersEndpoint.java @@ -1,37 +1,33 @@ 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.LinkedHashMap; import java.util.List; import java.util.Map; 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. * * @author Daryl Robbins * @author Gregor Zurowski */ -@ManagedResource(description = "List Zuul filters") -public class FiltersEndpoint extends AbstractEndpoint>>> { - - private static final String ID = "filters"; +@Endpoint(id = "filters") +public class FiltersEndpoint { private final FilterRegistry filterRegistry; public FiltersEndpoint(FilterRegistry filterRegistry) { - super(ID, true); this.filterRegistry = filterRegistry; } - @ManagedAttribute - @Override + @ReadOperation public Map>> invoke() { // Map of filters by type final Map>> filterMap = new TreeMap<>(); @@ -39,7 +35,7 @@ public class FiltersEndpoint extends AbstractEndpoint>()); + filterMap.put(filter.filterType(), new ArrayList<>()); } final Map filterInfo = new LinkedHashMap<>(); diff --git a/spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/zuul/FiltersEndpointTests.java b/spring-cloud-netflix-zuul/src/test/java/org/springframework/cloud/netflix/zuul/FiltersEndpointTests.java similarity index 67% rename from spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/zuul/FiltersEndpointTests.java rename to spring-cloud-netflix-zuul/src/test/java/org/springframework/cloud/netflix/zuul/FiltersEndpointTests.java index 6fc98430..a4a4d831 100644 --- a/spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/zuul/FiltersEndpointTests.java +++ b/spring-cloud-netflix-zuul/src/test/java/org/springframework/cloud/netflix/zuul/FiltersEndpointTests.java @@ -1,29 +1,44 @@ +/* + * 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; -import com.netflix.zuul.ZuulFilter; +import java.util.List; +import java.util.Map; + import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.SpringBootConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.web.bind.annotation.RestController; -import java.util.List; -import java.util.Map; +import com.netflix.zuul.ZuulFilter; import static org.hibernate.validator.internal.util.Contracts.assertTrue; import static org.junit.Assert.assertEquals; +import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; /** * Tests for Filters endpoint */ @RunWith(SpringJUnit4ClassRunner.class) -@SpringBootTest(classes = FiltersEndpointApplication.class, - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, - value = { "server.contextPath: /app" }) +@SpringBootTest(webEnvironment = RANDOM_PORT) public class FiltersEndpointTests { @Autowired @@ -53,9 +68,8 @@ public class FiltersEndpointTests { } -@Configuration +@SpringBootConfiguration @EnableAutoConfiguration -@RestController @EnableZuulProxy class FiltersEndpointApplication { diff --git a/spring-cloud-netflix-zuul/src/test/java/org/springframework/cloud/netflix/zuul/RoutesEndpointDetailsTests.java b/spring-cloud-netflix-zuul/src/test/java/org/springframework/cloud/netflix/zuul/RoutesEndpointDetailsTests.java index 7559fe02..e99af749 100644 --- a/spring-cloud-netflix-zuul/src/test/java/org/springframework/cloud/netflix/zuul/RoutesEndpointDetailsTests.java +++ b/spring-cloud-netflix-zuul/src/test/java/org/springframework/cloud/netflix/zuul/RoutesEndpointDetailsTests.java @@ -31,9 +31,6 @@ import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; 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.RouteLocator; import org.springframework.context.ApplicationEventPublisher;