Commit 896a53f7 by Nepxion

重构测试用例

parent f6871877
......@@ -14,9 +14,7 @@ import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import com.nepxion.discovery.plugin.framework.adapter.PluginAdapter;
import com.nepxion.discovery.plugin.strategy.discovery.DiscoveryEnabledAdapter;
import com.nepxion.discovery.plugin.strategy.extension.gateway.context.GatewayStrategyContext;
import com.netflix.loadbalancer.Server;
......@@ -24,11 +22,8 @@ import com.netflix.loadbalancer.Server;
public class MyDiscoveryEnabledAdapter implements DiscoveryEnabledAdapter {
private static final Logger LOG = LoggerFactory.getLogger(MyDiscoveryEnabledAdapter.class);
@Autowired
protected PluginAdapter pluginAdapter;
@Override
public boolean apply(Server server) {
public boolean apply(Server server, Map<String, String> metadata) {
GatewayStrategyContext context = GatewayStrategyContext.getCurrentContext();
String token = context.getExchange().getRequest().getHeaders().getFirst("token");
// String value = context.getExchange().getRequest().getQueryParams().getFirst("value");
......@@ -37,7 +32,6 @@ public class MyDiscoveryEnabledAdapter implements DiscoveryEnabledAdapter {
GatewayStrategyContext.clearCurrentContext();
String serviceId = server.getMetaInfo().getAppName().toLowerCase();
Map<String, String> metadata = pluginAdapter.getServerMetadata(server);
LOG.info("Gateway端负载均衡用户定制触发:serviceId={}, host={}, metadata={}, context={}", serviceId, server.toString(), metadata, context);
......
......@@ -14,9 +14,7 @@ import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import com.nepxion.discovery.plugin.framework.adapter.PluginAdapter;
import com.nepxion.discovery.plugin.framework.constant.PluginConstant;
import com.nepxion.discovery.plugin.strategy.discovery.DiscoveryEnabledAdapter;
import com.nepxion.discovery.plugin.strategy.extension.service.constant.ServiceStrategyConstant;
......@@ -26,17 +24,13 @@ import com.netflix.loadbalancer.Server;
public class MyDiscoveryEnabledAdapter implements DiscoveryEnabledAdapter {
private static final Logger LOG = LoggerFactory.getLogger(MyDiscoveryEnabledAdapter.class);
@Autowired
protected PluginAdapter pluginAdapter;
@SuppressWarnings("unchecked")
@Override
public boolean apply(Server server) {
public boolean apply(Server server, Map<String, String> metadata) {
ServiceStrategyContext context = ServiceStrategyContext.getCurrentContext();
Map<String, Object> attributes = context.getAttributes();
String serviceId = server.getMetaInfo().getAppName().toLowerCase();
Map<String, String> metadata = pluginAdapter.getServerMetadata(server);
String version = metadata.get(PluginConstant.VERSION);
LOG.info("Serivice端负载均衡用户定制触发:serviceId={}, host={}, metadata={}, context={}", serviceId, server.toString(), metadata, context);
......
......@@ -14,9 +14,7 @@ import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import com.nepxion.discovery.plugin.framework.adapter.PluginAdapter;
import com.nepxion.discovery.plugin.strategy.discovery.DiscoveryEnabledAdapter;
import com.netflix.loadbalancer.Server;
import com.netflix.zuul.context.RequestContext;
......@@ -24,17 +22,13 @@ import com.netflix.zuul.context.RequestContext;
public class MyDiscoveryEnabledAdapter implements DiscoveryEnabledAdapter {
private static final Logger LOG = LoggerFactory.getLogger(MyDiscoveryEnabledAdapter.class);
@Autowired
protected PluginAdapter pluginAdapter;
@Override
public boolean apply(Server server) {
public boolean apply(Server server, Map<String, String> metadata) {
RequestContext context = RequestContext.getCurrentContext();
String token = context.getRequest().getHeader("token");
// String value = context.getRequest().getParameter("value");
String serviceId = server.getMetaInfo().getAppName().toLowerCase();
Map<String, String> metadata = pluginAdapter.getServerMetadata(server);
LOG.info("Zuul端负载均衡用户定制触发:serviceId={}, host={}, metadata={}, context={}", serviceId, server.toString(), metadata, context);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment