update tests
This commit is contained in:
@@ -17,6 +17,8 @@
|
||||
package org.springframework.cloud.netflix.eureka.config;
|
||||
|
||||
import com.netflix.discovery.AbstractDiscoveryClientOptionalArgs;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
@@ -35,13 +37,17 @@ import org.springframework.context.annotation.Configuration;
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public class DiscoveryClientOptionalArgsConfiguration {
|
||||
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingClass("com.sun.jersey.api.client.filter.ClientFilter")
|
||||
@ConditionalOnMissingBean(value = { AbstractDiscoveryClientOptionalArgs.class },
|
||||
search = SearchStrategy.CURRENT)
|
||||
@ConditionalOnProperty(prefix = "eureka.client", name = "webclientSupport",
|
||||
matchIfMissing = true, havingValue = "false")
|
||||
@ConditionalOnProperty(prefix = "eureka.client",
|
||||
name = { "webclientSupport", "webclient-support" }, matchIfMissing = true,
|
||||
havingValue = "false")
|
||||
public RestTemplateDiscoveryClientOptionalArgs restTemplateDiscoveryClientOptionalArgs() {
|
||||
logger.info("Eureka HTTP Client uses RestTemplate.");
|
||||
return new RestTemplateDiscoveryClientOptionalArgs();
|
||||
}
|
||||
|
||||
@@ -51,9 +57,10 @@ public class DiscoveryClientOptionalArgsConfiguration {
|
||||
value = { AbstractDiscoveryClientOptionalArgs.class,
|
||||
RestTemplateDiscoveryClientOptionalArgs.class },
|
||||
search = SearchStrategy.CURRENT)
|
||||
@ConditionalOnProperty(prefix = "eureka.client", name = "webclientSupport",
|
||||
havingValue = "true")
|
||||
@ConditionalOnProperty(prefix = "eureka.client",
|
||||
name = { "webclientSupport", "webclient-support" }, havingValue = "true")
|
||||
public WebClientDiscoveryClientOptionalArgs webClientDiscoveryClientOptionalArgs() {
|
||||
logger.info("Eureka HTTP Client uses WebClient.");
|
||||
return new WebClientDiscoveryClientOptionalArgs();
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.reactive.function.BodyInserters;
|
||||
import org.springframework.web.reactive.function.client.ClientResponse;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
@@ -56,6 +57,7 @@ public class WebClientEurekaHttpClient implements EurekaHttpClient {
|
||||
@Override
|
||||
public EurekaHttpResponse<Void> register(InstanceInfo info) {
|
||||
return webClient.post().uri("apps/" + info.getAppName(), Void.class)
|
||||
.body(BodyInserters.fromValue(info))
|
||||
.header(HttpHeaders.ACCEPT_ENCODING, "gzip")
|
||||
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
|
||||
.exchange().map(response -> eurekaHttpResponse(response)).block();
|
||||
@@ -76,7 +78,9 @@ public class WebClientEurekaHttpClient implements EurekaHttpClient {
|
||||
? "&overriddenstatus=" + overriddenStatus.name() : "");
|
||||
|
||||
ClientResponse response = webClient.put().uri(urlPath, InstanceInfo.class)
|
||||
.exchange().block();
|
||||
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
|
||||
.header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE).exchange()
|
||||
.block();
|
||||
|
||||
EurekaHttpResponseBuilder<InstanceInfo> builder = anEurekaHttpResponse(
|
||||
statusCodeValueOf(response), InstanceInfo.class)
|
||||
@@ -99,8 +103,9 @@ public class WebClientEurekaHttpClient implements EurekaHttpClient {
|
||||
+ newStatus.name() + "&lastDirtyTimestamp="
|
||||
+ info.getLastDirtyTimestamp().toString();
|
||||
|
||||
return webClient.put().uri(urlPath, Void.class).exchange()
|
||||
.map(response -> eurekaHttpResponse(response)).block();
|
||||
return webClient.put().uri(urlPath, Void.class)
|
||||
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
|
||||
.exchange().map(response -> eurekaHttpResponse(response)).block();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -109,8 +114,9 @@ public class WebClientEurekaHttpClient implements EurekaHttpClient {
|
||||
String urlPath = "apps/" + appName + '/' + id + "/status?lastDirtyTimestamp="
|
||||
+ info.getLastDirtyTimestamp().toString();
|
||||
|
||||
return webClient.delete().uri(urlPath, Void.class).exchange()
|
||||
.map(response -> eurekaHttpResponse(response)).block();
|
||||
return webClient.delete().uri(urlPath, Void.class)
|
||||
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
|
||||
.exchange().map(response -> eurekaHttpResponse(response)).block();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -127,7 +133,9 @@ public class WebClientEurekaHttpClient implements EurekaHttpClient {
|
||||
+ StringUtil.join(regions);
|
||||
}
|
||||
|
||||
ClientResponse response = webClient.get().uri(url, Applications.class).exchange()
|
||||
ClientResponse response = webClient.get().uri(url, Applications.class)
|
||||
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
|
||||
.header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE).exchange()
|
||||
.block();
|
||||
|
||||
int statusCode = statusCodeValueOf(response);
|
||||
@@ -159,7 +167,9 @@ public class WebClientEurekaHttpClient implements EurekaHttpClient {
|
||||
public EurekaHttpResponse<Application> getApplication(String appName) {
|
||||
|
||||
ClientResponse response = webClient.get()
|
||||
.uri("apps/" + appName, Application.class).exchange().block();
|
||||
.uri("apps/" + appName, Application.class)
|
||||
.header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE).exchange()
|
||||
.block();
|
||||
|
||||
int statusCode = statusCodeValueOf(response);
|
||||
Application body = response.toEntity(Application.class).block().getBody();
|
||||
@@ -183,7 +193,8 @@ public class WebClientEurekaHttpClient implements EurekaHttpClient {
|
||||
|
||||
private EurekaHttpResponse<InstanceInfo> getInstanceInternal(String urlPath) {
|
||||
ClientResponse response = webClient.get().uri(urlPath, InstanceInfo.class)
|
||||
.exchange().block();
|
||||
.header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE).exchange()
|
||||
.block();
|
||||
|
||||
int statusCode = statusCodeValueOf(response);
|
||||
InstanceInfo body = response.toEntity(InstanceInfo.class).block().getBody();
|
||||
|
||||
@@ -39,7 +39,7 @@ import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
|
||||
@ClassPathExclusions({ "jersey-client-*", "jersey-core-*", "jersey-apache-client4-*" })
|
||||
@SpringBootTest(classes = EurekaSampleApplication.class,
|
||||
webEnvironment = WebEnvironment.RANDOM_PORT)
|
||||
public class RestTemplateOptionalArgsConfigurationTest {
|
||||
public class EurekaHttpClientsOptionalArgsConfigurationTest {
|
||||
|
||||
@Test
|
||||
public void contextLoadsWithRestTemplate() {
|
||||
@@ -47,11 +47,14 @@ public class RestTemplateOptionalArgsConfigurationTest {
|
||||
.web(WebApplicationType.NONE).sources(EurekaSampleApplication.class)
|
||||
.properties(new String[] { "eureka.client.webclientSupport=false" })
|
||||
.run()) {
|
||||
assertThat(context.getBean(RestTemplateDiscoveryClientOptionalArgs.class)).isNotNull();
|
||||
assertThat(context.getBean(RestTemplateDiscoveryClientOptionalArgs.class))
|
||||
.isNotNull();
|
||||
try {
|
||||
Object bean = context.getBean(WebClientDiscoveryClientOptionalArgs.class);
|
||||
assertThat(bean).isNull();
|
||||
} catch(Exception ex) {}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,11 +64,15 @@ public class RestTemplateOptionalArgsConfigurationTest {
|
||||
.web(WebApplicationType.NONE).sources(EurekaSampleApplication.class)
|
||||
.properties(new String[] { "eureka.client.webclientSupport=true" })
|
||||
.run()) {
|
||||
assertThat(context.getBean(WebClientDiscoveryClientOptionalArgs.class)).isNotNull();
|
||||
assertThat(context.getBean(WebClientDiscoveryClientOptionalArgs.class))
|
||||
.isNotNull();
|
||||
try {
|
||||
Object bean = context.getBean(RestTemplateDiscoveryClientOptionalArgs.class);
|
||||
Object bean = context
|
||||
.getBean(RestTemplateDiscoveryClientOptionalArgs.class);
|
||||
assertThat(bean).isNull();
|
||||
} catch(Exception ex) {}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,11 +81,14 @@ public class RestTemplateOptionalArgsConfigurationTest {
|
||||
try (ConfigurableApplicationContext context = new SpringApplicationBuilder()
|
||||
.web(WebApplicationType.NONE).sources(EurekaSampleApplication.class)
|
||||
.run()) {
|
||||
assertThat(context.getBean(RestTemplateDiscoveryClientOptionalArgs.class)).isNotNull();
|
||||
assertThat(context.getBean(RestTemplateDiscoveryClientOptionalArgs.class))
|
||||
.isNotNull();
|
||||
try {
|
||||
Object bean = context.getBean(WebClientDiscoveryClientOptionalArgs.class);
|
||||
assertThat(bean).isNull();
|
||||
} catch(Exception ex) {}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright 2012-2019 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.http;
|
||||
|
||||
import com.netflix.appinfo.InstanceInfo;
|
||||
import com.netflix.discovery.shared.Applications;
|
||||
import com.netflix.discovery.shared.transport.EurekaHttpClient;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author Haytham Mohamed
|
||||
**/
|
||||
public abstract class AbstractEurekaHttpClientTest {
|
||||
|
||||
protected EurekaHttpClient eurekaHttpClient;
|
||||
|
||||
protected InstanceInfo info;
|
||||
|
||||
abstract public void setup();
|
||||
|
||||
@Test
|
||||
public void testRegister() {
|
||||
assertThat(eurekaHttpClient.register(info).getStatusCode())
|
||||
.isEqualTo(HttpStatus.OK.value());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCancel() {
|
||||
assertThat(eurekaHttpClient.cancel("test", "test").getStatusCode())
|
||||
.isEqualTo(HttpStatus.OK.value());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSendHeartBeat() {
|
||||
assertThat(eurekaHttpClient.sendHeartBeat("test", "test", info, null)
|
||||
.getStatusCode()).isEqualTo(HttpStatus.OK.value());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSendHeartBeatFourOFour() {
|
||||
assertThat(eurekaHttpClient.sendHeartBeat("fourOFour", "test", info, null)
|
||||
.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND.value());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStatusUpdate() {
|
||||
assertThat(eurekaHttpClient
|
||||
.statusUpdate("test", "test", InstanceInfo.InstanceStatus.UP, info)
|
||||
.getStatusCode()).isEqualTo(HttpStatus.OK.value());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteStatusOverride() {
|
||||
assertThat(eurekaHttpClient.deleteStatusOverride("test", "test", info)
|
||||
.getStatusCode()).isEqualTo(HttpStatus.OK.value());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetApplications() {
|
||||
Applications entity = eurekaHttpClient.getApplications().getEntity();
|
||||
assertThat(entity).isNotNull();
|
||||
assertThat(eurekaHttpClient.getApplications("us", "eu").getEntity()).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDelta() {
|
||||
eurekaHttpClient.getDelta().getEntity();
|
||||
eurekaHttpClient.getDelta("us", "eu").getEntity();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetVips() {
|
||||
eurekaHttpClient.getVip("test");
|
||||
eurekaHttpClient.getVip("test", "us", "eu");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSecureVip() {
|
||||
eurekaHttpClient.getSecureVip("test");
|
||||
eurekaHttpClient.getSecureVip("test", "us", "eu");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetApplication() {
|
||||
eurekaHttpClient.getApplication("test");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetInstance() {
|
||||
eurekaHttpClient.getInstance("test");
|
||||
eurekaHttpClient.getInstance("test", "test");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,14 +16,9 @@
|
||||
|
||||
package org.springframework.cloud.netflix.eureka.http;
|
||||
|
||||
import com.netflix.appinfo.InstanceInfo;
|
||||
import com.netflix.appinfo.InstanceInfo.InstanceStatus;
|
||||
import com.netflix.appinfo.providers.EurekaConfigBasedInstanceInfoProvider;
|
||||
import com.netflix.discovery.shared.Applications;
|
||||
import com.netflix.discovery.shared.resolver.DefaultEndpoint;
|
||||
import com.netflix.discovery.shared.transport.EurekaHttpClient;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -32,12 +27,9 @@ import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||
import org.springframework.cloud.commons.util.InetUtils;
|
||||
import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author Daniel Lavoie
|
||||
*/
|
||||
@@ -46,7 +38,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
properties = { "debug=true", "security.basic.enabled=true" },
|
||||
webEnvironment = WebEnvironment.RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
public class RestTemplateEurekaHttpClientTest {
|
||||
public class RestTemplateEurekaHttpClientTest extends AbstractEurekaHttpClientTest {
|
||||
|
||||
@Autowired
|
||||
private InetUtils inetUtils;
|
||||
@@ -54,10 +46,6 @@ public class RestTemplateEurekaHttpClientTest {
|
||||
@Value("http://${security.user.name}:${security.user.password}@localhost:${local.server.port}")
|
||||
private String serviceUrl;
|
||||
|
||||
private EurekaHttpClient eurekaHttpClient;
|
||||
|
||||
private InstanceInfo info;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
eurekaHttpClient = new RestTemplateTransportClientFactory()
|
||||
@@ -78,76 +66,4 @@ public class RestTemplateEurekaHttpClientTest {
|
||||
info = new EurekaConfigBasedInstanceInfoProvider(config).get();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRegister() {
|
||||
assertThat(eurekaHttpClient.register(info).getStatusCode())
|
||||
.isEqualTo(HttpStatus.OK.value());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCancel() {
|
||||
assertThat(eurekaHttpClient.cancel("test", "test").getStatusCode())
|
||||
.isEqualTo(HttpStatus.OK.value());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSendHeartBeat() {
|
||||
assertThat(eurekaHttpClient.sendHeartBeat("test", "test", info, null)
|
||||
.getStatusCode()).isEqualTo(HttpStatus.OK.value());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSendHeartBeatFourOFour() {
|
||||
assertThat(eurekaHttpClient.sendHeartBeat("fourOFour", "test", info, null)
|
||||
.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND.value());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStatusUpdate() {
|
||||
assertThat(eurekaHttpClient.statusUpdate("test", "test", InstanceStatus.UP, info)
|
||||
.getStatusCode()).isEqualTo(HttpStatus.OK.value());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteStatusOverride() {
|
||||
assertThat(eurekaHttpClient.deleteStatusOverride("test", "test", info)
|
||||
.getStatusCode()).isEqualTo(HttpStatus.OK.value());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetApplications() {
|
||||
Applications entity = eurekaHttpClient.getApplications().getEntity();
|
||||
assertThat(entity).isNotNull();
|
||||
assertThat(eurekaHttpClient.getApplications("us", "eu").getEntity()).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDelta() {
|
||||
eurekaHttpClient.getDelta().getEntity();
|
||||
eurekaHttpClient.getDelta("us", "eu").getEntity();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetVips() {
|
||||
eurekaHttpClient.getVip("test");
|
||||
eurekaHttpClient.getVip("test", "us", "eu");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSecureVip() {
|
||||
eurekaHttpClient.getSecureVip("test");
|
||||
eurekaHttpClient.getSecureVip("test", "us", "eu");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetApplication() {
|
||||
eurekaHttpClient.getApplication("test");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetInstance() {
|
||||
eurekaHttpClient.getInstance("test");
|
||||
eurekaHttpClient.getInstance("test", "test");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright 2017-2019 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.http;
|
||||
|
||||
import com.netflix.appinfo.providers.EurekaConfigBasedInstanceInfoProvider;
|
||||
import com.netflix.discovery.shared.resolver.DefaultEndpoint;
|
||||
import org.junit.Before;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||
import org.springframework.cloud.commons.util.InetUtils;
|
||||
import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* @author Daniel Lavoie
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringBootTest(classes = EurekaServerMockApplication.class,
|
||||
properties = { "debug=true", "security.basic.enabled=true",
|
||||
"eureka.client.webclientSupport=true" },
|
||||
webEnvironment = WebEnvironment.RANDOM_PORT)
|
||||
@DirtiesContext
|
||||
public class WebClientEurekaHttpClientTest extends AbstractEurekaHttpClientTest {
|
||||
|
||||
@Autowired
|
||||
private InetUtils inetUtils;
|
||||
|
||||
@Value("http://${security.user.name}:${security.user.password}@localhost:${local.server.port}")
|
||||
private String serviceUrl;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
eurekaHttpClient = new WebClientTransportClientFactory()
|
||||
.newClient(new DefaultEndpoint(serviceUrl));
|
||||
|
||||
EurekaInstanceConfigBean config = new EurekaInstanceConfigBean(inetUtils);
|
||||
|
||||
String appname = "customapp";
|
||||
config.setIpAddress("127.0.0.1");
|
||||
config.setHostname("localhost");
|
||||
config.setAppname(appname);
|
||||
config.setVirtualHostName(appname);
|
||||
config.setSecureVirtualHostName(appname);
|
||||
config.setNonSecurePort(4444);
|
||||
config.setSecurePort(8443);
|
||||
config.setInstanceId("127.0.0.1:customapp:4444");
|
||||
|
||||
info = new EurekaConfigBasedInstanceInfoProvider(config).get();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2017-2019 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.http;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author Daniel Lavoie
|
||||
*/
|
||||
public class WebClientTransportClientFactoriesTest {
|
||||
|
||||
@Test(expected = UnsupportedOperationException.class)
|
||||
public void testJerseyIsUnsuported() {
|
||||
new WebClientTransportClientFactories().newTransportClientFactory(null, null);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright 2017-2019 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.http;
|
||||
|
||||
import com.netflix.discovery.shared.resolver.DefaultEndpoint;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author Daniel Lavoie
|
||||
*/
|
||||
public class WebClientTransportClientFactoryTest {
|
||||
|
||||
private WebClientTransportClientFactory transportClientFatory;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
transportClientFatory = new WebClientTransportClientFactory();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithoutUserInfo() {
|
||||
transportClientFatory.newClient(new DefaultEndpoint("http://localhost:8761"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvalidUserInfo() {
|
||||
transportClientFatory
|
||||
.newClient(new DefaultEndpoint("http://test@localhost:8761"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUserInfo() {
|
||||
transportClientFatory
|
||||
.newClient(new DefaultEndpoint("http://test:test@localhost:8761"));
|
||||
}
|
||||
|
||||
@After
|
||||
public void shutdown() {
|
||||
transportClientFatory.shutdown();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user