PtlCapabilities extends DesiredCapabilities { static List<Map<String, Object>> readCapabilitiesFromFileOrResources(String filePath) { LOG.trace("Load capabilities. ({})", filePath); TypeReference<List<Map<String, Object>>> reference = new TypeReference<List<Map<String, Object>>>() { }; try { return JSONUtils.readValue(new File(filePath), reference); } catch (JSONException e) { InputStream in = null; try { in = PtlCapabilities.class.getClassLoader().getResourceAsStream(filePath); return JSONUtils.readValue(in, reference); } catch (Exception e1) { throw new TestRuntimeException("Failed to load capabilities", e1); } finally { if (in != null) { try { in.close(); } catch (IOException ioe) { LOG.error("", ioe); } } } } } PtlCapabilities(Map<String, ?> rawMap);  PtlCapabilities(Capabilities other); static List<PtlCapabilities[]> readCapabilities(); String getPlatformName(); String getPlatformVersion(); String getDeviceName();  }
@Test public void capabilitiesをデフォルトパスから読み込み() throws Exception { String filePath = new EnvironmentConfig().getCapabilitiesFilePath(); List<Map<String, Object>> result = PtlCapabilities.readCapabilitiesFromFileOrResources(filePath); ObjectMapper mapper = new ObjectMapper(); JsonNode expected = mapper.readValue(getClass().getClassLoader().getResource(filePath), JsonNode.class); assertThat(result.size(), is(expected.size())); }