use of org.apache.shenyu.common.dto.PluginData in project incubator-shenyu by apache.
the class ZookeeperDataChangedListener method onPluginChanged.
@Override
public void onPluginChanged(final List<PluginData> changed, final DataEventTypeEnum eventType) {
for (PluginData data : changed) {
String pluginPath = DefaultPathConstants.buildPluginPath(data.getName());
// delete
if (eventType == DataEventTypeEnum.DELETE) {
deleteZkPathRecursive(pluginPath);
String selectorParentPath = DefaultPathConstants.buildSelectorParentPath(data.getName());
deleteZkPathRecursive(selectorParentPath);
String ruleParentPath = DefaultPathConstants.buildRuleParentPath(data.getName());
deleteZkPathRecursive(ruleParentPath);
continue;
}
// create or update
insertZkNode(pluginPath, data);
}
}
use of org.apache.shenyu.common.dto.PluginData in project incubator-shenyu by apache.
the class SyncDataServiceTest method syncAllTest.
@Test
public void syncAllTest() {
PluginData pluginData = buildPluginData();
SelectorData selectorData = buildSelectorData();
RuleData ruleData = buildRuleData();
given(this.appAuthService.syncData()).willReturn(ShenyuAdminResult.success());
given(this.pluginService.listAll()).willReturn(Collections.singletonList(pluginData));
given(this.selectorService.listAll()).willReturn(Collections.singletonList(selectorData));
given(this.ruleService.listAll()).willReturn(Collections.singletonList(ruleData));
assertThat(syncDataService.syncAll(DataEventTypeEnum.CREATE), greaterThan(false));
}
use of org.apache.shenyu.common.dto.PluginData in project incubator-shenyu by apache.
the class BaseDataCacheTest method testCleanPluginData.
@Test
public void testCleanPluginData() throws NoSuchFieldException, IllegalAccessException {
PluginData firstCachedPluginData = PluginData.builder().name(mockName1).build();
PluginData secondCachedPluginData = PluginData.builder().name(mockName2).build();
ConcurrentHashMap<String, PluginData> pluginMap = getFieldByName(pluginMapStr);
pluginMap.put(mockName1, firstCachedPluginData);
pluginMap.put(mockName2, secondCachedPluginData);
assertNotNull(pluginMap.get(mockName1));
assertNotNull(pluginMap.get(mockName2));
BaseDataCache.getInstance().cleanPluginData();
assertNull(pluginMap.get(mockName1));
assertNull(pluginMap.get(mockName2));
}
use of org.apache.shenyu.common.dto.PluginData in project incubator-shenyu by apache.
the class BaseDataCacheTest method testCachePluginData.
@Test
public void testCachePluginData() throws NoSuchFieldException, IllegalAccessException {
PluginData pluginData = PluginData.builder().name(mockName1).build();
ConcurrentHashMap<String, PluginData> pluginMap = getFieldByName(pluginMapStr);
assertNull(pluginMap.get(mockName1));
BaseDataCache.getInstance().cachePluginData(pluginData);
assertNotNull(pluginMap.get(mockName1));
assertEquals(pluginData, pluginMap.get(mockName1));
}
use of org.apache.shenyu.common.dto.PluginData in project incubator-shenyu by apache.
the class CommonPluginDataSubscriberTest method testUnSubscribe.
@Test
public void testUnSubscribe() {
baseDataCache.cleanPluginData();
PluginData pluginData = PluginData.builder().name(mockName1).build();
baseDataCache.cachePluginData(pluginData);
assertNotNull(baseDataCache.obtainPluginData(pluginData.getName()));
commonPluginDataSubscriber.unSubscribe(pluginData);
assertNull(baseDataCache.obtainPluginData(pluginData.getName()));
}
Aggregations