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

xiaoyu 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 fa9168e52 [type:bug] fix test bug. (#3999)
fa9168e52 is described below

commit fa9168e521d4aae085eba867d0ed3f6ba00e284d
Author: yunlongn <[email protected]>
AuthorDate: Mon Sep 26 19:51:13 2022 +0800

    [type:bug] fix test bug. (#3999)
---
 .../client/http/utils/SystemUtilsTest.java         | 23 ++--------------------
 1 file changed, 2 insertions(+), 21 deletions(-)

diff --git 
a/shenyu-register-center/shenyu-register-client/shenyu-register-client-http/src/test/java/org/apache/shenyu/register/client/http/utils/SystemUtilsTest.java
 
b/shenyu-register-center/shenyu-register-client/shenyu-register-client-http/src/test/java/org/apache/shenyu/register/client/http/utils/SystemUtilsTest.java
index 49de6a4cc..c4f04f825 100644
--- 
a/shenyu-register-center/shenyu-register-client/shenyu-register-client-http/src/test/java/org/apache/shenyu/register/client/http/utils/SystemUtilsTest.java
+++ 
b/shenyu-register-center/shenyu-register-client/shenyu-register-client-http/src/test/java/org/apache/shenyu/register/client/http/utils/SystemUtilsTest.java
@@ -17,15 +17,9 @@
 
 package org.apache.shenyu.register.client.http.utils;
 
+import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 
-import java.util.Optional;
-import java.util.Properties;
-
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
 /**
  * Test case for {@link SystemUtils}.
  */
@@ -33,19 +27,6 @@ class SystemUtilsTest {
 
     @Test
     void getOsNameTest() {
-        final Properties properties = System.getProperties();
-        try {
-            final Optional<String> osName = SystemUtils.getOsName();
-            if (osName.isPresent() && 
!osName.get().toLowerCase().contains("mac")) {
-                final Properties mock = mock(Properties.class);
-                System.setProperties(mock);
-                
when(mock.getProperty(anyString())).thenThrow(SecurityException.class);
-                SystemUtils.getOsName();
-            }
-        } catch (Exception e) {
-            System.setProperties(properties);
-        } finally {
-            System.setProperties(properties);
-        }
+        Assertions.assertDoesNotThrow(SystemUtils::getOsName);
     }
 }

Reply via email to