// Path: spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaServerAutoConfiguration.java
// static class RefreshablePeerEurekaNodes extends PeerEurekaNodes
// 		implements ApplicationListener<EnvironmentChangeEvent> {
// 
// 	private ReplicationClientAdditionalFilters replicationClientAdditionalFilters;
// 
// 	RefreshablePeerEurekaNodes(final PeerAwareInstanceRegistry registry, final EurekaServerConfig serverConfig,
// 			final EurekaClientConfig clientConfig, final ServerCodecs serverCodecs,
// 			final ApplicationInfoManager applicationInfoManager,
// 			final ReplicationClientAdditionalFilters replicationClientAdditionalFilters) {
// 		super(registry, serverConfig, clientConfig, serverCodecs, applicationInfoManager);
// 		this.replicationClientAdditionalFilters = replicationClientAdditionalFilters;
// 	}
// 
// 	@Override
// 	protected PeerEurekaNode createPeerEurekaNode(String peerEurekaNodeUrl) {
// 		JerseyReplicationClient replicationClient = JerseyReplicationClient.createReplicationClient(serverConfig,
// 				serverCodecs, peerEurekaNodeUrl);
// 
// 		this.replicationClientAdditionalFilters.getFilters().forEach(replicationClient::addReplicationClientFilter);
// 
// 		String targetHost = hostFromUrl(peerEurekaNodeUrl);
// 		if (targetHost == null) {
// 			targetHost = "host";
// 		}
// 		return new PeerEurekaNode(registry, targetHost, peerEurekaNodeUrl, replicationClient, serverConfig);
// 	}
// 
// 	@Override
// 	public void onApplicationEvent(final EnvironmentChangeEvent event) {
// 		if (shouldUpdate(event.getKeys())) {
// 			updatePeerEurekaNodes(resolvePeerUrls());
// 		}
// 	}
// 
// 	/*
// 	 * Check whether specific properties have changed.
// 	 */
// 	protected boolean shouldUpdate(final Set<String> changedKeys) {
// 		assert changedKeys != null;
// 
// 		// if eureka.client.use-dns-for-fetching-service-urls is true, then
// 		// service-url will not be fetched from environment.
// 		if (this.clientConfig.shouldUseDnsForFetchingServiceUrls()) {
// 			return false;
// 		}
// 
// 		if (changedKeys.contains("eureka.client.region")) {
// 			return true;
// 		}
// 
// 		for (final String key : changedKeys) {
// 			// property keys are not expected to be null.
// 			if (key.startsWith("eureka.client.service-url.")
// 					|| key.startsWith("eureka.client.availability-zones.")) {
// 				return true;
// 			}
// 		}
// 		return false;
// 	}
// 
// }


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.ReflectionUtils;
import static org.assertj.core.api.Assertions.assertThat;
import java.lang.reflect.Field;
import java.util.Collections;
import com.netflix.eureka.cluster.PeerEurekaNodes;
import com.sun.jersey.api.client.ClientHandlerException;
import com.sun.jersey.api.client.ClientRequest;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.filter.ClientFilter;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cloud.netflix.eureka.server.EurekaServerAutoConfiguration.RefreshablePeerEurekaNodes;
/*
 * Copyright 2013-2022 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
 *
 *      https://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.eureka.server;





/**
 * @author Yuxin Bai
 */
@SpringBootTest(classes = RefreshablePeerEurekaNodesWithCustomFiltersTests.Application.class,
		webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, value = { "spring.application.name=eureka",
				"server.contextPath=/context", "management.security.enabled=false" })
class RefreshablePeerEurekaNodesWithCustomFiltersTests {

	@Autowired
	private PeerEurekaNodes peerEurekaNodes;

