Search in sources :

Example 46 with MetaData

use of org.apache.shenyu.common.dto.MetaData in project incubator-shenyu by apache.

the class AlibabaDubboConfigCacheTest method testInitRef.

@Test
public void testInitRef() {
    MetaData metaData = new MetaData();
    metaData.setPath("/test");
    AlibabaDubboConfigCache alibabaDubboConfigCacheMock = mock(AlibabaDubboConfigCache.class);
    when(alibabaDubboConfigCacheMock.initRef(metaData)).thenReturn(new ReferenceConfig<>());
    assertNotNull(alibabaDubboConfigCacheMock.initRef(metaData));
}
Also used : MetaData(org.apache.shenyu.common.dto.MetaData) Test(org.junit.jupiter.api.Test)

Example 47 with MetaData

use of org.apache.shenyu.common.dto.MetaData in project incubator-shenyu by apache.

the class AlibabaDubboConfigCacheTest method testBuild.

@Test
public void testBuild() {
    DubboParam dubboParam = new DubboParam();
    dubboParam.setVersion("2.6.5");
    dubboParam.setGroup("Group");
    dubboParam.setUrl("http://192.168.55.113/dubbo");
    MetaData metaData = new MetaData();
    metaData.setRpcExt(GsonUtils.getInstance().toJson(dubboParam));
    AlibabaDubboConfigCache alibabaDubboConfigCacheMock = mock(AlibabaDubboConfigCache.class);
    when(alibabaDubboConfigCacheMock.build(metaData)).thenReturn(new ReferenceConfig<>());
    assertNotNull(alibabaDubboConfigCacheMock.build(metaData));
}
Also used : DubboParam(org.apache.shenyu.plugin.dubbo.common.cache.DubboParam) MetaData(org.apache.shenyu.common.dto.MetaData) Test(org.junit.jupiter.api.Test)

Example 48 with MetaData

use of org.apache.shenyu.common.dto.MetaData in project incubator-shenyu by apache.

the class AlibabaDubboPluginDataTest method setUp.

@BeforeEach
public void setUp() {
    alibabaDubboPluginDataHandler = new AlibabaDubboPluginDataHandler();
    MetaData metaData = new MetaData();
    metaData.setId("1332017966661636096");
    metaData.setAppName("dubbo");
    metaData.setPath("/dubbo/findAll");
    metaData.setServiceName("org.apache.shenyu.test.dubbo.api.service.DubboTestService");
    metaData.setMethodName("findAll");
    assertNotNull(metaData);
}
Also used : MetaData(org.apache.shenyu.common.dto.MetaData) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 49 with MetaData

use of org.apache.shenyu.common.dto.MetaData in project incubator-shenyu by apache.

the class SofaMetaDataSubscriber method onSubscribe.

@Override
public void onSubscribe(final MetaData metaData) {
    if (RpcTypeEnum.SOFA.getName().equals(metaData.getRpcType())) {
        MetaData exist = META_DATA.get(metaData.getPath());
        if (Objects.isNull(exist) || Objects.isNull(ApplicationConfigCache.getInstance().get(exist.getPath()).refer())) {
            // The first initialization
            ApplicationConfigCache.getInstance().initRef(metaData);
        } else {
            if (!exist.getServiceName().equals(metaData.getServiceName()) || !exist.getRpcExt().equals(metaData.getRpcExt())) {
                // update
                ApplicationConfigCache.getInstance().build(metaData);
            }
        }
        META_DATA.put(metaData.getPath(), metaData);
    }
}
Also used : MetaData(org.apache.shenyu.common.dto.MetaData)

Example 50 with MetaData

use of org.apache.shenyu.common.dto.MetaData in project incubator-shenyu by apache.

the class SofaProxyServiceTest method setup.

@BeforeEach
public void setup() {
    exchange = MockServerWebExchange.from(MockServerHttpRequest.get("localhost").build());
    metaData = new MetaData();
    metaData.setId("1332017966661636096");
    metaData.setAppName("sofa");
    metaData.setPath(PATH);
    metaData.setServiceName("org.apache.shenyu.test.dubbo.api.service.DubboTestService");
    metaData.setMethodName(METHOD_NAME);
    metaData.setRpcType(RpcTypeEnum.SOFA.getName());
}
Also used : MetaData(org.apache.shenyu.common.dto.MetaData) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

MetaData (org.apache.shenyu.common.dto.MetaData)70 Test (org.junit.jupiter.api.Test)31 BeforeEach (org.junit.jupiter.api.BeforeEach)14 RuleData (org.apache.shenyu.common.dto.RuleData)11 SelectorData (org.apache.shenyu.common.dto.SelectorData)10 ShenyuContext (org.apache.shenyu.plugin.api.context.ShenyuContext)9 ArrayList (java.util.ArrayList)8 MetaDataSubscriber (org.apache.shenyu.sync.data.api.MetaDataSubscriber)8 ServerWebExchange (org.springframework.web.server.ServerWebExchange)7 Objects (java.util.Objects)6 ShenyuException (org.apache.shenyu.common.exception.ShenyuException)6 Logger (org.slf4j.Logger)6 LoggerFactory (org.slf4j.LoggerFactory)6 Optional (java.util.Optional)5 Constants (org.apache.shenyu.common.constant.Constants)5 ShenyuPluginChain (org.apache.shenyu.plugin.api.ShenyuPluginChain)5 UnsupportedEncodingException (java.io.UnsupportedEncodingException)4 ResultEnum (org.apache.shenyu.common.enums.ResultEnum)4 RpcTypeEnum (org.apache.shenyu.common.enums.RpcTypeEnum)4 GsonUtils (org.apache.shenyu.common.utils.GsonUtils)4