Commit 5b86b577 by Dave Syer

Rename a test so it gets run in CI

Also does not rename another one because it fails (see gh-804). The bug can be fixed in feign (https://github.com/Netflix/feign/pull/324), and if that gets merged and released we can revert some of the recent changes to the apache load balancer here.
parent c2483cbe
/*
* Copyright 2013-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud.netflix.feign.encoding;
import com.netflix.loadbalancer.BaseLoadBalancer;
import com.netflix.loadbalancer.ILoadBalancer;
import com.netflix.loadbalancer.Server;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.IntegrationTest;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.cloud.netflix.feign.encoding.app.client.InvoiceClient;
import org.springframework.cloud.netflix.feign.encoding.app.domain.Invoice;
import org.springframework.cloud.netflix.ribbon.RibbonClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import java.util.Collections;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
/**
* Demonstrates usage of this component.
*
* @author Jakub Narloch
*/
@WebAppConfiguration
@IntegrationTest({"server.port=0","feign.compression.request.enabled=true","feign.compression.response.enabled=true"})
@SpringApplicationConfiguration(classes = {Demo.Application.class})
@RunWith(SpringJUnit4ClassRunner.class)
public class Demo {
@Autowired
private InvoiceClient invoiceClient;
@Test
public void compressedResponse() {
// given
final List<Invoice> invoices = Invoices.createInvoiceList(50);
// when
final ResponseEntity<List<Invoice>> response = invoiceClient.saveInvoices(invoices);
// then
assertNotNull(response);
assertEquals(HttpStatus.OK, response.getStatusCode());
assertNotNull(response.getBody());
assertEquals(invoices.size(), response.getBody().size());
}
@EnableFeignClients(clients = InvoiceClient.class)
@RibbonClient(name = "local", configuration = LocalRibbonClientConfiguration.class)
@ComponentScan("org.springframework.cloud.netflix.feign.encoding.app")
@EnableAutoConfiguration
@Configuration
public static class Application {
}
@Configuration
static class LocalRibbonClientConfiguration {
@Value("${local.server.port}")
private int port = 0;
@Bean
public ILoadBalancer ribbonLoadBalancer() {
BaseLoadBalancer balancer = new BaseLoadBalancer();
balancer.setServersList(Collections.singletonList(new Server("localhost", this.port)));
return balancer;
}
}
}
\ No newline at end of file
...@@ -16,14 +16,14 @@ ...@@ -16,14 +16,14 @@
package org.springframework.cloud.netflix.feign.encoding; package org.springframework.cloud.netflix.feign.encoding;
import com.netflix.loadbalancer.BaseLoadBalancer; import java.util.Collections;
import com.netflix.loadbalancer.ILoadBalancer; import java.util.List;
import com.netflix.loadbalancer.Server;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.test.IntegrationTest; import org.springframework.boot.test.IntegrationTest;
import org.springframework.boot.test.SpringApplicationConfiguration; import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.cloud.netflix.feign.EnableFeignClients; import org.springframework.cloud.netflix.feign.EnableFeignClients;
...@@ -31,15 +31,15 @@ import org.springframework.cloud.netflix.feign.encoding.app.client.InvoiceClient ...@@ -31,15 +31,15 @@ import org.springframework.cloud.netflix.feign.encoding.app.client.InvoiceClient
import org.springframework.cloud.netflix.feign.encoding.app.domain.Invoice; import org.springframework.cloud.netflix.feign.encoding.app.domain.Invoice;
import org.springframework.cloud.netflix.ribbon.RibbonClient; import org.springframework.cloud.netflix.ribbon.RibbonClient;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration; import org.springframework.test.context.web.WebAppConfiguration;
import java.util.Collections; import com.netflix.loadbalancer.BaseLoadBalancer;
import java.util.List; import com.netflix.loadbalancer.ILoadBalancer;
import com.netflix.loadbalancer.Server;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
...@@ -50,47 +50,46 @@ import static org.junit.Assert.assertNotNull; ...@@ -50,47 +50,46 @@ import static org.junit.Assert.assertNotNull;
* @author Jakub Narloch * @author Jakub Narloch
*/ */
@WebAppConfiguration @WebAppConfiguration
@IntegrationTest({"server.port=0","feign.compression.response.enabled=true"}) @IntegrationTest({ "server.port=0", "feign.compression.response.enabled=true" })
@SpringApplicationConfiguration(classes = {FeignAcceptEncodingTest.Application.class}) @SpringApplicationConfiguration(classes = { FeignAcceptEncodingTests.Application.class })
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
public class FeignAcceptEncodingTest { public class FeignAcceptEncodingTests {
@Autowired @Autowired
private InvoiceClient invoiceClient; private InvoiceClient invoiceClient;
@Test @Test
public void compressedResponse() { public void compressedResponse() {
// when // when
final ResponseEntity<List<Invoice>> invoices = invoiceClient.getInvoices(); final ResponseEntity<List<Invoice>> invoices = this.invoiceClient.getInvoices();
// then // then
assertNotNull(invoices); assertNotNull(invoices);
assertEquals(HttpStatus.OK, invoices.getStatusCode()); assertEquals(HttpStatus.OK, invoices.getStatusCode());
assertNotNull(invoices.getBody()); assertNotNull(invoices.getBody());
assertEquals(100, invoices.getBody().size()); assertEquals(100, invoices.getBody().size());
} }
@EnableFeignClients(clients = InvoiceClient.class) @EnableFeignClients(clients = InvoiceClient.class)
@RibbonClient(name = "local", configuration = LocalRibbonClientConfiguration.class) @RibbonClient(name = "local", configuration = LocalRibbonClientConfiguration.class)
@ComponentScan("org.springframework.cloud.netflix.feign.encoding.app") @SpringBootApplication(scanBasePackages = "org.springframework.cloud.netflix.feign.encoding.app")
@EnableAutoConfiguration public static class Application {
@Configuration }
public static class Application {
}
@Configuration @Configuration
static class LocalRibbonClientConfiguration { static class LocalRibbonClientConfiguration {
@Value("${local.server.port}") @Value("${local.server.port}")
private int port = 0; private int port = 0;
@Bean @Bean
public ILoadBalancer ribbonLoadBalancer() { public ILoadBalancer ribbonLoadBalancer() {
BaseLoadBalancer balancer = new BaseLoadBalancer(); BaseLoadBalancer balancer = new BaseLoadBalancer();
balancer.setServersList(Collections.singletonList(new Server("localhost", this.port))); balancer.setServersList(
return balancer; Collections.singletonList(new Server("localhost", this.port)));
} return balancer;
} }
}
} }
\ No newline at end of file
...@@ -16,14 +16,14 @@ ...@@ -16,14 +16,14 @@
package org.springframework.cloud.netflix.feign.encoding; package org.springframework.cloud.netflix.feign.encoding;
import com.netflix.loadbalancer.BaseLoadBalancer; import java.util.Collections;
import com.netflix.loadbalancer.ILoadBalancer; import java.util.List;
import com.netflix.loadbalancer.Server;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.test.IntegrationTest; import org.springframework.boot.test.IntegrationTest;
import org.springframework.boot.test.SpringApplicationConfiguration; import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.cloud.netflix.feign.EnableFeignClients; import org.springframework.cloud.netflix.feign.EnableFeignClients;
...@@ -31,15 +31,15 @@ import org.springframework.cloud.netflix.feign.encoding.app.client.InvoiceClient ...@@ -31,15 +31,15 @@ import org.springframework.cloud.netflix.feign.encoding.app.client.InvoiceClient
import org.springframework.cloud.netflix.feign.encoding.app.domain.Invoice; import org.springframework.cloud.netflix.feign.encoding.app.domain.Invoice;
import org.springframework.cloud.netflix.ribbon.RibbonClient; import org.springframework.cloud.netflix.ribbon.RibbonClient;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration; import org.springframework.test.context.web.WebAppConfiguration;
import java.util.Collections; import com.netflix.loadbalancer.BaseLoadBalancer;
import java.util.List; import com.netflix.loadbalancer.ILoadBalancer;
import com.netflix.loadbalancer.Server;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
...@@ -50,50 +50,52 @@ import static org.junit.Assert.assertNotNull; ...@@ -50,50 +50,52 @@ import static org.junit.Assert.assertNotNull;
* @author Jakub Narloch * @author Jakub Narloch
*/ */
@WebAppConfiguration @WebAppConfiguration
@IntegrationTest({"server.port=0","feign.compression.request.enabled=true"}) @IntegrationTest({ "server.port=0", "feign.compression.request.enabled=true",
@SpringApplicationConfiguration(classes = {FeignContentEncodingTest.Application.class}) "hystrix.command.default.execution.isolation.strategy=SEMAPHORE",
"ribbon.OkToRetryOnAllOperations=false" })
@SpringApplicationConfiguration(classes = { FeignContentEncodingTest.Application.class })
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
public class FeignContentEncodingTest { public class FeignContentEncodingTest {
@Autowired @Autowired
private InvoiceClient invoiceClient; private InvoiceClient invoiceClient;
@Test @Test
public void compressedResponse() { public void compressedResponse() {
// given // given
final List<Invoice> invoices = Invoices.createInvoiceList(50); final List<Invoice> invoices = Invoices.createInvoiceList(50);
// when // when
final ResponseEntity<List<Invoice>> response = invoiceClient.saveInvoices(invoices); final ResponseEntity<List<Invoice>> response = this.invoiceClient
.saveInvoices(invoices);
// then // then
assertNotNull(response); assertNotNull(response);
assertEquals(HttpStatus.OK, response.getStatusCode()); assertEquals(HttpStatus.OK, response.getStatusCode());
assertNotNull(response.getBody()); assertNotNull(response.getBody());
assertEquals(invoices.size(), response.getBody().size()); assertEquals(invoices.size(), response.getBody().size());
} }
@EnableFeignClients(clients = InvoiceClient.class) @EnableFeignClients(clients = InvoiceClient.class)
@RibbonClient(name = "local", configuration = LocalRibbonClientConfiguration.class) @RibbonClient(name = "local", configuration = LocalRibbonClientConfiguration.class)
@ComponentScan("org.springframework.cloud.netflix.feign.encoding.app") @SpringBootApplication(scanBasePackages = "org.springframework.cloud.netflix.feign.encoding.app")
@EnableAutoConfiguration public static class Application {
@Configuration }
public static class Application {
}
@Configuration @Configuration
static class LocalRibbonClientConfiguration { static class LocalRibbonClientConfiguration {
@Value("${local.server.port}") @Value("${local.server.port}")
private int port = 0; private int port = 0;
@Bean @Bean
public ILoadBalancer ribbonLoadBalancer() { public ILoadBalancer ribbonLoadBalancer() {
BaseLoadBalancer balancer = new BaseLoadBalancer(); BaseLoadBalancer balancer = new BaseLoadBalancer();
balancer.setServersList(Collections.singletonList(new Server("localhost", this.port))); balancer.setServersList(
return balancer; Collections.singletonList(new Server("localhost", this.port)));
} return balancer;
} }
}
} }
\ No newline at end of file
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
package org.springframework.cloud.netflix.feign.encoding.app.client; package org.springframework.cloud.netflix.feign.encoding.app.client;
import java.util.List;
import org.springframework.cloud.netflix.feign.FeignClient; import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.cloud.netflix.feign.encoding.app.domain.Invoice; import org.springframework.cloud.netflix.feign.encoding.app.domain.Invoice;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
...@@ -23,8 +25,6 @@ import org.springframework.http.ResponseEntity; ...@@ -23,8 +25,6 @@ import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import java.util.List;
/** /**
* Simple Feign client for retrieving the invoice list. * Simple Feign client for retrieving the invoice list.
* *
...@@ -33,10 +33,9 @@ import java.util.List; ...@@ -33,10 +33,9 @@ import java.util.List;
@FeignClient("local") @FeignClient("local")
public interface InvoiceClient { public interface InvoiceClient {
@RequestMapping(value = "invoices", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "invoices", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<List<Invoice>> getInvoices(); ResponseEntity<List<Invoice>> getInvoices();
@RequestMapping(value = "invoices", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, @RequestMapping(value = "invoices", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<List<Invoice>> saveInvoices(List<Invoice> invoices);
ResponseEntity<List<Invoice>> saveInvoices(List<Invoice> invoices);
} }
...@@ -220,7 +220,9 @@ public class EurekaClientConfigBean implements EurekaClientConfig, EurekaConstan ...@@ -220,7 +220,9 @@ public class EurekaClientConfigBean implements EurekaClientConfig, EurekaConstan
private int cacheRefreshExecutorExponentialBackOffBound = 10; private int cacheRefreshExecutorExponentialBackOffBound = 10;
/** /**
* Map of availability zone to fully qualified URLs to communicate with eureka server. * Map of availability zone to list of fully qualified URLs to communicate with eureka
* server. Each value can be a single URL or a comma separated list of alternative
* locations.
* *
* Typically the eureka server URLs carry protocol,host,port,context and version * Typically the eureka server URLs carry protocol,host,port,context and version
* information if any. Example: * information if any. Example:
......
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