mirror of
https://gitee.com/mirrors/Spring-Cloud-Alibaba.git
synced 2021-06-26 13:25:11 +08:00
format code with maven plugins
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
* Copyright 2013-2018 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
|
||||
* 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,
|
||||
@@ -25,7 +25,8 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ ElementType.TYPE, ElementType.METHOD })
|
||||
@ConditionalOnProperty(value = "spring.cloud.nacos.discovery.enabled", matchIfMissing = true)
|
||||
@ConditionalOnProperty(value = "spring.cloud.nacos.discovery.enabled",
|
||||
matchIfMissing = true)
|
||||
public @interface ConditionalOnNacosDiscoveryEnabled {
|
||||
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
* Copyright 2013-2018 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
|
||||
* 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,
|
||||
@@ -16,6 +16,10 @@
|
||||
|
||||
package com.alibaba.cloud.nacos;
|
||||
|
||||
import com.alibaba.cloud.nacos.registry.NacosAutoServiceRegistration;
|
||||
import com.alibaba.cloud.nacos.registry.NacosRegistration;
|
||||
import com.alibaba.cloud.nacos.registry.NacosServiceRegistry;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
@@ -27,10 +31,6 @@ import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import com.alibaba.cloud.nacos.registry.NacosAutoServiceRegistration;
|
||||
import com.alibaba.cloud.nacos.registry.NacosRegistration;
|
||||
import com.alibaba.cloud.nacos.registry.NacosServiceRegistry;
|
||||
|
||||
/**
|
||||
* @author xiaojing
|
||||
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
|
||||
@@ -38,7 +38,8 @@ import com.alibaba.cloud.nacos.registry.NacosServiceRegistry;
|
||||
@Configuration
|
||||
@EnableConfigurationProperties
|
||||
@ConditionalOnNacosDiscoveryEnabled
|
||||
@ConditionalOnProperty(value = "spring.cloud.service-registry.auto-registration.enabled", matchIfMissing = true)
|
||||
@ConditionalOnProperty(value = "spring.cloud.service-registry.auto-registration.enabled",
|
||||
matchIfMissing = true)
|
||||
@AutoConfigureAfter({ AutoServiceRegistrationConfiguration.class,
|
||||
AutoServiceRegistrationAutoConfiguration.class })
|
||||
public class NacosDiscoveryAutoConfiguration {
|
||||
@@ -73,4 +74,5 @@ public class NacosDiscoveryAutoConfiguration {
|
||||
return new NacosAutoServiceRegistration(registry,
|
||||
autoServiceRegistrationProperties, registration);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
* Copyright 2013-2018 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
|
||||
* 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,
|
||||
@@ -16,15 +16,6 @@
|
||||
|
||||
package com.alibaba.cloud.nacos;
|
||||
|
||||
import static com.alibaba.nacos.api.PropertyKeyConst.ACCESS_KEY;
|
||||
import static com.alibaba.nacos.api.PropertyKeyConst.CLUSTER_NAME;
|
||||
import static com.alibaba.nacos.api.PropertyKeyConst.ENDPOINT;
|
||||
import static com.alibaba.nacos.api.PropertyKeyConst.ENDPOINT_PORT;
|
||||
import static com.alibaba.nacos.api.PropertyKeyConst.NAMESPACE;
|
||||
import static com.alibaba.nacos.api.PropertyKeyConst.NAMING_LOAD_CACHE_AT_START;
|
||||
import static com.alibaba.nacos.api.PropertyKeyConst.SECRET_KEY;
|
||||
import static com.alibaba.nacos.api.PropertyKeyConst.SERVER_ADDR;
|
||||
|
||||
import java.net.Inet4Address;
|
||||
import java.net.InetAddress;
|
||||
import java.net.NetworkInterface;
|
||||
@@ -37,8 +28,15 @@ import java.util.Properties;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import com.alibaba.nacos.api.NacosFactory;
|
||||
import com.alibaba.nacos.api.naming.NamingMaintainFactory;
|
||||
import com.alibaba.nacos.api.naming.NamingMaintainService;
|
||||
import com.alibaba.nacos.api.naming.NamingService;
|
||||
import com.alibaba.nacos.api.naming.PreservedMetadataKeys;
|
||||
import com.alibaba.nacos.client.naming.utils.UtilAndComs;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
@@ -46,12 +44,14 @@ import org.springframework.cloud.commons.util.InetUtils;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.alibaba.nacos.api.NacosFactory;
|
||||
import com.alibaba.nacos.api.naming.NamingMaintainFactory;
|
||||
import com.alibaba.nacos.api.naming.NamingMaintainService;
|
||||
import com.alibaba.nacos.api.naming.NamingService;
|
||||
import com.alibaba.nacos.api.naming.PreservedMetadataKeys;
|
||||
import com.alibaba.nacos.client.naming.utils.UtilAndComs;
|
||||
import static com.alibaba.nacos.api.PropertyKeyConst.ACCESS_KEY;
|
||||
import static com.alibaba.nacos.api.PropertyKeyConst.CLUSTER_NAME;
|
||||
import static com.alibaba.nacos.api.PropertyKeyConst.ENDPOINT;
|
||||
import static com.alibaba.nacos.api.PropertyKeyConst.ENDPOINT_PORT;
|
||||
import static com.alibaba.nacos.api.PropertyKeyConst.NAMESPACE;
|
||||
import static com.alibaba.nacos.api.PropertyKeyConst.NAMING_LOAD_CACHE_AT_START;
|
||||
import static com.alibaba.nacos.api.PropertyKeyConst.SECRET_KEY;
|
||||
import static com.alibaba.nacos.api.PropertyKeyConst.SERVER_ADDR;
|
||||
|
||||
/**
|
||||
* @author dungu.zpf
|
||||
@@ -109,7 +109,7 @@ public class NacosDiscoveryProperties {
|
||||
private String clusterName = "DEFAULT";
|
||||
|
||||
/**
|
||||
* group name for nacos
|
||||
* group name for nacos.
|
||||
*/
|
||||
private String group = "DEFAULT_GROUP";
|
||||
|
||||
|
@@ -1,12 +1,11 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You 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
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* 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,
|
||||
@@ -14,24 +13,27 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.cloud.nacos;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import com.alibaba.nacos.api.naming.NamingMaintainService;
|
||||
import com.alibaba.nacos.api.naming.NamingService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.Objects;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:liaochunyhm@live.com">liaochuntao</a>
|
||||
*/
|
||||
public class NacosNamingManager {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(NacosNamingManager.class);
|
||||
private static final Logger log = LoggerFactory.getLogger(NacosNamingManager.class);
|
||||
|
||||
private static NamingService namingService = null;
|
||||
|
||||
private static NamingMaintainService namingMaintainService = null;
|
||||
|
||||
@Autowired
|
||||
|
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
* Copyright 2013-2018 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
|
||||
* 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,
|
||||
@@ -26,10 +26,15 @@ import org.springframework.cloud.client.ServiceInstance;
|
||||
* @author xiaojing
|
||||
*/
|
||||
public class NacosServiceInstance implements ServiceInstance {
|
||||
|
||||
private String serviceId;
|
||||
|
||||
private String host;
|
||||
|
||||
private int port;
|
||||
|
||||
private boolean secure;
|
||||
|
||||
private Map<String, String> metadata;
|
||||
|
||||
@Override
|
||||
|
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
* Copyright 2013-2018 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
|
||||
* 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,
|
||||
@@ -16,6 +16,12 @@
|
||||
|
||||
package com.alibaba.cloud.nacos.discovery;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
|
||||
import com.alibaba.cloud.nacos.NacosNamingManager;
|
||||
import com.alibaba.cloud.nacos.NacosServiceInstance;
|
||||
@@ -23,15 +29,10 @@ import com.alibaba.nacos.api.naming.pojo.Instance;
|
||||
import com.alibaba.nacos.api.naming.pojo.ListView;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.cloud.client.ServiceInstance;
|
||||
import org.springframework.cloud.client.discovery.DiscoveryClient;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author xiaojing
|
||||
* @author renhaojun
|
||||
@@ -39,9 +40,14 @@ import java.util.Map;
|
||||
public class NacosDiscoveryClient implements DiscoveryClient {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(NacosDiscoveryClient.class);
|
||||
|
||||
/**
|
||||
* Nacos Discovery Client Description.
|
||||
*/
|
||||
public static final String DESCRIPTION = "Spring Cloud Nacos Discovery Client";
|
||||
|
||||
private NacosNamingManager nacosNamingManager;
|
||||
|
||||
private NacosDiscoveryProperties discoveryProperties;
|
||||
|
||||
public NacosDiscoveryClient(NacosNamingManager nacosNamingManager,
|
||||
@@ -120,4 +126,5 @@ public class NacosDiscoveryClient implements DiscoveryClient {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
* Copyright 2013-2018 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
|
||||
* 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,
|
||||
@@ -16,7 +16,10 @@
|
||||
|
||||
package com.alibaba.cloud.nacos.discovery;
|
||||
|
||||
import com.alibaba.cloud.nacos.ConditionalOnNacosDiscoveryEnabled;
|
||||
import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
|
||||
import com.alibaba.cloud.nacos.NacosNamingManager;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
@@ -26,9 +29,6 @@ import org.springframework.cloud.client.discovery.simple.SimpleDiscoveryClientAu
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import com.alibaba.cloud.nacos.ConditionalOnNacosDiscoveryEnabled;
|
||||
import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
|
||||
|
||||
/**
|
||||
* @author xiaojing
|
||||
*/
|
||||
@@ -52,8 +52,10 @@ public class NacosDiscoveryClientAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@ConditionalOnProperty(value = "spring.cloud.nacos.discovery.watch.enabled", matchIfMissing = true)
|
||||
@ConditionalOnProperty(value = "spring.cloud.nacos.discovery.watch.enabled",
|
||||
matchIfMissing = true)
|
||||
public NacosWatch nacosWatch(NacosDiscoveryProperties nacosDiscoveryProperties) {
|
||||
return new NacosWatch(nacosDiscoveryProperties);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2019 the original author or authors.
|
||||
* Copyright 2013-2018 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
|
||||
* 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,
|
||||
@@ -23,8 +23,11 @@ import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
|
||||
import com.alibaba.nacos.api.naming.listener.EventListener;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.cloud.client.discovery.event.HeartbeatEvent;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.context.ApplicationEventPublisherAware;
|
||||
@@ -32,9 +35,6 @@ import org.springframework.context.SmartLifecycle;
|
||||
import org.springframework.scheduling.TaskScheduler;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
||||
|
||||
import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
|
||||
import com.alibaba.nacos.api.naming.listener.EventListener;
|
||||
|
||||
/**
|
||||
* @author xiaojing
|
||||
*/
|
||||
@@ -121,4 +121,5 @@ public class NacosWatch implements ApplicationEventPublisherAware, SmartLifecycl
|
||||
new HeartbeatEvent(this, nacosWatchIndex.getAndIncrement()));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
* Copyright 2013-2018 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
|
||||
* 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,
|
||||
@@ -18,6 +18,8 @@ package com.alibaba.cloud.nacos.discovery.configclient;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
@@ -25,8 +27,6 @@ import org.springframework.cloud.config.server.config.ConfigServerProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
|
||||
|
||||
/**
|
||||
* Extra configuration for config server if it happens to be registered with Nacos.
|
||||
*
|
||||
|
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
* Copyright 2013-2018 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
|
||||
* 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,
|
||||
@@ -16,22 +16,23 @@
|
||||
|
||||
package com.alibaba.cloud.nacos.discovery.configclient;
|
||||
|
||||
import com.alibaba.cloud.nacos.NacosDiscoveryAutoConfiguration;
|
||||
import com.alibaba.cloud.nacos.discovery.NacosDiscoveryClientAutoConfiguration;
|
||||
|
||||
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.cloud.config.client.ConfigServicePropertySourceLocator;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import com.alibaba.cloud.nacos.NacosDiscoveryAutoConfiguration;
|
||||
import com.alibaba.cloud.nacos.discovery.NacosDiscoveryClientAutoConfiguration;
|
||||
|
||||
/**
|
||||
* Helper for config client that wants to lookup the config server via discovery.
|
||||
*
|
||||
* @author JevonYang
|
||||
*/
|
||||
@ConditionalOnClass(ConfigServicePropertySourceLocator.class)
|
||||
@ConditionalOnProperty(value = "spring.cloud.config.discovery.enabled", matchIfMissing = false)
|
||||
@ConditionalOnProperty(value = "spring.cloud.config.discovery.enabled",
|
||||
matchIfMissing = false)
|
||||
@Configuration
|
||||
@ImportAutoConfiguration({ NacosDiscoveryClientAutoConfiguration.class,
|
||||
NacosDiscoveryAutoConfiguration.class })
|
||||
|
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
* Copyright 2013-2018 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
|
||||
* 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,
|
||||
@@ -21,18 +21,19 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
|
||||
import com.alibaba.cloud.nacos.NacosNamingManager;
|
||||
import com.alibaba.nacos.api.naming.NamingService;
|
||||
import com.alibaba.nacos.api.naming.pojo.ServiceInfo;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
|
||||
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
|
||||
|
||||
import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
|
||||
import com.alibaba.nacos.api.naming.NamingService;
|
||||
import com.alibaba.nacos.api.naming.pojo.ServiceInfo;
|
||||
|
||||
/**
|
||||
* Endpoint for nacos discovery, get nacos properties and subscribed services
|
||||
* Endpoint for nacos discovery, get nacos properties and subscribed services.
|
||||
*
|
||||
* @author xiaojing
|
||||
*/
|
||||
@Endpoint(id = "nacos-discovery")
|
||||
@@ -42,6 +43,7 @@ public class NacosDiscoveryEndpoint {
|
||||
.getLogger(NacosDiscoveryEndpoint.class);
|
||||
|
||||
private NacosNamingManager nacosNamingManager;
|
||||
|
||||
private NacosDiscoveryProperties nacosDiscoveryProperties;
|
||||
|
||||
public NacosDiscoveryEndpoint(NacosNamingManager nacosNamingManager,
|
||||
@@ -70,4 +72,5 @@ public class NacosDiscoveryEndpoint {
|
||||
result.put("subscribe", subscribe);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
* Copyright 2013-2018 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
|
||||
* 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,
|
||||
@@ -16,7 +16,10 @@
|
||||
|
||||
package com.alibaba.cloud.nacos.endpoint;
|
||||
|
||||
import com.alibaba.cloud.nacos.ConditionalOnNacosDiscoveryEnabled;
|
||||
import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
|
||||
import com.alibaba.cloud.nacos.NacosNamingManager;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
|
||||
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
@@ -24,9 +27,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import com.alibaba.cloud.nacos.ConditionalOnNacosDiscoveryEnabled;
|
||||
import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
|
||||
|
||||
/**
|
||||
* @author xiaojing
|
||||
*/
|
||||
|
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
* Copyright 2013-2018 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
|
||||
* 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,
|
||||
@@ -18,6 +18,7 @@ package com.alibaba.cloud.nacos.registry;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.cloud.client.serviceregistry.AbstractAutoServiceRegistration;
|
||||
import org.springframework.cloud.client.serviceregistry.AutoServiceRegistrationProperties;
|
||||
import org.springframework.cloud.client.serviceregistry.Registration;
|
||||
@@ -31,6 +32,7 @@ import org.springframework.util.StringUtils;
|
||||
*/
|
||||
public class NacosAutoServiceRegistration
|
||||
extends AbstractAutoServiceRegistration<Registration> {
|
||||
|
||||
private static final Logger log = LoggerFactory
|
||||
.getLogger(NacosAutoServiceRegistration.class);
|
||||
|
||||
|
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
* Copyright 2013-2018 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
|
||||
* 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,
|
||||
@@ -21,7 +21,11 @@ import java.util.Map;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
|
||||
import com.alibaba.cloud.nacos.NacosNamingManager;
|
||||
import com.alibaba.nacos.api.naming.NamingService;
|
||||
import com.alibaba.nacos.api.naming.PreservedMetadataKeys;
|
||||
|
||||
import org.springframework.cloud.client.DefaultServiceInstance;
|
||||
import org.springframework.cloud.client.ServiceInstance;
|
||||
import org.springframework.cloud.client.discovery.ManagementServerPortUtils;
|
||||
@@ -30,21 +34,33 @@ import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
|
||||
import com.alibaba.nacos.api.naming.NamingService;
|
||||
import com.alibaba.nacos.api.naming.PreservedMetadataKeys;
|
||||
|
||||
/**
|
||||
* @author xiaojing
|
||||
*/
|
||||
public class NacosRegistration implements Registration, ServiceInstance {
|
||||
|
||||
/**
|
||||
* The metadata key of management port.
|
||||
*/
|
||||
public static final String MANAGEMENT_PORT = "management.port";
|
||||
|
||||
/**
|
||||
* The metadata key of management context-path.
|
||||
*/
|
||||
public static final String MANAGEMENT_CONTEXT_PATH = "management.context-path";
|
||||
|
||||
/**
|
||||
* The metadata key of management address.
|
||||
*/
|
||||
public static final String MANAGEMENT_ADDRESS = "management.address";
|
||||
|
||||
/**
|
||||
* The metadata key of management endpoints web base path.
|
||||
*/
|
||||
public static final String MANAGEMENT_ENDPOINT_BASE_PATH = "management.endpoints.web.base-path";
|
||||
|
||||
private NacosNamingManager nacosNamingManager;
|
||||
|
||||
private NacosDiscoveryProperties nacosDiscoveryProperties;
|
||||
|
||||
private ApplicationContext context;
|
||||
@@ -155,4 +171,5 @@ public class NacosRegistration implements Registration, ServiceInstance {
|
||||
return "NacosRegistration{" + "nacosDiscoveryProperties="
|
||||
+ nacosDiscoveryProperties + '}';
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
* Copyright 2013-2018 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
|
||||
* 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,
|
||||
@@ -18,17 +18,17 @@ package com.alibaba.cloud.nacos.registry;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
|
||||
import com.alibaba.cloud.nacos.NacosNamingManager;
|
||||
import com.alibaba.nacos.api.naming.NamingService;
|
||||
import com.alibaba.nacos.api.naming.pojo.Instance;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.cloud.client.serviceregistry.Registration;
|
||||
import org.springframework.cloud.client.serviceregistry.ServiceRegistry;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
|
||||
import com.alibaba.nacos.api.naming.NamingService;
|
||||
import com.alibaba.nacos.api.naming.pojo.Instance;
|
||||
|
||||
/**
|
||||
* @author xiaojing
|
||||
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
|
||||
@@ -38,6 +38,7 @@ public class NacosServiceRegistry implements ServiceRegistry<Registration> {
|
||||
private static final Logger log = LoggerFactory.getLogger(NacosServiceRegistry.class);
|
||||
|
||||
private final NacosNamingManager nacosNamingManager;
|
||||
|
||||
private final NacosDiscoveryProperties nacosDiscoveryProperties;
|
||||
|
||||
private final NamingService namingService;
|
||||
@@ -142,8 +143,9 @@ public class NacosServiceRegistry implements ServiceRegistry<Registration> {
|
||||
.getAllInstances(serviceName);
|
||||
for (Instance instance : instances) {
|
||||
if (instance.getIp().equalsIgnoreCase(nacosDiscoveryProperties.getIp())
|
||||
&& instance.getPort() == nacosDiscoveryProperties.getPort())
|
||||
&& instance.getPort() == nacosDiscoveryProperties.getPort()) {
|
||||
return instance.isEnabled() ? "UP" : "DOWN";
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
* Copyright 2013-2018 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
|
||||
* 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,
|
||||
|
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2013-2018 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 com.alibaba.cloud.nacos.ribbon;
|
||||
|
||||
import java.util.List;
|
||||
@@ -9,13 +25,14 @@ import com.alibaba.nacos.client.naming.core.Balancer;
|
||||
* @author itmuch.com
|
||||
*/
|
||||
public class ExtendBalancer extends Balancer {
|
||||
|
||||
/**
|
||||
* 根据权重,随机选择实例
|
||||
*
|
||||
* @param instances 实例列表
|
||||
* @return 选择的实例
|
||||
* Choose instance by weight.
|
||||
* @param instances Instance List
|
||||
* @return the chosen instance
|
||||
*/
|
||||
public static Instance getHostByRandomWeight2(List<Instance> instances) {
|
||||
return getHostByRandomWeight(instances);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
* Copyright 2013-2018 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
|
||||
* 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,
|
||||
@@ -16,18 +16,18 @@
|
||||
|
||||
package com.alibaba.cloud.nacos.ribbon;
|
||||
|
||||
import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
|
||||
import com.alibaba.cloud.nacos.NacosNamingManager;
|
||||
import com.netflix.client.config.IClientConfig;
|
||||
import com.netflix.loadbalancer.ServerList;
|
||||
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
|
||||
|
||||
import com.netflix.client.config.IClientConfig;
|
||||
import com.netflix.loadbalancer.ServerList;
|
||||
|
||||
/**
|
||||
* integrated Ribbon by default
|
||||
* integrated Ribbon by default.
|
||||
*
|
||||
* @author xiaojing
|
||||
*/
|
||||
@Configuration
|
||||
@@ -50,4 +50,5 @@ public class NacosRibbonClientConfiguration {
|
||||
public NacosServerIntrospector nacosServerIntrospector() {
|
||||
return new NacosServerIntrospector();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,24 +1,39 @@
|
||||
/*
|
||||
* Copyright 2013-2018 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 com.alibaba.cloud.nacos.ribbon;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.alibaba.cloud.nacos.NacosNamingManager;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
|
||||
import com.alibaba.cloud.nacos.NacosNamingManager;
|
||||
import com.alibaba.nacos.api.naming.NamingService;
|
||||
import com.alibaba.nacos.api.naming.pojo.Instance;
|
||||
|
||||
import com.netflix.client.config.IClientConfig;
|
||||
import com.netflix.loadbalancer.AbstractLoadBalancerRule;
|
||||
import com.netflix.loadbalancer.DynamicServerListLoadBalancer;
|
||||
import com.netflix.loadbalancer.Server;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
/**
|
||||
* Supports preferentially calling the ribbon load balancing rules of the same cluster
|
||||
@@ -27,6 +42,7 @@ import com.netflix.loadbalancer.Server;
|
||||
* @author itmuch.com
|
||||
*/
|
||||
public class NacosRule extends AbstractLoadBalancerRule {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(NacosRule.class);
|
||||
|
||||
@Autowired
|
||||
@@ -78,4 +94,5 @@ public class NacosRule extends AbstractLoadBalancerRule {
|
||||
@Override
|
||||
public void initWithNiwsConfig(IClientConfig iClientConfig) {
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
* Copyright 2013-2018 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
|
||||
* 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,
|
||||
@@ -19,7 +19,6 @@ package com.alibaba.cloud.nacos.ribbon;
|
||||
import java.util.Map;
|
||||
|
||||
import com.alibaba.nacos.api.naming.pojo.Instance;
|
||||
|
||||
import com.netflix.loadbalancer.Server;
|
||||
|
||||
/**
|
||||
@@ -29,7 +28,9 @@ import com.netflix.loadbalancer.Server;
|
||||
public class NacosServer extends Server {
|
||||
|
||||
private final MetaInfo metaInfo;
|
||||
|
||||
private final Instance instance;
|
||||
|
||||
private final Map<String, String> metadata;
|
||||
|
||||
public NacosServer(final Instance instance) {
|
||||
@@ -71,4 +72,5 @@ public class NacosServer extends Server {
|
||||
public Map<String, String> getMetadata() {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2019 the original author or authors.
|
||||
* Copyright 2013-2018 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
|
||||
* 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,
|
||||
@@ -18,10 +18,10 @@ package com.alibaba.cloud.nacos.ribbon;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.cloud.netflix.ribbon.DefaultServerIntrospector;
|
||||
|
||||
import com.netflix.loadbalancer.Server;
|
||||
|
||||
import org.springframework.cloud.netflix.ribbon.DefaultServerIntrospector;
|
||||
|
||||
/**
|
||||
* @author xiaojing
|
||||
*/
|
||||
@@ -43,4 +43,5 @@ public class NacosServerIntrospector extends DefaultServerIntrospector {
|
||||
|
||||
return super.isSecure(server);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
* Copyright 2013-2018 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
|
||||
* 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,
|
||||
@@ -22,7 +22,6 @@ import java.util.List;
|
||||
import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
|
||||
import com.alibaba.cloud.nacos.NacosNamingManager;
|
||||
import com.alibaba.nacos.api.naming.pojo.Instance;
|
||||
|
||||
import com.alibaba.nacos.client.naming.utils.CollectionUtils;
|
||||
import com.netflix.client.config.IClientConfig;
|
||||
import com.netflix.loadbalancer.AbstractServerList;
|
||||
@@ -34,6 +33,7 @@ import com.netflix.loadbalancer.AbstractServerList;
|
||||
public class NacosServerList extends AbstractServerList<NacosServer> {
|
||||
|
||||
private NacosNamingManager nacosNamingManager;
|
||||
|
||||
private NacosDiscoveryProperties discoveryProperties;
|
||||
|
||||
private String serviceId;
|
||||
@@ -88,4 +88,5 @@ public class NacosServerList extends AbstractServerList<NacosServer> {
|
||||
public void initWithNiwsConfig(IClientConfig iClientConfig) {
|
||||
this.serviceId = iClientConfig.getClientName();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
* Copyright 2013-2018 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
|
||||
* 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,
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.alibaba.cloud.nacos.ribbon;
|
||||
|
||||
import com.alibaba.cloud.nacos.ConditionalOnNacosDiscoveryEnabled;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
@@ -24,8 +26,6 @@ import org.springframework.cloud.netflix.ribbon.RibbonClients;
|
||||
import org.springframework.cloud.netflix.ribbon.SpringClientFactory;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import com.alibaba.cloud.nacos.ConditionalOnNacosDiscoveryEnabled;
|
||||
|
||||
/**
|
||||
* {@link org.springframework.boot.autoconfigure.EnableAutoConfiguration
|
||||
* Auto-configuration} that sets up Ribbon for Nacos.
|
||||
@@ -38,4 +38,5 @@ import com.alibaba.cloud.nacos.ConditionalOnNacosDiscoveryEnabled;
|
||||
@AutoConfigureAfter(RibbonAutoConfiguration.class)
|
||||
@RibbonClients(defaultConfiguration = NacosRibbonClientConfiguration.class)
|
||||
public class RibbonNacosAutoConfiguration {
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
* Copyright 2013-2018 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
|
||||
* 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,
|
||||
@@ -16,17 +16,18 @@
|
||||
|
||||
package com.alibaba.cloud.nacos;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.cloud.nacos.discovery.NacosDiscoveryClient;
|
||||
import com.alibaba.nacos.api.naming.NamingService;
|
||||
import com.alibaba.nacos.api.naming.pojo.Instance;
|
||||
import com.alibaba.nacos.api.naming.pojo.ListView;
|
||||
import org.junit.Test;
|
||||
import org.springframework.cloud.client.ServiceInstance;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import org.springframework.cloud.client.ServiceInstance;
|
||||
|
||||
import static com.alibaba.cloud.nacos.test.NacosMockTest.serviceInstance;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -40,7 +41,9 @@ import static org.mockito.Mockito.when;
|
||||
public class NacosDiscoveryClientTests {
|
||||
|
||||
private String host = "123.123.123.123";
|
||||
|
||||
private int port = 8888;
|
||||
|
||||
private String serviceName = "test-service";
|
||||
|
||||
@Test
|
||||
@@ -127,4 +130,5 @@ public class NacosDiscoveryClientTests {
|
||||
|
||||
return "http://" + host + ":" + port;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,10 +1,25 @@
|
||||
/*
|
||||
* Copyright 2013-2018 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 com.alibaba.cloud.nacos;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
import com.alibaba.cloud.nacos.discovery.NacosDiscoveryClientAutoConfiguration;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
||||
@@ -13,17 +28,18 @@ import org.springframework.cloud.client.serviceregistry.AutoServiceRegistrationC
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.alibaba.cloud.nacos.NacosDiscoveryAutoConfiguration;
|
||||
import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
|
||||
import com.alibaba.cloud.nacos.discovery.NacosDiscoveryClientAutoConfiguration;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:lyuzb@lyuzb.com">lyuzb</a>
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = NacosDiscoveryPropertiesServerAddressBothLevelTests.TestConfig.class, properties = {
|
||||
"spring.cloud.nacos.discovery.server-addr=321.321.321.321:8848",
|
||||
"spring.cloud.nacos.server-addr=123.123.123.123:8848" }, webEnvironment = RANDOM_PORT)
|
||||
@SpringBootTest(
|
||||
classes = NacosDiscoveryPropertiesServerAddressBothLevelTests.TestConfig.class,
|
||||
properties = { "spring.cloud.nacos.discovery.server-addr=321.321.321.321:8848",
|
||||
"spring.cloud.nacos.server-addr=123.123.123.123:8848" },
|
||||
webEnvironment = RANDOM_PORT)
|
||||
public class NacosDiscoveryPropertiesServerAddressBothLevelTests {
|
||||
|
||||
@Autowired
|
||||
@@ -31,8 +47,7 @@ public class NacosDiscoveryPropertiesServerAddressBothLevelTests {
|
||||
|
||||
@Test
|
||||
public void testGetServerAddr() {
|
||||
assertEquals("NacosDiscoveryProperties server address was wrong",
|
||||
"321.321.321.321:8848", properties.getServerAddr());
|
||||
assertThat(properties.getServerAddr()).isEqualTo("321.321.321.321:8848");
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@@ -41,5 +56,7 @@ public class NacosDiscoveryPropertiesServerAddressBothLevelTests {
|
||||
NacosDiscoveryClientAutoConfiguration.class,
|
||||
NacosDiscoveryAutoConfiguration.class })
|
||||
public static class TestConfig {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,10 +1,25 @@
|
||||
/*
|
||||
* Copyright 2013-2018 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 com.alibaba.cloud.nacos;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
import com.alibaba.cloud.nacos.discovery.NacosDiscoveryClientAutoConfiguration;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
||||
@@ -13,18 +28,18 @@ import org.springframework.cloud.client.serviceregistry.AutoServiceRegistrationC
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.alibaba.cloud.nacos.NacosDiscoveryAutoConfiguration;
|
||||
import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
|
||||
import com.alibaba.cloud.nacos.discovery.NacosDiscoveryClientAutoConfiguration;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:lyuzb@lyuzb.com">lyuzb</a>
|
||||
*
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = NacosDiscoveryPropertiesServerAddressTopLevelTests.TestConfig.class, properties = {
|
||||
"spring.cloud.nacos.server-addr=123.123.123.123:8848" }, webEnvironment = RANDOM_PORT)
|
||||
@SpringBootTest(
|
||||
classes = NacosDiscoveryPropertiesServerAddressTopLevelTests.TestConfig.class,
|
||||
properties = { "spring.cloud.nacos.server-addr=123.123.123.123:8848" },
|
||||
webEnvironment = RANDOM_PORT)
|
||||
|
||||
public class NacosDiscoveryPropertiesServerAddressTopLevelTests {
|
||||
|
||||
@@ -33,8 +48,7 @@ public class NacosDiscoveryPropertiesServerAddressTopLevelTests {
|
||||
|
||||
@Test
|
||||
public void testGetServerAddr() {
|
||||
assertEquals("NacosDiscoveryProperties server address was wrong",
|
||||
"123.123.123.123:8848", properties.getServerAddr());
|
||||
assertThat(properties.getServerAddr()).isEqualTo("123.123.123.123:8848");
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@@ -43,5 +57,7 @@ public class NacosDiscoveryPropertiesServerAddressTopLevelTests {
|
||||
NacosDiscoveryClientAutoConfiguration.class,
|
||||
NacosDiscoveryAutoConfiguration.class })
|
||||
public static class TestConfig {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
* Copyright 2013-2018 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
|
||||
* 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,
|
||||
@@ -16,17 +16,17 @@
|
||||
|
||||
package com.alibaba.cloud.nacos.registry;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
import java.net.Inet4Address;
|
||||
import java.net.InetAddress;
|
||||
import java.net.NetworkInterface;
|
||||
import java.util.Enumeration;
|
||||
|
||||
import com.alibaba.cloud.nacos.NacosDiscoveryAutoConfiguration;
|
||||
import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
|
||||
import com.alibaba.cloud.nacos.discovery.NacosDiscoveryClientAutoConfiguration;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
||||
@@ -36,18 +36,19 @@ import org.springframework.cloud.commons.util.InetUtils;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.alibaba.cloud.nacos.NacosDiscoveryAutoConfiguration;
|
||||
import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
|
||||
import com.alibaba.cloud.nacos.discovery.NacosDiscoveryClientAutoConfiguration;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
/**
|
||||
* @author xiaojing
|
||||
*/
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = NacosAutoServiceRegistrationIpNetworkInterfaceTests.TestConfig.class, properties = {
|
||||
"spring.application.name=myTestService1",
|
||||
"spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848" }, webEnvironment = RANDOM_PORT)
|
||||
@SpringBootTest(
|
||||
classes = NacosAutoServiceRegistrationIpNetworkInterfaceTests.TestConfig.class,
|
||||
properties = { "spring.application.name=myTestService1",
|
||||
"spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848" },
|
||||
webEnvironment = RANDOM_PORT)
|
||||
public class NacosAutoServiceRegistrationIpNetworkInterfaceTests {
|
||||
|
||||
@Autowired
|
||||
@@ -64,21 +65,16 @@ public class NacosAutoServiceRegistrationIpNetworkInterfaceTests {
|
||||
|
||||
@Test
|
||||
public void contextLoads() throws Exception {
|
||||
|
||||
assertNotNull("NacosRegistration was not created", registration);
|
||||
assertNotNull("NacosDiscoveryProperties was not created", properties);
|
||||
assertNotNull("NacosAutoServiceRegistration was not created",
|
||||
nacosAutoServiceRegistration);
|
||||
assertThat(registration).isNotNull();
|
||||
assertThat(properties).isNotNull();
|
||||
assertThat(nacosAutoServiceRegistration).isNotNull();
|
||||
|
||||
checkoutNacosDiscoveryServiceIP();
|
||||
|
||||
}
|
||||
|
||||
private void checkoutNacosDiscoveryServiceIP() {
|
||||
assertEquals("NacosDiscoveryProperties service IP was wrong",
|
||||
getIPFromNetworkInterface(TestConfig.netWorkInterfaceName),
|
||||
registration.getHost());
|
||||
|
||||
assertThat(registration.getHost())
|
||||
.isEqualTo(getIPFromNetworkInterface(TestConfig.netWorkInterfaceName));
|
||||
}
|
||||
|
||||
private String getIPFromNetworkInterface(String networkInterface) {
|
||||
@@ -143,6 +139,7 @@ public class NacosAutoServiceRegistrationIpNetworkInterfaceTests {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
* Copyright 2013-2018 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
|
||||
* 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,
|
||||
@@ -16,12 +16,12 @@
|
||||
|
||||
package com.alibaba.cloud.nacos.registry;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
import com.alibaba.cloud.nacos.NacosDiscoveryAutoConfiguration;
|
||||
import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
|
||||
import com.alibaba.cloud.nacos.discovery.NacosDiscoveryClientAutoConfiguration;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
||||
@@ -30,19 +30,19 @@ import org.springframework.cloud.client.serviceregistry.AutoServiceRegistrationC
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.alibaba.cloud.nacos.NacosDiscoveryAutoConfiguration;
|
||||
import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
|
||||
import com.alibaba.cloud.nacos.discovery.NacosDiscoveryClientAutoConfiguration;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
/**
|
||||
* @author xiaojing
|
||||
*/
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = NacosAutoServiceRegistrationIpTests.TestConfig.class, properties = {
|
||||
"spring.application.name=myTestService1",
|
||||
"spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848",
|
||||
"spring.cloud.nacos.discovery.ip=123.123.123.123" }, webEnvironment = RANDOM_PORT)
|
||||
@SpringBootTest(classes = NacosAutoServiceRegistrationIpTests.TestConfig.class,
|
||||
properties = { "spring.application.name=myTestService1",
|
||||
"spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848",
|
||||
"spring.cloud.nacos.discovery.ip=123.123.123.123" },
|
||||
webEnvironment = RANDOM_PORT)
|
||||
public class NacosAutoServiceRegistrationIpTests {
|
||||
|
||||
@Autowired
|
||||
@@ -56,20 +56,15 @@ public class NacosAutoServiceRegistrationIpTests {
|
||||
|
||||
@Test
|
||||
public void contextLoads() throws Exception {
|
||||
|
||||
assertNotNull("NacosRegistration was not created", registration);
|
||||
assertNotNull("NacosDiscoveryProperties was not created", properties);
|
||||
assertNotNull("NacosAutoServiceRegistration was not created",
|
||||
nacosAutoServiceRegistration);
|
||||
assertThat(registration).isNotNull();
|
||||
assertThat(properties).isNotNull();
|
||||
assertThat(nacosAutoServiceRegistration).isNotNull();
|
||||
|
||||
checkoutNacosDiscoveryServiceIP();
|
||||
|
||||
}
|
||||
|
||||
private void checkoutNacosDiscoveryServiceIP() {
|
||||
assertEquals("NacosDiscoveryProperties service IP was wrong", "123.123.123.123",
|
||||
registration.getHost());
|
||||
|
||||
assertThat(registration.getHost()).isEqualTo("123.123.123.123");
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@@ -78,5 +73,7 @@ public class NacosAutoServiceRegistrationIpTests {
|
||||
NacosDiscoveryClientAutoConfiguration.class,
|
||||
NacosDiscoveryAutoConfiguration.class })
|
||||
public static class TestConfig {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
* Copyright 2013-2018 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
|
||||
* 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,
|
||||
@@ -16,12 +16,12 @@
|
||||
|
||||
package com.alibaba.cloud.nacos.registry;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
import com.alibaba.cloud.nacos.NacosDiscoveryAutoConfiguration;
|
||||
import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
|
||||
import com.alibaba.cloud.nacos.discovery.NacosDiscoveryClientAutoConfiguration;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
||||
@@ -30,20 +30,22 @@ import org.springframework.cloud.client.serviceregistry.AutoServiceRegistrationC
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.alibaba.cloud.nacos.NacosDiscoveryAutoConfiguration;
|
||||
import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
|
||||
import com.alibaba.cloud.nacos.discovery.NacosDiscoveryClientAutoConfiguration;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
/**
|
||||
* @author xiaojing
|
||||
*/
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = NacosAutoServiceRegistrationManagementPortTests.TestConfig.class, properties = {
|
||||
"spring.application.name=myTestService1", "management.server.port=8888",
|
||||
"management.server.servlet.context-path=/test-context-path",
|
||||
"spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848",
|
||||
"spring.cloud.nacos.discovery.port=8888" }, webEnvironment = RANDOM_PORT)
|
||||
@SpringBootTest(
|
||||
classes = NacosAutoServiceRegistrationManagementPortTests.TestConfig.class,
|
||||
properties = { "spring.application.name=myTestService1",
|
||||
"management.server.port=8888",
|
||||
"management.server.servlet.context-path=/test-context-path",
|
||||
"spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848",
|
||||
"spring.cloud.nacos.discovery.port=8888" },
|
||||
webEnvironment = RANDOM_PORT)
|
||||
public class NacosAutoServiceRegistrationManagementPortTests {
|
||||
|
||||
@Autowired
|
||||
@@ -57,24 +59,19 @@ public class NacosAutoServiceRegistrationManagementPortTests {
|
||||
|
||||
@Test
|
||||
public void contextLoads() throws Exception {
|
||||
|
||||
assertNotNull("NacosRegistration was not created", registration);
|
||||
assertNotNull("NacosDiscoveryProperties was not created", properties);
|
||||
assertNotNull("NacosAutoServiceRegistration was not created",
|
||||
nacosAutoServiceRegistration);
|
||||
assertThat(registration).isNotNull();
|
||||
assertThat(properties).isNotNull();
|
||||
assertThat(nacosAutoServiceRegistration).isNotNull();
|
||||
|
||||
checkoutNacosDiscoveryManagementData();
|
||||
|
||||
}
|
||||
|
||||
private void checkoutNacosDiscoveryManagementData() {
|
||||
assertEquals("NacosDiscoveryProperties management port was wrong", "8888",
|
||||
properties.getMetadata().get(NacosRegistration.MANAGEMENT_PORT));
|
||||
|
||||
assertEquals("NacosDiscoveryProperties management context path was wrong",
|
||||
"/test-context-path",
|
||||
properties.getMetadata().get(NacosRegistration.MANAGEMENT_CONTEXT_PATH));
|
||||
|
||||
assertThat(properties.getMetadata().get(NacosRegistration.MANAGEMENT_PORT))
|
||||
.isEqualTo("8888");
|
||||
assertThat(
|
||||
properties.getMetadata().get(NacosRegistration.MANAGEMENT_CONTEXT_PATH))
|
||||
.isEqualTo("/test-context-path");
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@@ -83,5 +80,7 @@ public class NacosAutoServiceRegistrationManagementPortTests {
|
||||
NacosDiscoveryClientAutoConfiguration.class,
|
||||
NacosDiscoveryAutoConfiguration.class })
|
||||
public static class TestConfig {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
* Copyright 2013-2018 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
|
||||
* 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,
|
||||
@@ -16,12 +16,12 @@
|
||||
|
||||
package com.alibaba.cloud.nacos.registry;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
import com.alibaba.cloud.nacos.NacosDiscoveryAutoConfiguration;
|
||||
import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
|
||||
import com.alibaba.cloud.nacos.discovery.NacosDiscoveryClientAutoConfiguration;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
||||
@@ -30,19 +30,19 @@ import org.springframework.cloud.client.serviceregistry.AutoServiceRegistrationC
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.alibaba.cloud.nacos.NacosDiscoveryAutoConfiguration;
|
||||
import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
|
||||
import com.alibaba.cloud.nacos.discovery.NacosDiscoveryClientAutoConfiguration;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
/**
|
||||
* @author xiaojing
|
||||
*/
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = NacosAutoServiceRegistrationPortTests.TestConfig.class, properties = {
|
||||
"spring.application.name=myTestService1",
|
||||
"spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848",
|
||||
"spring.cloud.nacos.discovery.port=8888" }, webEnvironment = RANDOM_PORT)
|
||||
@SpringBootTest(classes = NacosAutoServiceRegistrationPortTests.TestConfig.class,
|
||||
properties = { "spring.application.name=myTestService1",
|
||||
"spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848",
|
||||
"spring.cloud.nacos.discovery.port=8888" },
|
||||
webEnvironment = RANDOM_PORT)
|
||||
public class NacosAutoServiceRegistrationPortTests {
|
||||
|
||||
@Autowired
|
||||
@@ -56,20 +56,15 @@ public class NacosAutoServiceRegistrationPortTests {
|
||||
|
||||
@Test
|
||||
public void contextLoads() throws Exception {
|
||||
|
||||
assertNotNull("NacosRegistration was not created", registration);
|
||||
assertNotNull("NacosDiscoveryProperties was not created", properties);
|
||||
assertNotNull("NacosAutoServiceRegistration was not created",
|
||||
nacosAutoServiceRegistration);
|
||||
assertThat(registration).isNotNull();
|
||||
assertThat(properties).isNotNull();
|
||||
assertThat(nacosAutoServiceRegistration).isNotNull();
|
||||
|
||||
checkoutNacosDiscoveryServicePort();
|
||||
|
||||
}
|
||||
|
||||
private void checkoutNacosDiscoveryServicePort() {
|
||||
assertEquals("NacosDiscoveryProperties service Port was wrong", 8888,
|
||||
registration.getPort());
|
||||
|
||||
assertThat(registration.getPort()).isEqualTo(8888);
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@@ -78,5 +73,7 @@ public class NacosAutoServiceRegistrationPortTests {
|
||||
NacosDiscoveryClientAutoConfiguration.class,
|
||||
NacosDiscoveryAutoConfiguration.class })
|
||||
public static class TestConfig {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
* Copyright 2013-2018 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
|
||||
* 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,
|
||||
@@ -16,16 +16,16 @@
|
||||
|
||||
package com.alibaba.cloud.nacos.registry;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.alibaba.cloud.nacos.NacosDiscoveryAutoConfiguration;
|
||||
import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
|
||||
import com.alibaba.cloud.nacos.NacosNamingManager;
|
||||
import com.alibaba.cloud.nacos.discovery.NacosDiscoveryClientAutoConfiguration;
|
||||
import com.alibaba.cloud.nacos.endpoint.NacosDiscoveryEndpoint;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
||||
@@ -36,31 +36,30 @@ import org.springframework.cloud.commons.util.InetUtils;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.alibaba.cloud.nacos.NacosDiscoveryAutoConfiguration;
|
||||
import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
|
||||
import com.alibaba.cloud.nacos.discovery.NacosDiscoveryClientAutoConfiguration;
|
||||
import com.alibaba.cloud.nacos.endpoint.NacosDiscoveryEndpoint;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
/**
|
||||
* @author xiaojing
|
||||
*/
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = NacosAutoServiceRegistrationTests.TestConfig.class, properties = {
|
||||
"spring.application.name=myTestService1",
|
||||
"spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848",
|
||||
"spring.cloud.nacos.discovery.endpoint=test-endpoint",
|
||||
"spring.cloud.nacos.discovery.namespace=test-namespace",
|
||||
"spring.cloud.nacos.discovery.log-name=test-logName",
|
||||
"spring.cloud.nacos.discovery.weight=2",
|
||||
"spring.cloud.nacos.discovery.clusterName=test-cluster",
|
||||
"spring.cloud.nacos.discovery.namingLoadCacheAtStart=true",
|
||||
"spring.cloud.nacos.discovery.secure=true",
|
||||
"spring.cloud.nacos.discovery.accessKey=test-accessKey",
|
||||
"spring.cloud.nacos.discovery.secretKey=test-secretKey",
|
||||
"spring.cloud.nacos.discovery.heart-beat-interval=3",
|
||||
"spring.cloud.nacos.discovery.heart-beat-timeout=6",
|
||||
"spring.cloud.nacos.discovery.ip-delete-timeout=9", }, webEnvironment = RANDOM_PORT)
|
||||
@SpringBootTest(classes = NacosAutoServiceRegistrationTests.TestConfig.class,
|
||||
properties = { "spring.application.name=myTestService1",
|
||||
"spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848",
|
||||
"spring.cloud.nacos.discovery.endpoint=test-endpoint",
|
||||
"spring.cloud.nacos.discovery.namespace=test-namespace",
|
||||
"spring.cloud.nacos.discovery.log-name=test-logName",
|
||||
"spring.cloud.nacos.discovery.weight=2",
|
||||
"spring.cloud.nacos.discovery.clusterName=test-cluster",
|
||||
"spring.cloud.nacos.discovery.namingLoadCacheAtStart=true",
|
||||
"spring.cloud.nacos.discovery.secure=true",
|
||||
"spring.cloud.nacos.discovery.accessKey=test-accessKey",
|
||||
"spring.cloud.nacos.discovery.secretKey=test-secretKey",
|
||||
"spring.cloud.nacos.discovery.heart-beat-interval=3",
|
||||
"spring.cloud.nacos.discovery.heart-beat-timeout=6",
|
||||
"spring.cloud.nacos.discovery.ip-delete-timeout=9" },
|
||||
webEnvironment = RANDOM_PORT)
|
||||
public class NacosAutoServiceRegistrationTests {
|
||||
|
||||
@Autowired
|
||||
@@ -83,11 +82,9 @@ public class NacosAutoServiceRegistrationTests {
|
||||
|
||||
@Test
|
||||
public void contextLoads() throws Exception {
|
||||
|
||||
assertNotNull("NacosRegistration was not created", registration);
|
||||
assertNotNull("NacosDiscoveryProperties was not created", properties);
|
||||
assertNotNull("NacosAutoServiceRegistration was not created",
|
||||
nacosAutoServiceRegistration);
|
||||
assertThat(registration).isNotNull();
|
||||
assertThat(properties).isNotNull();
|
||||
assertThat(nacosAutoServiceRegistration).isNotNull();
|
||||
|
||||
checkoutNacosDiscoveryServerAddr();
|
||||
checkoutNacosDiscoveryEndpoint();
|
||||
@@ -114,105 +111,84 @@ public class NacosAutoServiceRegistrationTests {
|
||||
}
|
||||
|
||||
private void checkAutoRegister() {
|
||||
assertTrue("Nacos Auto Registration was not start",
|
||||
nacosAutoServiceRegistration.isRunning());
|
||||
assertThat(nacosAutoServiceRegistration.isRunning()).isEqualTo(Boolean.TRUE);
|
||||
}
|
||||
|
||||
private void checkoutNacosDiscoveryServerAddr() {
|
||||
assertEquals("NacosDiscoveryProperties server address was wrong",
|
||||
"127.0.0.1:8848", properties.getServerAddr());
|
||||
|
||||
assertThat(properties.getServerAddr()).isEqualTo("127.0.0.1:8848");
|
||||
}
|
||||
|
||||
private void checkoutNacosDiscoveryEndpoint() {
|
||||
assertEquals("NacosDiscoveryProperties endpoint was wrong", "test-endpoint",
|
||||
properties.getEndpoint());
|
||||
|
||||
assertThat(properties.getEndpoint()).isEqualTo("test-endpoint");
|
||||
}
|
||||
|
||||
private void checkoutNacosDiscoveryNamespace() {
|
||||
assertEquals("NacosDiscoveryProperties namespace was wrong", "test-namespace",
|
||||
properties.getNamespace());
|
||||
|
||||
assertThat(properties.getNamespace()).isEqualTo("test-namespace");
|
||||
}
|
||||
|
||||
private void checkoutNacosDiscoveryLogName() {
|
||||
assertEquals("NacosDiscoveryProperties logName was wrong", "test-logName",
|
||||
properties.getLogName());
|
||||
assertThat(properties.getLogName()).isEqualTo("test-logName");
|
||||
}
|
||||
|
||||
private void checkoutNacosDiscoveryWeight() {
|
||||
assertEquals(2, properties.getWeight(), 0.00000001);
|
||||
assertThat(properties.getWeight()).isEqualTo(2);
|
||||
}
|
||||
|
||||
private void checkoutNacosDiscoveryClusterName() {
|
||||
assertEquals("NacosDiscoveryProperties cluster was wrong", "test-cluster",
|
||||
properties.getClusterName());
|
||||
assertThat(properties.getClusterName()).isEqualTo("test-cluster");
|
||||
}
|
||||
|
||||
private void checkoutNacosDiscoveryCache() {
|
||||
assertEquals("NacosDiscoveryProperties naming load cache was wrong", "true",
|
||||
properties.getNamingLoadCacheAtStart());
|
||||
assertThat(properties.getNamingLoadCacheAtStart()).isEqualTo("true");
|
||||
}
|
||||
|
||||
private void checkoutNacosDiscoverySecure() {
|
||||
assertEquals("NacosDiscoveryProperties is secure was wrong", true,
|
||||
properties.isSecure());
|
||||
assertEquals("NacosDiscoveryProperties is secure was wrong", "true",
|
||||
properties.getMetadata().get("secure"));
|
||||
assertThat(properties.isSecure()).isEqualTo(true);
|
||||
assertThat(properties.getMetadata().get("secure")).isEqualTo("true");
|
||||
}
|
||||
|
||||
private void checkoutNacosDiscoveryAccessKey() {
|
||||
assertEquals("NacosDiscoveryProperties is access key was wrong", "test-accessKey",
|
||||
properties.getAccessKey());
|
||||
assertThat(properties.getAccessKey()).isEqualTo("test-accessKey");
|
||||
}
|
||||
|
||||
private void checkoutNacosDiscoverySecrectKey() {
|
||||
assertEquals("NacosDiscoveryProperties is secret key was wrong", "test-secretKey",
|
||||
properties.getSecretKey());
|
||||
assertThat(properties.getSecretKey()).isEqualTo("test-secretKey");
|
||||
}
|
||||
|
||||
private void checkoutNacosDiscoveryHeartBeatInterval() {
|
||||
assertEquals("NacosDiscoveryProperties heart beat interval was wrong",
|
||||
Integer.valueOf(3), properties.getHeartBeatInterval());
|
||||
assertThat(properties.getHeartBeatInterval()).isEqualTo(Integer.valueOf(3));
|
||||
}
|
||||
|
||||
private void checkoutNacosDiscoveryHeartBeatTimeout() {
|
||||
assertEquals("NacosDiscoveryProperties heart beat timeout was wrong",
|
||||
Integer.valueOf(6), properties.getHeartBeatTimeout());
|
||||
assertThat(properties.getHeartBeatTimeout()).isEqualTo(Integer.valueOf(6));
|
||||
}
|
||||
|
||||
private void checkoutNacosDiscoveryIpDeleteTimeout() {
|
||||
assertEquals("NacosDiscoveryProperties ip delete timeout was wrong",
|
||||
Integer.valueOf(9), properties.getIpDeleteTimeout());
|
||||
assertThat(properties.getIpDeleteTimeout()).isEqualTo(Integer.valueOf(9));
|
||||
}
|
||||
|
||||
private void checkoutNacosDiscoveryServiceName() {
|
||||
assertEquals("NacosDiscoveryProperties service name was wrong", "myTestService1",
|
||||
properties.getService());
|
||||
|
||||
assertThat(properties.getService()).isEqualTo("myTestService1");
|
||||
}
|
||||
|
||||
private void checkoutNacosDiscoveryServiceIP() {
|
||||
assertEquals("NacosDiscoveryProperties service IP was wrong",
|
||||
inetUtils.findFirstNonLoopbackHostInfo().getIpAddress(),
|
||||
registration.getHost());
|
||||
|
||||
assertThat(registration.getHost())
|
||||
.isEqualTo(inetUtils.findFirstNonLoopbackHostInfo().getIpAddress());
|
||||
}
|
||||
|
||||
private void checkoutNacosDiscoveryServicePort() {
|
||||
assertEquals("NacosDiscoveryProperties service Port was wrong", port,
|
||||
registration.getPort());
|
||||
|
||||
assertThat(registration.getPort()).isEqualTo(port);
|
||||
}
|
||||
|
||||
private void checkoutEndpoint() throws Exception {
|
||||
NacosDiscoveryEndpoint nacosDiscoveryEndpoint = new NacosDiscoveryEndpoint(
|
||||
nacosNamingManager, properties);
|
||||
Map<String, Object> map = nacosDiscoveryEndpoint.nacosDiscovery();
|
||||
assertEquals(map.get("NacosDiscoveryProperties"), properties);
|
||||
assertEquals(map.get("subscribe").toString(),
|
||||
nacosNamingManager.getNamingService().getSubscribeServices().toString());
|
||||
|
||||
assertThat(properties).isEqualTo(map.get("NacosDiscoveryProperties"));
|
||||
assertThat(
|
||||
nacosNamingManager.getNamingService().getSubscribeServices().toString())
|
||||
.isEqualTo(map.get("subscribe").toString());
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@@ -221,5 +197,7 @@ public class NacosAutoServiceRegistrationTests {
|
||||
NacosDiscoveryClientAutoConfiguration.class,
|
||||
NacosDiscoveryAutoConfiguration.class })
|
||||
public static class TestConfig {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,8 +1,26 @@
|
||||
/*
|
||||
* Copyright 2013-2018 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 com.alibaba.cloud.nacos.ribbon;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import com.alibaba.cloud.nacos.discovery.NacosDiscoveryClientAutoConfiguration;
|
||||
import com.netflix.client.config.DefaultClientConfigImpl;
|
||||
import com.netflix.client.config.IClientConfig;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
|
||||
@@ -12,10 +30,7 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import com.alibaba.cloud.nacos.discovery.NacosDiscoveryClientAutoConfiguration;
|
||||
|
||||
import com.netflix.client.config.DefaultClientConfigImpl;
|
||||
import com.netflix.client.config.IClientConfig;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author xiaojing
|
||||
|
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
* Copyright 2013-2018 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
|
||||
* 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,
|
||||
@@ -16,27 +16,25 @@
|
||||
|
||||
package com.alibaba.cloud.nacos.ribbon;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.alibaba.cloud.nacos.NacosNamingManager;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
|
||||
import com.alibaba.cloud.nacos.NacosNamingManager;
|
||||
import com.alibaba.cloud.nacos.test.NacosMockTest;
|
||||
import com.alibaba.nacos.api.naming.NamingService;
|
||||
import com.alibaba.nacos.api.naming.pojo.Instance;
|
||||
|
||||
import com.netflix.client.config.IClientConfig;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* @author xiaojing
|
||||
@@ -172,4 +170,5 @@ public class NacosServerListTests {
|
||||
assertThat(servers.get(0).getInstance().getMetadata().get("instanceNum"))
|
||||
.isEqualTo("1");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
* Copyright 2013-2018 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
|
||||
* 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,
|
||||
@@ -33,4 +33,5 @@ public class CommonTestConfig {
|
||||
RestTemplate loadBalancedRestTemplate() {
|
||||
return new RestTemplate();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
* Copyright 2013-2018 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
|
||||
* 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,
|
||||
@@ -46,4 +46,5 @@ public class NacosMockTest {
|
||||
instance.setMetadata(metadata);
|
||||
return instance;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user