Direct-BT v3.3.0-1-gc2d430c
Direct-BT - Direct Bluetooth Programming.
TestSystemPropsAndEnvs.java
Go to the documentation of this file.
1/**
2 * Author: Sven Gothel <sgothel@jausoft.com>
3 * Copyright (c) 2021 Gothel Software e.K.
4 * Copyright (c) 2012 Gothel Software e.K.
5 * Copyright (c) 2012 JogAmp Community.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining
8 * a copy of this software and associated documentation files (the
9 * "Software"), to deal in the Software without restriction, including
10 * without limitation the rights to use, copy, modify, merge, publish,
11 * distribute, sublicense, and/or sell copies of the Software, and to
12 * permit persons to whom the Software is furnished to do so, subject to
13 * the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be
16 * included in all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 */
26
27package jau.test.sys;
28
29import java.io.IOException;
30import java.util.Iterator;
31import java.util.Map;
32import java.util.Properties;
33
34import org.junit.FixMethodOrder;
35import org.junit.Test;
36import org.junit.runners.MethodSorters;
37
38import jau.test.junit.util.JunitTracer;
39
40@FixMethodOrder(MethodSorters.NAME_ASCENDING)
41public class TestSystemPropsAndEnvs extends JunitTracer {
42
43 @Test
44 public void dumpProperties() {
45 int i=0;
46 final Properties props = System.getProperties();
47 final Iterator<Map.Entry<Object,Object>> iter = props.entrySet().iterator();
48 while (iter.hasNext()) {
49 i++;
50 final Map.Entry<Object, Object> entry = iter.next();
51 System.out.format("%4d: %s = %s%n", i, entry.getKey(), entry.getValue());
52 }
53 System.out.println("Property count: "+i);
54 }
55
56 private static String[] suppress_envs = new String[] { "COOKIE", "SSH", "GPG" };
57
58 private static boolean contains(final String data, final String[] search) {
59 if(null != data && null != search) {
60 for(int i=0; i<search.length; i++) {
61 if(data.indexOf(search[i]) >= 0) {
62 return true;
63 }
64 }
65 }
66 return false;
67 }
68
69 @Test
70 public void dumpEnvironment() {
71 int i=0;
72 final Map<String, String> env = System.getenv();
73 for (final String envName : env.keySet()) {
74 if(!contains(envName, suppress_envs)) {
75 i++;
76 System.out.format("%4d: %s = %s%n",
77 i, envName,
78 env.get(envName));
79 }
80 }
81 System.out.println("Environment count: "+i);
82 }
83
84 public static void main(final String args[]) throws IOException {
85 final String tstname = TestSystemPropsAndEnvs.class.getName();
86 org.junit.runner.JUnitCore.main(tstname);
87 }
88
89}
static void main(final String args[])