View Javadoc
1   /*
2    * Copyright 2017-2022 The OSHI Project Contributors
3    * SPDX-License-Identifier: MIT
4    */
5   package oshi.software.os;
6   
7   import static org.hamcrest.MatcherAssert.assertThat;
8   import static org.hamcrest.Matchers.is;
9   import static org.hamcrest.Matchers.notNullValue;
10  
11  import org.junit.jupiter.api.Test;
12  
13  import oshi.SystemInfo;
14  
15  /**
16   * Test network parameters
17   */
18  class NetworkParamsTest {
19  
20      /**
21       * Test network parameters
22       */
23      @Test
24      void testNetworkParams() {
25          SystemInfo si = new SystemInfo();
26          NetworkParams params = si.getOperatingSystem().getNetworkParams();
27          assertThat("Network parameters hostname is null.", params.getHostName(), is(notNullValue()));
28          assertThat("Network parameters domain name is null.", params.getDomainName(), is(notNullValue()));
29          assertThat("Network parameters DNS server is null.", params.getDnsServers(), is(notNullValue()));
30          assertThat("Network parameters IPv4 default gateway is null.", params.getIpv4DefaultGateway(),
31                  is(notNullValue()));
32          assertThat("Network parameters IPv6 default gateway is null.", params.getIpv6DefaultGateway(),
33                  is(notNullValue()));
34      }
35  }