|
|
@ -57,16 +57,13 @@ import static org.mockito.ArgumentMatchers.anyString;
|
|
|
|
import static org.mockito.Mockito.doReturn;
|
|
|
|
import static org.mockito.Mockito.doReturn;
|
|
|
|
import static org.mockito.Mockito.mock;
|
|
|
|
import static org.mockito.Mockito.mock;
|
|
|
|
import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.GATEWAY_LOADBALANCER_RESPONSE_ATTR;
|
|
|
|
import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.GATEWAY_LOADBALANCER_RESPONSE_ATTR;
|
|
|
|
|
|
|
|
import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.GATEWAY_REQUEST_URL_ATTR;
|
|
|
|
|
|
|
|
|
|
|
|
@ExtendWith(MockitoExtension.class)
|
|
|
|
@ExtendWith(MockitoExtension.class)
|
|
|
|
public class EnhancedGatewayGlobalFilterTest {
|
|
|
|
public class EnhancedGatewayGlobalFilterTest {
|
|
|
|
|
|
|
|
|
|
|
|
private static MockedStatic<ApplicationContextAwareUtils> mockedApplicationContextAwareUtils;
|
|
|
|
private static MockedStatic<ApplicationContextAwareUtils> mockedApplicationContextAwareUtils;
|
|
|
|
@Mock
|
|
|
|
@Mock
|
|
|
|
private RpcEnhancementReporterProperties reporterProperties;
|
|
|
|
|
|
|
|
@Mock
|
|
|
|
|
|
|
|
private SDKContext sdkContext;
|
|
|
|
|
|
|
|
@Mock
|
|
|
|
|
|
|
|
Registration registration;
|
|
|
|
Registration registration;
|
|
|
|
@Mock
|
|
|
|
@Mock
|
|
|
|
ServerWebExchange exchange;
|
|
|
|
ServerWebExchange exchange;
|
|
|
@ -76,6 +73,10 @@ public class EnhancedGatewayGlobalFilterTest {
|
|
|
|
ServerHttpResponse response;
|
|
|
|
ServerHttpResponse response;
|
|
|
|
@Mock
|
|
|
|
@Mock
|
|
|
|
ServerHttpRequest request;
|
|
|
|
ServerHttpRequest request;
|
|
|
|
|
|
|
|
@Mock
|
|
|
|
|
|
|
|
private RpcEnhancementReporterProperties reporterProperties;
|
|
|
|
|
|
|
|
@Mock
|
|
|
|
|
|
|
|
private SDKContext sdkContext;
|
|
|
|
|
|
|
|
|
|
|
|
@BeforeAll
|
|
|
|
@BeforeAll
|
|
|
|
static void beforeAll() {
|
|
|
|
static void beforeAll() {
|
|
|
@ -87,7 +88,8 @@ public class EnhancedGatewayGlobalFilterTest {
|
|
|
|
StaticMetadataManager staticMetadataManager = mock(StaticMetadataManager.class);
|
|
|
|
StaticMetadataManager staticMetadataManager = mock(StaticMetadataManager.class);
|
|
|
|
doReturn(metadataLocalProperties).when(applicationContext).getBean(MetadataLocalProperties.class);
|
|
|
|
doReturn(metadataLocalProperties).when(applicationContext).getBean(MetadataLocalProperties.class);
|
|
|
|
doReturn(staticMetadataManager).when(applicationContext).getBean(StaticMetadataManager.class);
|
|
|
|
doReturn(staticMetadataManager).when(applicationContext).getBean(StaticMetadataManager.class);
|
|
|
|
mockedApplicationContextAwareUtils.when(ApplicationContextAwareUtils::getApplicationContext).thenReturn(applicationContext);
|
|
|
|
mockedApplicationContextAwareUtils.when(ApplicationContextAwareUtils::getApplicationContext)
|
|
|
|
|
|
|
|
.thenReturn(applicationContext);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@AfterAll
|
|
|
|
@AfterAll
|
|
|
@ -123,6 +125,7 @@ public class EnhancedGatewayGlobalFilterTest {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
doReturn(serviceInstanceResponse).when(exchange).getAttribute(GATEWAY_LOADBALANCER_RESPONSE_ATTR);
|
|
|
|
doReturn(serviceInstanceResponse).when(exchange).getAttribute(GATEWAY_LOADBALANCER_RESPONSE_ATTR);
|
|
|
|
|
|
|
|
doReturn(new URI("http://0.0.0.0/")).when(exchange).getAttribute(GATEWAY_REQUEST_URL_ATTR);
|
|
|
|
doReturn(request).when(exchange).getRequest();
|
|
|
|
doReturn(request).when(exchange).getRequest();
|
|
|
|
doReturn(response).when(exchange).getResponse();
|
|
|
|
doReturn(response).when(exchange).getResponse();
|
|
|
|
|
|
|
|
|
|
|
|