This is an automated email from the ASF dual-hosted git repository.

Aias00 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git


The following commit(s) were added to refs/heads/master by this push:
     new 936eef8b56 feat: invoke refresh method in DiscoveryUpstreamDataHandler 
and add unit tests (#6956)
936eef8b56 is described below

commit 936eef8b5615d7befe95bb2a1cecf5801a7cabb0
Author: Limbo <[email protected]>
AuthorDate: Sat Sep 5 10:52:16 2026 +0800

    feat: invoke refresh method in DiscoveryUpstreamDataHandler and add unit 
tests (#6956)
    
    Co-authored-by: aias00 <[email protected]>
---
 .../handler/DiscoveryUpstreamDataHandler.java      |  1 +
 .../handler/DiscoveryUpstreamDataHandlerTest.java  | 48 ++++++++++++++++++++++
 2 files changed, 49 insertions(+)

diff --git 
a/shenyu-sync-data-center/shenyu-sync-data-websocket/src/main/java/org/apache/shenyu/plugin/sync/data/websocket/handler/DiscoveryUpstreamDataHandler.java
 
b/shenyu-sync-data-center/shenyu-sync-data-websocket/src/main/java/org/apache/shenyu/plugin/sync/data/websocket/handler/DiscoveryUpstreamDataHandler.java
index 44f74be754..295f93114d 100644
--- 
a/shenyu-sync-data-center/shenyu-sync-data-websocket/src/main/java/org/apache/shenyu/plugin/sync/data/websocket/handler/DiscoveryUpstreamDataHandler.java
+++ 
b/shenyu-sync-data-center/shenyu-sync-data-websocket/src/main/java/org/apache/shenyu/plugin/sync/data/websocket/handler/DiscoveryUpstreamDataHandler.java
@@ -38,6 +38,7 @@ public class DiscoveryUpstreamDataHandler extends 
AbstractDataHandler<DiscoveryS
 
     @Override
     protected void doRefresh(final List<DiscoverySyncData> dataList) {
+        
discoveryUpstreamDataSubscribers.forEach(DiscoveryUpstreamDataSubscriber::refresh);
         dataList.forEach(data -> discoveryUpstreamDataSubscribers.forEach(p -> 
p.onSubscribe(data)));
     }
 
diff --git 
a/shenyu-sync-data-center/shenyu-sync-data-websocket/src/test/java/org/apache/shenyu/plugin/sync/data/websocket/handler/DiscoveryUpstreamDataHandlerTest.java
 
b/shenyu-sync-data-center/shenyu-sync-data-websocket/src/test/java/org/apache/shenyu/plugin/sync/data/websocket/handler/DiscoveryUpstreamDataHandlerTest.java
new file mode 100644
index 0000000000..7f0c204077
--- /dev/null
+++ 
b/shenyu-sync-data-center/shenyu-sync-data-websocket/src/test/java/org/apache/shenyu/plugin/sync/data/websocket/handler/DiscoveryUpstreamDataHandlerTest.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.plugin.sync.data.websocket.handler;
+
+import org.apache.shenyu.common.dto.DiscoverySyncData;
+import org.apache.shenyu.sync.data.api.DiscoveryUpstreamDataSubscriber;
+import org.junit.jupiter.api.Test;
+import org.mockito.InOrder;
+
+import java.util.Arrays;
+import java.util.Collections;
+
+import static org.mockito.Mockito.inOrder;
+import static org.mockito.Mockito.mock;
+
+public final class DiscoveryUpstreamDataHandlerTest {
+
+    @Test
+    public void testDoRefresh() {
+        DiscoveryUpstreamDataSubscriber firstSubscriber = 
mock(DiscoveryUpstreamDataSubscriber.class);
+        DiscoveryUpstreamDataSubscriber secondSubscriber = 
mock(DiscoveryUpstreamDataSubscriber.class);
+        DiscoveryUpstreamDataHandler handler = new 
DiscoveryUpstreamDataHandler(Arrays.asList(firstSubscriber, secondSubscriber));
+        DiscoverySyncData data = new DiscoverySyncData();
+
+        handler.doRefresh(Collections.singletonList(data));
+
+        InOrder inOrder = inOrder(firstSubscriber, secondSubscriber);
+        inOrder.verify(firstSubscriber).refresh();
+        inOrder.verify(secondSubscriber).refresh();
+        inOrder.verify(firstSubscriber).onSubscribe(data);
+        inOrder.verify(secondSubscriber).onSubscribe(data);
+    }
+}

Reply via email to