Polish test

parent 14c1d461
...@@ -17,6 +17,9 @@ ...@@ -17,6 +17,9 @@
package org.springframework.cloud.netflix.zuul.filters.route; package org.springframework.cloud.netflix.zuul.filters.route;
import com.netflix.zuul.context.RequestContext;
import org.junit.After;
import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
...@@ -34,11 +37,21 @@ import java.util.concurrent.atomic.AtomicInteger; ...@@ -34,11 +37,21 @@ import java.util.concurrent.atomic.AtomicInteger;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(value = { "zuul.routes.myroute.service-id=eager", @SpringBootTest(properties = { "zuul.routes.eagerroute.service-id=eager",
"zuul.ribbon.eager-load.enabled=true" }) "zuul.ribbon.eager-load.enabled=true" })
@DirtiesContext @DirtiesContext
public class EagerLoadOfZuulConfigurationTests { public class EagerLoadOfZuulConfigurationTests {
@Before
public void setTestRequestContext() {
RequestContext context = new RequestContext();
RequestContext.testSetCurrentContext(context);
}
@After
public void clear() {
RequestContext.getCurrentContext().clear();
}
@Test @Test
public void testEagerLoading() { public void testEagerLoading() {
// Child context FooConfig should have been eagerly instantiated.. // Child context FooConfig should have been eagerly instantiated..
......
...@@ -19,6 +19,7 @@ package org.springframework.cloud.netflix.zuul.filters.route; ...@@ -19,6 +19,7 @@ package org.springframework.cloud.netflix.zuul.filters.route;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import org.junit.After; import org.junit.After;
import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
...@@ -46,14 +47,21 @@ import static org.assertj.core.api.Assertions.assertThat; ...@@ -46,14 +47,21 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = RANDOM_PORT, value = { @SpringBootTest(webEnvironment = RANDOM_PORT, properties = {
"zuul.routes.myroute.service-id=lazy", "zuul.routes.myroute.path=/lazy/**" }) "zuul.routes.lazyroute.service-id=lazy", "zuul.routes.lazyroute.path=/lazy/**",
"zuul.ribbon.eager-load.enabled=false"})
@DirtiesContext @DirtiesContext
public class LazyLoadOfZuulConfigurationTests { public class LazyLoadOfZuulConfigurationTests {
@LocalServerPort @LocalServerPort
protected int port; protected int port;
@Before
public void setTestRequestContext() {
RequestContext context = new RequestContext();
RequestContext.testSetCurrentContext(context);
}
@After @After
public void clear() { public void clear() {
RequestContext.getCurrentContext().clear(); RequestContext.getCurrentContext().clear();
......
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