public static Properties getProperties(String resourceFile, boolean isResource) { Properties props = new Properties(); String propertiesString = getResourceAsString(resourceFile, isResource); try { props.load(new StringReader(propertiesString)); } catch (IOException e) { throw new RuntimeException("Unable to load resources from string", e); } return props; }
private static String getContent(String filename) { return FileUtil.getResourceAsString("/compose/" + filename, true); }
private static String getContent(String filename) { return FileUtil.getResourceAsString("/compose/" + filename, true); }
public static String getContent(String filename) { return FileUtil.getResourceAsString("/compose/" + filename, true); }
private SslTrustCertificateState createSslTrustCert() throws Throwable { if (this.sslTrustCert != null) { return this.sslTrustCert; } String sslTrustPem = FileUtil.getResourceAsString("/certs/ca.pem", true).trim(); SslTrustCertificateState sslTrustCert = new SslTrustCertificateState(); sslTrustCert.certificate = sslTrustPem; return createEntity(sslTrustCert, SslTrustCertificateService.FACTORY_LINK); }
private void startExternalPopularImagesService(String resourcesPath) { Path filePath = Paths.get(resourcesPath, POPULAR_IMAGES_FILE); if (!filePath.toFile().exists()) { logInfo("Skip loading popular images from user resource path."); return; } else { logInfo("Loading popular images from user resource path..."); } File file = filePath.toFile(); try { Utils.fromJson(FileUtil.getResourceAsString(file.getAbsolutePath(), false), Collection.class); } catch (Exception e) { logWarning("Error validating popular images file content: %s", e.getMessage()); return; } Operation post = Operation.createPost(UriUtils.buildUri(getHost(), EXTERNAL_LINK)); FileContentService fcs = new FileContentService(file); getHost().startService(post, fcs); }
@Test public void testGetResourceAsString() { String resourceString = FileUtil.getResourceAsString(TEST_RESOURCE_PROPERTIES_FILE, true); assertNotNull(resourceString); assertTrue(resourceString.contains(BUILD_NUMBER_PROPERTY_KEY)); }