You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by de...@apache.org on 2023/05/03 12:55:36 UTC
[shenyu] branch master updated: Add test case for PortUtils.findPort (#4604)
This is an automated email from the ASF dual-hosted git repository.
dengliming 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 a6c7831af Add test case for PortUtils.findPort (#4604)
a6c7831af is described below
commit a6c7831afefd735f273b98ba137453efe97a35f0
Author: VampireAchao <ac...@gmail.com>
AuthorDate: Wed May 3 20:55:28 2023 +0800
Add test case for PortUtils.findPort (#4604)
* upgrade hutool 5.8.18
* add test case for PortUtils.findPort
* add file header opensource licence
* add file header opensource licence
---------
Co-authored-by: VampireAchao <va...@dromara.org>
Co-authored-by: xiaoyu <xi...@apache.org>
Co-authored-by: likeguo <33...@users.noreply.github.com>
---
shenyu-client/shenyu-client-core/pom.xml | 10 ++++++
.../shenyu/client/core/utils/PortUtilsTest.java | 42 ++++++++++++++++++++++
2 files changed, 52 insertions(+)
diff --git a/shenyu-client/shenyu-client-core/pom.xml b/shenyu-client/shenyu-client-core/pom.xml
index 62a39f863..db9b3cb0b 100644
--- a/shenyu-client/shenyu-client-core/pom.xml
+++ b/shenyu-client/shenyu-client-core/pom.xml
@@ -96,5 +96,15 @@
<artifactId>spring-web</artifactId>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-tomcat</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
diff --git a/shenyu-client/shenyu-client-core/src/test/java/org/apache/shenyu/client/core/utils/PortUtilsTest.java b/shenyu-client/shenyu-client-core/src/test/java/org/apache/shenyu/client/core/utils/PortUtilsTest.java
new file mode 100644
index 000000000..47399d121
--- /dev/null
+++ b/shenyu-client/shenyu-client-core/src/test/java/org/apache/shenyu/client/core/utils/PortUtilsTest.java
@@ -0,0 +1,42 @@
+/*
+ * 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.client.core.utils;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.support.DefaultListableBeanFactory;
+import org.springframework.beans.factory.support.GenericBeanDefinition;
+import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
+
+/**
+ * Test for {@link PortUtils}.
+ */
+public class PortUtilsTest {
+
+ @Test
+ public void testFindPort() {
+ DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
+ GenericBeanDefinition beanDefinition = new GenericBeanDefinition();
+ beanDefinition.setBeanClass(TomcatServletWebServerFactory.class);
+ beanFactory.registerBeanDefinition("webServerFactory", beanDefinition);
+
+ int port = PortUtils.findPort(beanFactory);
+ Assertions.assertEquals(8080, port);
+ }
+
+}