Skip to content

Commit

Permalink
fix ci
Browse files Browse the repository at this point in the history
  • Loading branch information
kangzhaok committed Jul 29, 2024
1 parent 07cae34 commit e397c3a
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions sys/src/test/java/com/alibaba/nacos/sys/env/EnvUtilTest.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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));
}
}

0 comments on commit e397c3a

Please sign in to comment.