use of org.apache.shenyu.plugin.api.context.ShenyuContext in project incubator-shenyu by apache.
the class ApacheDubboPluginTest method skip.
@Test
public void skip() {
final ServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("localhost").build());
ShenyuContext context = mock(ShenyuContext.class);
when(context.getRpcType()).thenReturn(RpcTypeEnum.DUBBO.getName());
exchange.getAttributes().put(Constants.CONTEXT, context);
exchange.getAttributes().put(Constants.META_DATA, metaData);
final boolean result = apacheDubboPlugin.skip(exchange);
assertFalse(result);
}
use of org.apache.shenyu.plugin.api.context.ShenyuContext in project incubator-shenyu by apache.
the class RpcParamTransformPluginTest method testSimpleBody.
/**
* Test simple body.
*/
@Test
public void testSimpleBody() {
ServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.post("localhost").body("test"));
Mockito.when(chain.execute(exchange)).thenReturn(Mono.empty());
ShenyuContext context = new ShenyuContext();
context.setRpcType(RpcTypeEnum.DUBBO.getName());
exchange.getAttributes().put(Constants.CONTEXT, context);
Mono<Void> result = rpcParamTransformPlugin.execute(exchange, chain);
StepVerifier.create(result).expectSubscription().verifyComplete();
}
use of org.apache.shenyu.plugin.api.context.ShenyuContext in project incubator-shenyu by apache.
the class AlibabaDubboPluginTest method testAlibabaDubboPlugin.
@Test
public void testAlibabaDubboPlugin() {
final ServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("localhost").remoteAddress(new InetSocketAddress("127.0.0.1", 20880)).build());
ShenyuContext context = mock(ShenyuContext.class);
when(context.getRpcType()).thenReturn(RpcTypeEnum.DUBBO.getName());
exchange.getAttributes().put(Constants.CONTEXT, context);
exchange.getAttributes().put(Constants.META_DATA, metaData);
ShenyuPluginChain chain = mock(ShenyuPluginChain.class);
when(chain.execute(exchange)).thenReturn(Mono.empty());
RuleData data = mock(RuleData.class);
SelectorData selectorData = mock(SelectorData.class);
Mono<Void> voidMono = alibabaDubboPluginUnderTest.doExecute(exchange, chain, selectorData, data);
StepVerifier.create(voidMono).expectSubscription().verifyComplete();
}
use of org.apache.shenyu.plugin.api.context.ShenyuContext in project incubator-shenyu by apache.
the class AlibabaDubboPluginTest method testAlibabaDubboPluginMetaDataNull.
@Test
public void testAlibabaDubboPluginMetaDataNull() {
final ServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("localhost").remoteAddress(new InetSocketAddress("127.0.0.1", 20880)).build());
ShenyuContext context = mock(ShenyuContext.class);
when(context.getRpcType()).thenReturn(RpcTypeEnum.DUBBO.getName());
exchange.getAttributes().put(Constants.CONTEXT, context);
exchange.getAttributes().put(Constants.META_DATA, new MetaData());
ShenyuPluginChain chain = mock(ShenyuPluginChain.class);
when(chain.execute(exchange)).thenReturn(Mono.empty());
RuleData data = mock(RuleData.class);
SelectorData selectorData = mock(SelectorData.class);
try (MockedStatic<ShenyuResultWrap> shenyuResultWrapMockedStatic = mockStatic(ShenyuResultWrap.class)) {
shenyuResultWrapMockedStatic.when(() -> ShenyuResultWrap.error(exchange, ShenyuResultEnum.DUBBO_HAVE_BODY_PARAM, null)).thenReturn(new Object());
Mono<Void> voidMono = alibabaDubboPluginUnderTest.doExecute(exchange, chain, selectorData, data);
StepVerifier.create(voidMono).expectSubscription().verifyComplete();
}
}
use of org.apache.shenyu.plugin.api.context.ShenyuContext in project incubator-shenyu by apache.
the class AlibabaDubboPluginTest method testSkip.
@Test
public void testSkip() {
final ServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("localhost").build());
ShenyuContext context = mock(ShenyuContext.class);
when(context.getRpcType()).thenReturn(RpcTypeEnum.DUBBO.getName());
exchange.getAttributes().put(Constants.CONTEXT, context);
exchange.getAttributes().put(Constants.META_DATA, metaData);
final boolean result = alibabaDubboPluginUnderTest.skip(exchange);
assertFalse(result);
}
Aggregations