polish

parent ac1ac4d5
......@@ -8,19 +8,17 @@ import org.junit.Before;
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.SpringApplication;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.cloud.netflix.ribbon.RibbonClient;
import org.springframework.cloud.netflix.ribbon.StaticServerList;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
import org.springframework.cloud.netflix.zuul.RoutesEndpoint;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
......@@ -39,21 +37,21 @@ import com.netflix.zuul.context.RequestContext;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.springframework.cloud.netflix.zuul.filters.discovery.PatternServiceRouteMapperIntegrationTests.SERVICE_ID;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
/**
* @author Stéphane Leroy
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = SampleCustomZuulProxyApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT, value = {
"spring.application.name=regex-test-application", "spring.jmx.enabled=false",
@SpringBootTest(webEnvironment = RANDOM_PORT,
properties = { "spring.application.name=regex-test-application", "spring.jmx.enabled=false",
"eureka.client.enabled=false" })
@DirtiesContext
public class PatternServiceRouteMapperIntegrationTests {
protected static final String SERVICE_ID = "domain-service-v1";
@Value("${local.server.port}")
@LocalServerPort
private int port;
@Autowired
......@@ -94,14 +92,12 @@ public class PatternServiceRouteMapperIntegrationTests {
assertEquals("Get 1", result.getBody());
}
}
@Configuration
@EnableAutoConfiguration
@RestController
@EnableZuulProxy
@RibbonClient(value = SERVICE_ID, configuration = SimpleRibbonClientConfiguration.class)
class SampleCustomZuulProxyApplication {
@SpringBootConfiguration
@EnableAutoConfiguration
@RestController
@EnableZuulProxy
@RibbonClient(value = SERVICE_ID, configuration = SimpleRibbonClientConfiguration.class)
protected static class SampleCustomZuulProxyApplication {
@Bean
public DiscoveryClient discoveryClient() {
......@@ -124,19 +120,16 @@ class SampleCustomZuulProxyApplication {
"${version}/${domain}/${name}");
}
public static void main(String[] args) {
SpringApplication.run(SampleCustomZuulProxyApplication.class, args);
}
}
@Configuration
class SimpleRibbonClientConfiguration {
protected static class SimpleRibbonClientConfiguration {
@Value("${local.server.port}")
@LocalServerPort
private int port = 0;
@Bean
public ServerList<Server> ribbonServerList() {
return new StaticServerList<>(new Server("localhost", this.port));
}
}
}
......@@ -19,6 +19,7 @@ package org.springframework.cloud.netflix.zuul.filters.post;
import com.netflix.util.Pair;
import com.netflix.zuul.context.RequestContext;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.springframework.cloud.netflix.zuul.filters.Route;
......@@ -57,6 +58,12 @@ public class LocationRewriteFilterTests {
RequestContext.testSetCurrentContext(context);
}
@After
public void reset() {
RequestContext.getCurrentContext().clear();
}
@Test
public void shouldRewriteLocationHeadersWithRoutePrefix() {
RequestContext context = RequestContext.getCurrentContext();
......
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