• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements.  See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License.  You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 package org.apache.commons.lang3;
19 
20 import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
21 import static org.junit.jupiter.api.Assertions.assertNotNull;
22 import static org.junit.jupiter.api.Assertions.assertNull;
23 import org.junit.jupiter.api.Test;
24 
25 public class SystemPropertiesTest {
26 
isJava11OrGreater()27     private boolean isJava11OrGreater() {
28         return SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_11);
29     }
30 
31     @Test
testGetAwtToolkit()32     public void testGetAwtToolkit() {
33         assertDoesNotThrow(SystemProperties::getAwtToolkit);
34     }
35 
36     @Test
testGetFileEncoding()37     public void testGetFileEncoding() {
38         assertNotNull(SystemProperties.getFileEncoding());
39     }
40 
41     @Test
testGetFileSeparator()42     public void testGetFileSeparator() {
43         assertNotNull(SystemProperties.getFileSeparator());
44     }
45 
46     @Test
testGetJavaAwtFonts()47     public void testGetJavaAwtFonts() {
48         assertNull(SystemProperties.getJavaAwtFonts());
49     }
50 
51     @Test
testGetJavaAwtGraphicsenv()52     public void testGetJavaAwtGraphicsenv() {
53         assertDoesNotThrow(SystemProperties::getJavaAwtGraphicsenv);
54     }
55 
56     @Test
testGetJavaAwtHeadless()57     public void testGetJavaAwtHeadless() {
58         assertNull(SystemProperties.getJavaAwtHeadless());
59     }
60 
61     @Test
testGetJavaAwtPrinterjob()62     public void testGetJavaAwtPrinterjob() {
63         assertDoesNotThrow(SystemProperties::getJavaAwtPrinterjob);
64     }
65 
66     @Test
testGetJavaClassPath()67     public void testGetJavaClassPath() {
68         assertNotNull(SystemProperties.getJavaClassPath());
69     }
70 
71     @Test
testGetJavaClassVersion()72     public void testGetJavaClassVersion() {
73         assertNotNull(SystemProperties.getJavaClassVersion());
74     }
75 
76     @Test
testGetJavaCompiler()77     public void testGetJavaCompiler() {
78         if (SystemUtils.IS_JAVA_14) {
79             // Not in Java 11
80             assertNotNull(SystemProperties.getJavaCompiler());
81         }
82     }
83 
84     @Test
testGetJavaEndorsedDirs()85     public void testGetJavaEndorsedDirs() {
86         if (isJava11OrGreater()) {
87             // Not in Java 11
88             assertNull(SystemProperties.getJavaEndorsedDirs());
89         } else {
90             assertNotNull(SystemProperties.getJavaExtDirs());
91         }
92     }
93 
94     @Test
testGetJavaExtDirs()95     public void testGetJavaExtDirs() {
96         if (isJava11OrGreater()) {
97             // Not in Java 11
98             assertNull(SystemProperties.getJavaExtDirs());
99         } else {
100             assertNotNull(SystemProperties.getJavaExtDirs());
101         }
102     }
103 
104     @Test
testGetJavaHome()105     public void testGetJavaHome() {
106         assertNotNull(SystemProperties.getJavaHome());
107     }
108 
109     @Test
testGetJavaIoTmpdir()110     public void testGetJavaIoTmpdir() {
111         assertNotNull(SystemProperties.getJavaIoTmpdir());
112     }
113 
114     @Test
testGetJavaLibraryPath()115     public void testGetJavaLibraryPath() {
116         assertNotNull(SystemProperties.getJavaLibraryPath());
117     }
118 
119     @Test
testGetJavaRuntimeName()120     public void testGetJavaRuntimeName() {
121         assertNotNull(SystemProperties.getJavaRuntimeName());
122     }
123 
124     @Test
testGetJavaRuntimeVersion()125     public void testGetJavaRuntimeVersion() {
126         assertNotNull(SystemProperties.getJavaRuntimeVersion());
127     }
128 
129     @Test
testGetJavaSpecificationName()130     public void testGetJavaSpecificationName() {
131         assertNotNull(SystemProperties.getJavaSpecificationName());
132     }
133 
134     @Test
testGetJavaSpecificationVendor()135     public void testGetJavaSpecificationVendor() {
136         assertNotNull(SystemProperties.getJavaSpecificationVendor());
137     }
138 
139     @Test
testGetJavaSpecificationVersion()140     public void testGetJavaSpecificationVersion() {
141         assertNotNull(SystemProperties.getJavaSpecificationVersion());
142     }
143 
144     @Test
testGetJavaUtilPrefsPreferencesFactory()145     public void testGetJavaUtilPrefsPreferencesFactory() {
146         assertNull(SystemProperties.getJavaUtilPrefsPreferencesFactory());
147     }
148 
149     @Test
testGetJavaVendor()150     public void testGetJavaVendor() {
151         assertNotNull(SystemProperties.getJavaVendor());
152     }
153 
154     @Test
testGetJavaVendorUrl()155     public void testGetJavaVendorUrl() {
156         assertNotNull(SystemProperties.getJavaVendorUrl());
157     }
158 
159     @Test
testGetJavaVersion()160     public void testGetJavaVersion() {
161         assertNotNull(SystemProperties.getJavaVersion());
162     }
163 
164     @Test
testGetJavaVmInfo()165     public void testGetJavaVmInfo() {
166         assertNotNull(SystemProperties.getJavaVmInfo());
167     }
168 
169     @Test
testGetJavaVmName()170     public void testGetJavaVmName() {
171         assertNotNull(SystemProperties.getJavaVmName());
172     }
173 
174     @Test
testGetJavaVmSpecificationName()175     public void testGetJavaVmSpecificationName() {
176         assertNotNull(SystemProperties.getJavaVmSpecificationName());
177     }
178 
179     @Test
testGetJavaVmSpecificationVendor()180     public void testGetJavaVmSpecificationVendor() {
181         assertNotNull(SystemProperties.getJavaVmSpecificationVendor());
182     }
183 
184     @Test
testGetJavaVmSpecificationVersion()185     public void testGetJavaVmSpecificationVersion() {
186         assertNotNull(SystemProperties.getJavaVmSpecificationVersion());
187     }
188 
189     @Test
testGetJavaVmVendor()190     public void testGetJavaVmVendor() {
191         assertNotNull(SystemProperties.getJavaVmVendor());
192     }
193 
194     @Test
testGetJavaVmVersion()195     public void testGetJavaVmVersion() {
196         assertNotNull(SystemProperties.getJavaVmVersion());
197     }
198 
199     @Test
testGetLineSeparator()200     public void testGetLineSeparator() {
201         assertNotNull(SystemProperties.getLineSeparator());
202     }
203 
204     @Test
testGetOsArch()205     public void testGetOsArch() {
206         assertNotNull(SystemProperties.getOsArch());
207     }
208 
209     @Test
testGetOsName()210     public void testGetOsName() {
211         assertNotNull(SystemProperties.getOsName());
212     }
213 
214     @Test
testGetOsVersion()215     public void testGetOsVersion() {
216         assertNotNull(SystemProperties.getOsVersion());
217     }
218 
219     @Test
testGetPathSeparator()220     public void testGetPathSeparator() {
221         assertNotNull(SystemProperties.getPathSeparator());
222     }
223 
224     @Test
testGetUserCountry()225     public void testGetUserCountry() {
226         assertDoesNotThrow(SystemProperties::getUserCountry);
227     }
228 
229     @Test
testGetUserDir()230     public void testGetUserDir() {
231         assertNotNull(SystemProperties.getUserDir());
232     }
233 
234     @Test
testGetUserHome()235     public void testGetUserHome() {
236         assertNotNull(SystemProperties.getUserHome());
237     }
238 
239     @Test
testGetUserLanguage()240     public void testGetUserLanguage() {
241         assertNotNull(SystemProperties.getUserLanguage());
242     }
243 
244     @Test
testGetUserName()245     public void testGetUserName() {
246         assertNotNull(SystemProperties.getUserName());
247     }
248 
249     @Test
testGetUserTimezone()250     public void testGetUserTimezone() {
251         assertDoesNotThrow(SystemProperties::getUserTimezone);
252     }
253 
254 }
255