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

zhangzicheng 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 5ef58ea28 HashLoadBalancer unit test (#4383)
5ef58ea28 is described below

commit 5ef58ea28f5f493e2ffd79111bea733e58b77de9
Author: iwangjie <[email protected]>
AuthorDate: Fri Mar 24 14:19:27 2023 +0800

    HashLoadBalancer unit test (#4383)
    
    * HashLoadBalancer unit test
    
    * fix ci.
    
    ---------
    
    Co-authored-by: likeguo <[email protected]>
    Co-authored-by: xiaoyu <[email protected]>
    Co-authored-by: dragon-zhang <[email protected]>
---
 .../loadbalancer/spi/HashLoadBalancerTest.java     | 45 ++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git 
a/shenyu-loadbalancer/src/test/java/org/apache/shenyu/loadbalancer/spi/HashLoadBalancerTest.java
 
b/shenyu-loadbalancer/src/test/java/org/apache/shenyu/loadbalancer/spi/HashLoadBalancerTest.java
new file mode 100644
index 000000000..e7c9d1fca
--- /dev/null
+++ 
b/shenyu-loadbalancer/src/test/java/org/apache/shenyu/loadbalancer/spi/HashLoadBalancerTest.java
@@ -0,0 +1,45 @@
+/*
+ * 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.loadbalancer.spi;
+
+import org.apache.shenyu.loadbalancer.entity.Upstream;
+import org.junit.jupiter.api.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * HashLoadBalancer unit test.
+ */
+class HashLoadBalancerTest {
+
+    @Test
+    void doSelectWithSuccess() {
+        final HashLoadBalancer hashLoadBalancer = new HashLoadBalancer();
+        final List<Upstream> upstreamList = new ArrayList<>();
+        upstreamList.add(Upstream.builder().url("http://1.1.1.1/api";).build());
+        upstreamList.add(Upstream.builder().url("http://2.2.2.2/api";).build());
+        upstreamList.add(Upstream.builder().url("http://3.3.3.3/api";).build());
+
+        final Upstream upstream = hashLoadBalancer.doSelect(upstreamList, 
"127.0.0.1");
+        assertEquals(upstreamList.get(2).getUrl(), upstream.getUrl());
+    }
+
+}

Reply via email to