[type:bug] fix test bug.
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);
}
}
