From e397c3a0cb5c904b98fe511c84b2305a134ec8f5 Mon Sep 17 00:00:00 2001 From: zhoakang <172639487@qq.com> Date: Mon, 29 Jul 2024 10:29:44 +0800 Subject: [PATCH] fix ci --- .../alibaba/nacos/sys/env/EnvUtilTest.java | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/sys/src/test/java/com/alibaba/nacos/sys/env/EnvUtilTest.java b/sys/src/test/java/com/alibaba/nacos/sys/env/EnvUtilTest.java index e1b2bb9548e..f9fdd2ef216 100644 --- a/sys/src/test/java/com/alibaba/nacos/sys/env/EnvUtilTest.java +++ b/sys/src/test/java/com/alibaba/nacos/sys/env/EnvUtilTest.java @@ -1,7 +1,24 @@ +/* + * Copyright 1999-2020 Alibaba Group Holding Ltd. + * + * Licensed 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 com.alibaba.nacos.sys.env; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; + import org.junit.jupiter.api.Test; import org.mockito.MockedStatic; import org.mockito.Mockito; @@ -25,12 +42,12 @@ void after() { } @Test - public void test() { - systemBeanManagerMocked.when(() -> OperatingSystemBeanManager.getFreePhysicalMem()).thenReturn(123l); - systemBeanManagerMocked.when(() -> OperatingSystemBeanManager.getTotalPhysicalMem()).thenReturn(2048l); - assertEquals(EnvUtil.getMem(), 1 - ((double) 123 / (double) 2048)); + public void testGetMem() { + systemBeanManagerMocked.when(() -> OperatingSystemBeanManager.getFreePhysicalMem()).thenReturn(123L); + systemBeanManagerMocked.when(() -> OperatingSystemBeanManager.getTotalPhysicalMem()).thenReturn(2048L); + assertEquals(EnvUtil.getMem(), 1 - ((double) 123L / (double) 2048L)); - systemBeanManagerMocked.when(() -> OperatingSystemBeanManager.getFreePhysicalMem()).thenReturn(0l); - assertEquals(EnvUtil.getMem(), 1 - ((double) 0 / (double) 2048)); + systemBeanManagerMocked.when(() -> OperatingSystemBeanManager.getFreePhysicalMem()).thenReturn(0L); + assertEquals(EnvUtil.getMem(), 1 - ((double) 0L / (double) 2048L)); } }