use of java.util.Properties in project hadoop by apache.
the class TestFileSignerSecretProvider method testGetSecrets.
@Test
public void testGetSecrets() throws Exception {
File testDir = new File(System.getProperty("test.build.data", "target/test-dir"));
testDir.mkdirs();
String secretValue = "hadoop";
File secretFile = new File(testDir, "http-secret.txt");
Writer writer = new FileWriter(secretFile);
writer.write(secretValue);
writer.close();
FileSignerSecretProvider secretProvider = new FileSignerSecretProvider();
Properties secretProviderProps = new Properties();
secretProviderProps.setProperty(AuthenticationFilter.SIGNATURE_SECRET_FILE, secretFile.getAbsolutePath());
secretProvider.init(secretProviderProps, null, -1);
Assert.assertArrayEquals(secretValue.getBytes(), secretProvider.getCurrentSecret());
byte[][] allSecrets = secretProvider.getAllSecrets();
Assert.assertEquals(1, allSecrets.length);
Assert.assertArrayEquals(secretValue.getBytes(), allSecrets[0]);
}
use of java.util.Properties in project hadoop by apache.
the class TestSigner method createStringSignerSecretProvider.
private StringSignerSecretProvider createStringSignerSecretProvider() throws Exception {
StringSignerSecretProvider secretProvider = new StringSignerSecretProvider();
Properties secretProviderProps = new Properties();
secretProviderProps.setProperty(AuthenticationFilter.SIGNATURE_SECRET, "secret");
secretProvider.init(secretProviderProps, null, -1);
return secretProvider;
}
use of java.util.Properties in project hadoop by apache.
the class TestConfigurationSubclass method testGetProps.
public void testGetProps() {
SubConf conf = new SubConf(true);
Properties properties = conf.getProperties();
assertNotNull("hadoop.tmp.dir is not set", properties.getProperty("hadoop.tmp.dir"));
}
use of java.util.Properties in project hadoop by apache.
the class TestConfigurationSubclass method testReload.
public void testReload() throws Throwable {
SubConf conf = new SubConf(true);
assertFalse(conf.isReloaded());
Configuration.addDefaultResource(EMPTY_CONFIGURATION_XML);
assertTrue(conf.isReloaded());
Properties properties = conf.getProperties();
}
use of java.util.Properties in project flink by apache.
the class EnvironmentInformation method getRevisionInformation.
/**
* Returns the code revision (commit and commit date) of Flink, as generated by the Maven builds.
*
* @return The code revision.
*/
public static RevisionInformation getRevisionInformation() {
String revision = UNKNOWN;
String commitDate = UNKNOWN;
try (InputStream propFile = EnvironmentInformation.class.getClassLoader().getResourceAsStream(".version.properties")) {
if (propFile != null) {
Properties properties = new Properties();
properties.load(propFile);
String propRevision = properties.getProperty("git.commit.id.abbrev");
String propCommitDate = properties.getProperty("git.commit.time");
revision = propRevision != null ? propRevision : UNKNOWN;
commitDate = propCommitDate != null ? propCommitDate : UNKNOWN;
}
} catch (Throwable t) {
if (LOG.isDebugEnabled()) {
LOG.debug("Cannot determine code revision: Unable to read version property file.", t);
} else {
LOG.info("Cannot determine code revision: Unable to read version property file.");
}
}
return new RevisionInformation(revision, commitDate);
}
Aggregations