MCPcopy Index your code
hub / github.com/OpenTSDB/opentsdb / TestConfigArgP

Class TestConfigArgP

test/tools/TestConfigArgP.java:73–626  ·  view source on GitHub ↗

Title: TestConfigArgP Description: Test cases for the fat-jar launcher configuration manager

Source from the content-addressed store, hash-verified

71 * <p>Description: Test cases for the fat-jar launcher configuration manager</p>
72 */
73public class TestConfigArgP {
74 /** The number of cores available to this JVM */
75 static final int CORES = ManagementFactory.getOperatingSystemMXBean().getAvailableProcessors();
76 /** Platform EOL */
77 static final String EOL = System.getProperty("line.separator", "\n");
78 /** The quickie web server */
79 static QuickieWebServer webServer = null;
80 /** The port the web server is listening on */
81 static int port = -1;
82 /** true/false string values */
83 static final Set<String> trueFalseValues = Collections.unmodifiableSet(new HashSet<String>(Arrays.asList("true", "false")));
84
85 static final boolean runningFatJar;
86
87 static {
88 boolean tmp = false;
89 InputStream is = null;
90 try {
91 is = TestConfigArgP.class.getClassLoader().getResourceAsStream("opentsdb.conf.json");
92 BufferedReader bin = new BufferedReader(new InputStreamReader(is));
93 StringBuilder b = new StringBuilder();
94 String line = null;
95 while((line = bin.readLine())!=null) {
96 b.append(line);
97 }
98 JSONObject jo = new JSONObject(b.toString());
99 tmp = true;
100 } catch (Exception x) {
101 tmp = false;
102 } finally {
103 if(is!=null) try { is.close(); } catch (Exception x) {/* No Op */}
104 }
105 runningFatJar = tmp;
106 }
107
108 /**
109 * Loads a fresh new JSONObject with the config
110 * from the classpath loaded <code>opentsdb.conf.json</code>.
111 * @return A loaded JSONObject
112 */
113 static JSONObject newTSDBConfig() {
114 InputStream is = null;
115 try {
116 is = TestConfigArgP.class.getClassLoader().getResourceAsStream("opentsdb.conf.json");
117 BufferedReader bin = new BufferedReader(new InputStreamReader(is));
118 StringBuilder b = new StringBuilder();
119 String line = null;
120 while((line = bin.readLine())!=null) {
121 b.append(line);
122 }
123 return new JSONObject(b.toString());
124 } catch (Exception ex) {
125 throw new RuntimeException("Failed to load opentsdb.conf.json from the classpath", ex);
126 } finally {
127 if(is!=null) try { is.close(); } catch (Exception x) {/* No Op */}
128 }
129 }
130

Callers

nothing calls this directly

Calls 3

appendMethod · 0.45
toStringMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…