Browse Source

Updates to boot 2.0.0 endpoint and properties.

pull/6/head
Spencer Gibb 7 years ago
parent
commit
a878472a73
No known key found for this signature in database
GPG Key ID: 7788A47380690861
  1. 8
      spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/EurekaClientAutoConfigurationTests.java
  2. 24
      spring-cloud-netflix-zuul/src/main/java/org/springframework/cloud/netflix/zuul/FiltersEndpoint.java
  3. 34
      spring-cloud-netflix-zuul/src/test/java/org/springframework/cloud/netflix/zuul/FiltersEndpointTests.java
  4. 3
      spring-cloud-netflix-zuul/src/test/java/org/springframework/cloud/netflix/zuul/RoutesEndpointDetailsTests.java

8
spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/EurekaClientAutoConfigurationTests.java

@ -105,7 +105,10 @@ public class EurekaClientAutoConfigurationTests { @@ -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 { @@ -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());
}

24
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/FiltersEndpoint.java → spring-cloud-netflix-zuul/src/main/java/org/springframework/cloud/netflix/zuul/FiltersEndpoint.java

@ -1,37 +1,33 @@ @@ -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<Map<String, List<Map<String, Object>>>> {
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<String, List<Map<String, Object>>> invoke() {
// Map of filters by type
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()) {
// Ensure that we have a list to store filters of each type
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<>();

34
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/zuul/FiltersEndpointTests.java → spring-cloud-netflix-zuul/src/test/java/org/springframework/cloud/netflix/zuul/FiltersEndpointTests.java

@ -1,29 +1,44 @@ @@ -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 { @@ -53,9 +68,8 @@ public class FiltersEndpointTests {
}
@Configuration
@SpringBootConfiguration
@EnableAutoConfiguration
@RestController
@EnableZuulProxy
class FiltersEndpointApplication {

3
spring-cloud-netflix-zuul/src/test/java/org/springframework/cloud/netflix/zuul/RoutesEndpointDetailsTests.java

@ -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.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;

Loading…
Cancel
Save