	@Test
	void testCustomPeerNodesShouldTakePrecedenceOverDefault() {
// Path: spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaServerAutoConfiguration.java
// static class RefreshablePeerEurekaNodes extends PeerEurekaNodes
// 		implements ApplicationListener<EnvironmentChangeEvent> {
// 
// 	private ReplicationClientAdditionalFilters replicationClientAdditionalFilters;
// 
// 	RefreshablePeerEurekaNodes(final PeerAwareInstanceRegistry registry, final EurekaServerConfig serverConfig,
// 			final EurekaClientConfig clientConfig, final ServerCodecs serverCodecs,
// 			final ApplicationInfoManager applicationInfoManager,
// 			final ReplicationClientAdditionalFilters replicationClientAdditionalFilters) {
// 		super(registry, serverConfig, clientConfig, serverCodecs, applicationInfoManager);
// 		this.replicationClientAdditionalFilters = replicationClientAdditionalFilters;
// 	}
// 
// 	@Override
// 	protected PeerEurekaNode createPeerEurekaNode(String peerEurekaNodeUrl) {
// 		JerseyReplicationClient replicationClient = JerseyReplicationClient.createReplicationClient(serverConfig,
// 				serverCodecs, peerEurekaNodeUrl);
// 
// 		this.replicationClientAdditionalFilters.getFilters().forEach(replicationClient::addReplicationClientFilter);
// 
// 		String targetHost = hostFromUrl(peerEurekaNodeUrl);
// 		if (targetHost == null) {
// 			targetHost = "host";
// 		}
// 		return new PeerEurekaNode(registry, targetHost, peerEurekaNodeUrl, replicationClient, serverConfig);
// 	}
// 
// 	@Override
// 	public void onApplicationEvent(final EnvironmentChangeEvent event) {
// 		if (shouldUpdate(event.getKeys())) {
// 			updatePeerEurekaNodes(resolvePeerUrls());
// 		}
// 	}
// 
// 	/*
// 	 * Check whether specific properties have changed.
// 	 */
// 	protected boolean shouldUpdate(final Set<String> changedKeys) {
// 		assert changedKeys != null;
// 
// 		// if eureka.client.use-dns-for-fetching-service-urls is true, then
// 		// service-url will not be fetched from environment.
// 		if (this.clientConfig.shouldUseDnsForFetchingServiceUrls()) {
// 			return false;
// 		}
// 
// 		if (changedKeys.contains("eureka.client.region")) {
// 			return true;
// 		}
// 
// 		for (final String key : changedKeys) {
// 			// property keys are not expected to be null.
// 			if (key.startsWith("eureka.client.service-url.")
// 					|| key.startsWith("eureka.client.availability-zones.")) {
// 				return true;
// 			}
// 		}
// 		return false;
// 	}
// 
// }


// Path: spring-cloud-netflix-eureka-server/src/test/java/org/springframework/cloud/netflix/eureka/server/RefreshablePeerEurekaNodesWithCustomFiltersTests.java
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.ReflectionUtils;
import static org.assertj.core.api.Assertions.assertThat;
import java.lang.reflect.Field;
import java.util.Collections;
import com.netflix.eureka.cluster.PeerEurekaNodes;
import com.sun.jersey.api.client.ClientHandlerException;
import com.sun.jersey.api.client.ClientRequest;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.filter.ClientFilter;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cloud.netflix.eureka.server.EurekaServerAutoConfiguration.RefreshablePeerEurekaNodes;

/*
 * Copyright 2013-2022 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
 *
 *      https://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.eureka.server;





/**
 * @author Yuxin Bai
 */
@SpringBootTest(classes = RefreshablePeerEurekaNodesWithCustomFiltersTests.Application.class,
		webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, value = { "spring.application.name=eureka",
				"server.contextPath=/context", "management.security.enabled=false" })
class RefreshablePeerEurekaNodesWithCustomFiltersTests {

	@Autowired
	private PeerEurekaNodes peerEurekaNodes;

	@Test
	void testCustomPeerNodesShouldTakePrecedenceOverDefault() {
		assertThat(peerEurekaNodes instanceof RefreshablePeerEurekaNodes)